/* ── YGH ERP Design Tokens v2 + Shared Component Styles ──────────────────────
   theme.css — v2 2026-08-28 (v1 2026-08-12)
   Light (default) / Dark ([data-theme=dark]) via CSS custom properties.
   Quiet green-tinted neutrals, steel-blue accent, brand green only in chrome.
   Principle #1: this is a technical tool — clarity beats decoration.
   ──────────────────────────────────────────────────────────────────────────── */

/* ── Self-hosted InterVariable (all weights 100-900, real bold — no synth) ── */
@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── Design tokens: LIGHT (default) ─────────────────────────────────────── */
:root {
  /* color */
  --bg:            #F4F5F2;
  --surface:       #FFFFFF;
  --surface-2:     #F7F8F5;
  --border:        #DFE3DC;
  --border-strong: #C4CBC0;
  --text:          #20261F;
  --text-2:        #565E56;
  --text-3:        #68716A;
  --accent:        #2B4E9C;
  --accent-hover:  #24428A;
  --accent-contrast:#FFFFFF;
  --brand:         #2E6B4F;
  --hover:         #EDEFEA;
  --ok:            #1E7042;
  --ok-bg:         #E4F2E9;
  --warn:          #8A5709;
  --warn-bg:       #F8EED8;
  --danger:        #B3261E;
  --danger-bg:     #F9E5E2;
  --info:          #2B4E9C;
  --info-bg:       #E7ECF7;
  --est:           #565D9E;      /* aplēses: "~$X (estimate)" — NOT a warning */
  --est-bg:        #EBECF6;
  --overlay:       rgba(24,28,23,.45);
  color-scheme: light;   /* native scrollbars, selects, date pickers follow the theme */
  /* elevation */
  --shadow:        0 1px 2px rgba(32,38,31,.06);
  --shadow-md:     0 8px 28px rgba(32,38,31,.14);
  /* type scale */
  --fs-2xs: 11px;   /* micro labels only, always with letter-spacing */
  --fs-xs:  12px;
  --fs-sm:  13px;   /* table body */
  --fs-md:  15px;   /* app base */
  --fs-lg:  17px;
  --fs-xl:  20px;
  --fs-2xl: 26px;
  /* spacing scale (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  /* radius scale */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px;
  --radius: var(--r-md);
  /* z-index scale */
  --z-sticky: 10; --z-actionbar: 20; --z-modal: 100; --z-toast: 200;
  /* focus ring */
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  /* legacy aliases used in JS-generated HTML */
  --good:          var(--ok);
  --amber:         var(--warn);
  --red:           var(--danger);
  --primary:       var(--accent);
  --muted:         var(--text-2);
  --row:           var(--surface);
  --row-alt:       var(--surface-2);
}

/* ── Design tokens: DARK ─────────────────────────────────────────────────── */
[data-theme=dark] {
  --bg:            #171A16;
  --surface:       #1F231E;
  --surface-2:     #262B24;
  --border:        #343A32;
  --border-strong: #475044;
  --text:          #E4E7E0;
  --text-2:        #ABB2A8;
  --text-3:        #939C92;
  --accent:        #8FAEE3;
  --accent-hover:  #A5BFEC;
  --accent-contrast:#131A2A;
  --brand:         #7FBB9C;
  --hover:         #2B302A;
  --ok:            #85C79F;
  --ok-bg:         #1E3328;
  --warn:          #DCA84E;
  --warn-bg:       #372A10;
  --danger:        #E58E80;
  --danger-bg:     #3A211C;
  --info:          #8FAEE3;
  --info-bg:       #202B41;
  --est:           #A6ACDD;
  --est-bg:        #262A45;
  --overlay:       rgba(0,0,0,.6);
  color-scheme: dark;
  --shadow:        0 1px 2px rgba(0,0,0,.4);
  --shadow-md:     0 8px 28px rgba(0,0,0,.5);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  /* legacy aliases */
  --good:          var(--ok);
  --amber:         var(--warn);
  --red:           var(--danger);
  --primary:       var(--accent);
  --muted:         var(--text-2);
  --row:           var(--surface);
  --row-alt:       var(--surface-2);
}

/* ── Reset + Base ─────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  font-family: Inter, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;   /* svh: mobile toolbar never covers the bottom */
  font-size: var(--fs-md);
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
.muted { color: var(--text-2); }
.hidden { display: none !important; }

