/* ============================================
   CMS — Data-dense B2B analytics interface
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  /* Dark theme (default) */
  --bg: oklch(0.17 0.008 260);
  --bg-1: oklch(0.20 0.009 260);
  --bg-2: oklch(0.23 0.010 260);
  --bg-3: oklch(0.27 0.011 260);
  --line: oklch(0.30 0.012 260);
  --line-strong: oklch(0.38 0.015 260);
  --text: oklch(0.96 0.008 85);
  --text-1: oklch(0.82 0.010 85);
  --text-2: oklch(0.62 0.012 85);
  --text-3: oklch(0.45 0.012 260);

  /* Monochrome + tiny accents */
  --cat-a: oklch(0.78 0.04 260);  /* neutral-top */
  --cat-b: oklch(0.62 0.03 260);  /* neutral-mid */
  --cat-c: oklch(0.45 0.03 260);  /* neutral-tail */
  --accent: oklch(0.78 0.12 230); /* muted blue — interactive */
  --danger: oklch(0.65 0.16 25);  /* desaturated red */
  --positive: oklch(0.72 0.11 150); /* desaturated green */

  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 1px 0 oklch(1 0 0 / 0.04) inset, 0 8px 24px -8px oklch(0 0 0 / 0.4);

  --font-sans: 'Instrument Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;
}

[data-theme="light"] {
  --bg: oklch(0.98 0.004 85);
  --bg-1: oklch(0.96 0.005 85);
  --bg-2: oklch(0.93 0.006 85);
  --bg-3: oklch(0.89 0.007 85);
  --line: oklch(0.86 0.008 85);
  --line-strong: oklch(0.78 0.010 85);
  --text: oklch(0.18 0.010 260);
  --text-1: oklch(0.30 0.012 260);
  --text-2: oklch(0.48 0.012 260);
  --text-3: oklch(0.62 0.010 260);
  --cat-a: oklch(0.58 0.17 142);
  --cat-b: oklch(0.65 0.16 70);
  --cat-c: oklch(0.55 0.03 260);
  --accent: oklch(0.48 0.18 250);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: -0.005em;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

button, input, select { font: inherit; color: inherit; }

.mono { font-family: var(--font-mono); font-feature-settings: 'zero'; }
.serif { font-family: var(--font-serif); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============ App shell ============ */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 54px 1fr 28px;
  grid-template-areas:
    "brand topbar"
    "sidebar main"
    "statusbar statusbar";
  height: 100vh;
  background: var(--bg);
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.brand-mark {
  width: 22px; height: 22px;
  background: var(--text);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  border-radius: 2px;
}
.brand-name {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.brand-ver {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.crumbs {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.crumbs .sep { color: var(--text-3); }
.crumbs .now { color: var(--text); }

.topbar-spacer { flex: 1; }

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-1);
}

.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 280px;
  transition: border-color 0.12s;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  width: 100%;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-3); }

.theme-toggle {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-1);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.theme-toggle:hover { background: var(--bg-2); color: var(--text); border-color: var(--line-strong); }
.theme-toggle svg { width: 15px; height: 15px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 11px;
  cursor: pointer;
}
.user-chip:hover { background: var(--bg-2); }
.avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--cat-a);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  color: var(--bg);
}

/* ============ Sidebar ============ */

.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  overflow-y: auto;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
}

.nav-group { padding: 0 10px; margin-bottom: 14px; }
.nav-group-title {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 0 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-1);
  font-size: 12.5px;
  position: relative;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--line);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--text);
}
.nav-icon {
  width: 14px; height: 14px;
  flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--text-2);
}
.nav-item.active .nav-icon { color: var(--text); }
.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}
.nav-dot {
  margin-left: auto;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cat-a);
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ============ Main area ============ */

.main {
  grid-area: main;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; }

/* ============ Page header ============ */

.page-head {
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.page-title .count {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 13px;
  color: var(--text-3);
  margin-left: 10px;
  vertical-align: 2px;
}
.page-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 16px;
  align-items: center;
}
.page-sub .dot { color: var(--text-3); }

