/* ════════════════════════════════════════════════════════════
   Stock Aging Dashboard — NORTHWIND design system
   Parchment (light) primary · Espresso (dark) toggle
   ════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Theme tokens (shared with landing page) ─── */
:root, [data-theme="light"] {
  --bg-0:#ede4cf; --bg-1:#faf5e8; --surface:#ffffff; --surface-hi:#fbf6ea;
  --surface-2:#f4ecda;
  --line:rgba(42,29,8,.10); --line-hi:rgba(42,29,8,.20);
  --text:#2a1d08; --text-mute:#7a6e5c; --text-dim:#a99a80;
  --gold:#8c6418; --gold-soft:#c79433; --gold-ink:#fff8ed;
  --gold-wash:rgba(199,147,51,.12);
  --green:#3f8f3a; --green-soft:#5ba34f;
  --grade-b:#9333ea;
  --noise:0;
  --zebra:rgba(42,29,8,.022);
  --shadow:0 1px 2px rgba(42,29,8,.05), 0 6px 22px -16px rgba(42,29,8,.30);
}
[data-theme="dark"] {
  --bg-0:#0a0705; --bg-1:#140e0b; --surface:#1d1612; --surface-hi:#241c16;
  --surface-2:#2a201a;
  --line:rgba(239,230,216,.08); --line-hi:rgba(239,230,216,.20);
  --text:#f4ecdd; --text-mute:#b8a98f; --text-dim:#7a6e5c;
  --gold:#f0b340; --gold-soft:#ffd27a; --gold-ink:#2a1d08;
  --gold-wash:rgba(240,179,64,.10);
  --green:#9fcf63; --green-soft:#b6dd86;
  --grade-b:#c79bed;
  --noise:.05;
  --zebra:rgba(239,230,216,.022);
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 18px 38px -24px rgba(0,0,0,.8);
}

/* fixed espresso tokens — used by the masthead in BOTH themes (a letterhead) */
:root {
  --ink-0:#16100c; --ink-1:#1d1612; --ink-2:#2a201a;
  --ink-line:rgba(239,230,216,.10); --ink-line-hi:rgba(239,230,216,.18);
  --ink-text:#f4ecdd; --ink-mute:#b8a98f; --ink-dim:#7a6e5c;
  --ink-gold:#f0b340; --ink-gold-soft:#ffd27a;
}

/* status — vivid functional signals, kept consistent across themes */
:root {
  --s-expired:#dc2626; --s-critical:#ea580c; --s-warning:#d4900b; --s-safe:#16a34a;
  --s-expired-bg:rgba(220,38,38,.10); --s-critical-bg:rgba(234,88,12,.10);
  --s-warning-bg:rgba(212,144,11,.13); --s-safe-bg:rgba(22,163,74,.11);
  --s-unknown:#94a3b8; --s-unknown-bg:rgba(148,163,184,.12);
  --s-oos:#64748b; --s-oos-bg:rgba(100,116,139,.12);
}
[data-theme="dark"] {
  --s-warning:#e3a82a;
  --s-expired-bg:rgba(220,38,38,.16); --s-critical-bg:rgba(234,88,12,.16);
  --s-warning-bg:rgba(227,168,42,.16); --s-safe-bg:rgba(22,163,74,.18);
}

/* Reorder status colors stay conventional: red needs action, amber needs review,
   green is healthy. Overstock is informational blue; no velocity is neutral.
   These tokens also drive the Marimekko, badges, dots and brand counts. */
:root, [data-theme="light"] {
  --mk-order:#e0645f; --mk-watch:#d9982f; --mk-ok:#3fa96a; --mk-over:#5b93d6; --mk-nov:#a7b0bb; --mk-uncfg:#8064a2; --mk-conflict:#a34b68;
  --ro-order:#c62828; --ro-watch:#a16207; --ro-ok:#15803d; --ro-over:#2563eb; --ro-nov:#64748b; --ro-uncfg:#6d4a8f; --ro-conflict:#9d174d;
}
[data-theme="dark"] {
  --mk-order:#ff6b62; --mk-watch:#f0b03c; --mk-ok:#48c07a; --mk-over:#79aef5; --mk-nov:#9aa4b0; --mk-uncfg:#c4a5e8; --mk-conflict:#f29aba;
  --ro-order:#ff7b72; --ro-watch:#facc15; --ro-ok:#4ade80; --ro-over:#7cb0ff; --ro-nov:#a1a1aa; --ro-uncfg:#d8b4fe; --ro-conflict:#f9a8d4;
}

