/* ============================================================
   Quietstock — base.css (required foundation, all projects)
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: none; text-size-adjust: none;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; scroll-behavior: smooth;
}
body {
  min-height: 100dvh; line-height: 1.55;
  font-family: var(--font-body); font-size: var(--text-base);
  color: var(--color-text); background-color: var(--color-bg);
}
img, svg { display: block; max-width: 100%; height: auto; }
ul[role='list'] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; }
p, li { text-wrap: pretty; }
::selection { background: color-mix(in oklab, var(--color-primary) 25%, transparent); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }
a, button, [role='button'], input, select {
  transition: color .18s cubic-bezier(.16,1,.3,1), background .18s cubic-bezier(.16,1,.3,1),
              border-color .18s cubic-bezier(.16,1,.3,1), box-shadow .18s cubic-bezier(.16,1,.3,1);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   Design tokens — Quietstock brand (derived from the desktop app)
   ============================================================ */
:root {
  /* Fixed brand tokens — do not change between light/dark, used for the sidebar shell */
  --color-sidebar-bg: #1B4332;
  --color-sidebar-bg-hover: #163A2A;
  --color-sidebar-active: #2D6A4F;
}
:root, [data-theme='light'] {
  --color-bg: #F7F5F0;
  --color-surface: #FFFFFF;
  --color-surface-2: #FBFAF7;
  --color-surface-offset: #F0EDE6;
  --color-border: #E4E1D8;
  --color-divider: #EAE7DE;

  --color-text: #1F2933;
  --color-text-muted: #5B6770;
  --color-text-faint: #94A0A8;
  --color-text-inverse: #F7F5F0;

  --color-primary: #1B4332;
  --color-primary-hover: #122E21;
  --color-primary-light: #2D6A4F;
  --color-primary-highlight: #DCE7DF;

  --color-accent: #C9A227;
  --color-accent-hover: #AD8A1E;
  --color-accent-light: #E0BE55;
  --color-accent-highlight: #F3E9C8;

  --color-success: #2D6A4F;
  --color-warning: #AD8A1E;
  --color-error: #A13544;
  --color-error-highlight: #F1D8DB;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(20,30,25,.06);
  --shadow-md: 0 6px 20px rgba(20,30,25,.08);
  --shadow-lg: 0 16px 40px rgba(20,30,25,.14);

  --font-display: 'Cabinet Grotesk', 'General Sans', 'Segoe UI', sans-serif;
  --font-body: 'Satoshi', 'General Sans', 'Segoe UI', sans-serif;
}

[data-theme='dark'] {
  --color-bg: #10170F;
  --color-surface: #16211A;
  --color-surface-2: #1B271F;
  --color-surface-offset: #1F2C23;
  --color-border: #2B3A31;
  --color-divider: #263429;

  --color-text: #E7E9E3;
  --color-text-muted: #9AA79E;
  --color-text-faint: #6C7A70;
  --color-text-inverse: #10170F;

  --color-primary: #4F9C79;
  --color-primary-hover: #6BB595;
  --color-primary-light: #3E8265;
  --color-primary-highlight: #22352A;

  --color-accent: #E0BE55;
  --color-accent-hover: #EDD07A;
  --color-accent-light: #C9A227;
  --color-accent-highlight: #3B341C;

  --color-success: #6BB595;
  --color-warning: #E0BE55;
  --color-error: #D97C8B;
  --color-error-highlight: #3A2226;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
}

:root {
  --text-xs: clamp(.75rem, .7rem + .2vw, .8125rem);
  --text-sm: clamp(.8125rem, .78rem + .2vw, .875rem);
  --text-base: clamp(.9375rem, .9rem + .2vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + .4vw, 1.25rem);
  --text-xl: clamp(1.375rem, 1.15rem + 1vw, 1.75rem);

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem;
  --space-12: 3rem; --space-16: 4rem;
}

/* ============================================================
   Layout shell
   ============================================================ */
