/* Stockroom — industrial tokens, layout, components, print. */
:root {
  color-scheme: light;
  --bg: #ECECE7;
  --surface: #FAFAF7;
  --surface-2: #F2F2EE;
  --surface-hover: #F0F0EA;
  --ink: #1C1C1A;
  --muted: #66665F;
  --faint: #8A8A82;
  --line: #D6D5CE;
  --line-strong: #B9B8B0;
  --grid-line: #C9C8C0;
  --head-bg: #E4E4DE;
  --accent: #F2C230;           /* safety yellow: fills only, dark ink on top */
  --accent-hover: #E3B21F;
  --accent-ink: #1C1C1A;
  --accent-soft: #FBEFC4;
  --link: #13505B;             /* deep teal: links and focus */
  --link-hover: #0C3A42;
  --focus: #13505B;
  --st-in: #2F6B3B;
  --st-in-soft: #E1EDE2;
  --st-low: #A86400;
  --st-low-text: #8A5200;
  --st-low-soft: #F7EAD3;
  --st-out: #B3261E;
  --st-out-soft: #F6E1DF;
  --info-soft: #DDEBEC;
  --neutral-soft: #E6E6E0;
  --chart-in: #007A99;
  --chart-out: #B7860B;
  --chart-grid: #DCDBD4;
  --chart-bar: #13505B;
  --side-bg: #1C1C1A;
  --side-ink: #E8E8E2;
  --side-muted: #A3A39A;
  --side-line: #34342F;
  --side-hover: #2A2A26;
  --shadow-pop: 0 10px 30px rgba(28, 28, 26, 0.18), 0 1px 3px rgba(28, 28, 26, 0.1);
  --radius: 4px;
  --ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --head: 'Barlow Semi Condensed', 'Barlow', 'Arial Narrow', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --sidebar-w: 236px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #161614;
    --surface: #1F1F1C;
    --surface-2: #252522;
    --surface-hover: #292926;
    --ink: #ECECE6;
    --muted: #A9A9A0;
    --faint: #85857D;
    --line: #34342F;
    --line-strong: #46463F;
    --grid-line: #3A3A34;
    --head-bg: #2A2A26;
    --accent: #F2C230;
    --accent-hover: #F7CF4E;
    --accent-ink: #1C1C1A;
    --accent-soft: #3A3218;
    --link: #6FC3CF;
    --link-hover: #93D6DF;
    --focus: #6FC3CF;
    --st-in: #6CC07A;
    --st-in-soft: #1E3322;
    --st-low: #E9A23B;
    --st-low-text: #EDB056;
    --st-low-soft: #3A2C14;
    --st-out: #F2766C;
    --st-out-soft: #3D1D1A;
    --info-soft: #1B3236;
    --neutral-soft: #2C2C28;
    --chart-in: #1FA0B8;
    --chart-out: #B08210;
    --chart-grid: #33332E;
    --chart-bar: #6FC3CF;
    --side-bg: #111110;
    --side-ink: #E8E8E2;
    --side-muted: #9A9A92;
    --side-line: #2A2A26;
    --side-hover: #22221F;
    --shadow-pop: 0 12px 34px rgba(0, 0, 0, 0.55);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: 0.005em; }
