/* ==========================================================================
   ShelfPilot seller console: styles
   Layout: a fixed instrument rail (navigation) beside a scrolling work surface.
   An autopilot strip sits on top of every page and shows what each agent is
   doing, the way a cockpit mode annunciator shows the engaged autopilot modes.
   Colour rule: magenta always means "the AI commanded this" (like the magenta
   flight-director line); green = engaged/healthy, cyan = armed/info,
   amber = needs you, red = loss or risk.
   ========================================================================== */

:root {
  /* Colour: cool grey work surface, ink text, magenta for AI-commanded values */
  --bg: #ECEFF1;
  --surface: #FFFFFF;
  --surface-2: #F5F7F8;
  --surface-3: #E5EAED;
  --ink: #0D1820;
  --ink-2: #2D3B46;
  --muted: #566571;
  --faint: #85929C;
  --line: #D3DADF;
  --line-soft: #E4E9EC;

  --ai: #A3168A;
  --ai-soft: #F7E5F3;
  --good: #11703A;
  --good-soft: #DDF1E4;
  --warn: #935000;
  --warn-soft: #FAEBD5;
  --bad: #B0261E;
  --bad-soft: #FBE3E0;
  --info: #0A6782;
  --info-soft: #DCEEF4;
  --on-color: #FFFFFF;

  --primary: #0D1820;
  --on-primary: #FFFFFF;
  --focus: #0A6782;
  --scrim: rgba(8, 15, 21, 0.45);
  --shadow: 0 1px 2px rgba(13, 24, 32, 0.06), 0 10px 30px rgba(13, 24, 32, 0.14);
  --thumb: #FFFFFF;

  /* Instrument display: dark in both themes, like a cockpit screen */
  --instr-bg: #071017;
  --instr-btn: #0F1C25;
  --instr-edge: #1C2B35;
  --instr-fg: #D3E2EB;
  --instr-dim: #6E8796;
  --instr-off: #23323C;
  --instr-green: #3DE07C;
  --instr-cyan: #46D7F2;
  --instr-magenta: #FF6AEB;
  --instr-amber: #FFB52E;

  /* Chart series: validated categorical slots (colour-blind safe on this surface).
     Each cost type keeps its slot everywhere: 1 product cost, 2 referral fee, 3 FBA fee,
     4 ads, 5 storage/returns/other, 6 net profit. --c-ai is "your price / AI command". */
  --c1: #2A78D6;
  --c2: #EB6834;
  --c3: #1BAF7A;
  --c4: #EDA100;
  --c5: #E87BA4;
  --c6: #008300;
  --c-ai: #A3168A;
  --c-muted: #98A3AC;
  --s-good: #0CA30C;
  --s-warn: #D99A12;
  --s-crit: #D03B3B;

  /* Type: one variable grotesque at three widths, plus a cockpit-display mono */
  --font-ui: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "B612 Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --wide: 116%;
  --narrow: 90%;
  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 12.75px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 21px;
  --fs-2xl: 27px;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 9px;
  --rail-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0F13;
    --surface: #10181F;
    --surface-2: #151F28;
    --surface-3: #1D2933;
    --ink: #E3EAEF;
    --ink-2: #C2CDD5;
    --muted: #8E9BA6;
    --faint: #66737E;
    --line: #25333D;
    --line-soft: #1B2730;
    --ai: #F27AD9;
    --ai-soft: #3A1635;
    --good: #4BD283;
    --good-soft: #0F2E1D;
    --warn: #F3B64C;
    --warn-soft: #362710;
    --bad: #FF8073;
    --bad-soft: #3B1714;
    --info: #57C9E6;
    --info-soft: #0D2B35;
    --on-color: #0A0F13;
    --primary: #E3EAEF;
    --on-primary: #0A0F13;
    --focus: #57C9E6;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.55);
    --instr-edge: #24363F;
    --c1: #3987E5;
    --c2: #D95926;
    --c3: #199E70;
    --c4: #C98500;
    --c5: #D55181;
    --c6: #008300;
    --c-ai: #C94DB5;
    --c-muted: #5D6C77;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0A0F13;
  --surface: #10181F;
  --surface-2: #151F28;
  --surface-3: #1D2933;
  --ink: #E3EAEF;
  --ink-2: #C2CDD5;
  --muted: #8E9BA6;
  --faint: #66737E;
  --line: #25333D;
  --line-soft: #1B2730;
  --ai: #F27AD9;
  --ai-soft: #3A1635;
  --good: #4BD283;
  --good-soft: #0F2E1D;
  --warn: #F3B64C;
  --warn-soft: #362710;
  --bad: #FF8073;
  --bad-soft: #3B1714;
  --info: #57C9E6;
  --info-soft: #0D2B35;
  --on-color: #0A0F13;
  --primary: #E3EAEF;
  --on-primary: #0A0F13;
  --focus: #57C9E6;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.55);
  --instr-edge: #24363F;
  --c1: #3987E5;
  --c2: #D95926;
  --c3: #199E70;
  --c4: #C98500;
  --c5: #D55181;
  --c6: #008300;
  --c-ai: #C94DB5;
  --c-muted: #5D6C77;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; }
a { color: var(--info); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--ai-soft); }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.t-ai { color: var(--ai); }
.t-good { color: var(--good); }
.t-warn { color: var(--warn); }
.t-bad { color: var(--bad); }
.t-info { color: var(--info); }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ico { flex: none; display: block; }

.label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  font-stretch: var(--narrow);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name {
  font-size: 17px;
  font-weight: 800;
  font-stretch: 118%;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.brand-sub { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; font-stretch: 100%; letter-spacing: 0; }

.nav { display: grid; gap: 1px; padding: 0 8px; }
.nav-group { padding: 12px 10px 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
}
.nav a .ico { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-3); color: var(--ink); font-weight: 650; }
.nav a[aria-current="page"] .ico { color: var(--ink); }
.nav .badge { margin-left: auto; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--warn);
  color: var(--on-color);
  font-size: var(--fs-2xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.badge.ai { background: var(--ai); }

.rail-foot { margin-top: auto; padding: 12px; display: grid; gap: 10px; }
.health {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  background: var(--surface-2);
}
.health-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.health-score { font-size: 20px; font-weight: 750; font-stretch: 112%; font-variant-numeric: tabular-nums; }
.health dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: var(--fs-xs); }
.health dt { color: var(--muted); }
.health dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.demo-note { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; padding: 0 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-inline: 24px;
  padding-block: 10px;
  display: grid;
  gap: 10px;
}
.topbar-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { min-width: 0; flex: 1; }
.page-title h1 {
  font-size: var(--fs-xl);
  font-weight: 750;
  font-stretch: var(--wide);
  letter-spacing: -0.01em;
}
.page-title p { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.topbar-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.menu-btn { display: none; }

.page {
  width: 100%;
  max-width: 1500px;
  padding-inline: 24px;
  padding-block: 20px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-content: start;
}
.page:focus { outline: none; }

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 45;
}