.page-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ============ KPI strip ============ */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.kpi {
  padding: 10px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 0.12s;
}
.kpi:hover { background: var(--bg-2); }
.kpi:last-child { border-right: none; }
.kpi-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-delta.up { color: var(--positive); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta .spark { height: 14px; width: 42px; }

/* ============ Toolbar ============ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.toolbar .spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--text-1);
  border-radius: var(--radius);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-2); color: var(--text); border-color: var(--line-strong); }
.btn.active { background: var(--bg-3); color: var(--text); border-color: var(--line-strong); }
.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { background: oklch(from var(--text) calc(l - 0.08) c h); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { padding: 2px 6px; font-size: 10.5px; }

.btn-icon {
  width: 14px; height: 14px;
  display: grid; place-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-1);
}
.chip .x { color: var(--text-3); cursor: pointer; padding: 0 2px; }
.chip .x:hover { color: var(--text); }

.divider-v {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 2px 6px;
}

/* ============ Table ============ */

.table-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-1);
  padding: 8px 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  user-select: none;
}
table.data thead th.sorted { color: var(--text); }
table.data thead th .sort-arrow { margin-left: 4px; opacity: 0.6; }

table.data tbody td {
  padding: 0 12px;
  height: 36px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
table.data tbody tr { cursor: pointer; transition: background 0.08s; }
table.data tbody tr:hover { background: var(--bg-1); }
table.data tbody tr.selected { background: oklch(from var(--accent) l c h / 0.08); }
table.data tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

.col-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.col-center { text-align: center; }

.sku {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}
.product-cell { display: flex; align-items: center; gap: 10px; }
.thumb {
  width: 28px; height: 28px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.thumb svg { display: block; width: 100%; height: 100%; }
.product-name {
  font-weight: 500;
  color: var(--text);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-meta { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); }

.cat-badge {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--bg);
}
.cat-a { background: var(--cat-a); }
.cat-b { background: var(--cat-b); }
.cat-c { background: var(--cat-c); color: var(--bg); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.status-pill.ok .dot { background: var(--positive); }
.status-pill.warn .dot { background: var(--cat-b); }
.status-pill.bad .dot { background: var(--danger); }

.bar-cell {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.bar-track {
  flex: 1;
  height: 4px;
  background: var(--bg-2);
  border-radius: 2px;
  overflow: hidden;
  min-width: 40px;
}
.bar-fill { height: 100%; background: var(--text-2); }
.bar-fill.pos { background: var(--positive); }
.bar-fill.neg { background: var(--danger); }

/* Trend sparkline inside table */
.trend-inline { width: 60px; height: 16px; display: block; }

/* Margin bar: neg/pos from center */
.margin-bar {
  width: 80px; height: 14px;
  background: var(--bg-2);
  border-radius: 2px;
  position: relative;
}
.margin-bar .zero {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 1px; background: var(--line-strong);
}
.margin-bar .fill {
  position: absolute; top: 2px; bottom: 2px;
  border-radius: 1px;
}

/* Channel dots */
.channels {
  display: inline-flex; gap: 3px;
}
.ch-dot {
  width: 16px; height: 16px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  font-weight: 600;
}
.ch-dot.on { background: var(--text-1); color: var(--bg); border-color: var(--text-1); }

/* ============ Right drawer (product detail) ============ */

.drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--bg-1);
  border-left: 1px solid var(--line-strong);
  box-shadow: -12px 0 32px -16px rgba(0,0,0,0.4);
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.drawer-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 6px;
  background: var(--bg);
}

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: 12px; }
.kv dt { color: var(--text-3); font-family: var(--font-mono); font-size: 11px; }
.kv dd { color: var(--text); font-variant-numeric: tabular-nums; }

/* ============ Status bar ============ */

.statusbar {
  grid-area: statusbar;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}
.statusbar .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--positive);
}
.statusbar .spacer { flex: 1; }
.statusbar .clickable { cursor: pointer; }
.statusbar .clickable:hover { color: var(--text-1); }

/* ============ Dashboard cards ============ */

.dash-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto 1fr;
  gap: 1px;
  background: var(--line);
  overflow: auto;
}

.card {
  background: var(--bg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.card.span-2 { grid-column: span 2; }
.card.span-3 { grid-column: span 3; }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.card-hint { font-size: 11px; color: var(--text-2); }

/* ABC block */
.abc-bar {
  display: grid;
  grid-template-columns: var(--a, 70%) var(--b, 20%) var(--c, 10%);
  height: 36px;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0 10px;
}
.abc-bar > div {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--bg);
}
.abc-bar .ab-a { background: var(--cat-a); }
.abc-bar .ab-b { background: var(--cat-b); }
.abc-bar .ab-c { background: var(--cat-c); }

.abc-rows { display: grid; gap: 6px; }
.abc-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.abc-row:last-child { border-bottom: none; }
.abc-row .badge-mini {
  width: 18px; height: 18px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--bg);
}