.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--color-sidebar-bg);
  color: #F7F5F0; display: flex; flex-direction: column;
  padding: var(--space-6) var(--space-5); position: sticky; top: 0; height: 100dvh;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.sidebar-brand svg { width: 26px; height: 26px; color: #C9A227; flex-shrink: 0; }
.sidebar-brand-text { font-family: var(--font-display); font-weight: 700; font-size: var(--text-base); letter-spacing: .04em; color: #F7F5F0; }
.sidebar-tagline { font-size: var(--text-xs); color: rgba(247,245,240,.55); letter-spacing: .08em; text-transform: uppercase; margin-bottom: var(--space-8); padding-left: 34px; }

.nav-list { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; min-height: 0; overflow-y: auto; }
.nav-spacer { flex: 1 1 auto; min-height: var(--space-4); }
.nav-divider { height: 1px; background: rgba(247,245,240,.14); margin: var(--space-3) var(--space-1); flex-shrink: 0; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-3); border-radius: var(--radius-sm);
  color: rgba(247,245,240,.78);
  font-size: var(--text-sm); font-weight: 500; text-align: left; width: 100%;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--color-sidebar-bg-hover); color: #F7F5F0; }
.nav-item.active { background: var(--color-sidebar-active); color: #F7F5F0; border-left-color: #C9A227; }

.sidebar-footer { font-size: var(--text-xs); color: rgba(247,245,240,.45); display: flex; align-items: center; justify-content: space-between; }
.theme-toggle { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); color: rgba(247,245,240,.7); }
.theme-toggle:hover { background: var(--color-sidebar-bg-hover); color: #F7F5F0; }
.theme-toggle svg { width: 16px; height: 16px; }

.main { flex: 1; min-width: 0; padding: var(--space-8) var(--space-10); }
.page { display: none; max-width: 1200px; }
.page.active { display: block; animation: fade-in .25s cubic-bezier(.16,1,.3,1); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header { margin-bottom: var(--space-8); }
.page-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 700; color: var(--color-text); }
.page-subtitle { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }

.section-label { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: var(--space-3); }

/* ============================================================
   Cards, stat cards, buttons
   ============================================================ */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: var(--space-6); margin-bottom: var(--space-6);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stat-card { min-width: 0; container-type: inline-size; }

@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.an-velocity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
@media (max-width: 900px) { .an-velocity-grid { grid-template-columns: 1fr; } }
.stat-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.stat-card .stat-value { font-family: var(--font-display); font-size: clamp(1rem, 12cqi, var(--text-xl)); font-weight: 700; color: var(--color-text); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-card .stat-label { overflow-wrap: anywhere; }
.order-store-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--space-4); }
.order-store-stats .stat-card-money { grid-column: 1 / -1; }
@media (max-width: 480px) {
  .stat-card.stat-card-money { grid-column: 1 / -1; }
}
.stat-card .stat-value.stat-value-note { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); font-family: var(--font-body); line-height: 1.4; }
.stat-card.amber .stat-value { color: var(--color-accent-hover); }
[data-theme='dark'] .stat-card.amber .stat-value { color: var(--color-accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-accent { background: var(--color-accent); color: #241D06; }
.btn-accent:hover { background: var(--color-accent-hover); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
[data-theme='dark'] .btn-secondary:hover { color: var(--color-primary-hover); }
.btn svg { width: 15px; height: 15px; }
.btn-wrap { white-space: normal; max-width: 100%; min-width: 0; height: auto; line-height: 1.5; }
.btn-wrap svg { flex-shrink: 0; }
.btn-wrap span { min-width: 0; overflow-wrap: anywhere; }
.transfer-file-list { margin-top: var(--space-4); display: grid; gap: var(--space-2); }
.transfer-file-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
.transfer-file-name { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); }
.transfer-file-name small { display: block; color: var(--color-text-muted); margin-top: 4px; }
.transfer-file-row .btn { flex-shrink: 0; }
@media (max-width: 480px) {
  .transfer-file-row { align-items: flex-start; flex-direction: column; }
}
.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs, 0.75rem); }
.btn-sm svg { width: 13px; height: 13px; }
.sku-count-card .hint { font-size: 12px; line-height: 1.4; }
.transfer-type-options { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 10px; }
.transfer-type-options label { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--color-border); border-radius: 10px; cursor: pointer; }
.transfer-type-options label:has(input:checked) { border-color: var(--color-primary); background: var(--color-surface-alt); }
.transfer-type-options input { flex: 0 0 auto; margin-top: 4px; }
.transfer-type-options span { min-width: 0; }
.transfer-type-options strong { display: block; font-size: 14px; }
.transfer-type-options small { display: block; color: var(--color-text-muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.transfer-type-card .card-help { margin-top: 12px; }
#asnReceiptSummary details { margin-top: 12px; }
#asnReceiptSummary .table-scroll { max-height: 440px; margin-top: 12px; }
.sku-accessory-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--color-border); }
.sku-accessory-count > span:last-child { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
#asnReceiptSummary { overflow-wrap: anywhere; }
#asnReceiptSummary[hidden] { display: none; }
#asnReceiptSummary summary { font-size: 13px; line-height: 1.5; cursor: pointer; color: var(--color-warning); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-danger-outline { background: var(--color-surface); border-color: var(--color-error); color: var(--color-error); }
.btn-danger-outline:hover { background: var(--color-error-highlight); }

/* ============================================================
   Forms
   ============================================================ */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); min-width: 0; }
