/* Watovi VPN — design system
   Tokens → base → layout → components → pages → responsive.
   CSP: no inline styles anywhere; everything lives here. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #07100d;
  --bg-glow: rgba(52, 211, 153, 0.13);
  --surface: #0d1915;
  --surface-2: #122019;
  --surface-3: #182a23;
  --overlay: rgba(3, 8, 6, 0.72);
  --border: rgba(160, 205, 185, 0.10);
  --border-strong: rgba(160, 205, 185, 0.20);
  --text: #ecf5f1;
  --text-2: #a6bab2;
  --text-3: #6d837b;
  --accent: #5ee3a1;
  --accent-hover: #7aebb3;
  --accent-ink: #03140c;
  --accent-soft: rgba(94, 227, 161, 0.12);
  --accent-ring: rgba(94, 227, 161, 0.35);
  --danger: #ff8080;
  --danger-soft: rgba(255, 128, 128, 0.12);
  --danger-solid: #dc3c43;
  --warn: #f3c46a;
  --warn-soft: rgba(243, 196, 106, 0.12);
  --info: #7cc4ff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, 0.7);

  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  --container: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f7f5;
    --bg-glow: rgba(16, 185, 129, 0.10);
    --surface: #ffffff;
    --surface-2: #f3f7f5;
    --surface-3: #e8efeb;
    --overlay: rgba(10, 25, 18, 0.35);
    --border: rgba(12, 45, 32, 0.09);
    --border-strong: rgba(12, 45, 32, 0.17);
    --text: #0c1a14;
    --text-2: #4a5e56;
    --text-3: #7d8f88;
    --accent: #0e9f62;
    --accent-hover: #0b8a55;
    --accent-ink: #ffffff;
    --accent-soft: rgba(14, 159, 98, 0.10);
    --accent-ring: rgba(14, 159, 98, 0.30);
    --danger: #d93b3b;
    --danger-soft: rgba(217, 59, 59, 0.09);
    --danger-solid: #d93b3b;
    --warn: #a86a00;
    --warn-soft: rgba(214, 150, 20, 0.12);
    --info: #1f7ad1;
    --shadow-sm: 0 1px 2px rgba(12, 40, 30, 0.06);
    --shadow: 0 1px 2px rgba(12, 40, 30, 0.04), 0 8px 24px -12px rgba(12, 40, 30, 0.14);
    --shadow-lg: 0 24px 60px -20px rgba(12, 40, 30, 0.28);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 400 15px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 500px at 110% 0%, rgba(124, 196, 255, 0.05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sprite { display: none; }
.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), #2fbf86);
  box-shadow: 0 6px 18px -6px var(--accent-ring);
}
.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.brand-name b { color: var(--accent); font-weight: 700; }
.brand-tag {
  padding: 2px 8px; border-radius: var(--r-full); font-size: 12px; font-weight: 500;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border);
}

/* Public pages */
.public-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.public-top { display: flex; justify-content: center; padding: 28px var(--gutter) 0; }
.public-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px var(--gutter);
}
.public-foot { padding: 20px var(--gutter) 28px; text-align: center; font-size: 13px; color: var(--text-3); }
.fineprint { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); text-align: center; }
.fineprint .icon { width: 15px; height: 15px; }

/* Admin shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-actions form { margin: 0; }
.admin-main { padding-top: 32px; padding-bottom: 64px; display: grid; gap: 24px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: clamp(26px, 3.2vw, 34px); line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; }
.page-sub { margin-top: 6px; color: var(--text-2); }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; font-size: 14px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- Components ---------- */

/* Buttons */
.btn {
  --btn-h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r);
  font-size: 14px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .65; cursor: progress; }