/* ============ Supplier view ============ */

.supplier-grid {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  align-content: start;
}
.supplier-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.supplier-card:hover {
  border-color: var(--line-strong);
  background: var(--bg-2);
}
.supplier-card .sc-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.supplier-logo {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--bg-3);
  display: grid; place-items: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--text);
  flex-shrink: 0;
}
.supplier-name { font-weight: 600; font-size: 14px; }
.supplier-country { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }
.score {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.score small { font-size: 11px; color: var(--text-3); font-weight: 400; margin-left: 2px; }

.sc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.sc-stat { background: var(--bg-1); padding: 7px 9px; }
.sc-stat .l {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.05em;
}
.sc-stat .v {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.score-bars { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.score-bar {
  display: grid; grid-template-columns: 90px 1fr 32px;
  gap: 8px; align-items: center;
  font-size: 11px;
  color: var(--text-2);
}
.score-bar .l { font-family: var(--font-mono); font-size: 10px; }
.score-bar .t { height: 3px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.score-bar .t > div { height: 100%; background: var(--text-1); }
.score-bar .v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; font-size: 11px; color: var(--text); }

/* ============ Channels view ============ */

.channels-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  overflow: auto;
}
.ch-card {
  background: var(--bg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 260px;
}
.ch-head { display: flex; align-items: center; gap: 10px; }
.ch-logo {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--bg);
}
.ch-name { font-size: 16px; font-weight: 600; }
.ch-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

.ch-big {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ch-big .v { font-size: 30px; letter-spacing: -0.02em; }
.ch-big .d { font-size: 12px; color: var(--positive); }
.ch-big .d.neg { color: var(--danger); }

.ch-chart { flex: 1; min-height: 80px; }

.ch-foot-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--line);
  border-top: 1px solid var(--line);
  margin: 0 -20px -18px;
}
.ch-foot-stats > div {
  background: var(--bg); padding: 8px 12px;
}
.ch-foot-stats .l { font-family: var(--font-mono); font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.ch-foot-stats .v { font-family: var(--font-mono); font-size: 13px; margin-top: 2px; }

/* ============ B2B / КП — 3-колонный layout ============ */

.cart3-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 264px 1fr 320px;
  overflow: hidden;
  min-height: 0;
}

/* ---- LEFT: Список корзин ---- */
.carts-list {
  border-right: 1px solid var(--line);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.carts-list-head {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.kind-tabs {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.kind-tabs button {
  flex: 1;
  padding: 4px 6px;
  background: transparent;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 11px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.kind-tabs button span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}
.kind-tabs button.on {
  background: var(--bg-3);
  color: var(--text);
}
.kind-tabs button.on span { color: var(--text-1); }

.carts-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}
.cart-card {
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 2px;
  transition: background 0.1s;
}
.cart-card:hover { background: var(--bg-2); }
.cart-card.active {
  background: var(--bg-2);
  border-color: var(--line);
  box-shadow: inset 2px 0 0 var(--accent);
}
.cc-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.cc-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kind-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 500;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.kind-pill.b2b { background: oklch(from var(--accent) l c h / 0.15); color: var(--accent); }
.kind-pill.eu  { background: oklch(from var(--danger) l c h / 0.15); color: var(--danger); }
.kind-pill.sent{ background: oklch(from var(--cat-b) l c h / 0.15); color: var(--cat-b); }

.cc-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.cc-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}
.cc-stats b {
  color: var(--text);
  font-weight: 500;
  margin-left: auto;
}
.cc-stats .dot { color: var(--text-3); }
.cc-stats .sep { flex: 1; }
.cc-time {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

.carts-archive {
  border-top: 1px solid var(--line);
  padding: 10px 14px;
}
.archive-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 6px;
}
.arch-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-2);
  padding: 2px 0;
}

/* ---- CENTER: Детализация КП ---- */
.cart-detail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg);
}