/* iOS Safari zooms the page on focus when a field is under 16px. Touch screens only;
   !important because page-level field rules (13px toolbars) are more specific. */
@media (pointer: coarse) {
  input, select, textarea { font-size: max(16px, 1em) !important; }
}

/* Keyboard focus is always visible; mouse clicks stay quiet. */
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

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

/* Numbers line up: tables, KPI values, anything .num */
table, .num, .kpi-value { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.mono a { color: var(--accent); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   NEW COMPONENT LAYER (v2) — adopt these class names as screens migrate.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons: one family. Default = quiet surface button. ────────────────── */
.btn2 {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px;
  min-height: 32px;
  font: inherit; font-size: var(--fs-sm); font-weight: 550;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
@media (hover: hover) { .btn2:hover { background: var(--hover); border-color: var(--border-strong); } }
.btn2:active { transform: translateY(1px); }
.btn2:disabled { opacity: .55; cursor: default; transform: none; }
.btn2--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
@media (hover: hover) { .btn2--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); } }
.btn2--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn2--ghost { background: transparent; }
.btn2--sm { min-height: 26px; padding: 3px 10px; font-size: var(--fs-xs); }
.btn2--touch { min-height: 44px; min-width: 44px; padding: 10px 16px; font-size: var(--fs-md); border-radius: var(--r-md); }

/* ── Tab strip: active tab = brand underline, not a loud filled block. ───── */
.tabstrip { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); }
.tabstrip button, .tabstrip a {
  padding: 8px 16px 10px;
  font: inherit; font-size: var(--fs-sm); font-weight: 550;
  color: var(--text-2);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer; text-decoration: none;
  transition: color .15s, border-color .15s;
}
@media (hover: hover) { .tabstrip button:hover, .tabstrip a:hover { color: var(--text); } }
.tabstrip .on, .tabstrip .active { color: var(--text); font-weight: 640; border-bottom-color: var(--brand); }

/* ── Banner: the ONE alert component (replaces hand-rolled inline blocks). ── */
.banner {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 10px 14px;
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-3);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--text);
}
.banner b, .banner .banner-title { font-weight: 640; }
.banner--info   { border-left-color: var(--info);   background: var(--info-bg); }
.banner--ok     { border-left-color: var(--ok);     background: var(--ok-bg); }
.banner--warn   { border-left-color: var(--warn);   background: var(--warn-bg); }
.banner--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.banner--warn .banner-title   { color: var(--warn); }
.banner--danger .banner-title { color: var(--danger); }
.banner--ok .banner-title     { color: var(--ok); }
.banner .banner-body { flex: 1; min-width: 0; }

/* ── Status pill: one base, semantic modifiers. ──────────────────────────── */
.pill2 {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.pill2--ok     { background: var(--ok-bg);     border-color: transparent; color: var(--ok); }
.pill2--warn   { background: var(--warn-bg);   border-color: transparent; color: var(--warn); }
.pill2--danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.pill2--info   { background: var(--info-bg);   border-color: transparent; color: var(--info); }
.pill2--est    { background: var(--est-bg);    border-color: transparent; color: var(--est); }

/* Estimate value inline (Profit): calm indigo, NOT amber. */
.est { color: var(--est); font-weight: 600; }
.est-note { color: var(--est); font-size: var(--fs-2xs); }

/* ── Skeleton loading ────────────────────────────────────────────────────── */
.skel {
  display: block;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--hover) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skel-wave 1.2s linear infinite;
  min-height: 14px;
}
@keyframes skel-wave { to { background-position: -200% 0; } }
.skel-row { height: 34px; margin-bottom: 6px; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.empty-state b { display: block; font-size: var(--fs-md); color: var(--text); margin-bottom: 4px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   EXISTING APP SELECTORS (markup unchanged; values now flow from v2 tokens)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 8px;
  transition: background .15s, border-color .15s;
}
@media (hover: hover) {
  .theme-btn:hover {
    background: var(--hover);
    border-color: var(--border-strong);
    color: var(--text);
  }
}

/* ── Board / ERP layout (.app) ────────────────────────────────────────────── */
.app { max-width: 1500px; margin: 0 auto; padding: var(--sp-4) var(--sp-5); }
.app h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; color: var(--text); margin-bottom: 2px; }
.app h1::before {
  content: '';
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 3px;
  background: var(--brand);
  margin-right: 8px;
}
.app .subtitle { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: var(--sp-3); }

