:root {
  --bg: oklch(97.5% 0.008 85);
  --surface: oklch(99.5% 0.004 85);
  --surface-2: oklch(95% 0.01 85);
  --line: oklch(89% 0.012 85);
  --text: oklch(24% 0.02 160);
  --muted: oklch(50% 0.02 160);
  --accent: oklch(45% 0.09 165);
  --accent-ink: oklch(98% 0.01 165);
  --accent-soft: oklch(92% 0.04 165);
  --gold: oklch(72% 0.12 80);
  --red: oklch(52% 0.17 28);
  --red-soft: oklch(94% 0.03 28);
  --amber-soft: oklch(94% 0.05 85);
  --in: oklch(55% 0.11 160);
  --out: oklch(62% 0.14 45);
  --shadow: 0 1px 2px oklch(20% 0.02 160 / 0.06), 0 6px 20px oklch(20% 0.02 160 / 0.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(17% 0.015 165);
    --surface: oklch(21% 0.016 165);
    --surface-2: oklch(25% 0.018 165);
    --line: oklch(31% 0.018 165);
    --text: oklch(93% 0.01 85);
    --muted: oklch(70% 0.015 120);
    --accent: oklch(72% 0.11 165);
    --accent-ink: oklch(18% 0.02 165);
    --accent-soft: oklch(30% 0.04 165);
    --red: oklch(70% 0.15 28);
    --red-soft: oklch(30% 0.06 28);
    --amber-soft: oklch(32% 0.05 85);
    --in: oklch(70% 0.12 160);
    --out: oklch(72% 0.13 50);
    --shadow: 0 1px 2px oklch(0% 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: oklch(17% 0.015 165);
  --surface: oklch(21% 0.016 165);
  --surface-2: oklch(25% 0.018 165);
  --line: oklch(31% 0.018 165);
  --text: oklch(93% 0.01 85);
  --muted: oklch(70% 0.015 120);
  --accent: oklch(72% 0.11 165);
  --accent-ink: oklch(18% 0.02 165);
  --accent-soft: oklch(30% 0.04 165);
  --red: oklch(70% 0.15 28);
  --red-soft: oklch(30% 0.06 28);
  --amber-soft: oklch(32% 0.05 85);
  --in: oklch(70% 0.12 160);
  --out: oklch(72% 0.13 50);
  --shadow: 0 1px 2px oklch(0% 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 "Inter Tight", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; cursor: pointer;
  padding: 10px 16px; background: var(--accent); color: var(--accent-ink); min-height: 40px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 6px 12px; min-height: 32px; font-size: 13.5px; }
.btn-ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn-danger { background: var(--red); color: white; }
.btn-fb { background: oklch(52% 0.17 260); color: white; width: 100%; min-height: 48px; font-size: 16px; }
.icon-btn { font: inherit; font-size: 18px; background: none; border: 0; color: var(--muted); cursor: pointer; width: 36px; height: 36px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; }
.brand-mark span { width: 20px; height: 20px; border-radius: 50%; background: oklch(88% 0.07 80); box-shadow: inset 0 0 0 6px oklch(88% 0.07 80), inset 0 0 0 10px var(--red); }
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; }
.brand-mark.sm span { width: 13px; height: 13px; box-shadow: inset 0 0 0 4px oklch(88% 0.07 80), inset 0 0 0 7px var(--red); }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h1 { font-size: 26px; }
.msg { min-height: 1.4em; margin: 0; font-size: 14px; color: var(--red); }

.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 16px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.top-right { display: flex; gap: 6px; align-items: center; }
.tabs { display: flex; gap: 4px; justify-content: center; }
.tabs button {
  font: inherit; font-weight: 500; background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 8px 12px; border-radius: 9px; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.pill { background: var(--red); color: white; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; }
.tab { display: none; }
.tab.on { display: block; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 14px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .l { font-size: 12.5px; color: var(--muted); }

.chart svg { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .bar { fill: var(--accent); }
.chart .bar.in { fill: var(--in); }
.chart .bar.out { fill: var(--out); }
.chart .bar:hover { opacity: .75; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: "Inter Tight", sans-serif; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin: -4px 0 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.sw.in { background: var(--in); } .sw.out { background: var(--out); }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; margin: 6px 0; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: flex; }
.hbar .fill { height: 100%; background: var(--accent); }
.hbar .fill.in { background: var(--in); } .hbar .fill.out { background: var(--out); }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search { display: flex; gap: 8px; margin-bottom: 14px; }
input[type=search], input[type=number], input[type=text], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; min-height: 40px; width: 100%;
}
input:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 14px; }

.list { display: grid; gap: 8px; }
.item {
  background: var(--surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; cursor: pointer;
  border: 1px solid transparent; text-align: left; font: inherit; color: inherit; width: 100%;
}
.item:hover { border-color: var(--line); }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.item > div { min-width: 0; }
.av { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); object-fit: cover; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tag.live { background: var(--accent-soft); color: var(--accent); }
.tag.bad { background: var(--red-soft); color: var(--red); }
.tag.warn { background: var(--amber-soft); color: var(--text); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg button { font: inherit; border: 0; background: none; padding: 6px 16px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.sheet { position: fixed; inset: 0; z-index: 20; background: oklch(10% 0.01 160 / .45); display: flex; justify-content: flex-end; }
.sheet-panel { background: var(--bg); width: min(680px, 100%); height: 100%; overflow-y: auto; padding: 20px 16px 60px; position: relative; }
.sheet .close { position: absolute; right: 10px; top: 10px; font-size: 26px; }
.sheet h2 { font-size: 22px; padding-right: 40px; }
.sec { margin-top: 18px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.kv div { background: var(--surface); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); min-width: 0; }
.kv b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv span { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl { overflow-x: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); }
.pos { color: var(--in); } .neg { color: var(--red); }
.timeline { display: grid; gap: 6px; }
.ev { background: var(--surface); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: baseline; font-size: 13.5px; }
.ev .seq { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev.SHOT_RESULT { border-left: 3px solid var(--accent); }
.ev.TURN_TIMEOUT { border-left: 3px solid var(--out); }
.board { width: 100%; max-width: 320px; aspect-ratio: 1; display: block; margin: 0 auto; }
pre { background: var(--surface-2); border-radius: 10px; padding: 12px; overflow: auto; font-size: 12px; max-height: 320px; }
.danger-zone { border: 1px solid var(--red-soft); border-radius: 12px; padding: 12px; }

dialog { border: 0; border-radius: 16px; padding: 20px; background: var(--surface); color: var(--text); width: min(420px, calc(100% - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: oklch(10% 0.01 160 / .5); }
dialog h3 { text-transform: none; font-size: 18px; color: var(--text); letter-spacing: -0.01em; }
dialog #cExtra { margin: 10px 0 14px; display: grid; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--red); color: white; }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .top { grid-template-columns: 1fr auto; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; }
  .brand b { font-size: 15px; }
  .hbar { grid-template-columns: 84px 1fr auto; }
  .item { grid-template-columns: auto 1fr; }
  .item .r { grid-column: 2; text-align: left; }
}