.cart-detail-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.cdh-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}
.cdh-title {
  font-size: 26px;
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.cdh-meta {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}
.cdh-meta .dot { color: var(--text-3); }

.cart-client-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.ccc-col {
  padding: 10px 14px;
  border-right: 1px solid var(--line);
}
.ccc-col:last-child { border-right: none; }
.ccc-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 4px;
}
.ccc-val {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
}
.ccc-sub {
  font-size: 10.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.cart-items-wrap {
  flex: 1;
  overflow: auto;
  padding: 14px 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.items-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cart-items-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-1);
}
table.cart-items-table tbody td {
  height: 64px;
  border-bottom: 1px solid var(--line);
}
table.cart-items-table tbody tr:last-child td { border-bottom: none; }
table.cart-items-table tbody tr { cursor: default; }
table.cart-items-table tbody tr:hover { background: var(--bg-2); }

.disc-input {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 3px;
  padding: 2px 5px;
}
.disc-input input {
  width: 30px;
  background: transparent;
  border: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.disc-input input::-webkit-outer-spin-button,
.disc-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.disc-input span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}

.cart-add-row {
  margin-top: 10px;
  padding: 10px 12px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.cart-add-row:hover {
  border-color: var(--text-3);
  color: var(--text-1);
  background: var(--bg-1);
}

/* ---- RIGHT: Totals panel ---- */
.cart-totals-panel {
  border-left: 1px solid var(--line);
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.ctp-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.ctp-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.ctp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 12.5px;
  color: var(--text-1);
}
.ctp-row.sub { color: var(--text-2); font-size: 11.5px; }
.ctp-row .mono { font-variant-numeric: tabular-nums; }
.ctp-row.grand {
  font-size: 15px;
  padding: 8px 0 4px;
  color: var(--text);
}
.ctp-row.grand .mono {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.ctp-row.margin .mono { color: var(--positive); font-weight: 500; }

.extra-disc {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.extra-disc input {
  width: 50px;
  background: transparent;
  border: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.extra-disc input::-webkit-outer-spin-button,
.extra-disc input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ctp-note {
  margin-top: 8px;
  padding: 6px 9px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.4;
}

.ctp-grand-wrap { border-bottom: none; }

.ctp-foot-note {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.45;
}

/* qty — унаследовано из старой cart-item, но поправим */
.qty {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  align-items: center;
  background: var(--bg);
}
.qty button {
  width: 22px;
  height: 24px;
  background: var(--bg-2);
  border: none;
  color: var(--text-1);
  cursor: pointer;
  font-size: 13px;
  display: grid;
  place-items: center;
}
.qty button:hover { background: var(--bg-3); color: var(--text); }
.qty input {
  width: 38px;
  height: 24px;
  background: transparent;
  border: none;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  -moz-appearance: textfield;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============ End B2B ============ */

/* ---- inline picker inside cart ---- */
.picker-inline {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  margin-bottom: 10px;
  overflow: hidden;
}
.picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.picker-rows {
  max-height: 260px;
  overflow-y: auto;
}
.pr-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}
.pr-row:last-child { border-bottom: none; }
.pr-row:hover { background: var(--bg-2); }
.pr-row.in { opacity: 0.55; cursor: default; }
.pr-row.in:hover { background: transparent; }

/* inline editable price in cart rows */
.inline-price-input {
  width: 86px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 3px 6px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.inline-price-input::-webkit-outer-spin-button,
.inline-price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inline-price-input:hover { background: var(--bg-2); }
.inline-price-input:focus {
  background: var(--bg);
  border-color: var(--accent);
}

/* ctp CTA block */
.ctp-cta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

/* arch-row hover (uses existing .clickable style) */
.arch-row.clickable { cursor: pointer; border-radius: 3px; padding: 2px 4px; margin: 0 -4px; }
.arch-row.clickable:hover { background: var(--bg-2); color: var(--text-1); }

/* ============ Misc ============ */

.spark { display: block; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* focus */
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ============ Tweaks panel ============ */
.tweaks-panel {
  position: fixed; bottom: 40px; right: 14px;
  width: 260px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.tweaks-panel.open { display: flex; }
.tp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2);
}
.tp-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 12px; }
.tp-row { display: grid; gap: 5px; }
.tp-row label {
  font-family: var(--font-mono); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3);
}
.tp-seg {
  display: flex; gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.tp-seg button {
  flex: 1; padding: 4px 6px;
  background: transparent; border: none;
  color: var(--text-2); cursor: pointer;
  font-size: 11px; border-radius: 3px;
}
.tp-seg button.on { background: var(--bg-3); color: var(--text); }

/* scroll ticker */
.ticker {
  display: inline-flex;
  gap: 20px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  align-items: center;
}
.ticker .t-item {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-2);
}
.ticker .t-item b { color: var(--text); font-weight: 500; }
.ticker .pos { color: var(--positive); }
.ticker .neg { color: var(--danger); }

/* ============ Role switcher ============ */
.role-switch {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  height: 26px; box-sizing: border-box;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-1);
  position: relative;
  user-select: none;
}
.role-switch:hover { background: var(--bg-2); border-color: var(--line-strong); }
.role-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.role-label { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.role-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 240px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.6);
  z-index: 200;
  overflow: hidden;
  cursor: default;
}
.role-menu-hd {
  padding: 8px 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-2); font-family: var(--font-mono); font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.role-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.role-menu-item:hover { background: var(--bg-2); }
.role-menu-item.on { background: var(--bg-2); }
.rm-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.rm-sub { font-size: 10.5px; color: var(--text-2); margin-top: 1px; }
.role-menu-hint {
  padding: 8px 12px; font-size: 10.5px; color: var(--text-3);
  background: var(--bg); border-top: 1px solid var(--line);
  font-style: italic;
}

/* ============ Status chips (topbar) ============ */
.status-chips { display: flex; gap: 4px; margin-right: 6px; flex-shrink: 0; flex-wrap: nowrap; min-width: 0; }
.status-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 6px;
  height: 24px; box-sizing: border-box;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all 0.1s;
  flex-shrink: 0;
}
.status-chip:hover { background: var(--bg-2); border-color: var(--line-strong); color: var(--text); }
.status-chip .sc-num { font-size: 11px; font-weight: 600; }
.status-chip.warn { color: var(--cat-b); border-color: oklch(0.62 0.03 260 / 0.5); }
.status-chip.err  { color: var(--danger); border-color: oklch(0.65 0.16 25 / 0.3); }
.status-chip.ok   { color: var(--positive); border-color: oklch(0.72 0.11 150 / 0.3); }
.status-chip.info { color: var(--accent); border-color: oklch(0.78 0.12 230 / 0.3); }