/* ---------- Autopilot strip (mode control + annunciator) ---------- */
.fcu {
  display: flex;
  align-items: stretch;
  background: var(--instr-bg);
  border: 1px solid var(--instr-edge);
  border-radius: var(--r-md);
  color: var(--instr-fg);
  font-family: var(--font-mono);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--instr-off) transparent;
  min-width: 0;
}
.fcu-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-right: 1px solid var(--instr-edge);
  flex: none;
}
.fcu-tag { font-size: 9.5px; letter-spacing: 0.12em; color: var(--instr-dim); writing-mode: horizontal-tb; margin-right: 2px; }
.fcu-btn {
  position: relative;
  appearance: none;
  border: 1px solid var(--instr-edge);
  background: var(--instr-btn);
  color: var(--instr-dim);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 8px 10px 5px;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
}
.fcu-btn::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 50%;
  width: 16px;
  height: 2px;
  margin-left: -8px;
  border-radius: 1px;
  background: var(--instr-off);
}
.fcu-btn:hover { color: var(--instr-fg); }
.fcu-btn[aria-pressed="true"] { color: var(--instr-fg); }
.fcu-btn[aria-pressed="true"]::before { background: var(--instr-green); box-shadow: 0 0 6px var(--instr-green); }
.fcu-btn[data-mode="off"][aria-pressed="true"]::before { background: var(--instr-amber); box-shadow: 0 0 6px var(--instr-amber); }
.fcu-btn[data-mode="assist"][aria-pressed="true"]::before { background: var(--instr-cyan); box-shadow: 0 0 6px var(--instr-cyan); }
.fcu-btn:focus-visible { outline: 2px solid var(--instr-cyan); outline-offset: 1px; }

