:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --err: #b91c1c;
  --err-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a2f3a;
    --accent: #60a5fa;
    --accent-soft: #1e293b;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #fbbf24;
    --warn-soft: #3a2d0e;
    --err: #f87171;
    --err-soft: #3b1414;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); display: flex; gap: 8px; align-items: center; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-sub { color: var(--muted); font-weight: 500; font-size: 13px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.nav-cta { color: var(--accent); }

main { padding-top: 24px; padding-bottom: 32px; outline: none; }
.footer { padding-top: 8px; padding-bottom: 24px; font-size: 13px; color: var(--muted); }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }

/* Cards & stats */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
.url { word-break: break-all; font-size: 13px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Badges */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.neutral { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

/* Forms & buttons */
form.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { font-size: 13px; font-weight: 600; display: grid; gap: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 120px; resize: vertical; }
.grow { flex: 1 1 260px; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 8px 14px;
}
button.secondary, .btn.secondary { background: var(--surface); color: var(--accent); }
.btn { display: inline-block; }
.btn:hover { text-decoration: none; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: progress; }

.toast {
  position: fixed; right: 16px; bottom: 16px; max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px; border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .18);
  background: var(--text); color: var(--surface); font-size: 14px;
}
.toast.err { background: var(--err); color: #fff; }

.result { margin-top: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; }
