:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16202a;
  --muted: #5d6b79;
  --line: #e2e6eb;
  --accent: #159451;
  --accent-text: #ffffff;
  --bad: #b3261e;
  --warn: #8a5a00;
  --bar: #159451;
  --bar2: #3b6fb6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1418;
    --card: #182028;
    --text: #e8edf2;
    --muted: #93a1b0;
    --line: #2a3541;
    --accent: #4ecb82;
    --accent-text: #06231a;
    --bad: #ff8a80;
    --warn: #f2c063;
    --bar: #4ecb82;
    --bar2: #7aa7e6;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
a { color: var(--accent); }
[hidden] { display: none !important; }
svg.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 320px; display: grid; gap: .5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
label { font-weight: 600; font-size: .9rem; }
input, select { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: .5rem .85rem; display: inline-flex; align-items: center; gap: .4rem; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; justify-content: center; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }
.error { color: var(--bad); min-height: 1.4em; margin: 0; font-size: .9rem; }
.ok { color: var(--accent); }
.muted { color: var(--muted); }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { margin-right: 4px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { padding: .4rem .75rem; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap; }
nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; }
.view { max-width: 1080px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; outline: none; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1 { margin: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .8rem; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover { background: var(--bg); }
tr.click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 200px; }
.toolbar select, .head select { width: auto; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.pill { display: inline-block; padding: .05rem .55rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; }
.chart { width: 100%; height: auto; }
.chart rect, .chart text { stroke: none; }
.chart text { fill: var(--muted); font-size: 10px; }
.empty { color: var(--muted); padding: 1.5rem 0; text-align: center; }
.qr { display: block; width: 260px; max-width: 100%; height: auto; background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.setting { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.setting input { max-width: 320px; }
.setting .hint { font-size: .8rem; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.dot.ready { background: var(--accent); }
.dot.qr, .dot.starting { background: var(--warn); }
.dot.logged_out, .dot.disconnected { background: var(--bad); }
@media (max-width: 640px) {
  .bar { padding: 8px 12px; }
  .view { padding: 12px; }
  .brand { display: none; }
  button.ghost span { display: none; }
}
