:root {
  color-scheme: dark;
  --bg: #09131b;
  --surface: #11212b;
  --border: #263c48;
  --text: #edf6f8;
  --muted: #9eb5c0;
  --accent: #54dbc0;
  --direct: #7da8ff;
  --warn: #ffc878;
  --bad: #ff9494;
  font: 15px/1.55 system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
p, h1, h2 { margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -0.055em; line-height: 1.12; font-weight: 660; }
h2 { font-size: 1.3rem; letter-spacing: -0.025em; line-height: 1.3; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .43; cursor: default; }
button, input, textarea { border-radius: 9px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.wrap { width: min(1110px, calc(100% - 48px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 14px; gap: 12px; }
.device-label { display: flex; align-items: center; gap: 11px; font-weight: 650; letter-spacing: .035em; }
.device-mark { width: 11px; height: 11px; border: 2px solid var(--accent); transform: rotate(45deg); border-radius: 2px; margin-inline: 2px; }
.device-ip, code { font-family: ui-monospace, monospace; }
.device-ip { font-size: .85rem; font-weight: 400; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }
main.wrap { padding-block: 36px 56px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 22px; }
.hero p, .section-head p { color: var(--muted); margin-top: 6px; }
.status { border: 1px solid var(--border); border-radius: 999px; padding: 8px 13px; white-space: nowrap; align-self: flex-start; color: var(--muted); }
.status-dot { display: inline-block; background: currentColor; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.status[data-state="up"] { color: var(--accent); }
.status[data-state="down"] { color: var(--bad); }
.status[data-state="same_ip"], .status[data-state="unchecked"], .status[data-state="gateway"] { color: var(--warn); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metrics article, .surface, .login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; }
.metrics article { display: grid; gap: 5px; padding: 15px 16px; }
.metrics p, small, .muted, .hint { color: var(--muted); }
.metrics strong { font-variant-numeric: tabular-nums; font-size: clamp(1.15rem, 2.4vw, 1.62rem); letter-spacing: -.025em; line-height: 1.35; overflow-wrap: anywhere; }
.metrics small { font-size: .8rem; line-height: 1.35; }
.surface { padding: 21px; margin-top: 16px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-head p, .hint { font-size: .88rem; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: .85rem; }
.legend span { white-space: nowrap; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.vpn-key::before { background: var(--accent); }
.direct-key::before { background: var(--direct); }
#chart { display: block; width: 100%; height: 184px; }
.group-selector { border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 15px; }
.group-selector label { position: relative; cursor: pointer; }
.group-selector input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; width: 100%; }
.group-selector span { display: block; border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; color: var(--muted); }
.group-selector input:checked + span { border-color: var(--accent); color: var(--accent); background: #153931; }
.group-selector input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#rule-count { white-space: nowrap; }
.edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.edit-grid label { display: flex; flex-direction: column; gap: 7px; }
textarea, input[type="password"] { background: var(--bg); color: var(--text); border: 1px solid var(--border); padding: 11px; width: 100%; }
textarea { resize: vertical; font: .88rem/1.55 ui-monospace, monospace; }
.rule-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
button { padding: 7px 13px; background: transparent; color: var(--text); border: 1px solid transparent; }
.quiet { color: var(--muted); }
.quiet:hover:not(:disabled), .secondary:hover:not(:disabled) { background: #1a2d3a; color: var(--text); }
.secondary { border-color: var(--border); }
.primary { background: var(--accent); color: #0b2424; font-weight: 700; border-color: transparent; }
.primary:hover:not(:disabled) { background: #84eed9; }
.feedback { color: var(--accent); min-height: 1.5em; margin-top: 8px; }
.feedback[data-error="true"], .login-error { color: var(--bad); }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 410px); padding: 31px; }
.login-card h1 { margin-block: 16px 22px; font-size: 2.3rem; }
.login-card form { display: grid; gap: 10px; }
.login-card .primary { justify-self: start; min-width: 100px; }
.login-error { margin-bottom: 12px; }
.screen-reader { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 730px) {
  .wrap { width: calc(100% - 28px); }
  main.wrap { padding-block: 24px 38px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 490px) {
  .hero, .traffic .section-head { display: grid; }
  .status { justify-self: start; }
  .legend { justify-content: flex-start; }
  .edit-grid { grid-template-columns: 1fr; }
  .surface { padding: 14px; }
  .metrics article { padding: 11px; }
}
