/* DICS ERP - one stylesheet, light and dark themes from the same tokens. */

:root {
  color-scheme: light;
  --plane: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --surface-3: #e9e8e2;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #17694a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f0e9;
  --focus: #2a78d6;
  --series-1: #2a78d6;
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #7a4f00;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #b3261e;
  --critical-soft: #fbe9e7;
  --warning-soft: #fdf3dc;
  --good-soft: #e3f3e3;
  --info-soft: #e6effa;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 8px 24px rgba(11, 11, 11, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar: 228px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a29b;
    --line: #2c2c2a;
    --line-strong: #44443f;
    --accent: #3fae7f;
    --accent-ink: #08130e;
    --accent-soft: #15291f;
    --focus: #3987e5;
    --series-1: #3987e5;
    --series-1-wash: rgba(57, 135, 229, 0.14);
    --grid: #2c2c2a;
    --axis: #383835;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --critical-ink: #ef6b6b;
    --critical-soft: #3a1b1a;
    --warning-soft: #33280f;
    --good-soft: #142b14;
    --info-soft: #15233a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --surface-3: #2c2c2a;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #a3a29b;
  --line: #2c2c2a;
  --line-strong: #44443f;
  --accent: #3fae7f;
  --accent-ink: #08130e;
  --accent-soft: #15291f;
  --focus: #3987e5;
  --series-1: #3987e5;
  --series-1-wash: rgba(57, 135, 229, 0.14);
  --grid: #2c2c2a;
  --axis: #383835;
  --good-ink: #0ca30c;
  --warning-ink: #fab219;
  --critical-ink: #ef6b6b;
  --critical-soft: #3a1b1a;
  --warning-soft: #33280f;
  --good-soft: #142b14;
  --info-soft: #15233a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--plane); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- shell ----------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.brand-name { font-weight: 650; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.nav-group { margin: 10px 0 2px; padding: 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: 18px; padding: 10px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.theme-toggle { margin-top: 6px; }

.topbar { display: none; }
.content { min-width: 0; }
main { min-width: 0; padding: 24px 28px 64px; }
.page { max-width: 1440px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%);
    transition: transform 0.18s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  main { padding: 16px 16px 72px; }
}