.fma { display: flex; flex: 1 0 auto; }
.fma-cell {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 4px 12px;
  min-width: 92px;
  border-right: 1px solid var(--instr-edge);
  text-align: center;
  flex: 1 0 auto;
}
.fma-cell:last-child { border-right: 0; }
.fma-k { font-size: 9.5px; letter-spacing: 0.12em; color: var(--instr-dim); }
.fma-v { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; padding: 1px 4px; border: 1.5px solid transparent; border-radius: 2px; white-space: nowrap; }
.fma-v.g { color: var(--instr-green); }
.fma-v.c { color: var(--instr-cyan); }
.fma-v.m { color: var(--instr-magenta); }
.fma-v.a { color: var(--instr-amber); }
.fma-v.w { color: var(--instr-fg); }
/* A new mode is boxed for 10 seconds, as on a real flight mode annunciator */
.fma-v.boxed { border-color: var(--instr-fg); }
.fcu-feed { gap: 8px; font-size: 11px; color: var(--instr-dim); }
.fcu-feed b { color: var(--instr-fg); font-weight: 700; font-variant-numeric: tabular-nums; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--instr-green); box-shadow: 0 0 6px var(--instr-green); animation: blink 1.6s infinite; }
.pulse-dot.paused { background: var(--instr-amber); box-shadow: none; animation: none; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- Generic building blocks ---------- */
.grid { display: grid; gap: 16px; min-width: 0; }
.split { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.top { align-items: start; }
.grid > .callout { align-self: start; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }
.vstack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }

.lede {
  max-width: 80ch;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
}
.lede b { color: var(--ink); }

.brief {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.brief .lede { flex: 1 1 420px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-h h2,
.panel-h h3 { font-size: 14.5px; font-weight: 700; font-stretch: 108%; }
.panel-h .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 1px; }
.panel-h > div:first-child { min-width: 0; }
.panel-h .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.panel-b { padding: 16px; min-width: 0; }
.panel-b.flush { padding: 0; }
.panel-b.tight { padding: 12px 16px; }
.panel-f {
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: var(--fs-sm);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--info-soft);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.callout .ico { color: var(--info); margin-top: 1px; }
.callout.warn { background: var(--warn-soft); }
.callout.warn .ico { color: var(--warn); }
.callout.ai { background: var(--ai-soft); }
.callout.ai .ico { color: var(--ai); }
.callout.bad { background: var(--bad-soft); }
.callout.bad .ico { color: var(--bad); }
.callout b { color: var(--ink); }
.callout.has-actions { flex-wrap: wrap; align-items: center; }
.callout.has-actions > .txt { flex: 1 1 260px; min-width: 0; }

/* ---------- Buttons & controls ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ai { background: var(--ai); border-color: var(--ai); color: var(--on-color); }
.btn-ai:hover { background: var(--ai); border-color: var(--ai); filter: brightness(1.08); }
.btn-good { background: var(--good); border-color: var(--good); color: var(--on-color); }
.btn-good:hover { background: var(--good); border-color: var(--good); filter: brightness(1.08); }
.btn-bad { color: var(--bad); }
.btn-bad:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-icon { width: 32px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.btn-lg { min-height: 40px; padding: 0 16px; font-size: var(--fs-md); }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  max-width: 100%;
  overflow-x: auto;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.field { display: grid; gap: 5px; min-width: 0; }
.field > label,
.field > .label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); letter-spacing: 0; text-transform: none; font-stretch: 100%; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.input,
.select,
.textarea {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-md);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.textarea { padding: 8px 10px; resize: vertical; line-height: 1.45; min-height: 88px; }
.select { padding-right: 28px; }
.affix { position: relative; display: block; }
.affix > span {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: var(--fs-sm);
  pointer-events: none;
}
.affix.pre > span { left: 10px; }
.affix.pre .input { padding-left: 22px; }
.affix.post > span { right: 10px; }
.affix.post .input { padding-right: 28px; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--ai); }

.switch { position: relative; display: inline-flex; flex: none; width: 36px; height: 20px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background-color 0.15s, border-color 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--good); border-color: var(--good); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .t { font-weight: 600; font-size: var(--fs-sm); }
.toggle-row .d { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.2;
  background: var(--surface-3);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip { justify-self: start; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.ai { background: var(--ai-soft); color: var(--ai); }
.chip.code {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
  min-height: 20px;
  padding: 0 6px;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chips .chip { white-space: normal; max-width: 100%; }
.tag-stack { display: grid; gap: 4px; justify-items: start; }
.tag-stack .chip { white-space: nowrap; }
button.chip { border: 0; cursor: pointer; font-family: inherit; text-align: left; padding-block: 3px; }
button.chip:hover { background: var(--line); color: var(--ink); }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}
/* Two lines are reserved for every label so the values line up across the row */
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; min-height: 34px; }
.kpi-top .label { min-width: 0; padding-top: 2px; }
.kpi-v {
  font-size: var(--fs-2xl);
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.05;
  white-space: nowrap;
}
.kpi-d { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi .spark { flex: none; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.kpi.flash .kpi-v { animation: kpiFlash 0.9s ease-out; }
@keyframes kpiFlash { 0% { color: var(--ai); } 100% { color: var(--ink); } }

/* ---------- Tables ---------- */
/* position: relative keeps visually-hidden header labels inside the scroll box */
.table-wrap { position: relative; overflow-x: auto; min-width: 0; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th {
  text-align: left;
  font-size: var(--fs-2xs);
  font-weight: 600;
  font-stretch: var(--narrow);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl tr.row-click { cursor: pointer; }
.tbl tr.row-click:hover td { background: var(--surface-2); }
.tbl tr.sel td { background: var(--info-soft); }
.tbl tr.new td { animation: rowIn 1.4s ease-out; }
@keyframes rowIn { from { background: var(--ai-soft); } to { background: transparent; } }
.tbl .prod { display: grid; gap: 2px; min-width: 200px; }
.tbl .prod b { font-weight: 600; color: var(--ink); }
.tbl .prod small { color: var(--muted); font-size: var(--fs-xs); }
.tbl .actions { text-align: right; white-space: nowrap; }

/* ---------- Event tape (live feed) ---------- */
.tape { list-style: none; max-height: 560px; overflow-y: auto; }
.tape-fill { flex: 1 1 auto; position: relative; min-height: 520px; }
.tape-fill .tape { position: absolute; inset: 0; max-height: none; }
.appr-list { max-height: 720px; overflow-y: auto; }
.ev {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.ev:last-child { border-bottom: 0; }
.ev time { font-size: var(--fs-xs); color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; }
.ev > .chip { align-self: start; }
.ev-main { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ev-what { font-weight: 600; font-size: var(--fs-sm); }
.ev-act {
  grid-column: 2 / 4;
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.ev-act .ico { color: var(--ai); align-self: flex-start; margin-top: 2px; }
.ev-act b { font-weight: 650; color: var(--ai); white-space: nowrap; }
.ev.new { animation: evIn 1.6s ease-out; }
@keyframes evIn { from { background: var(--ai-soft); } to { background: transparent; } }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Approvals ---------- */
.appr-list { list-style: none; }
.appr { display: grid; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.appr:last-child { border-bottom: 0; }
.appr-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.appr-amt { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.appr-title { font-weight: 600; font-size: var(--fs-sm); }
.appr-why { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.appr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- Agents ---------- */
.agents { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.agent {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  display: grid;
  gap: 8px;
  align-content: start;
  background: var(--surface);
  min-width: 0;
}
.agent-h { display: flex; align-items: center; gap: 10px; }
.agent-ico {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink-2);
  flex: none;
}
.agent-name { font-weight: 650; font-size: var(--fs-sm); }
.agent-role { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.agent-last {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  line-height: 1.4;
}
.agent-last .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.agent-stat { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-xs); color: var(--muted); }
.agent-stat b { color: var(--ink); font-variant-numeric: tabular-nums; }
.agent.busy .agent-ico { color: var(--ai); border-color: var(--ai); }

/* ---------- Charts ---------- */
.chart-box { width: 100%; min-width: 0; position: relative; }
.chart { display: block; overflow: visible; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; fill: none; }
.chart .axis-line { stroke: var(--line); stroke-width: 1; fill: none; }
.chart text { fill: var(--muted); font-family: var(--font-ui); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.strong { fill: var(--ink); font-weight: 600; }
.chart text.ai { fill: var(--ai); font-weight: 600; }
.chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.chart .xhair { stroke: var(--ink-2); stroke-width: 1; }
.chart .col-hover { fill: var(--surface-3); opacity: 0.6; }
.chart .bar.on { filter: brightness(1.12) saturate(1.05); }
.chart-tip {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  display: grid;
  gap: 4px;
  min-width: 150px;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
}
.chart-tip .tip-h { color: var(--muted); font-weight: 600; margin-bottom: 1px; }
.chart-tip .tip-row { display: grid; grid-template-columns: 14px auto minmax(0, 1fr); align-items: center; gap: 7px; }
.chart-tip .tip-row i { display: block; width: 14px; height: 2px; border-radius: 1px; }
.chart-tip .tip-row i.dash { height: 0; border-top: 2px dashed; background: none; }
.chart-tip .tip-row b { font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-tip .tip-row span { color: var(--muted); }
.chart-data { margin-top: 10px; font-size: var(--fs-sm); }
.chart-data summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; width: max-content; }
.chart-data summary:hover { color: var(--ink); }
.chart-data .table-wrap { margin-top: 8px; max-height: 260px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.spark { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { height: 0; border-top: 2px dashed; background: none !important; }
.legend i.box { width: 10px; height: 10px; border-radius: 2px; }

.stackbar { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: var(--surface); gap: 2px; }
.stackbar span { display: block; min-width: 2px; }
.stack-legend { list-style: none; display: grid; gap: 6px; margin-top: 12px; font-size: var(--fs-sm); }
.stack-legend li { display: flex; align-items: center; gap: 8px; }
.stack-legend i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.stack-legend b { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.stack-legend .pct { color: var(--muted); font-variant-numeric: tabular-nums; width: 48px; text-align: right; }

.ring { display: block; flex: none; }
.ring text { fill: var(--ink); font-family: var(--font-ui); font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }

.meter { display: grid; gap: 4px; }
.meter-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 40px; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.meter-row .num { text-align: right; }
.meter-bar { height: 8px; border-radius: 4px; background: color-mix(in oklab, var(--c1) 16%, var(--surface)); overflow: hidden; }
.meter-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--c1); }

.heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.heat div {
  height: 40px;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.heat-axis { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10px; color: var(--muted); margin-top: 4px; }
.heat-axis span { text-align: center; }

/* ---------- Stat row (label/value pairs) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 2px; min-width: 0; }
.stat-v { font-size: 18px; font-weight: 700; font-stretch: 108%; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-s { font-size: var(--fs-xs); color: var(--muted); }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.kv .total { border-top: 1px solid var(--line); padding-top: 6px; color: var(--ink); font-weight: 700; }

/* ---------- Drawer ---------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(580px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(105%);
  transition: transform 0.22s ease;
  visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-h { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font-size: var(--fs-lg); font-weight: 750; font-stretch: 108%; }
.drawer-h .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.drawer-b { overflow-y: auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.drawer-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.drawer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
.section-t { font-size: var(--fs-sm); font-weight: 700; margin-bottom: 8px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  line-height: 1.4;
  animation: toastIn 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast .ico { margin-top: 1px; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Product finder ---------- */
.ask { display: flex; gap: 8px; flex-wrap: wrap; }
.ask .input { flex: 1 1 320px; min-height: 40px; font-size: 15px; }
.ask .btn { min-height: 40px; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; align-items: end; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* ---------- Sourcing ---------- */
.ai-pick td { background: var(--ai-soft); }
.supplier { display: grid; gap: 2px; min-width: 190px; }
.supplier b { font-weight: 600; }
.supplier small { color: var(--muted); font-size: var(--fs-xs); }
.calc { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.calc-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line-soft); background: var(--surface-2); }
.calc-out .stat-v.big { font-size: 24px; }

.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.lane { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 10px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.lane-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.lane-h span:first-child { font-weight: 650; font-size: var(--fs-sm); }
.po {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px;
  display: grid;
  gap: 4px;
  font-size: var(--fs-sm);
}
.po-id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.po b { font-weight: 650; }
.po .meta { color: var(--muted); font-size: var(--fs-xs); }
.po .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.po.new { animation: rowIn 1.4s ease-out; }

.draft {
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  min-height: 120px;
  color: var(--ink-2);
}
.caret::after { content: "\258D"; color: var(--ai); animation: blink 1s infinite; margin-left: 1px; }

/* ---------- Listing studio ---------- */
.out-block { display: grid; gap: 6px; }
.out-block + .out-block { margin-top: 14px; }
.out-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.out-text { font-size: var(--fs-md); line-height: 1.5; color: var(--ink); min-height: 1.5em; overflow-wrap: anywhere; }
.out-text.title { font-weight: 650; font-size: 15px; }
.out-list { padding-left: 18px; display: grid; gap: 6px; font-size: var(--fs-sm); line-height: 1.5; }
.out-terms { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; overflow-wrap: anywhere; }
.checks { list-style: none; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: start; font-size: var(--fs-sm); }
.checks li .ico { margin-top: 1px; }
.checks li.pass .ico { color: var(--good); }
.checks li.fail .ico { color: var(--bad); }
.checks li .why { display: block; color: var(--muted); font-size: var(--fs-xs); }
.checks li .num { color: var(--muted); font-size: var(--fs-xs); }
.score-head { display: flex; align-items: center; gap: 12px; }

/* ---------- Repricer ---------- */
.sku-tabs { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 2px; }
.sku-tab {
  appearance: none;
  display: grid;
  gap: 2px;
  text-align: left;
  min-width: 128px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  flex: none;
}
.sku-tab:hover { border-color: var(--faint); }
.sku-tab[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sku-tab .n { font-weight: 600; font-size: var(--fs-sm); }
.sku-tab .p { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: 6px; align-items: center; }
.bb-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; height: 12px; margin-top: 6px; border-radius: 2px; overflow: hidden; }
.bb-strip span { display: block; background: var(--surface-3); }
.bb-strip span.me { background: var(--s-good); }
.strategy { display: grid; gap: 8px; }
.strategy label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
}
.strategy label:hover { border-color: var(--faint); }
.strategy input { margin: 2px 0 0; accent-color: var(--ai); }
.strategy label:has(input:checked) { border-color: var(--ai); background: var(--ai-soft); }
.strategy .t { font-weight: 600; font-size: var(--fs-sm); }
.strategy .d { color: var(--muted); font-size: var(--fs-xs); }
.log { list-style: none; max-height: 360px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 2px 10px; padding: 8px 16px; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-sm); }
.log li:last-child { border-bottom: 0; }
.log time { font-size: var(--fs-xs); color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums; }
.log .why { grid-column: 2; color: var(--muted); font-size: var(--fs-xs); }
.log li.new { animation: evIn 1.6s ease-out; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); min-height: 420px; }
.inbox-list { list-style: none; border-right: 1px solid var(--line-soft); overflow-y: auto; max-height: 560px; }
.inbox-list button {
  appearance: none;
  width: 100%;
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  cursor: pointer;
}
.inbox-list button:hover { background: var(--surface-2); }
.inbox-list button[aria-pressed="true"] { background: var(--info-soft); }
.inbox-list .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.inbox-list .who { font-weight: 650; font-size: var(--fs-sm); }
.inbox-list .snip { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.inbox-list .unread .who::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--info); margin-right: 6px; vertical-align: 1px; }
.thread { padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.bubble { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 10px 12px; font-size: var(--fs-sm); line-height: 1.5; }
.bubble.me { background: var(--ai-soft); border-color: transparent; }
.thread .textarea { min-height: 150px; }

.stars { display: grid; gap: 6px; }
.star-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 40px; gap: 8px; align-items: center; font-size: var(--fs-sm); }

.themes { display: grid; gap: 8px; list-style: none; }
.themes li { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: var(--fs-sm); padding-bottom: 8px; border-bottom: 1px dashed var(--line-soft); }
.themes li:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------- Automations ---------- */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode-card {
  appearance: none;
  text-align: left;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  cursor: pointer;
  align-content: start;
}
.mode-card:hover { border-color: var(--faint); }
.mode-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mode-card .t { font-weight: 700; font-size: var(--fs-lg); font-stretch: 108%; display: flex; align-items: center; gap: 8px; }
.mode-card .d { color: var(--muted); font-size: var(--fs-sm); line-height: 1.45; }
.rules { display: grid; gap: 12px; }
.rule {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.rule.off { opacity: 0.62; }
.rule-h { display: flex; align-items: center; gap: 10px; }
.rule-h .t { font-weight: 650; flex: 1; min-width: 0; }
.wit { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px 10px; font-size: var(--fs-sm); }
.wit dt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; color: var(--muted); padding-top: 2px; }
.wit dd { margin: 0; color: var(--ink-2); }
.wit dd.then { color: var(--ai); font-weight: 600; }
.rule-f { display: flex; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.kill { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--bad); border-radius: var(--r-lg); background: var(--bad-soft); }
.kill .t { font-weight: 700; color: var(--ink); }
.kill .d { color: var(--ink-2); font-size: var(--fs-sm); }

/* ---------- How it works ---------- */
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px; position: relative; }
.flow-col { display: grid; gap: 8px; align-content: start; position: relative; min-width: 0; }
.flow-col + .flow-col::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 34px;
  width: 16px;
  height: 16px;
  border-top: 2px solid var(--ai);
  border-right: 2px solid var(--ai);
  transform: rotate(45deg);
}
.flow-step { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; color: var(--ai); }
.flow-title { font-weight: 750; font-stretch: 110%; font-size: var(--fs-lg); }
.flow-box { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; background: var(--surface-2); font-size: var(--fs-sm); display: grid; gap: 2px; }
.flow-box b { font-weight: 650; }
.flow-box small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.flow-box.hot { border-color: var(--ai); background: var(--ai-soft); }

.timeline { list-style: none; display: grid; gap: 0; position: relative; }
.timeline li {
  display: grid;
  grid-template-columns: 74px 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding-bottom: 14px;
  position: relative;
  opacity: 0.45;
  transition: opacity 0.3s;
}
.timeline li.lit { opacity: 1; }
.timeline .tt { font-size: var(--fs-xs); color: var(--muted); text-align: right; padding-top: 1px; font-variant-numeric: tabular-nums; }
.timeline .pin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--faint); background: var(--surface); margin-top: 3px; position: relative; z-index: 1; }
.timeline li.lit .pin { border-color: var(--ai); background: var(--ai); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 89px; top: 15px; bottom: 0; width: 2px; background: var(--line); }
.timeline .tx b { display: block; font-size: var(--fs-sm); }
.timeline .tx span { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; display: block; }

.two-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.plain-list { list-style: none; display: grid; gap: 8px; font-size: var(--fs-sm); }
.plain-list li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; line-height: 1.45; }
.plain-list li .ico { margin-top: 1px; }
.steps { list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; font-size: var(--fs-sm); line-height: 1.5; }
.steps li::before {
  content: counter(step);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 700;
}
.steps b { color: var(--ink); }

/* ---------- Responsive ---------- */
@media (max-width: 1360px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .agents { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-col:nth-child(3)::before { display: none; }
  .kpis.k5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: auto;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 50;
    visibility: hidden;
  }
  .app.nav-open .rail { transform: none; box-shadow: var(--shadow); visibility: visible; }
  .menu-btn { display: inline-flex; }
  .modes { grid-template-columns: minmax(0, 1fr); }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox-list { border-right: 0; border-bottom: 1px solid var(--line-soft); max-height: 260px; }
}
@media (max-width: 760px) {
  .topbar { position: static; padding-inline: 16px; }
  .page { padding-inline: 16px; padding-block: 16px 48px; }
  .even, .two-lists { grid-template-columns: minmax(0, 1fr); }
  .kpis, .kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.k5 > :last-child { grid-column: 1 / -1; }
  .kpi-v { font-size: 22px; }
  .agents { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calc { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .calc-out { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .flow-col + .flow-col::before { left: 50%; top: -24px; margin-left: -8px; transform: rotate(135deg); }
  .flow-col:nth-child(3)::before { display: block; }
  .page-title h1 { font-size: 18px; }
  .page-title p { display: none; }
  .heat div { height: 28px; font-size: 0; }
  .meter-row { grid-template-columns: 92px minmax(0, 1fr) 36px; }
  .ev { grid-template-columns: 54px minmax(0, 1fr); }
  .sku-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .feed-label { display: none; }
  .agent-role { display: none; }
  .ev > .chip { grid-column: 2; justify-self: start; }
  .ev-act { grid-column: 2; }
}
@media (max-width: 420px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .kpi { padding: 10px 12px; }
  .kpi-v { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Live app additions: help popups, banners, sign-in, dialogs, decisions,
   tasks, connections, finder, sourcing, listing studio, assistant, manual
   ========================================================================== */

/* ---------- "i" help buttons ---------- */
.info-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  margin-left: 3px;
  border: 0;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  vertical-align: 2px;
  cursor: pointer;
  flex: none;
  transition: background-color 0.12s, color 0.12s;
}
.info-btn:hover { background: var(--info); color: var(--on-color); }
.info-btn.on-dark { background: transparent; color: var(--instr-dim); box-shadow: inset 0 0 0 1px var(--instr-edge); margin-left: 2px; }
.info-btn.on-dark:hover { color: var(--instr-cyan); box-shadow: inset 0 0 0 1px var(--instr-cyan); background: transparent; }
.page-title h1 .info-btn { vertical-align: 4px; }
.label .info-btn { vertical-align: 0; margin-left: 2px; }

.nav-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.nav-row > a { flex: 1; min-width: 0; }
.nav-row > a > span:not(.badge) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-row > .info-btn { opacity: 0; margin-right: 4px; transition: opacity 0.12s; }
.nav-row:hover > .info-btn,
.nav-row > .info-btn:focus-visible,
.nav-row:has(a[aria-current="page"]) > .info-btn { opacity: 1; }
@media (hover: none) { .nav-row > .info-btn { opacity: 0.8; } }

/* Emergency pause button on the strip */
.fcu-btn.pause { color: var(--instr-amber); border-color: color-mix(in oklab, var(--instr-amber) 35%, var(--instr-edge)); }
.fcu-btn.pause[aria-pressed="true"] { color: #1a0f00; background: var(--instr-amber); border-color: var(--instr-amber); }
.fcu-btn.pause[aria-pressed="true"]::before { background: #1a0f00; box-shadow: none; }

/* ---------- Banners under the strip ---------- */
#banners { display: grid; gap: 6px; }
#banners:empty { display: none; }
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.4;
  border: 1px solid transparent;
}
.banner > span { flex: 1 1 280px; min-width: 0; }
.banner .ico { flex: none; }
.banner.demo { background: var(--ai-soft); color: var(--ink-2); }
.banner.demo .ico { color: var(--ai); }
.banner.pause { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.banner.pause .ico { color: var(--warn); }
.banner.offline { background: var(--info-soft); color: var(--ink-2); }
.banner.offline .ico { color: var(--info); animation: spin 1.4s linear infinite; }
.linkish { appearance: none; border: 0; background: none; padding: 0; color: var(--info); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkish:hover { color: var(--ink); }

/* ---------- Sign-in ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 15% -10%, color-mix(in oklab, var(--c1) 16%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in oklab, var(--ai) 14%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand .brand-mark { width: 40px; height: 40px; }
.login-brand .brand-name { font-size: 20px; }
.login-brand .brand-sub { font-size: var(--fs-sm); }
.login-err { color: var(--bad); font-size: var(--fs-sm); min-height: 1.2em; }
.login-err:empty { min-height: 0; }
.login-foot { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }

/* ---------- Dialogs (help popups and forms) ---------- */
.modal {
  --tone: var(--c1);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.wide { width: min(780px, calc(100vw - 24px)); }
.modal::backdrop { background: var(--scrim); }
.modal[open] { animation: modalIn 0.16s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal.tone-blue { --tone: var(--c1); }
.modal.tone-green { --tone: var(--good); }
.modal.tone-amber { --tone: var(--c4); }
.modal.tone-violet { --tone: var(--ai); }
.modal.tone-teal { --tone: var(--c3); }
.modal.tone-rose { --tone: var(--c5); }
.modal-box { display: flex; flex-direction: column; max-height: calc(100vh - 26px); }
.modal-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 12px 16px;
  border-top: 4px solid var(--tone);
  background: color-mix(in oklab, var(--tone) 11%, var(--surface));
  border-bottom: 1px solid var(--line-soft);
}
.modal-h h2 { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: 750; font-stretch: 108%; }
.modal-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone); color: #fff; flex: none; }
.modal-b { padding: 16px; overflow-y: auto; display: grid; gap: 12px; font-size: var(--fs-md); line-height: 1.55; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-soft); background: var(--surface-2); }

/* ---------- Help and manual content blocks ---------- */
.hsummary { font-size: 15px; color: var(--ink); line-height: 1.55; }
.hsec { display: grid; gap: 6px; }
.hsec h3 { font-size: var(--fs-sm); font-weight: 750; color: var(--tone, var(--ink)); letter-spacing: 0.01em; }
.hsec p { color: var(--ink-2); }
.hlist { list-style: none; display: grid; gap: 6px; }
.hlist li { position: relative; padding-left: 18px; color: var(--ink-2); line-height: 1.5; }
.hlist li::before { content: ""; position: absolute; left: 3px; top: 0.6em; width: 7px; height: 7px; border-radius: 50%; background: var(--tone, var(--accent, var(--c1))); }
.hsteps { list-style: none; counter-reset: hs; display: grid; gap: 8px; }
.hsteps li { counter-increment: hs; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; color: var(--ink-2); line-height: 1.5; }
.hsteps li::before {
  content: counter(hs);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 750;
  color: #fff;
  background: var(--tone, var(--accent, var(--c1)));
}
.hbox { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); line-height: 1.5; font-size: var(--fs-sm); color: var(--ink-2); border-left: 3px solid; }
.hbox .ico { margin-top: 2px; }
.hbox p, .hbox div { margin: 0; min-width: 0; }
.hbox b { color: var(--ink); }
.hbox.tip { background: var(--good-soft); border-color: var(--good); }
.hbox.tip .ico { color: var(--good); }
.hbox.warn { background: var(--warn-soft); border-color: var(--warn); }
.hbox.warn .ico { color: var(--warn); }
.hbox.info { background: var(--info-soft); border-color: var(--info); }
.hbox.info .ico { color: var(--info); }
.hbox.bad { background: var(--bad-soft); border-color: var(--bad); }
.hbox.bad .ico { color: var(--bad); }
.hbox.inapp { background: var(--ai-soft); border-color: var(--ai); }
.hbox.inapp .ico { color: var(--ai); }
.hterms { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: var(--fs-sm); }
.hterms dt { font-weight: 700; color: var(--ink); }
.hterms dd { margin: 0; color: var(--ink-2); line-height: 1.5; }
.help-table { border: 1px solid var(--line); border-radius: var(--r-md); }
.help-table .tbl { font-size: var(--fs-sm); }
.help-table .tbl th { background: color-mix(in oklab, var(--tone, var(--accent, var(--c1))) 10%, var(--surface-2)); color: var(--ink-2); white-space: normal; }
.help-table .tbl td { vertical-align: top; line-height: 1.45; padding: 8px 12px; }
.help-table .tbl td:first-child { font-weight: 600; color: var(--ink); }
.help-table .tbl tbody tr:nth-child(even) td { background: var(--surface-2); }
.help-note { color: var(--muted); font-size: var(--fs-xs); margin-top: 6px; }
.hfoot { padding-top: 12px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; }
.lsteps { list-style: none; counter-reset: ls; display: grid; gap: 10px; }
.lsteps li { counter-increment: ls; position: relative; display: grid; gap: 2px; padding: 10px 12px 10px 48px; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--surface-2); }
.lsteps li::before {
  content: counter(ls);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent, var(--c1));
  color: #fff;
  font-weight: 750;
  font-size: var(--fs-sm);
}
.lsteps li b { color: var(--ink); }
.lsteps li span { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.5; }
.lexample { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.lexample-h { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-weight: 700; font-size: var(--fs-sm); background: color-mix(in oklab, var(--good) 12%, var(--surface)); color: var(--ink); }
.lexample-h .ico { color: var(--good); }
.lexample dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 12px 14px; margin: 0; font-size: var(--fs-sm); }
.lexample dt { color: var(--ink-2); }
.lexample dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.lexample .total { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 800; color: var(--good); }

/* ---------- Data markers: source, missing, empty ---------- */
.src {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
  vertical-align: 1px;
}
.src.good { background: var(--good-soft); color: var(--good); }
.src.warn { background: var(--warn-soft); color: var(--warn); }
.src.ai { background: var(--ai-soft); color: var(--ai); }
.src.info { background: var(--info-soft); color: var(--info); }
.missing {
  display: inline-block;
  padding: 0 6px;
  border: 1px dashed var(--warn);
  border-radius: 3px;
  color: var(--warn);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
  white-space: nowrap;
}
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 36px 20px; text-align: center; }
.es-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.es-t { font-weight: 750; font-size: var(--fs-lg); font-stretch: 106%; }
.es-d { color: var(--muted); max-width: 62ch; font-size: var(--fs-sm); line-height: 1.55; }
.es-a { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.chart-empty { display: grid; place-items: center; min-height: 120px; padding: 16px; border: 1px dashed var(--line); border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-sm); text-align: center; background: var(--surface-2); }
.ring-na { display: grid; place-items: center; border-radius: 50%; border: 2px dashed var(--line); color: var(--faint); font-weight: 700; font-size: 13px; flex: none; }

/* ---------- Generic helpers ---------- */
.hstack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hstack.wrap { flex-wrap: wrap; }
.small { font-size: var(--fs-xs); }
.form-h { font-size: var(--fs-sm); font-weight: 750; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.form-h:first-child { padding-top: 0; border-top: 0; }
.sep { border: 0; border-top: 1px solid var(--line-soft); margin: 12px 0; }
.seg.big button { min-height: 32px; padding: 0 14px; font-size: var(--fs-sm); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); cursor: pointer; padding: 3px 0; line-height: 1.4; }
.check-row input { accent-color: var(--ai); width: 16px; height: 16px; margin: 0; flex: none; }
.more { font-size: var(--fs-sm); }
.more > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; width: max-content; max-width: 100%; margin-top: 8px; }
.more > summary:hover { color: var(--ink); }
.more[open] > summary { margin-bottom: 8px; }
pre.pre { margin: 0; padding: 10px 12px; max-height: 260px; overflow: auto; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-md); font-family: var(--font-mono); font-size: var(--fs-2xs); line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; vertical-align: -2px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-line { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--info-soft); color: var(--ink-2); font-size: var(--fs-sm); }
.busy-line .spinner { color: var(--info); }
.counter { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge-inline { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: var(--on-color); font-size: var(--fs-2xs); font-weight: 700; }
.tbl.compact th, .tbl.compact td { padding: 6px 10px; }
.thumb { width: 40px; height: 40px; object-fit: contain; border-radius: var(--r-sm); background: #fff; border: 1px solid var(--line-soft); flex: none; }
.prod-row { display: flex; align-items: center; gap: 10px; min-width: 240px; }

/* ---------- Command center ---------- */
.brief-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-list { list-style: none; counter-reset: su; display: grid; }
.setup-list li { counter-increment: su; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.setup-list li:last-child { border-bottom: 0; }
.setup-list li::before { content: counter(su); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: var(--fs-xs); font-weight: 750; background: var(--surface-3); color: var(--ink-2); }
.setup-list li.pri-urgent::before, .setup-list li.pri-high::before { background: var(--warn); color: var(--on-color); }
.setup-list li > div { flex: 1; min-width: 0; }
.setup-list b { font-size: var(--fs-sm); }
.setup-list p { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; margin-top: 2px; }

/* ---------- Decisions and tasks ---------- */
.dlist { list-style: none; }
.dcard { display: grid; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.dcard:last-child { border-bottom: 0; }
.dcard:hover { background: var(--surface-2); }
.dcard-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-xs); }
.dcard-title { font-weight: 650; font-size: var(--fs-sm); }
.dcard-sum { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.dsec { display: grid; gap: 8px; }
.dsec h3 { font-size: var(--fs-sm); font-weight: 750; display: flex; align-items: center; gap: 4px; }
.dsec p { font-size: var(--fs-sm); line-height: 1.5; }
.dsec .timeline li { opacity: 1; grid-template-columns: 112px auto minmax(0, 1fr); gap: 8px; padding-bottom: 8px; font-size: var(--fs-xs); align-items: center; }
.dsec .timeline li::after { display: none; }
.dsec .timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
.alts { list-style: none; display: grid; gap: 6px; }
.alts li { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--r-md); font-size: var(--fs-sm); line-height: 1.45; }
.alts li .ico { margin-top: 2px; color: var(--muted); }
.alts li.chosen { border-color: var(--good); background: var(--good-soft); }
.alts li.chosen .ico { color: var(--good); }
.checks-list { list-style: none; display: grid; gap: 6px; }
.check { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: var(--fs-sm); line-height: 1.45; }
.check .ico { margin-top: 2px; }
.check.good .ico { color: var(--good); }
.check.bad .ico { color: var(--bad); }
.check.warn .ico { color: var(--warn); }
.checks-list .check-row { padding: 2px 0; }
.task-list { list-style: none; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); border-left: 3px solid transparent; }
.task:last-child { border-bottom: 0; }
.task.pri-urgent { border-left-color: var(--bad); }
.task.pri-high { border-left-color: var(--warn); }
.task-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.task-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-sm); }
.task-main p { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.5; }
.task-act { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Automations ---------- */
.modes.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Connections ---------- */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(460px, 100%), 1fr)); gap: 16px; align-items: start; }
.conn-cost { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: var(--fs-sm); }
.conn-cost .ico { margin-top: 2px; color: var(--good); }
.conn-form { display: grid; gap: 12px; }
.conn-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.conn-extra { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); }
.conn-extra .hint { flex-basis: 100%; font-size: var(--fs-xs); color: var(--muted); line-height: 1.5; }
.conn-extra code, .hint code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 4px; border-radius: 3px; word-break: break-all; }
.subs { list-style: none; display: grid; gap: 4px; flex-basis: 100%; font-size: var(--fs-xs); }
.subs li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.subs li .ico { color: var(--good); }
.cover > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; width: max-content; max-width: 100%; }
.cover > summary:hover { color: var(--ink); }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; margin-top: 10px; }
.cover-grid h4 { font-size: var(--fs-2xs); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.cover-grid p, .cover-grid li { font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.45; }
.cover-grid .plain-list { gap: 3px; }
.cover-grid .plain-list li { display: block; padding-left: 12px; position: relative; }
.cover-grid .plain-list li::before { content: "·"; position: absolute; left: 2px; color: var(--muted); }
.qr { display: grid; place-items: center; }
.qr svg { width: 200px; height: 200px; padding: 8px; background: #fff; border-radius: var(--r-md); }

/* ---------- Product finder ---------- */
.profile-strip { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; padding: 10px 14px; border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pkv { display: inline-flex; align-items: baseline; gap: 6px; font-size: var(--fs-sm); }
.pkv b { font-variant-numeric: tabular-nums; }
.profile-strip .btn { margin-left: auto; }
.find-form { display: grid; gap: 8px; }
.cov { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-xs); color: var(--muted); }
.cov-bar { width: 140px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; flex: none; }
.cov-bar > span { display: block; height: 100%; background: var(--c1); border-radius: 3px; }
.gate-list { list-style: none; display: grid; gap: 6px; }
.gate { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: var(--r-md); font-size: var(--fs-sm); }
.gate .ico { margin-top: 2px; }
.gate b { display: block; font-weight: 650; }
.gate span { display: block; color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.gate.pass .ico { color: var(--good); }
.gate.fail { background: var(--bad-soft); border-color: transparent; }
.gate.fail .ico { color: var(--bad); }
.gate.unknown { background: var(--warn-soft); border-color: transparent; }
.gate.unknown .ico { color: var(--warn); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .affix { flex: 1 1 180px; }
.meter-bar.na { background: repeating-linear-gradient(-45deg, var(--surface-3) 0 4px, transparent 4px 8px); }

/* ---------- Sourcing ---------- */
.kanban { grid-template-columns: repeat(6, minmax(190px, 1fr)); }
.row-actions { display: inline-flex; align-items: center; gap: 4px; }
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
.sup-card { display: grid; gap: 10px; align-content: start; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); min-width: 0; }
.sup-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.sup-h b { font-weight: 700; }
.sup-h small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.kv-list { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: var(--fs-xs); }
.kv-list dt { color: var(--muted); }
.kv-list dd { margin: 0; overflow-wrap: anywhere; }
.sup-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 8px; border-top: 1px dashed var(--line); }

/* ---------- Listing studio ---------- */
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.label-row > label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.bullet-edit { display: grid; gap: 2px; }
.bullet-edit .textarea { min-height: 54px; }
.bullet-edit .counter { justify-self: end; }
#dTitle { min-height: 56px; font-weight: 600; }
.checks li.warn .ico { color: var(--warn); }
.cur-listing { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.cur-listing ul { padding-left: 18px; display: grid; gap: 4px; color: var(--ink-2); }
.cur-listing .btn { justify-self: start; }
.pending-card { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--info-soft); color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.45; }
.pending-card .ico { display: inline; vertical-align: -3px; color: var(--info); }

/* ---------- Assistant ---------- */
.chat-wrap { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.chat-side { align-self: start; }
.thread-list { list-style: none; max-height: 520px; overflow-y: auto; }
.thread-btn { appearance: none; width: 100%; text-align: left; display: grid; gap: 2px; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; cursor: pointer; font-size: var(--fs-sm); }
.thread-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-btn small { color: var(--muted); font-size: var(--fs-xs); }
.thread-btn:hover { background: var(--surface-2); }
.thread-btn.on { background: var(--info-soft); }
.chat-main { min-height: 560px; }
.chat { flex: 1 1 auto; display: grid; gap: 14px; align-content: start; padding: 18px; overflow-y: auto; min-height: 380px; max-height: calc(100vh - 330px); }
.msg { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.msg.me { justify-content: flex-end; }
.msg-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--ai-soft); color: var(--ai); flex: none; }
.msg-b { max-width: min(78ch, 100%); min-width: 0; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line-soft); background: var(--surface-2); font-size: var(--fs-sm); line-height: 1.6; overflow-wrap: anywhere; }
.msg.me .msg-b { background: var(--primary); color: var(--on-primary); border-color: transparent; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.ai .msg-b { border-top-left-radius: 4px; }
.msg-b p + p, .msg-b p + ul, .msg-b p + ol, .msg-b ul + p, .msg-b ol + p { margin-top: 8px; }
.msg-b ul, .msg-b ol { padding-left: 20px; display: grid; gap: 3px; margin-top: 4px; }
.msg-b code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-3); padding: 1px 4px; border-radius: 3px; }
.msg-meta { margin-top: 8px; color: var(--muted); font-size: var(--fs-xs); }
.chat-empty { display: grid; justify-items: center; gap: 8px; padding: 32px 12px; text-align: center; color: var(--muted); }
.chat-empty .ico { color: var(--ai); }
.chat-empty h3 { color: var(--ink); font-size: var(--fs-lg); }
.chat-empty .chips { justify-content: center; max-width: 640px; margin-top: 6px; }
.chat-input { display: grid; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.chat-input .textarea { min-height: 64px; }
.chat-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Learn (the manual) ---------- */
.learn-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(120deg, color-mix(in oklab, var(--c1) 17%, var(--surface)) 0%, color-mix(in oklab, var(--c5) 13%, var(--surface)) 52%, color-mix(in oklab, var(--c3) 16%, var(--surface)) 100%);
}
.lh-text { display: grid; gap: 10px; min-width: 0; }
.lh-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ai); }
.learn-hero h2 { font-size: var(--fs-2xl); font-weight: 800; font-stretch: 112%; letter-spacing: -0.01em; }
.learn-hero p { color: var(--ink-2); max-width: 72ch; line-height: 1.6; }
.lh-progress { display: flex; align-items: center; gap: 14px; font-size: var(--fs-sm); padding: 14px 16px; border-radius: 12px; background: color-mix(in oklab, var(--surface) 75%, transparent); border: 1px solid var(--line-soft); }
.lh-ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c3) calc(var(--p) * 1%), var(--surface-3) 0); flex: none; }
.lh-ring span { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-weight: 800; font-variant-numeric: tabular-nums; }
.learn-search { position: relative; }
.learn-search .input { min-height: 44px; padding-left: 40px; font-size: 15px; border-radius: 10px; }
.ls-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.learn-group { display: grid; gap: 10px; }
.learn-group + .learn-group { margin-top: 10px; }
.lg-h { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 12px; }
.learn-card {
  --accent: var(--c1);
  position: relative;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.learn-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--accent); }