/* ============ Command palette ============ */
.palette-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.palette {
  width: 580px; max-width: 90vw;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7);
  overflow: hidden;
}
.palette-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
}
.palette-input-wrap input {
  flex: 1;
  background: transparent; border: none;
  color: var(--text); font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
}
.palette-list { max-height: 420px; overflow: auto; padding: 6px; }
.palette-empty { padding: 30px; text-align: center; color: var(--text-2); font-size: 12px; }
.palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: 5px;
  font-size: 13px;
}
.palette-item:hover { background: var(--bg-2); }
.palette-icon { color: var(--text-2); display: flex; }
.palette-label { flex: 1; color: var(--text); font-weight: 500; }
.palette-group {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em;
}
.palette-foot {
  display: flex; gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: 10.5px; color: var(--text-3);
  font-family: var(--font-mono);
}
.palette-foot kbd {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 5px;
  margin-right: 4px;
  font-size: 10px;
}

/* small buttons / inputs helper */
.btn.sm { padding: 3px 9px; font-size: 11px; }
.btn.primary {
  background: var(--accent);
  color: oklch(0.15 0.01 260);
  border: 1px solid var(--accent);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.1); }
.input.sm {
  padding: 4px 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-mono);
}
.input.sm:focus { outline: none; border-color: var(--accent); }

/* nav group title collapsible */
.nav-group-title {
  display: flex; align-items: center; gap: 4px;
  cursor: pointer;
  user-select: none;
}
.nav-group-title:hover { color: var(--text); }

/* make search-box a button */
button.search-box {
  background: var(--bg-1);
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: inherit;
}
button.search-box:hover { border-color: var(--line-strong); }

/* ============ Suppliers — platforms coverage ============ */
.supplier-logo.sm { width: 24px; height: 24px; font-size: 11px; border-radius: 3px; }

