/* Manufacturing app (mrp-*): tokens from admin.css only, logical properties, light + dark through the tokens, phone first at 375 px.
   Loaded by public/js/admin/modules/mrp/kit.js (useCss) and linked in admin.html. Shared brand-kit rules (bk-*, kpi, ord-banner) come from orders.css. */

/* ------------------------------------------------------------ tables (components, operations, costs, lists) */
.mrp-table-wrap { overflow-x: auto; }
.mrp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mrp-table th { text-align: start; font-size: 12px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mrp-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mrp-table th.num, .mrp-table td.num { text-align: end; font-variant-numeric: tabular-nums; }
.mrp-table tbody tr:last-child td { border-bottom: 0; }
.mrp-table .mrp-del { text-align: end; white-space: nowrap; width: 1%; }
.mrp-table .mrp-del .btn { min-height: 40px; }
.mrp-edit input:not([type=checkbox]), .mrp-edit select, .mrp-extra-add input, .mrp-edit .ss-input { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); outline: 0; }
.mrp-edit input:focus, .mrp-edit select:focus, .mrp-extra-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.mrp-edit td { min-width: 110px; }
.mrp-edit td:first-child { min-width: 220px; }
.mrp-dim { opacity: .4; }
.mrp-short-row td { background: var(--danger-soft); }
.mrp-bad { color: var(--danger-ink); font-weight: 700; }
.mrp-short ul { margin: 4px 0; padding-inline-start: 18px; }
.mrp-late > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
[dir="rtl"] .mrp-late > td:first-child { box-shadow: inset -3px 0 0 var(--danger); }
.mrp-main { display: grid; gap: 2px; }
.mrp-phone-meta { display: none; }
.mrp-kcard { display: grid; gap: 4px; }
.mrp-kc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ------------------------------------------------------------ new order, BoM card, extra costs */
.mrp-new { display: grid; gap: 16px; }
.mrp-bomcard { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); padding: 12px 14px; display: grid; gap: 10px; }
.mrp-bomhead { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.mrp-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mrp-card-head { display: flex; align-items: center; gap: 8px; }
.mrp-card-head h3 { flex: 1; }
.mrp-unit { font-size: 20px; color: var(--accent-d); font-variant-numeric: tabular-nums; }
.mrp-explain { margin-top: 10px; line-height: 1.5; }
.mrp-extras { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mrp-extra { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-extra-add { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-top: 10px; }
.mrp-extra-add .field-error { grid-column: 1 / -1; }
.mrp-entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mrp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.mrp-list li { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--line); }
.mrp-list li:last-child { border-bottom: 0; }
.mrp-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrp-pk { display: grid; gap: 10px; justify-items: start; }
.mrp-sc-total { display: flex; align-items: center; gap: 10px; margin: 10px 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--accent-soft); }
.mrp-sc-total b { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--accent-d); }
.mrp-bar-split { display: flex; min-width: 140px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--panel-3); }
.mrp-bar-split i { display: block; height: 100%; }

/* ------------------------------------------------------------ variant chips, "applies to" */
.mrp-chips { display: flex; align-items: center; gap: 6px; overflow-x: auto; padding-block: 4px; scrollbar-width: thin; }
.mrp-chips[hidden] { display: none; }
.mrp-chip { flex: 0 0 auto; min-height: 36px; padding-inline: 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: inherit; font-weight: 650; cursor: pointer; }
.mrp-chip:hover { border-color: var(--accent); }
.mrp-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-d); }
.mrp-apply-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding-inline: 10px; max-width: 260px; border: 1px dashed var(--line); border-radius: var(--r-sm); background: var(--panel); color: var(--muted); cursor: pointer; text-align: start; }
.mrp-apply-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrp-apply-btn.on { border-style: solid; border-color: var(--accent); color: var(--accent-d); background: var(--accent-soft); }
.mrp-apply-btn:disabled { opacity: .5; cursor: default; }
.mrp-apply { display: grid; gap: 12px; }
.mrp-apply-group { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.mrp-apply-group legend { padding-inline: 6px; font-weight: 700; }
.mrp-apply-vals { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.mrp-cost .muted { margin: 0 0 8px; }

/* ------------------------------------------------------------ phone action bar (the header buttons move to a bar above the bottom navigation) */
.mrp-bar { display: none; }

@media (max-width: 1100px) { .mrp-extra-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ------------------------------------------------------------ phone */
@media (max-width: 720px) {
  .mrp-phone-meta { display: block; }
  .mrp-table thead { display: none; }
  .mrp-table, .mrp-table tbody, .mrp-table tr, .mrp-table td { display: block; width: 100%; }
  .mrp-table tr { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); padding: 6px 10px; margin-bottom: 8px; }
  .mrp-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: end; min-height: 36px; }
  .mrp-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; text-align: start; flex: 0 0 auto; }
  .mrp-table td[data-label=""]::before, .mrp-table td:not([data-label])::before { content: none; }
  .mrp-table td > * { min-width: 0; }
  .mrp-edit td { min-width: 0; }
  .mrp-edit td:first-child { min-width: 0; display: block; text-align: start; }
  .mrp-edit td:first-child::before { display: block; margin-bottom: 4px; }
  .mrp-edit td input:not([type=checkbox]), .mrp-edit td select { max-width: 60%; }
  .mrp-table .mrp-del { width: 100%; justify-content: flex-end; }
  .mrp-apply-btn { max-width: 100%; min-height: 44px; }
  .mrp-chip { min-height: 44px; }
  .mrp-extra-add { grid-template-columns: minmax(0, 1fr); }
  .mrp-extra-add .btn { min-height: 48px; }
  .mrp-actions .btn { flex: 1 1 100%; }
  /* order page: the buttons go to a bar above the bottom navigation, 48 px tall */
  .mrp-doc { padding-bottom: 76px; }
  .mrp-doc .dh-actions { display: none; }
  .mrp-bar { display: flex; gap: 8px; position: fixed; inset-inline: 0; bottom: var(--bn-h); z-index: 30; padding: 10px max(14px, env(safe-area-inset-left)); background: var(--panel); border-top: 1px solid var(--line); box-shadow: var(--shadow-lg); }
  :root:root .mrp-bar .btn { flex: 1 1 0; min-height: 48px; font-size: 15px; }
  :root:root .mrp-bar .btn { min-width: 0; padding-inline: 10px; }
  :root:root .mrp-bar .btn.btn-danger-ghost { flex: 0 0 52px; }
  .mrp-bar .btn.btn-danger-ghost > span:not(.ico) { display: none; }
}
@media (max-width: 900px) and (max-height: 520px) { .mrp-bar { bottom: 0; } }
@media (pointer: coarse) { .mrp-chip, .mrp-apply-btn { min-height: 44px; } }
