/* bizwarDSS - page chrome and chart tokens.
   Palette: validated categorical slots + a single-hue ordinal blue ramp.
   Dark values are declared under both the media query and the [data-theme]
   scope so an explicit toggle wins in either direction. */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --wash:           rgba(11,11,11,0.035);
  /* ordinal blue ramp, light -> dark */
  --ramp-0: #86b6ef;
  --ramp-1: #3987e5;
  --ramp-2: #1c5cab;
  --ramp-3: #0d366b;
  /* categorical slots, fixed order, never cycled */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --accent:   #eb6834;
  --good:     #006300;
  --good-mark:#0ca30c;
  --warning:  #fab219;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,0.10);
    --wash:           rgba(255,255,255,0.05);
    --ramp-0: #184f95;
    --ramp-1: #256abf;
    --ramp-2: #5598e7;
    --ramp-3: #b7d3f6;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --accent:   #d95926;
    --good:     #0ca30c;
    --good-mark:#0ca30c;
    --warning:  #fab219;
    --critical: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255,255,255,0.10);
  --wash:           rgba(255,255,255,0.05);
  --ramp-0: #184f95;
  --ramp-1: #256abf;
  --ramp-2: #5598e7;
  --ramp-3: #b7d3f6;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --accent:   #d95926;
  --good:     #0ca30c;
  --good-mark:#0ca30c;
  --warning:  #fab219;
  --critical: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 0 0 72px;
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--series-1); }

/* ---------------------------------------------------------------- nav */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  min-height: 52px;
}
.brand { font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.brand .firm { color: var(--text-muted); font-weight: 400; margin-left: 7px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.tabs a {
  display: block; padding: 7px 13px; border-radius: 7px;
  color: var(--text-secondary); text-decoration: none; font-weight: 550;
  font-size: 13.5px; white-space: nowrap;
}
.tabs a:hover { background: var(--wash); color: var(--text-primary); }
.tabs a[aria-current="page"] {
  background: var(--wash); color: var(--text-primary);
  box-shadow: inset 0 -2px 0 var(--series-1);
}
.tabs a.soon { color: var(--text-muted); pointer-events: none; opacity: 0.55; }

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 20px 0; }
h1 { font-size: 21px; font-weight: 650; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--text-secondary); margin: 0 0 22px; max-width: 76ch; }
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2 { font-size: 14px; font-weight: 650; margin: 0 0 2px; }
.card > .note { color: var(--text-secondary); font-size: 12.5px; margin: 0 0 14px;
                max-width: 92ch; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; }

/* ---------------------------------------------------------------- controls */
.filters { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
                 text-transform: uppercase; letter-spacing: 0.04em; }
select, input[type="number"], input[type="text"] {
  font: inherit; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px;
}
select { min-width: 250px; }
input[type="range"] { width: 210px; accent-color: var(--series-1); }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-val { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 62px; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--axis); border-radius: 999px; padding: 5px 11px 5px 9px;
  font-size: 13px; user-select: none; background: var(--surface-1);
}
.toggle input { margin: 0; accent-color: var(--series-1); }
.toggle[data-on="0"] { color: var(--text-muted); }
.btn {
  font: inherit; cursor: pointer; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--axis); border-radius: 6px; padding: 6px 12px;
}
.btn:hover { background: var(--wash); }
.btn[aria-pressed="true"] { background: var(--wash); box-shadow: inset 0 0 0 1px var(--series-1); }
.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--series-1); filter: brightness(1.1); }