.field label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
.field .hint { font-size: var(--text-xs); color: var(--color-text-muted); }
input[type="text"], input[type="date"], input[type="number"], select, #staffRequestForm textarea {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-3); background: var(--color-surface); color: var(--color-text);
  font-size: var(--text-sm); width: 100%; min-width: 0; max-width: 100%;
}
input:focus, select:focus { border-color: var(--color-primary); }
.field > div:has(> input[type="date"]) { flex-wrap: wrap; }
.field input[type="date"] { min-width: min(100%, 130px); }
.checkbox-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--color-primary); }
.radio-group { display: flex; flex-direction: column; gap: var(--space-2); }
.radio-row { display: flex; flex-direction: column; }
.radio-option { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-sm); padding: var(--space-2) 0; }
.radio-option input { margin-top: 3px; accent-color: var(--color-primary); }
.radio-option .radio-text strong { display: block; }
.radio-option .radio-text span { color: var(--color-text-muted); font-size: var(--text-xs); }

/* On/off style switch for a two-way choice (e.g. OCS receiving mode) */
.mode-switch {
  position: relative; display: flex; gap: 4px; padding: 4px;
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.mode-switch input {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}
.mode-switch-thumb {
  position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px);
  background: var(--color-primary); border-radius: calc(var(--radius-md) - 2px); z-index: 0;
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
#ocsModeConsolidated:checked ~ .mode-switch-thumb { transform: translateX(100%); }
.mode-switch-option {
  position: relative; z-index: 1; flex: 1; text-align: center; cursor: pointer;
  padding: var(--space-3) var(--space-3); border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted);
  transition: color .2s; user-select: none;
}
#ocsModeDistributed:checked ~ label[for="ocsModeDistributed"],
#ocsModeConsolidated:checked ~ label[for="ocsModeConsolidated"] { color: #fff; }

.dropzone {
  border: 2px dashed var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-8) var(--space-4); text-align: center; cursor: pointer;
  background: var(--color-surface-2);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--color-primary); background: var(--color-primary-highlight); }
.dropzone svg { width: 28px; height: 28px; color: var(--color-text-faint); margin: 0 auto var(--space-2); }
.dropzone .filename { font-size: var(--text-sm); font-weight: 600; color: var(--color-primary); margin-top: var(--space-2); overflow-wrap: anywhere; }

.card-help { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0 0 var(--space-3); line-height: 1.5; }