/* ── Nav (main tabs) — brand underline, quiet chrome ─────────────────────── */
.nav { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-4); border-bottom: 1px solid var(--border); }
.nav button, .nav a.navlink {
  padding: 8px 18px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  font-size: var(--fs-sm);
  background: none;
  color: var(--text-2);
  text-decoration: none;
  transition: color .15s, border-color .15s;
}
@media (hover: hover) { .nav button:hover, .nav a.navlink:hover { color: var(--text); background: none; } }
.nav button.on { background: none; color: var(--text); font-weight: 640; border-bottom-color: var(--brand); }
/* Manufacturer switcher lives IN the nav — same quiet tab voice, native select */
.nav select.nav-mfg {
  margin-left: auto;
  align-self: center;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  margin-bottom: 6px;
  cursor: pointer;
}
@media (hover: hover) { .nav select.nav-mfg:hover { color: var(--text); background: var(--hover); } }

/* ── KPI cards ───────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: var(--sp-2); margin-bottom: var(--sp-4); }
.kpi-card {
  container-type: inline-size;   /* lets .kpi-value size against the card */
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
@media (hover: hover) { .kpi-card:hover { border-color: var(--border-strong); } }
.kpi-card .kpi-label { font-size: var(--fs-2xs); text-transform: uppercase; color: var(--text-3); letter-spacing: .06em; font-weight: 550; margin-bottom: 4px; }
/* The value sizes itself to the CARD, not the viewport: a long money string
   ("~$146,578.76") in a narrow column shrinks instead of spilling past the
   edge. overflow-wrap is the last-resort guard for any value we did not
   anticipate — a number must never escape its card. */
.kpi-card .kpi-value {
  font-size: clamp(18px, 11cqi, 27px);
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  overflow-wrap: anywhere;
}
/* the sub line can hold one long unbreakable token
   ("rev−cogs−freight−customs−final") — let it wrap rather than touch the edge */
