:root {
  --bg: #f5f6f8; --card: #ffffff; --ink: #15171c; --muted: #6b7280; --line: #e3e5ea;
  --pos: #12805c; --neg: #c2362f; --warn: #b7791f; --accent: #2a78d6; --soft: #eef2f8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b21; --ink: #e8eaee; --muted: #9aa1ad; --line: #2a2e36;
    --pos: #3fbf8f; --neg: #ef6a5f; --warn: #e0a84a; --accent: #5b9dff; --soft: #1f2530; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
button, select, input { font: inherit; color: inherit; }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 22px; margin: 0 0 8px; }
.login input { font-size: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.login button, .btn { padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600; min-height: 44px; }
.btn.danger { background: var(--neg); }
.err { color: var(--neg); min-height: 1em; margin: 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 8px 12px; border-radius: 8px; min-height: 36px; }
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--pos); } .dot.bad { background: var(--neg); }
.controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; padding: 8px 16px; max-width: 760px; margin: 0 auto; }
.controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; min-width: 0; }
.controls select { width: 100%; font-size: 16px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }

main { padding: 8px 16px 96px; max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; border: 0; background: none; padding: 12px 2px; min-height: 52px; font-size: 13px; color: var(--muted); }
.tabs button.on { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .03em; }
.hero { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv .k { font-size: 12px; color: var(--muted); } .kv .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); } .muted { color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcard { cursor: pointer; }
.pcard .sym { font-weight: 700; font-size: 17px; }
.pcard .pnl { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--soft); font-variant-numeric: tabular-nums; }
.badge.warn { background: rgba(224,168,74,.18); } .badge.neg { background: rgba(239,106,95,.16); } .badge.pos { background: rgba(63,191,143,.16); }
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--soft); margin-top: 10px; overflow: hidden; }
.bar > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; background: var(--pos); }
.bar > i.w { background: var(--warn); } .bar > i.n { background: var(--neg); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td:last-child { text-align: right; }
.log-item { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-item .t { font-size: 12px; color: var(--muted); }
.lvl-alert, .lvl-error { color: var(--neg); } .lvl-warn { color: var(--warn); }
svg.chart { width: 100%; height: 170px; display: block; }
svg.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; }
svg.chart .ar { fill: var(--accent); opacity: .08; }
svg.chart .gl { stroke: var(--line); stroke-width: 1; }
svg.chart .ref { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1; }
svg.chart .stop { stroke: var(--neg); stroke-dasharray: 4 4; stroke-width: 1; }
svg.chart text { fill: var(--muted); font-size: 11px; }
.range { display: flex; gap: 6px; margin-bottom: 6px; }
.range button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 10px; font-size: 13px; }
.range button.on { border-color: var(--accent); color: var(--accent); }
.back { border: 0; background: none; color: var(--accent); padding: 8px 0; font-size: 15px; min-height: 44px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
details summary { cursor: pointer; padding: 6px 0; color: var(--accent); }