.learn-card.done { background: color-mix(in oklab, var(--good) 5%, var(--surface)); }
.lc-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in oklab, var(--accent) 16%, var(--surface)); color: var(--accent); flex: none; }
.lc-body { display: grid; gap: 3px; min-width: 0; padding-right: 16px; }
.lc-body b { font-size: var(--fs-md); font-weight: 700; }
.lc-sum { color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.45; }
.lc-meta { color: var(--muted); font-size: var(--fs-xs); }
.lc-done { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--good); color: var(--on-color); }
.learn-results { list-style: none; }
.learn-results a { display: grid; gap: 3px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; font-size: var(--fs-sm); }
.learn-results a:hover { background: var(--surface-2); }
.learn-results .muted { font-size: var(--fs-xs); line-height: 1.45; }
.lr-ch { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 650; color: var(--accent); }
.learn-layout { --accent: var(--c1); display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.learn-toc { position: sticky; top: 160px; max-height: calc(100vh - 180px); overflow-y: auto; font-size: var(--fs-sm); display: grid; gap: 8px; padding-right: 4px; }
.lt-back { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 650; color: var(--muted); text-decoration: none; }
.lt-back:hover { color: var(--ink); }
.lt-chapters { list-style: none; display: grid; gap: 1px; }
.lt-chapters > li > a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-md); color: var(--ink-2); text-decoration: none; line-height: 1.3; }
.lt-chapters > li > a:hover { background: var(--surface-2); color: var(--ink); }
.lt-chapters > li > a .ico { color: var(--good); }
.lt-chapters > li.on > a { background: var(--surface-3); color: var(--ink); font-weight: 650; }
.lt-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 2px; }
.lt-sections { list-style: none; display: grid; gap: 1px; margin: 4px 0 8px 15px; padding-left: 12px; border-left: 2px solid var(--accent); }
.lt-sections a { display: block; padding: 3px 0; font-size: var(--fs-xs); color: var(--muted); text-decoration: none; line-height: 1.35; }
.lt-sections a:hover { color: var(--ink); }
.learn-main { display: grid; gap: 14px; min-width: 0; max-width: 900px; }
.learn-head { display: flex; gap: 16px; align-items: flex-start; padding: 22px; border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: 12px; background: color-mix(in oklab, var(--accent) 10%, var(--surface)); }
.lh-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.lh-level { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.learn-head h2 { font-size: var(--fs-2xl); font-weight: 800; font-stretch: 110%; margin: 2px 0 6px; }
.learn-head p { color: var(--ink-2); line-height: 1.6; }
.learn-sec { display: grid; gap: 12px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: 170px; }
.learn-sec > h2 { font-size: var(--fs-lg); font-weight: 750; font-stretch: 106%; display: flex; align-items: center; gap: 8px; padding-left: 10px; border-left: 4px solid var(--accent); }
.learn-sec > h2 .ico { color: var(--accent); }
.learn-sec > p { color: var(--ink-2); line-height: 1.65; font-size: 14.5px; }
.learn-sec.flash { animation: secFlash 1.6s ease-out; }
@keyframes secFlash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: 0 0 0 0 transparent; } }
.learn-check { list-style: none; display: grid; gap: 2px; }
.quiz-q { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.quiz-q:last-child { border-bottom: 0; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opt { appearance: none; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink); }
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.quiz-opt:disabled { cursor: default; opacity: 0.8; }
.quiz-opt.right { background: var(--good-soft); border-color: var(--good); opacity: 1; }
.quiz-opt.wrong { background: var(--bad-soft); border-color: var(--bad); opacity: 1; }
.quiz-why { font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-2); }
.learn-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 0 12px; }
.learn-nav { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- How it works ---------- */
.record-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.rs { display: grid; gap: 4px; align-content: start; padding: 12px; border: 1px solid var(--line-soft); border-radius: var(--r-md); background: var(--surface-2); }
.rs .ico { color: var(--ai); }
.rs b { font-size: var(--fs-sm); }
.rs span { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }

/* ---------- Repricer: unknown Buy Box checks ---------- */
.bb-strip span.unk { background: repeating-linear-gradient(-45deg, var(--surface-3) 0 3px, transparent 3px 6px); }

/* ---------- Responsive for the additions ---------- */
@media (max-width: 1180px) {
  .modes.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .chat-wrap { grid-template-columns: minmax(0, 1fr); }
  .chat-side .thread-list { max-height: 180px; }
  .learn-layout { grid-template-columns: minmax(0, 1fr); }
  .learn-toc { position: static; max-height: none; }
  .learn-toc .lt-chapters { display: none; }
  .learn-hero { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .modes.four { grid-template-columns: minmax(0, 1fr); }
  .record-steps { grid-template-columns: minmax(0, 1fr); }
  .learn-hero { padding: 18px; }
  .learn-hero h2, .learn-head h2 { font-size: var(--fs-xl); }
  .learn-sec { padding: 16px; }
  .learn-head { padding: 16px; }
  .lh-ico { width: 42px; height: 42px; }
  .hterms { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .hterms dd { margin-bottom: 6px; }
  .chat { max-height: none; min-height: 300px; }
  .task { flex-wrap: wrap; }
  .task-act { width: 100%; justify-content: flex-start; }
  .profile-strip .btn { margin-left: 0; }
  .modal-b { padding: 14px; }
}
