/* 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; }

/* ------------------------------------------------------------ subcontracted order: issues, deliveries, inspection, close production, settings */
.mrp-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mrp-sec-head .form-section { margin: 0; flex: 1 1 auto; }
.mrp-totals { display: grid; gap: 8px; margin-block: 8px 12px; }
.mrp-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.mrp-tot { display: grid; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-tot b { font-size: 20px; font-variant-numeric: tabular-nums; }
.mrp-tot.tone-ok b { color: var(--ok-ink); }
.mrp-tot.tone-bad b { color: var(--danger-ink); }
.mrp-tot.tone-wait b { color: var(--info-ink); }
.mrp-prog { display: flex; block-size: 10px; border-radius: 999px; overflow: hidden; background: var(--panel-3); }
.mrp-prog i { display: block; block-size: 100%; }
.mrp-prog i.ok { background: var(--ok); }
.mrp-prog i.bad { background: var(--danger); }
.mrp-prog i.wait { background: var(--info); }
.mrp-hint { margin-block: 8px; }
.mrp-wait { max-inline-size: 190px; }
.mrp-dlv { display: grid; gap: 2px; }
.mrp-dlv-main { display: grid; gap: 2px; min-inline-size: 170px; text-align: start; }
.mrp-lines > div { white-space: nowrap; }
.mrp-st { display: grid; gap: 6px; justify-items: start; }
.mrp-act-row { display: flex; align-items: center; justify-content: flex-start; gap: 6px; flex-wrap: wrap; }
.mrp-dlv-table .mrp-del { width: auto; white-space: normal; }
.mrp-insp, .mrp-close { display: grid; gap: 14px; }
.mrp-insp input[type=number], .mrp-insp input[type=text], .mrp-insp select, .mrp-insp textarea, .mrp-close textarea { inline-size: 100%; min-block-size: 44px; }
.mrp-insp input[type=number] { font-variant-numeric: tabular-nums; }
.mrp-sum { padding: 8px 12px; border-radius: var(--r-sm); font-weight: 650; }
.mrp-sum.ok { background: var(--ok-soft); color: var(--ok-ink); }
.mrp-sum.bad { background: var(--danger-soft); color: var(--danger-ink); }
.mrp-rejects { display: grid; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-rejects[hidden], .mrp-split[hidden] { display: none; }
.mrp-check { display: flex; align-items: center; gap: 10px; min-block-size: 44px; cursor: pointer; }
.mrp-check input { inline-size: 20px; block-size: 20px; }
.mrp-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mrp-split label { display: grid; gap: 4px; }
.mrp-qc { display: grid; gap: 8px; }
.mrp-qc .form-section { margin: 0; }
.mrp-qc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mrp-qc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-qc-main { display: grid; gap: 4px; min-inline-size: 0; }
.mrp-qc-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mrp-insp .mrp-qc-measure { inline-size: 110px; }
.mrp-close-sum { padding: 12px 14px; border-radius: var(--r-sm); background: var(--accent-soft); }
.mrp-close-sum .form-section { margin: 0 0 6px; }
.mrp-close-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; }
.mrp-waste { font-variant-numeric: tabular-nums; }
.mrp-waste.warn { color: var(--warn-ink); }
.mrp-waste.bad { color: var(--danger-ink); }
.mrp-closed { display: flex; align-items: flex-start; gap: 6px; margin-top: 10px; line-height: 1.5; }
.mrp-settings { display: grid; gap: 4px; }
.mrp-set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 12px; border-bottom: 1px solid var(--line); }
.mrp-set-row:last-child { border-bottom: 0; }
.mrp-set-row > div { flex: 1 1 320px; min-inline-size: 0; }
.mrp-set-row select { min-block-size: 44px; max-inline-size: 100%; padding-inline: 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); }

/* ------------------------------------------------------------ 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-table td.mrp-lines { flex-wrap: wrap; }   /* several component lines in one cell: one under the other (the row of the card laid them side by side, on top of each other) */
  .mrp-table td.mrp-lines > div { flex: 0 0 100%; white-space: normal; text-align: end; }
  .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%; }
  .mrp-dlv-main { min-inline-size: 0; }
  .mrp-dlv-table .mrp-del { justify-content: flex-end; }
  .mrp-st { justify-items: end; text-align: end; }
  .mrp-act-row { justify-content: flex-end; }
  .mrp-act-row .btn { min-height: 44px; }
  .mrp-split { grid-template-columns: minmax(0, 1fr); }
  .mrp-wait { max-inline-size: none; }
  .mrp-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mrp-edit td input[type=number] { max-width: 60%; min-width: 90px; }
  /* 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; } }

/* ------------------------------------------------------------ product pictures (.pthumb is in orders.css) and the scan buttons */
.mrp-prod { display: flex; align-items: center; gap: 10px; min-inline-size: 0; }
.mrp-prod > div { min-inline-size: 0; overflow-wrap: anywhere; }
.mrp-prod-head { margin-block-end: 12px; align-items: flex-start; }
.mrp-scan { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 8px; }
:root:root .mrp-scan .btn { min-block-size: 44px; }
@media (max-width: 720px) { :root:root .mrp-scan .btn { flex: 1 1 100%; } }