.kpi-card .kpi-sub { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 4px; overflow-wrap: anywhere; }
.kpi-card.warn { border-left: 3px solid var(--warn); }
.kpi-card.warn .kpi-value { color: var(--warn); }
.kpi-card.danger { border-left: 3px solid var(--danger); }
.kpi-card.danger .kpi-value { color: var(--danger); }
.kpi-card.good { border-left: 3px solid var(--ok); }
.kpi-card.good .kpi-value { color: var(--ok); }
/* Estimate card: calm indigo — a modelled number, not a problem. */
.kpi-card.est { border-left: 3px solid var(--est); }
.kpi-card.est .kpi-value { color: var(--est); }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-bottom: var(--sp-4); }
@media(max-width:800px) { .panels { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: var(--fs-sm);
  font-weight: 640;
  color: var(--text);
  margin-bottom: var(--sp-2);
}

/* ── Stage bars ──────────────────────────────────────────────────────────── */
.stage-bar { margin-bottom: 6px; display: flex; align-items: center; gap: var(--sp-2); }
.stage-bar .bar-label { width: 140px; font-size: var(--fs-xs); color: var(--text-2); text-align: right; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-bar .bar-track { flex: 1; height: 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.stage-bar .bar-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s; min-width: 2px; }
.stage-bar .bar-count { width: 36px; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; color: var(--text); text-align: right; flex-shrink: 0; }

/* ── Activity feed ───────────────────────────────────────────────────────── */
.activity-item { display: flex; gap: var(--sp-2); padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); align-items: flex-start; }
.activity-item:last-child { border-bottom: none; }
.activity-item .act-time { color: var(--text-3); white-space: nowrap; min-width: 70px; font-size: var(--fs-2xs); font-variant-numeric: tabular-nums; }
.activity-item .act-order { color: var(--accent); cursor: pointer; font-weight: 550; white-space: nowrap; }
@media (hover: hover) { .activity-item .act-order:hover { text-decoration: underline; } }
.activity-item .act-desc { color: var(--text-2); }
.activity-item .act-arrow { color: var(--accent); font-weight: 600; margin: 0 3px; }

/* "Today" summary row atop the activity feed */
.activity-item.today-row {
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  margin-bottom: 6px;
  align-items: center;
}
.activity-item.today-row .act-time { font-weight: 640; color: var(--text); min-width: 50px; }
.today-desc { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.today-count { font-weight: 640; white-space: nowrap; color: var(--text); }
.today-count.good { color: var(--ok); }
.today-sep { color: var(--text-3); margin: 0 2px; }

/* ── Quick links ─────────────────────────────────────────────────────────── */
.quick-links { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.quick-links a {
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.quick-links a:hover { background: var(--hover); color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.quick-links a .count { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.quick-links a.ql-warn { border-color: var(--warn); color: var(--warn); }
.quick-links a.ql-warn .count { color: var(--warn); }
.quick-links a.ql-danger { border-color: var(--danger); color: var(--danger); }
.quick-links a.ql-danger .count { color: var(--danger); }

/* ── Board views (sub-tabs) — same underline language as .nav ────────────── */
.views { display: flex; gap: var(--sp-1); margin-bottom: var(--sp-2); border-bottom: 1px solid var(--border); }
.views button {
  padding: 7px 16px 9px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  font-size: var(--fs-sm);
  background: none;
  color: var(--text-2);
  transition: color .15s, border-color .15s;
}
@media (hover: hover) { .views button:hover { background: none; color: var(--text); } }
.views button.on { background: none; color: var(--text); font-weight: 640; border-bottom-color: var(--brand); }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); flex-wrap: wrap; align-items: center; }
.toolbar input,
.toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--fs-sm);
  background: var(--surface);
  color: var(--text);
}
.toolbar input:focus-visible,
.toolbar select:focus-visible { box-shadow: none; outline: 2px solid var(--accent); outline-offset: -1px; }
.toolbar input { min-width: 200px; flex: 1; max-width: 320px; }
.toolbar button.icon-btn {
  font: inherit; font-size: var(--fs-xs); font-weight: 550;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-2);
  cursor: pointer;
  opacity: 1; margin-left: 0;
  transition: background .15s, color .15s;
}
@media (hover: hover) { .toolbar button.icon-btn:hover { background: var(--hover); color: var(--text); } }
.toolbar button.icon-btn:disabled { opacity: .55; cursor: default; }

/* ── Counts ──────────────────────────────────────────────────────────────── */
.counts { display: flex; gap: 6px 14px; margin-bottom: var(--sp-3); font-size: var(--fs-xs); color: var(--text-2); flex-wrap: wrap; align-items: center; }
.counts span { padding: 3px 9px; border-radius: var(--r-sm); white-space: nowrap; }
.counts .clickable { cursor: pointer; background: var(--surface); border: 1px solid var(--border); transition: background .15s; }
@media (hover: hover) { .counts .clickable:hover { background: var(--hover); } }
.counts .count-on { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.counts .count-on b { color: var(--accent-contrast); }
.counts b { color: var(--text); font-variant-numeric: tabular-nums; }
.counts .warn { color: var(--danger); }
.counts .warn b { color: var(--danger); }

/* ── Table (board base) ──────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th {
  text-align: left;
  padding: 9px 12px;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); line-height: 1.35; color: var(--text); white-space: nowrap; }
@media (hover: hover) { tr:hover { background: var(--hover); } }
tr:last-child td { border-bottom: none; }
tr.clickable-row { cursor: pointer; }
@media (hover: hover) { tr.clickable-row:hover { background: var(--info-bg); } }
tr.clickable-row:focus-visible { box-shadow: inset var(--ring); border-radius: 0; }

/* ── Pills (existing classes) ────────────────────────────────────────────── */
.stage-pill { display: inline-block; padding: 3px 9px; border-radius: 5px; font-size: var(--fs-2xs); font-weight: 550; letter-spacing: .02em; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.stage-pill.terminal { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.stage-pill.fulfilled { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.stage-pill.in-flight { background: var(--info-bg); border-color: transparent; color: var(--info); }
.deliv { padding: 3px 8px; border-radius: 5px; font-size: var(--fs-2xs); font-weight: 600; }
.deliv.late { color: var(--danger); background: var(--danger-bg); }
.deliv.soon { color: var(--warn); background: var(--warn-bg); }
.deliv.ok { color: var(--ok); background: var(--ok-bg); }

/* ── Courier / tracking ──────────────────────────────────────────────────── */
.tracking { font-size: var(--fs-2xs); color: var(--text-3); margin-top: 2px; }
.courier-cell { line-height: 1.4; }
.courier-cell .courier-line { font-size: var(--fs-2xs); }
.courier-cell .courier-line.muted { color: var(--text-3); }
.est-late { color: var(--warn); }
.await-courier { color: var(--warn); font-size: var(--fs-2xs); }
.jax-warn {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}
.empty { text-align: center; color: var(--text-3); padding: var(--sp-8); }

/* ── Order detail modal (board) ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 40px;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  max-width: 700px;
  width: 95%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 640; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
}
@media (hover: hover) { .modal-close:hover { background: var(--hover); color: var(--text); } }
.modal-body { padding: var(--sp-4) var(--sp-5); }
.modal-body h3 { font-size: var(--fs-xs); text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-2); letter-spacing: .05em; font-weight: 600; }
.modal-body .info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-4); font-size: var(--fs-sm); }
.modal-body .info-grid .lbl { color: var(--text-3); font-size: var(--fs-xs); }
.modal-body .info-grid .val { color: var(--text); }
.modal-body .line-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.modal-body .event-item { padding: 5px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); display: flex; gap: var(--sp-2); }
.modal-body .event-time { color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.modal-body .event-desc { color: var(--text-2); }
.modal-body .stage-actions { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-4); padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.modal-body .stage-actions .lbl { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.modal-body .stage-actions select { flex: 1; font: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); padding: 6px 8px; font-size: var(--fs-sm); }
.modal-body .stage-actions button { font: inherit; background: var(--accent); color: var(--accent-contrast); border: none; border-radius: var(--r-sm); padding: 6px 14px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s; }
@media (hover: hover) { .modal-body .stage-actions button:hover { background: var(--accent-hover); } }
.modal-body .stage-actions button:disabled { opacity: .6; cursor: default; }

/* ── Board extras ────────────────────────────────────────────────────────── */
.daterow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--fs-xs); }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-pill);
  padding: 3px 12px;
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
@media (hover: hover) { .chip:hover { background: var(--hover); border-color: var(--border-strong); } }
.chip.active, .chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.daterow input[type=date],
.daterow select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  padding: 4px 6px;
  font-size: var(--fs-xs);
}
#board-report {
  margin-bottom: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 14px;
}
#board-report summary { cursor: pointer; font-weight: 600; font-size: var(--fs-xs); color: var(--accent); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.report-grid h4 { margin: 0 0 6px; font-size: var(--fs-xs); color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.rt { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.rt td, .rt th { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: left; color: var(--text); }
.rt th { background: none; text-transform: uppercase; font-size: var(--fs-2xs); letter-spacing: .04em; color: var(--text-2); }
.rt .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.actionbar {
  position: sticky;
  top: 0;
  z-index: var(--z-actionbar);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  padding: 9px 14px;
  background: var(--info-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: var(--fs-xs);
}
.actionbar b { font-variant-numeric: tabular-nums; }
.actionbar button {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 5px 12px;
  cursor: pointer;
  font-size: var(--fs-xs);
  transition: background .15s;
}
@media (hover: hover) { .actionbar button:hover { background: var(--hover); } }
.actionbar select {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 4px 6px;
  font-size: var(--fs-xs);
}
.cbx { width: 34px; text-align: center; }
.cbx input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent); }
/* index.html small decorative icon links */
.icon-btn { margin-left: 5px; text-decoration: none; font-size: var(--fs-sm); opacity: .55; cursor: pointer; }
@media (hover: hover) { .icon-btn:hover { opacity: 1; } }
.mchips { display: flex; flex-wrap: wrap; gap: 4px; }
.mchip { font-size: var(--fs-2xs); font-weight: 550; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.board-foot { display: flex; gap: 10px; align-items: center; padding: 10px 4px; font-size: var(--fs-sm); }
.mchip--acc { color: var(--text-3); font-weight: 450; font-style: italic; }
.jax-pill { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .03em; color: var(--ok); background: var(--ok-bg); border-radius: 5px; padding: 2px 8px; }
.lane-ok { font-size: var(--fs-2xs); color: var(--ok); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.lane-sug { font-size: var(--fs-2xs); color: var(--warn); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.lane-confirm {
  font: inherit;
  font-size: var(--fs-2xs);
  margin-top: 2px;
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  max-width: 110px;
}
.redzone { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-2xs); font-weight: 600; color: var(--danger); white-space: nowrap; }
tr.is-red { background: color-mix(in srgb, var(--danger-bg) 60%, var(--surface)); }
@media (hover: hover) { tr.is-red:hover { background: color-mix(in srgb, var(--danger-bg) 80%, var(--surface)); } }
.notes-cell { max-width: 220px; cursor: text; white-space: normal; }
.note-text { display: inline-block; font-size: var(--fs-xs); line-height: 1.35; }

/* ── Warehouse: Login ─────────────────────────────────────────────────────── */
#loginView { min-height: 100svh; display: flex; align-items: center; }
#loginView .wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: var(--sp-4); }
.login-title { font-size: 28px; font-weight: 800; text-align: center; margin: 0 0 4px; letter-spacing: -.01em; }
.login-sub { text-align: center; color: var(--text-2); margin: 0 0 28px; font-size: var(--fs-md); }
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
/* Big-touch fields are warehouse-only (.field wraps login + ship modal inputs);
   unscoped, this rule used to swallow the board toolbar's inline selects. */
.field input[type=text], .field input[type=password], .field select {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: var(--fs-lg);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-height: 52px;
}
.field input:focus-visible, .field select:focus-visible,
#search:focus-visible, .flt:focus-visible { box-shadow: none; outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px;
  font: inherit;
  font-size: var(--fs-lg);
  font-weight: 700;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--accent-contrast);
  background: var(--accent);
  transition: background .15s;
}
@media (hover: hover) { .btn:hover { background: var(--accent-hover); } }
.btn:active { filter: brightness(.94); }
.btn-good.solid { background: var(--ok); color: #fff; }
[data-theme=dark] .btn-good.solid { color: #10241A; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
@media (hover: hover) { .btn-ghost:hover { background: var(--hover); } }
.err { color: var(--danger); text-align: center; margin-top: 14px; font-size: var(--fs-md); min-height: 20px; }

/* ── Warehouse: Top bar ───────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: 10px 14px;
}
.topbar .brand { font-weight: 800; font-size: var(--fs-lg); white-space: nowrap; }
.topbar .brand::before {
  content: '';
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 3px;
  background: var(--brand);
  margin-right: 7px;
}
.topbar .brand small { color: var(--text-2); font-weight: 400; font-size: var(--fs-xs); margin-left: 6px; }
.topbar .spacer { flex: 1 1 auto; }
.flt {
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-size: var(--fs-sm);
  min-height: 44px;
}
#search {
  flex: 1 1 180px;
  min-width: 140px;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: var(--fs-md);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* ── Warehouse: Big-touch icon buttons (toolbar buttons on warehouse screen) */
/* NOTE: index.html uses .icon-btn for tiny decorative links; those stay as
   defined above. Warehouse overrides .icon-btn inside .topbar only. */
.topbar .icon-btn,
.icon-btn.wh {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  margin-left: 0;
  opacity: 1;
  text-decoration: none;
  transition: background .15s;
}
@media (hover: hover) { .topbar .icon-btn:hover, .icon-btn.wh:hover { background: var(--hover); } }
.topbar .icon-btn:active, .icon-btn.wh:active { filter: brightness(1.05); }

/* ── Warehouse: Tabs ──────────────────────────────────────────────────────── */
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); padding: var(--sp-2) 14px 0; }
.tab {
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .03em;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
@media (hover: hover) { .tab:hover { color: var(--text); } }
.tab.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* ── Warehouse: Legend + Toast ───────────────────────────────────────────── */
.legend { padding: 6px 14px 4px; color: var(--text-2); font-size: var(--fs-xs); }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--border); }
.legend-swatch--amber { background: color-mix(in srgb, var(--warn) 25%, var(--surface)); }
.legend-swatch--orange { background: color-mix(in srgb, var(--warn) 45%, var(--surface)); }
.toast {
  margin: 6px 14px 0;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: var(--fs-sm);
}