/* ---------------------------------------------------------------- tables */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
th { font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
     text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
tr.off td, tr.off th { color: var(--text-muted); }
tr.best th, tr.best td { font-weight: 650; }
tr.sep td, tr.sep th { border-top: 1px solid var(--axis); }
.num { width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* ---------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
         gap: 1px; background: var(--border); border: 1px solid var(--border);
         border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.stat { background: var(--surface-1); padding: 15px 16px; }
.stat .label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600;
               text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 25px; font-weight: 650; margin-top: 5px; letter-spacing: -0.015em; }
.stat.hero .value { font-size: 38px; }
.stat .foot { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.stat .foot.good { color: var(--good); }
.stat .foot.bad  { color: var(--critical); }

/* ---------------------------------------------------------------- charts */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px;
          color: var(--text-secondary); margin: 10px 0 6px; }
.legend span.item { white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px;
          vertical-align: -1px; margin-right: 6px; }
.keyline { display: inline-block; width: 14px; height: 2px; border-radius: 1px;
           vertical-align: 4px; margin-right: 6px; }
.plot { position: relative; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
svg text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; }
.tick { fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.axis-title { fill: var(--text-secondary); font-size: 11.5px; font-weight: 600; }
.tip {
  position: absolute; pointer-events: none; z-index: 10;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; min-width: 190px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.13); font-size: 12.5px;
}
.tip[hidden] { display: none !important; }
.tip .tt { font-weight: 650; font-size: 12px; color: var(--text-secondary);
           margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.tip .row { display: flex; align-items: baseline; gap: 8px; margin-top: 3px; }
.tip .row .v { font-weight: 650; font-variant-numeric: tabular-nums;
               margin-left: auto; color: var(--text-primary); }
.tip .row .n { color: var(--text-secondary); }
.tip .row.dim { opacity: 0.55; }
.tip .hint { margin-top: 7px; font-size: 11.5px; color: var(--text-secondary); }

/* ---------------------------------------------------------------- prose */
.callout { font-size: 12.5px; color: var(--text-secondary); margin: 12px 0 0;
           padding-left: 11px; border-left: 2px solid var(--accent); }
.callout.tone-warn { border-left-color: var(--critical); }
.callout.tone-ok { border-left-color: var(--good-mark); }
.findings { margin: 10px 0 0; padding-left: 20px; color: var(--text-secondary);
            font-size: 13px; }
.findings li { margin-bottom: 6px; }
.findings b, .callout b { color: var(--text-primary); font-weight: 650; }
.flag { color: var(--critical); font-weight: 650; }
.ok   { color: var(--good); font-weight: 650; }
details { margin-top: 12px; }
summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.err { color: var(--critical); font-weight: 600; }
.pending { opacity: 0.55; transition: opacity 120ms; }

@media (max-width: 620px) {
  select, input[type="range"] { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .tabs { margin-left: 0; }
}

/* ---------------------------------------------------------------- misc */
.chart-head { display: flex; justify-content: space-between; align-items: baseline;
              gap: 16px; flex-wrap: wrap; }
.tot { font-weight: 650; }
.dgrid input { width: 68px; text-align: right; font-variant-numeric: tabular-nums; }
.consts { font-size: 12.5px; color: var(--text-secondary); }
.consts code { font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* ---------------------------------------------------------------- planner */
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }
.status { font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.status.busy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px;
                       border-radius: 50%; background: var(--series-1); vertical-align: 0;
                       animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .status.busy::before { animation: none; } }
textarea { font: 12px/1.4 ui-monospace, Consolas, monospace; width: 100%; min-height: 140px;
           color: var(--text-primary); background: var(--surface-1);
           border: 1px solid var(--axis); border-radius: 6px; padding: 8px; resize: vertical; }
details > summary { font-size: 13px; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; vertical-align: middle; }
.chip { font-size: 11.5px; border: 1px solid var(--axis); border-radius: 999px; padding: 1px 8px;
        color: var(--text-secondary); font-weight: 400; }
.card.tight { padding: 14px 16px; }
.boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 10px; }
.box label { display: block; font-size: 12px; font-weight: 650; margin-bottom: 2px; }
.box .where { display: block; font-size: 11px; color: var(--text-muted); min-height: 2.6em; line-height: 1.3; }
.box textarea { min-height: 96px; font-size: 11px; margin-top: 4px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.presets select { min-width: 180px; max-width: 100%; }
.presets input[type="text"] { width: 170px; max-width: 100%; }
.box .state { font-size: 11.5px; margin-top: 3px; min-height: 1.4em; }
.box .state.ok { color: var(--good); }
.box .state.bad { color: var(--critical); }
.box .state.empty { color: var(--text-muted); }
.kept { font-size: 11.5px; color: var(--text-muted); margin: 8px 0 0; }
.derive { font-size: 12px; color: var(--text-secondary); margin: -2px 0 8px; }
.card.tight > h2 { margin-bottom: 8px; }

/* target grid: units over price */
.tgrid td { vertical-align: top; padding: 5px 6px; }
.tgrid input { width: 78px; text-align: right; font-variant-numeric: tabular-nums; }
.tgrid input.units { font-weight: 650; }
.tgrid input.price { margin-top: 3px; font-size: 12px; color: var(--text-secondary); padding: 3px 6px; }
.tgrid .hint { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tgrid .hint.pdiff { color: var(--text-secondary); }
.tgrid .hint.flag { color: var(--critical); font-weight: 650; }
.tgrid .hint.model { color: var(--text-secondary); cursor: help; }
.tgrid .hint.model.pinned { cursor: pointer; text-decoration: underline dotted; }
.tgrid input.changed { border-color: var(--accent); background: rgba(235,104,52,0.08); }
.tgrid input.units.typed { font-style: italic; }
.changes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0;
  padding: 6px 10px; font-size: 13px; background: var(--wash); border-left: 3px solid var(--accent); }
.changes[hidden] { display: none; }
.tgrid input.spend, .effects input.spend { width: 86px; font-size: 12px; padding: 3px 6px; }
.tgrid tr.promo th, .tgrid tr.promo td { border-top: 1px solid var(--border, #ddd); }
.effects td, .effects th { padding: 4px 8px; vertical-align: top; text-align: left; }
.effects .src { font-size: 12px; color: var(--text-muted); }
.margins th .hint { font-weight: 400; }
.margins td { min-width: 150px; }
.margins .muted { color: var(--text-muted); }
.margins tr.ladder th, .margins tr.ladder td { padding-top: 0; font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.margins .rung { display: block; margin-bottom: 2px; }
.mchart { margin: 6px 0 18px; }
.mchart h3 { font-size: 13px; font-weight: 650; margin: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; margin-top: 12px; }
.opts input[type=number] { width: 70px; }
.opts .field > label { font-size: 11px; }
.testopts { margin: 4px 0 12px; }
.testopts input[type=number] { width: 96px; }
#testCard .stats { margin-bottom: 8px; }
#testCard .stat .value { font-size: 21px; }
#testFlags .callout { margin: 4px 0 8px; }

.alerts { margin: 0 0 14px; }
.alerts p { margin: 0 0 6px; font-size: 13px; padding: 7px 11px; border-radius: 7px;
            background: var(--wash); border-left: 3px solid var(--warning); }
.alerts p.bad { border-left-color: var(--critical); }
.alerts p.info { border-left-color: var(--series-1); }
.alerts b { font-weight: 650; }

.form td, .form th { padding: 6px 8px; }
td.cell { font-weight: 650; font-size: 15px; }
td.changed { background: var(--wash); box-shadow: inset 3px 0 0 var(--accent); }
.was { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.was.flag { color: var(--critical); }
.sens { font-size: 12px; color: var(--text-secondary); margin: 8px 0 0; }
.copyrow { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.btn:disabled { cursor: not-allowed; color: var(--text-muted); background: var(--surface-1); }
.src { text-align: left; color: var(--text-secondary); font-size: 12px; }
td.kind { text-align: left; font-size: 12px; color: var(--text-secondary); }
.pos { color: var(--critical); }
.more > summary { font-weight: 650; color: var(--text-primary); font-size: 14px; }

/* a plan that no longer matches the inputs stays readable but greyed until
   the new one is ready */
.stale .form, .stale table, .alerts.stale, .stale .stats, .stale .mchart { opacity: 0.45; transition: opacity 120ms; }
.working { font-size: 12.5px; color: var(--text-secondary); margin: 0 0 10px; }

/* ---------------------------------------------------------------- inventory */
.model { font-size: 13px; color: var(--text-secondary); max-width: 88ch; margin-top: 10px; }
.model p, .model ul { margin: 0 0 8px; }
.model li { margin-bottom: 4px; }
.model b, .model i { color: var(--text-primary); }
.model h3 { font-size: 13px; font-weight: 650; color: var(--text-primary); margin: 14px 0 6px; }
.model .eq { font-size: 14px; color: var(--text-primary); padding: 6px 12px; background: var(--wash);
             border-radius: 6px; overflow-x: auto; }
.ratio .big { display: block; font-weight: 650; font-size: 15px; }
/* corner checklist */
.helper { position: fixed; right: 16px; bottom: 16px; z-index: 30; width: 330px;
          max-width: calc(100vw - 32px); background: var(--surface-1);
          border: 1px solid var(--border); border-radius: 10px;
          box-shadow: 0 6px 20px rgba(0,0,0,0.14); }
.helper-bar { display: flex; align-items: center; gap: 8px; width: 100%; font: inherit;
              font-size: 13px; font-weight: 650; color: var(--text-primary); background: none;
              border: 0; padding: 9px 12px; cursor: pointer; text-align: left; }
.helper-count { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--text-muted);
                font-variant-numeric: tabular-nums; }
.helper-chev::before { content: "\25B4"; color: var(--text-secondary); }
.helper-bar[aria-expanded="true"] .helper-chev::before { content: "\25BE"; }
.helper-body { max-height: min(62vh, 560px); overflow-y: auto; padding: 0 12px 12px;
               border-top: 1px solid var(--grid); }
.helper-body .btn { font-size: 12px; padding: 4px 10px; margin-top: 4px; }
.checks { margin: 6px 0 8px; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.4; }
.checks li { margin-bottom: 5px; }
.checks li.grp { margin: 10px 0 4px; font-size: 11px; font-weight: 650; color: var(--text-secondary);
                 text-transform: uppercase; letter-spacing: 0.04em; }
.checks label { display: flex; gap: 6px; align-items: baseline; cursor: pointer; color: var(--text-secondary); }
.checks b { color: var(--text-primary); font-weight: 650; }
.checks input { accent-color: var(--series-1); margin: 0; flex: none; }
.checks label:has(input:checked) { opacity: 0.55; }

/* ---------------------------------------------------------------- team lock */
body.locked > :not(.lock) { visibility: hidden; }
.lock { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
        padding: 16px; background: var(--page); }
.lock[hidden] { display: none; }
.lock-card { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 280px;
             background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
             padding: 20px; }
.lock-card label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary);
                   text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; }
.lock-card input { font: inherit; color: var(--text-primary); background: var(--surface-1);
                   border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; }
.lock-card .err { margin: 0; min-height: 1.2em; font-size: 12.5px; }

/* experiments view */
.exp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-top: 10px; }
.exp-panel { min-width: 0; }
.exp-panel .chart-head { gap: 10px; flex-wrap: wrap; }
td.exp-text { text-align: left; max-width: 46ch; white-space: normal; }
.chip.flag { border-color: var(--critical); }

/* final competition view */
.fin-toc { display: flex; flex-wrap: wrap; gap: 6px; }
.fin-toc a { font-size: 12.5px; padding: 3px 10px; border: 1px solid var(--axis); border-radius: 999px;
             color: var(--text-secondary); text-decoration: none; white-space: nowrap; }
.fin-toc a:hover { background: var(--wash); color: var(--text-primary); }
.fin .card { scroll-margin-top: 66px; }
.fin .card > h3 { font-size: 13px; font-weight: 650; margin: 14px 0 6px; }
.fin .card > p { max-width: 92ch; margin: 0 0 8px; }
.fin .findings { max-width: 92ch; margin-bottom: 4px; }
.fin .alerts { margin: 0 0 10px; }
.fin table.lt th, .fin table.lt td { text-align: left; vertical-align: top; }
.fin table.lt .n { text-align: right; white-space: nowrap; }
.fin td.over { background: rgba(235,104,52,0.08); box-shadow: inset 3px 0 0 var(--accent); font-weight: 650; }
.fin .scroll + .scroll { margin-top: 12px; }
.chip.plan { border-color: var(--series-1); color: var(--series-1); }
.chip.trig { border-color: var(--accent); color: var(--accent); }
.chip.good { border-color: var(--good-mark); color: var(--good); }
.chip.weak { border-color: var(--critical); color: var(--critical); }
