/* Trade Bot dashboard. System fonts, no external assets (CSP: self only).
   Colour carries status only: ok, warn, bad. Everything else is ink on paper. */

:root { --bg: #e9edf1; --panel: #fbfcfd; --sunk: #f1f4f7; --ink: #132030; --dim: #4a5969; --line: #d3dae2;
  --line-2: #b9c3ce;
  --accent: #1f5a8c;
  --ok: #1b6f45;
  --warn: #875600;
  --bad: #b0261e;
  --ok-bg: #e1f0e7;
  --warn-bg: #f6ead2;
  --bad-bg: #f8e1de;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --r: 6px;
  --gap: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1318;
    --panel: #131b22;
    --sunk: #0f161c;
    --ink: #dfe6ec;
    --dim: #97a5b2;
    --line: #233039;
    --line-2: #33424e;
    --accent: #84b6de;
    --ok: #5cc28c;
    --warn: #e3ad50;
    --bad: #f2857c;
    --ok-bg: #15301f;
    --warn-bg: #352812;
    --bad-bg: #3a1c1b;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, p, dl, dd, ul, pre { margin: 0; }
ul { padding: 0; list-style: none; }
code { font-size: 0.92em; background: var(--sunk); border: 1px solid var(--line); border-radius: 3px; padding: 0 0.3em; }
small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.neg { color: var(--bad); }
.muted, .stale { color: var(--dim); }
[data-tone="ok"] { --tone: var(--ok); --tone-bg: var(--ok-bg); }
[data-tone="warn"] { --tone: var(--warn); --tone-bg: var(--warn-bg); }
[data-tone="bad"] { --tone: var(--bad); --tone-bg: var(--bad-bg); }

/* header */

.top { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.state { display: flex; align-items: center; gap: 10px; min-width: 0; }
.state__why { color: var(--dim); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border: 1px solid var(--tone, var(--dim)); border-radius: 4px; background: var(--tone-bg, var(--sunk)); color: var(--tone, var(--dim)); font-weight: 700; font-size: 12.5px; letter-spacing: 0.04em; white-space: nowrap; }
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; color: var(--dim); font-size: 13px; }
.facts [data-tone="bad"] { color: var(--bad); font-weight: 600; }
.badge { display: inline-block; padding: 0 7px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--ink); font-size: 12px; font-weight: 600; text-transform: capitalize; }
.badge[data-tone] { border-color: var(--tone, var(--line-2)); color: var(--tone, var(--ink)); }
.dot { display: inline-flex; align-items: center; gap: 6px; }
.dot__mark { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--dim); }
.dot[data-tone] .dot__mark { border-color: var(--tone, var(--dim)); background: var(--tone, transparent); }
.logout { margin-left: auto; }
.btn, .range button { font: inherit; font-size: 13px; color: var(--ink); background: transparent; border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 11px; cursor: pointer; }
.btn:hover, .range button:hover { background: var(--sunk); }

.banner { margin: 12px 16px 0; padding: 10px 14px; border: 1px solid var(--warn); border-left-width: 4px; border-radius: var(--r); background: var(--warn-bg); }

/* layout */

.main { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); max-width: 1440px; margin: 0 auto; padding: var(--gap) 16px; }
.panel { grid-column: 1 / -1; min-width: 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.span-8 { grid-column: span 8; }
.span-4 { grid-column: span 4; }
.panel h2 { font-size: 15px; font-weight: 650; }
.panel__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 10px; }
.panel__meta { color: var(--dim); font-size: 13px; margin-left: auto; }
.panel__meta > span + span { margin-left: 14px; }
.perr { margin: 0 0 10px; padding: 6px 10px; border-left: 3px solid var(--warn); background: var(--warn-bg); font-size: 13px; }
.note { margin-top: 10px; color: var(--dim); font-size: 12.5px; max-width: 95ch; }
.waiting p { margin-top: 6px; color: var(--dim); max-width: 75ch; }

/* risk strip */