/* ── Board: CHR report upload result ─────────────────────────────────────── */
#chr-upload-result { display:none; margin: 6px 0 0; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); font-size: var(--fs-sm); }
#chr-upload-result.ok { display:block; background: var(--info-bg); color: var(--info); border-left: 3px solid var(--info); }
#chr-upload-result.err { display:block; background: var(--danger-bg); color: var(--danger); border-left: 3px solid var(--danger); }

/* ── Warehouse: Table ────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; padding: var(--sp-2) 14px 40px; -webkit-overflow-scrolling: touch; }
/* table base styles inherited from shared section above */
thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  color: var(--text-2);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 10px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr { background: var(--surface); }
tbody tr:nth-child(even) { background: var(--surface-2); }
tr.tint-amber { background: color-mix(in srgb, var(--warn) 8%, var(--surface)) !important; }
tr.tint-orange { background: color-mix(in srgb, var(--warn) 16%, var(--surface)) !important; }

/* ── Warehouse: Cell helpers ─────────────────────────────────────────────── */
td.col-num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-line { white-space: nowrap; }
.item-line + .item-line { margin-top: 3px; }
.dims { color: var(--text-2); font-size: var(--fs-xs); margin-left: 6px; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }
.amber { color: var(--warn); }
.addr { color: var(--text-2); font-size: var(--fs-xs); margin-top: 2px; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-2xs);
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.pill.delivered { background: var(--ok-bg); border-color: transparent; color: var(--ok); }

