/* Shared by the dashboard and the backtest reports. */
.viz-root {
  color-scheme: light;
  --page: #f9f9f9; --surface-1: #ffffff; --text-primary: #191919; --text-secondary: #666666;
  --grid: #e7e7e7; --axis: #c2c2c2; --border: rgba(11,11,11,0.10);
  --series-1: #257de0; --series-2: #f47230; --series-3: #00b894; --series-4: #f2a600;
  --up: #006c10; --down: #dc3c3d;
  --good: #0aac23; --warning: #fbb315; --critical: #dc3c3d;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0b0b0b; --surface-1: #191919; --text-primary: #efefef; --text-secondary: #9c9c9c;
    --grid: #303030; --axis: #474747; --border: rgba(255,255,255,0.10);
    --series-1: #338ced; --series-2: #e76624; --series-3: #00a888; --series-4: #d28e05;
    --up: #53c556; --down: #eb6263;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page: #0b0b0b; --surface-1: #191919; --text-primary: #efefef; --text-secondary: #9c9c9c;
  --grid: #303030; --axis: #474747; --border: rgba(255,255,255,0.10);
  --series-1: #338ced; --series-2: #e76624; --series-3: #00a888; --series-4: #d28e05;
  --up: #53c556; --down: #eb6263;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.viz-root { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--page); color: var(--text-primary); min-height: 100vh; padding: 24px; }
.wrap { max-width: 1200px; margin: 0 auto; display: grid; gap: 16px; }
h1 { font-size: 20px; margin: 0; }
.params { color: var(--text-secondary); font-size: 13px; margin: 4px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile, .card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.tile .k { color: var(--text-secondary); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 4px; overflow-wrap: anywhere; }
.tile .sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.tile .unit { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 5px; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); }

.card h2 { font-size: 15px; margin: 0 0 2px; }
.card .desc { color: var(--text-secondary); font-size: 12px; margin: 0 0 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; }
.chart text { font-size: 11px; fill: var(--text-secondary); font-variant-numeric: tabular-nums; }
.chart .dl { fill: var(--text-primary); }
.chart .empty { color: var(--text-secondary); font-size: 13px; padding: 40px 0; text-align: center; margin: 0; }
.tip { position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; display: none; z-index: 2; }
.tip .row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip .row b { margin-left: auto; padding-left: 12px; font-weight: 600; }
.tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tip .when { color: var(--text-secondary); margin-bottom: 4px; }
.tip .fill { margin-top: 4px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-secondary); font-weight: 500; }
th.l, td.l { text-align: left; }
.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; }
details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.note, .disclaimer { color: var(--text-secondary); font-size: 12px; }

/* Dashboard */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar .spacer { flex: 1; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-1); }
.badge.live { background: var(--critical); color: #ffffff; border-color: transparent; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status.running .dot { background: var(--good); }
.status.paused .dot { background: var(--warning); }
.status.error .dot { background: var(--critical); }
.banner { border-radius: 12px; padding: 12px 16px; font-size: 13px; border: 1px solid var(--border); background: var(--surface-1); }
.banner b { margin-right: 6px; }
.banner.warn { border-left: 4px solid var(--warning); }
.banner.err { border-left: 4px solid var(--critical); }
button { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
button:hover { border-color: var(--axis); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--series-1); border-color: transparent; color: #ffffff; }
button.danger { color: var(--down); }
button.ghost { background: transparent; }
.login { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 12px; }
.login input { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--axis); background: var(--page); color: var(--text-primary); }
.login .error { color: var(--down); font-size: 13px; min-height: 1em; margin: 0; }
.logs { font-family: ui-monospace, Consolas, monospace; font-size: 12px; max-height: 320px; overflow: auto; margin: 0; padding: 0; list-style: none; }
.logs li { padding: 3px 0; border-bottom: 1px solid var(--grid); color: var(--text-secondary); overflow-wrap: anywhere; }
@media (max-width: 600px) { .viz-root { padding: 12px; } .grid-2 { grid-template-columns: 1fr; } }
