/* Layout: control rail left, chart + stat ledger right; stacks to one column on phones */
:root {
  --bg: #f5f6f7; --panel: #ffffff; --ink: #14171b; --ink-2: #4f5660; --muted: #858c96;
  --line: #e1e4e8; --grid: #edf0f2; --bench: #7e858f; --wash: #eef3fb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #101215; --panel: #171a1e; --ink: #eceef0; --ink-2: #b3b8bf; --muted: #868c95;
  --line: #2a2e34; --grid: #20242a; --bench: #9ba1a9; --wash: #1a2433;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  color-scheme: dark } }
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
.wrap { padding-block: 20px 40px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); display: grid; gap: 16px; }
header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.sub { color: var(--ink-2); margin: 2px 0 0; max-width: 68ch; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); }
.seg button { font: inherit; border: 0; background: none; color: var(--ink-2); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--ink); font-weight: 500; }
.btn:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.filters label { color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tune { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .tune { grid-template-columns: minmax(0, 1fr); } }
.knobs { padding: 16px; display: grid; gap: 16px; }
.knobs h2, .card h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 500; margin: 0; }
.knob { display: grid; gap: 4px; }
.knob .top { display: flex; justify-content: space-between; gap: 8px; }
.knob .top label { color: var(--ink-2); }
.stack { display: grid; gap: 16px; }
.stack[hidden], [hidden] { display: none !important; }
.knob output { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.knob input[type=range] { width: 100%; accent-color: var(--s1); }
.hint { color: var(--muted); font-size: 12px; }
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn.primary { background: var(--s1); border-color: var(--s1); color: #fff; font-weight: 500; }
.card { padding: 14px 16px 10px; display: grid; gap: 10px; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 16px; height: 0; border-top: 2px solid; display: inline-block; }
.key.dash { border-top-style: dashed; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); min-width: 170px; display: grid; gap: 3px; z-index: 2; }
.tip .d { color: var(--muted); font-family: var(--mono); }
.tip .row { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; }
.tip .row b { font-family: var(--mono); font-weight: 500; text-align: right; }
.tip .row i { font-style: normal; font-family: var(--mono); color: var(--muted); text-align: right; min-width: 52px; }
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.stat { padding: 10px 12px 4px 0; display: grid; gap: 2px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; }
.stat .b { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.stat .delta { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.cmpknobs { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; }
.cmpknobs .knob { width: 170px; }
.cmpknobs .knob .top { white-space: nowrap; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; cursor: pointer; user-select: none; }
th:first-child, td:first-child { text-align: left; }
td { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.name { font-family: var(--font); }
td.name label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
tr.off td { color: var(--muted); }
tr.draft td { background: var(--wash); }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
.note { color: var(--muted); font-size: 12px; max-width: 80ch; }
.strategies { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 6px; font-size: 13px; }
.strategies a { color: var(--muted); text-decoration: none; }
.strategies a[aria-current] { color: var(--s1); font-weight: 500; }
#tradesA { border-top: 1px solid var(--line); padding-top: 8px; }
#trades td.name:nth-child(2), #trades td.name:last-child { color: var(--ink-2); }
