:root {
  --bg: #0b0d10;
  --panel: #13161c;
  --panel-2: #191d25;
  --line: #222833;
  --text: #d6dae2;
  --dim: #6b7280;
  --up: #26c2a0;
  --down: #ef5368;
  --accent: #7aa2ff;
  --of: #ffb347;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button { font: inherit; color: inherit; }
.dim { color: var(--dim); }
.up { color: var(--up); }
.down { color: var(--down); }

#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: 40px 1fr;
  grid-template-areas: 'top top' 'chart wl';
  height: 100vh;
}

#top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  min-width: 0;
}
.spacer { flex: 1 1 0; min-width: 0; }
.sym-badge, .seg, .toggle, .acct, .cand { flex-shrink: 0; }
.sym-badge { display: flex; align-items: baseline; gap: 6px; font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
.sym-badge .venue {
  font-size: 10px; font-weight: 500; color: var(--dim); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; text-transform: uppercase;
}
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.seg button, .toggle {
  background: transparent; border: 0; border-radius: 4px; padding: 4px 7px; cursor: pointer; color: var(--dim);
}
.seg button:hover, .toggle:hover { color: var(--text); background: var(--panel-2); }
.seg button.on { color: #fff; background: #2a3242; }
.toggle { border: 1px solid var(--line); font-weight: 600; }
.toggle.on { color: #0b0d10; background: var(--of); border-color: var(--of); }
#ind.on { background: var(--accent); border-color: var(--accent); }
.toggle[disabled] { opacity: 0.35; cursor: default; }
.acct { display: flex; gap: 8px; font-variant-numeric: tabular-nums; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; }
.cand {
  font-weight: 600; color: #0b0d10; background: #c3e88d; border-radius: 6px; padding: 3px 8px;
}
.tele {
  display: flex; gap: 9px; color: var(--dim); font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace;
  font-size: 10.5px; min-width: 0; overflow: hidden; flex-shrink: 1;
}
.tele span { flex-shrink: 0; }
.tele b { color: var(--text); font-weight: 500; }

#chart { grid-area: chart; position: relative; overflow: hidden; cursor: crosshair; touch-action: none; min-width: 0; }
#chart.dragging { cursor: grabbing; }
#chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#chart canvas[hidden] { display: none; }
#hud { pointer-events: none; }
#toasts { position: absolute; left: 12px; bottom: 32px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast {
  background: rgba(19, 22, 28, 0.94); border: 1px solid var(--line); border-left: 3px solid var(--of);
  padding: 6px 10px; border-radius: 6px; max-width: 420px; animation: fade 5s forwards;
}
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#wl { grid-area: wl; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.wl-group {
  position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--dim);
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.wl-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 54px; align-items: center; gap: 6px;
  padding: 5px 10px; cursor: pointer; border-bottom: 1px solid rgba(34, 40, 51, 0.5); outline: none;
}
.wl-row:hover { background: var(--panel-2); }
.wl-row.sel { background: #1e2633; box-shadow: inset 2px 0 0 var(--accent); }
.wl-name { display: grid; grid-template-columns: minmax(0, max-content) max-content; grid-template-rows: auto auto; column-gap: 5px; align-items: center; min-width: 0; }
.wl-sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-venue { grid-column: 1 / -1; grid-row: 2; color: var(--dim); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-of { justify-self: start; font-size: 9px; font-weight: 700; color: #0b0d10; background: var(--of); border-radius: 3px; padding: 0 3px; }
.wl-price, .wl-chg { font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, monospace; font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.wl-chg.up { color: var(--up); }
.wl-chg.down { color: var(--down); }
.tick-up { animation: tu 0.6s; }
.tick-down { animation: td 0.6s; }
@keyframes tu { from { color: var(--up); } }
@keyframes td { from { color: var(--down); } }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 40px 1fr 200px; grid-template-areas: 'top' 'chart' 'wl'; }
  .tele { display: none; }
}
