:root {
  color-scheme: light;
  --page: #f9f9f9;
  --surface: #ffffff;
  --ink: #191919;
  --ink-2: #666666;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --border: rgba(11, 11, 11, 0.10);
  --ai: #257de0;
  --bh: #f47230;
  --good: #006c10;
  --bad: #c42b2c;
  --live: #0aac23;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;
  --button: #f1f1f1;
  --button-on: #191919;
  --button-on-ink: #ffffff;
  --link: #1b64be;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0b0b;
    --surface: #191919;
    --ink: #efefef;
    --ink-2: #9c9c9c;
    --grid: #303030;
    --axis: #474747;
    --border: rgba(255, 255, 255, 0.10);
    --ai: #338ced;
    --bh: #e76624;
    --good: #53c556;
    --bad: #f07373;
    --live: #0aac23;
    --warn-bg: #3a2d05;
    --warn-ink: #fbd56b;
    --button: #262626;
    --button-on: #efefef;
    --button-on-ink: #191919;
    --link: #84b9f3;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface: #191919;
  --ink: #efefef;
  --ink-2: #9c9c9c;
  --grid: #303030;
  --axis: #474747;
  --border: rgba(255, 255, 255, 0.10);
  --ai: #338ced;
  --bh: #e76624;
  --good: #53c556;
  --bad: #f07373;
  --live: #0aac23;
  --warn-bg: #3a2d05;
  --warn-ink: #fbd56b;
  --button: #262626;
  --button-on: #efefef;
  --button-on-ink: #191919;
  --link: #84b9f3;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
main.wide { max-width: 1200px; }  /* home: the comparison table has ten columns */
a { color: var(--link); }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; }
.sub { margin: 4px 0 0; color: var(--ink-2); }

.top { display: flex; gap: 12px 24px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 20px; }
.status { margin: 2px 0 0; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--ink-2); font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--axis); flex: none; }
.status.live .dot { background: var(--live); }
.status.stale { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.status.stale .dot { background: transparent; width: auto; height: auto; border-radius: 0; }
.status.stale .dot::before { content: "⚠"; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; min-width: 0; }
.kpi .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .note { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.up { color: var(--good); }
.down { color: var(--bad); }

.key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; flex: none; }
.key-ai { background: var(--ai); }
.key-bh { background: var(--bh); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0; padding: 0; color: var(--ink-2); font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.ranges { display: inline-flex; background: var(--button); border-radius: 8px; padding: 2px; }
.ranges button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2); padding: 4px 12px; border-radius: 6px; cursor: pointer; min-height: 32px; }
.ranges button[aria-pressed="true"] { background: var(--button-on); color: var(--button-on-ink); font-weight: 600; }
.ranges button:focus-visible { outline: 2px solid var(--ai); outline-offset: 1px; }

.chart { position: relative; height: 320px; transition: opacity .2s; }
.chart.loading { opacity: .55; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-ai { stroke: var(--ai); }
.chart .line-bh { stroke: var(--bh); }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .dot-ai { fill: var(--ai); stroke: var(--surface); stroke-width: 2; }
.chart .dot-bh { fill: var(--bh); stroke: var(--surface); stroke-width: 2; }
.tooltip { position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); border-radius: 8px; padding: 8px 10px; font-size: 13px; min-width: 170px; }
.tooltip .t { color: var(--ink-2); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; }
.tooltip .row strong { font-variant-numeric: tabular-nums; }
.tooltip .row span:last-child { color: var(--ink-2); }
.empty { color: var(--ink-2); text-align: center; margin: 16px 0; }
.chart .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 16px; }
.chart .empty[hidden] { display: none; }
.fine { color: var(--ink-2); font-size: 13px; margin: 8px 0 0; }