.btn-sm { --btn-h: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { --btn-h: 50px; padding: 0 22px; font-size: 15px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent-ring); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-solid); color: #fff; box-shadow: 0 8px 20px -10px rgba(220, 60, 67, 0.6); }
.btn-danger:hover { filter: brightness(1.08); }
.btn .spinner { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--r-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.icon-btn-success { color: var(--accent); }
.icon-btn-success:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* Tooltips from title → data-tip (set by JS) */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  translate: -50% 4px; opacity: 0; pointer-events: none;
  padding: 5px 9px; border-radius: var(--r-xs);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  color: var(--text); background: var(--surface-3); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  transition: opacity .12s var(--ease), translate .12s var(--ease);
  z-index: 5;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; translate: -50% 0; }
/* In the right-most actions column, anchor tooltips to the right edge so they
   never stick out of the table (which would create a horizontal scrollbar). */
.row-actions [data-tip]::after { left: auto; right: 0; translate: 0 4px; }
.row-actions [data-tip]:hover::after, .row-actions [data-tip]:focus-visible::after { translate: 0 0; }

/* Forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-size: 13px; color: var(--text-3); }
.input {
  width: 100%; height: 42px; padding: 0 14px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.input-lg { height: 52px; font-size: 16px; border-radius: var(--r); }
.input.mono { font-size: 15px; letter-spacing: 0.04em; }
.input-lg.mono { font-size: 17px; }
.input[type="search"]::-webkit-search-cancel-button { filter: grayscale(1); opacity: .5; }

.input-group { position: relative; }
.input-group .input { padding-right: 52px; }
.input-addon {
  position: absolute; top: 50%; right: 6px; translate: 0 -50%;
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-3); cursor: pointer;
}
.input-addon:hover { color: var(--text); background: var(--surface-3); }
.input-addon .icon-hide, .input-addon[aria-pressed="true"] .icon-show { display: none; }
.input-addon[aria-pressed="true"] .icon-hide { display: block; }

.search { position: relative; display: block; width: 260px; max-width: 100%; }
.search .icon { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search .input { height: 38px; padding-left: 36px; font-size: 14px; border-radius: var(--r-sm); }

/* Cards */
.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
}
.card-auth { max-width: 460px; padding: 36px; display: grid; gap: 20px; }
.card-narrow { max-width: 420px; }
.card-auth > .card-title { margin-top: -6px; }
.card-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.card-icon .icon { width: 22px; height: 22px; }
.card-icon-success { color: var(--accent-ink); background: var(--accent); border-color: transparent; box-shadow: 0 10px 28px -10px var(--accent-ring); }
.card-icon-success .icon { stroke-width: 2.6; }
.card-icon-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.card-title { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.card-lead { color: var(--text-2); margin-top: -8px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: -12px; }

/* Alerts */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r);
  font-size: 14px; line-height: 1.45;
  border: 1px solid transparent;
}
.alert .icon { width: 18px; height: 18px; margin-top: 1px; }
.alert-error { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert-warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }

/* Steps */
.steps { list-style: none; margin: 4px 0 0; padding: 20px 0 0; border-top: 1px solid var(--border); display: grid; gap: 14px; }
.steps li { display: flex; align-items: flex-start; gap: 12px; }
.steps div { display: grid; gap: 1px; }
.steps b { font-weight: 600; font-size: 14px; }
.steps span:not(.step-n) { font-size: 13px; color: var(--text-3); }
.step-n {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft);
}

