.viz-root {
  color-scheme: dark;
  --bg: #111214;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --muted: #8d8c84;
  --grid: #2c2c29;
  --series-1: #3987e5;
  --series-2: #d95926;
  --spy: #9a988f;
  --win: #3987e5;
  --loss: #e66767;
  --warn: #c98500;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; }
header { padding: 14px 20px 8px; }
h1 { margin: 0; font-size: 20px; }
h1 small { font-size: 13px; color: var(--muted); font-weight: normal; margin-left: 8px; }
.warn { margin: 6px 0 0; color: var(--text-secondary); font-size: 13px; border-left: 3px solid var(--warn); padding-left: 8px; }
#app { display: grid; grid-template-columns: 340px 1fr; gap: 14px; padding: 8px 20px 30px; align-items: start; }
aside { position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; background: var(--surface-1);
  border-radius: 8px; padding: 12px 14px; }
main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface-1); border-radius: 8px; padding: 12px 16px; }
.card.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
h2 { font-size: 15px; margin: 0 0 6px; }
h2 small, .muted { color: var(--muted); font-weight: normal; font-size: 12px; }
h3 { font-size: 13px; margin: 16px 0 6px; color: var(--text-secondary); border-bottom: 1px solid var(--grid); padding-bottom: 3px; }
button { background: var(--series-1); color: #fff; border: 0; border-radius: 6px; padding: 5px 10px; font: inherit; cursor: pointer; }
button.ghost, .presets button { background: var(--surface-2); color: var(--text-primary); }
.presets button.on { outline: 1px solid var(--series-1); }
.presets { display: flex; gap: 8px; }
.kinds { margin: 10px 0 0; display: flex; gap: 14px; font-size: 13px; }
.f { margin: 8px 0 2px; }
.f.off .fv { color: var(--muted); }
.f.na { opacity: .4; }
.fl { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-secondary); gap: 6px; }
.fv { color: var(--text-primary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fl span[title] { border-bottom: 1px dotted var(--muted); cursor: help; }
input[type=range] { width: 100%; margin: 2px 0 0; accent-color: var(--series-1); }
canvas.spark { display: block; width: 100%; height: 30px; cursor: crosshair; }
.sparktip { font-size: 11px; color: var(--muted); height: 14px; white-space: nowrap; overflow: hidden; }
.sel { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; font-size: 12.5px; color: var(--text-secondary); }
select { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--grid); border-radius: 5px; padding: 3px 6px; font: inherit; }
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; }
.sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin: 0 3px 0 8px; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); } .sw.spy { background: var(--spy); }
.sw.win { background: var(--win); height: 9px; } .sw.loss { background: var(--loss); height: 9px; }
.legend { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.chartwrap { position: relative; }
.chartwrap canvas { display: block; width: 100%; }
.tip { position: absolute; pointer-events: none; background: rgba(20,20,19,.95); border: 1px solid var(--grid); border-radius: 6px;
  padding: 5px 8px; font-size: 12px; color: var(--text-primary); display: none; white-space: nowrap; z-index: 5; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#stats table td, #stats table th { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
#stats table th { color: var(--text-secondary); font-weight: normal; }
#stats table td:first-child, #stats table th:first-child { text-align: left; color: var(--text-secondary); }
#stats tr.big td { font-size: 17px; font-weight: 600; }
#stats tr.big td:first-child { font-size: 14px; font-weight: normal; }
#stats .sub { color: var(--muted); font-size: 12px; }
.pos { color: #7fb4f2; } .neg { color: var(--loss); }
#alerts p { margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); }
#alerts p::before { content: "⚠ "; color: var(--warn); }
.tablewrap { max-height: 460px; overflow: auto; }
#trades th { position: sticky; top: 0; background: var(--surface-1); cursor: pointer; color: var(--text-secondary); font-weight: normal; }
#trades th, #trades td { padding: 3px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; font-size: 13px; }
#trades td:nth-child(2), #trades th:nth-child(2), #trades td:nth-child(3) { text-align: left; }
#trades tbody tr { cursor: pointer; }
#trades tbody tr:hover { background: var(--surface-2); }
#trades .dim { color: var(--muted); }
#compare table td, #compare table th { padding: 3px 6px; text-align: right; font-size: 12.5px; border-bottom: 1px solid var(--grid); }
#compare table th { color: var(--text-secondary); font-weight: normal; }
#compare table td:first-child { text-align: left; color: var(--text-secondary); white-space: nowrap; }
#compare table th { white-space: nowrap; }
#compare tr.cur td { background: var(--surface-2); color: var(--text-primary); }
#compare tr.sep td { border-bottom: 1px solid var(--muted); }
.about ul { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 13px; }
.about li { margin: 4px 0; }
#kpanel { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; display: flex; align-items: center; justify-content: center; }
#kpanel[hidden] { display: none; }
.kbox { background: var(--surface-1); border-radius: 10px; width: min(1200px, 96vw); padding: 12px 16px; max-height: 96vh; overflow: auto; }
.khead { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
#kinfo { font-size: 13px; color: var(--text-secondary); }
#kinfo b { color: var(--text-primary); font-size: 15px; }
.kbtns { display: flex; gap: 8px; flex-shrink: 0; }
#kfeat { margin-top: 6px; }
@media (max-width: 900px) {
  #app { display: flex; flex-direction: column; padding: 8px 10px 30px; }
  main { display: contents; }
  #statsCard { order: 1; } aside { order: 2; } main > .card:not(#statsCard) { order: 3; }
  aside { position: static; max-height: none; width: 100%; }
  .card.two { grid-template-columns: 1fr; }
  header { padding: 12px 12px 4px; }
  #stats table td, #stats table th { padding: 4px 5px; }
}
