:root {
  --bg: #0e1117; --panel: #161b22; --panel2: #1c2330; --line: #2a3140; --text: #d7dde8; --dim: #8390a5;
  --green: #2ecc71; --red: #ff5c5c; --yellow: #f5c542; --cyan: #3cc7e8; --violet: #b28cff; --orange: #ff9f43;
  --green-bg: rgba(46, 204, 113, .12); --red-bg: rgba(255, 92, 92, .12); --yellow-bg: rgba(245, 197, 66, .14);
  --cyan-bg: rgba(60, 199, 232, .14);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f2f5; --line: #dde1e7; --text: #1d2330; --dim: #6b7486;
  --green: #14964f; --red: #d63031; --yellow: #b7860b; --cyan: #0a84a8; --violet: #6c47d1; --orange: #d9730d;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}
.num, td.num, .mono { font-variant-numeric: tabular-nums; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--dim); }
button.ghost { background: transparent; border-color: transparent; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; }

header#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-left: 4px; }
.dot.on { background: var(--green); } .dot.off { background: var(--red); }
.market { display: flex; gap: 16px; flex-wrap: wrap; }
.market span b { margin-right: 4px; }
.status { color: var(--yellow); flex: 1; text-align: right; }

nav#tabs { position: sticky; top: 41px; z-index: 4; display: flex; gap: 4px; padding: 8px 16px; background: var(--bg);
  border-bottom: 1px solid var(--line); overflow-x: auto; }
nav#tabs button { white-space: nowrap; background: transparent; border-color: transparent; }
nav#tabs button.active { background: var(--panel2); border-color: var(--line); font-weight: 600; }
nav#tabs b { color: var(--dim); font-weight: 500; margin-left: 3px; }

main { padding: 12px 16px 60px; }
footer { position: fixed; bottom: 0; left: 0; right: 0; padding: 4px 16px; font-size: 11px; color: var(--dim);
  background: var(--bg); border-top: 1px solid var(--line); }
h3 { margin: 18px 0 8px; font-size: 14px; }
h3 small { color: var(--dim); font-weight: 400; margin-left: 6px; }
.hint { color: var(--dim); font-size: 12px; margin: 4px 0 10px; max-width: 1100px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.empty { color: var(--dim); padding: 18px 4px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel2); color: var(--dim); font-weight: 600; font-size: 12px;
  cursor: pointer; user-select: none; }
th.sorted::after { content: " ▾"; } th.sorted.asc::after { content: " ▴"; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 260px; max-width: 520px; color: var(--dim); }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
tr.finished td { opacity: .6; }

.up { color: var(--green); } .down { color: var(--red); } .dim { color: var(--dim); } .warn { color: var(--yellow); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent; }
.pill.long { color: var(--green); background: var(--green-bg); }
.pill.short { color: var(--red); background: var(--red-bg); }
.pill.zone { color: var(--yellow); background: var(--yellow-bg); }
.pill.entry { color: var(--cyan); background: var(--cyan-bg); }
.pill.good { color: var(--green); background: var(--green-bg); }
.pill.bad { color: var(--red); background: var(--red-bg); }
.pill.muted { color: var(--dim); border-color: var(--line); }
.src { color: var(--dim); font-size: 11.5px; }
.tp { display: block; }
.bar { position: relative; width: 150px; height: 8px; background: var(--panel2); border-radius: 4px; margin-top: 5px; }
.bar i { position: absolute; top: -2px; width: 2px; height: 12px; background: var(--dim); }
.bar b { position: absolute; top: -3px; width: 10px; height: 14px; border-radius: 3px; margin-left: -5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.box h4 { margin: 0 0 6px; font-size: 13px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.kv span:nth-child(odd) { color: var(--dim); }

aside#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(1100px, 100vw); z-index: 10;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; }
aside#drawer.hidden { display: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); }
#d-title { font-size: 16px; font-weight: 700; }
#d-title small { color: var(--dim); font-weight: 400; margin-left: 8px; font-size: 12px; }
.drawer-tools { display: flex; gap: 6px; }
.tf.active { border-color: var(--cyan); color: var(--cyan); }
#chart { height: 430px; flex: none; position: relative; }
#heat { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
#chart > div { position: relative; z-index: 1; }
.heat-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; opacity: .85; cursor: pointer; }
.family { font-size: 11px; opacity: .75; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 14px; font-size: 11.5px; color: var(--dim);
  border-bottom: 1px solid var(--line); }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; }
#d-body { overflow-y: auto; padding: 4px 14px 30px; }
pre.rich { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; line-height: 1.35; margin: 0;
  padding: 12px; background: #0b0e14; color: #d7dde8; border-radius: 8px; overflow-x: auto; }

@media (max-width: 700px) {
  header#top { gap: 8px; } .status { text-align: left; } nav#tabs { top: 0; position: static; }
  #chart { height: 300px; }
}

/* scenario card (scenarios.py) */
.scen-long, .scen-short { border: 1px solid; border-radius: 6px; padding: 6px 10px; margin: 6px 0; }
.scen-long { border-color: #2ecc71; }
.scen-short { border-color: #ff5c5c; }