.risk { padding: 18px 20px 16px; }
.risk__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 22px; }
.risk__equity { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.risk__equity .unit { font-size: 14px; font-weight: 500; color: var(--dim); letter-spacing: 0; }
.risk__vs { color: var(--dim); }
.risk__vs .neg { font-weight: 600; }
.risk__kill { margin-left: auto; font-weight: 600; color: var(--tone, var(--ink)); }

.runway { margin: 30px 0 4px; padding-bottom: 26px; }
.rw__track { position: relative; height: 12px; background: var(--sunk); border: 1px solid var(--line-2); border-radius: 2px; }
.rw__zone { position: absolute; top: 0; bottom: 0; }
.rw__zone--halt { background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 6px); opacity: 0.55; }
.rw__zone--block { background: var(--warn-bg); border-left: 1px solid var(--bad); border-right: 1px dashed var(--warn); }
.rw__mark { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 2px solid var(--dim); }
.rw__mark--kill { border-color: var(--bad); }
.rw__mark--now { top: -9px; bottom: -9px; border-left-width: 3px; border-color: var(--ink); margin-left: -1px; }
.rw__label { position: absolute; top: calc(100% + 4px); white-space: nowrap; font-size: 12.5px; color: var(--dim); }
.rw__label b { color: var(--ink); font-weight: 600; }
.rw__mark--now .rw__label { top: auto; bottom: calc(100% + 3px); color: var(--ink); }
[data-side="start"] .rw__label { left: -2px; }
[data-side="end"] .rw__label { right: -2px; }
[data-side="mid"] .rw__label { left: 0; transform: translateX(-50%); }
.runway__key { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--dim); font-size: 12px; }
.key::before { content: ""; display: inline-block; width: 12px; height: 9px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line-2); }
.key--halt::before { background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 5px); }
.key--block::before { background: var(--warn-bg); border-color: var(--warn); }
.key--now::before { width: 3px; background: var(--ink); border: 0; }

.gauges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 28px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.gauge { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 4px 10px; }
.gauge h3 { font-size: 13px; font-weight: 600; color: var(--dim); }
.gauge__val { font-weight: 600; }
.gauge__sub { grid-column: 1 / -1; color: var(--dim); font-size: 12.5px; }
.bar { grid-column: 1 / -1; position: relative; height: 8px; background: var(--sunk); border: 1px solid var(--line); border-radius: 2px; }
.bar__fill { display: block; height: 100%; width: 0; background: var(--dim); }
.bar[data-tone] .bar__fill { background: var(--tone, var(--dim)); }
.bar__tick { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px solid var(--ink); }
.pips { grid-column: 1 / -1; display: flex; gap: 4px; height: 8px; }
.pip { flex: 1; border: 1px solid var(--line-2); border-radius: 2px; background: var(--sunk); }
.pip--on { background: var(--ink); border-color: var(--ink); }
.pips[data-tone] .pip--on { background: var(--tone, var(--ink)); border-color: var(--tone, var(--ink)); }

/* chart + side stats */