.quick-start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.quick-start-slot-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); margin-bottom: var(--space-2); }
.quick-start-slot .dropzone { padding: var(--space-4) var(--space-3); min-height: auto; }
.quick-start-dest { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-2); }
@media (max-width: 900px) { .quick-start-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .quick-start-grid { grid-template-columns: 1fr; } }
.optional-tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-muted); background: var(--color-surface-2); border: 1px solid var(--color-border);
  border-radius: 999px; padding: 2px 8px; margin-left: var(--space-2); vertical-align: middle;
}
.status-chip {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border-radius: 999px; padding: 3px 9px; display: inline-block; white-space: nowrap;
  background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text-muted);
}
.status-chip.active { color: var(--color-success); background: color-mix(in oklab, var(--color-success) 16%, transparent); border-color: transparent; }
.status-chip.upcoming { color: var(--color-warning); background: color-mix(in oklab, var(--color-warning) 16%, transparent); border-color: transparent; }
.status-chip.expired { color: var(--color-text-faint); }
.status-chip.paused { color: var(--color-text-faint); }
.file-chip-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.file-chip {
  display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 500; min-width: 0; max-width: 100%;
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: 999px;
  padding: 5px 6px 5px 12px; color: var(--color-text);
}
.file-chip button {
  border: none; background: none; cursor: pointer; color: var(--color-text-muted);
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1; flex-shrink: 0;
}
.file-chip button:hover { background: var(--color-danger-highlight, rgba(220,60,60,0.12)); color: var(--color-danger, #c0392b); }
.file-chip button svg { width: 12px; height: 12px; }
.file-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; min-width: 0; }
.file-chip-store {
  font-size: 11px; font-weight: 500; color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: 999px; padding: 2px 6px; max-width: 190px;
  cursor: pointer;
}
.file-chip-store:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

.preset-row { display: flex; gap: var(--space-2); }
.preset-btn {
  flex: 1; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface);
  color: var(--color-text); font-size: var(--text-sm); font-weight: 600; padding: var(--space-2) 0; cursor: pointer;
}
.preset-btn:hover { border-color: var(--color-primary); }
.preset-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); }

/* ============================================================
   Transfer Builder split layout
   ============================================================ */
.builder-grid { display: grid; grid-template-columns: 340px 1fr; gap: var(--space-6); align-items: start; }
.builder-grid > * { min-width: 0; }
@media (max-width: 1000px) { .builder-grid { grid-template-columns: 1fr; } }
.config-panel { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.results-panel { min-width: 0; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); overflow-x: auto; }
.tab-btn { padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in .2s ease; }

