:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #dcdfe4;
  --text: #1b1f24;
  --muted: #656d76;
  --accent: #1b5fb3;
  --accentText: #ffffff;
  --danger: #b3261e;
  --ok: #1e7f3c;
  --warn: #9a6700;
  --row: #f2f4f7;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 6px;
  --s0: 0px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0f1115;
  --surface: #171a21;
  --border: #2b3040;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #5b9cf6;
  --accentText: #0f1115;
  --danger: #f28b82;
  --ok: #6fd38b;
  --warn: #f2c94c;
  --row: #1d212b;
} }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

/* # Layout */
.hbox { display: flex; flex-direction: row; gap: var(--s3); align-items: center; }
.vbox { display: flex; flex-direction: column; gap: var(--s3); }
.grow { flex-grow: 1; }
.wrap { flex-wrap: wrap; }
.hide { display: none !important; }

.app { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }
.topbar { display: flex; align-items: center; gap: var(--s4); padding: var(--s2) var(--s4);
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar nav { display: flex; gap: var(--s3); }
.topbar nav a { color: var(--muted); padding: var(--s1) var(--s2); border-radius: var(--radius); }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--row); text-decoration: none; }
.page { width: min(1100px, 100%); margin: 0 auto; padding: var(--s5) var(--s4); display: flex;
  flex-direction: column; gap: var(--s5); }
.page h1 { font-size: 22px; font-weight: 650; }
.page h2 { font-size: 16px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4);
  display: flex; flex-direction: column; gap: var(--s3); }
.card header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.card header h2 { margin: 0; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s4); }

/* # Table */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tbody tr:hover { background: var(--row); }
td.num, th.num { text-align: right; }
.empty { color: var(--muted); font-style: italic; padding: var(--s4); text-align: center; }

/* # Controls */
button, .button { font: inherit; padding: var(--s2) var(--s4); border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; }
button:hover, .button:hover { background: var(--row); text-decoration: none; }
button.primary { background: var(--accent); color: var(--accentText); border-color: transparent; }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea { font: inherit; padding: var(--s2) var(--s3); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.field { display: flex; flex-direction: column; gap: var(--s1); }
label.field span { font-size: 13px; color: var(--muted); }
form.form { display: flex; flex-direction: column; gap: var(--s3); max-width: 420px; }
.actions { display: flex; gap: var(--s2); justify-content: flex-end; }

/* # Badges / state */
.badge { display: inline-block; padding: 1px var(--s2); border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.badge.busy { color: var(--accent); border-color: var(--accent); }
.notice { padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.notice.danger { border-color: var(--danger); }
.notice.warn { border-color: var(--warn); }
pre.snippet { padding: var(--s3); background: var(--row); border-radius: var(--radius); overflow-x: auto;
  font-family: var(--mono); font-size: 13px; }
.logs { font-family: var(--mono); font-size: 12px; background: #0b0d12; color: #d6dbe4; padding: var(--s3);
  border-radius: var(--radius); max-height: 360px; overflow: auto; white-space: pre; }

/* # Auth / landing */
.centered { min-height: 100%; display: grid; place-items: center; padding: var(--s5); }
.centered .card { width: min(380px, 100%); text-align: center; align-items: center; }

/* # Loading / error */
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--danger); }
