/* =====================================================================
   ERP stylesheet — tokens, layout, components, themes, responsive
   8px grid. Light = white + violet. Dark = black + violet.
   ===================================================================== */
:root {
  --accent: #5b3df5;
  --accent-ink: #ffffff;
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f1f1f8;
  --surface-3: #e9e9f3;
  --border: #e4e4ee;
  --border-strong: #cfcfdf;
  --text: #14141f;
  --text-2: #4a4b5e;
  --muted: #7a7b90;
  --good: #0f8a4f;  --good-bg: #e3f6ec;
  --warn: #a86400;  --warn-bg: #fdf1d9;
  --bad: #c62b3a;   --bad-bg: #fde8ea;
  --info: #1d63c9;  --info-bg: #e5effc;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 8px 24px -12px rgba(20, 20, 40, .12);
  --shadow-lg: 0 24px 64px -16px rgba(20, 20, 40, .28);
  --radius: 12px; --radius-sm: 8px; --radius-lg: 16px;
  --sidebar-w: 264px; --topbar-h: 60px;
  --font: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --accent: #8b7bff;
  --accent-ink: #0a0a10;
  --bg: #050507;
  --surface: #0e0e13;
  --surface-2: #15151c;
  --surface-3: #1d1d27;
  --border: #22222d;
  --border-strong: #34344a;
  --text: #ececf4;
  --text-2: #b9bace;
  --muted: #8a8ba2;
  --good: #3ddc84;  --good-bg: #0f2a1c;
  --warn: #f5b942;  --warn-bg: #2e2208;
  --bad: #ff7a86;   --bad-bg: #321317;
  --info: #6fa8ff;  --info-bg: #101f38;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -12px rgba(0, 0, 0, .8);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, .9);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --accent: #8b7bff; --accent-ink: #0a0a10; --bg: #050507; --surface: #0e0e13; --surface-2: #15151c; --surface-3: #1d1d27;
    --border: #22222d; --border-strong: #34344a; --text: #ececf4; --text-2: #b9bace; --muted: #8a8ba2;
    --good: #3ddc84; --good-bg: #0f2a1c; --warn: #f5b942; --warn-bg: #2e2208; --bad: #ff7a86; --bad-bg: #321317; --info: #6fa8ff; --info-bg: #101f38;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.8); --shadow-lg: 0 24px 64px -16px rgba(0,0,0,.9);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.hide { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap16 { gap: 16px; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb16 { margin-bottom: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40; transition: transform .22s ease;
}
.brand { height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); flex: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: -.03em; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: -2px; }
.nav { flex: 1; overflow-y: auto; padding: 12px; scrollbar-width: thin; }
.nav-item, .nav-group > summary {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 600; cursor: pointer; text-decoration: none; list-style: none; user-select: none; position: relative;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-item:hover, .nav-group > summary:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-group > summary .chev { margin-left: auto; transition: transform .2s; width: 16px; height: 16px; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group[open] > summary { color: var(--text); }
.nav-sub { margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.nav-sub .nav-item { height: 34px; font-weight: 500; font-size: 13px; padding: 0 10px; }
.nav-sub .nav-item.active::before { left: -13px; top: 6px; bottom: 6px; }
.nav-count { margin-left: auto; font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 7px; line-height: 18px; font-weight: 700; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; transition: margin-left .22s ease; display: flex; flex-direction: column; }
body.nav-hidden .sidebar { transform: translateX(-100%); }
body.nav-hidden .main { margin-left: 0; }
.scrim { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border);
}
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.search-box { position: relative; flex: 0 1 420px; }
.search-box .ico { position: absolute; left: 12px; top: 11px; color: var(--muted); }
.search-box input { width: 100%; height: 40px; padding: 0 56px 0 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); outline: none; }
.search-box input:focus { border-color: var(--accent); background: var(--surface); }
.kbd { position: absolute; right: 10px; top: 9px; font-size: 11px; border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 6px; color: var(--muted); line-height: 20px; background: var(--surface); }
.content { padding: 24px; max-width: 1760px; width: 100%; margin: 0 auto; flex: 1; }
.menu { position: absolute; right: 0; top: 46px; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 8px; color: var(--text); text-align: left; cursor: pointer; font-weight: 500; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu .head { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.avatar { border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; letter-spacing: 0; }
.rel { position: relative; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); outline: none; min-width: 0;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.sm, .select.sm { height: 30px; font-size: 13px; border-radius: 8px; }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--bad); }
.field .req { color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.multi { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); max-height: 260px; overflow: auto; }

/* ---------- cards / badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-h h3 { font-size: 15px; }
.card-b { padding: 20px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge.good { background: var(--good-bg); color: var(--good); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; background: none; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-color: var(--accent); }
.tab .n { margin-left: 6px; font-size: 11px; background: var(--surface-3); border-radius: 99px; padding: 1px 7px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .ico { width: 36px; height: 36px; margin-bottom: 8px; opacity: .6; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }
.alert { padding: 12px 16px; border-radius: 10px; font-weight: 500; display: flex; gap: 10px; align-items: flex-start; }
.alert.info { background: var(--info-bg); color: var(--info); } .alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.good { background: var(--good-bg); color: var(--good); }

/* ---------- KPI ---------- */
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; text-decoration: none !important; color: inherit; transition: border-color .15s, transform .15s; }
.kpi:hover { border-color: var(--accent); }
.kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.kpi .s { font-size: 12px; color: var(--muted); }
.attn { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none !important; }
.attn:hover { background: var(--surface-2); }
.attn .n { min-width: 34px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: var(--warn-bg); color: var(--warn); }
.attn .n.bad { background: var(--bad-bg); color: var(--bad); } .attn .n.zero { background: var(--surface-2); color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.bar-h { display: flex; flex-direction: column; gap: 10px; }
.bar-h .r { display: grid; grid-template-columns: 110px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.bar-h .trk { height: 14px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-h .fill { height: 100%; border-radius: 0 4px 4px 0; }

/* ---------- table ---------- */
.dt-wrap { display: flex; flex-direction: column; }
.dt-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dt-bar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.dt-bar .search .ico { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; color: var(--muted); }
.dt-bar .search input { padding-left: 34px; }
.dt-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.fchip { display: inline-flex; align-items: center; gap: 6px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-radius: 99px; padding: 2px 6px 2px 10px; font-size: 12px; font-weight: 600; }
.fchip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 4px; font-size: 14px; line-height: 1; }
.dt-scroll { overflow: auto; max-height: calc(100vh - 280px); min-height: 120px; }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 640px; }
.dt th { position: sticky; top: 0; z-index: 2; background: var(--surface); text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 12px; height: 44px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dt th .th { display: flex; align-items: center; gap: 4px; }
.dt th.right .th { justify-content: flex-end; }
.dt th .lbl { cursor: default; } .dt th.sortable .lbl { cursor: pointer; }
.dt th .lbl:hover { color: var(--text); }
.dt th .sort { width: 12px; opacity: .5; }
.dt th .fbtn { width: 24px; height: 24px; border-radius: 6px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.dt th .fbtn:hover { background: var(--surface-2); color: var(--text); }
.dt th .fbtn.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.dt th .fbtn .ico { width: 14px; height: 14px; }
.dt td { padding: 0 12px; height: 52px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dt tbody tr:hover td { background: var(--surface-2); }
.dt tbody tr.click { cursor: pointer; }
.dt tbody tr.sel td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dt td.right { text-align: right; font-variant-numeric: tabular-nums; }
.dt td .clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt .cb { width: 40px; padding-left: 16px; }
.dt .cb input { width: 16px; height: 16px; accent-color: var(--accent); }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; color: var(--muted); font-size: 13px; }
.dt-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 16px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-bottom: 1px solid var(--border); font-weight: 600; }
.pop { position: fixed; z-index: 90; width: 280px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pop .opts { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }

/* ---------- modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(8, 8, 16, .55); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 640px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: rise .18s ease; }
.modal.lg { max-width: 920px; } .modal.xl { max-width: 1180px; } .modal.sm { max-width: 440px; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-h h3 { font-size: 16px; }
.modal-b { padding: 20px; overflow: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 600; max-width: 420px; animation: rise .2s; display: flex; gap: 10px; align-items: flex-start; }
.toast.bad { background: var(--bad); color: #fff; } .toast.good { background: var(--good); color: #fff; }
:root[data-theme="dark"] .toast.good { color: #04140b; } :root[data-theme="dark"] .toast.bad { color: #1a0306; }
.palette { width: 100%; max-width: 600px; align-self: start; margin-top: 12vh; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.palette input { width: 100%; height: 52px; border: 0; border-bottom: 1px solid var(--border); padding: 0 20px; outline: none; background: transparent; font-size: 16px; }
.palette .list { max-height: 360px; overflow: auto; padding: 6px; }
.palette .it { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.palette .it.on, .palette .it:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---------- order detail ---------- */
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.tl:last-child { padding-bottom: 0; }
.tl::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.tl:last-child::before { display: none; }
.tl .pt { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 800; z-index: 1; }
.tl.done .pt { background: var(--good); color: #fff; } .tl.now .pt { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.tl.done::before { background: var(--good); }
.tl .t { font-weight: 700; } .tl .w { font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13px; } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.perm-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.perm-box h4 { font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.perm-box .check { padding: 3px 0; font-size: 13px; }
.tier-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.heat { display: grid; grid-template-columns: 130px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; margin: 6px 0; }
.heat .trk { height: 16px; border-radius: 4px; background: var(--surface-2); overflow: hidden; display: flex; gap: 2px; }
.heat .seg { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.fin-table { width: 100%; border-collapse: collapse; }
.fin-table td, .fin-table th { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.fin-table th { font-size: 12px; color: var(--muted); }
.fin-table td.n, .fin-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table tr.sec td { font-weight: 800; background: var(--surface-2); }
.fin-table tr.tot td { font-weight: 800; border-top: 2px solid var(--text); }
.fin-table tr.sub td { font-weight: 700; border-top: 1px solid var(--border-strong); }
.fin-table td.ind { padding-left: 28px; }
.scroll-x { overflow-x: auto; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { background: #07070b; color: #ececf4; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; inset: auto -20% -35% 10%; height: 70%; background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 55%, transparent), transparent); filter: blur(30px); }
.login-art h2 { font-size: 40px; line-height: 1.1; letter-spacing: -.03em; max-width: 14ch; position: relative; z-index: 1; }
.login-art p { color: #a9aabf; max-width: 42ch; margin-top: 16px; position: relative; z-index: 1; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 26px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0 !important; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(8, 8, 16, .5); z-index: 35; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .content { padding: 16px; } .topbar { padding: 0 12px; gap: 6px; }
  .search-box { flex: 1 1 auto; } .search-box .kbd { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .g4.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; } .page-head h1 { font-size: 20px; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
  .bar-h .r { grid-template-columns: 80px 1fr 50px; }
  .heat { grid-template-columns: 90px 1fr 44px; }
  .tier-row { grid-template-columns: 1fr; }
  .modal { max-height: calc(100vh - 16px); } .overlay { padding: 8px; }
  .hide-sm { display: none !important; }
  /* tables become cards */
  table.dt, .dt thead, .dt tbody, .dt tr, .dt td { display: block; min-width: 0; width: 100%; }
  .dt thead { display: none; }
  .dt tbody tr { border: 1px solid var(--border); border-radius: 12px; margin: 10px 12px; width: auto; padding: 6px 0; background: var(--surface); }
  .dt td { height: auto; min-height: 36px; border: 0; padding: 4px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: right; }
  .dt td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; flex: none; }
  .dt td.cb::before, .dt td.nolabel::before { display: none; } .dt td.cb { width: auto; }
  .dt-scroll { max-height: none; }
}
@media (min-width: 1920px) { :root { --sidebar-w: 288px; } body { font-size: 15px; } .content { padding: 32px 40px; } }
@media print { .sidebar, .topbar, .toasts, .no-print { display: none !important; } .main { margin: 0 !important; } .card { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.table-scroll { overflow-x: auto; }

/* ---------- v2 additions ---------- */
.nav-item, .nav-group > summary { position: relative; }
.nbadge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; line-height: 1; flex: none; animation: nbpulse 1.8s ease-out infinite; font-variant-numeric: tabular-nums; }
.nav-group > summary .nbadge + .chev { margin-left: 8px; }
.nav-group > summary .nbadge { margin-left: auto; }
.nav-group[open] > summary .nbadge { animation-duration: 2.6s; }
@keyframes nbpulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .55); } 70% { box-shadow: 0 0 0 8px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
.nav-item { gap: 10px; }
.nav-item .lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-list { display: flex; flex-direction: column; }
.tier-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.icon-btn.danger-ico { color: var(--bad); } .icon-btn.danger-ico:hover { background: var(--bad-bg); }
.daypick { display: flex; flex-wrap: wrap; gap: 6px; }
.daychip { height: 34px; min-width: 46px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 700; font-size: 13px; cursor: pointer; }
.daychip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hours-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hours-pick select { flex: 1 1 110px; min-width: 0; }
/* order item lines: aligned grid */
.iline { display: grid; grid-template-columns: minmax(0, 2.2fr) repeat(4, minmax(0, 1fr)) 40px; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-bottom: 10px; }
.iline .fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.iline .fld > label { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iline .fld input, .iline .fld select { width: 100%; min-width: 0; }
.iline .iline-del { align-self: end; }
.iline .iline-sum { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.icon-btn, .btn.icon { flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.stock-co { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.stock-co .card { padding: 14px 16px; }
.lock-note { font-size: 12px; color: var(--muted); }
.stockchk { width: 100%; border-collapse: collapse; font-size: 13px; }
.stockchk th, .stockchk td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.stockchk .n { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1024px) { .iline { grid-template-columns: repeat(4, minmax(0, 1fr)); } .iline .fld.prod { grid-column: 1 / -1; } .iline .iline-del { grid-column: 4; justify-self: end; } }
@media (max-width: 720px) {
  .iline { grid-template-columns: repeat(2, minmax(0, 1fr)); } .iline .iline-del { grid-column: 2; }
  .page-head { align-items: flex-start; } .page-head .btn-row { width: 100%; }
  .tabs, .tabbar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
  .modal { width: 100% !important; max-width: 100% !important; }
  .stock-co { grid-template-columns: 1fr 1fr; }
  .card-pad, .card { min-width: 0; }
  img, canvas { max-width: 100%; }
}
.stock-card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.vline { grid-template-columns: repeat(5, minmax(0, 1fr)) 40px; }
@media (max-width: 1024px) { .vline { grid-template-columns: repeat(2, minmax(0, 1fr)); } .vline .iline-del { grid-column: 2; } }
.gb-holder .select { height: 36px; }
.logo-prev { width: 160px; height: 90px; border: 1px dashed var(--border-strong); border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.courier-owed { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.courier-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.courier-stats div { display: flex; flex-direction: column; align-items: center; } .courier-stats b { font-size: 16px; } .courier-stats span { font-size: 11.5px; color: var(--muted); }
.courier-orders { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.courier-orders tr.picked td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.courier-sum { margin-left: auto; width: min(360px, 100%); display: flex; flex-direction: column; gap: 4px; }
.courier-sum > div { display: flex; justify-content: space-between; padding: 4px 0; }
.courier-sum .net { border-top: 2px solid var(--text); font-size: 16px; padding-top: 8px; }
.row.gap12 { gap: 12px; } .row.gap12 > .field { flex: 1 1 200px; }
.iline { align-items: start; }
.iline .iline-del { align-self: start; margin-top: 21px; }
.iline .fld > label { height: 16px; line-height: 16px; }
.iline .iline-sum .muted { font-size: 12px; }
.nav-group > summary .lbl, .nav-item .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.nav-group > summary { gap: 12px; }
.nav-group > summary .nbadge { margin-left: 0; }
.nav-group > summary .chev { margin-left: 0 !important; }
@media (max-width: 720px) {
  .kpi { padding: 14px; } .kpi .v { font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
  .dt td[colspan] { justify-content: center; text-align: center; } .dt td[colspan]::before { display: none; }
  .courier-sum { width: 100%; }
}
.pager select, select[aria-label*="per page"] { min-width: 96px; }