.sub-tabs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.sub-tab-btn { padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; background: var(--color-surface-offset); color: var(--color-text-muted); }
.sub-tab-btn.active { background: var(--color-primary); color: #fff; }

/* ============================================================
   Data tables
   ============================================================ */
.table-scroll {
  overflow: auto; max-width: 100%; min-width: 0; max-height: 560px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  scrollbar-gutter: stable;
  overscroll-behavior-x: contain;
}
/* Native scrolling, with the same muted green / warm surface treatment as
   the surrounding controls. Covers results tabs as well as table panes. */
html, .table-scroll, .tabs, .nav-list {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary-light) var(--color-surface-offset);
}
:is(html, .table-scroll, .tabs, .nav-list)::-webkit-scrollbar { width: 10px; height: 10px; }
:is(html, .table-scroll, .tabs, .nav-list)::-webkit-scrollbar-track { background: var(--color-surface-offset); border-radius: var(--radius-full); }
:is(html, .table-scroll, .tabs, .nav-list)::-webkit-scrollbar-thumb {
  background-color: var(--color-primary-light);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface-offset);
}
:is(html, .table-scroll, .tabs, .nav-list)::-webkit-scrollbar-thumb:hover { background-color: var(--color-primary); }
.table-scroll::-webkit-scrollbar-corner { background: var(--color-surface-offset); }
.data-table { width: 100%; font-size: var(--text-xs); }
.data-table th {
  position: sticky; top: 0; background: var(--color-primary); color: #fff;
  text-align: left; padding: var(--space-2) var(--space-3); font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
.data-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--color-surface-offset); }
.data-table tr.flagged td { background: color-mix(in oklab, var(--color-accent) 16%, transparent); }
[data-theme='dark'] .data-table tr.flagged td { background: color-mix(in oklab, var(--color-accent) 12%, transparent); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.narrative-box { white-space: pre-wrap; font-size: var(--text-sm); line-height: 1.7; color: var(--color-text); }
.watchlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.watchlist li { display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-sm); line-height: 1.6; color: var(--color-text); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-2); }
.watchlist li::before { content: ''; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: #C9A227; margin-top: 6px; }

/* Store settings table */
.store-table input { border: none; background: transparent; width: 100%; font-size: var(--text-sm); padding: var(--space-1); }
.store-table input:focus { background: var(--color-surface-2); border-radius: var(--radius-sm); }
.store-table td.actions { text-align: center; }
.store-table input.store-name { min-width: 180px; }
.store-table input.store-code { min-width: 90px; }
.store-table input.store-buffer { min-width: 64px; }
.store-table input.store-role { min-width: 200px; }
.icon-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--color-text-muted); }
.icon-btn:hover { background: var(--color-error-highlight); color: var(--color-error); }
.icon-btn svg { width: 15px; height: 15px; }

/* Empty / loading states */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-12) var(--space-6); color: var(--color-text-muted); }
.empty-state svg { width: 40px; height: 40px; color: var(--color-text-faint); margin-bottom: var(--space-4); }
.empty-state h3 { color: var(--color-text); font-size: var(--text-lg); font-family: var(--font-display); margin-bottom: var(--space-2); }
.empty-state p { max-width: 40ch; margin: 0 auto; font-size: var(--text-sm); }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-divider) 50%, var(--color-surface-offset) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.toast {
  position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 50;
  background: var(--color-primary); color: #fff; padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: 600;
  display: flex; align-items: center; gap: var(--space-2);
  transform: translateY(12px); opacity: 0; transition: all .3s cubic-bezier(.16,1,.3,1); pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--color-error); }

.banner {
  background: var(--color-primary-highlight); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--text-xs);
  color: var(--color-text-muted); margin-bottom: var(--space-6); display: flex; gap: var(--space-2); align-items: flex-start;
}
.banner svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; color: var(--color-primary); }
.banner.warn { background: var(--color-accent-highlight); }
.banner.warn svg { color: var(--color-warning); }

