/* EPBoost: dark-first operations tool. Tokens first, everything else derives from them. */
:root {
  --bg: #0f1216; --panel: #161b22; --panel2: #1c232c; --line: #262e38; --fg: #e6e9ee; --mut: #8b95a3;
  --accent: #f2b544; --accent2: #6aa6ff; --ok: #3fc380; --bad: #ff6b6b; --warn: #f2b544;
  --bar: #2b3542; --bar-last: #f2b544; --spark: #3a4656;
  --radius: 8px; --gap: 12px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f7; --panel: #ffffff; --panel2: #f0f2f5; --line: #dde2e8; --fg: #1a1f26; --mut: #66707d;
          --accent: #b97a08; --accent2: #2b63c6; --ok: #1e8f58; --bad: #c93c3c; --warn: #b97a08;
          --bar: #e3e7ec; --bar-last: #e6a21a; --spark: #c9d0d8; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 var(--gap); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
h3.group { font-size: 13px; font-weight: 500; margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
.mut { color: var(--mut); } .small { font-size: 12px; } .right { margin-left: auto; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid var(--bad); padding: 8px 12px; border-radius: var(--radius); }
.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid var(--ok); padding: 8px 12px; border-radius: var(--radius); }
.page { max-width: 1480px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: var(--gap); }

.top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--mut); padding: 6px 10px; border-radius: 6px; }
.nav a.on { color: var(--fg); background: var(--panel2); }
.nav a:hover { text-decoration: none; color: var(--fg); }
.logout { margin-left: auto; }
button, input, select { font: inherit; color: var(--fg); }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--mut); }
button.danger { color: var(--bad); }
button.link { background: none; border: 0; color: var(--mut); padding: 0; }
button.link:hover { color: var(--fg); }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=number], input:not([type]) {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }

.period { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--mut); border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--fg); color: var(--bg); }
.seg a:hover { text-decoration: none; }
.range { display: inline-flex; gap: 6px; align-items: center; }

.strip { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: var(--gap); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); }
.tile .big { font-size: 24px; font-weight: 600; line-height: 1.15; }
.tile .sub { font-size: 12px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--gap); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card > p.small { margin: 0 0 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.toolbar h2 { margin: 0; }
.chk { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; cursor: pointer; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.head-row h1 { margin: 0; }

.chart { display: block; width: 100%; height: auto; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--mut); }
.chart .val { fill: var(--fg); }
.chart .grid { stroke: var(--line); }
.chart .axis { stroke: var(--line); }
.chart .bar { fill: var(--bar); }
.chart .bar.last { fill: var(--bar-last); }
.chart .bar:hover { fill: var(--accent2); }
.chart .line { fill: none; stroke: var(--accent2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--accent2); }
.chart .dot.last { fill: var(--accent); }
.spark .sb { fill: var(--spark); } .spark .sb.last { fill: var(--accent); }
.hbar { vertical-align: middle; margin-right: 6px; }
.hbar .hb-bg { fill: var(--bar); } .hbar .hb-fg { fill: color-mix(in srgb, var(--accent) 55%, var(--bar)); }

.tablebox { overflow: auto; max-height: 78vh; }
.tablebox.short { max-height: 420px; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
.t th, .t td { padding: 6px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.t th { position: sticky; top: 0; background: var(--panel); color: var(--mut); font-weight: 500; z-index: 1; user-select: none; }
.t th[data-sort] { cursor: pointer; }
.t th[data-sort]:hover { color: var(--fg); }
.t th.desc::after { content: " ↓"; } .t th.asc::after { content: " ↑"; }
.t .l { text-align: left; }
.t td.cc { font-weight: 600; } .t td.cc small { font-weight: 400; color: var(--mut); margin-left: 6px; }
.t td.bar { min-width: 190px; }
.t tbody tr[data-href] { cursor: pointer; }
.t tbody tr[data-href]:hover { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.t tr.mut td { color: var(--mut); }
.t tr.hide { display: none; }
.tag { color: var(--accent); font-weight: 500; margin-left: 6px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; background: color-mix(in srgb, currentColor 12%, transparent); font-size: 12px; line-height: 1.5; white-space: nowrap; }
.q-down { color: var(--bad); } .q-down_weak { color: var(--warn); } .q-up { color: var(--ok); } .q-up_weak { color: var(--ok); } .q-flat, .q-low { color: var(--mut); }
.v-down { color: var(--warn); } .v-up { color: var(--accent2); } .v-flat, .v-none, .v-new { color: var(--mut); }
.pill.q-up_weak { opacity: .8; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--gap); }
.note { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.note.q-down { border-left-color: var(--bad); color: var(--fg); }
.note.q-up { border-left-color: var(--ok); color: var(--fg); }
.note.q-down_weak { border-left-color: var(--warn); color: var(--fg); }
.note.q-flat, .note.q-low, .note.q-up_weak { color: var(--fg); }
.note .head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.note .geo { font-size: 18px; font-weight: 700; color: var(--fg); }
.note .text, .text { margin: 0; line-height: 1.5; }
.note .act, .act { margin: 0; color: var(--mut); line-height: 1.5; }
.act b { color: var(--fg); font-weight: 600; }
.note.hide { display: none; }

.auth { max-width: 360px; margin: 10vh auto 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.auth.wide { max-width: 480px; }
.auth form, .stack { display: flex; flex-direction: column; gap: 10px; }
.auth label, .stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mut); }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.inline input[type=number] { width: 70px; }
.qr { background: #fff; padding: 8px; border-radius: 6px; width: max-content; }
.qr svg { display: block; width: 220px; height: 220px; }
code { background: var(--panel2); padding: 2px 6px; border-radius: 4px; }

@media (max-width: 820px) { .t .sec { display: none; } .top { gap: 10px; padding: 8px 12px; } .nav a { padding: 6px 8px; } }
@media (prefers-reduced-motion: no-preference) { .chart .bar, .nav a, button { transition: fill .15s, background .15s, color .15s; } }