/* ---- building blocks -------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sep { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  font: inherit; font-weight: 550; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--critical-ink); border-color: var(--line-strong); }
.btn.danger:hover { background: var(--critical-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 30px; padding: 0; height: 30px; }
.btn.icon.sm { width: 26px; height: 26px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.on { background: var(--accent-soft); font-weight: 650; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.fields .span-2 { grid-column: span 2; }
@media (max-width: 760px) { .fields .span-2 { grid-column: 1 / -1; } }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 6px 9px; min-height: 34px; width: 100%; min-width: 0;
}
textarea { min-height: 72px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; min-height: 16px; height: 16px; accent-color: var(--accent); }
input[type="number"] { font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
input.invalid { border-color: var(--critical); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 400; }
.input-group { display: flex; }
.input-group > input, .input-group > select { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > .btn, .input-group > select:last-child, .input-group > .addon {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; flex: none; }
.input-group > select:last-child { width: auto; }
.addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
.search { position: relative; min-width: 220px; flex: 1 1 260px; max-width: 420px; }
.search input { padding-left: 32px; }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar select, .toolbar input[type="date"] { width: auto; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data th { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { color: var(--muted); margin-left: 4px; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }
table.data tfoot td { font-weight: 650; background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data .sub { display: block; font-size: 12px; color: var(--muted); }
table.data.compact th, table.data.compact td { padding: 6px 8px; }
table.data input, table.data select { min-height: 30px; padding: 4px 7px; }
.card.flush table.data th:first-child, .card.flush table.data td:first-child { padding-left: 16px; }
.card.flush table.data th:last-child, .card.flush table.data td:last-child { padding-right: 16px; }
.card.flush .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* chips & badges */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap; line-height: 18px; }
.chip svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chip.status-Submitted { background: var(--info-soft); color: var(--ink); }
.chip.status-Filled { background: var(--accent-soft); color: var(--ink); }
.chip.status-Sent { background: var(--surface-3); color: var(--ink); }
.chip.status-Delivered { background: var(--good-soft); color: var(--good-ink); }
.chip.status-Cancelled { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.chip.warn { background: var(--warning-soft); color: var(--warning-ink); }
.chip.bad { background: var(--critical-soft); color: var(--critical-ink); }
.chip.good { background: var(--good-soft); color: var(--good-ink); }
.chip.outline { background: transparent; border: 1px solid var(--line-strong); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.type-Sativa { background: #eb6834; } .type-Hybrid { background: #1baf7a; } .type-Indica { background: #6250d6; }
.type-High-CBD { background: #2a78d6; } .type-Alternate-Cannabinoids { background: #eda100; }
.stock-low { color: var(--warning-ink); font-weight: 600; }
.stock-out { color: var(--critical-ink); font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { border-bottom-color: var(--accent); color: var(--ink); font-weight: 650; }
.tabs .count { margin-left: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* stat tiles */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 2px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi.hero .value { font-size: 34px; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.kpi .delta.up { color: var(--good-ink); }
.kpi .delta.down { color: var(--critical-ink); }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series-1); }
.chart .bar.hot { filter: brightness(1.15); }
.chart .hit { fill: transparent; cursor: default; }
.chart .label { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 120px; }
.tooltip .tv { font-size: 14px; font-weight: 650; }
.tooltip .tl { color: var(--ink-2); }
.tooltip .key { display: inline-block; width: 12px; height: 2px; background: var(--series-1); vertical-align: middle; margin-right: 6px; }
.bars { display: grid; gap: 8px; }
.bars .bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr; gap: 10px; align-items: center; }
.bars .bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--ink); }
.bars .bar-track { position: relative; height: 18px; display: flex; align-items: center; gap: 8px; }
.bars .bar-fill { height: 14px; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; flex: none; }
.bars .bar-value { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .bar-row:hover .bar-fill { filter: brightness(1.15); }

/* product bits */
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex: none; display: block; }
.thumb.lg { width: 160px; height: 160px; border-radius: 12px; }
.thumb.sm { width: 32px; height: 32px; border-radius: 6px; }
.thumb-empty { display: grid; place-items: center; color: var(--muted); }
.thumb-empty svg { width: 45%; height: 45%; stroke: currentColor; fill: none; stroke-width: 1.6; }
.product-cell { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.product-cell .name { font-weight: 600; }
.potency { display: inline-flex; gap: 8px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.potency b { color: var(--ink); font-weight: 650; }
.profile-grid { display: grid; gap: 8px 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.profile-grid .field input { text-align: right; }

/* order status stepper */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 4px 0 2px; }
.step { position: relative; padding-top: 24px; text-align: center; font-size: 13px; }
.step::before { content: ""; position: absolute; top: 8px; left: -50%; right: 50%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step .node { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); display: grid; place-items: center; }
.step .node svg { width: 11px; height: 11px; stroke: var(--accent-ink); fill: none; stroke-width: 3; }
.step.done .node { background: var(--accent); border-color: var(--accent); }
.step.done::before { background: var(--accent); }
.step .when { display: block; color: var(--muted); font-size: 12px; }
.step .name { font-weight: 600; }
.cancel-banner { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--critical-soft); color: var(--critical-ink); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 6px 0; }
.timeline .dot { margin-top: 6px; background: var(--accent); }
.timeline .what { font-weight: 600; }
.timeline .when { color: var(--muted); font-size: 12px; }
.order-number { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.06em; }
.big-number { font-size: 40px; font-weight: 700; text-align: center; margin: 8px 0 4px; }

/* cart builder */
table.menu-table { table-layout: fixed; min-width: 760px; }
table.menu-table col.c-size { width: 72px; } table.menu-table col.c-case { width: 60px; }
table.menu-table col.c-price { width: 84px; } table.menu-table col.c-stock { width: 80px; }
table.menu-table col.c-qty { width: 176px; } table.menu-table col.c-total { width: 96px; }
table.menu-table .product-cell { min-width: 0; }
@media (max-width: 760px) {
  /* each product becomes a small card: product, then size/case/price/stock, then quantity and total */
  table.menu-table { min-width: 0; table-layout: auto; }
  table.menu-table colgroup, table.menu-table thead { display: none; }
  table.menu-table, table.menu-table tbody { display: block; }
  table.menu-table tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.menu-table td { display: block; padding: 0 !important; border: 0; text-align: left; }
  table.menu-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  table.menu-table td.c-product { grid-column: 1 / -1; }
  table.menu-table td.c-qty { grid-column: 1 / 4; }
  table.menu-table td.c-total { align-self: center; text-align: right; font-weight: 650; }
  table.menu-table tr.in-cart { background: var(--accent-soft); }
  table.menu-table tr.in-cart td { background: transparent; }
}
.menu-group + .menu-group { margin-top: 16px; }
.menu-group > .card-head h2 { display: flex; gap: 8px; align-items: center; }
.qty { display: inline-flex; align-items: center; }
.qty input { width: 72px; text-align: right; border-radius: 0; margin: 0 -1px; }
.qty .btn { height: 34px; }
.qty .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.qty .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
tr.in-cart td { background: var(--accent-soft); }
.cart-panel { position: sticky; top: 16px; }
.cart-lines { max-height: 340px; overflow-y: auto; margin: 0 -16px; padding: 0 16px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.cart-line .meta { color: var(--muted); font-size: 12px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0; }
.totals .grand { font-size: 18px; font-weight: 700; }
.saved-state { font-size: 12px; color: var(--muted); }

/* menu builder */
.group-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.group-card + .group-card { margin-top: 12px; }
.group-card.drag-over { outline: 2px dashed var(--focus); outline-offset: 2px; }
.group-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.group-head input.group-name { font-weight: 650; max-width: 360px; flex: 1 1 160px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.entry:last-child { border-bottom: 0; }
.entry.dragging { opacity: 0.4; }
.entry.drop-before { box-shadow: inset 0 2px 0 var(--focus); }
.entry.drop-after { box-shadow: inset 0 -2px 0 var(--focus); }
.handle { cursor: grab; color: var(--muted); display: grid; place-items: center; width: 18px; }
.handle svg { width: 14px; height: 14px; fill: currentColor; }
.entry .pos { width: 22px; color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.entry .grow { flex: 1; min-width: 0; }
.entry .grow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }

/* BOM editor */
.stage-card { border: 1px solid var(--line); border-radius: var(--radius); }
.stage-card + .stage-card { margin-top: 12px; }
.stage-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.stage-head .stage-no { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.stage-head input { font-weight: 650; max-width: 320px; flex: 1 1 160px; }
.list-editor .item { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.list-editor .item:last-child { border-bottom: 0; }

/* dialogs & toasts */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(11, 11, 11, 0.45); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 16px 18px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.toasts { position: fixed; z-index: 200; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--plane); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: var(--critical); color: #fff; }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }
.notice.warn { background: var(--warning-soft); color: var(--warning-ink); }
.notice.bad { background: var(--critical-soft); color: var(--critical-ink); }
.notice.good { background: var(--good-soft); color: var(--good-ink); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.dirty-bar { position: sticky; bottom: 0; z-index: 20; display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dirty-bar .state { margin-right: auto; color: var(--muted); font-size: 13px; }
.dirty-bar .state.on { color: var(--warning-ink); font-weight: 600; }
.token { cursor: pointer; }
.picker-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.picker-list label { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picker-list label:last-child { border-bottom: 0; }
.picker-list label:hover { background: var(--surface-2); }
.picker-list label.disabled { opacity: 0.55; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }

/* print: order documents and reports print without the app chrome */
.print-only { display: none; }
@media print {
  .print-only { display: block; margin-bottom: 12px; }
  .grid-side { grid-template-columns: 1fr; }
  .sidebar, .topbar, .no-print, .dirty-bar, .toasts, .page-head .actions { display: none !important; }
  .shell { display: block; }
  main { padding: 0; }
  body, .card, .kpi { background: #fff; color: #000; }
  .card { border-color: #ccc; break-inside: avoid; }
}