/* Code display (admin: new ID) */
.code-display {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 16px 18px; border-radius: var(--r);
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  cursor: pointer; text-align: left; transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.code-display .mono { font-size: 18px; font-weight: 600; letter-spacing: 0.06em; overflow-wrap: anywhere; }
.code-display .icon { color: var(--text-3); }
.code-display:hover { border-color: var(--accent); background: var(--accent-soft); }
.code-display:hover .icon { color: var(--accent); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  display: grid; gap: 6px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.kpi-label .icon { width: 16px; height: 16px; color: var(--text-3); }
.kpi-value { font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; min-height: 32px; display: flex; align-items: center; }
.kpi-sub { font-size: 12.5px; color: var(--text-3); }

/* Panels + tables */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.panel-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.panel-sub { margin-top: 3px; font-size: 13px; color: var(--text-3); }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-tools .search { width: 200px; }
.panel-alert { margin: 16px 20px 0; }
.count {
  padding: 1px 8px; border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  color: var(--text-2); background: var(--surface-3);
}

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  position: sticky; top: 0;
  padding: 10px 16px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .12s var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-actions { width: 1%; text-align: right; }

.th-sort {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px; margin: -4px -6px;
  border: 0; border-radius: var(--r-xs); background: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit;
}
.th-sort:hover { color: var(--text); background: var(--surface-3); }
.th-sort .icon { width: 13px; height: 13px; opacity: .45; }
.th-sort.is-active { color: var(--text); }
.th-sort.is-active .icon { opacity: 1; color: var(--accent); }
.num .th-sort { flex-direction: row-reverse; }

.user-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-meta { display: grid; gap: 1px; min-width: 0; }
.user-name { font-weight: 550; overflow-wrap: anywhere; }
.user-sub { font-size: 12.5px; color: var(--text-3); }
.avatar {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 650; letter-spacing: 0.02em;
  color: var(--accent); background: var(--accent-soft);
  position: relative;
}
.avatar-off { color: var(--text-3); background: var(--surface-3); }
.avatar[data-online]::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--surface);
}

.code-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 5px 8px 5px 10px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.code-chip .mono { font-size: 13px; white-space: nowrap; }
.code-chip .icon { width: 14px; height: 14px; color: var(--text-3); }
.code-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.code-chip:hover .icon { color: var(--accent); }
.code-chip.is-copied, .code-display.is-copied { border-color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px;
  border-radius: var(--r-full); font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-on { color: var(--accent); background: var(--accent-soft); }
.badge-wait { color: var(--warn); background: var(--warn-soft); }
.badge-off { color: var(--text-3); background: var(--surface-3); }
.badge-info { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); }