/* Week-over-week comparison */
.week-compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.wc-stat { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); }
.wc-stat .wc-label { font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.wc-stat .wc-values { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.wc-stat .wc-this { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; color: var(--color-text); }
.wc-stat .wc-last { font-size: var(--text-xs); color: var(--color-text-muted); }
.wc-delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border-radius: var(--radius-sm); margin-top: var(--space-2); }
.wc-delta.up { color: var(--color-success); background: color-mix(in oklab, var(--color-success) 16%, transparent); }
.wc-delta.down { color: var(--color-error); background: color-mix(in oklab, var(--color-error) 14%, transparent); }
.wc-delta.flat { color: var(--color-text-muted); background: var(--color-surface-2); }
.wc-delta svg { width: 12px; height: 12px; }

/* Saved run history & comparison */
.history-controls { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.history-controls input[type="text"], .history-controls select {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3); font-size: var(--text-sm); color: var(--color-text); min-width: 180px;
}
.hist-list { display: flex; flex-direction: column; gap: var(--space-2); }
.hist-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.hist-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hist-item-label { font-weight: 700; font-size: var(--text-sm); color: var(--color-text); }
.hist-item-meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.hist-item-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }
.hist-item-actions button {
  background: transparent; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: var(--text-xs); color: var(--color-text-muted);
}
.hist-item-actions button:hover { border-color: var(--color-primary); color: var(--color-primary); }
.hist-item-actions button.danger:hover { border-color: var(--color-error); color: var(--color-error); }
.hist-quickpicks { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }
.hist-quickpick-btn {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-full);
  padding: 4px 12px; font-size: var(--text-xs); color: var(--color-text-muted);
}
.hist-quickpick-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); }
.hist-quickpick-btn:disabled { opacity: .4; cursor: not-allowed; }
.hist-quickpick-btn.active { background: var(--color-primary-highlight); border-color: var(--color-primary); color: var(--color-primary); }
.hist-compare-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.hist-empty-hint { font-size: var(--text-xs); color: var(--color-text-muted); padding: var(--space-2) 0; }
.hist-scope-toggle {
  display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3);
  font-size: var(--text-xs); color: var(--color-text-muted); cursor: pointer; user-select: none;
}
.hist-scope-toggle input[type="checkbox"] { accent-color: var(--color-primary); width: 14px; height: 14px; cursor: pointer; }
.hist-item-owner {
  display: inline-block; margin-left: var(--space-2); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--color-accent); background: color-mix(in oklab, var(--color-accent) 14%, transparent);
  border-radius: var(--radius-sm); padding: 1px 6px;
}
.week-compare-movers { display: flex; flex-direction: column; gap: var(--space-2); }
.wc-mover { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-2); font-size: var(--text-sm); }
.wc-mover .wc-mover-cat { font-weight: 600; color: var(--color-text); }
.wc-mover .wc-mover-nums { font-size: var(--text-xs); color: var(--color-text-muted); }