/* ------------------------------------------------------------ costing rule, lots and traceability, WIP reconciliation */
.mrp-costing, .mrp-rec, .mrp-trace-detail { display: grid; gap: 16px; }
.mrp-rule-main { display: grid; gap: 4px; margin-block-end: 8px; }
.mrp-rule-name { font-size: 20px; color: var(--accent-d); }
.mrp-rule-counts { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.mrp-methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mrp-method { display: grid; gap: 6px; align-content: start; justify-items: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-method.on { border-color: var(--accent); background: var(--accent-soft); }
.mrp-method p { margin: 0; }
.mrp-pct { display: flex; align-items: center; gap: 8px; }
.mrp-pct input { max-inline-size: 140px; }
.mrp-pending { border-color: var(--warn); }
.mrp-method-hint { margin-block: 6px 0; }
.mrp-costing select, .mrp-costing textarea, .mrp-costing input[type=number] { inline-size: 100%; min-block-size: 44px; }
.mrp-rule-tag { margin-block-start: 4px; }

.mrp-rec .ord-banner.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.mrp-rec .ord-banner.ok > .ico { color: var(--ok-ink); }
.mrp-rec-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.mrp-rec-card.bad { border-color: var(--danger); }
.mrp-rec-card.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }

/* lots: chips on the order, the "Choose lots" step */
.mrp-lots-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.mrp-lot { display: inline-flex; align-items: center; gap: 4px; min-block-size: 28px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); color: inherit; font-size: 13px; text-decoration: none; }
a.mrp-lot { color: var(--accent-d); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
a.mrp-lot:hover { background: var(--accent-soft); }
.mrp-lot.ghost { border-style: dashed; color: var(--muted); }
.mrp-lot small { color: var(--muted); }
.mrp-lotcell { min-inline-size: 150px; }
.mrp-lots { display: grid; gap: 14px; }
.mrp-lotline { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-lotline .mrp-edit td:first-child { min-width: 200px; }
.mrp-lotline .mrp-edit select { inline-size: 100%; }
.mrp-lot-sum { padding: 6px 10px; border-radius: var(--r-sm); background: var(--panel); }
.mrp-lot-sum.ok { background: var(--ok-soft); color: var(--ok-ink); }
.mrp-lot-sum.warn { background: var(--warn-soft); color: var(--warn-ink); }
.mrp-lot-sum.bad { background: var(--danger-soft); color: var(--danger-ink); }
.mrp-design { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }

/* traceability */
.mrp-trace { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.mrp-trace-pick { display: grid; gap: 10px; position: sticky; top: 8px; max-block-size: calc(100vh - 24px); overflow: auto; }
.mrp-trace-pick .toolbar { display: grid; gap: 8px; }
.mrp-trace-list { display: grid; gap: 8px; }
.mrp-trace-detail { scroll-margin-top: 72px; }
.mrp-lotcard { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; text-align: start; inline-size: 100%; min-block-size: 56px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); color: inherit; cursor: pointer; font: inherit; }
.mrp-lotcard:hover { border-color: var(--accent); }
.mrp-lotcard.on { border-color: var(--accent); background: var(--accent-soft); }
.mrp-lotcard-main { display: grid; gap: 2px; min-inline-size: 0; overflow-wrap: anywhere; }
.mrp-lotcard-side { display: grid; justify-items: end; gap: 2px; text-align: end; }
.mrp-lotcard-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.mrp-trace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.mrp-trace-sum .kv-list { margin-block-start: 6px; }
.mrp-tree { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.mrp-tree .mrp-tree { margin-inline-start: 14px; padding-inline-start: 12px; border-inline-start: 2px solid var(--line); }
.mrp-node { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel-2); }
.mrp-node > .mrp-tree { grid-column: 1 / -1; }
.mrp-node-main { min-inline-size: 0; overflow-wrap: anywhere; }
.mrp-node-qty { font-variant-numeric: tabular-nums; font-weight: 700; text-align: end; }
.mrp-node-sub { grid-column: 1 / -1; overflow-wrap: anywhere; }
.mrp-sub-title { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.mrp-lotlink { font-weight: 700; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .mrp-trace { grid-template-columns: minmax(0, 1fr); }
  .mrp-trace-pick { position: static; max-block-size: none; }
  .mrp-trace.open .mrp-trace-detail { order: -1; }
  .mrp-trace-grid { grid-template-columns: minmax(0, 1fr); }
  .mrp-methods { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .mrp-lotline .mrp-edit td:first-child { min-width: 0; }
  .mrp-lotline .mrp-edit select { max-width: 100%; min-height: 44px; }
  .mrp-lot, a.mrp-lot { min-block-size: 44px; padding-inline: 12px; }
  .mrp-lotcard { min-block-size: 56px; }
  .mrp-pct input { max-inline-size: none; }
  .mrp-costing .mrp-actions .btn { min-height: 48px; }
}
