:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --text: #16191f; --muted: #5f6b7a; --line: #e2e6ec;
  --accent: #3b5bdb; --accent-soft: #e7ecff; --ok: #1f9d55; --ok-soft: #e3f6ea; --bad: #d64545; --bad-soft: #fdecec;
  --warn: #c27c0e; --warn-soft: #fdf3e1; --dl: #3b5bdb; --ul: #94a8f0; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --panel-2: #1e232b; --text: #e8ebf0; --muted: #98a2b3; --line: #2a313b;
    --accent: #7c95ff; --accent-soft: #232b48; --ok: #3ccf7f; --ok-soft: #16301f; --bad: #ff6b6b; --bad-soft: #3a1c1c;
    --warn: #f0b44c; --warn-soft: #3a2c12; --dl: #7c95ff; --ul: #3d4f99; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --panel-2: #1e232b; --text: #e8ebf0; --muted: #98a2b3; --line: #2a313b;
  --accent: #7c95ff; --accent-soft: #232b48; --ok: #3ccf7f; --ok-soft: #16301f; --bad: #ff6b6b; --bad-soft: #3a1c1c;
  --warn: #f0b44c; --warn-soft: #3a2c12; --dl: #7c95ff; --ul: #3d4f99; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { 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; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
nav.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
nav.tabs a:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
nav.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.top-actions { display: flex; gap: 8px; align-items: center; }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }
section.view { display: none; }
section.view.on { display: block; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.stat .v { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .8rem; }

button, .btn { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { background: var(--panel-2); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
button:disabled { opacity: .6; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 11px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
select, input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label.f { display: block; font-size: .85rem; color: var(--muted); }
label.f > span { display: block; margin-bottom: 4px; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
label.chk input { width: auto; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
.share { height: 6px; background: var(--panel-2); border-radius: 3px; min-width: 60px; overflow: hidden; }
.share > i { display: block; height: 100%; background: var(--dl); border-radius: 3px; }

.bar { height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

.chart svg { width: 100%; height: auto; display: block; }
.chart .b-dl { fill: var(--dl); }
.chart .b-ul { fill: var(--ul); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i.lg-dl { background: var(--dl); }
.legend i.lg-ul { background: var(--ul); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; align-items: baseline; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font-size: .8rem; white-space: nowrap; min-width: 118px; }

.proj { display: flex; flex-direction: column; gap: 8px; }
.proj .meta { font-size: .85rem; color: var(--muted); }
.proj .parts { font-size: .82rem; background: var(--panel-2); border-radius: 8px; padding: 6px 9px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.note { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; font-size: .9rem; }
.note.warn { background: var(--warn-soft); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-size: .85em; }
ol.steps { padding-left: 20px; margin: 8px 0; }
ol.steps li { margin: 4px 0; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
dialog form { padding: 18px; display: grid; gap: 12px; }
dialog .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
dialog .actions .grow { flex: 1; }
.err { color: var(--bad); font-size: .85rem; min-height: 1em; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.on { opacity: 1; }

.sec-title { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 22px 0 10px; }
#v-overview > .sec-title:first-child { margin-top: 0; }
.card.travel { border-style: dashed; border-color: var(--accent); }
.site-sub { margin: -6px 0 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.vpn-card .big { font-size: 1.1rem; font-weight: 650; }
.full { width: 100%; }
.mt8 { margin-top: 8px; }
.mt10 { margin-top: 10px; }
.mt14 { margin-top: 14px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); }
.login h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login .stack { margin-top: 16px; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .top-inner { gap: 8px; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .kv dd { text-align: left; }
  dialog .row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .events time { min-width: 0; }
  .events li { flex-direction: column; gap: 2px; }
}
