:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #191919;
  --surface-2: #222326;
  --border: #2e3035;
  --text: #efefef;
  --text-2: #9c9c9c;
  --accent: #338ced;     /* series / sequential blue, dark step */
  --accent-dim: #1757ac;
  --good: #3fae6a;
  --warn: #d9a43b;
  --bad: #e5534b;
  --yes: #3fae6a;
  --no: #e5534b;
  --band: rgba(51, 140, 237, 0.10);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
h2 .muted { font-weight: 400; margin-left: 6px; }
.mt { margin-top: 18px; }
button, input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; }
input[type=checkbox] { padding: 0; accent-color: var(--accent); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; }
button.link { background: none; border: 0; color: var(--text-2); }
button.link:hover { color: var(--text); }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; white-space: nowrap; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: none; border: 0; color: var(--text-2); padding: 6px 12px; border-radius: 6px; }
nav button:hover { color: var(--text); }
nav button.on { color: var(--text); background: var(--surface-2); }
.right { display: flex; gap: 12px; align-items: center; }
.right form { margin: 0; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.pill.good { color: var(--good); }
.pill.bad { color: var(--bad); }

main { padding: 18px 20px 40px; max-width: 1700px; margin: 0 auto; }
.tab { display: none; }
.tab.on { display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; min-width: 0; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.scroll { overflow-x: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--text-2); }
.filters input[type=number] { width: 90px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .k { color: var(--text-2); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; cursor: pointer; user-select: none; }
.tbl th.sa::after { content: " ▲"; }
.tbl th.sd::after { content: " ▼"; }
.tbl td { padding: 5px 8px; border-bottom: 1px solid #23252a; white-space: nowrap; }
.tbl tbody tr[data-cid] { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; }
.tbl td.hl { color: var(--accent); font-weight: 600; }
.tbl.kv td:first-child { color: var(--text-2); }
.tbl.kv td { white-space: normal; }
.tbl.kv th { cursor: default; }
.ev { color: var(--text-2); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.tag.yes { color: var(--yes); }
.tag.no { color: var(--no); }
.tag.warn { color: var(--warn); }

/* bars */
.bars { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; }
.bar { display: grid; grid-template-columns: 110px 1fr 70px; gap: 8px; align-items: center; font-size: 12px; padding: 2px 0; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: capitalize; }
.bar .track { height: 12px; }
.bar .fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar .val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar:hover .fill { background: #5aa3f2; }

/* line chart */
.chart svg { display: block; }
.chart .grid { stroke: #2a2c31; stroke-width: 1; }
.chart .axis { fill: var(--text-2); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .xh { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: #2a2c31; border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 12px; max-width: 280px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }

/* market */
.mhead { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.mhead .big { font-size: 22px; font-weight: 650; }
.kvs { display: grid; grid-template-columns: repeat(2, auto); gap: 4px 20px; align-content: center; }
.ladder td { padding: 3px 8px; }
.ladder tr.ask td:first-child { color: var(--no); }
.ladder tr.bid td:first-child { color: var(--yes); }
.ladder tr.band { background: var(--band); }
.ladder td.depth { width: 40%; }
.ladder td.depth span { display: block; height: 10px; border-radius: 0 3px 3px 0; }
.ladder tr.ask td.depth span { background: rgba(229, 83, 75, .45); }
.ladder tr.bid td.depth span { background: rgba(63, 174, 106, .45); }
.ladder tr.midrow td { text-align: center; color: var(--text-2); font-size: 12px; padding: 6px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter span.bad { background: var(--bad); }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); font-size: 12px; }
.login-card input { padding: 8px 10px; }
.login-card button { background: var(--accent); border-color: var(--accent); color: #fff; padding: 9px; font-weight: 600; margin-top: 6px; }
.err { color: var(--bad); margin: 0; font-size: 13px; }