.trades { width: 100%; border-collapse: collapse; font-size: 14px; }
.trades th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--axis); }
.trades td { padding: 7px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.trades .num { text-align: right; font-variant-numeric: tabular-nums; }
.trades th:first-child, .trades td:first-child { padding-left: 0; }
.trades th:last-child, .trades td:last-child { padding-right: 0; }
.side { font-weight: 600; }
.side::before { margin-right: 4px; font-size: 11px; }
.side-buy::before { content: "▲"; color: var(--good); }
.side-sell::before { content: "▼"; color: var(--bad); }

.about p { margin: 8px 0 0; color: var(--ink); max-width: 72ch; }
.about h2 { margin-bottom: 4px; }

@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  main { padding-top: 16px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .chart { height: 260px; }
  .trades .wide { display: none; }
  .trades { font-size: 13px; }
  .trades td, .trades th { padding-left: 4px; padding-right: 4px; }
}
@media (prefers-reduced-motion: reduce) { .chart { transition: none; } }

/* every page: the paper-trading notice */
.notice { margin: 0; padding: 6px 16px; text-align: center; font-size: 13px; background: var(--warn-bg); color: var(--warn-ink); }
.crumbs { margin: 0 0 12px; font-size: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card-head .fine { margin-top: 2px; max-width: 64ch; }
.warn { color: var(--warn-ink); }

/* home: the comparison table */
.sims { width: 100%; border-collapse: collapse; font-size: 14px; }
.sims th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
.sims td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.sims tr:last-child td { border-bottom: 0; }
.sims .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sims th:first-child, .sims td:first-child { padding-left: 0; }
.sims th:last-child, .sims td:last-child { padding-right: 0; }
.sims td.name { min-width: 170px; }
.sims .name a { font-weight: 600; text-decoration: none; }
.sims .name a:hover, .sims .name a:focus-visible { text-decoration: underline; }
.sims .meta { display: block; color: var(--ink-2); font-size: 12px; }
.sims .updated { color: var(--ink-2); white-space: nowrap; font-size: 13px; }
.sims .spark-col { width: 128px; }
.spark { display: block; width: 120px; height: 34px; }
.spark .line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .line-ai { stroke: var(--ai); }
.spark .line-bh { stroke: var(--bh); }

.sims .risk-wait { color: var(--ink-2); font-size: 13px; text-align: center; white-space: nowrap; }
.formula { max-width: none; }

/* simulation page: risk */
.risk { width: 100%; border-collapse: collapse; font-size: 14px; }
.risk th, .risk td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: left; }
.risk thead th { font-weight: 600; color: var(--ink-2); font-size: 12px; border-bottom-color: var(--axis); white-space: nowrap; }
.risk tbody th { font-weight: 400; color: var(--ink-2); }
.risk .num { text-align: right; font-variant-numeric: tabular-nums; }
.risk th:first-child, .risk td:first-child { padding-left: 0; }
.risk th:last-child, .risk td:last-child { padding-right: 0; }
.risk tr:last-child th, .risk tr:last-child td { border-bottom: 0; }
.risk .key { vertical-align: middle; }
.risk .meta { display: block; color: var(--ink-2); font-size: 12px; white-space: nowrap; }

/* simulation page: settings */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; margin: 12px 0 4px; }
.settings div { min-width: 0; }
.settings dt { color: var(--ink-2); font-size: 12px; }
.settings dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.settings .help { display: block; color: var(--ink-2); font-size: 12px; }

@media (max-width: 1100px) {
  /* the table becomes one card per simulation */
  .sims thead { display: none; }
  .sims, .sims tbody, .sims tr { display: block; }
  .sims tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--grid); }
  .sims tr:last-child { border-bottom: 0; }
  .sims td { display: block; padding: 0 !important; border: 0; text-align: left !important; min-width: 0; }
  .sims td::before { content: attr(data-label); display: block; color: var(--ink-2); font-size: 12px; }
  .sims td.name { grid-column: 1 / span 2; }
  .sims td.name::before, .sims td.spark-col::before { content: none; }
  .sims td.spark-col { grid-column: 3; grid-row: 1; width: auto; justify-self: end; align-self: center; }
  .sims td.risk-wait { grid-column: 1 / -1; white-space: normal; font-size: 14px; color: var(--ink); }
  .sims .spark { width: 96px; height: 30px; }
  .sims .updated { white-space: normal; }
}