.range { display: inline-flex; margin-left: auto; }
.range button { border-radius: 0; margin-left: -1px; padding: 3px 10px; }
.range button:first-child { border-radius: 4px 0 0 4px; }
.range button:last-child { border-radius: 0 4px 4px 0; }
.range button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.chart__wrap { position: relative; height: 290px; }
.chart__svg { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chart__empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-axis { fill: var(--dim); font-size: 11.5px; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.c-area { fill: var(--accent); opacity: 0.08; }
.c-halt { fill: var(--bad); opacity: 0.1; }
.c-ref { stroke-width: 1.25; stroke-dasharray: 5 4; }
.c-ref--base { stroke: var(--dim); }
.c-ref--kill { stroke: var(--bad); stroke-dasharray: none; }
.c-ref-label { font-size: 11.5px; font-weight: 600; fill: var(--dim); }
.c-ref-label--kill { fill: var(--bad); }
.c-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.c-cross { stroke: var(--line-2); stroke-width: 1; }
.c-hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; z-index: 2; display: grid; gap: 1px; padding: 6px 9px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 4px; font-size: 12.5px; pointer-events: none; white-space: nowrap; }
.tip span { color: var(--dim); }
.side__h { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.stats { margin-top: 8px; }
.stats div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.stats div:last-child { border-bottom: 0; }
.stats dt { color: var(--dim); }
.stats dd { font-weight: 600; text-align: right; }

/* tables */

.scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.scroll--capped { max-height: 520px; overflow-y: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 7px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid .wrap, .grid .verdict-cell, .grid .ind { white-space: normal; }
.wrap { min-width: 13em; }
.grid th:first-child, .grid td:first-child { padding-left: 0; }
.grid th:last-child, .grid td:last-child { padding-right: 0; }
.grid thead th { position: sticky; top: 0; background: var(--panel); color: var(--dim); font-size: 12.5px; font-weight: 600; white-space: nowrap; border-bottom-color: var(--line-2); }
.grid tbody th { font-weight: 600; white-space: nowrap; }
.grid tbody tr:last-child > * { border-bottom: 0; }
.grid .num { text-align: right; white-space: nowrap; }
.grid td small, .grid th small { display: block; color: var(--dim); font-weight: 400; }
.grid__empty td { color: var(--dim); padding: 14px 0; }
.grid .sym small, .sym small { display: inline; color: var(--dim); font-weight: 400; }
.verdict-cell { min-width: 15em; max-width: 30em; }
.verdict { font-weight: 700; letter-spacing: 0.03em; color: var(--ink); }
.ind { color: var(--dim); font-size: 12.5px; min-width: 12em; }
.ind span { display: inline-block; margin-right: 10px; white-space: nowrap; }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 3px; font-size: 12px; color: var(--dim); white-space: nowrap; }
.tag[data-tone], .advisories [data-tone] { color: var(--tone, var(--dim)); border-color: var(--tone, var(--line-2)); background: var(--tone-bg, transparent); }

.medal { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: 12px; color: var(--dim); }
.medal--1 { background: #e8c35a; color: #3a2a00; }
.medal--2 { background: #c9d0d8; color: #1f2933; }
.medal--3 { background: #d39a6a; color: #3a1d06; }
.spark { display: block; }
.spark__line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark__line--down { stroke: var(--bad); }
.spark__none { stroke: var(--line-2); stroke-dasharray: 3 3; }

/* desk */

.desk__summary { max-width: 85ch; }
.advisories { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.advisories li { padding: 4px 9px; border: 1px solid var(--line-2); border-radius: 4px; max-width: 42ch; }
.advisories small { color: var(--dim); }
.why { display: block; color: var(--dim); font-size: 12.5px; }
.sub-h { font-size: 13px; font-weight: 600; color: var(--dim); margin-top: 6px; }
.list { display: grid; gap: 6px; margin-top: 6px; }
.desk__value { margin-top: 12px; max-width: 95ch; }
.desk__transcript { margin-top: 12px; }
.desk__transcript summary { cursor: pointer; font-weight: 600; }
.turn { margin-top: 10px; }
.turn h4 { font-size: 13px; text-transform: capitalize; }
.turn pre { margin-top: 4px; padding: 8px 10px; max-height: 320px; overflow: auto; background: var(--sunk); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }

/* footer */

.foot { max-width: 1440px; margin: 0 auto; padding: 4px 16px 32px; color: var(--dim); font-size: 12.5px; }
.foot__h { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.params { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-bottom: 10px; }
.params div { display: flex; gap: 6px; }
.params dd { color: var(--ink); font-weight: 600; }

/* login */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 340px; }
.login__card { display: grid; gap: 14px; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.login__brand { font-size: 17px; }
.login__lede { color: var(--dim); font-size: 13px; margin-top: -8px; }
.login__field { display: grid; gap: 5px; }
.login__label { color: var(--dim); font-size: 13px; font-weight: 600; }
.login__field input { font: inherit; color: var(--ink); background: var(--sunk); border: 1px solid var(--line-2); border-radius: 4px; padding: 8px 10px; }
.login__submit { font: inherit; font-weight: 650; color: var(--panel); background: var(--ink); border: 1px solid var(--ink); border-radius: 4px; padding: 9px; cursor: pointer; }
.login__submit:disabled { opacity: 0.6; cursor: progress; }
.login__error { padding: 8px 10px; border-left: 3px solid var(--bad); background: var(--bad-bg); color: var(--ink); }

/* small screens */

@media (max-width: 960px) {
  .span-8, .span-4 { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .gauges { grid-template-columns: 1fr; gap: 14px; }
  .risk__kill { margin-left: 0; }
  .risk__equity { font-size: 28px; }
  .chart__wrap { height: 230px; }
  .state__why { white-space: normal; }
}
@media (max-width: 480px) {
  .main { padding: 10px; gap: 10px; }
  .panel { padding: 12px; }
  .risk { padding: 14px 12px; }
  .scroll { margin: 0 -12px; padding: 0 12px; }
  .top { padding: 8px 10px; gap: 6px 12px; }
  .banner { margin: 10px 10px 0; }
  .foot { padding: 4px 10px 24px; }
}