/* ── Warehouse: Location cell ────────────────────────────────────────────── */
.loc-cell { cursor: pointer; }
.loc-add { color: var(--accent); }
.loc-input {
  width: 110px;
  min-height: 40px;
  padding: 6px 8px;
  font: inherit;
  font-size: var(--fs-sm);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
}

/* ── Warehouse: Action buttons ───────────────────────────────────────────── */
.act-btn {
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 700;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  white-space: nowrap;
  transition: filter .15s;
}
.act-btn:active { filter: brightness(.92); }
.act-ready { background: var(--ok); color: #fff; }
[data-theme=dark] .act-ready { color: #10241A; }
.act-ship { background: var(--accent); color: var(--accent-contrast); }
.act-undo {
  display: block;
  margin-top: 6px;
  background: none;
  border: none;
  font: inherit;
  color: var(--text-2);
  font-size: var(--fs-sm);
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 2px;
  min-height: 32px;
}

/* ── Board phase: toolbar groups, inline note editing, row icons ─────────── */
.tb-group { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.tb-search { flex: 1 1 220px; max-width: 340px; }
.tb-search input { width: 100%; max-width: none; }
.tb-actions { margin-left: auto; }
.toolbar .btn2 svg { vertical-align: -2px; }
.note-input {
  width: 100%;
  min-width: 160px;
  font: inherit;
  font-size: var(--fs-xs);
  padding: 4px 6px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
}
td .icon-btn svg { vertical-align: -2px; }

/* ── Warehouse: Ship modal ───────────────────────────────────────────────── */
.modal-back {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--z-modal);
}
/* .modal shared above — warehouse adds sheet-style radius for bottom sheet */
.modal-back .modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--sp-5);
  border-top: 1px solid var(--border);
  /* reset board-modal overrides */
  max-height: none;
  overflow-y: visible;
}
.modal-back .modal h3 { margin: 0 0 4px; font-size: var(--fs-xl); font-weight: 700; }
.modal-back .modal .sub { color: var(--text-2); margin: 0 0 18px; font-size: var(--fs-md); }
.modal-back .modal .row { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.modal-back .modal .row .btn { flex: 1; }
.modal-back .modal .merr { color: var(--danger); font-size: var(--fs-md); min-height: 20px; margin-top: 6px; }
@media (min-width: 641px) {
  .modal-back { align-items: center; }
  .modal-back .modal { border-radius: var(--r-lg); margin: var(--sp-4); }
}

/* ── Modal + CHR phase ───────────────────────────────────────────────────── */
/* The dialog gets programmatic focus on open; it must not flash a focus ring. */
.modal:focus-visible, #modal:focus-visible { box-shadow: none; }
/* Inline stage-change error (board modal) — replaces the old alert() calls. */
.modal-body .stage-actions .merr { color: var(--danger); font-size: var(--fs-xs); }

.chr-panel { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; margin-top: var(--sp-2); background: var(--surface-2); }
.chr-fields { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; }
.chr-field { font-size: var(--fs-2xs); color: var(--text-3); }
.chr-field input {
  font: inherit;
  font-size: var(--fs-sm);
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
}
#chr-length, #chr-width, #chr-height { width: 70px; }
#chr-weight { width: 80px; }
#chr-pallets { width: 60px; }
.chr-note { color: var(--text-3); font-size: var(--fs-2xs); margin-top: 4px; }
.chr-note--warn { color: var(--warn); }