.coverage {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  margin-bottom: 18px;
  overflow: hidden;
}
.cov-hd {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.cov-t { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.cov-s { font-size: 11px; color: var(--text-2); }
.cov-legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 10.5px; color: var(--text-2); }
.cov-leg { display: inline-flex; align-items: center; gap: 5px; }

.pm-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 4px;
  background: var(--bg-2); border: 1px solid var(--line);
  font-family: var(--font-mono); font-weight: 600; font-size: 12px;
  color: var(--text-1); flex-shrink: 0;
}
.pm-letter.sm { width: 20px; height: 20px; font-size: 10px; border-radius: 3px; }
.pm-letter.own {
  background: color-mix(in oklab, var(--positive) 16%, var(--bg-2));
  border-color: color-mix(in oklab, var(--positive) 40%, var(--line));
  color: var(--positive);
}

.cov-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cov-table thead th {
  text-align: left; padding: 8px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3); font-family: var(--font-mono);
}
.cov-table tbody tr { border-bottom: 1px solid var(--line); }
.cov-table tbody tr:hover { background: var(--bg-2); }
.cov-table td { padding: 8px 10px; vertical-align: middle; }

.cov-cell {
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  font-family: var(--font-mono); font-size: 10px;
}
.cov-cell.on { color: var(--positive); }
.cov-cell.off { color: var(--text-3); font-size: 13px; }
.cov-check { display: inline-flex; width: 14px; height: 14px; color: var(--positive); }
.cov-check svg { width: 100%; height: 100%; }
.cov-mk { color: var(--text-2); font-size: 9.5px; }

/* Supplier card — platforms row */
.sc-platforms { margin-top: 10px; }
.sc-plat-l {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 5px;
}
.sc-plat-row { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.sc-plat {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  border: 1px solid var(--line);
}
.sc-plat.on { background: var(--bg-2); color: var(--text-1); }
.sc-plat.off { background: transparent; color: var(--text-3); opacity: 0.35; }
.sc-plat.on.own {
  background: color-mix(in oklab, var(--positive) 18%, var(--bg-2));
  border-color: color-mix(in oklab, var(--positive) 35%, var(--line));
  color: var(--positive);
}
.sc-plat-sum {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-3);
}

/* ============ Supplier detail ============ */
.supplier-kpis {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px;
}
.s-kpi { background: var(--bg-1); padding: 12px 14px; }
.s-kpi .k-l {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px;
}
.s-kpi .k-v { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--text); }
.s-kpi .k-sub { margin-top: 4px; font-size: 10.5px; color: var(--text-2); }

.sub-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.sub-tab {
  padding: 8px 16px; background: transparent; border: none;
  color: var(--text-2); cursor: pointer; font-size: 12px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* Platforms matrix (detail) */
.platforms-matrix {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-1); overflow: hidden;
}
.pm-intro {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 14px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.pm-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.pm-sub { font-size: 11px; color: var(--text-2); max-width: 560px; }
.pm-legend { display: flex; gap: 14px; font-size: 10.5px; color: var(--text-2); }
.pm-legend i {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 5px; vertical-align: middle;
}
.pm-legend .dot-ok { background: var(--positive); }
.pm-legend .dot-off { background: var(--text-3); opacity: 0.4; }
.pm-legend .dot-own { background: color-mix(in oklab, var(--positive) 70%, #fff); }

.pm-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pm-table thead th {
  text-align: left; padding: 8px 14px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3); font-family: var(--font-mono);
}
.pm-table tbody tr { border-bottom: 1px solid var(--line); }
.pm-table tbody tr:last-child { border-bottom: 0; }
.pm-table tbody tr.pm-off { opacity: 0.55; }
.pm-table td { padding: 10px 14px; vertical-align: middle; }
.pm-table.sm td { padding: 5px 8px; font-size: 11px; }

.pm-pl { display: flex; gap: 10px; align-items: center; min-width: 0; }
.pm-name { font-weight: 600; font-size: 12px; color: var(--text); }
.pm-note { font-size: 10.5px; color: var(--text-2); }

.pm-kind {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.05em; border: 1px solid var(--line); color: var(--text-2);
}
.pm-kind-own {
  background: color-mix(in oklab, var(--positive) 12%, var(--bg-2));
  color: var(--positive); border-color: color-mix(in oklab, var(--positive) 30%, var(--line));
}
.pm-kind-shop { background: var(--bg-2); color: var(--text-1); }
.pm-kind-mp { background: var(--bg-2); color: var(--text-2); }
.pm-kind-b2b { background: var(--bg-2); color: var(--text-1); }

.pm-toggle {
  width: 34px; height: 18px; border-radius: 9px;
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 0; cursor: pointer; position: relative; display: inline-flex;
}
.pm-toggle-dot {
  position: absolute; top: 1px; left: 1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-3); transition: all .15s;
}
.pm-toggle.on { background: color-mix(in oklab, var(--positive) 40%, var(--bg-3)); border-color: var(--positive); }
.pm-toggle.on .pm-toggle-dot { left: 17px; background: var(--positive); }

.pm-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--bg); border-top: 1px solid var(--line);
}

