:root {
  --sand: #F0EDE5;
  --ink: #120803;
  --paper: #FFFFFF;
  --hair: #C7C1B3;
  --muted: #5C554A;
  --amber: #F6C258;
  --stone: #D6CFBE;
  --locked: #E9E4D8;
  --warn: #71140C;
  --warn-bg: #F5DCD5;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--sand); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--ink); }
a:hover { color: var(--muted); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Top bar */
.topbar { background: var(--ink); color: var(--sand); display: flex; flex-wrap: wrap; gap: 12px 24px;
  align-items: center; justify-content: space-between; padding: 12px 32px; }
.topbar a { color: var(--sand); text-decoration: none; }
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand strong { font-size: 18px; font-weight: 700; }
.brand span { color: var(--stone); }
.whoami { display: flex; align-items: center; gap: 8px; color: var(--stone); font-size: 13px; }
.whoami input { font: inherit; width: 140px; padding: 5px 8px; border: 1px solid var(--muted);
  background: transparent; color: var(--sand); }
.whoami button { font: inherit; padding: 5px 10px; border: 1px solid var(--stone); background: transparent;
  color: var(--sand); cursor: pointer; }

main { padding: 24px 32px 64px; display: flex; flex-direction: column; gap: 20px; }
.crumbs { font-size: 13px; color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.page-head .meta { color: var(--muted); margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--ink); background: var(--paper); color: var(--ink); font: 600 14px var(--font);
  text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--sand); color: var(--ink); }
.btn-primary { background: var(--ink); color: var(--sand); }
.btn-primary:hover { background: #3a2f27; color: var(--sand); }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }

/* Messages */
.flash { padding: 10px 14px; background: var(--paper); border-left: 0; border-top: 3px solid var(--ink); }
.flash.error { border-top-color: var(--warn); color: var(--warn); }
.flash.success { border-top-color: var(--ink); }
.flash.info { border-top-color: var(--stone); }

/* Panels and tables */
.panel { background: var(--paper); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: baseline; }
.scroll { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px;
  border-bottom: 1px solid var(--hair); white-space: nowrap; }
table.t td { padding: 8px 10px; border-bottom: 1px solid #E4DFD4; vertical-align: middle; }
table.t tr.total td { background: var(--sand); font-weight: 700; border-bottom: 0; }
table.t tr.sub td { background: #F7F5F0; font-weight: 700; }
table.t tr.selected td { background: var(--stone); }
table.t th.num { text-align: right; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--paper); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--hair); }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
  margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 12.5px; font-weight: 600; }
.status.draft { background: var(--amber); }
.status.final { background: var(--ink); color: var(--sand); }
.status.none { border: 1px solid var(--muted); }

/* Work area: product list + grid */
.work { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.work > .side { flex: 1 1 250px; max-width: 300px; background: var(--paper); max-height: 78vh; overflow-y: auto; }
.work > .main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.plist a { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 14px; text-decoration: none;
  border-bottom: 1px solid #E4DFD4; }
.plist a[aria-current="true"] { background: var(--stone); }
.plist .d { font-size: 12.5px; color: var(--muted); grid-column: 1 / -1; }

/* Planning grid */
table.grid { border-collapse: separate; border-spacing: 3px; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 4px 6px; white-space: nowrap; }
table.grid th.rowhead, table.grid td.rowhead { text-align: left; position: sticky; left: 0; background: var(--paper);
  z-index: 1; min-width: 120px; padding-right: 12px; }
table.grid th.arrival { color: var(--ink); }
table.grid th .small { font-weight: 400; }
table.grid td { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
  position: relative; min-width: 64px; }
table.grid td.locked { background: var(--locked); }
table.grid td.ly-fc { background: var(--locked); color: var(--muted); font-style: italic; }
table.grid td.calc { border-bottom: 1px solid #E4DFD4; }
table.grid td.sugg { font-style: italic; color: var(--muted); }
table.grid td.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
table.grid td.order { background: var(--ink); color: var(--sand); font-weight: 700; }
table.grid td.order.blocked { background: var(--stone); color: var(--muted); }
table.grid td.total { background: var(--sand); font-weight: 700; }
table.grid td.edit { padding: 0; }
table.grid tr.sub td:not(.rowhead) { background: #F7F5F0; font-weight: 700; }
table.grid input { width: 72px; font: inherit; text-align: right; padding: 6px 8px; border: 1px solid var(--muted);
  background: var(--paper); color: var(--ink); font-variant-numeric: tabular-nums; }
table.grid input.changed { background: var(--amber); border-color: var(--ink); font-weight: 700; }
table.grid input.carried { border-bottom: 4px solid var(--muted); padding-bottom: 3px; }
table.grid input:disabled { background: transparent; border-color: var(--hair); color: var(--ink); }
/* B1: the order override on a locked month: greyed, any old value struck through (it isn't used) */
table.grid td.edit.is-locked { background: var(--locked); }
table.grid td.edit.is-locked input:disabled { color: var(--muted); text-decoration: line-through; }
.already-note { margin: 0 0 10px; }
.locked-note.frozen-note { background: #E3ECF5; border-left-color: #2C4A78; }
.frozen-btn { border-color: #2C4A78; color: #2C4A78; }
.ev-summary { margin: 0 0 10px; }
.ev-table tbody.ig { border-top: 1px solid #D9D2C3; }
.ev-table .ig-row th, .ev-table .ig-row td { font-weight: 600; }
.ev-table .ig-line th { font-weight: 400; padding-left: 26px; }
.js .ev-table tbody.ig:not(.open) .ig-line { display: none; }
.ev-table tbody.ig.open .ig-toggle .chev { transform: rotate(90deg); }
.ev-moves { margin-top: 10px; }
.move-btn { font-size: 11px; font-weight: 600; }
.ochip .move-btn { color: #71140C; margin-top: 2px; text-align: left; }
.drop-effects { margin: 0; padding-left: 18px; }
.drop-effects .warn { color: #71140C; }
.ochip.earlier { background: #F5DCD5; border-color: #C9A39A; cursor: default; }
.ochip.earlier .m, .ochip.earlier .k { color: #71140C; }
.ochip.earlier .k { font-weight: 600; }
table.grid td.earlier { box-shadow: inset 0 -3px 0 #C0473A; }
table.grid td.earlier .cell-sub { color: #71140C; font-weight: 600; }
@media (prefers-color-scheme: dark) { .ochip.earlier { background: rgba(200,90,70,.25); border-color: rgba(200,90,70,.5); } .ochip.earlier .m, .ochip.earlier .k { color: #F2C4B8; } }
.review-btn { font-size: 12px; padding: 3px 10px; margin-left: 10px; vertical-align: middle; }
.review-btn.on { background: #3D6B3A; border-color: #3D6B3A; color: #fff; }
.rev-tick { color: #3D6B3A; }
h2 [data-review-count] { font-weight: 400; margin-left: 6px; }
.cover-line { margin-top: 4px; }
.mt-modes { display: inline-flex; gap: 6px; margin-left: auto; }
.mt-table td, .mt-table th { white-space: nowrap; }
.plist-total { display: block; margin: 4px 0 8px; font-weight: 600; }
.cover-line .asp-input { width: 5.5em; }
.otb-form { margin-top: 6px; font-size: 12px; }
.otb-form input { font: inherit; width: 9em; padding: 2px 6px; border: 1px solid var(--hair); }
.cover-line .fmc-input { font: inherit; width: 3.2em; padding: 2px 6px; margin: 0 2px; border: 1px solid var(--ink); background: var(--paper); text-align: right; }
.cover-line .fmc-input:not(:placeholder-shown) { background: var(--amber); }
table.grid th.f-col, table.grid td.f-col { background-color: #F7F4EC; }
.split-dialog .split-by { display: flex; flex-direction: column; gap: 4px; }
@media (prefers-color-scheme: dark) { table.grid th.f-col, table.grid td.f-col { background-color: rgba(255,255,255,.04); } }
.badge.kind.earlier { background: #F5DCD5; color: #71140C; font-weight: 600; }
.ochip .moq-warn { color: #71140C; font-weight: 600; }
.ochip[aria-pressed="true"] .moq-warn { color: #F5B7A8; }
.gap-dialog { width: min(800px, 94vw); }
.gap-dialog .gap-fields { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.gap-dialog select { font: inherit; font-size: 16px; padding: 7px 8px; border: 1px solid var(--ink); }
.gap-dialog .split-table { max-height: 50vh; }
.gap-dialog [data-gap-hint] .moq-warn { color: #71140C; font-weight: 600; }
@media (prefers-color-scheme: dark) { .badge.kind.earlier { background: rgba(200,90,70,.3); color: #F2C4B8; } }
.ochip .k.already { color: #3D6B3A; font-weight: 600; }
.ochip[aria-pressed="true"] .k.already { color: #CFE6C7; }
table.grid input.saving { opacity: .6; }
table.grid input.bad { outline: 2px solid var(--warn); }
.has-note::after { content: ""; position: absolute; top: 0; right: 0; border-top: 9px solid #BA6451;
  border-left: 9px solid transparent; }
td.order.has-note::after { border-top-color: var(--amber); }
.notebtn { border: 0; background: none; padding: 2px 4px; font: inherit; font-size: 12px; color: var(--muted);
  text-decoration: underline; cursor: pointer; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; display: inline-block; }
.sw.locked { background: var(--locked); }
.sw.edit { background: var(--paper); border: 1px solid var(--muted); }
.sw.changed { background: var(--amber); border: 1px solid var(--ink); }
.sw.carried { background: var(--paper); border: 1px solid var(--muted); border-bottom: 4px solid var(--muted); }
.sw.order { background: var(--ink); }
.sw.new { background: var(--amber); }

.alerts { display: flex; flex-direction: column; }
.alerts a { padding: 9px 0; border-top: 1px solid #E4DFD4; text-decoration: none; display: grid;
  grid-template-columns: 112px 1fr; gap: 12px; }
.work > .aside { flex: 1 1 340px; max-width: 440px; }
.alerts .k-stockout, .alerts .k-moq, .alerts .k-earlier, .alerts .k-overdue, .alerts .k-podiff, .alerts .k-polate, .alerts .k-asp, .alerts .k-dropped { color: var(--warn); }
.locked-note.dropped-note { background: var(--warn-bg); border-left-color: var(--warn); color: var(--warn); }
/* links inside a Product tab alert sentence stay inline (the grid layout is for the Summary's alert list) */
.alerts p a, .alerts p .linkbtn { display: inline; padding: 0; border: 0; text-decoration: underline; color: var(--ink); }

.issues { display: flex; flex-direction: column; }
.issue { display: grid; grid-template-columns: minmax(80px, 200px) minmax(100px, 260px) 1fr; gap: 12px; padding: 8px 0;
  border-top: 1px solid #E4DFD4; }
.issue.error { color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--sand); padding: 12px 14px; }
.stat .v { font-size: 22px; font-weight: 700; }

.dropzone { border: 2px dashed var(--muted); padding: 22px; display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between; background: var(--paper); }
.dropzone input[type=file] { font: inherit; }

.comments { display: flex; flex-direction: column; }
.comment { padding: 10px 0; border-top: 1px solid #E4DFD4; display: flex; flex-direction: column; gap: 2px; }
.comment .t { white-space: pre-wrap; unicode-bidi: plaintext; text-align: start; }

dialog { border: 1px solid var(--ink); padding: 0; width: min(480px, 92vw); }
dialog::backdrop { background: rgba(18, 8, 3, .35); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--hair); background: var(--sand);
  min-height: 90px; resize: vertical; unicode-bidi: plaintext; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
select, input[type=text], input[type=search] { font: inherit; padding: 6px 8px; border: 1px solid var(--hair); background: var(--paper); color: var(--ink); }

.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: var(--sand); padding: 10px 14px;
  font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.toast.error { background: var(--warn); }

@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
@media (max-width: 700px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .work > .side { max-width: none; max-height: 240px; }
}

/* Excel-style editing */
body.grid-dragging, body.grid-dragging * { user-select: none; cursor: cell; }
table.grid td.sel input { background: #E6EEF7; border-color: #2F5D8A; }
table.grid td.sel input.changed { background: #F2D9A0; }
table.grid td.sel-anchor input { outline: 2px solid #2F5D8A; outline-offset: -1px; }
table.grid td.fillprev input { background: #FCEBC4; border: 1px dashed #120803; }
.fill-handle { position: absolute; display: none; width: 9px; height: 9px; background: #2F5D8A; border: 2px solid #FFFFFF;
  box-sizing: content-box; cursor: crosshair; z-index: 50; }
.ctxmenu { position: fixed; z-index: 60; width: 240px; background: var(--paper); border: 1px solid var(--ink);
  box-shadow: 0 6px 18px rgba(18, 8, 3, .18); padding: 4px 0; display: flex; flex-direction: column; }
.ctxmenu[hidden] { display: none; }
.ctxmenu button { font: inherit; display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; border: 0;
  background: var(--paper); color: var(--ink); text-align: left; cursor: pointer; }
.ctxmenu button:hover, .ctxmenu button:focus-visible { background: #E6EEF7; outline: none; }
.ctxmenu button[disabled] { color: var(--hair); cursor: default; background: var(--paper); }
.ctxmenu .key { color: var(--muted); }
.split-dialog { width: min(620px, 94vw); }
.split-dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.split-dialog input[name=total] { font: inherit; font-size: 18px; font-weight: 700; padding: 8px 10px; border: 1px solid var(--ink); width: 200px; }
.split-dialog .field-inline { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.toast.interactive { pointer-events: auto; display: flex; gap: 14px; align-items: center; }
.toast-undo { font: inherit; font-weight: 700; color: var(--amber); background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }

.app-version { font-size: 11px; color: #A69F90; margin-left: 12px; letter-spacing: .02em; }

/* PO feed */
table.grid td.dup input { border: 2px dashed #B4531A; }
details.panel > summary { cursor: pointer; list-style: revert; }
details.panel[open] > summary { margin-bottom: 10px; }

select.po-month { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--muted); background: var(--paper); color: var(--ink); }
tr.muted td { color: var(--muted); }

button.histcell { font: inherit; width: 100%; padding: 0; border: 0; background: none; color: inherit; text-align: inherit; cursor: pointer; }
button.histcell:hover, button.histcell:focus-visible { text-decoration: underline; outline: none; }

/* ---------- On order: one row per PO, lines on demand ---------- */
.po-months { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.po-chip { display: grid; gap: 2px; min-width: 112px; padding: 8px 12px; text-align: left; font: inherit;
  background: var(--surface, #fff); border: 1px solid #D9D2C3; cursor: pointer; }
.po-chip .lbl { font-size: 12px; color: #6B6257; }
.po-chip strong { font-size: 16px; }
.po-chip .split { font-size: 11px; color: #6B6257; }
.po-chip:hover { border-color: #120803; }
.po-chip[aria-pressed="true"] { background: #120803; color: #fff; border-color: #120803; }
.po-chip[aria-pressed="true"] .lbl, .po-chip[aria-pressed="true"] .split { color: #E8E1D3; }
.po-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid #120803; }
.seg button { font: inherit; font-size: 13px; padding: 5px 12px; border: 0; background: none; cursor: pointer; }
.seg button + button { border-left: 1px solid #120803; }
.seg button[aria-pressed="true"] { background: #120803; color: #fff; }
.chip-toggle { font: inherit; font-size: 13px; padding: 5px 12px; border: 1px solid #71140C; color: #71140C;
  background: none; cursor: pointer; }
.chip-toggle[aria-pressed="true"] { background: #71140C; color: #fff; }
.po-search { font: inherit; font-size: 13px; padding: 5px 10px; min-width: 220px; border: 1px solid #B9B0A0; }
.linkbtn { font: inherit; font-size: 13px; border: 0; background: none; text-decoration: underline; cursor: pointer; padding: 0; margin-left: auto; }
.po-table tbody.po-group { border-top: 1px solid #D9D2C3; }
.po-table .po-row td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.po-table .supplier { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-toggle { font: inherit; display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; }
.po-toggle .chev { width: 0; height: 0; border-left: 6px solid #120803; border-top: 5px solid transparent;
  border-bottom: 5px solid transparent; transition: transform .15s; }
.po-group.open .po-toggle .chev { transform: rotate(90deg); }
.js .po-group:not(.open) .po-line { display: none; }
.po-line td { background: #FAF8F3; font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
.po-group.is-residual .po-row { color: #8A8174; }
.sizes { display: flex; flex-wrap: wrap; gap: 4px; }
.sz { display: inline-flex; gap: 4px; padding: 2px 6px; background: #F1ECE2; font-size: 12px; white-space: nowrap; }
.sz b { font-weight: 600; }
.flag.warn { color: #71140C; font-weight: 600; }
.po-line .flag { color: #6B6257; font-weight: 400; }
@media (prefers-color-scheme: dark) {
  .po-chip, .seg button, .po-search { background: transparent; color: inherit; }
  .sz { background: rgba(255,255,255,.08); }
  .po-line td { background: rgba(255,255,255,.04); }
}

/* ---------- finalised plans are locked ---------- */
.locked-note { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid #120803; background: #F1ECE2; font-size: 13px; }
.locked-note.warn { border-left-color: #71140C; }
.changes-list { max-height: 360px; overflow: auto; }
td.up { color: #1F5E2E; font-weight: 600; }
td.down { color: #71140C; font-weight: 600; }
@media (prefers-color-scheme: dark) { .locked-note { background: rgba(255,255,255,.06); } }

/* ---------- Intake (Kristy's layout) ---------- */
.intake-head { align-items: flex-start; }
.intake-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 10px; }
.seg a { display: inline-block; font-size: 13px; padding: 5px 12px; color: inherit; text-decoration: none; }
.seg a + a { border-left: 1px solid #120803; }
.seg a[aria-current="true"] { background: #120803; color: #fff; }
.intake-table { font-size: 12px; }
.intake-table th, .intake-table td { padding: 5px 7px; white-space: nowrap; }
.intake-table thead .band th { text-align: left; font-size: 11px; letter-spacing: .04em; border-bottom: 2px solid #120803; }
.intake-table .gap { width: 14px; padding: 0; background: none !important; border: 0; }
.intake-table td.actual, .intake-table th.actual { background: #F1ECE2; }
.intake-table tbody.ig { border-top: 1px solid #D9D2C3; }
.intake-table .ig-row th, .intake-table .ig-row td { font-weight: 600; }
.intake-table .ig-line th { font-weight: 400; padding-left: 26px; }
.js .intake-table tbody.ig:not(.open) .ig-line { display: none; }
.intake-table tbody.ig.open .ig-toggle .chev { transform: rotate(90deg); }
.intake-table tr.total th, .intake-table tr.total td { font-weight: 700; border-top: 2px solid #120803; }
@media (prefers-color-scheme: dark) { .intake-table td.actual, .intake-table th.actual { background: rgba(255,255,255,.07); } }

/* ---------- received so far this month (GRN) ---------- */
td.rcvd, .intake-table td.rcvd { background: #DDEBD6 !important; box-shadow: inset 3px 0 0 #2E6B3A; }
.cell-sub { display: block; font-size: 10.5px; color: #1F5E2E; font-weight: 600; white-space: nowrap; }
.sw.rcvd { background: #DDEBD6; border-color: #2E6B3A; }
.rcvd-box { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; margin: 4px 0 14px;
  padding: 10px 12px; background: #F2F7EF; border-left: 3px solid #2E6B3A; }
.rcvd-chip { cursor: default; background: #DDEBD6; border-color: #2E6B3A; }
.rcvd-chip strong { color: #1F5E2E; }
table.t.rcvd-table { width: auto; min-width: 420px; font-size: 12.5px; flex: 0 1 auto; }
.rcvd-table th, .rcvd-table td { padding: 3px 10px; }
.rcvd-box > p { flex-basis: 100%; margin: 0; }
.rcvd-list { margin: 10px 0; padding: 8px 12px; background: #F2F7EF; border-left: 3px solid #2E6B3A; }
.rcvd-list summary { cursor: pointer; }
@media (prefers-color-scheme: dark) {
  td.rcvd, .intake-table td.rcvd, .sw.rcvd, .rcvd-chip { background: rgba(80, 160, 90, .22) !important; }
  .rcvd-box, .rcvd-list { background: rgba(80, 160, 90, .10); }
  .cell-sub, .rcvd-chip strong { color: #9BD3A3; }
}

/* ---------- A1: arrivals by stage ---------- */
tr.split-row th.rowhead { padding-left: 22px; font-weight: 400; }
tr.split-row td { font-size: 12.5px; }
tr.split-row th.rowhead::before { content: "↳ "; color: #8A8174; }
table.no-split tr.split-row { display: none; }
.split-toggle { font-size: 12px; margin-left: 6px; }
.stage { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; margin-bottom: 2px; }
.st-grn, .st-com { font-size: 10.5px; line-height: 1.4; padding: 0 4px; white-space: nowrap; font-weight: 600; }
.st-grn { background: #DDEBD6; color: #1F5E2E; }
.st-com { background: #E3E6F3; color: #2C3A78; }
@media (prefers-color-scheme: dark) {
  .st-grn { background: rgba(80, 160, 90, .25); color: #9BD3A3; }
  .st-com { background: rgba(110, 125, 200, .28); color: #C3CBF2; }
}

/* ---------- A2: growth keyed as +20 / -20 / 0; units where there were no sales last year ---------- */
input.units-mode { font-style: italic; }

/* ---------- A6: dropped-out PO quantity ---------- */
.drop-box { margin: 4px 0 14px; padding: 10px 12px; background: #FBEDEA; border-left: 3px solid #71140C; }
.drop-box p { margin: 0 0 8px; font-size: 13px; }
table.t.drop-table { width: auto; min-width: 640px; font-size: 12.5px; }
.drop-table th, .drop-table td { padding: 3px 9px; }
@media (prefers-color-scheme: dark) { .drop-box { background: rgba(200, 70, 50, .14); } }

/* ---------- shared filters, product list, Summary ---------- */
.fbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 12px; }
.fbar input[type=search] { font: inherit; font-size: 13px; padding: 6px 10px; min-width: 260px; border: 1px solid #B9B0A0; }
.fbar select { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid #B9B0A0; background: transparent; color: inherit; max-width: 220px; }
.fchip { font: inherit; font-size: 12px; padding: 4px 9px; border: 1px solid #B9B0A0; background: none; color: inherit; cursor: pointer; }
.fchip[aria-pressed="true"] { background: #120803; color: #fff; border-color: #120803; }
.fchip[aria-pressed="true"] .muted { color: #E8E1D3; }
.fflags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.fbar-compact { display: grid; gap: 6px; margin: 0 0 6px; }
.fbar-compact input[type=search] { min-width: 0; width: 100%; box-sizing: border-box; }
.fmore summary { cursor: pointer; font-size: 12.5px; }
.fmore-body { display: grid; gap: 6px; padding: 6px 0; }
.fmore-body select { max-width: 100%; }
.plist-nav { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 6px; }
.badge { display: inline-block; font-size: 10.5px; padding: 0 5px; margin-left: 2px; background: #FBEDEA; color: #71140C; font-weight: 600; white-space: nowrap; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.tile { font: inherit; display: grid; gap: 2px; min-width: 130px; padding: 10px 14px; text-align: left; border: 1px solid #D9D2C3; background: var(--surface, #fff); cursor: pointer; }
.tile .v { font-size: 22px; font-weight: 700; }
.tile .l { font-size: 12.5px; color: #6B6257; }
.tile.has { border-color: #71140C; }
.tile.has .v { color: #71140C; }
.tile[disabled] { cursor: default; opacity: .55; }
.tile[aria-pressed="true"] { background: #120803; border-color: #120803; }
.tile[aria-pressed="true"] .v, .tile[aria-pressed="true"] .l { color: #fff; }
.sum-details { margin-top: 10px; }
.sum-details > summary { cursor: pointer; font-size: 13px; }
.ftable th[data-sort] { cursor: pointer; white-space: nowrap; }
.ftable th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
.ftable th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
.ftable-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.warn-text { color: #71140C; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .tile { background: transparent; }
  .badge { background: rgba(200, 70, 50, .2); color: #F2B8AD; }
}

/* anything the script hides stays hidden, whatever its own display style */
[hidden] { display: none !important; }

/* ---------- the filter bar inside the narrow product list ---------- */
.plist .fbar-compact { position: sticky; top: 0; z-index: 2; background: var(--paper); margin: 0;
  padding: 10px 14px 8px; box-sizing: border-box; width: 100%; min-width: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center;
  border-bottom: 1px solid #E6E0D4; }
.plist .fbar-compact input[type=search] { grid-row: 1; grid-column: 1; width: 100%; min-width: 0; }
.plist .fbar-compact [data-f-clear] { grid-row: 1; grid-column: 2; font-size: 12px; }
.plist .fbar-compact .fmore { grid-row: 2; grid-column: 1 / -1; min-width: 0; }
.plist .fmore-body { display: grid; gap: 6px; padding: 8px 0 2px; min-width: 0; }
.plist .fmore-body > * { min-width: 0; max-width: 100%; box-sizing: border-box; }
.plist .fmore-body select { width: 100%; max-width: 100%; }
.plist .fmore-body .fflags { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.plist .fmore-body .fchip { font-size: 11.5px; padding: 3px 7px; white-space: nowrap; }
.plist .plist-nav { padding: 6px 14px 2px; }
.plist .plist-nav .linkbtn { font-size: 12px; }
.plist [data-plist-empty] { padding: 0 14px; }

/* ---------- filters on Order and Intake ---------- */
.f-out { display: none !important; }
.f-banner { margin: 0 0 10px; padding: 7px 12px; background: #FFF4D6; border-left: 3px solid #B88A00; font-size: 13px; }
.fbar-extra { margin-top: -6px; }
tr.f-shown td { background: #FFF4D6; }
@media (prefers-color-scheme: dark) { .f-banner, tr.f-shown td { background: rgba(200, 160, 40, .15); } }

/* ---------- Order tab: items with their SKUs underneath ---------- */
.og-tools { display: flex; justify-content: space-between; align-items: center; margin: 0 0 6px; gap: 12px; }
.og-table tbody.og { border-top: 1px solid #D9D2C3; }
.og-table .og-row th, .og-table .og-row td { vertical-align: top; padding-top: 9px; padding-bottom: 9px; }
.og-table .og-row th { text-align: left; font-weight: 400; }
.js .og-table tbody.og:not(.open) .og-line { display: none; }
.og-table tbody.og.open .og-toggle .chev { transform: rotate(90deg); }
.og-line td { background: #FAF8F3; font-size: 12.5px; padding-top: 5px; padding-bottom: 5px; }
th[data-gsort] { cursor: pointer; white-space: nowrap; }
th[data-gsort][aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
th[data-gsort][aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
@media (prefers-color-scheme: dark) { .og-line td { background: rgba(255,255,255,.04); } }

/* ---------- B1: order months and locks ---------- */
.omonths { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 12px; }
.ochip { font: inherit; display: grid; gap: 1px; min-width: 96px; padding: 6px 10px; text-align: left; border: 1px solid #B9B0A0;
  background: var(--surface, #fff); color: inherit; cursor: pointer; }
.ochip .m { font-size: 11.5px; color: #6B6257; }
.ochip strong { font-size: 14px; }
.ochip .k { font-size: 10.5px; color: #6B6257; min-height: 1em; }
.ochip[aria-pressed="true"] { background: #120803; border-color: #120803; color: #fff; }
.ochip[aria-pressed="true"] .m, .ochip[aria-pressed="true"] .k { color: #E8E1D3; }
.ochip[disabled] { opacity: .6; cursor: default; }
.badge.kind { background: #E3E6F3; color: #2C3A78; }
.unlock-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.unlock-form input[name=reason] { font: inherit; font-size: 13px; padding: 5px 8px; min-width: 240px; border: 1px solid #B9B0A0; }
@media (prefers-color-scheme: dark) { .ochip { background: transparent; } .badge.kind { background: rgba(110,125,200,.28); color: #C3CBF2; } }

/* ---- UX tidy-up (v2026-11-21.24): the top-bar menu, the plan header's details, the collapsible item list ---- */
.menu-wrap { position: relative; display: flex; gap: 8px; align-items: center; }
.topbar-user, .menu-btn { font: inherit; font-size: 13px; color: var(--sand); background: transparent; border: 1px solid var(--muted);
  padding: 5px 10px; cursor: pointer; }
.topbar-user { border-color: transparent; color: var(--stone); }
.menu-btn:hover, .topbar-user:hover, .menu-btn[aria-expanded="true"] { border-color: var(--sand); }
.app-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 100; min-width: 280px; background: var(--paper);
  color: var(--ink); border: 1px solid var(--ink); box-shadow: 0 6px 18px rgba(18, 8, 3, .18); padding: 6px 0;
  display: flex; flex-direction: column; }
.app-menu[hidden] { display: none; }
.topbar .app-menu a { color: var(--ink); padding: 9px 16px; text-decoration: none; }
.topbar .app-menu a:hover, .topbar .app-menu a:focus-visible { background: #E6EEF7; outline: none; }
.app-menu .whoami { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 16px;
  border-top: 1px solid var(--hair); margin-top: 4px; color: var(--muted); }
.app-menu .whoami span { display: flex; gap: 6px; }
.app-menu .whoami input { flex: 1; color: var(--ink); background: var(--paper); border: 1px solid var(--hair); }
.app-menu .whoami button { font: inherit; padding: 4px 10px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }
.app-menu .app-version { padding: 6px 16px 4px; color: var(--muted); font-size: 12px; }
.page-head h1 .status { font-size: 12px; vertical-align: middle; margin-left: 6px; }
.pill-frozen { font-size: 12px; font-weight: 600; vertical-align: middle; padding: 2px 8px; background: #E3ECF5; color: #2C4A78;
  text-decoration: none; border: 1px solid #9DB3CF; }
.head-details { margin-top: 4px; }
.head-details p { margin: 2px 0; }
.side-toggle { font: inherit; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 6px 14px 2px; cursor: pointer;
  text-align: left; }
.side-toggle:hover { color: var(--ink); text-decoration: underline; }
.side-rail { display: none; }
.side-collapsed .work > .side { display: none; }
.side-collapsed .side-rail { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 30px; padding: 10px 0;
  background: var(--paper); border: 1px solid var(--hair); font: inherit; font-size: 16px; color: var(--ink); cursor: pointer;
  position: sticky; top: 8px; align-self: flex-start; }
.side-collapsed .side-rail span { writing-mode: vertical-rl; font-size: 12px; color: var(--muted); }
.side-collapsed .side-rail:hover { border-color: var(--ink); }
@media print { .topbar, .tabs, .side, .side-rail, .actions { display: none !important; } }
.page-head { align-items: flex-start; }
.page-head > .actions { margin-top: 30px; }
.head-notes:empty { display: none; }
.head-notes .locked-note { margin: 10px 0 0; }

/* SKU tab: the table scrolls inside a box the height of the screen, with its header row frozen (v2026-11-21.25) */
.sku-scroll { max-height: calc(100vh - 110px); overflow: auto; scroll-padding-top: 64px; outline: none;
  border-top: 1px solid var(--hair); }
.sku-scroll > table.grid > thead th { position: sticky; top: 0; z-index: 4; background-color: var(--paper);
  box-shadow: inset 0 -2px 0 var(--hair); }
.sku-scroll > table.grid > thead th.f-col { background-color: #F7F4EC; }
@media (prefers-color-scheme: dark) { .sku-scroll > table.grid > thead th.f-col { background-color: var(--paper);
  background-image: linear-gradient(rgba(255,255,255,.04), rgba(255,255,255,.04)); } }
@media print { .sku-scroll { max-height: none; overflow: visible; } .sku-scroll > table.grid > thead th { position: static; } }

/* ---- sign-in and access (v2026-11-21.27) ---- */
.role-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; margin-left: 4px; background: #E6EEF7;
  color: #2C4A78; vertical-align: middle; }
.role-tag.role-manager { background: #EBE3F5; color: #4B2C78; }
.role-tag.role-viewer { background: var(--sand); color: var(--muted); }
.topbar .role-tag { background: transparent; color: var(--stone); border: 1px solid var(--muted); }
.role-note { font-size: 13px; color: var(--muted); border: 1px solid var(--hair); padding: 6px 12px; }
.menu-logout { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px;
  border-top: 1px solid var(--hair); margin-top: 4px; }
.menu-logout button { font: inherit; padding: 4px 12px; border: 1px solid var(--ink); background: var(--paper); cursor: pointer;
  white-space: nowrap; flex: none; }
.menu-logout span { min-width: 0; overflow-wrap: anywhere; }
.panel.narrow { max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack input, .login-card input { font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--ink); }
.login-page { background: var(--sand); min-height: 100vh; display: flex; align-items: center; justify-content: center; margin: 0; }
.login-card { background: var(--paper); border-top: 4px solid var(--ink); padding: 32px 36px; width: min(420px, 92vw); }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.login-card .btn { align-self: flex-start; }
.login-error { color: var(--warn); background: var(--warn-bg); padding: 8px 10px; margin: 8px 0 0; }
.access-table td, .access-table th { white-space: nowrap; }

/* ---- change log (v2026-11-21.28) ---- */
.log-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 0 0 8px; }
.log-filters input, .log-filters select { font: inherit; padding: 4px 8px; border: 1px solid var(--hair); }
.log-table td { vertical-align: top; }
.log-table tr.log-auth td { color: var(--muted); }
.log-table tr.log-user td:nth-child(3), .log-table tr.log-group td:nth-child(3) { color: #4B2C78; font-weight: 600; }