/* About page */
.about-page { text-align: center; padding-top: var(--space-10); }
.about-page .about-logo-chip { display: inline-block; background: #FFFFFF; border-radius: var(--radius-lg); padding: var(--space-5) var(--space-6); margin: 0 auto var(--space-5); box-shadow: var(--shadow-sm); }
.about-page .about-logo { width: 220px; margin: 0; }
.about-page .about-tagline { font-style: italic; color: var(--color-text-muted); margin-bottom: var(--space-6); }
.about-page .about-info { font-size: var(--text-sm); margin-bottom: var(--space-4); }
.about-page .about-note { max-width: 460px; margin: 0 auto; font-size: var(--text-xs); color: var(--color-text-muted); }

.about-pitch { max-width: 680px; margin: var(--space-6) auto 0; text-align: left; }
.about-pitch .about-lede { font-size: var(--text-lg); font-family: var(--font-display); line-height: 1.5; color: var(--color-text); margin-bottom: var(--space-4); }
.about-pitch p { font-size: var(--text-sm); line-height: 1.7; color: var(--color-text-muted); }
.about-pitch p + p { margin-top: var(--space-3); }

.about-feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); margin-top: var(--space-5); }
.about-feature { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-5); }
.about-feature svg { width: 22px; height: 22px; color: #C9A227; margin-bottom: var(--space-3); }
.about-feature h3 { font-family: var(--font-display); font-size: var(--text-base); margin-bottom: var(--space-2); color: var(--color-text); }
.about-feature p { font-size: var(--text-sm); line-height: 1.6; color: var(--color-text-muted); margin: 0; }

#page-about .card.about-closing { text-align: center; padding: var(--space-8) var(--space-6); }
#page-about .card.about-closing .about-note { max-width: 560px; text-align: center; margin: 0 auto; font-style: italic; font-size: var(--text-sm); line-height: 1.7; color: var(--color-text-muted); }
.about-closing-ornament { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.about-closing-ornament svg { width: 18px; height: 18px; color: #C9A227; flex-shrink: 0; }
.about-closing-line { display: block; width: 64px; height: 1px; background: linear-gradient(90deg, transparent, var(--color-border)); }
.about-closing-ornament .about-closing-line:last-child { background: linear-gradient(90deg, var(--color-border), transparent); }

/* Maple-leaf "Made in Canada" mark, centered at the bottom of the About page and splash/login screen */
.made-in-canada { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: var(--space-8) auto 0; padding-top: var(--space-4); color: var(--color-text-muted); font-size: var(--text-xs); letter-spacing: .04em; text-transform: uppercase; }
.made-in-canada svg { color: #d52b1e; flex-shrink: 0; }
.app-page-footer { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8) 0 var(--space-4); margin-top: var(--space-6); opacity: .55; }
.app-page-footer img { width: 28px; height: 28px; }
.app-page-footer span { font-family: var(--font-display); font-size: var(--text-xs); letter-spacing: .08em; text-transform: uppercase; color: var(--color-text-muted); }

@media (max-width: 720px) {
  .about-feature-grid { grid-template-columns: 1fr; }
}

.btn-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ============================================================
   Order Builder — product search
   ============================================================ */
.search-results-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); max-height: 280px; overflow-y: auto; }
.search-result-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  cursor: pointer; background: var(--color-surface);
}
.search-result-row:hover { border-color: var(--color-primary); background: var(--color-surface-2); }
.search-result-row.selected { border-color: var(--color-primary); background: var(--color-primary-highlight); }
.search-result-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-result-main .sr-name { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-main .sr-meta { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-side { text-align: right; flex-shrink: 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.search-result-side .sr-price { font-weight: 700; color: var(--color-primary); display: block; }
[data-theme='dark'] .search-result-side .sr-price { color: var(--color-primary-hover); }

.product-add-bar { border-top: 1px solid var(--color-divider); margin-top: var(--space-4); padding-top: var(--space-4); }
.selected-product-label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }

.manual-line-row {
  display: flex; flex-direction: column; gap: var(--space-1); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); background: var(--color-surface);
}
.manual-line-row .manual-line-main { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.manual-line-row .manual-line-item { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.manual-line-row .manual-line-sku { font-size: var(--text-xs); color: var(--color-text-muted); flex-shrink: 0; }
.manual-line-row .manual-line-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-text-muted); }
.manual-line-row .manual-line-store { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.manual-line-row .manual-line-qty { font-weight: 600; color: var(--color-text); flex-shrink: 0; }
.manual-line-row .manual-line-warn { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--color-warning); background: var(--color-accent-highlight); padding: 2px 8px; border-radius: var(--radius-sm); flex-shrink: 0; white-space: nowrap; }
.manual-line-row .manual-line-warn svg { width: 12px; height: 12px; }
.manual-line-row .icon-btn { flex-shrink: 0; }

.unmatched-callout {
  background: var(--color-accent-highlight); border: 1px solid var(--color-accent-light); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); font-size: var(--text-xs); color: var(--color-text); margin-bottom: var(--space-4);
}
.unmatched-callout summary { cursor: pointer; font-weight: 600; }
.unmatched-callout ul { margin: var(--space-2) 0 0; padding-left: var(--space-5); columns: 2; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; padding: var(--space-4); }
  .sidebar-brand-text, .sidebar-tagline, .sidebar-footer { display: none; }
  .nav-list { flex-direction: row; scroll-behavior: smooth; }
  /* Without flex-shrink:0 + nowrap, nav-items default to shrinking to fit
     the row (flex-shrink:1) instead of keeping their natural width and
     letting admin.css's overflow-x:auto strip scroll horizontally — that
     shrink was squeezing longer labels like "Transfer Builder" into a
     mid-word wrap on narrow viewports. */
  .nav-item { scroll-snap-align: start; flex-shrink: 0; white-space: nowrap; width: auto; }
  .nav-spacer { display: none; }
  .nav-divider { width: 1px; height: 24px; margin: 0 var(--space-2); flex-shrink: 0; }
  .main { padding: var(--space-5); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
.request-queue-totals { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-3); margin:var(--space-3) 0; }
.request-queue-totals > div { padding:var(--space-3); border:1px solid var(--color-border); border-radius:8px; min-width:0; overflow-wrap:anywhere; }
.request-queue-totals strong { display:block; font-size:1.1rem; margin:var(--space-2) 0; }
.request-selected-totals { grid-template-columns:minmax(0,1fr); }
.request-selected-totals > div { border-color:var(--color-primary); background:var(--color-surface); }
.fulfillment-details { margin-top:var(--space-3); border-top:1px solid var(--color-border); padding-top:var(--space-3); min-width:0; }
.fulfillment-details summary { cursor:pointer; overflow-wrap:anywhere; padding:var(--space-2) 0; }
.fulfillment-details .table-scroll { margin-top:var(--space-3); }
.fulfillment-quantity { width:95px; min-height:44px; }
.asn-match-choice { width:100%; margin-top:var(--space-2); text-align:left; }
.asn-match-choice[aria-pressed="true"] { border-color:var(--color-primary); }
.request-queue-actions { display:flex; flex-wrap:wrap; gap:var(--space-2); margin:var(--space-3) 0; }
.request-queue-clear { border-top:1px solid var(--color-border); padding-top:var(--space-4); margin-top:var(--space-4); display:grid; gap:var(--space-3); }
.request-queue-clear select { min-width:0; max-width:100%; width:100%; }
@media(max-width:400px) { .request-queue-totals { grid-template-columns:minmax(0,1fr); } }
.request-workspace { display:grid; grid-template-columns:minmax(0, 380px) minmax(0, 1fr); gap:var(--space-6); align-items:start; }
.request-workspace > * { min-width:0; }
.request-page-actions { display:flex; flex-wrap:wrap; gap:var(--space-2); }
.submission-row { padding:var(--space-4) 0; border-bottom:1px solid var(--color-border); overflow-wrap:anywhere; }
.submission-row h3 { font-size:16px; margin:0 0 var(--space-2); }
.submission-row p { margin:var(--space-2) 0; font-size:13px; color:var(--color-text-muted); }
#staffRequestForm textarea { width:100%; resize:vertical; }
#staffRequestOrderBtn[hidden] { display:none; }
#staffRequestQtyField[hidden] { display:none; }
.request-catalog-match { border-bottom:1px solid var(--color-border); padding:var(--space-3) 0; overflow-wrap:anywhere; }
.request-catalog-match summary { cursor:pointer; font-weight:600; font-size:14px; }
.request-match-search { display:flex; gap:var(--space-2); margin-top:var(--space-2); }
.request-match-search input { min-width:0; flex:1; }
.request-match-result { display:flex; justify-content:space-between; align-items:center; gap:var(--space-3); padding:var(--space-3) 0; border-bottom:1px solid var(--color-border); }
.request-match-result p { min-width:0; margin:0; font-size:13px; }
.request-match-result button { flex-shrink:0; }
.required-tag { font-size:12px; font-weight:400; color:var(--color-text-muted); }
.request-store-choices { margin:0; padding:0; border:0; min-width:0; }
.request-store-choices legend { font-size:var(--text-sm); font-weight:600; margin-bottom:var(--space-2); padding:0; }
#staffRequestStoreOptions { display:grid; gap:8px; }
.request-store-choice { display:flex; align-items:center; gap:10px; padding:12px; min-height:48px; border:1px solid var(--color-border); border-radius:var(--radius-sm); cursor:pointer; }
.request-store-choice input { flex:0 0 auto; width:18px; height:18px; margin:0; accent-color:var(--color-primary); }
.request-store-choice span { overflow-wrap:anywhere; font-weight:400; }
.request-store-choice:has(input:checked) { background:var(--color-primary-highlight); border-color:var(--color-primary); }
.request-store-choice:focus-within { outline:2px solid var(--color-primary); outline-offset:2px; }
.request-store-choices:disabled { opacity:.6; }
@media (max-width:600px) { .request-match-search, .request-match-result { flex-direction:column; align-items:stretch; } }
@media (max-width:900px) { .request-workspace { grid-template-columns:minmax(0, 1fr); } }