/* AR detail */
.ar-detail { display: flex; flex-direction: column; }
.ar-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ar-card {
  padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--bg-1);
}
.ar-card-l {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.ar-card-v { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--text); }
.ar-card-s { margin-top: 6px; font-size: 11px; color: var(--text-2); }
.ar-gauge {
  margin-top: 10px; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.ar-gauge-t { height: 100%; border-radius: 2px; transition: width .2s; }

.ar-op {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.05em; margin-right: 6px;
}
.ar-op-inv { background: color-mix(in oklab, var(--danger) 18%, var(--bg-2)); color: var(--danger); }
.ar-op-pay { background: color-mix(in oklab, var(--positive) 18%, var(--bg-2)); color: var(--positive); }
.ar-op-adj { background: var(--bg-3); color: var(--text-2); }

/* Profile grid */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.p-card {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-1); padding: 14px 16px;
}
.p-card-t {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); font-family: var(--font-mono);
  padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px;
}
.p-field {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 12px;
  border-bottom: 1px solid color-mix(in oklab, var(--line) 50%, transparent);
}
.p-field:last-child { border-bottom: 0; }
.p-field span { color: var(--text-2); }
.p-field b { color: var(--text); font-weight: 500; }
.p-foot { margin-top: 10px; font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); }

/* ============ Receiving / Batches ============ */
.receive-summary {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px;
}
.rs-step {
  background: var(--bg-1); padding: 12px 14px; border: 0; text-align: left;
  cursor: pointer; color: var(--text); font-family: inherit;
  transition: background .1s;
}
.rs-step:hover { background: var(--bg-2); }
.rs-step.active {
  background: color-mix(in oklab, var(--accent) 10%, var(--bg-1));
  box-shadow: inset 0 -2px 0 var(--accent);
}
.rs-step-t { display: flex; gap: 10px; align-items: baseline; }
.rs-num { font-size: 22px; font-weight: 600; color: var(--text); }
.rs-l { font-size: 12px; color: var(--text-1); font-weight: 500; }
.rs-hint { margin-top: 4px; font-size: 10.5px; color: var(--text-2); line-height: 1.35; }

.batches-list { display: flex; flex-direction: column; gap: 12px; }

