:root {
  --bg: #0d1016;
  --panel: #151a22;
  --panel-2: #1b212b;
  --line: #262e3b;
  --text: #e8edf4;
  --muted: #8f9aab;
  --accent: #f0483e;
  --accent-ink: #fff;
  --gold: #ffcb3d;
  --good: #3ecf8e;
  --warn: #f5a524;
  --bad: #ff6b61;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --panel: #ffffff;
    --panel-2: #f0f2f6;
    --line: #dfe3ea;
    --text: #161b24;
    --muted: #5d6878;
    --accent: #d93a31;
    --gold: #b98300;
    --good: #128a57;
    --warn: #a86400;
    --bad: #c42b22;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
a { color: inherit; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 16px; }

.top { border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; align-items: center; gap: 14px; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -0.01em; }
.pill { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.on { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.pill.off { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 13px; text-decoration: none; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--accent); }
.tabs .sep { width: 1px; background: var(--line); margin: 9px 8px; }

main { padding-top: 24px; padding-bottom: 40px; flex: 1; outline: none; }
.foot { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; padding-top: 16px; padding-bottom: 24px; border-top: 1px solid var(--line); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card > h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn { text-decoration: none; display: inline-block; font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 10px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
input:focus { border-color: var(--muted); }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }

/* Server page */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.hero-main { padding: 28px; display: grid; gap: 22px; align-content: start; }
.hero-state { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.05; }
.hero-state.on { color: var(--good); }
.hero-state.off { color: var(--bad); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 16px; }
.fact b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.fact span { color: var(--muted); font-size: 13px; }
.address { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 16px; }
.address code { font: 600 17px ui-monospace, "Cascadia Code", Consolas, monospace; flex: 1; overflow-wrap: anywhere; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; counter-increment: step; }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.steps b { display: block; }

.people { display: flex; flex-wrap: wrap; gap: 10px; }
.person { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px 6px 6px; font-weight: 600; text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--line); image-rendering: pixelated; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.avatar.big { width: 56px; height: 56px; border-radius: 12px; font-size: 22px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; flex: none; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.mapframe { width: 100%; height: min(72vh, 760px); min-height: 420px; border: 1px solid var(--line); border-radius: 12px; background: #000; display: block; margin-top: 14px; }
.steps p { margin-top: 10px; }

/* Charts */
.chart svg { width: 100%; height: auto; display: block; }
.chart .area { fill: var(--accent); opacity: 0.14; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart.gold .area { fill: var(--gold); }
.chart.gold .line { stroke: var(--gold); }
.chart.green .area { fill: var(--good); }
.chart.green .line { stroke: var(--good); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; border-top: 0; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td.r, th.r { text-align: right; }
th button { all: unset; cursor: pointer; }
th button:hover, th[aria-sort] button { color: var(--text); }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--panel-2); }
.rank { color: var(--muted); width: 1%; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Trainer detail */
.trainer-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.trainer-head h2 { font-size: 24px; }
.party { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.mon { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.mon b { display: block; }
.mon.shiny { border-color: var(--gold); }
.badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); text-transform: uppercase; letter-spacing: 0.05em; }

/* Tiles and meters */
.tile b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 2px; }
.tile small { color: var(--muted); font-size: 13px; }
progress { width: 100%; height: 6px; border: 0; border-radius: 99px; overflow: hidden; background: var(--line); margin-top: 10px; display: block; appearance: none; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--good); }
progress::-moz-progress-bar { background: var(--good); }
progress.warn::-webkit-progress-value { background: var(--warn); }
progress.warn::-moz-progress-bar { background: var(--warn); }
progress.bad::-webkit-progress-value { background: var(--bad); }
progress.bad::-moz-progress-bar { background: var(--bad); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.feed li { display: flex; gap: 10px; align-items: baseline; }
.feed time { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
.ok { color: var(--good); }
.fail { color: var(--bad); }

/* Console */
.console { background: #07090d; color: #cfd6e2; border: 1px solid var(--line); border-radius: 12px; font: 12.5px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; height: min(62vh, 620px); overflow: auto; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.console .warnline { color: #f5c26b; }
.console .errline { color: #ff8a80; }
.console .cmd { color: #7fd1ff; }
.console .out { color: #9be7b4; }
.cmdbar { display: flex; gap: 10px; margin-top: 12px; }
.cmdbar input { flex: 1; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-weight: 600; }
.list li:first-child { border-top: 0; }
.addrow { display: flex; gap: 8px; margin-top: 12px; }
.addrow input { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; }

dialog { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius); padding: 24px; width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: grid; gap: 12px; }
dialog input { width: 100%; }
.error { color: var(--bad); font-size: 13.5px; min-height: 1.2em; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px); z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero-state { font-size: 32px; }
  .hero-main { padding: 20px; }
  .wrap { padding: 0 16px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
