/* VPN dashboard — tokens first, then layout, then components. */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e3e2dd;
  --text: #121211;
  --text-2: #52514e;
  --text-3: #7c7b76;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c; --good-ink: #0a6e0a;
  --warning: #fab219; --warning-ink: #8a5a00;
  --serious: #ec835a;
  --critical: #d03b3b; --critical-ink: #b12a2a;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --shadow: 0 1px 2px rgba(20, 20, 18, .05), 0 2px 8px rgba(20, 20, 18, .04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --line: #2e2e2b;
    --text: #f4f4f1; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #3987e5;
    --good-ink: #4fd14f; --warning-ink: #fab219; --critical-ink: #f07070;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --line: #2e2e2b;
  --text: #f4f4f1; --text-2: #c3c2b7; --text-3: #8f8e86;
  --accent: #3987e5;
  --good-ink: #4fd14f; --warning-ink: #fab219; --critical-ink: #f07070;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: none;
}

* { 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, "Helvetica Neue", sans-serif;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }

/* layout */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; gap: 18px; align-items: center;
  padding: 12px max(16px, calc((100vw - 1180px) / 2)); background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.top nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.top nav a[aria-current="page"], .top nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.top .out { margin-left: auto; color: var(--text-3); font-size: 14px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-2, .cols-3-1 { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.tile .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 360px; }

/* status */
.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px; font-weight: 550; font-size: 14px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.status.good .dot { background: var(--good); } .status.good { color: var(--good-ink); }
.status.warning .dot { background: var(--warning); } .status.warning { color: var(--warning-ink); }
.status.critical .dot { background: var(--critical); } .status.critical { color: var(--critical-ink); }
.status.unknown .dot { background: var(--text-3); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--text-2); font-size: 14px; margin-top: 10px; }
.facts b { color: var(--text); font-weight: 600; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-3); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.inactive td { color: var(--text-3); }
.name { font-weight: 600; color: var(--text); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; margin: 1px 2px 1px 0; white-space: nowrap; }
.on { color: var(--good-ink); font-weight: 600; }
.on::before { content: "●"; margin-right: 5px; font-size: 10px; vertical-align: 1px; }

/* proportion bar (share of channels) */
.split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin: 6px 0 12px; background: var(--surface); }
.split span { display: block; min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* events */
.events { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.events li { display: grid; grid-template-columns: 22px 88px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--text-3); font-size: 13px; }

/* forms & buttons */
form.inline { display: inline; }
input[type=text], input[type=password], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 6px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 550; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--critical-ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.error { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); color: var(--critical-ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.ok-note { background: color-mix(in srgb, var(--good) 12%, var(--surface)); color: var(--good-ink); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.auth { max-width: 420px; margin: 8vh auto 0; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 200px; max-width: 100%; }
.qr svg { width: 100%; height: auto; display: block; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 550; }
details ol, details ul { margin: 8px 0 0; padding-left: 20px; color: var(--text-2); }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13.5px; }
.bars .bar { position: relative; height: 22px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bars .bar span { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--s1) 30%, transparent); border-right: 3px solid var(--s1); }
.bars .bar em { position: relative; font-style: normal; padding-left: 8px; line-height: 22px; white-space: nowrap; }
.bars .v { text-align: right; color: var(--text-2); }