.batch {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-1); overflow: hidden;
}
.batch-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.batch-id { font-size: 13px; font-weight: 600; color: var(--text); }
.batch-po { font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.batch-sup { font-size: 12px; color: var(--text-1); }

.batch-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 3px;
  border: 1px solid currentColor;
  background: color-mix(in oklab, currentColor 10%, transparent);
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em;
}
.batch-status i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* Rail */
.batch-rail {
  display: flex; align-items: center; gap: 0;
  padding: 12px 14px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.batch-rail-line {
  flex: 1; height: 1px; background: var(--line); margin: 0 6px;
  position: relative; top: 9px;
}
.batch-rail-line.done { background: var(--text-1); }
.batch-rail-node {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 70px;
}
.brn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line);
}
.batch-rail-node.done .brn-dot { background: var(--text-1); border-color: var(--text-1); }
.batch-rail-node.current .brn-dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent);
}
.brn-l {
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.batch-rail-node.done .brn-l { color: var(--text-2); }
.batch-rail-node.current .brn-l { color: var(--text); font-weight: 600; }

.batch-body { padding: 12px 14px; }
.batch-meta {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.batch-meta > div span {
  display: block; font-family: var(--font-mono); font-size: 9.5px;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.batch-meta > div b { font-size: 12px; color: var(--text); font-weight: 500; }

.batch-progress { margin-bottom: 12px; }
.batch-progress-l {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-2); margin-bottom: 4px;
}
.batch-progress-bar {
  height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.batch-progress-bar > div { height: 100%; border-radius: 2px; }

.batch-lines { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.batch-lines thead th {
  text-align: left; padding: 5px 8px; background: var(--bg-2);
  font-weight: 500; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-3); font-family: var(--font-mono);
  border-bottom: 1px solid var(--line);
}
.batch-lines tbody td {
  padding: 5px 8px; border-bottom: 1px solid color-mix(in oklab, var(--line) 50%, transparent);
}
.batch-lines tbody tr:last-child td { border-bottom: 0; }

.batch-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg); border-top: 1px solid var(--line);
}

.spacer-sm { width: 8px; display: inline-block; }
.btn.ghost { background: transparent; border: 1px dashed var(--line); color: var(--text-2); }

@media (max-width: 1320px) {
  .supplier-kpis { grid-template-columns: repeat(3, 1fr); }
  .receive-summary { grid-template-columns: repeat(3, 1fr); }
  .profile-grid { grid-template-columns: 1fr; }
  .batch-meta { grid-template-columns: repeat(2, 1fr); }
  .ar-cards { grid-template-columns: 1fr; }
}

/* Skeleton shimmer animation */
@keyframes ds2-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton-bar {
  display: block;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 400px 10px;
  animation: ds2-shimmer 1.2s infinite ease-in-out;
}
tr.is-skeleton td { padding: 10px 12px; }
tr.is-skeleton td:nth-child(1) .skeleton-bar { width: 18px; }
tr.is-skeleton td:nth-child(2) .skeleton-bar { width: 22px; }
tr.is-skeleton td:nth-child(3) .skeleton-bar { width: 80px; }
tr.is-skeleton td:nth-child(4) .skeleton-bar { width: 160px; }
tr.is-skeleton td:nth-child(5) .skeleton-bar { width: 100px; }
tr.is-skeleton td:nth-child(6) .skeleton-bar { width: 70px; }
tr.is-skeleton td:nth-child(7) .skeleton-bar { width: 50px; }
tr.is-skeleton td:nth-child(8) .skeleton-bar { width: 60px; }

/* Page warn chip */
.page-warn {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  padding: 2px 7px; border-radius: 10px;
  background: oklch(from var(--cat-b) l c h / 0.15);
  color: var(--cat-b);
  margin-left: 8px; vertical-align: 3px;
}
.page-warn::before { content: '●'; font-size: 6px; }

/* Data quality signals */
.price-missing { color: var(--cat-b); font-variant-numeric: tabular-nums; cursor: help; }
.muted { color: var(--text-3); cursor: help; }
.kpi-value.warn { color: var(--cat-b); }

/* Filter chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 12px; font-size: 11.5px; cursor: pointer; background: var(--bg-1); }
.chip:hover { border-color: var(--line-strong); background: var(--bg-2); }

/* Health score */
.health-score { display: flex; flex-direction: column; gap: 4px; min-width: 80px; }
.health-num { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text); }
.health-max { color: var(--text-3); font-size: 11px; }
.health-bar { height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.health-fill { height: 100%; border-radius: 2px; }
.health-fill.ok { background: var(--positive); }
.health-fill.warn { background: var(--cat-b); }
.health-fill.err { background: var(--danger); }

/* Sync cell */
.sync-cell { display: flex; align-items: center; gap: 8px; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.sync-dot.ok { background: var(--positive); }
.sync-dot.error { background: var(--danger); }
.sync-dot.running { background: var(--cat-b); animation: pulse 1s infinite; }
.sync-err { font-size: 11px; color: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Row actions menu */
.row-actions-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg-1);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
}
.row-actions-btn:hover { color: var(--text); border-color: var(--line-strong); }
.row-actions-menu {
  min-width: 220px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 4px 0;
  z-index: 20;
}
.row-actions-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-1);
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
}
.row-actions-menu button:hover { background: var(--bg-2); }
.row-actions-menu button.danger { color: var(--danger); }
.row-actions-menu .divider { height: 1px; background: var(--line); margin: 4px 0; }

/* Dark theme overrides */
[data-theme="dark"] .price-missing { color: oklch(0.75 0.14 70); }
[data-theme="dark"] .chip { background: var(--bg-2); border-color: var(--line); }
[data-theme="dark"] .chip:hover { background: var(--bg-3); }
[data-theme="dark"] .page-warn { background: oklch(0.65 0.16 70 / 0.2); color: oklch(0.82 0.14 70); }
[data-theme="dark"] .skeleton-bar { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); }
[data-theme="dark"] .health-bar { background: var(--bg-3); }
[data-theme="dark"] .status-pill { background: var(--bg-2); border-color: var(--line); }