html { background:var(--bg-0); }
body {
  font-family:'Inter', system-ui, sans-serif;
  /* ponytail: page-wide tabular figures — the mono face used to align number
     columns for free; now that everything is sans, one rule replaces it. */
  font-variant-numeric:tabular-nums;
  background:var(--bg-1);
  color:var(--text);
  font-size:14px; line-height:1.45;
  -webkit-font-smoothing:antialiased;
  min-height:100vh;
  position:relative;
}
[data-theme="dark"] body {
  background:radial-gradient(ellipse at 50% -8%, #221912 0%, #140e0b 46%, #0a0705 100%);
}
body::after {
  content:""; position:fixed; inset:0; pointer-events:none; z-index:9999;
  opacity:var(--noise); mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/></svg>");
}

.mono { font-family:'IBM Plex Sans', Inter, sans-serif; }
.serif { font-family:'Fraunces', Georgia, serif; }
.tnum { font-variant-numeric:tabular-nums; }

/* ════════ Masthead (espresso letterhead) ════════ */
.masthead {
  background:linear-gradient(120deg, var(--ink-1) 0%, var(--ink-2) 60%, var(--ink-1) 100%);
  border-bottom:1px solid var(--ink-line-hi);
  color:var(--ink-text);
  padding:16px 26px;
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  position:relative;
  /* overflow stays visible so the "Data updates" panel can escape the header;
     the corner glow is painted inside an inset:0 pseudo-element instead of
     bleeding past the edge, so it needs no clipping. */
}
.masthead::before {
  content:""; position:absolute; inset:0; pointer-events:none; z-index:0;
  background:radial-gradient(ellipse 460px 320px at 82% -30%, rgba(240,179,64,.16) 0%, transparent 62%);
}
.mh-left { display:flex; align-items:center; gap:15px; position:relative; z-index:1; }
.mh-mark {
  height:38px; width:auto; flex-shrink:0;
}
.mh-titles .eyebrow {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; letter-spacing:.18em;
  text-transform:uppercase; color:var(--ink-dim); margin-bottom:4px;
}
.mh-titles h1 {
  font-family:'Fraunces', Georgia, serif; font-weight:500; font-size:26px;
  letter-spacing:-.02em; line-height:1; color:var(--ink-text);
}
.mh-titles h1 em { font-style:italic; color:var(--ink-gold); font-weight:400; }
.mh-right { display:flex; align-items:center; gap:12px; position:relative; z-index:1; }

/* "Data updates" — one compact disclosure replacing the Bluepeak/NORTHWIND/Generated/
   version cluster. Its espresso surface and cream ink keep it legible on the
   letterhead in either dashboard theme; the opened panel remains theme-aware. */
.data-updates { position:relative; font-family:'IBM Plex Sans', Inter, sans-serif; }
.du-summary {
  display:flex; align-items:center; gap:8px; list-style:none; cursor:pointer;
  padding:6px 11px; border-radius:8px; white-space:nowrap;
  background:#493522; color:#f4ecdd; border:1px solid rgba(244,236,221,.30);
  font-size:10px; letter-spacing:.04em;
}
.du-summary::-webkit-details-marker { display:none; }
.du-summary:focus-visible { outline:2px solid var(--ink-gold-soft); outline-offset:2px; }
.du-label { font-weight:600; text-transform:uppercase; letter-spacing:.1em; }
.du-brief { color:#d9cdb8; }
.du-chev { color:#d9cdb8; transition:transform .15s; }
.data-updates[open] .du-chev { transform:rotate(180deg); }
.du-panel {
  position:absolute; top:calc(100% + 7px); right:0; z-index:40;
  min-width:250px; padding:13px 15px; display:flex; flex-direction:column; gap:12px;
  background:var(--surface-hi); color:var(--text);
  border:1px solid var(--line-hi); border-radius:10px; box-shadow:var(--shadow);
}
.du-group-h {
  font-size:8.5px; font-weight:600; letter-spacing:.11em; text-transform:uppercase;
  color:var(--text-mute); margin-bottom:6px;
}
.du-row { display:flex; align-items:center; gap:10px; font-size:11px; padding:2px 0; }
.du-co { font-size:8.5px; font-weight:700; letter-spacing:.08em; padding:2px 6px; border-radius:4px; }
.du-co.bluepeak { color:#8a55d0; background:rgba(155,109,214,.14); }
.du-co.northwind  { color:var(--gold); background:var(--gold-wash); }
[data-theme="dark"] .du-co.bluepeak { color:#bd97e8; }
.du-dt { font-variant-numeric:tabular-nums; }
.du-version-row { display:flex; align-items:baseline; gap:10px; }
.du-version-row .du-group-h { margin-bottom:0; }
.du-ver { font-size:11px; color:var(--text-mute); }
@media (max-width:720px) {
  .du-brief { display:none; }
  .mh-right {
    display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px;
    align-items:stretch; width:100%; align-self:stretch;
  }
  .data-updates, .du-summary { width:100%; min-width:0; }
  .du-summary { min-height:44px; justify-content:space-between; }
  /* Align with the disclosure on the left and keep the panel inside a 320px viewport. */
  .du-panel {
    left:0; right:auto; width:min(320px, calc(100vw - 28px));
    min-width:0; max-width:calc(100vw - 28px);
  }
  .du-row { flex-wrap:wrap; gap:4px 10px; }
  .du-dt { white-space:normal; overflow-wrap:anywhere; }
  .theme-btn { min-height:44px; height:auto; padding:0 12px; }
}
.theme-btn {
  min-height:34px; padding:0 10px; gap:6px; border-radius:8px; flex-shrink:0;
  border:1px solid rgba(244,236,221,.30); background:#493522;
  color:#f4ecdd; cursor:pointer;
  display:flex; align-items:center; justify-content:center; transition:background .15s;
}
.theme-btn:hover { background:#5a432b; }
.theme-btn svg { width:15px; height:15px; pointer-events:none; }
.theme-btn-label { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; font-weight:600; letter-spacing:.04em; }
.icon-sun { display:none; } .icon-moon { display:block; }
[data-theme="dark"] .icon-sun { display:block; } [data-theme="dark"] .icon-moon { display:none; }
@media (max-width:720px) { .theme-btn { min-height:44px; height:auto; padding:0 12px; } }

/* ════════ Shell ════════ */
.shell { padding:18px 26px 40px; max-width:1640px; margin:0 auto; }
.card {
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  box-shadow:var(--shadow);
}

/* ════════ KPI section ════════ */
.kpi-head {
  display:flex; align-items:flex-end; justify-content:space-between;
  gap:16px; margin-bottom:13px; flex-wrap:wrap;
}
/* Same eyebrow as the table titles (.tbl-hdr h2, e.g. Product QTY). */
.section-label {
  font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:11px; font-weight:700;
  letter-spacing:.14em; text-transform:uppercase; color:var(--text-dim);
  display:flex; align-items:center; gap:9px;
}
.section-label::before {
  content:""; width:16px; height:2px; background:var(--gold-soft); border-radius:2px;
}
.kpi-overview {
  font-family:'Fraunces', Georgia, serif; font-size:19px; font-weight:500;
  letter-spacing:-.01em; color:var(--text); margin-top:2px;
}
.kpi-overview .total { color:var(--gold); }

/* variation switcher */
.seg {
  display:inline-flex; background:var(--surface-2); border:1px solid var(--line);
  border-radius:9px; padding:3px; gap:2px;
}
.seg button {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; font-weight:600;
  letter-spacing:.04em; color:var(--text-mute); background:transparent;
  border:none; border-radius:6px; padding:6px 13px; cursor:pointer;
  transition:all .14s; white-space:nowrap;
}
.seg button:hover { color:var(--text); }
.seg button.on {
  background:var(--surface); color:var(--gold);
  box-shadow:0 1px 2px rgba(42,29,8,.12); border:1px solid var(--line-hi);
  padding:5px 12px;
}
[data-theme="dark"] .seg button.on { background:var(--ink-2); }
.seg-cap {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; letter-spacing:.14em;
  text-transform:uppercase; color:var(--text-dim); margin-right:9px;
}

/* ponytail: .kpiA / .kpiB / .kpiC and their .k / .status-grid / .status-stat /
   .ksku / .kwide / .kc-* children are dead — the Overview is now just the
   #kpi-overview summary line. Left inert (they match no element); delete in a
   CSS-cleanup pass. */
/* ===== KPI Layout A — refined stat cards ===== */
.kpiA { display:grid; grid-template-columns:repeat(7, 1fr); gap:11px; }
.kpiA .k {
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
  padding:15px 16px 14px; box-shadow:var(--shadow); position:relative; overflow:hidden;
}
.kpiA .k::before {
  content:""; position:absolute; left:0; top:0; bottom:0; width:3px;
  background:var(--kc, var(--gold-soft));
}
.kpiA .k .kl {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; font-weight:600;
  letter-spacing:.1em; text-transform:uppercase; color:var(--text-mute); margin-bottom:9px;
}
.kpiA .k .kv {
  font-family:'Fraunces', Georgia, serif; font-weight:600; font-size:30px;
  line-height:.95; color:var(--kc-ink, var(--text)); letter-spacing:-.01em;
}
.kpiA .k .ks {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; color:var(--text-dim);
  margin-top:7px; letter-spacing:.02em;
}

/* ===== KPI Layout B — ledger band ===== */
.kpiB {
  display:flex; background:var(--surface); border:1px solid var(--line);
  border-radius:14px; box-shadow:var(--shadow); overflow:hidden;
}
.kpiB .k {
  flex:1; padding:18px 20px; border-left:1px solid var(--line); position:relative;
  min-width:0;
}
.kpiB .k:first-child { border-left:none; }
.kpiB .k .kl {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; font-weight:600;
  letter-spacing:.11em; text-transform:uppercase; color:var(--text-mute);
  margin-bottom:11px; display:flex; align-items:center; gap:7px;
}
.kpiB .k .kl::before {
  content:""; width:7px; height:7px; border-radius:50%; background:var(--kc, var(--gold-soft));
  flex-shrink:0;
}
.kpiB .k .kv {
  font-family:'Fraunces', Georgia, serif; font-weight:600; font-size:34px;
  line-height:.9; color:var(--kc-ink, var(--text)); letter-spacing:-.015em;
}
.kpiB .k .ks {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; color:var(--text-dim);
  margin-top:8px;
}

/* ===== KPI Layout C — consolidated executive cards ===== */
.kpiC { display:grid; grid-template-columns:minmax(500px,2.2fr) minmax(170px,.72fr) minmax(285px,1.1fr); gap:11px; }
.kpiC .k {
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
  padding:15px 16px 13px; box-shadow:var(--shadow); min-width:0;
}
.kpiC .k .kl {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; font-weight:600;
  letter-spacing:.1em; text-transform:uppercase; color:var(--text-mute);
}
.kpiC .k .kv {
  font-family:'Fraunces', Georgia, serif; font-weight:600; font-size:27px;
  line-height:1; color:var(--kc-ink, var(--text)); letter-spacing:-.01em;
}
.kpiC .k .ks {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; color:var(--text-dim);
}
.kcard-head { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:10px; }
.kcard-title {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; font-weight:600;
  letter-spacing:.1em; text-transform:uppercase; color:var(--text-mute);
}
.kcard-total { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; color:var(--text-dim); white-space:nowrap; }
.status-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); }
.status-stat { min-width:0; padding:2px 14px; border-left:1px solid var(--line); }
.status-stat:first-child { border-left:0; padding-left:0; }
.status-stat:last-child { padding-right:0; }
.status-label {
  display:flex; align-items:center; gap:6px; color:var(--text-mute);
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; font-weight:600;
  letter-spacing:.06em; text-transform:uppercase;
}
.status-label i, .qlabel i { display:block; width:7px; height:7px; border-radius:2px; background:var(--kc); flex:0 0 7px; }
.status-value-row { display:flex; flex-direction:column; gap:4px; margin-top:6px; }
.status-stat .kv { color:var(--kc-ink); }
.status-stat .ks { white-space:nowrap; }
.kpiC .k.ksku { display:flex; flex-direction:column; justify-content:center; align-items:flex-start; }
.kpiC .k.ksku .kv { font-size:32px; margin:9px 0 7px; }
/* the wide quantity card in layout C */
.kpiC .k.kwide { display:flex; flex-direction:column; justify-content:center; gap:7px; }
.kpiC .k.kwide .kcard-head { margin-bottom:2px; }
.kpiC .k.kwide .qrow { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.qlabel { display:flex; align-items:center; gap:7px; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--text-mute); }
.qmetric { display:flex; align-items:baseline; justify-content:flex-end; gap:9px; }
.kpiC .k.kwide .qv { font-family:'Fraunces', Georgia, serif; font-weight:600; font-size:22px; }
.kpiC .k.kwide .qv.dmg { color:var(--gold); }
.qpct { min-width:42px; text-align:right; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; color:var(--text-dim); }
.damage-row .qlabel i { background:var(--gold-soft); }

/* accent classes for KPI cards */
.kc-blue   { --kc:var(--gold-soft); --kc-ink:var(--gold); }
.kc-exp    { --kc:var(--s-expired);  --kc-ink:var(--s-expired); }
.kc-crit   { --kc:var(--s-critical); --kc-ink:var(--s-critical); }
.kc-warn   { --kc:var(--s-warning);  --kc-ink:var(--s-warning); }
.kc-safe   { --kc:var(--s-safe);     --kc-ink:var(--s-safe); }
.kc-good   { --kc:var(--green-soft); --kc-ink:var(--green); }
.kc-dmg    { --kc:var(--gold-soft);   --kc-ink:var(--gold); }

/* ════════ Filter bar ════════ */
.filter-bar {
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  box-shadow:var(--shadow); padding:14px 18px; margin:16px 0;
  position:sticky; top:0; z-index:10;
}
/* Main row: compact Company pills + multi-select dropdowns (Brand, Group,
   Product Type, Grade, Status), then Search which stretches up to the "More"
   button. More opens the secondary row (UOM). ≤720px: only Search + More show;
   More reveals everything (see the mobile block below). */
.filter-entry { display:flex; gap:8px; align-items:flex-end; }
.filter-entry .fg { gap:5px; min-width:0; }
.fg-sep { width:1px; align-self:stretch; background:var(--line-hi); margin:14px 2px 0; flex:0 0 auto; }
.filter-entry .fg-search { flex:1 1 160px; min-width:160px; }
.filter-entry .search-wrap { width:100%; }
.filter-entry .search-box { min-width:0; padding-top:6px; padding-bottom:6px; font-size:12.5px; }
.filter-toggle {
  display:inline-flex; align-items:center; gap:7px; flex:0 0 auto;
  font-family:'Inter', sans-serif; font-size:12.5px; font-weight:600; color:var(--text-mute);
  background:var(--surface-hi); border:1px solid var(--line-hi); border-radius:8px;
  padding:8px 13px; cursor:pointer; white-space:nowrap;
}
.filter-toggle:hover { border-color:var(--gold-soft); color:var(--text); }
.filter-toggle:focus-visible { outline:2px solid var(--gold-soft); outline-offset:2px; }
.filter-toggle .filter-count {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:11px; color:var(--gold);
}
.filter-toggle .filter-count:empty { display:none; }
.filter-chev { transition:transform .15s; font-size:10px; }
.filter-bar.open .filter-chev { transform:rotate(180deg); }

/* Active-filter chips */
.filter-chips { display:flex; flex-wrap:wrap; gap:7px; margin-top:10px; max-width:100%; }
.filter-chips[hidden] { display:none; }
/* Whole chip is the remove target (≥28px tall; the × is just the affordance). */
.chip {
  display:inline-flex; align-items:center; gap:6px; max-width:100%;
  padding:4px 6px 4px 11px; min-height:28px;
  border:0; border-radius:999px; background:var(--gold-wash); color:var(--gold);
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; font-weight:600; cursor:pointer;
}
.chip:hover { background:color-mix(in srgb, var(--gold) 20%, transparent); }
.chip:focus-visible { outline:2px solid var(--gold-soft); outline-offset:2px; }
.chip-txt { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:min(60vw, 220px); }
.chip-x {
  display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
  width:18px; height:18px; border-radius:50%; font-size:14px; line-height:1;
  background:color-mix(in srgb, var(--gold) 16%, transparent);
}
.chip.chip-clear {
  background:transparent; color:var(--text-mute); padding:4px 11px;
  border:1px solid var(--line-hi);
}
.chip.chip-clear:hover { border-color:var(--gold-soft); color:var(--text); background:transparent; }
@media (max-width:720px) {
  .chip { min-height:44px; padding-top:7px; padding-bottom:7px; }
  .chip-x { width:22px; height:22px; font-size:15px; }
  .pri-more { min-height:40px; }
  .cg-filter { min-height:38px; }
  .pri-row { min-height:44px; }
}

.filter-row { display:none; flex-wrap:wrap; gap:20px 22px; align-items:flex-end; }
/* Compact Company pills; the selected pill takes the company's table colour
   (NORTHWIND gold, Bluepeak purple — same as .b-bluepeak / .du-co.bluepeak badges). */
.btn-grp-sm { padding:2px; gap:1px; }
.btn-grp-sm .tog { padding:4px 8px; font-size:11px; }
#f-company .tog.on[data-val="Bluepeak"] { background:#8a55d0; color:#fff; }
#f-company .tog[data-val="Bluepeak"]:not(.on):hover { background:rgba(155,109,214,.14); color:#8a55d0; }
[data-theme="dark"] #f-company .tog.on[data-val="Bluepeak"] { background:#bd97e8; color:#1d1612; }
.chip[data-k="company"].chip-bluepeak { background:rgba(155,109,214,.14); color:#8a55d0; }

/* Multi-select dropdown button (shared by every filter dropdown) */
.ms-btn {
  display:inline-flex; align-items:center; gap:6px; justify-content:space-between;
  min-width:92px; max-width:140px; padding:6px 8px; font-size:11.5px;
}
.ms-btn .ms-txt { overflow:hidden; text-overflow:ellipsis; flex:1 1 auto; }
.ms-btn .ms-chev { font-size:10px; color:var(--text-dim); flex:0 0 auto; }
.ms-btn .ms-ico:empty { display:none; }
.ms-btn .ms-ico { display:inline-flex; }
.ms-btn.on { border-color:var(--gold); background:var(--gold-wash); color:var(--gold); font-weight:600; }
.ms-panel { min-width:220px; max-height:340px; overflow:auto; }
.ms-find {
  width:100%; margin-bottom:6px; padding:6px 8px; border:1px solid var(--line-hi); border-radius:6px;
  font-family:'Inter', sans-serif; font-size:12px; background:var(--surface); color:var(--text); outline:none;
}
.ms-find:focus { border-color:var(--gold); }
/* Cascading: options with no rows under the other filters are hidden */
.cbdd-item.ms-na { display:none !important; }
.cbdd-item .ms-lbl { flex:1 1 auto; }
.cbdd-item .ms-cnt { margin-left:10px; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; color:var(--text-dim); }
.ms-logo { width:18px; height:18px; object-fit:contain; border-radius:3px; flex:0 0 auto; }
.ms-logo.nolg { border-radius:50%; background:var(--surface-2); border:1px solid var(--line); }
.cbdd-item .status-dot, .ms-btn .status-dot { width:8px; height:8px; flex:0 0 auto; }
.sd-damage { background:var(--gold-soft); }
.filter-bar.open .filter-row { display:flex; margin-top:12px; }
.fg { display:flex; flex-direction:column; gap:7px; }
.fg-label {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; font-weight:600;
  letter-spacing:.12em; text-transform:uppercase; color:var(--text-dim);
}
.btn-grp {
  display:inline-flex; gap:2px; flex-wrap:nowrap; max-width:100%; padding:3px;
  border:1px solid var(--line-hi); border-radius:999px; background:var(--surface-2);
  box-shadow:inset 0 1px 2px rgba(42,29,8,.06); overflow-x:auto; scrollbar-width:none;
}
.btn-grp::-webkit-scrollbar { display:none; }
.tog {
  font-family:'Inter', sans-serif; padding:5px 12px; border-radius:999px;
  border:0; background:transparent; color:var(--text-mute); white-space:nowrap;
  font-size:11.5px; font-weight:600; cursor:pointer; transition:all .12s; line-height:1.4;
}
.tog:hover { background:var(--gold-wash); color:var(--text); }
.tog:focus-visible { outline:2px solid var(--gold-soft); outline-offset:2px; }
.tog.on {
  background:var(--gold); color:var(--gold-ink); font-weight:700;
  box-shadow:0 1px 3px rgba(42,29,8,.22);
}

.filter-sel {
  font-family:'Inter', sans-serif; padding:7px 10px; border:1px solid var(--line-hi);
  border-radius:7px; font-size:12px; background:var(--surface-hi); color:var(--text);
  outline:none; cursor:pointer; min-width:120px;
}
.filter-sel:focus { border-color:var(--gold); }
.cbdd { position:relative; }
.cbdd-btn { text-align:left; white-space:nowrap; }
.cbdd-panel {
  display:none; position:absolute; top:calc(100% + 6px); left:0; z-index:20;
  min-width:240px; padding:8px; border:1px solid var(--line-hi); border-radius:9px;
  background:var(--surface-hi); box-shadow:var(--shadow);
}
.cbdd.open .cbdd-panel { display:block; }
.cbdd-actions { display:flex; gap:6px; padding-bottom:6px; margin-bottom:6px; border-bottom:1px solid var(--line); }
.cbdd-actions button {
  font-family:'Inter', sans-serif; font-size:11px; font-weight:600; padding:3px 9px;
  border:1px solid var(--line-hi); border-radius:999px; background:transparent;
  color:var(--text-mute); cursor:pointer;
}
.cbdd-actions button:hover { border-color:var(--gold-soft); color:var(--text); }
.cbdd-item {
  display:flex; align-items:center; gap:8px; padding:5px 4px; border-radius:6px;
  font-family:'Inter', sans-serif; font-size:12.5px; color:var(--text); cursor:pointer; white-space:nowrap;
}
.cbdd-item:hover { background:var(--gold-wash); }
.cbdd-item input { accent-color:var(--gold); cursor:pointer; }
.search-wrap { position:relative; width:100%; }
.search-wrap svg {
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  width:14px; height:14px; color:var(--text-dim); pointer-events:none;
}
.search-box {
  font-family:'Inter', sans-serif; padding:8px 12px 8px 33px; border:1px solid var(--line-hi);
  border-radius:7px; font-size:13px; width:100%; min-width:320px; outline:none;
  background:var(--surface-hi); color:var(--text);
}
.search-box:focus { border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-wash); }
.search-box::placeholder { color:var(--text-dim); }

/* Desktop filter compaction (G-1). */
@media (min-width:769px) {
  .filter-bar { padding:10px 12px; }
  .filter-row { gap:10px 12px; }
  .fg { flex:0 1 auto; min-width:90px; gap:5px; }
  .filter-sel { min-width:90px; }
  .filter-sel.ms-btn { min-width:92px; }
}

/* ════════ Mid row (combo card stacked over summary) ════════ */
.mid-left { display:flex; flex-direction:column; gap:14px; min-width:0; }
.mid-left .panel { flex:0 0 auto; }
.panel { padding:16px; display:flex; flex-direction:column; }
.panel-h {
  font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:11px; font-weight:700; letter-spacing:.14em;
  text-transform:uppercase; color:var(--text-dim); margin-bottom:15px;
  display:flex; align-items:center; gap:9px;
}
.panel-h::before { content:""; width:16px; height:2px; background:var(--gold-soft); border-radius:2px; }
.panel-h .ph-count {
  margin-left:auto; font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:10px; font-weight:700;
  color:var(--gold); background:var(--gold-wash); padding:2px 8px; border-radius:999px; letter-spacing:0;
}

/* priority "expiring soon" list */
/* Expands in the page — no nested scroll box (S-10 §6). */
.pri-scroll { margin:0 -4px; padding:0 4px; }
.pri-row { display:flex; align-items:center; gap:9px; padding:4px 0; border-bottom:1px solid var(--line); }
.pri-row:last-child { border-bottom:none; }
.pri-more {
  display:inline-flex; align-items:center; margin-top:9px; min-height:32px;
  padding:5px 13px; border:1px solid var(--line-hi); border-radius:999px;
  background:var(--surface-hi); color:var(--gold); cursor:pointer;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; font-weight:600; letter-spacing:.04em;
}
.pri-more:hover { border-color:var(--gold-soft); }
.pri-ctrl { display:flex; flex-wrap:wrap; align-items:center; gap:8px 10px; margin-top:6px; }
.pri-ctrl .pri-more { margin-top:0; }
.pri-ctrl .pri-note { margin-top:0; }
.pri-note {
  display:block; margin-top:6px;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; color:var(--text-dim);
}
.pri-dl {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-weight:600; font-size:12px;
  min-width:48px; text-align:right; flex-shrink:0; font-variant-numeric:tabular-nums;
}
.pri-body { min-width:0; flex:1; }
.pri-name {
  font-size:12px; color:var(--text); line-height:1.3;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.pri-sub {
  display:flex; align-items:center; gap:6px; margin-top:1px;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; color:var(--text-mute);
}
.pri-empty {
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:11px; color:var(--s-safe);
  padding:24px 8px; text-align:center; line-height:1.5;
}

/* S-6: 0-90d urgency timeline above the Expiring Soon list */
.exp-tl { margin:0 0 4px; }
.tl-track {
  position:relative; height:18px; border-radius:6px;
  background:linear-gradient(90deg, var(--s-expired-bg) 0%, var(--s-critical-bg) 33%,
                             var(--s-warning-bg) 66%, var(--s-safe-bg) 100%);
  border:1px solid var(--line);
}
.tl-tick { position:absolute; top:3px; width:3px; height:12px; border-radius:2px; transform:translateX(-1px); opacity:.85; }
.tl-axis { display:flex; justify-content:space-between; margin-top:4px; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:8.5px; letter-spacing:.08em; text-transform:uppercase; color:var(--text-dim); }
.pri-code { font-family:'IBM Plex Sans', Inter, sans-serif; color:var(--text-dim); }
.pri-row .status-dot { width:8px; height:8px; flex-shrink:0; }
/* Grouped Expiring Soon: one row per SKU + status, lots behind a caret */
.pri-tag {
  flex-shrink:0; min-width:38px; text-align:center; padding:2px 6px; border-radius:5px;
  font:700 9.5px 'IBM Plex Sans', Inter, sans-serif; letter-spacing:.06em;
}
.pt-expired  { color:var(--s-expired);  background:var(--s-expired-bg); }
.pt-critical { color:var(--s-critical); background:var(--s-critical-bg); }
.pt-warning  { color:var(--s-warning);  background:var(--s-warning-bg); }
.pri-qty { font-weight:600; color:var(--text); font-variant-numeric:tabular-nums; }
.pri-grp { border-bottom:1px solid var(--line); }
.pri-grp:last-child { border-bottom:none; }
.pri-grp > summary { list-style:none; cursor:pointer; border-bottom:none; }
.pri-grp > summary::-webkit-details-marker { display:none; }
.pri-grp > summary:hover .pri-name { color:var(--gold); }
.pri-chev { flex-shrink:0; color:var(--text-mute); font-size:12px; transition:transform .2s; }
.pri-grp[open] .pri-chev { transform:rotate(180deg); }
.pri-lots { margin:0 0 5px 60px; border-left:2px solid var(--line); padding-left:10px; }
.pri-lot {
  display:grid; grid-template-columns:minmax(0,1.4fr) 1fr .7fr 1fr; gap:8px; padding:1px 0;
  font:500 10.5px 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute); font-variant-numeric:tabular-nums;
}
.pri-lot > :nth-child(n+3) { text-align:right; }
.pri-lot-id { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text-dim); }
@media (max-width:600px) { .pri-lots { margin-left:12px; } }

/* ═══ Overview card — stats strip on top, then Product Grade (focus, left) and
   Expiring Soon (right) side by side in ONE card. Stock by company & group was
   removed 2026-09-30. ═══ */
.ov-card { position:relative; padding:0; overflow:hidden; min-width:0; margin-bottom:18px; }
.ov-card::before {
  content:""; position:absolute; inset:0 0 auto 0; height:2px;
  background:linear-gradient(90deg, var(--gold-soft), transparent 70%);
}
/* Stats strip: one tile per figure with real breathing room — the old
   "21act/9inact" cell crammed two numbers and two words into one slot. */
.ov-stats {
  display:grid; grid-template-columns:repeat(5, minmax(0,1fr));
  border-bottom:1px solid var(--line); font-variant-numeric:tabular-nums;
}
.ovs { display:flex; flex-direction:column; gap:3px; padding:14px 14px 12px; border-left:1px solid var(--line); min-width:0; }
.ovs:first-child { border-left:none; border-top-left-radius:14px; }
/* Brand list popup under a brand tile — hover, tap or keyboard focus. */
.ovs.has-pop { position:relative; cursor:pointer; outline:none; }
.ovs.has-pop:hover, .ovs.has-pop:focus-visible { background:var(--surface-2); }
.ovs-pop {
  display:none; position:absolute; top:calc(100% - 4px); left:8px; z-index:30;
  width:max-content; max-width:280px; padding:9px 10px; flex-wrap:wrap; gap:4px;
  background:var(--surface); border:1px solid var(--line-hi); border-radius:10px; box-shadow:var(--shadow);
}
.ovs.has-pop:hover .ovs-pop, .ovs.has-pop:focus .ovs-pop { display:flex; }
.ovs-pop i {
  font:600 10.5px 'IBM Plex Sans', Inter, sans-serif; font-style:normal; white-space:nowrap;
  color:var(--text); background:var(--surface-2); border-radius:5px; padding:2px 7px;
}
/* the card clips overflow; let the popup escape the stats strip */
.ov-card { overflow:visible; }
.ovs-n { font:800 22px/1.05 'Plus Jakarta Sans', system-ui, sans-serif; color:var(--text); }
.ovs.act .ovs-n { color:var(--gold); }
.ovs.inact .ovs-n { color:var(--text-mute); }
.ovs.oos .ovs-n { color:var(--s-oos); }
.ovs-l { font:600 9.5px/1.25 'IBM Plex Sans', Inter, sans-serif; letter-spacing:.06em; text-transform:uppercase; color:var(--text-mute); }
.ovs-l em { font-style:normal; color:var(--text-dim); }
.ovs-bar { display:block; height:3px; margin-top:4px; background:var(--line); border-radius:2px; overflow:hidden; }
.ovs-bar i { display:block; height:100%; background:var(--gold-soft); border-radius:2px; transition:width .3s ease; }
.ov-body { display:grid; grid-template-columns:minmax(0,1.12fr) minmax(0,1fr); }
.ov-grade { padding:14px 16px; min-width:0; }
/* stats strip sits on top of the Product Grade pane only, bleeding to its edges */
.ov-grade > .ov-stats { margin:-14px -16px 14px; }
.ov-body > .expiring-pane { border-left:1px solid var(--line); }
@media (max-width:980px) {
  /* Single column: grade stays first so the focus point survives. */
  .ov-body { grid-template-columns:1fr; }
  .ov-body > .expiring-pane { border-left:none; border-top:1px solid var(--line); }
}
@media (max-width:600px) {
  .ov-stats { grid-template-columns:repeat(3, minmax(0,1fr)); }
  .ovs:nth-child(4) { border-left:none; }
  .ovs:nth-child(n+4) { border-top:1px solid var(--line); }
  .ovs { padding:11px 14px 10px; }
  .ovs-n { font-size:19px; }
}

/* Grade A lead sits in the Product Grade title row's right slot. */
.gc-lead { margin-left:auto; display:flex; align-items:baseline; gap:7px; letter-spacing:normal; text-transform:none; }
.gc-lead-n {
  font-family:'Fraunces', Georgia, serif; font-size:23px; font-weight:500;
  line-height:1; color:var(--gold); font-variant-numeric:tabular-nums;
}
.gc-lead-l { font:600 9.5px 'IBM Plex Sans', Inter, sans-serif; letter-spacing:.06em; text-transform:uppercase; color:var(--text-mute); white-space:nowrap; }

.gc-chart { display:flex; flex-direction:column; gap:7px; font-variant-numeric:tabular-nums; }
.gc-row { display:grid; grid-template-columns:minmax(88px,auto) 1fr auto auto; align-items:center; gap:9px; }
.gc-name { display:flex; align-items:center; gap:6px; font:600 11px 'IBM Plex Sans', Inter, sans-serif; color:var(--text); white-space:nowrap; }
.gc-name i { width:7px; height:7px; border-radius:2px; flex:0 0 auto; }
.gc-bar { height:9px; background:var(--surface-2); border-radius:5px; overflow:hidden; min-width:0; }
.gc-fill { display:block; height:100%; border-radius:5px; transition:width .35s ease; }
.gc-pct { font:700 11.5px 'IBM Plex Sans', Inter, sans-serif; color:var(--text); min-width:44px; text-align:right; }
.gc-val { font:500 10px 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute); min-width:62px; text-align:right; }
.gc-note { margin-top:10px; }

@media (max-width:560px) {
  .gc-row { grid-template-columns:minmax(76px,auto) 1fr auto; }
  .gc-val { display:none; }          /* percentage is the read; pcs go to the tooltip */
  .gc-lead-n { font-size:20px; }
}


.expiring-pane { min-width:0; padding:14px 16px; display:flex; flex-direction:column; }
.expiring-pane .panel-h { margin-bottom:6px; }
.expiring-pane .pri-scroll { flex:1; min-height:0; max-height:420px; overflow:auto; }
@media (max-width:820px) {
  .expiring-pane .pri-scroll { max-height:none; overflow:visible; }
  /* Header stats wrap to their own line under the title, but stay ONE row and
     scroll sideways rather than stacking into a tall block. Applies to every
     card that carries .ph-stats (Expiring Soon). */
  .panel-h { flex-wrap:wrap; }
  .ph-stats {
    margin-left:0; flex:1 1 100%; margin-top:8px; padding-top:8px;
    border-top:1px solid var(--line);
    flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none;
  }
  .ph-stats::-webkit-scrollbar { display:none; }
  .phs { flex:0 0 auto; }
}

/* UOM chips — color-coded so units read apart at a glance */
.uom {
  display:inline-block; padding:2px 8px; border-radius:5px;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9.5px; font-weight:600; letter-spacing:.05em;
  background:var(--surface-2); color:var(--text-mute); border:1px solid var(--line);
}
.uom.u-ctn  { background:var(--gold-wash); color:var(--gold); border-color:transparent; }
.uom.u-pcs  { background:rgba(19,153,184,.13);  color:#0e7e98; border-color:transparent; }
.uom.u-pack { background:rgba(47,158,111,.13);  color:#268059; border-color:transparent; }
.uom.u-pkt  { background:rgba(47,158,111,.13);  color:#268059; border-color:transparent; }
.uom.u-box  { background:rgba(155,109,214,.13); color:#8a55d0; border-color:transparent; }
.uom.u-bag  { background:rgba(155,109,214,.13); color:#8a55d0; border-color:transparent; }
.uom.u-set  { background:rgba(214,120,60,.13);  color:#bd6a2e; border-color:transparent; }
[data-theme="dark"] .uom.u-pcs  { color:#5cc7df; }
[data-theme="dark"] .uom.u-pack { color:#6fd0a0; }
[data-theme="dark"] .uom.u-pkt  { color:#6fd0a0; }
[data-theme="dark"] .uom.u-box  { color:#bd97e8; }
[data-theme="dark"] .uom.u-bag  { color:#bd97e8; }
[data-theme="dark"] .uom.u-set  { color:#e0a071; }
/* ════════ Tables ════════ */
.tbl-section { margin-bottom:22px; }
/* Mobile SKU cards replace the two tables at ≤600px — see the block near the
   end of this file (search "Mobile SKU cards"); hidden by default here so
   desktop/tablet keep the tables untouched down to 601px. */
.mob-cards-section { display:none; }
.tbl-hdr { display:flex; align-items:baseline; justify-content:space-between; gap:14px; margin-bottom:11px; }
.tbl-hdr h2 {
  font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:11px; font-weight:700;
  letter-spacing:.14em; text-transform:uppercase; color:var(--text-dim);
  display:flex; align-items:center; gap:9px;
}
.tbl-hdr h2::before { content:""; width:16px; height:2px; background:var(--gold-soft); border-radius:2px; }
.tbl-hdr .hint { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; color:var(--text-dim); letter-spacing:.04em; }
.rec-count { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:11px; color:var(--text-mute); letter-spacing:.03em; }
.rec-count b { color:var(--gold); font-weight:600; }

.tbl-wrap {
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  box-shadow:var(--shadow); overflow:auto; max-height:620px;
}
table.t { width:100%; border-collapse:separate; border-spacing:0;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:12.5px; }
table.t.wide { min-width:1180px; }
table.t thead th {
  background:var(--ink-1); color:#fff;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-weight:700; font-size:10.5px;
  letter-spacing:.04em; text-transform:uppercase;
  padding:8px 14px; text-align:left; white-space:nowrap;
  position:sticky; top:0; z-index:2; cursor:pointer;
  user-select:text; -webkit-user-select:text;
  border-bottom:1px solid var(--ink-line-hi);
}
table.t thead th:first-child { border-top-left-radius:0; }
table.t thead th.num { text-align:right; }
table.t thead th:hover { background:var(--ink-2); color:var(--ink-text); }
table.t thead th.sorted { color:var(--ink-gold); }
table.t thead th .si { margin-left:4px; opacity:.35; font-size:9px; user-select:none; -webkit-user-select:none; }
table.t thead th.sorted .si { opacity:1; }

table.t tbody td {
  padding:7px 14px; border-bottom:1px solid var(--line);
  white-space:nowrap; color:var(--text); vertical-align:middle;
}
table.t tbody tr:nth-child(even) td { background:var(--zebra); }
table.t tbody tr:hover td { background:var(--gold-wash); }
table.t tbody tr:last-child td { border-bottom:none; }
td.num { text-align:right; font-family:'IBM Plex Sans', Inter, sans-serif; font-variant-numeric:tabular-nums; }
td.idx { color:var(--text-dim); font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; width:34px; }
td.code { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:11px; color:var(--text-mute); }
td.name { white-space:normal; min-width:210px; max-width:320px; line-height:1.35; color:var(--text); font-weight:450; }
td.muted { color:var(--text-mute); }

/* Product Stock Detail table: explicit <colgroup> widths (table-layout:fixed) so
   short numeric columns (Days/Remaining %/Status/etc.) can't get auto-stretched
   wider than their content needs — Product Name (the one unset <col>) absorbs
   all the leftover width instead. Scoped above the mobile column-hiding
   breakpoint (600px) so the existing nth-child(display:none) mobile rules keep
   working against plain auto layout, untouched. */
@media (min-width:601px) {
  #main-t { table-layout:fixed; min-width:1348px; }
  #main-t td { overflow:hidden; text-overflow:ellipsis; }
  #main-t td.name { overflow:visible; text-overflow:clip; max-width:none; }
}

/* Keep Product QTY and Product Stock Detail rows equally compact. */
#qty-t th, #qty-t td,
#main-t th, #main-t td { padding:7px 9px; }

/* S-5: Aging Status column — colored circle only, no text label */
.status-cell { text-align:center; }
.status-dot {
  display:inline-block; width:12px; height:12px; border-radius:50%;
  vertical-align:middle; cursor:default;
}
.sd-expired  { background:var(--s-expired); }
.sd-critical { background:var(--s-critical); }
.sd-warning  { background:var(--s-warning); }
.sd-safe     { background:var(--s-safe); }
.sd-unknown  { background:var(--s-unknown); }
.sd-oos      { background:var(--s-oos); }

/* S-5: legend mapping circle colors to status, placed under Product Stock Detail table */
.status-legend {
  display:flex; flex-wrap:wrap; align-items:center; gap:8px 18px;
  margin-top:10px; padding:10px 14px;
  background:var(--surface); border:1px solid var(--line); border-radius:10px;
  box-shadow:var(--shadow);
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; color:var(--text-mute);
}
.status-legend .sl-item { display:flex; align-items:center; gap:6px; white-space:nowrap; }
.status-legend .sl-cap {
  font-weight:600; letter-spacing:.1em; text-transform:uppercase; color:var(--text-dim);
  margin-right:4px;
}

/* row status accent on detail table */
table.t tbody tr.r-expired  td:first-child { box-shadow:inset 3px 0 0 var(--s-expired); }
table.t tbody tr.r-critical td:first-child { box-shadow:inset 3px 0 0 var(--s-critical); }
table.t tbody tr.r-warning  td:first-child { box-shadow:inset 3px 0 0 var(--s-warning); }
table.t tbody tr.r-safe     td:first-child { box-shadow:inset 3px 0 0 var(--s-safe); }
table.t tbody tr.r-unknown  td:first-child { box-shadow:inset 3px 0 0 var(--s-unknown); }
table.t tbody tr.r-oos      td:first-child { box-shadow:inset 3px 0 0 var(--s-oos); }

/* quantity bar cell — "what's left" at a glance */
.qcell { position:relative; display:flex; align-items:center; justify-content:flex-end; gap:0; }
.qbar {
  position:absolute; right:0; top:50%; transform:translateY(-50%);
  height:21px; border-radius:4px; background:var(--gold-wash);
  border:1px solid color-mix(in srgb, var(--gold) 18%, transparent);
  z-index:0;
}
.qval {
  position:relative; z-index:1; font-family:'IBM Plex Sans', Inter, sans-serif;
  font-variant-numeric:tabular-nums; font-weight:600; padding:0 7px;
}
.qval.zero { color:var(--text-dim); font-weight:400; }

/* badges */
.badge {
  display:inline-block; padding:2px 8px; border-radius:5px;
  font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:9.5px; font-weight:600; letter-spacing:.04em;
  white-space:nowrap;
}
.b-expired  { background:var(--s-expired-bg);  color:var(--s-expired); }
.b-critical { background:var(--s-critical-bg); color:var(--s-critical); }
.b-warning  { background:var(--s-warning-bg);  color:var(--s-warning); }
.b-safe     { background:var(--s-safe-bg);     color:var(--s-safe); }
.b-unknown  { background:var(--s-unknown-bg);  color:var(--s-unknown); }
.b-oos      { background:var(--s-oos-bg);      color:var(--s-oos); }
.b-bluepeak    { background:rgba(155,109,214,.14); color:#8a55d0; }
.b-northwind     { background:var(--gold-wash); color:var(--gold); }
.b-vitakraft { background:rgba(155,109,214,.13); color:#8a55d0; }
.b-aatas     { background:rgba(224,123,59,.13);  color:#c0621e; }
.b-wmf      { background:rgba(19,153,184,.13); color:#0e7e98; }
.b-fmcg     { background:rgba(47,158,111,.13); color:#268059; }
[data-theme="dark"] .b-bluepeak { color:#bd97e8; }
[data-theme="dark"] .b-vitakraft { color:#bd97e8; }
[data-theme="dark"] .b-aatas { color:#f0a070; }
[data-theme="dark"] .b-wmf { color:#5cc7df; } [data-theme="dark"] .b-fmcg { color:#6fd0a0; }

.d-expired  { color:var(--s-expired);  font-weight:600; }
.d-critical { color:var(--s-critical); font-weight:600; }
.d-warning  { color:var(--s-warning);  font-weight:600; }
.d-safe     { color:var(--s-safe); }
.d-unknown  { color:var(--text-dim); }

/* Company × Group — a comparable company-volume bar followed by visible,
   three-dimension group summaries. */
.panel-h-unit {
  margin-left:auto; font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:9px;
  letter-spacing:.06em; color:var(--text-dim); text-transform:none;
}
/* ════════ Header stats (Expiring Soon title row) ════════
   tabular-nums keeps the header from reflowing when a filter changes the
   numbers; labels are 9.5px on --text-mute because --text-dim below 9px
   fails WCAG AA in both themes. Each brand number carries its own word, so
   active vs inactive is never signalled by colour alone (WCAG 1.4.1). */
.ph-stats {
  margin-left:auto; display:flex; align-items:center; gap:0;
  letter-spacing:normal; text-transform:none; font-variant-numeric:tabular-nums;
}
.phs { display:flex; align-items:baseline; gap:4px; padding:0 10px; border-left:1px solid var(--line); }
.phs:first-child { border-left:none; padding-left:0; }
.phs:last-child { padding-right:0; }
.phs-n { font:700 12.5px 'IBM Plex Sans', Inter, sans-serif; color:var(--text); }
.phs-l { font:600 9.5px 'IBM Plex Sans', Inter, sans-serif; letter-spacing:.06em; text-transform:uppercase; color:var(--text-mute); white-space:nowrap; }
/* Expired is already money lost, not a warning — the only stat that gets colour. */
.phs-n.exp-expired { color:var(--s-expired); }
/* group colours — shared by the bar segments and the legend/detail dots */
.cg-seg, .cg-grp-dot { background:var(--gold-soft); }
.cg-seg[data-g="Vitakraft"], .cg-grp-dot[data-g="Vitakraft"] { background:#9b6dd6; }
.cg-seg[data-g="Aatas"],     .cg-grp-dot[data-g="Aatas"]     { background:#e07b3b; }
.cg-seg[data-g="WMF"],       .cg-grp-dot[data-g="WMF"]       { background:#1399b8; }
.cg-seg[data-g="FMCG"],      .cg-grp-dot[data-g="FMCG"]      { background:#2f9e6f; }

.cg-chart { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 16px; }
.cg-co { display:flex; flex-direction:column; min-width:0; }
.cg-row {
  display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:10px;
  width:100%; padding:5px 6px; border-radius:7px; color:var(--text);
}
.cg-co-badge { flex-shrink:0; }
.cg-co-badge { font-size:10px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; padding:3px 9px; }
.cg-track {
  display:flex; height:20px; min-width:3px; border-radius:5px; overflow:hidden;
  background:var(--surface-2); outline:1px solid var(--line);
}
.cg-seg { height:100%; min-width:1px; }
.cg-val {
  font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:15px; font-weight:800; font-variant-numeric:tabular-nums;
  text-align:right; color:var(--text); white-space:nowrap;
}
.cg-co { padding:0 16px 6px 0; }
.cg-co:nth-child(even) { padding-right:0; }
.cg-co:nth-child(odd):not(:last-child) { border-right:1px solid var(--line); }
.cg-grp-dot { width:9px; height:9px; border-radius:2px; flex-shrink:0; }
.cg-group-actions { display:flex; flex-wrap:wrap; gap:4px; padding:1px 6px 5px; }
.cg-filter {
  display:inline-flex; align-items:center; gap:5px; flex-shrink:0; border:1px solid var(--line-hi); border-radius:999px;
  background:var(--surface-hi); color:var(--gold); font-family:'Inter', system-ui, sans-serif; font-size:10px; font-weight:600; padding:3px 8px; cursor:pointer; min-height:24px;
}
.cg-filter:hover { border-color:var(--gold-soft); }
.cg-company-dimensions { display:flex; flex-direction:column; gap:6px; padding:0 6px; }
/* Each dimension is a compact share bar: label · stacked segments · dominant
   category · denominator. The split is visible, not hidden behind a hover.
   Inter (the sales dashboard's body face) instead of the mono stack — the
   8.5px mono read thin and cramped in this pane. */
.cg-company-dimension { display:grid; grid-template-columns:96px minmax(0,1fr) max-content max-content; align-items:center; gap:8px; min-width:0; font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:10px; }
.cg-dimension-label { color:var(--text-mute); white-space:nowrap; font-weight:600; letter-spacing:.02em; }
.cg-dim-track {
  display:flex; height:10px; min-width:34px; border-radius:5px; overflow:hidden;
  background:var(--surface-2); outline:1px solid var(--line);
}
.cg-dim-seg { height:100%; min-width:2px; }
.cg-dim-empty { height:100%; width:100%; }
.cg-dimension-lead { display:inline-flex; align-items:center; gap:5px; min-width:0; color:var(--text-dim); white-space:nowrap; font-family:'Inter', system-ui, sans-serif; }
.cg-dimension-lead i { flex:none; width:6px; height:6px; border-radius:50%; }
.cg-dimension-lead b { color:var(--text); font-weight:800; }
.cg-dimension-none { color:var(--text-mute); }
.cg-dimension-total { color:var(--text); white-space:nowrap; font-family:'Inter', system-ui, sans-serif; font-weight:700; font-variant-numeric:tabular-nums; }
.cg-omission-note { padding:4px 6px 0 118px; color:var(--text-dim); font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:8px; }
.cg-dimension-legend i { display:inline-block; width:6px; height:6px; margin-right:4px; border-radius:50%; }

.cg-note {
  margin-top:9px; padding-top:8px; border-top:1px solid var(--line);
  display:flex; flex-direction:column; gap:5px;
  font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:9px; color:var(--text-dim); line-height:1.5;
}
.cg-legend { display:flex; flex-wrap:wrap; gap:5px 12px; }
.cg-legend b, .cg-dimension-legend b { color:var(--text-mute); font-weight:600; }
.cg-leg { display:flex; align-items:center; gap:5px; color:var(--text-mute); }
.cg-dimension-legend { display:flex; flex-wrap:wrap; align-items:center; gap:4px 8px; color:var(--text-dim); }
.cg-dimension-legend span { display:inline-flex; align-items:center; white-space:nowrap; }
.cg-dimension-legend .cg-legend-sep { color:var(--line-hi); font-size:10px; }
.cg-empty {
  padding:28px 8px; text-align:center; color:var(--text-dim);
  font-family:'IBM Plex Sans', system-ui, sans-serif; font-size:11px;
}
@media (max-width:720px) {
  /* Each company becomes its own calm card.  The three bars retain their
     different denominators, while the group buttons remain close to the total. */
  .cg-chart { grid-template-columns:1fr; gap:10px; }
  .cg-co, .cg-co:nth-child(even) {
    padding:10px; border:1px solid var(--line); border-radius:10px;
    background:var(--surface-2);
  }
  .cg-row { grid-template-columns:auto minmax(0,1fr) max-content; gap:7px; padding:2px 0 6px; }
  .cg-track { height:16px; }
  .cg-val { font-size:13px; font-weight:800; }
  .cg-group-actions { padding:0 0 6px; gap:5px; }
  .cg-filter { min-height:38px; padding:4px 9px; font-size:10px; font-weight:600; }
  .cg-company-dimensions { gap:7px; padding:0; }
  .cg-company-dimension { grid-template-columns:1fr max-content; gap:4px 8px; font-size:10px; }
  .cg-dimension-label { font-size:10px; color:var(--text); }
  .cg-dim-track { grid-column:1 / -1; grid-row:2; height:9px; min-width:0; }
  .cg-dimension-lead { grid-column:1; grid-row:1; }
  .cg-dimension-total { grid-column:2; grid-row:1; justify-self:end; }
  .cg-omission-note { padding-left:0; font-size:10px; }
  .cg-note { font-size:10px; gap:8px; }
  .cg-legend, .cg-dimension-legend { gap:6px 12px; }
}
@media (min-width:721px) and (max-width:960px) {
  .cg-company-dimension { grid-template-columns:1fr max-content; gap:4px 8px; }
  .cg-dim-track { grid-column:1 / -1; grid-row:2; }
  .cg-dimension-lead { grid-column:1; grid-row:1; }
  .cg-dimension-total { grid-column:2; grid-row:1; justify-self:end; }
  .cg-omission-note { padding-left:6px; }
}

.no-data { text-align:center; padding:54px; color:var(--text-dim); font-size:13px; font-family:'IBM Plex Sans', Inter, sans-serif; }
.footer {
  text-align:center; padding:22px; font-family:'IBM Plex Sans', Inter, sans-serif;
  font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--text-dim);
}
.footer b { color:var(--gold); font-weight:500; }

/* ════════ Responsive ════════ */
@media (max-width:1280px) {
  .kpiA { grid-template-columns:repeat(4, 1fr); }
  .kpiC { grid-template-columns:minmax(440px,2fr) minmax(150px,.7fr) minmax(240px,1fr); }
  .kpiB { flex-wrap:wrap; }
  .kpiB .k { flex:1 1 25%; border-bottom:1px solid var(--line); }
}
@media (max-width:760px) {
  .kpiA { grid-template-columns:repeat(2, 1fr); }
  .kpiC { grid-template-columns:repeat(2, minmax(0,1fr)); }
  .kstatus-combined { grid-column:1 / -1; }
  .shell { padding:14px 16px 32px; }
  .masthead { flex-direction:column; align-items:flex-start; gap:14px; }
  .mh-right { align-self:stretch; justify-content:flex-end; }
  /* Make KPI values slightly smaller on tablet */
  .kpiA .k .kv, .kpiB .k .kv { font-size:26px; }
  /* Table overflow scroll on mobile */
  .tbl-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
}
@media (max-width:480px) {
  .kpiA { grid-template-columns:1fr 1fr; }
  .kpiC { grid-template-columns:1fr; }
  .kstatus-combined { grid-column:auto; }
  .status-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 0; }
  .status-stat:nth-child(3) { border-left:0; padding-left:0; }
  .kpiB { flex-direction:column; }
  .kpiB .k { flex:none; border-left:none; border-bottom:1px solid var(--line); }
  /* Tap-friendly password modal inputs & buttons */
  .pw-box input { min-height:44px; }
  .pw-box button { min-height:44px; }
  .shell { padding:10px 12px 28px; }
  .masthead { padding:12px 14px; }
  .mh-titles h1 { font-size:20px; }
  .filter-bar { padding:12px 14px; }
  .filter-row { gap:14px 16px; }
}
@media (max-width:600px) {
  /* ── Masthead: compact letterhead, less vertical height ── */
  .masthead { position:relative; padding:11px 14px; gap:9px; }
  .mh-left { gap:10px; }
  .mh-mark { height:28px; }
  .mh-titles .eyebrow { font-size:8px; letter-spacing:.13em; margin-bottom:2px; }
  .mh-titles h1 { font-size:18px; }

  /* ── Overview: denser, less wasted space ── */
  .kpi-head { margin-bottom:10px; }
  .kpiC .k { padding:12px 13px; }
  .kcard-head { margin-bottom:8px; }
  .kpiC .k.ksku .kv { font-size:25px; margin:5px 0 4px; }
  .kpiC .k.kwide { gap:5px; }
  .kpiC .k.kwide .qv { font-size:16px; }

  /* ── Dated lot status: compact list instead of 2×2 grid ── */
  .status-grid { grid-template-columns:1fr; gap:0; }
  .status-stat {
    display:flex; align-items:baseline; justify-content:space-between; gap:10px;
    padding:6px 0; border-left:0; border-bottom:1px solid var(--line);
  }
  .status-stat:first-child { padding-top:0; }
  .status-stat:last-child { border-bottom:0; padding-bottom:0; }
  .status-stat:nth-child(3) { border-left:0; padding-left:0; }
  .status-value-row { flex-direction:row; align-items:baseline; gap:8px; margin-top:0; }
  .status-stat .kv { font-size:17px; }
  .status-stat .ks { font-size:9px; }

  /* ── Filter bar: compact ── */
  .tog { padding:4px 9px; font-size:11px; }
  .filter-sel { font-size:12px; padding:5px 8px; }
  .fg-label { font-size:9px; margin-bottom:3px; }

  /* ── QTY table: remove Pcs/Su, Good QTY, Damage (Type + UOM kept) ── */
  #qty-t th:nth-child(7),#qty-t td:nth-child(7),
  #qty-t th:nth-child(8),#qty-t td:nth-child(8),
  #qty-t th:nth-child(9),#qty-t td:nth-child(9) { display:none; }

  /* S-2: QTY table compact on mobile — release forced width, tighten cells */
  #qty-t { min-width:0; }
  #qty-t th, #qty-t td { padding:6px 6px; }
  #qty-t td.name .nn {
    max-width:none !important;
    white-space:normal !important;
    overflow:visible !important;
    text-overflow:clip !important;
    overflow-wrap:anywhere;
  }
  #qty-t th:nth-child(5), #qty-t td:nth-child(5) { max-width:80px; overflow:hidden; text-overflow:ellipsis; }
  #qty-t .qval { padding:0 4px; }

  /* S-2-1: Detail table compact on mobile — same treatment as QTY table */
  #main-t { min-width:0; }
  #main-t th, #main-t td { padding:6px 6px; }
  #main-t th[data-col="name"] { min-width:0 !important; } /* beats inline style attr min-width:280px */
  #main-t tbody td.name {
    max-width:none !important;
    white-space:normal !important;
    overflow:visible !important;
    text-overflow:clip !important;
    overflow-wrap:anywhere;
  }
  #main-t th:nth-child(5), #main-t td:nth-child(5) { max-width:80px; overflow:hidden; text-overflow:ellipsis; }
  #main-t .qval { padding:0 4px; }

  /* ── Detail table: remove Batch/Lot, Days Left, Remaining %, Pcs/Su, Good Qty, Damage ── */
  #main-t th:nth-child(6),#main-t td:nth-child(6),
  #main-t th:nth-child(8),#main-t td:nth-child(8),
  #main-t th:nth-child(9),#main-t td:nth-child(9),
  #main-t th:nth-child(12),#main-t td:nth-child(12),
  #main-t th:nth-child(13),#main-t td:nth-child(13),
  #main-t th:nth-child(14),#main-t td:nth-child(14) { display:none; }

  /* ── Table compact ── */
  table.t tbody td,table.t thead th { padding:7px 9px; font-size:11.5px; }
  .tbl-hdr h2 { font-size:10px; letter-spacing:.12em; }
  .tbl-hdr .hint { display:none; }
  td.name { min-width:140px; max-width:none; }
}

/* ════════ Password modal ════════ */
dialog.pw-modal {
  position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  border:none; border-radius:14px; padding:0; background:transparent; box-shadow:none;
  max-width:380px; width:90%;
}
dialog.pw-modal::backdrop { background:rgba(14,10,8,.92); backdrop-filter:blur(7px); }
.pw-box {
  background:var(--ink-1); border:1px solid var(--ink-line-hi); border-radius:14px; padding:36px;
  box-shadow:0 30px 70px -30px rgba(0,0,0,.85);
}
.pw-brand { font-family:'Fraunces', Georgia, serif; font-size:24px; font-weight:600; color:var(--ink-text); letter-spacing:-.02em; margin-bottom:5px; }
.pw-brand em { font-style:italic; color:var(--ink-gold); font-weight:400; }
.pw-sub { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; color:var(--ink-gold-soft); margin-bottom:24px; text-transform:uppercase; letter-spacing:.12em; }
.pw-box input {
  width:100%; padding:11px 14px; border-radius:8px; border:1px solid var(--ink-line-hi);
  background:#0e0a08; color:#f4ecdd; font-family:'Inter', sans-serif; font-size:13px;
  outline:none; margin-bottom:12px;
}
.pw-box input:focus { border-color:var(--ink-gold); }
.pw-err { color:#f08a8a; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; margin-bottom:10px; min-height:1.3em; }
.pw-box button {
  width:100%; padding:11px; border-radius:8px; border:none; background:var(--ink-gold);
  color:#2a1d08; font-family:'Inter', sans-serif; font-size:13px; font-weight:700; cursor:pointer;
  transition:background .15s;
}
.pw-box button:hover:not(:disabled) { background:var(--ink-gold-soft); }
.pw-box button:disabled { opacity:.5; cursor:not-allowed; }

/* ── Light-mode password modal ── */
[data-theme="light"] .pw-box {
  background:var(--surface-2); border-color:var(--line-hi);
  box-shadow:0 30px 70px -30px rgba(42,29,8,.22);
}
[data-theme="light"] .pw-brand { color:var(--text); }
[data-theme="light"] .pw-sub { color:var(--gold-soft); }
[data-theme="light"] .pw-box input {
  background:var(--surface); border-color:var(--line-hi); color:var(--text);
}
[data-theme="light"] .pw-box input::placeholder { color:var(--text-dim); }
[data-theme="light"] .pw-box input:focus { border-color:var(--gold); }
[data-theme="light"] .pw-box button { background:var(--gold-soft); color:#2a1d08; }
[data-theme="light"] .pw-box button:hover:not(:disabled) { background:var(--gold); color:#fff8ed; }
[data-theme="light"] .pw-err { color:#8c1c1c; }

/* ════════ Mobile filter panel (≤720px) — expanded controls scroll in place ════════ */
@media (max-width:720px) {
  .filter-bar.open .filter-row { max-height:64vh; overflow-y:auto; }
  .fg { width:100%; }
  .filter-sel { width:100%; }
  .search-box { min-width:0; width:100%; }
  /* Mobile: Search + More on one line; More reveals the main filters too */
  .filter-entry { flex-wrap:wrap; }
  .filter-entry .fg-main, .filter-entry .fg-sep { display:none; }
  .filter-bar.open .filter-entry .fg.fg-main { display:flex; width:100%; }
  .filter-entry .fg-search { order:-1; flex:1 1 0; width:auto; }
  .filter-entry .fg-search .fg-label { display:none; }
  .filter-entry .filter-toggle { order:-1; }
  .ms-btn { max-width:none; width:100%; }
  .ms-panel { width:100%; }
}

/* ═══ Reorder view ═══ */

/* Page selector — underline tabs in the right cluster (beside Data updates /
   theme). Selected = gold text + 2px gold underline; unselected = dim ink on
   the dark masthead. The Reorder count rides in its own pill. A hairline
   (.rh-sep) separates the tabs from the utility controls. */
.page-switch {
  display:inline-flex; align-items:center; gap:18px;
  padding:0; border:0; border-radius:0; background:transparent;
}
.page-switch .tog {
  display:inline-flex; align-items:center; gap:5px;
  min-height:auto; padding:0 0 5px; border:0; border-radius:0;
  color:var(--ink-mute); background:transparent;
  font-family:'Inter', sans-serif; font-size:12.5px; font-weight:600;
  letter-spacing:.01em; white-space:nowrap; cursor:pointer; position:relative;
  transition:color .16s;
}
.page-switch .tog::after {
  content:""; position:absolute; left:0; right:0; bottom:-1px; height:2px;
  background:transparent; border-radius:2px;
}
.page-switch .tog:hover:not(.on) { color:var(--ink-text); }
.page-switch .tog:focus-visible { outline:2px solid var(--ink-gold-soft); outline-offset:2px; }
.page-switch .tog.on {
  color:var(--ink-gold); background:transparent;
  box-shadow:none; font-weight:700;
}
.page-switch .tog.on::after { background:var(--ink-gold); }
/* hairline between the view tabs and the Data updates / theme controls */
.rh-sep { width:1px; align-self:stretch; margin:4px 2px; background:var(--ink-line-hi); }
.vt-badge {
  display:inline-flex; align-items:center; justify-content:center;
  min-width:15px; height:14px; padding:0 4px;
  border-radius:999px; font-family:'IBM Plex Sans', Inter, sans-serif;
  font-size:8.5px; font-weight:700; line-height:1;
  color:var(--ink-gold-soft); background:var(--ink-line-hi);
}
.page-switch .tog.on .vt-badge { color:var(--ink-gold); background:rgba(240,179,64,.22); }
.vt-badge:empty { display:none; }

/* ════════ Mobile bottom navigation (≤720px) ════════
   Replaces the masthead page switcher on phones. Fixed to the bottom, clears the
   home-indicator safe area, and the content column gets matching bottom padding
   so the last rows stay above it. */
.bottom-nav { display:none; }
@media (max-width:720px) {
  .bottom-nav {
    display:grid; grid-template-columns:1fr 1fr;
    position:fixed; left:0; right:0; bottom:0; z-index:50;
    background:linear-gradient(180deg, var(--ink-2) 0%, var(--ink-1) 100%);
    border-top:1px solid var(--ink-line-hi);
    padding-bottom:env(safe-area-inset-bottom, 0px);
    box-shadow:0 -6px 20px -12px rgba(0,0,0,.5);
  }
  .bn-item {
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    min-height:54px; padding:8px 4px; border:0; background:transparent; cursor:pointer;
    font-family:'Inter', sans-serif; font-size:11px; font-weight:600; letter-spacing:.02em;
    color:var(--ink-mute); transition:color .14s;
  }
  .bn-item svg { width:19px; height:19px; pointer-events:none; }
  .bn-item.on { color:var(--ink-gold); }
  .bn-item:focus-visible { outline:2px solid var(--ink-gold-soft); outline-offset:-3px; }
  .bn-item .vt-badge { color:var(--ink-gold-soft); background:var(--ink-line-hi); }
  .bn-item.on .vt-badge { color:var(--ink-gold); background:rgba(240,179,64,.22); }

  /* content clears the fixed bar */
  #dashboard-content { padding-bottom:calc(54px + env(safe-area-inset-bottom, 0px)); }
  /* the masthead switcher is redundant on phones — the bottom nav owns it */
  .masthead .page-switch { display:none; }
}

/* ── Reorder action strip (replaces mosaic) ── */
.rx-card {
  position:relative; overflow:hidden; margin-bottom:14px;
}
.rx-card::before {
  content:""; position:absolute; inset:0 0 auto 0; height:2px;
  background:linear-gradient(90deg, var(--gold-soft), transparent 70%);
}
.rx-stats {
  display:grid; grid-template-columns:minmax(0,1.25fr) repeat(4, minmax(0,1fr));
  font-variant-numeric:tabular-nums;
}
.rxs {
  display:flex; flex-direction:column; gap:3px; padding:13px 14px 11px;
  border-left:1px solid var(--line); min-width:0;
}
.rxs:first-child { border-left:none; }
.rxs.hero { background:color-mix(in srgb, var(--mk-order) 7%, transparent); }
.rxs-n {
  font:800 22px/1.05 'Plus Jakarta Sans', system-ui, sans-serif;
  color:var(--text); display:flex; align-items:baseline; gap:6px;
}
.rxs.hero .rxs-n { font-size:30px; color:var(--ro-order); }
.rxs.watch .rxs-n { color:var(--ro-watch); }
.rxs-n small { font:600 11px 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute); letter-spacing:.02em; }
.rxs-l {
  font:600 9.5px/1.25 'IBM Plex Sans', Inter, sans-serif;
  letter-spacing:.06em; text-transform:uppercase; color:var(--text-mute);
  display:flex; align-items:center; gap:6px;
}
.rxs-l i { width:7px; height:7px; border-radius:2px; background:var(--c, var(--gold-soft)); flex:0 0 7px; }
.rxs-s { font:500 10.5px 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rxs-s b { color:var(--text); font-weight:600; }
.rxs-s .late { color:var(--s-expired); font-weight:600; }
.rx-mix {
  display:flex; align-items:center; gap:14px; padding:9px 14px 10px;
  border-top:1px solid var(--line);
}
.rx-mix-bar {
  flex:0 0 220px; display:flex; height:8px; border-radius:4px; overflow:hidden;
  gap:1px; background:var(--line);
}
.rx-mix-bar i { display:block; height:100%; }
.rx-chips {
  display:flex; gap:6px; flex-wrap:nowrap; overflow-x:auto;
  scrollbar-width:none; min-width:0;
}
.rx-chips::-webkit-scrollbar { display:none; }
.rx-chip {
  display:inline-flex; align-items:center; gap:6px; padding:3px 9px;
  border-radius:999px; border:1px solid var(--line); background:var(--surface);
  font:600 10.5px 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute);
  white-space:nowrap; cursor:pointer; min-height:24px;
}
.rx-chip i { width:7px; height:7px; border-radius:50%; background:var(--c); flex:0 0 7px; }
.rx-chip b { color:var(--text); font-weight:700; font-variant-numeric:tabular-nums; }
.rx-chip:hover { border-color:var(--line-hi); background:var(--surface-2); }
.rx-chip:focus-visible { outline:2px solid var(--gold-soft); outline-offset:2px; }
.rx-chip[aria-pressed="true"] { border-color:var(--c); background:color-mix(in srgb, var(--c) 12%, transparent); color:var(--text); }
.rx-chip.zero { opacity:.55; }

/* ── Active / Inactive / All brand switch (same pill idiom as .btn-grp/.tog) ── */
.rx-seg {
  display:inline-flex; gap:2px; padding:3px; border:1px solid var(--line-hi); border-radius:999px;
  background:var(--surface-2);
}
.rx-seg-btn {
  font:600 11px 'Inter', sans-serif; padding:4px 11px; border:0; border-radius:999px;
  background:transparent; color:var(--text-mute); cursor:pointer; white-space:nowrap; min-height:26px;
}
.rx-seg-btn:hover { color:var(--text); background:var(--gold-wash); }
.rx-seg-btn:focus-visible { outline:2px solid var(--gold-soft); outline-offset:2px; }
.rx-seg-btn.on { background:var(--gold); color:var(--gold-ink); font-weight:700; }
/* "Inactive" word tag — the word carries the meaning, the muting only supports it */
.rx-inact {
  display:inline-block; margin-left:7px; padding:1px 6px; border-radius:999px; vertical-align:middle;
  font:700 9.5px 'IBM Plex Sans', Inter, sans-serif; letter-spacing:.06em; text-transform:uppercase;
  color:var(--text-mute); background:var(--surface-2); border:1px solid var(--line);
}
tr.rx-inact-row > td > :not(.rx-inact):not(.rx-tog),
tr.rx-inact-row .rx-tog > :not(.rx-inact):not(.rx-chev) { opacity:.7; }
.rxs-hid { color:var(--text-mute); font-weight:600; }
.rxs-n.d-safe { color:var(--s-safe); }

/* the card clips overflow; let the popup escape the stats strip */
.rx-card { overflow:visible; }
.rxs.has-pop { position:relative; cursor:pointer; outline:none; }
.rxs.has-pop:hover, .rxs.has-pop:focus-visible { background:var(--surface-2); }
.rxs.has-pop:hover .ovs-pop, .rxs.has-pop:focus .ovs-pop { display:flex; }

/* ── Compact toolbar ── */
.rx-toolbar {
  display:flex; align-items:center; gap:10px; margin:0 0 14px; padding:8px 10px;
  background:var(--surface); border:1px solid var(--line); border-radius:12px;
}
.rx-reset {
  font:600 11px 'Inter', sans-serif; color:var(--gold); background:none; border:0;
  cursor:pointer; padding:4px 6px; white-space:nowrap;
}
.rx-reset:hover { text-decoration:underline; }

/* ── Brand + PO side by side grid ── */
.rx-grid {
  display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.45fr);
  gap:14px; margin-bottom:16px; align-items:start;
}
.rx-grid > section { min-width:0; }
.rx-grid .tbl-wrap { max-height:380px; }
@media (max-width:1100px) { .rx-grid { grid-template-columns:minmax(0,1fr); } }

/* ── Table section headers for rx-grid ── */
.rx-ph {
  display:flex; align-items:center; gap:10px; margin-bottom:9px;
}
.rx-ph h2 {
  font-family:'Plus Jakarta Sans', system-ui, sans-serif; font-size:11px; font-weight:700;
  letter-spacing:.14em; text-transform:uppercase; color:var(--text-dim);
  display:flex; align-items:center; gap:9px;
}
.rx-ph h2::before { content:""; width:16px; height:2px; background:var(--gold-soft); border-radius:2px; }
.rx-count {
  margin-left:auto; font:700 10px 'Plus Jakarta Sans', sans-serif;
  color:var(--gold); background:var(--gold-wash); padding:2px 8px; border-radius:999px;
}
.rx-count.late { color:var(--s-expired); background:color-mix(in srgb, var(--s-expired) 10%, transparent); }
.rx-xall {
  font:600 10.5px 'Inter', sans-serif; color:var(--gold); background:none; border:0;
  cursor:pointer; padding:3px 4px;
}
.rx-xall:hover { text-decoration:underline; }
.rx-foot {
  margin-top:7px; font:500 10px/1.5 'IBM Plex Sans', Inter, sans-serif; color:var(--text-mute);
}
.rx-foot summary { display:inline; cursor:pointer; color:var(--gold); }
.rx-foot-body { display:block; margin-top:4px; font-size:9px; line-height:1.5; }
.reorder-coverage-mismatch { color:var(--ro-order); font-weight:700; }
.reorder-ownership-details { margin-top:5px; color:var(--text-dim); font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; line-height:1.5; }
.reorder-ownership-details summary { cursor:pointer; color:var(--text-mute); }
.reorder-ownership-details span { display:block; margin-top:4px; }

/* ── Brand table cell helpers ── */
.rx-ow { display:inline-flex; gap:8px; justify-content:flex-end; font-variant-numeric:tabular-nums; }
.rx-ow b { font-weight:700; }
.rx-ow .o { color:var(--ro-order); }
.rx-ow .w { color:var(--ro-watch); }
.rx-ow .z { color:var(--text-dim); font-weight:400; }
.rx-po-n {
  font:600 10px 'IBM Plex Sans', sans-serif; color:var(--gold);
  background:var(--gold-wash); border-radius:5px; padding:1px 6px;
}
.rx-sugg { font-weight:800; font-family:'Plus Jakarta Sans', sans-serif; color:var(--text); font-variant-numeric:tabular-nums; }

/* ── Expand toggle (shared Brand + PO) ── */
.rx-tog {
  display:inline-flex; align-items:center; gap:7px; padding:0; border:0;
  background:none; color:inherit; font:inherit; cursor:pointer; text-align:left; min-height:24px;
}
.rx-tog:focus-visible { outline:2px solid var(--gold-soft); outline-offset:3px; border-radius:4px; }
.rx-chev {
  display:inline-grid; place-items:center; width:18px; height:18px;
  border-radius:5px; border:1px solid var(--line-hi); color:var(--text-mute);
  font-size:9px; flex:0 0 18px;
  transition:transform .15s cubic-bezier(.2,.7,.3,1), background .12s;
}
.rx-tog:hover .rx-chev { background:var(--surface-2); color:var(--text); }
.rx-tog[aria-expanded="true"] .rx-chev {
  transform:rotate(90deg); background:var(--gold); border-color:var(--gold); color:var(--gold-ink);
}
.rx-subn { margin-left:7px; font:600 9.5px 'IBM Plex Sans', sans-serif; color:var(--text-mute); letter-spacing:.04em; white-space:nowrap; }
.rx-tog .rx-subn { margin-left:0; }
table.t tbody tr.rx-open > td { background:var(--gold-wash) !important; border-bottom-color:transparent; }
table.t tbody tr.rx-sub > td { padding:0 !important; background:transparent !important; border-bottom:1px solid var(--line); }
table.t tbody tr.rx-sub:hover > td { background:transparent !important; }

/* ── B · Tree rows (desktop sub-row style) ── */
table.t tbody tr.sb-row > td { padding:5px 8px; font-size:11.5px; background:var(--surface-hi); }
table.t tbody tr.sb-row:hover > td { background:var(--gold-wash); }
.sb-name {
  position:relative; display:block; padding-left:30px; white-space:nowrap;
  overflow:hidden; text-overflow:ellipsis; max-width:220px;
}
.sb-name::before {
  content:""; position:absolute; left:13px; top:-6px; bottom:50%; width:12px;
  border-left:1px solid var(--line-hi); border-bottom:1px solid var(--line-hi);
  border-bottom-left-radius:5px;
}
tr.sb-row:not(.sb-last) .sb-name::after {
  content:""; position:absolute; left:13px; top:50%; bottom:-6px;
  border-left:1px solid var(--line-hi);
}
.sb-name .code { font-size:10px; }
.sb-dot { display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:5px; vertical-align:middle; background:var(--c); }
.sb-st { font:600 10px 'IBM Plex Sans', sans-serif; color:var(--text-mute); }

/* ── C · Mini cards (mobile sub-row style, ≤600px) ── */
.sc-wrap {
  display:grid; grid-template-columns:repeat(auto-fill, minmax(170px, 1fr));
  gap:8px; padding:4px 10px 12px 34px;
}
.sc-card {
  position:relative; padding:8px 10px 8px 12px; border:1px solid var(--line);
  border-radius:9px; background:var(--surface-hi); min-width:0;
}
.sc-card::before {
  content:""; position:absolute; left:0; top:8px; bottom:8px; width:3px;
  border-radius:0 3px 3px 0; background:var(--c);
}
.sc-top { display:flex; align-items:center; justify-content:space-between; gap:6px; }
.sc-code { font:600 9.5px 'IBM Plex Sans', sans-serif; color:var(--text-mute); letter-spacing:.03em; }
.sc-name { font:500 11.5px/1.3 'IBM Plex Sans', Inter, sans-serif; color:var(--text); margin:3px 0 6px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sc-kv { display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:4px; font-variant-numeric:tabular-nums; }
.sc-kv span { display:flex; flex-direction:column; gap:1px; font:700 13px 'Plus Jakarta Sans', sans-serif; color:var(--text); }
.sc-kv em { font:600 9.5px 'IBM Plex Sans', sans-serif; font-style:normal; letter-spacing:.05em; text-transform:uppercase; color:var(--text-mute); }

/* ── SKU table: 3px status edge + cover bar ── */
#reorder-sku-t tbody tr { --edge: transparent; }
#reorder-sku-t tbody tr td:first-child { box-shadow:inset 3px 0 0 var(--edge); }
.rx-cover { display:inline-flex; align-items:center; gap:6px; justify-content:flex-end; }
.rx-cover s { display:block; width:38px; height:4px; border-radius:2px; background:var(--line); overflow:hidden; text-decoration:none; }
.rx-cover s i { display:block; height:100%; background:var(--c, var(--ro-ok)); }

.reorder-toolbar {
  display:flex; align-items:flex-end; justify-content:flex-start; gap:18px;
  margin:4px 0 14px; padding:10px 0 12px; border-bottom:1px solid var(--line);
}
/* The redesigned Reorder toolbar is a card: the legacy rule above zeroes the side
   padding and bottom-aligns, which jams the Brand select and Reset into the border. */
.rx-toolbar.reorder-toolbar { padding:10px 16px; margin:0 0 14px; }
@media (min-width:901px) {
  .rx-toolbar.reorder-toolbar { align-items:center; }
}
.reorder-filters { display:flex; gap:12px; flex:1; }
.reorder-filters .fg.grow { flex:1; margin-left:auto; max-width:420px; }
.reorder-filters .fg.grow .search-box { min-width:0; }
.ro-badge {
  display:inline-block; padding:2px 8px; border-radius:6px; font-size:10.5px;
  font-weight:600; letter-spacing:.02em; white-space:nowrap;
}
.ro-order { background:var(--ro-order); color:#fff; }
.ro-watch { background:var(--ro-watch); color:#fff; }
.ro-ok    { background:var(--ro-ok);    color:#fff; }
.ro-over  { background:var(--ro-over);  color:#fff; }
.ro-nov   { background:var(--ro-nov);   color:#fff; }
.ro-uncfg { background:var(--ro-uncfg); color:#fff; }
.ro-conflict { background:var(--ro-conflict); color:#fff; }
[data-theme="dark"] .ro-order { color:#3b0a07; }
[data-theme="dark"] .ro-watch { color:#332700; }
[data-theme="dark"] .ro-ok    { color:#052e16; }
[data-theme="dark"] .ro-over  { color:#071c3a; }
[data-theme="dark"] .ro-nov   { color:#18181b; }
[data-theme="dark"] .ro-uncfg { color:#27123b; }
[data-theme="dark"] .ro-conflict { color:#500724; }
.ro-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:5px; vertical-align:middle; }
.ro-dot.ro-order { background:var(--ro-order); }
.ro-dot.ro-watch { background:var(--ro-watch); }
.ro-dot.ro-ok    { background:var(--ro-ok); }
.ro-dot.ro-over  { background:var(--ro-over); }
.ro-dot.ro-nov   { background:var(--ro-nov); }
.ro-dot.ro-uncfg { background:var(--ro-uncfg); }
.ro-dot.ro-conflict { background:var(--ro-conflict); }

/* By Brand — expand/collapse SKU sub-rows */
.ro-brand-toggle {
  display:inline-flex; align-items:center; padding:0; border:0; background:transparent;
  color:inherit; font:inherit; text-align:left; cursor:pointer;
}
.ro-brand-toggle:focus-visible { outline:2px solid var(--gold); outline-offset:3px; border-radius:3px; }
.ro-caret {
  display:inline-block; width:12px; margin-right:5px; color:var(--text-dim);
  transition:transform .15s; font-size:10px;
}
.ro-brand-toggle[aria-expanded="true"] .ro-caret { transform:rotate(90deg); }
#reorder-brand-t .ro-subhead td {
  background:var(--surface-2); color:var(--text-dim);
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; font-weight:600;
  letter-spacing:.06em; text-transform:uppercase; padding:6px 8px;
  white-space:normal; line-height:1.15; vertical-align:middle; text-align:center; overflow:visible;
}
.ro-subhead td[data-col] { cursor:pointer; user-select:none; }
.ro-subhead td[data-col]:hover { color:var(--ink-text); background:var(--ink-2); }
.ro-subhead td .si { margin-left:3px; opacity:.4; font-size:8px; }
.ro-subhead td.sorted { color:var(--ink-gold); }
.ro-subhead td.sorted .si { opacity:1; }
.ro-srow { background:var(--zebra); font-size:11px; }
.ro-srow td:first-child { padding-left:18px; }
.ro-srow .code { font-size:10px; }
.ro-brow td { vertical-align:middle; }
.ro-brand-toggle { min-height:20px; }
.ro-brand-id { display:inline-flex; align-items:center; gap:7px; min-width:0; }
.ro-brand-logo {
  position:relative; display:inline-grid; place-items:center;
  width:28px; height:20px; flex:0 0 28px; overflow:hidden; border-radius:4px;
  background:#fff; border:1px solid color-mix(in srgb, var(--brand-color) 34%, var(--line));
}
.ro-brand-initial { color:var(--brand-color); font-family:'IBM Plex Sans', Inter, sans-serif; font-size:9px; font-weight:800; }
.ro-brand-logo img { position:absolute; inset:1px; z-index:1; display:block; width:calc(100% - 2px); height:calc(100% - 2px); object-fit:contain; background:#fff; }
.ro-brand-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ro-company-tag { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:8px; font-weight:700; letter-spacing:.04em; }

/* Reorder tables: compact vertical rhythm */
#reorder-brand-t thead th, #reorder-sku-t thead th { padding:8px 10px; white-space:normal; line-height:1.2; vertical-align:middle; text-align:center; }
#reorder-brand-t thead th .si, #reorder-sku-t thead th .si { margin-left:2px; }
#reorder-brand-t tbody > tr > td,
#reorder-sku-t tbody > tr > td { padding:7px 9px; }
#reorder-brand-t .qbar, #reorder-sku-t .qbar { height:16px; }
#reorder-brand-t .qval, #reorder-sku-t .qval { padding:0 5px; }
#reorder-brand-t .ro-badge, #reorder-sku-t .ro-badge { padding:2px 7px; font-size:10px; white-space:nowrap; }
#reorder-sku-t td:nth-child(3) { text-align:center; }
#reorder-sku-t .ro-product { min-width:260px; white-space:nowrap; }
.ro-product-line { display:inline; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ro-product-meta { display:inline; margin-left:8px; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:8.5px; letter-spacing:.035em; color:var(--text-dim); white-space:nowrap; }

/* Open PO expand — SKU lines under each PO row */
.po-toggle { color:inherit; }
.po-sub { background:var(--zebra); font-size:11px; font-family:'IBM Plex Sans', Inter, sans-serif; }
.po-sub td:first-child { padding-left:26px; }
.po-sub .code { font-size:10px; }

/* Open PO Status pills — same geometry as .ro-badge, dark ink on a light fill
   so it reads in both themes without a per-theme ink override. */
.po-badge {
  display:inline-block; padding:2px 8px; border-radius:6px; font-size:10.5px;
  font-weight:600; letter-spacing:.02em; white-space:nowrap;
}
.po-badge.pob-late  { background:#fecaca; color:#7f1d1d; }
.po-badge.pob-eta   { background:#fde68a; color:#713f12; }
.po-badge.pob-in    { background:#bbf7d0; color:#14532d; }
.po-badge.pob-other { background:#e2e8f0; color:#334155; }
@media (max-width:600px) { .po-badge { padding:2px 6px; font-size:10px; } }

/* Fixed column widths above the 600px mobile breakpoint. */
@media (min-width:601px) {
  #reorder-brand-t, #reorder-sku-t, #reorder-po-t { table-layout:fixed; }
  #reorder-brand-t tbody tr td:first-child,
  #reorder-po-t tbody tr:not(.po-sub) td:first-child { overflow:hidden; text-overflow:ellipsis; }
  #reorder-sku-t tbody td:not(:nth-child(2)):not(:nth-child(3)) { overflow:hidden; text-overflow:ellipsis; }
  /* tree-row children: let name wrap and use the full column width */
  #reorder-brand-t tbody tr.sb-row td:first-child,
  #reorder-po-t .po-sub td:first-child { white-space:normal; word-break:break-word; }
  #reorder-brand-t tbody tr.sb-row .sb-name,
  #reorder-po-t .po-sub .sb-name { max-width:none; }

  /* By Brand: 6 cols — Brand name auto, On hand, Order·Watch, Lowest cover, POs, Suggested */
  #reorder-brand-t th:nth-child(1) { width:auto; }
  #reorder-brand-t th:nth-child(2) { width:100px; }
  #reorder-brand-t th:nth-child(3) { width:110px; }
  #reorder-brand-t th:nth-child(4) { width:72px; }
  #reorder-brand-t th:nth-child(5) { width:54px; }
  #reorder-brand-t th:nth-child(6) { width:82px; }

  /* SKU detail: 9 cols (no New cover) */
  #reorder-sku-t th:nth-child(1) { width:34px; }
  #reorder-sku-t th:nth-child(2) { width:auto; }
  #reorder-sku-t th:nth-child(3) { width:104px; }
  #reorder-sku-t th:nth-child(4) { width:70px; }
  #reorder-sku-t th:nth-child(5) { width:62px; }
  #reorder-sku-t th:nth-child(6) { width:70px; }
  #reorder-sku-t th:nth-child(7) { width:62px; }
  #reorder-sku-t th:nth-child(8) { width:66px; }
  #reorder-sku-t th:nth-child(9) { width:74px; }

  /* Open PO: 5 cols */
  #reorder-po-t th:nth-child(2) { width:140px; }
  #reorder-po-t th:nth-child(3) { width:100px; }
  #reorder-po-t th:nth-child(4) { width:120px; }
  #reorder-po-t th:nth-child(5) { width:64px; }
}

#view-reorder .tbl-section .tbl-wrap {
  max-height:520px; overflow:auto; overscroll-behavior:contain;
  scrollbar-gutter:stable;
}

@media (max-width:900px) {
  .reorder-toolbar { align-items:flex-start; flex-direction:column; }
  .reorder-filters { flex-wrap:wrap; }
}
@media (max-width:600px) {
  .mh-left { flex-wrap:wrap; width:100%; }
  /* the view tabs now live in .mh-right; on a phone the bottom nav owns them,
     so hide the masthead copy and its separator. */
  .masthead .page-switch, .masthead .rh-sep { display:none; }
}

/* Reorder is a working view on a phone: filters use the full width without
   pushing the page sideways, and wide data stays inside deliberate scroll areas. */
@media (max-width:720px) {
  #view-reorder .reorder-toolbar {
    margin:0 0 14px; padding:12px; gap:10px;
    border:1px solid var(--line); border-radius:12px; background:var(--surface);
  }
  #view-reorder .reorder-filters {
    display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:10px; width:100%;
  }
  #view-reorder .reorder-filters .fg { width:auto; min-width:0; }
  #view-reorder .reorder-filters .fg.grow { grid-column:1 / -1; max-width:none; margin-left:0; }
  #view-reorder .reorder-filters .filter-sel,
  #view-reorder .reorder-filters .search-wrap { width:100%; min-width:0; }
  #view-reorder .reorder-filters .search-box { min-height:42px; }
  #view-reorder .tbl-section { margin-bottom:22px; }
  #view-reorder .tbl-hdr { align-items:flex-start; gap:6px; }
  #view-reorder .tbl-hdr h2 { font-size:15px; }
  #view-reorder .tbl-wrap { max-height:60vh; border:1px solid var(--line); border-radius:10px; }
  #reorder-po-t { min-width:620px; }
  /* rx-toolbar wraps to two rows on small screens */
  .rx-toolbar { flex-wrap:wrap; }
  .rx-toolbar .reorder-filters { flex:1 1 100%; }
  /* the brand switch fills its grid cell and splits evenly, so 320px never overflows */
  #view-reorder .rx-seg { display:flex; width:100%; min-width:0; }
  #view-reorder .rx-seg-btn { flex:1 1 0; min-width:0; padding:4px 6px; min-height:36px; }
}
/* action strip stays one row on mobile — house rule: compact strips scroll sideways */
@media (max-width:820px) {
  .rx-stats { display:flex; overflow-x:auto; scrollbar-width:none; }
  .rx-stats::-webkit-scrollbar { display:none; }
  .rxs { flex:0 0 auto; min-width:128px; }
  .rx-mix { flex-wrap:wrap; gap:8px; }
  .rx-mix-bar { flex:1 1 100%; }
}
/* mini cards used on phone for sub-row expand (<=600px), tree rows on desktop */
@media (max-width:600px) {
  .rx-grid .tbl-wrap { max-height:none; }
}

/* ════════ Phone-first dashboard arrangement ════════
   Keep the identity, view choice and report dates in deliberate rows. This avoids
   the previous narrow, wrap-prone masthead where the important controls were hard
   to scan or tap. */
@media (max-width:600px) {
  .masthead {
    display:grid;
    grid-template-columns:minmax(0, 1fr);
    gap:10px;
    padding:13px 14px 12px;
  }
  .mh-left {
    display:grid;
    grid-template-columns:minmax(0, 1fr);
    column-gap:10px;
    row-gap:9px;
    align-items:center;
  }
  .mh-titles { grid-column:1; grid-row:1; min-width:0; }
  .mh-titles .eyebrow { font-size:8px; letter-spacing:.11em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .mh-titles h1 { font-size:20px; }
  /* The view tabs now sit in .mh-right on desktop; on a phone the fixed bottom
     nav (≤720px) owns them, so the masthead copy is hidden — no grid placement
     needed here. */
  .shell { padding:16px 12px 30px; }
  .kpi-head { margin-bottom:11px; }
  .section-label { font-size:10px; letter-spacing:.12em; }
  .kpi-overview { font-size:18px; line-height:1.25; overflow-wrap:anywhere; }

  .filter-bar { margin:14px 0 18px; padding:10px; border-radius:12px; }
  .filter-toggle { min-height:42px; padding:10px 12px; }
  .filter-bar.open .filter-row { max-height:60vh; padding:2px; }

  .ov-grade, .expiring-pane { padding:14px; }
  .ov-grade > .ov-stats { margin:-14px -14px 14px; }
  .ov-card { border-radius:12px; }
  .expiring-pane .pri-scroll { max-height:none; }
  .tbl-section { margin-bottom:24px; }
  .tbl-hdr { align-items:center; margin-bottom:9px; }
  .rec-count { font-size:10px; text-align:right; }
}

/* ════════ Mobile SKU cards (≤600px) — replaces Product QTY / Detail tables ════════
   Desktop/tablet (≥601px) keep the original tables untouched; only the
   .mob-cards-section visibility + the two table sections' display are flipped
   inside the media query below. Component styling reuses .card/.tog/.badge/
   .status-dot/.pri-code idioms already defined above — no new tokens. */
.mc-legend {
  display:flex; flex-wrap:wrap; gap:8px 14px; margin:0 0 10px; padding:8px 12px;
  background:var(--surface); border:1px solid var(--line); border-radius:10px;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; color:var(--text-mute);
}
.mc-legend .sl-item { display:flex; align-items:center; gap:5px; white-space:nowrap; }
.mc-list { display:flex; flex-direction:column; gap:9px; }
.mc-card {
  background:var(--surface); border:1px solid var(--line); border-left:3px solid var(--s-unknown);
  border-radius:12px; box-shadow:var(--shadow); overflow:hidden;
}
.mc-card.sd-edge-expired  { border-left-color:var(--s-expired); }
.mc-card.sd-edge-critical { border-left-color:var(--s-critical); }
.mc-card.sd-edge-warning  { border-left-color:var(--s-warning); }
.mc-card.sd-edge-safe     { border-left-color:var(--s-safe); }
.mc-card.sd-edge-oos      { border-left-color:var(--s-oos); }
.mc-head {
  display:flex; align-items:center; gap:10px; width:100%; min-height:44px;
  padding:11px 12px; border:0; background:transparent; color:inherit; text-align:left;
  font:inherit;
}
.mc-head-main { min-width:0; flex:1; user-select:text; -webkit-user-select:text; cursor:text; }
.mc-name { font-size:12.5px; color:var(--text); line-height:1.35; overflow-wrap:anywhere; }
.mc-meta { display:flex; align-items:center; gap:5px; margin-top:3px; font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10px; color:var(--text-mute); flex-wrap:wrap; }
.mc-head-stats { display:flex; flex-direction:column; align-items:flex-end; gap:3px; flex-shrink:0; user-select:text; -webkit-user-select:text; cursor:text; }
.mc-qty { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:12px; font-weight:600; color:var(--text); }
.mc-days { font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; }
.mc-toggle { display:grid; place-items:center; width:44px; height:44px; margin:-8px -8px -8px 0; padding:0; flex:0 0 44px; border:0; border-radius:8px; background:transparent; color:inherit; cursor:pointer; }
.mc-toggle:focus-visible { outline:2px solid var(--gold-soft); outline-offset:-2px; }
.mc-chev { color:var(--text-dim); transition:transform .15s; flex-shrink:0; }
.mc-toggle[aria-expanded="true"] .mc-chev { transform:rotate(180deg); }
.mc-lots { border-top:1px solid var(--line); padding:8px 12px 10px; display:flex; flex-direction:column; gap:7px; }
.mc-lots[hidden] { display:none; }
.mc-lot {
  display:flex; flex-wrap:wrap; align-items:center; gap:4px 10px; padding:2px 0;
  font-family:'IBM Plex Sans', Inter, sans-serif; font-size:10.5px; color:var(--text-mute);
}
.mc-lot-exp { color:var(--text); }
.mc-lot-batch { flex-basis:100%; color:var(--text-dim); font-size:9.5px; overflow-wrap:anywhere; }
@media (max-width:600px) {
  .mob-cards-section { display:block; }
  #qty-tbl-section, #detail-tbl-section { display:none; }
}
.gc-sep{height:1px;background:var(--border,rgba(128,128,128,.25));margin:8px 0}