h2 { font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--line); padding: 0 4px; border-radius: 2px; }
.mono, .qty { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.qty { font-size: 0.94em; }
.qty.zero { color: var(--faint); }
.qty.neg, .neg { color: var(--st-out); }
.qty.muted, .muted { color: var(--muted); }
.small { font-size: 13px; }
.strong, .strong .qty { font-weight: 600; }
.nowrap { white-space: nowrap; }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.late { color: var(--st-out); font-weight: 600; }
.eyebrow { font-family: var(--head); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; z-index: 100; font-weight: 600; border-radius: var(--radius); }
.skip-link:focus { top: 12px; }
.print-only { display: none; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--side-bg); color: var(--side-ink);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 4px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 18px 18px 16px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-name { font-family: var(--head); font-weight: 700; font-size: 21px; text-transform: uppercase; letter-spacing: 0.06em; display: flex; flex-direction: column; line-height: 1.05; }
.brand-org { font-family: var(--ui); font-size: 11.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--side-muted); margin-top: 3px; }
.sidebar .brand { border-bottom: 1px solid var(--side-line); color: var(--side-ink); }
.sidebar .brand:hover { color: var(--side-ink); }
.nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.nav a, .mobile-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius);
  color: var(--side-ink); text-decoration: none; font-weight: 500; font-size: 15px; position: relative;
}
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a .ic { color: var(--side-muted); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.nav a[aria-current="page"] .ic { color: var(--accent-ink); }
.nav :focus-visible, .sidebar :focus-visible { outline-color: var(--accent); }
.nav-count { margin-left: auto; font-family: var(--mono); font-size: 11.5px; font-weight: 600; min-width: 22px; padding: 1px 6px; text-align: center; border-radius: 2px; background: var(--side-line); color: var(--side-ink); }
.nav a[aria-current="page"] .nav-count { background: var(--accent-ink); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 18px 18px; border-top: 1px solid var(--side-line); font-size: 12.5px; color: var(--side-muted); display: flex; flex-direction: column; gap: 8px; }
.wh-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; color: var(--side-ink); }
.wh-list .eyebrow { color: var(--side-muted); font-size: 11px; }
.wh-list .mono { display: inline-block; width: 34px; color: var(--accent); font-size: 12px; }
.sidebar .linklike { color: var(--accent); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-align: left; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 28px; min-height: 58px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .brand-top { display: none; padding: 0; }
.topbar .brand-top .brand-name { font-size: 18px; }
.topbar-date { font-size: 14px; display: flex; gap: 8px; align-items: baseline; }
.topbar-spacer { flex: 1; }
.topbar .nav-toggle { display: none; }
h1:focus, h1:focus-visible { outline: none; }
.user-switch { display: flex; align-items: center; gap: 8px; }
.user-switch label { font-size: 13px; color: var(--muted); }
.user-switch select { width: auto; min-width: 0; max-width: 260px; font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: var(--radius); display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 13px; background: var(--ink); color: var(--surface); flex: none; }
.avatar[data-role="admin"] { background: var(--accent); color: var(--accent-ink); }
.avatar[data-role="manager"] { background: var(--link); color: #fff; }
@media (prefers-color-scheme: dark) { .avatar[data-role="manager"] { color: #111; } }
.mobile-nav { background: var(--side-bg); padding: 8px 12px 14px; border-bottom: 4px solid var(--accent); }
.mobile-nav a { color: var(--side-ink); }
.mobile-nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.mobile-nav .nav-count { margin-left: auto; }
.mobile-nav-foot { padding: 10px 10px 0; color: var(--side-muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.mobile-nav .linklike { color: var(--accent); }

main { padding: 24px 28px 40px; outline: none; flex: 1; width: 100%; max-width: 1480px; }
.demo-note { padding: 14px 28px 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.view { display: flex; flex-direction: column; gap: 18px; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head .eyebrow { display: block; margin-bottom: 4px; }
.mono-h1 { font-family: var(--mono); font-weight: 600; font-size: 28px; letter-spacing: -0.01em; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; gap: 8px; font-size: 13.5px; color: var(--muted); align-items: center; margin-bottom: -8px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 7px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  font: 600 14.5px/1.1 var(--ui); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); color: var(--ink); border-color: var(--ink); }
.btn-primary { background: var(--accent); border-color: #C99A10; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--ink); color: var(--accent-ink); }
.btn-danger { background: var(--st-out); border-color: var(--st-out); color: #fff; }
.btn-danger:hover { background: #941F18; color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger, .btn-danger:hover { color: #1C1C1A; } }
.btn-danger-ghost { color: var(--st-out); border-color: currentColor; background: transparent; }
.btn-danger-ghost:hover { background: var(--st-out-soft); color: var(--st-out); border-color: var(--st-out); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13.5px; }
.btn-icon { padding: 6px; min-width: 38px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[aria-disabled="true"] { opacity: 0.62; cursor: not-allowed; border-style: dashed; background: var(--surface-2); color: var(--muted); border-color: var(--line-strong); }
.btn[aria-disabled="true"]:hover { background: var(--surface-2); color: var(--muted); }
.input {
  width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: 400 15px/1.3 var(--ui);
}
.input:hover { border-color: var(--muted); }
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--st-out); box-shadow: inset 0 0 0 1px var(--st-out); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2366665F' stroke-width='1.6'/%3E%3C/svg%3E"); background-position: right 10px center; background-size: 10px 6px; background-repeat: no-repeat; }
@media (prefers-color-scheme: dark) { select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23A9A9A0' stroke-width='1.6'/%3E%3C/svg%3E"); } }
textarea.input { resize: vertical; min-height: 64px; }
.mono-input { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; }
input[type="file"].input { padding: 6px; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 600; color: var(--ink); }
fieldset.field { border: 0; padding: 0; margin: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); }
.err { color: var(--st-out); font-size: 13px; font-weight: 500; }
.err:empty { display: none; }
.err-inline { color: var(--st-out); font-weight: 600; }
.callout { padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); display: flex; gap: 10px; align-items: flex-start; }
.callout .ic { margin-top: 1px; }
.callout-warn { background: var(--st-low-soft); border-color: var(--st-low); border-left-width: 4px; }
.callout-action { background: var(--accent-soft); border-color: #C99A10; border-left-width: 4px; }
.callout-danger { background: var(--st-out-soft); border-color: var(--st-out); border-left-width: 4px; }
.err.callout { background: var(--st-out-soft); border-color: var(--st-out); }
.note { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); padding: 10px 0 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters .field { min-width: 150px; flex: 0 1 190px; }
.filters .field.grow { flex: 1 1 240px; }
.inline-filters { padding: 0; border: 0; background: none; flex-wrap: nowrap; }
.inline-filters .field { min-width: 140px; flex: 0 0 170px; }
.result-count { font-size: 13.5px; color: var(--muted); margin: -6px 0 -8px; }
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); width: max-content; max-width: 100%; overflow: hidden; background: var(--surface); }
.seg-btn { border: 0; border-right: 1px solid var(--line); background: transparent; padding: 7px 12px; font: 600 13.5px var(--ui); color: var(--ink); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.seg-n { font-size: 12px; opacity: 0.75; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 48px; }
.card-head.wrap { flex-wrap: wrap; align-items: flex-end; }
.card-head h2 { position: relative; padding-left: 12px; }
.card-head h2::before { content: ''; position: absolute; left: 0; top: 1px; bottom: 1px; width: 4px; background: var(--accent); }
.card-body { padding: 16px; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2-wide { grid-template-columns: 1.15fr 1fr; }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); position: relative; min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--surface-hover); color: var(--ink); }
.kpi::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: transparent; }
.kpi:first-child::before { background: var(--accent); }
.kpi-low::before { background: var(--st-low) !important; }
.kpi-out::before { background: var(--st-out) !important; }
.kpi-label { font-family: var(--head); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.kpi-value { font-size: 27px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.kpi-low .kpi-value { color: var(--st-low-text); }
.kpi-out .kpi-value { color: var(--st-out); }
.kpi-sub { font-size: 13px; color: var(--muted); }

/* ---------- charts ---------- */
[data-chart] { position: relative; }
.chart-tip { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 6px 9px; border-radius: 3px; white-space: nowrap; z-index: 5; font-family: var(--mono); box-shadow: var(--shadow-pop); }
.hbar { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.hbar-row, .hbar-axis { display: grid; grid-template-columns: 110px 1fr 120px; gap: 12px; align-items: center; }
.hbar-row { border-radius: 2px; }
.hbar-row:hover .hbar-fill { filter: brightness(1.15); }
.hbar-label { font-weight: 600; font-size: 14px; white-space: nowrap; }
.wh-code { font-size: 11.5px; font-weight: 600; background: var(--ink); color: var(--surface); padding: 1px 4px; border-radius: 2px; margin-right: 2px; }
.hbar-track { height: 28px; border-left: 2px solid var(--ink); position: relative; display: block; }
.hbar-track .gl { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--chart-grid); }
.hbar-fill { position: relative; }
.hbar-fill { display: block; height: 100%; background: var(--chart-bar); border-radius: 0 4px 4px 0; }
.hbar-val { font-size: 13.5px; font-weight: 600; text-align: right; white-space: nowrap; }
.hbar-ticks { position: relative; height: 14px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.hbar-ticks span { position: absolute; transform: translateX(-50%); }
.hbar-ticks span:first-child { transform: none; }
.hbar-ticks span:last-child { transform: translateX(-100%); }
.flow-svg { width: 100%; height: auto; display: block; overflow: visible; }
.flow-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.flow-svg .axis { stroke: var(--ink); stroke-width: 1.5; }
.flow-svg .tick { fill: var(--muted); font: 11px var(--mono); }
.flow-svg .axis-cap { fill: var(--muted); font: 600 11px var(--head); text-transform: uppercase; letter-spacing: 0.06em; }
.flow-svg .bar-in { fill: var(--chart-in); }
.flow-svg .bar-out { fill: var(--chart-out); }
.flow-svg .hit { fill: transparent; cursor: crosshair; }
.flow-svg .hover-col { fill: var(--ink); opacity: 0.07; display: none; }
.flow-svg .hover-col.on { display: inline; }
.flow-summary { display: flex; gap: 18px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.flow-summary .mono { font-size: 18px; font-weight: 600; }
.flow-summary .muted { flex-basis: 100%; }
.legend { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 12px; height: 12px; display: inline-block; border-radius: 2px; }
.sw-in { background: var(--chart-in); }
.sw-out { background: var(--chart-out); }
.chart-table { margin-top: 10px; font-size: 13.5px; }
.chart-table summary { cursor: pointer; color: var(--link); font-weight: 600; width: max-content; }
.chart-table .table-wrap { max-height: 260px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.table-wrap:focus-visible { outline-offset: -3px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table thead th { background: var(--head-bg); font-family: var(--head); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink); white-space: nowrap; border-bottom: 2px solid var(--ink); vertical-align: bottom; }
.table tbody tr:hover { background: var(--surface-hover); }
.table .num { text-align: right; }
.table tfoot th, .table tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 600; background: var(--surface-2); }
.grid-table th + th, .grid-table td + td, .grid-table th + td, .grid-table td + th { border-left: 1px solid var(--grid-line); }
.grid-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.grid-table tbody tr:nth-child(even):hover { background: var(--surface-hover); }
.table.compact th, .table.compact td { padding: 7px 10px; }
.card > .table-wrap .table thead th { border-top: 0; }
.sort-btn { all: unset; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.sort-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.sort-btn .arrow { font-size: 10px; color: var(--muted); }
th[aria-sort="ascending"] .arrow, th[aria-sort="descending"] .arrow { color: var(--ink); }
th[aria-sort="ascending"], th[aria-sort="descending"] { background: var(--accent-soft); }
th.num .sort-btn { flex-direction: row; }
.wh-col.is-focus { background: var(--accent-soft) !important; }
.sku { font-family: var(--mono); font-weight: 500; font-size: 13.5px; white-space: nowrap; }
.strong-link { font-weight: 600; }
.name-cell { min-width: 220px; }
.row-error { background: var(--st-out-soft) !important; }
.err-list { margin: 0; padding-left: 16px; color: var(--st-out); font-size: 13px; }
.ok-text { color: var(--st-in); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.ok-text .ic { width: 16px; height: 16px; }
.is-src { background: var(--accent-soft) !important; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 2px; font: 600 12.5px/1.5 var(--ui); white-space: nowrap; border: 1px solid transparent; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.st-in { background: var(--st-in-soft); color: var(--st-in); border-color: color-mix(in srgb, var(--st-in) 35%, transparent); }
.st-low { background: var(--st-low-soft); color: var(--st-low-text); border-color: color-mix(in srgb, var(--st-low) 45%, transparent); }
.st-low .dot { border-radius: 1px; transform: rotate(45deg); width: 7px; height: 7px; }
.st-out { background: var(--st-out-soft); color: var(--st-out); border-color: color-mix(in srgb, var(--st-out) 40%, transparent); }
.st-out .dot { border-radius: 0; height: 2.5px; width: 9px; }
.po-draft { background: var(--neutral-soft); color: var(--muted); border-color: var(--line-strong); border-style: dashed; }
.po-pending { background: var(--accent); color: var(--accent-ink); }
.po-approved { background: var(--info-soft); color: var(--link); border-color: color-mix(in srgb, var(--link) 35%, transparent); }
.po-ordered { background: var(--surface); color: var(--link); border-color: var(--link); }
.po-partially_received { background: var(--st-low-soft); color: var(--st-low-text); border-color: color-mix(in srgb, var(--st-low) 45%, transparent); }
.po-received { background: var(--st-in-soft); color: var(--st-in); border-color: color-mix(in srgb, var(--st-in) 35%, transparent); }
.po-cancelled { background: var(--st-out-soft); color: var(--st-out); text-decoration: line-through; text-decoration-thickness: 1px; }
.role-tag { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.role-admin { color: var(--ink); background: var(--accent); padding: 0 4px; border-radius: 2px; }
.role-manager { color: var(--link); }
.role-clerk { color: var(--muted); }
.mv-tag { display: inline-block; font: 600 12px/1.5 var(--ui); padding: 0 6px; border-radius: 2px; border-left: 3px solid; background: var(--surface-2); white-space: nowrap; }
.mv-receipt { border-color: var(--st-in); }
.mv-shipment { border-color: var(--chart-out); }
.mv-transfer_in, .mv-transfer_out { border-color: var(--link); }
.mv-adjustment { border-color: var(--ink); }

/* ---------- overview lists ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 130px 1fr auto; grid-template-areas: "tag main qty" "tag when qty"; gap: 1px 12px; padding: 9px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .mv-tag { grid-area: tag; justify-self: start; white-space: normal; }
.feed-main { grid-area: main; font-size: 14px; min-width: 0; }
.feed-when { grid-area: when; }
.feed-qty { grid-area: qty; font-weight: 600; }
.qty.signed:not(.neg) { color: var(--st-in); }
.empty-inline { padding: 16px; color: var(--muted); font-size: 14px; }
.empty { text-align: center; padding: 40px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty-ic .ic { width: 32px; height: 32px; color: var(--faint); }
.empty-title { font-family: var(--head); font-weight: 700; font-size: 18px; color: var(--ink); }

/* ---------- pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); }
.card .pager { padding: 10px 16px; border-top: 1px solid var(--line); }
.pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pg[aria-current="page"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

/* ---------- product detail ---------- */
.span-2 { min-width: 0; }
.stock-table th[scope="row"] { font-weight: 600; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 4px 0 0; font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.preview-line { font-size: 14px; padding: 8px 10px; background: var(--surface-2); border-left: 3px solid var(--accent); }
.preview-line:empty { display: none; }
.timeline { list-style: none; margin: 0; padding: 6px 16px 12px; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; background: var(--ink); }
.t-what { font-weight: 600; }
.t-meta { font-size: 12.5px; color: var(--muted); }
.t-change, .changes-cell { font-size: 13.5px; }
.t-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.change { display: block; }
.change .from { color: var(--muted); text-decoration: line-through; }
.change .arrow { color: var(--muted); }

/* ---------- transfers ---------- */
.transfer-layout { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; gap: 18px; align-items: start; }
.avail-grid:empty { display: none; }
.avail-grid { display: flex; flex-direction: column; gap: 6px; }
.compact-field { min-width: 200px; }

/* ---------- PO ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.stepper li { flex: 1; padding: 10px 12px 10px 22px; font-family: var(--head); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); position: relative; border-right: 1px solid var(--line); min-width: 0; }
.stepper li:last-child { border-right: 0; }
.stepper li::before { content: ''; position: absolute; left: 9px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border: 1.5px solid currentColor; }
.stepper li.done { color: var(--ink); }
.stepper li.done::before { background: var(--ink); border-color: var(--ink); }
.stepper li.current { background: var(--accent); color: var(--accent-ink); }
.stepper li.current::before { background: var(--accent-ink); border-color: var(--accent-ink); }
.stepper li.dim { opacity: 0.6; }
.po-doc-head { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.po-parties { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.po-parties > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.po-parties .eyebrow { margin-bottom: 2px; }
.po-note { font-size: 14px; }
.status-tl { list-style: none; margin: 0; padding: 12px 16px; display: flex; flex-direction: column; }
.status-tl li { display: flex; gap: 12px; padding: 6px 0; position: relative; }
.status-tl li:not(:last-child)::after { content: ''; position: absolute; left: 5px; top: 22px; bottom: -8px; width: 2px; background: var(--line); }
.tl-dot { width: 12px; height: 12px; margin-top: 4px; background: var(--ink); flex: none; }
.status-tl .s-pending .tl-dot { background: var(--accent); outline: 1px solid var(--ink); }
.status-tl .s-received .tl-dot { background: var(--st-in); }
.status-tl .s-partially_received .tl-dot { background: var(--st-low); }
.status-tl .s-cancelled .tl-dot { background: var(--st-out); }
.status-tl .s-draft .tl-dot { background: var(--surface); outline: 2px dashed var(--muted); outline-offset: -2px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.span-all { grid-column: 1 / -1; }
.line-editor td { vertical-align: top; }
.line-editor .input { min-width: 0; }
.line-editor td:first-child { min-width: 240px; }
.qty-input { width: 96px; text-align: right; margin-left: auto; }
.cost-input { width: 120px; text-align: right; margin-left: auto; }
.line-foot { justify-content: space-between; }
.totals { display: grid; grid-template-columns: auto auto; gap: 2px 16px; margin: 0; text-align: right; }
.totals dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--head); font-weight: 600; }
.totals dd { margin: 0; font-size: 15px; }
.totals dd.strong { font-size: 20px; }
.approval-note { font-size: 13.5px; color: var(--muted); }
.approval-note:empty { display: none; }
.approval-note.is-over { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); }
.po-form { display: flex; flex-direction: column; gap: 18px; }
.dlg-tools { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.recv-table .input { width: 90px; }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line-strong); border-top: 5px solid var(--accent); border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog.wide { width: min(820px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(20, 20, 18, 0.55); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 18px; text-transform: none; letter-spacing: 0.01em; }
.dlg-body { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.lead { color: var(--muted); font-size: 14.5px; }
.check-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); }
.check-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--link); }
.check-row .sub { display: block; overflow-wrap: anywhere; }
.check-row.inline { border: 0; padding: 0; grid-template-columns: auto 1fr; }
.import-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.import-row .btn { margin-top: 23px; }
.imp-summary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.imp-table { max-height: 320px; overflow: auto; border: 1px solid var(--line); }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px 11px 14px; background: var(--ink); color: var(--surface); border-radius: var(--radius); border-left: 5px solid var(--accent); box-shadow: var(--shadow-pop); font-size: 14px; }
.toast.is-error { border-left-color: var(--st-out); }
.toast > span { flex: 1; }
.t-close { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: 0.8; }
.t-close .ic { width: 16px; height: 16px; }
.t-close:focus-visible { outline-color: var(--accent); }

/* ---------- 404 ---------- */
.nf { max-width: 560px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.nf-code { font-size: 64px; font-weight: 600; background: var(--accent); color: var(--accent-ink); padding: 0 18px; border-radius: var(--radius); line-height: 1.2; }
.nf p { color: var(--muted); }
.nf .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid-2, .grid-2-wide, .detail-grid { grid-template-columns: 1fr; }
  .hide-md { display: none; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .transfer-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar .nav-toggle { display: inline-flex; }
  .topbar { padding: 8px 16px; gap: 10px; }
  .topbar .brand-top { display: flex; }
  .topbar-date { display: none; }
  main { padding: 18px 16px 32px; }
  .demo-note { padding: 14px 16px 22px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .po-parties { grid-template-columns: 1fr 1fr; }
  .stepper { flex-wrap: wrap; }
  .stepper li { flex: 1 1 33%; border-bottom: 1px solid var(--line); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 25px; }
  .mono-h1 { font-size: 23px; }
  .user-switch label { display: none; }
  .user-switch select { max-width: 170px; font-size: 14px; }
  .avatar { display: none; }
  .topbar { gap: 8px; }
  .user-switch { min-width: 0; flex: 0 1 auto; }
  .hide-sm { display: none; }
  .kpi { padding: 12px 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11.5px; }
  .filters { padding: 10px; }
  .filters .field, .filters .field.grow, .inline-filters .field { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .filters .field.grow { flex-basis: 100%; }
  .field-row, .form-grid, .po-parties { grid-template-columns: 1fr; }
  .hbar-row, .hbar-axis { grid-template-columns: 74px 1fr 96px; gap: 8px; }
  .hbar-label { font-size: 13px; }
  .hbar-label .wh-code { display: none; }
  .hbar-val .muted { display: none; }
  .hbar-ticks span:nth-child(2), .hbar-ticks span:nth-child(4) { display: none; }
  .wh-stats th, .wh-stats td { padding: 6px 8px; }
  .flow-svg .tick { font-size: 15px; }
  .flow-svg .axis-cap { font-size: 14px; }
  .feed li { grid-template-columns: 1fr auto; grid-template-areas: "tag qty" "main qty" "when qty"; padding: 9px 12px; }
  .card-head { padding: 10px 12px; }
  .card-body { padding: 12px; }
  .page-head { align-items: flex-start; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
  .stepper li { flex: 1 1 50%; font-size: 11.5px; }
  .seg { width: 100%; }
  .seg-btn { flex: 1 1 auto; justify-content: center; padding: 7px 8px; border-bottom: 1px solid var(--line); }
  .import-row .btn { margin-top: 0; }
  .crumbs { margin-bottom: -4px; }
  .compact-field { min-width: 0; width: 100%; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .line-editor td:first-child { min-width: 180px; }
  .chart-tip { white-space: normal; max-width: 240px; }
  .table { font-size: 13.5px; }
  .table th, .table td { padding: 7px 8px; }
  .table thead th { font-size: 11px; letter-spacing: 0.03em; }
  .stock-table .wh-code { display: none; }
  .wh-stats .table thead th { white-space: normal; }
  .sug-table .sub { display: none; }
  .sug-table .badge { padding: 2px 5px; }
}

/* ---------- product cards (phones) ---------- */
.card-list { display: none; list-style: none; margin: 0; padding: 0; }
@media (max-width: 640px) {
  #table-slot .table-wrap { display: none; }
  .card-list { display: flex; flex-direction: column; gap: 8px; }
  .pcard { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; }
  .pcard:has(.st-low) { border-left-color: var(--st-low); }
  .pcard:has(.st-out) { border-left-color: var(--st-out); }
  .pcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .pcard-name { font-weight: 500; margin: 4px 0 8px; }
  .pcard-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin: 0; border-top: 1px solid var(--line); padding-top: 6px; }
  .pcard-stats > div { min-width: 0; }
  .pcard-stats > div + div { border-left: 1px solid var(--line); padding-left: 6px; }
  .pcard-stats dt { font-family: var(--head); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pcard-stats abbr { text-decoration: none; }
  .pcard-stats dd { margin: 0; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 14mm; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4f4f1; --ink: #000; --muted: #444; --line: #bbb; --grid-line: #bbb; --head-bg: #eee; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .mobile-nav, .demo-note, .toast-stack, .no-print, .skip-link, .crumbs { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; }
  .print-only { display: block; }
  .print-brand { font-family: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 3px solid #000; padding-bottom: 6px; margin-bottom: 8px; }
  .po-doc-head { padding: 0 0 12px; }
  .table-wrap { overflow: visible; }
  .table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .page-head .eyebrow { color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media (forced-colors: active) { .nav a[aria-current="page"], .stepper li.current, .btn-primary { border: 2px solid CanvasText; } }

@media (max-width: 480px) {
  .topbar .brand-top .brand-name { display: none; }
  .user-switch select { max-width: 220px; }
  .inline-filters { flex-wrap: wrap; width: 100%; }
  .inline-filters .field { flex: 1 1 calc(50% - 10px); min-width: 0; }
}
.wh-stats { margin-top: 18px; }
abbr[title] { text-decoration: none; }
.card-head.wrap.center { align-items: center; }