/* Status filter chips (multi-select) */
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.filter-label { font-size: 13px; color: var(--text-3); margin-right: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 12px;
  border-radius: var(--r-full); border: 1px solid var(--border-strong); background: transparent;
  font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.chip-dot { width: 8px; height: 8px; padding: 0; border-radius: 50%; background: currentColor; }
.chip-dot.badge-on { background: var(--accent); }
.chip-dot.badge-wait { background: var(--warn); }
.chip-dot.badge-info { background: var(--info); }
.chip-dot.badge-off { background: var(--text-3); }
.chip-dot::before { display: none; }
.chip-count { min-width: 20px; padding: 1px 6px; border-radius: var(--r-full); font-size: 11.5px; font-weight: 650; text-align: center; background: var(--surface-3); color: var(--text-2); }
.chip-reset { border: 0; background: none; padding: 0 6px; height: 32px; font-size: 13px; font-weight: 550; color: var(--accent); cursor: pointer; }
.chip-reset:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Period select */
.select { position: relative; display: block; }
.select .input {
  height: 38px; padding: 0 34px 0 12px; font-size: 14px; font-weight: 550; border-radius: var(--r-sm); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px;
  background-size: 5px 5px; background-repeat: no-repeat;
}

/* Auto-refresh indicator */
.panel-sub { display: flex; align-items: center; gap: 8px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.live-dot.is-live { background: var(--accent); animation: pulse 2s infinite; }
.live-dot.is-paused { background: var(--warn); }

.row-actions { display: inline-flex; gap: 2px; }
.row-actions form { margin: 0; }
.icon-btn-label { display: none; }

/* Traffic */
.last-seen { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.last-seen.is-online { color: var(--accent); font-weight: 550; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.is-online .dot { background: var(--accent); box-shadow: 0 0 0 0 var(--accent-ring); animation: pulse 2s infinite; }
.last-seen.is-never { color: var(--text-3); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-ring); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.total-cell { display: grid; justify-items: end; gap: 6px; }
.bar { width: 96px; height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2fbf86, var(--accent)); }
.col-total { width: 1%; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
  height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
  font-size: 13px; font-weight: 550; color: var(--text-2); cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

@keyframes spin { to { rotate: 360deg; } }

/* Empty + skeleton */
.empty { display: grid; justify-items: center; gap: 8px; padding: 40px 20px; color: var(--text-3); text-align: center; }
.empty .icon { width: 28px; height: 28px; opacity: .6; }
.skeleton {
  display: block; height: 12px; width: 70%; border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
.skeleton-num { width: 56px; height: 24px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Modal */
.modal {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: var(--text);
  max-height: calc(100dvh - 32px);
}
.modal::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .18s var(--ease); }
.modal[open]::backdrop { animation: fade .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  display: grid; gap: 18px; padding: 22px 24px 24px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-right: -8px; }
.modal-title { font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.modal-text { color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50;
  translate: -50% 0;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 550;
  color: var(--accent-ink); background: var(--accent); box-shadow: var(--shadow-lg);
  animation: toast-in .2s var(--ease);
}
.toast .icon { width: 16px; height: 16px; stroke-width: 2.6; }
@keyframes toast-in { from { opacity: 0; translate: -50% 10px; } }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }


/* ---------- Admin tabs ---------- */
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); margin-right: auto; margin-left: 12px; }
.tab { padding: 6px 14px; border-radius: 6px; font-size: 14px; font-weight: 550; color: var(--text-2); white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Payments ---------- */
.alert-info { color: var(--info); background: color-mix(in srgb, var(--info) 10%, transparent); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.kpi-good { color: var(--accent); }
.kpi-warn { color: var(--warn); }
.count-warn { color: var(--warn); background: var(--warn-soft); }
.peer-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.peer-chip { padding: 2px 8px; border-radius: var(--r-full); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.peer-chip.is-off { color: var(--text-3); text-decoration: line-through; }
.status-cell { display: grid; gap: 3px; justify-items: start; }
.status-detail { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.col-assign { width: 1%; }
.assign-form { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.assign-form .select { min-width: 220px; }
.empty-ok { color: var(--accent); }
.collapsible > summary { list-style: none; cursor: pointer; border-bottom: 0; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary .panel-title::after { content: "▾"; font-size: 12px; color: var(--text-3); transition: rotate .15s var(--ease); }
.collapsible:not([open]) > summary .panel-title::after { rotate: -90deg; }
.collapsible[open] > summary { border-bottom: 1px solid var(--border); }

.modal-wide { width: min(640px, calc(100vw - 32px)); }
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label-row .muted { font-size: 12.5px; }
.search-block { width: 100%; }
.peer-picker { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); padding: 4px; background: var(--surface-2); }
.peer-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.peer-option:hover { background: var(--surface-3); }
.peer-option input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.peer-option-name { font-size: 14px; }
.peer-option-note { margin-left: auto; font-size: 12px; color: var(--text-3); text-align: right; }
.history-list { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.history-item div { display: grid; gap: 2px; }
.history-item .muted { font-size: 12.5px; }
.history-add { display: grid; gap: 8px; padding-top: 4px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .hide-sm { display: none; }
  .admin-main { padding-top: 20px; gap: 16px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head .btn { width: 100%; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 24px; }
  .panel { border-radius: var(--r-lg); }
  .panel-head { padding: 16px; }
  .panel-tools, .panel-tools .search, .search { width: 100%; }
  .panel-tools .search { flex: 1 1 100%; order: -1; }
  .panel-tools .btn { flex: 1; }
  .panel-tools .select, .panel-tools .segmented { flex: 1; }
  .panel-tools .segmented button { flex: 1; }
  .filter-bar { padding: 12px 16px; }
  .panel-alert { margin: 12px 16px 0; }

  /* Tables become card lists */
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tbody tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table th:first-child, .table td:first-child, .table td:last-child { padding: 0; border: 0; }
  .table td + td { margin-top: 10px; }
  .table td[data-label] { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .table td[data-label]::before { content: attr(data-label); font-size: 12.5px; color: var(--text-3); flex: none; }
  .table td:first-child[data-label]::before { display: none; }
  .table td:first-child { margin-bottom: 12px; }
  .table .num { text-align: right; }
  .col-actions { width: auto; text-align: left; }
  .row-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px dashed var(--border); width: 100%; }
  .row-actions form { flex: 1; }
  .row-actions .icon-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 38px; padding: 0 8px; font-size: 13px; font-weight: 550; border-color: var(--border); background: var(--surface-2); }
  .row-actions .icon-btn .icon { width: 15px; height: 15px; }
  .icon-btn-label { display: inline; white-space: nowrap; }
  .row-actions [data-tip]::after { display: none; }
  .table-traffic .total-cell { justify-items: end; }
  .code-chip .mono { font-size: 12.5px; }

  .row-actions form { flex: 1 1 0; min-width: 0; }

  /* Users: compact card — name + status / ID + IP / actions */
  .table-users tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "id id" "actions actions"; gap: 12px 12px; align-items: center; }
  .table-users td { margin: 0 !important; }
  .table-users td:nth-child(1) { grid-area: name; }
  .table-users td:nth-child(2) { grid-area: id; min-width: 0; }
  .table-users td:nth-child(3) { grid-area: status; }
  .table-users td:nth-child(4) { grid-area: actions; }
  .table-users td[data-label] { display: block; width: auto; }
  .table-users td[data-label]::before { display: none; }
  .table-users .code-chip { max-width: 100%; }
  .table-users .code-chip .mono { overflow: hidden; text-overflow: ellipsis; }
  .table-users .row-actions { padding-top: 0; border-top: 0; }

  /* Traffic: compact card — name / activity / three numbers */
  .table-traffic tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
  .table-traffic td { margin: 0 !important; }
  .table-traffic td:nth-child(1), .table-traffic td:nth-child(2) { grid-column: 1 / -1; }
  .table-traffic td:nth-child(2) { display: block; padding-left: 46px; margin-top: -8px !important; }
  .table-traffic td:nth-child(2)::before { display: none; }
  .table-traffic td.num { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
  .table-traffic td.num::before { font-size: 11.5px; }
  .table-traffic .total-cell { justify-items: start; width: 100%; }
  .table-traffic .bar { width: 100%; }

  /* Payments: compact cards */
  .table-payers tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name sum" "peers peers" "status status" "actions actions"; gap: 10px 12px; }
  .table-payers td { margin: 0 !important; }
  .table-payers td:nth-child(1) { grid-area: name; }
  .table-payers td:nth-child(2) { grid-area: peers; }
  .table-payers td:nth-child(3) { grid-area: sum; }
  .table-payers td:nth-child(4) { grid-area: status; }
  .table-payers td:nth-child(5) { grid-area: actions; }
  .table-payers td[data-label] { display: block; }
  .table-payers td[data-label]::before { display: none; }
  .table-payers .status-cell { grid-auto-flow: column; justify-content: start; align-items: center; gap: 8px; }
  .table-payers .row-actions { padding-top: 0; border-top: 0; }
  .table-assign tbody tr { display: grid; gap: 10px; }
  .table-assign td[data-label] { display: block; }
  .table-assign td[data-label]::before { display: none; }
  .assign-form { justify-content: stretch; }
  .assign-form .select { flex: 1; min-width: 0; }
  .col-assign { width: auto; }
  .tabs { margin-left: 0; }
  .tab { padding: 6px 10px; font-size: 13px; }
  .brand-tag { display: none; }
  .topbar .brand-name { display: none; }
  .topbar-inner { gap: 8px; }
  .topbar-actions .btn-sm { padding: 0 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .peer-chips { max-width: none; }

  .card-auth { padding: 26px 22px; border-radius: var(--r-lg); }
  .card-title { font-size: 23px; }
  .public-main { justify-content: flex-start; padding-top: 24px; }
  .public-top { padding-top: 20px; }
  .modal-foot .btn { flex: 1; }
}

@media (max-width: 360px) {
  .tab { padding: 6px 8px; font-size: 12.5px; }
  .topbar-actions { gap: 0; }
  .topbar-actions .btn-sm { padding: 0 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
