/* ── Traverse VPN Dashboard — Dark Theme ────────────────────────────────── */

:root {
  --bg:         #0d0f1a;
  --surface:    #141724;
  --surface-2:  #1c2035;
  --surface-3:  #252a42;
  --border:     #2a2f4a;
  --accent:     #7c6af7;
  --accent-dim: #5c4fd9;
  --text:       #e2e8f0;
  --text-muted: #8892a4;
  --text-dim:   #5a6278;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #3b82f6;
  --radius:     8px;
  --radius-lg:  12px;
  --sidebar-w:  180px;
  --font:       'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 13px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar — 52px icon rail ─────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  position: relative;
}

.sidebar-logo[data-tooltip]::after,
.nav-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 300;
  font-family: var(--font);
}

.sidebar-logo[data-tooltip]:hover::after,
.nav-link[data-tooltip]:hover::after { opacity: 1; }

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  scrollbar-width: none;
}

.nav-section { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 16px;
  gap: 11px;
  color: var(--text);
  opacity: 0.5;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
  border-left: 3px solid transparent;
  border-radius: 0;
  position: relative;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.nav-link:hover {
  opacity: 0.8;
  background: rgba(255,255,255,0.03);
}

.nav-link.active {
  opacity: 1;
  border-left-color: var(--accent);
  background: rgba(124,106,247,0.1);
  color: var(--accent);
}

.nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.nav-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,0.7);
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  width: 100%;
}

.sidebar-wg-status {
  padding: 7px 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.wg-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
}

.status-dot.up   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.down { background: var(--danger); }

/* ── Main layout ─────────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  padding: 20px 22px;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 20px;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: var(--surface-3);
}

.stat-card-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.stat-card-icon.purple { background: rgba(124,106,247,0.15); color: var(--accent); }
.stat-card-icon.green  { background: rgba(16,185,129,0.15);  color: var(--success); }
.stat-card-icon.blue   { background: rgba(59,130,246,0.15);  color: var(--info); }
.stat-card-icon.orange { background: rgba(245,158,11,0.15);  color: var(--warning); }
.stat-card-icon.red    { background: rgba(239,68,68,0.15);   color: var(--danger); }
.stat-card-icon.teal   { background: rgba(20,184,166,0.15);  color: #14b8a6; }

.stat-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-card-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--mono);
  word-break: break-all;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--surface-2);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:active { background: var(--surface-3); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.td-mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-success { background: rgba(16,185,129,0.15);  color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.15);   color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15);  color: var(--warning); }
.badge-muted   { background: rgba(88,100,126,0.2);   color: var(--text-muted); }
.badge-accent  { background: rgba(124,106,247,0.15); color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--accent); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
  background: rgba(16,185,129,0.15);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-warning {
  background: rgba(245,158,11,0.15);
  color: var(--warning);
  border: 1px solid rgba(245,158,11,0.3);
}
.btn-warning:hover { background: var(--warning); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-icon { padding: 7px 10px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select {
  width: 100%;
  padding: 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,106,247,0.15);
}

.form-input::placeholder { color: var(--text-dim); }

.form-textarea {
  width: 100%;
  padding: 9px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s;
  outline: none;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,106,247,0.15);
}

.form-textarea::placeholder { color: var(--text-dim); }

.form-hint {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 450;
  border-left: 3px solid;
}

.flash-success { background: rgba(16,185,129,0.1);  border-color: var(--success); color: #6ee7b7; }
.flash-error   { background: rgba(239,68,68,0.1);   border-color: var(--danger);  color: #fca5a5; }
.flash-warning { background: rgba(245,158,11,0.1);  border-color: var(--warning); color: #fcd34d; }
.flash-info    { background: rgba(59,130,246,0.1);  border-color: var(--info);    color: #93c5fd; }

/* ── Code blocks ─────────────────────────────────────────────────────────── */

.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.7;
  color: #a5d6a7;
  overflow-x: auto;
  white-space: pre;
}

.code-wrap { white-space: pre-wrap; word-break: break-all; }

.copy-block-wrap {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  padding: 4px 9px;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.copy-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.12s;
}
.copy-icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-icon-btn.copied { color: var(--success); border-color: var(--success); }

/* ── Peer search/filter ─────────────────────────────────────────────── */

.peer-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.peer-search-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 28px 6px 30px;
  font-size: 0.85rem;
  font-family: var(--font);
  width: 240px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23808595' stroke-width='1.6'><circle cx='7' cy='7' r='4.5'/><path d='M10.5 10.5L14 14'/></svg>");
  background-repeat: no-repeat;
  background-position: 8px center;
  background-size: 14px 14px;
}
.peer-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 106, 247, 0.15);
}
.peer-search-input::placeholder { color: var(--text-dim); }

.peer-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}
.peer-search-clear:hover { color: var(--text); background: var(--surface-3); }

/* ── Page transitions ──────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-content {
  animation: fadeIn 0.15s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .page-content { animation: none; }
}

/* ── Help overlay ─────────────────────────────────────────────────── */

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}

.help-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.help-hdr {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.help-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.help-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.help-close:hover { color: var(--text); background: var(--surface-3); }

.help-body { padding: 16px 18px 20px; }

.help-section { margin-bottom: 18px; }
.help-section:last-child { margin-bottom: 0; }
.help-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--mono);
}

.help-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.help-list li::before {
  content: '›';
  color: var(--accent);
  margin-right: 8px;
  font-weight: 700;
}
.help-list a { color: var(--accent); text-decoration: none; font-weight: 600; }
.help-list a:hover { text-decoration: underline; }

.help-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  font-size: 0.82rem;
}
.help-stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 5px;
}
.help-k { color: var(--text-dim); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.help-v { color: var(--text); font-weight: 600; }
.help-note { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.help-note a { color: var(--accent); text-decoration: none; font-weight: 600; }
.help-note a:hover { text-decoration: underline; }

/* ── Friendly empty states ────────────────────────────────────────── */

.empty-state-friendly {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 4px;
}
.empty-state-icon-lg {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 14px;
  filter: grayscale(0.2);
  opacity: 0.92;
}
.empty-state-heading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.empty-state-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── QR code ──────────────────────────────────────────────────────────────── */

.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px;
}

.qr-wrapper img {
  border-radius: 12px;
  border: 6px solid #fff;
  display: block;
  max-width: 280px;
  width: 100%;
}

/* ── Detail sections ─────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-field {
  margin-bottom: 16px;
}

.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-all;
}

.detail-value.mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #a5d6a7;
  background: var(--surface-2);
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

/* ── Page sections ───────────────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon { font-size: 2.5rem; opacity: 0.4; }
.empty-state-text { font-size: 0.9rem; }

/* ── Utility ──────────────────────────────────────────────────────────────── */

.text-muted   { color: var(--text-muted); }
.text-dim     { color: var(--text-dim); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent  { color: var(--accent); }
.text-mono    { font-family: var(--mono); }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.w-full { width: 100%; }
.max-w-lg { max-width: 640px; }
.max-w-md { max-width: 480px; }

.text-sm   { font-size: 0.85rem; }
.text-xs   { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--mono); }

.overflow-hidden { overflow: hidden; }

/* ── Action bar ──────────────────────────────────────────────────────────── */

.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Device badge ────────────────────────────────────────────────────────── */

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Hamburger button (hidden on desktop) ────────────────────────────────── */

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0;
  margin-right: 10px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.hamburger:hover { background: var(--surface-2); border-color: var(--accent); }

/* ── Sidebar overlay (mobile) ────────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Danger zone ──────────────────────────────────────────────────────────── */

.danger-zone {
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: rgba(239,68,68,0.04);
}

.danger-zone-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 8px;
}

/* ── Leaflet dark overrides ──────────────────────────────────────────────── */

/* CARTO dark_all ocean colour — hides the grey Leaflet canvas edge */
.leaflet-container { background: #1a1a2e !important; }

.leaflet-popup-content-wrapper {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.leaflet-popup-tip { background: var(--surface-2); }

.leaflet-popup-content-wrapper a { color: var(--accent); }

.leaflet-control-zoom a {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-zoom a:hover { background: var(--surface-3) !important; }

.leaflet-control-attribution {
  background: rgba(20,23,36,0.8) !important;
  color: var(--text-dim) !important;
  font-size: 10px;
}

.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* ── Live data animations ────────────────────────────────────────────────── */

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0   rgba(16,185,129,0.45); }
  70%  { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0   rgba(16,185,129,0); }
}

.live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-ring 2s ease-out infinite;
  flex-shrink: 0;
  transition: background 0.4s;
}

.live-dot.stale {
  background: var(--text-dim);
  animation: none;
}

.stat-card-value {
  transition: color 0.4s ease;
}

/* Speed display inside traffic card */
.speed-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
  transition: color 0.3s;
}

.speed-unit {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 3px;
}

.live-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.25);
  color: var(--success);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-badge.stale {
  background: rgba(90,98,120,0.15);
  border-color: rgba(90,98,120,0.3);
  color: var(--text-dim);
}

/* ── Server health bar ───────────────────────────────────────────────────── */

.noc-health-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  opacity: 0.85;
}

/* ── Pi-hole status bar ──────────────────────────────────────────────────── */

.noc-pihole-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  opacity: 0.85;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease, border-bottom-color 0.15s ease;
}

.noc-pihole-bar:hover {
  opacity: 1;
  background: rgba(124, 106, 247, 0.04);
  border-bottom-color: rgba(124, 106, 247, 0.35);
}

/* ── Bottom nav (mobile only) ────────────────────────────────────────────── */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.6rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: color 0.15s;
  position: relative;
  min-width: 52px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bottom-nav-item.active { color: var(--accent); }

.bottom-nav-item .icon {
  font-size: 1.25rem;
  line-height: 1;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT — full rewrite for screens ≤ 768px
   Mobile-first principles applied AFTER the desktop rules above. We do
   not touch desktop styling; we override only inside this media query.
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Resets ──────────────────────────────────────────────────────── */
  html, body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }
  body { overflow-x: hidden; }
  * { -webkit-tap-highlight-color: transparent; }

  /* Min touch targets */
  button, .btn, .nav-link, .install-btn, .install-dismiss { min-height: 44px; }

  /* ── Hide desktop chrome ─────────────────────────────────────────── */
  .sidebar, .sidebar-overlay, .hamburger { display: none; }
  .main { margin-left: 0; }

  /* ── Fixed top bar — 48px + iOS safe area ────────────────────────── */
  .topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: auto;
    min-height: 48px;
    padding: env(safe-area-inset-top, 0) 12px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    gap: 8px;
    align-items: center;
  }
  .topbar .page-title {
    flex: 1;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    line-height: 48px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-right { gap: 6px; }

  /* Hide noisy topbar actions: bell/help/sound/theme + Sign Out */
  .topbar-right #sound-toggle,
  .topbar-right #help-toggle,
  .topbar-right #theme-toggle,
  .topbar-right a[href*="logout"] { display: none; }

  /* + Add Peer becomes a compact 36×36 round button (icon only) */
  .topbar-right .topbar-add-peer {
    padding: 0;
    width: 36px;
    height: 36px;
    min-height: 36px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .topbar-add-peer-label { display: none; }

  /* Push main content below fixed topbar */
  .main { padding-top: calc(48px + env(safe-area-inset-top, 0)); }

  /* ── NOC dashboard scroll setup ──────────────────────────────────── */
  body.noc          { overflow: auto; }
  body.noc .main    {
    height: auto;
    overflow: auto;
    padding-top: calc(48px + env(safe-area-inset-top, 0));
  }
  body.noc .content { overflow: visible; flex: initial; }

  .content {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 16px);
  }

  .noc-layout      { overflow: visible; padding: 8px; }
  .noc-grid        { grid-template-columns: 1fr !important; height: auto; gap: 8px; }
  .noc-col         { overflow: visible; }
  .noc-panel-flex  { min-height: 180px; }

  /* ── Hide right column entirely (INTERFACE / WG SHOW / SPEEDTEST) ── */
  .noc-col-right { display: none !important; }

  /* ── Top stats bar — flat 2-col grid, no rounded card ────────────── */
  .noc-bar {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    gap: 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .noc-bar > .noc-stat,
  .noc-health-bar > .noc-stat,
  .noc-pihole-bar > .noc-stat {
    flex: 1 0 50%;
    min-width: 50%;
    max-width: 50%;
    box-sizing: border-box;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background: transparent;
  }
  .noc-bar > .noc-stat:nth-child(2n),
  .noc-health-bar > .noc-stat:nth-child(2n),
  .noc-pihole-bar > .noc-stat:nth-child(2n) { border-right: none; }
  .noc-bar > .noc-stat .noc-lbl,
  .noc-health-bar > .noc-stat .noc-lbl,
  .noc-pihole-bar > .noc-stat .noc-lbl {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
  }
  .noc-bar > .noc-stat .noc-val,
  .noc-health-bar > .noc-stat .noc-val,
  .noc-pihole-bar > .noc-stat .noc-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    word-break: break-word;
  }
  .noc-sep { display: none; }

  /* Live speeds row appended at the bottom of the top stats bar */
  .noc-bar > .noc-bar-right {
    flex: 0 0 100%;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
  }

  /* ── Server health bar — same 2-col grid + VPS SPEED full row ────── */
  .noc-health-bar {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .noc-health-bar .noc-bar-right {
    flex: 0 0 100%;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
  }
  .noc-health-bar .noc-sep { display: none; }

  /* ── Pi-hole bar — 2-col grid; hide ↗ ADMIN tail; CLIENTS hidden ─── */
  .noc-pihole-bar {
    display: flex;
    flex-wrap: wrap;
    padding: 0;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .noc-pihole-bar .noc-bar-right { display: none; }
  .noc-pihole-bar .noc-sep { display: none; }

  /* Generic hide-on-mobile helper (.hide-mobile is set on CLIENTS) */
  .hide-mobile { display: none !important; }

  /* ── Live traffic chart — full width, 140px tall ─────────────────── */
  .chart-canvas-wrap {
    height: 140px !important;
    padding: 4px 8px !important;
  }
  .noc-panel-hdr.chart-hdr {
    flex-wrap: wrap;
    row-gap: 2px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .noc-panel-hdr.chart-hdr .chart-stat-grp { font-size: 11px; }
  .noc-panel-hdr.chart-hdr .noc-sep-sm { opacity: 0.4; }

  /* ── NOC peers table — Name + last-seen + chevron only ───────────── */
  .noc-table tbody tr {
    cursor: pointer;
    min-height: 52px;
  }
  .noc-table tbody tr:active { background: var(--surface-3); }
  /* Hide RX/TX column (5th, plus its header) — keep dot, name, view-arrow */
  .noc-table thead th:nth-child(5),
  .noc-table tbody td:nth-child(5) { display: none; }
  .noc-table tbody td { padding: 14px 8px; }

  /* ── /peers list table — show only Name, Device, Status, Last Seen ─ */
  .table-wrap { overflow-x: hidden; }
  .table-wrap table th:nth-child(1),  /* Bulk select */
  .table-wrap table td:nth-child(1),
  .table-wrap table th:nth-child(2),  /* #          */
  .table-wrap table td:nth-child(2),
  .table-wrap table th:nth-child(5),  /* VPN IP     */
  .table-wrap table td:nth-child(5),
  .table-wrap table th:nth-child(6),  /* DNS        */
  .table-wrap table td:nth-child(6),
  .table-wrap table th:nth-child(7),  /* Tunnel     */
  .table-wrap table td:nth-child(7),
  .table-wrap table th:nth-child(10), /* Session    */
  .table-wrap table td:nth-child(10),
  .table-wrap table th:nth-child(11), /* RX / TX    */
  .table-wrap table td:nth-child(11),
  .table-wrap table th:nth-child(12), /* Sparkline  */
  .table-wrap table td:nth-child(12),
  .table-wrap table th:nth-child(13), /* Expires    */
  .table-wrap table td:nth-child(13),
  .table-wrap table th:nth-child(14), /* Created    */
  .table-wrap table td:nth-child(14),
  .table-wrap table th:nth-child(15), /* Actions    */
  .table-wrap table td:nth-child(15) { display: none; }
  .table-wrap table tbody tr { cursor: pointer; min-height: 52px; }
  .table-wrap table tbody td { padding: 14px 10px; line-height: 1.3; }

  /* ── Bottom navigation — 56px + safe area, blur, accent line ─────── */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0));
    padding: 0 0 env(safe-area-inset-bottom, 0) 0;
    background: rgba(20, 23, 36, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    z-index: 200;
    justify-content: space-around;
    align-items: stretch;
  }
  .bottom-nav-item {
    flex: 1;
    min-width: 0;
    height: 56px;
    padding: 6px 4px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
    opacity: 0.55;
    border-radius: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    min-height: 56px;
  }
  .bottom-nav-item .icon {
    font-size: 24px;
    line-height: 1;
  }
  .bottom-nav-item.active {
    color: var(--accent);
    opacity: 1;
  }
  .bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }

  /* ── Map / forms / generic grids ─────────────────────────────────── */
  .map-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: 0 !important;
  }
  .map-grid > .card:first-child {
    height: 55vmax;
    min-height: 280px;
  }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .content { padding: 10px; padding-bottom: 68px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── NOC Dashboard ───────────────────────────────────────────────────────── */

body.noc { height: 100vh; overflow: hidden; }

body.noc .main {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.noc .content {
  flex: 1;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── NOC status bar ─────────────────────────────────────────────────── */

.noc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.noc-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.noc-lbl {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.noc-val {
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.noc-val.green  { color: var(--success); }
.noc-val.blue   { color: var(--info); }
.noc-val.accent { color: var(--accent); }

.noc-sep    { color: var(--border); padding: 0 2px; font-size: 14px; }
.noc-sep-sm { color: var(--text-dim); font-size: 11px; }

.noc-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.noc-speed-val {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.noc-ago {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  min-width: 30px;
  text-align: right;
}

/* ── NOC layout ─────────────────────────────────────────────────────── */

.noc-layout {
  flex: 1;
  overflow: hidden;
  padding: 10px;
  min-height: 0;
}

.noc-grid {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 10px;
  height: 100%;
}

.noc-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

.noc-col-right {
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

/* ── NOC panels ─────────────────────────────────────────────────────── */

.noc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.noc-panel-flex {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.noc-panel-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.noc-panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-family: var(--mono);
}

.noc-panel-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ── Chart header stats ─────────────────────────────────────────────── */

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.chart-hdr {
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 5px;
}

.chart-stat-grp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chart-lbl {
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.chart-val {
  font-size: 11px;
  font-weight: 600;
}

.chart-live-dot {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--success);
  letter-spacing: 0.05em;
  animation: livePulse 2s ease-in-out infinite;
  white-space: nowrap;
  flex-shrink: 0;
}

.noc-action-btn {
  padding: 3px 8px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
  font-family: var(--mono);
  font-weight: 600;
  transition: all 0.12s;
  white-space: nowrap;
}

.noc-action-btn:hover { color: var(--accent); border-color: var(--accent); }

.noc-action-btn + .noc-action-btn { margin-left: 0; }

/* push action buttons to the right */
.noc-panel-hdr .noc-action-btn:first-of-type { margin-left: auto; }

/* ── NOC peers table ────────────────────────────────────────────────── */

.noc-table-wrap {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.noc-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
}

.noc-table thead th {
  background: var(--surface-2);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.noc-table tbody tr {
  border-bottom: 1px solid rgba(42,47,74,0.5);
  transition: background 0.1s;
}

.noc-table tbody tr:last-child { border-bottom: none; }
.noc-table tbody tr:hover      { background: var(--surface-2); }

.noc-table tbody td {
  padding: 8px 10px;
  vertical-align: middle;
  color: var(--text);
  font-size: 12px;
}

.noc-status-cell {
  width: 20px;
  padding-right: 0 !important;
  padding-left: 10px !important;
}

.noc-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.noc-dot-green { background: var(--success); box-shadow: 0 0 5px rgba(16,185,129,0.7); }
.noc-dot-dim   { background: var(--surface-3); }

.noc-link {
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
}

.noc-link:hover { color: var(--accent); }

.noc-rx { color: var(--info); }
.noc-tx { color: var(--accent); }

.noc-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
  width: 22px;
  transition: color 0.12s;
}

.noc-view-btn:hover { color: var(--accent); }

.noc-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
}

.noc-empty .noc-link { color: var(--accent); }

/* ── NOC KV grid (interface info) ───────────────────────────────────── */

.noc-kv-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  align-items: baseline;
}

.noc-k {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.07em;
  white-space: nowrap;
}

.noc-v {
  color: var(--text);
  word-break: break-all;
}

/* ── WG show pre ────────────────────────────────────────────────────── */

.noc-pre-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.noc-pre {
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  color: #a5d6a7;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  word-break: normal;
  margin: 0;
}

/* ── Quick nav ──────────────────────────────────────────────────────── */

.noc-quicknav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.noc-qbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
  text-align: center;
  font-family: var(--mono);
  transition: all 0.12s;
  gap: 5px;
  white-space: nowrap;
}

.noc-qbtn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(124,106,247,0.08);
}

/* ── NOC badges (interface up/down) ─────────────────────────────────── */

.noc-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.noc-badge-green {
  background: rgba(16,185,129,0.12);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.25);
}

.noc-badge-red {
  background: rgba(239,68,68,0.12);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.25);
}

/* ── Inline utility ─────────────────────────────────────────────────── */

.mono { font-family: var(--mono); }
.dim  { color: var(--text-dim); }

/* ── Logs page ───────────────────────────────────────────────────────── */

.logs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 860px) { .logs-grid { grid-template-columns: 1fr; } }

.log-box {
  background: var(--surface-2);
  border: none;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--text-muted);
  padding: 12px 14px;
  height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Wizard steps indicator ──────────────────────────────────────────── */

.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.wizard-step-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 8px;
}
.step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  flex-shrink: 0;
}
.step-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
}
.wizard-step.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.wizard-step.active .step-label { color: var(--text); }
.wizard-step.completed .step-num {
  background: rgba(16,185,129,0.15);
  border-color: var(--success);
  color: var(--success);
}
.wizard-step.completed .step-label { color: var(--text-muted); }

/* ── Last-seen badges ────────────────────────────────────────────────── */

.last-seen {
  font-size: 0.78rem;
  font-weight: 500;
  font-family: var(--mono);
  white-space: nowrap;
}
.seen-online { color: var(--success); }
.seen-recent { color: var(--success); opacity: 0.8; }
.seen-today  { color: var(--text-muted); }
.seen-week   { color: var(--text-dim); }
.seen-old    { color: var(--text-dim); opacity: 0.6; }
.seen-never  { color: var(--text-dim); opacity: 0.5; }

/* ── Theme toggle button ─────────────────────────────────────────────── */

.theme-toggle-btn {
  font-size: 1rem;
  padding: 0 8px;
  min-width: 32px;
  line-height: 1;
}

/* ── Pause pill button (dashboard NOC bar) ───────────────────────────── */

.noc-pause-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.noc-pause-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Light theme overrides ───────────────────────────────────────────── */

body.theme-light {
  --bg:         #f0f2f8;
  --surface:    #ffffff;
  --surface-2:  #e8eaf2;
  --surface-3:  #dde0ee;
  --border:     #c8cce0;
  --text:       #1a1d2e;
  --text-muted: #5a6380;
  --text-dim:   #8890a8;
}

body.theme-light .topbar,
body.theme-light .sidebar {
  background: var(--surface);
  border-color: var(--border);
}

body.theme-light .noc-bar,
body.theme-light .noc-health-bar,
body.theme-light .noc-pihole-bar {
  background: #e8eaf2;
  border-color: var(--border);
}

body.theme-light .noc-pre,
body.theme-light pre {
  background: #e2e5f0;
  color: var(--text);
}

body.theme-light .card,
body.theme-light .stat-card,
body.theme-light .noc-panel,
body.theme-light .noc-table-wrap {
  background: var(--surface);
  border-color: var(--border);
}

body.theme-light .noc-table th {
  background: var(--surface-2);
  color: var(--text-muted);
}

body.theme-light .noc-table tr:hover td {
  background: var(--surface-2);
}

body.theme-light input,
body.theme-light select,
body.theme-light textarea {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

body.theme-light .btn-ghost {
  color: var(--text-muted);
  border-color: var(--border);
}

body.theme-light .btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

body.theme-light .noc-pihole-bar:hover {
  background: rgba(124,106,247,0.08);
}

/* ── Dashboard recent alerts ───────────────────────────────────────────── */
.noc-alert-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: background 0.15s;
}
.noc-alert-row:hover { background: var(--surface-2); }
.noc-alert-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-dim);
}
.noc-alert-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noc-alert-info    .noc-alert-dot { background: var(--info); }
.noc-alert-warning .noc-alert-dot { background: var(--warning); }
.noc-alert-error   .noc-alert-dot { background: var(--danger); }
.noc-alert-critical .noc-alert-dot { background: var(--danger); }
.noc-alert-info    { border-left-color: var(--info); }
.noc-alert-warning { border-left-color: var(--warning); }
.noc-alert-error   { border-left-color: var(--danger); }
.noc-alert-critical { border-left-color: var(--danger); }
.noc-alert-none {
  padding: 8px 12px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--success);
  opacity: 0.75;
}

/* ── About / Changelog ─────────────────────────────────────────────────── */
.changelog-body {
  padding: 16px 20px;
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-height: 600px;
  overflow-y: auto;
}

.cl-version {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 18px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.cl-section {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cl-item {
  padding: 1px 0 1px 8px;
  color: var(--text-muted);
}

/* ── PWA install banner ───────────────────────────────────────────── */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  animation: install-slide-down 0.35s ease-out;
}
.install-banner-text {
  flex: 1;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.install-banner .install-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font: 600 0.82rem 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.install-banner .install-btn:hover  { box-shadow: 0 4px 14px rgba(124, 106, 247, 0.45); }
.install-banner .install-btn:active { transform: translateY(1px); }
.install-banner .install-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}
.install-banner .install-dismiss:hover {
  background: var(--surface);
  color: var(--text);
}
.install-banner.ios-tip {
  background: linear-gradient(135deg, #1c2035, #252a42);
}
@keyframes install-slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@media (max-width: 540px) {
  .install-banner { font-size: 0.78rem; padding: 9px 12px; gap: 8px; }
  .install-banner .install-btn { padding: 6px 10px; font-size: 0.78rem; }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE SCROLL RESTORATION (must come LAST)
   The desktop `body.noc { height: 100vh; overflow: hidden }` rules above
   appear AFTER the main mobile media block, so source order makes them
   win on mobile too — that pinned the dashboard at viewport height with
   no overflow, killing scroll. This block re-asserts the mobile scroll
   model after those rules so it wins by source order.

   Scroll model: BODY is the only scroll container. `.main` and `.content`
   are overflow:visible. Two nested scrollers (body + .main) caused iOS
   Safari to freeze momentum scrolling.
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  html {
    height: 100%;
    overflow-x: hidden;
  }
  body {
    min-height: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: auto;
  }

  /* All NOC-page wrappers must NOT clip vertical scroll */
  body.noc {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.noc .main,
  .main {
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    position: static;
  }
  body.noc .content,
  .content,
  .page-content {
    height: auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: visible;
    flex: initial;
  }

  /* Padding so content clears the fixed top bar and bottom nav */
  body.noc .main,
  .main {
    padding-top: calc(48px + env(safe-area-inset-top, 0));
  }
  .content,
  body.noc .content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   POLISH PASS — appended last so it wins by source order. Touches:
   skeletons, scrollbars, stat-bar tightening, online pulse, alt rows,
   action-button reveal, focus rings, toggle switches, status banner,
   touch feedback, mobile glow + chevron, topology grid + ring, vignette.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Skeleton shimmer (utility) ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #1e2433 25%, #252d3d 50%, #1e2433 75%);
  background-size: 200% 100%;
  animation: tv-shimmer 1.5s infinite;
  border-radius: 4px;
  display: inline-block;
  min-height: 1em;
  min-width: 40px;
  color: transparent !important;
  opacity: 0.85;
}
@keyframes tv-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Scrollbars (consistent) ──────────────────────────────────────────── */
::-webkit-scrollbar          { width: 6px; height: 6px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }
.noc-col-right::-webkit-scrollbar { width: 5px; }

/* ── Tighten stat-bars + accent separators ───────────────────────────── */
.noc-bar         { padding: 6px 14px; }
.noc-health-bar  { padding: 4px 14px; border-bottom: 1px solid rgba(124,106,247,0.12); }
.noc-pihole-bar  { padding: 4px 14px; border-bottom: 1px solid rgba(124,106,247,0.12); }

/* ── Number flash (chart NOW/PEAK/AVG accent → normal) ───────────────── */
.num-flash { animation: tv-flash 0.32s ease-out; }
@keyframes tv-flash {
  0%   { color: var(--accent); text-shadow: 0 0 8px rgba(124,106,247,0.55); }
  100% { color: inherit; text-shadow: none; }
}

/* ── Online dot pulse (peers table) ──────────────────────────────────── */
@keyframes tv-pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  50%      { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}
.noc-dot-green { animation: tv-pulse-dot 2.2s ease-in-out infinite; }

/* ── Peer table polish: alt rows + action reveal ─────────────────────── */
.noc-table tbody tr:nth-child(odd) td { background: rgba(255,255,255,0.018); }
.noc-table tbody tr:hover td          { background: rgba(124,106,247,0.06); }
.noc-view-btn {
  opacity: 0.45;
  transition: opacity 0.18s ease, transform 0.05s ease;
}
.noc-table tbody tr:hover .noc-view-btn,
.noc-table tbody tr:focus-within .noc-view-btn,
.noc-table tbody tr:active .noc-view-btn { opacity: 1; }

/* ── Right-panel sections: subtle accent border ──────────────────────── */
.noc-col-right .noc-panel { border-left: 2px solid rgba(124,106,247,0.18); }

/* ── Form focus rings (consistent) ───────────────────────────────────── */
input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.16);
}

/* ── Touch / press feedback (everywhere) ─────────────────────────────── */
button:active,
.btn:active,
.bottom-nav-item:active,
.noc-action-btn:active,
.noc-qbtn:active,
.noc-view-btn:active,
.toggle-switch:active {
  transform: scale(0.97);
  transition: transform 0.05s ease;
}

/* ── Toggle switches (drop-in for checkboxes) ────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  vertical-align: middle;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-switch .slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: #e2e8f0;
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.toggle-switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .slider::before {
  transform: translateX(20px);
  background: #fff;
}
.toggle-switch input:focus-visible + .slider {
  box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.22);
}

/* ── Loading spinner (inline) ────────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: tv-spin 0.6s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes tv-spin { to { transform: rotate(360deg); } }
.btn[disabled], button[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Status banner (peer detail) ─────────────────────────────────────── */
.peer-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 0 0 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  border-left: 3px solid;
}
.peer-status-banner .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.peer-status-banner.online {
  background: rgba(16, 185, 129, 0.08);
  color: var(--success);
  border-left-color: var(--success);
}
.peer-status-banner.offline {
  background: rgba(90, 98, 120, 0.08);
  color: var(--text-muted);
  border-left-color: var(--text-dim);
}
.peer-status-banner.disabled {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border-left-color: var(--danger);
}

/* ── Topology canvas grid dots + slow rotating ring ──────────────────── */
.topology-grid-bg {
  background-image: radial-gradient(circle, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 22px 22px;
}
@keyframes tv-slow-spin { to { transform: rotate(360deg); } }
.topology-server-ring {
  position: absolute;
  width: 96px; height: 96px;
  margin: -48px 0 0 -48px;
  left: 50%; top: 50%;
  border: 1.5px dashed rgba(124, 106, 247, 0.4);
  border-radius: 50%;
  pointer-events: none;
  animation: tv-slow-spin 14s linear infinite;
}
@keyframes tv-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}
.topology-peer-active { animation: tv-pulse-glow 2.4s ease-in-out infinite; }

/* ── Pi-hole grid colour state ───────────────────────────────────────── */
.ph-blocked-warn { color: var(--warning) !important; }
.ph-blocked-zero { color: var(--success) !important; }

/* ── Mobile polish ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Bottom nav active tab — top accent line */
  .bottom-nav-item { transition: color 0.1s, transform 0.05s; }
  .bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0; left: 28%; right: 28%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 2px 2px;
  }

  /* Stats grid — value glow on success states */
  .mobile-glow-good { text-shadow: 0 0 12px rgba(16, 185, 129, 0.45); }

  /* Page transitions slightly snappier */
  .content,
  body.noc .content { animation: tv-fade-in 0.1s ease-out; }
  @keyframes tv-fade-in {
    from { opacity: 0; transform: translateY(2px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Bump tiny font sizes to ≥11px */
  [style*="font-size:9px"]  { font-size: 11px !important; }
  [style*="font-size: 9px"] { font-size: 11px !important; }
  [style*="font-size:10px"] { font-size: 11px !important; }
  [style*="font-size: 10px"]{ font-size: 11px !important; }
}

/* ── Border-radius consistency ───────────────────────────────────────── */
.btn, .noc-action-btn, .noc-qbtn, .noc-view-btn { border-radius: 6px; }
.noc-badge, .live-badge { border-radius: 999px; }

/* ── Empty search state ──────────────────────────────────────────────── */
.empty-search {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.empty-search-icon { font-size: 2rem; opacity: 0.4; margin-bottom: 8px; display: block; }

/* ── Map vignette overlay (applied via .map-vignette wrapper) ────────── */
.map-vignette {
  position: relative;
}
.map-vignette::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 80px 12px rgba(13, 15, 26, 0.55);
  z-index: 450; /* leaflet panes top out below this */
}

/* ════════════════════════════════════════════════════════════════════════
   v1.5.x POLISH BATCH — appended last, wins by source order. Components:
   toasts, loading bar, confirm modal, command palette, filter chips,
   bulk action bar, sortable tables, friendly empty states upgrade,
   event feed widget, keyboard shortcut hints, light-theme coverage.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Toast notifications ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--surface-2, #1a1f2e);
  border: 1px solid var(--border, #2a3142);
  border-left: 3px solid var(--accent, #7c6af7);
  border-radius: var(--radius, 8px);
  padding: 11px 14px 11px 13px;
  color: var(--text, #e2e8f0);
  font-size: 0.85rem;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  animation: tv-toast-in 0.22s ease-out;
  cursor: default;
}
.toast.toast-success { border-left-color: var(--success, #10b981); }
.toast.toast-error   { border-left-color: var(--danger,  #ef4444); }
.toast.toast-warning { border-left-color: var(--warning, #f59e0b); }
.toast.toast-info    { border-left-color: var(--info,    #3b82f6); }
.toast.toast-leaving { animation: tv-toast-out 0.2s ease-in forwards; }
.toast-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.2;
  margin-top: 1px;
}
.toast-success .toast-icon { color: var(--success, #10b981); }
.toast-error   .toast-icon { color: var(--danger,  #ef4444); }
.toast-warning .toast-icon { color: var(--warning, #f59e0b); }
.toast-info    .toast-icon { color: var(--info,    #3b82f6); }
.toast-body { flex: 1; min-width: 0; word-wrap: break-word; }
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 4px;
  margin: -2px -4px -2px 0;
  border-radius: 3px;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text, #e2e8f0); }
@keyframes tv-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tv-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@media (max-width: 540px) {
  #toast-container {
    top: 8px; right: 8px; left: 8px; max-width: none;
  }
  .toast { min-width: 0; max-width: none; font-size: 0.82rem; }
}

/* ── Top loading bar ────────────────────────────────────────────────── */
#tv-loading-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent, #7c6af7), #b794f4);
  box-shadow: 0 0 8px rgba(124, 106, 247, 0.55);
  z-index: 9500;
  pointer-events: none;
  opacity: 0;
  transition: width 0.18s ease-out, opacity 0.2s ease-out;
}
#tv-loading-bar.tv-loading-active { opacity: 1; }
#tv-loading-bar.tv-loading-done   { opacity: 0; transition: width 0.18s ease-out, opacity 0.4s ease-out 0.15s; }

/* ── Confirm modal ──────────────────────────────────────────────────── */
.tv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 8500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: tv-fade-in 0.16s ease-out;
}
.tv-modal {
  background: var(--surface, #14172a);
  border: 1px solid var(--border, #2a3142);
  border-radius: var(--radius-lg, 10px);
  max-width: 460px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: tv-modal-in 0.18s ease-out;
}
.tv-modal-hdr {
  padding: 18px 22px 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text, #e2e8f0);
}
.tv-modal-body {
  padding: 8px 22px 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted, #94a3b8);
}
.tv-modal-actions {
  padding: 14px 22px 18px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border, #2a3142);
  background: rgba(255, 255, 255, 0.012);
  border-radius: 0 0 var(--radius-lg, 10px) var(--radius-lg, 10px);
}
@keyframes tv-fade-in    { from { opacity: 0; } to { opacity: 1; } }
@keyframes tv-modal-in   {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Filter chips (used on /peers/) ─────────────────────────────────── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px 0;
}
.filter-chip-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  background: var(--surface-2, #1a1f2e);
  border: 1px solid var(--border, #2a3142);
  border-radius: 999px;
  font-size: 0.72rem;
}
.filter-chip-group-label {
  color: var(--text-dim, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.66rem;
  font-weight: 600;
}
.filter-chip {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted, #94a3b8);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
}
.filter-chip:hover {
  background: rgba(124, 106, 247, 0.10);
  color: var(--text, #e2e8f0);
}
.filter-chip.active {
  background: rgba(124, 106, 247, 0.18);
  color: var(--text, #e2e8f0);
  border-color: rgba(124, 106, 247, 0.45);
}
.filter-chip-clear {
  border: none;
  background: none;
  color: var(--text-dim, #64748b);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
}
.filter-chip-clear:hover { color: var(--text, #e2e8f0); background: rgba(255,255,255,0.05); }

/* ── Bulk-action bar (peers list) ───────────────────────────────────── */
.bulk-action-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(124,106,247,0.10), rgba(124,106,247,0.04));
  border: 1px solid rgba(124, 106, 247, 0.32);
  border-radius: var(--radius, 8px);
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--text, #e2e8f0);
  animation: tv-fade-in 0.15s ease-out;
}
.bulk-action-bar.active { display: flex; }
.bulk-action-count {
  font-weight: 700;
  color: var(--accent, #7c6af7);
}
.bulk-action-spacer { flex: 1; }

/* ── Sortable table headers ─────────────────────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}
th.sortable:hover { color: var(--accent, #7c6af7); }
th.sortable .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.7em;
  opacity: 0.35;
  transition: opacity 0.1s, transform 0.1s;
}
th.sortable.sort-asc  .sort-arrow { opacity: 1; }
th.sortable.sort-desc .sort-arrow { opacity: 1; transform: rotate(180deg); }

/* ── Command palette (Cmd+K / Ctrl+K) ───────────────────────────────── */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 8800;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  animation: tv-fade-in 0.14s ease-out;
}
.cmd-palette {
  background: var(--surface, #14172a);
  border: 1px solid var(--border, #2a3142);
  border-radius: var(--radius-lg, 10px);
  width: 100%;
  max-width: 540px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  overflow: hidden;
  animation: tv-modal-in 0.16s ease-out;
}
.cmd-palette-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text, #e2e8f0);
  font-size: 0.95rem;
  padding: 14px 18px;
  outline: none;
  border-bottom: 1px solid var(--border, #2a3142);
  font-family: inherit;
}
.cmd-palette-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: 50vh;
  overflow-y: auto;
}
.cmd-palette-item {
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  border-left: 2px solid transparent;
}
.cmd-palette-item:hover,
.cmd-palette-item.active {
  background: rgba(124, 106, 247, 0.10);
  color: var(--text, #e2e8f0);
  border-left-color: var(--accent, #7c6af7);
}
.cmd-palette-icon {
  width: 22px; text-align: center;
  color: var(--text-dim, #64748b);
  flex-shrink: 0;
}
.cmd-palette-item.active .cmd-palette-icon { color: var(--accent, #7c6af7); }
.cmd-palette-label { flex: 1; }
.cmd-palette-hint  {
  font-size: 0.7rem;
  color: var(--text-dim, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cmd-palette-empty {
  padding: 22px 18px;
  text-align: center;
  color: var(--text-dim, #64748b);
  font-size: 0.82rem;
}

/* ── Keyboard key hints in help overlay ─────────────────────────────── */
kbd, .kbd {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border, #2a3142);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono, monospace);
  font-size: 0.72rem;
  color: var(--text, #e2e8f0);
  display: inline-block;
  line-height: 1.4;
}
.shortcut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 0.84rem;
  color: var(--text-muted, #94a3b8);
}
.shortcut-keys { display: flex; gap: 3px; align-items: center; min-width: 70px; }

/* ── Real-time event feed widget ────────────────────────────────────── */
.event-feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
  max-height: 260px;
  overflow-y: auto;
}
.event-feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  border-radius: 4px;
  animation: tv-fade-in 0.2s ease-out;
}
.event-feed-row:hover { background: rgba(255,255,255,0.025); }
.event-feed-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.event-feed-dot.connected    { background: var(--success, #10b981); box-shadow: 0 0 4px rgba(16,185,129,0.6); }
.event-feed-dot.disconnected { background: var(--text-dim, #64748b); }
.event-feed-dot.killed       { background: var(--danger, #ef4444); }
.event-feed-name { color: var(--text, #e2e8f0); font-weight: 600; }
.event-feed-time { color: var(--text-dim, #64748b); margin-left: auto; font-size: 0.7rem; font-family: var(--mono, monospace); flex-shrink: 0; }
.event-feed-empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--text-dim, #64748b);
  font-size: 0.8rem;
}

/* ── Light theme coverage gaps ──────────────────────────────────────── */
body.theme-light .toast {
  background: #ffffff;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
}
body.theme-light .toast-close { color: #64748b; }
body.theme-light .toast-close:hover { color: #111827; }
body.theme-light .tv-modal {
  background: #ffffff;
  border-color: #e5e7eb;
}
body.theme-light .tv-modal-hdr { color: #111827; }
body.theme-light .tv-modal-body { color: #475569; }
body.theme-light .tv-modal-actions { border-top-color: #e5e7eb; background: #f8fafc; }
body.theme-light .cmd-palette {
  background: #ffffff;
  border-color: #e5e7eb;
}
body.theme-light .cmd-palette-input {
  color: #111827;
  border-bottom-color: #e5e7eb;
}
body.theme-light .cmd-palette-item { color: #475569; }
body.theme-light .cmd-palette-item:hover,
body.theme-light .cmd-palette-item.active {
  background: rgba(124, 106, 247, 0.08);
  color: #111827;
}
body.theme-light .filter-chip-group {
  background: #f1f5f9;
  border-color: #e2e8f0;
}
body.theme-light .filter-chip-group-label { color: #64748b; }
body.theme-light .filter-chip {
  background: rgba(15, 23, 42, 0.04);
  color: #475569;
}
body.theme-light .filter-chip:hover {
  background: rgba(124, 106, 247, 0.10);
  color: #111827;
}
body.theme-light .filter-chip.active {
  background: rgba(124, 106, 247, 0.14);
  color: #111827;
  border-color: rgba(124, 106, 247, 0.42);
}
body.theme-light .skeleton {
  background: linear-gradient(90deg, #e5e7eb 25%, #f1f5f9 50%, #e5e7eb 75%);
  background-size: 200% 100%;
}
body.theme-light kbd, body.theme-light .kbd {
  background: #f8fafc;
  color: #111827;
  border-color: #cbd5e1;
}
body.theme-light .event-feed-row:hover { background: rgba(15,23,42,0.04); }
body.theme-light .event-feed-name { color: #111827; }
body.theme-light .bulk-action-bar { color: #111827; }
body.theme-light th.sortable:hover { color: var(--accent); }

/* ── Light theme — additional surface coverage ──────────────────────── */
body.theme-light {
  /* Make page background slightly different from card surface for separation */
  background: var(--bg);
  color: var(--text);
}
body.theme-light .table-wrap {
  background: var(--surface);
  border-color: var(--border);
}
body.theme-light .table-wrap table thead {
  background: var(--surface-2);
}
body.theme-light .table-wrap table th {
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom-color: var(--border);
}
body.theme-light .table-wrap table td {
  border-bottom-color: var(--border);
  color: var(--text);
}
body.theme-light .noc-table tbody tr:nth-child(odd) td { background: rgba(15,23,42,0.018); }
body.theme-light .noc-table tbody tr:hover td { background: rgba(124,106,247,0.06); }
body.theme-light .noc-pre,
body.theme-light .log-box,
body.theme-light pre.noc-pre {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
body.theme-light .section-title,
body.theme-light .page-title,
body.theme-light .card-title,
body.theme-light .noc-panel-title { color: var(--text); }
body.theme-light .section-sub,
body.theme-light .form-hint { color: var(--text-muted); }
body.theme-light .form-label { color: var(--text); }
body.theme-light .form-input,
body.theme-light .form-select,
body.theme-light .form-textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
body.theme-light .help-overlay { background: rgba(15, 23, 42, 0.45); }
body.theme-light .help-modal {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
body.theme-light .help-section-title { color: var(--text); }
body.theme-light .help-list a { color: var(--accent); }
body.theme-light .help-k { color: var(--text-muted); }
body.theme-light .help-v { color: var(--text); }
body.theme-light .peer-search-input {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
body.theme-light .peer-search-input::placeholder { color: var(--text-dim); }
body.theme-light .peer-search-clear {
  color: var(--text-muted);
  background: var(--surface-2);
}
body.theme-light .peer-search-clear:hover {
  background: var(--surface-3);
  color: var(--text);
}
body.theme-light .empty-state-friendly,
body.theme-light .empty-state {
  background: transparent;
  color: var(--text-muted);
}
body.theme-light .empty-state-heading { color: var(--text); }
body.theme-light .empty-state-sub { color: var(--text-muted); }
body.theme-light .empty-state-icon-lg { opacity: 0.4; }
body.theme-light .badge-muted {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}
body.theme-light .device-badge {
  color: var(--text-muted);
  background: rgba(124, 106, 247, 0.08);
  border-color: rgba(124, 106, 247, 0.2);
}
body.theme-light .last-seen.seen-online { color: var(--success); }
body.theme-light .noc-alert-row {
  color: var(--text-muted);
}
body.theme-light .noc-alert-row:hover { background: var(--surface-2); }
body.theme-light .noc-alert-msg { color: var(--text); }
body.theme-light .noc-alert-none { color: var(--text-dim); }
body.theme-light .noc-quicknav .noc-qbtn {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
body.theme-light .noc-quicknav .noc-qbtn:hover {
  background: var(--surface-3);
}
body.theme-light .noc-action-btn {
  color: var(--text-muted);
  border-color: var(--border);
}
body.theme-light .noc-action-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}
body.theme-light .install-banner {
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  color: var(--text);
}
body.theme-light .nav-link {
  color: var(--text-muted);
}
body.theme-light .nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}
body.theme-light .nav-link.active {
  background: rgba(124, 106, 247, 0.10);
  color: var(--accent);
}
body.theme-light .sidebar-footer {
  border-top-color: var(--border);
}
body.theme-light .sidebar-wg-status { color: var(--text-muted); }
body.theme-light .bottom-nav {
  background: var(--surface);
  border-top: 1px solid var(--border);
}
body.theme-light .bottom-nav-item {
  color: var(--text-muted);
}
body.theme-light .bottom-nav-item.active {
  color: var(--accent);
}
body.theme-light .filter-chip-group { background: var(--surface-2); border-color: var(--border); }
body.theme-light .chart-canvas-wrap { background: var(--surface); }
body.theme-light .last-seen.seen-recent { color: var(--info); }
body.theme-light .last-seen.seen-today  { color: var(--text-muted); }
body.theme-light .last-seen.seen-week,
body.theme-light .last-seen.seen-old    { color: var(--text-dim); }
body.theme-light .last-seen.seen-never  { color: var(--text-dim); }

/* ── Light theme — v3 surface coverage (Telegram-unify refactor pass) ── */
/* These rules cover the last few dark-only colours that were hardcoded
   in early CSS and were missed by the v2 light-theme pass:

   1. `.install-banner.ios-tip` was a literal dark gradient.
   2. `.topology-grid-bg` dots were `rgba(255,255,255,0.04)` — invisible
      on a light background. Switch to a dark-on-light dot.
   3. The toggle-switch thumb was `#e2e8f0` (light grey) which all but
      vanishes on a light slider track. Light theme gets a white thumb
      and a stronger shadow ring instead. */

body.theme-light .install-banner {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.10);
}
body.theme-light .install-banner.ios-tip {
  background: linear-gradient(135deg, #ffffff, #f0f2f8);
}

body.theme-light .topology-grid-bg {
  background-image: radial-gradient(circle, rgba(15,23,42,0.07) 1px, transparent 1px);
}

body.theme-light .toggle-switch .slider::before {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}
body.theme-light .toggle-switch input:checked + .slider::before {
  background: #ffffff;
}

/* Code blocks in peer detail / config pages */
body.theme-light .code-block,
body.theme-light .code-wrap {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Danger-zone card has a hardcoded subtle red tint — keep the accent
   but lift the surface so the warning text isn't on a near-black panel. */
body.theme-light .danger-zone {
  background: rgba(239, 68, 68, 0.04);
  border-color: rgba(239, 68, 68, 0.25);
}

/* Modal backdrops keep a dark dim (intentional, both themes) but the
   surface inside should follow the theme. The Regenerate / Rotate-PSK
   confirm modals use inline `var(--surface)` already — nothing to do
   there. */

/* ═══════════════════════════════════════════════════════════════════════
   MOTION POLISH (v1.10.0) — seamless transitions pass
   Everything below is appended so source order wins over earlier rules.
   Tokens unify timing/easing across previously ad-hoc 0.1/0.12/0.15/0.18s
   transitions. All decorative motion is gated behind prefers-reduced-motion.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --ease-out:     cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out:  cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:  cubic-bezier(0.34, 1.32, 0.64, 1);
  --dur-instant:  90ms;
  --dur-fast:     140ms;
  --dur-base:     200ms;
  --dur-slow:     320ms;
}

html { scroll-behavior: smooth; }

/* ── Page enter — slightly slower + larger lift; pair with JS-driven exit ── */
@keyframes tv-page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-content {
  animation: tv-page-enter var(--dur-base) var(--ease-out) both;
  will-change: opacity, transform;
}
/* Body-level navigating state — set by JS on internal-link click to fade
   the current view out before the browser navigates. Keeps perceptual
   continuity between routes without needing a SPA. */
body.tv-navigating .content {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

/* ── View Transitions API (progressive enhancement) ─────────────────────
   Browsers that support `@view-transition` get a fully native cross-fade
   between pages. Others fall through to the JS-driven .tv-navigating path. */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: tv-vt-out 180ms var(--ease-out) both;
}
::view-transition-new(root) {
  animation: tv-vt-in var(--dur-base) var(--ease-out) both;
}
@keyframes tv-vt-out {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes tv-vt-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* ── Sidebar nav-link polish ────────────────────────────────────────────
   The earlier rule only animates opacity/background/border-color. Add
   an animated accent line that slides in from the left on active state. */
.nav-link {
  transition:
    opacity     var(--dur-fast) var(--ease-out),
    background  var(--dur-fast) var(--ease-out),
    color       var(--dur-fast) var(--ease-out),
    border-left-color var(--dur-fast) var(--ease-out);
}
.nav-link::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transform: scaleY(0);
  transform-origin: center;
  opacity: 0;
  transition:
    transform var(--dur-base) var(--ease-spring),
    opacity   var(--dur-fast) var(--ease-out);
  pointer-events: none;
}
.nav-link.active::before { transform: scaleY(1); opacity: 1; }
/* The original `.nav-link.active` rule sets `border-left-color: var(--accent)`;
   we let the ::before pseudo handle it visually instead. Hide the border. */
.nav-link.active { border-left-color: transparent; }

.nav-icon { transition: transform var(--dur-fast) var(--ease-out); }
.nav-link:hover .nav-icon { transform: translateX(1px); }

/* ── Sidebar overlay (mobile drawer) — fade instead of hard appear ────── */
.sidebar-overlay {
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
body.sidebar-open .sidebar-overlay { opacity: 1; }

/* ── Topbar buttons — subtle scale on press ───────────────────────────── */
.topbar-right .btn,
.topbar-right button {
  transition:
    background var(--dur-fast) var(--ease-out),
    color      var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform  var(--dur-instant) var(--ease-out);
}
.topbar-right .btn:active,
.topbar-right button:active { transform: scale(0.94); }

/* ── Buttons — unified motion + micro-depth ──────────────────────────── */
.btn {
  transition:
    background var(--dur-fast) var(--ease-out),
    color      var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform  var(--dur-instant) var(--ease-out);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-primary:hover { box-shadow: 0 6px 18px -6px rgba(124, 106, 247, 0.55); }
.btn-success:hover { box-shadow: 0 6px 18px -6px rgba(16, 185, 129, 0.45); }
.btn-danger:hover  { box-shadow: 0 6px 18px -6px rgba(239, 68, 68, 0.45); }
.btn-warning:hover { box-shadow: 0 6px 18px -6px rgba(245, 158, 11, 0.45); }
/* Disabled buttons never lift. */
.btn[disabled],
.btn[disabled]:hover,
.btn[disabled]:active { transform: none; box-shadow: none; }

/* ── Stat cards — subtle lift on hover ───────────────────────────────── */
.stat-card {
  transition:
    border-color var(--dur-base) var(--ease-out),
    transform    var(--dur-base) var(--ease-out),
    box-shadow   var(--dur-base) var(--ease-out);
  will-change: transform;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.45);
}

/* ── Cards — gentle border + shadow lift ─────────────────────────────── */
.card {
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow   var(--dur-base) var(--ease-out);
}

/* ── Table rows — slower fade for a calmer scan ──────────────────────── */
tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
tbody tr.clickable-row { transition: background var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-out); }
tbody tr.clickable-row:active { transform: scale(0.998); }

/* ── Form inputs — unified focus motion ──────────────────────────────── */
input, select, textarea {
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background   var(--dur-fast) var(--ease-out),
    box-shadow   var(--dur-fast) var(--ease-out);
}

/* ── Filter chips — slightly springier toggle ────────────────────────── */
.filter-chip {
  transition:
    background var(--dur-fast) var(--ease-out),
    color      var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform  var(--dur-instant) var(--ease-out);
}
.filter-chip:active { transform: scale(0.96); }

/* ── Bottom-nav (mobile) — gentler active glide ──────────────────────── */
.bottom-nav-item {
  transition:
    color     var(--dur-fast) var(--ease-out),
    transform var(--dur-instant) var(--ease-out);
}
.bottom-nav-item:active { transform: scale(0.96); }
.bottom-nav-item .icon { transition: transform var(--dur-fast) var(--ease-spring); }
.bottom-nav-item.active .icon { transform: translateY(-1px) scale(1.05); }

/* ── Toasts — slide in from a slightly larger offset, gentler curve ──── */
@keyframes tv-toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes tv-toast-out {
  to { opacity: 0; transform: translateY(-10px) scale(0.96); }
}
.toast { animation: tv-toast-in var(--dur-base) var(--ease-spring) both; }
.toast.toast-leaving { animation: tv-toast-out 180ms var(--ease-out) forwards; }

/* ── Modal — softer scale entrance ───────────────────────────────────── */
@keyframes tv-modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.tv-modal { animation: tv-modal-in var(--dur-base) var(--ease-spring) both; }
.tv-modal-overlay { animation: tv-fade-in var(--dur-fast) var(--ease-out); }

/* ── Loading bar — gradient sheen on the leading edge ───────────────── */
#tv-loading-bar {
  background:
    linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.25) 50%,
      transparent 100%),
    linear-gradient(90deg, var(--accent), #b794f4);
  background-blend-mode: overlay, normal;
}

/* ── Status dot pulse smoothing (sidebar WG state) ───────────────────── */
.status-dot { transition: background var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }

/* ── Reduce-motion master switch ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .page-content { animation: none; }
  body.tv-navigating .content { opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   AESTHETIC POLISH (v1.10.0 — pass 2) — items 1-11
   1.  Glass topbar + bottom-nav
   2.  Bottom-nav SVG (markup change in base.html)
   3.  Ambient gradient body background
   4.  Refined focus ring
   5.  Stagger grid entrance
   6.  Number count-up (JS in app.js)
   7.  Card hover sheen (CSS var driven; JS sets --mx/--my)
   8.  Active nav indicator gradient
   9.  Topbar status pill (markup change in base.html)
   10. Hairline dividers (gradient borders on key separators)
   11. Typography rhythm (numeric features, tighter heading tracking)
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 11. Typography rhythm ───────────────────────────────────────────── */
:root {
  --t-xs:   0.72rem;
  --t-sm:   0.8rem;
  --t-md:   0.92rem;
  --t-lg:   1.08rem;
  --t-xl:   1.4rem;
}
body {
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Numeric displays universally tabular */
.stat-card-value,
.noc-val,
.noc-speed-val,
.help-v,
td .td-mono,
.td-mono,
.mono,
[class*='-num'],
[class*='num-'] {
  font-variant-numeric: tabular-nums;
}
/* Headings — tighter tracking + display weight */
.page-title,
.card-title,
.help-title,
.tv-modal-hdr {
  letter-spacing: -0.012em;
  font-feature-settings: "cv11", "ss01", "ss03";
}
/* Uppercase labels — slightly looser tracking for legibility */
.stat-card-label,
.noc-lbl,
thead th,
.filter-chip-group-label {
  letter-spacing: 0.075em;
  font-weight: 600;
}

/* ── 3. Ambient background — radial gradient mesh ───────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% -10%, rgba(124, 106, 247, 0.10), transparent 50%),
    radial-gradient(circle at 88% 110%, rgba(80, 70, 200, 0.07), transparent 55%),
    radial-gradient(circle at 50% 50%, rgba(20, 23, 36, 0) 0%, rgba(8, 10, 18, 0.35) 100%);
  background-attachment: fixed;
}
body.theme-light::before {
  background:
    radial-gradient(circle at 15% -10%, rgba(124, 106, 247, 0.08), transparent 50%),
    radial-gradient(circle at 88% 110%, rgba(80, 70, 200, 0.05), transparent 55%);
}

/* ── 1. Glass topbar + bottom-nav ───────────────────────────────────── */
.topbar {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  /* Hairline (item 10): replace flat border with a gradient under-line */
  background-image:
    linear-gradient(color-mix(in srgb, var(--surface) 70%, transparent),
                    color-mix(in srgb, var(--surface) 70%, transparent)),
    linear-gradient(90deg,
      transparent 0%,
      var(--border) 18%,
      var(--border) 82%,
      transparent 100%);
  background-clip: padding-box, border-box;
  background-origin: padding-box, border-box;
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 100% 1px;
  background-position: 0 0, 0 100%;
}
.bottom-nav {
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

/* The sidebar gets a hairline right-edge gradient too (item 10) */
.sidebar {
  border-right-color: transparent;
  background-image:
    linear-gradient(var(--surface), var(--surface)),
    linear-gradient(180deg,
      transparent 0%,
      var(--border) 8%,
      var(--border) 92%,
      transparent 100%);
  background-clip: padding-box, border-box;
  background-origin: padding-box, border-box;
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 1px 100%;
  background-position: 0 0, 100% 0;
}

/* ── 4. Refined focus ring ──────────────────────────────────────────── */
:where(a, button, input, select, textarea, [tabindex]):focus { outline: none; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 75%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
  transition:
    outline-color var(--dur-fast) var(--ease-out),
    box-shadow    var(--dur-fast) var(--ease-out);
}
/* Inputs already have their own focus styling — keep their box-shadow ring,
   but make it consistent with the global accent + offset. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ── 5. Stagger grid entrance ──────────────────────────────────────── */
@keyframes tv-grid-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.stats-grid > *,
.noc-bar .noc-stat,
.help-stats > * {
  animation: tv-grid-in var(--dur-base) var(--ease-out) both;
}
.stats-grid > *:nth-child(1),
.noc-bar .noc-stat:nth-child(1) { animation-delay: 0ms; }
.stats-grid > *:nth-child(2),
.noc-bar .noc-stat:nth-child(2) { animation-delay: 40ms; }
.stats-grid > *:nth-child(3),
.noc-bar .noc-stat:nth-child(3) { animation-delay: 80ms; }
.stats-grid > *:nth-child(4),
.noc-bar .noc-stat:nth-child(4) { animation-delay: 120ms; }
.stats-grid > *:nth-child(5),
.noc-bar .noc-stat:nth-child(5) { animation-delay: 160ms; }
.stats-grid > *:nth-child(6),
.noc-bar .noc-stat:nth-child(6) { animation-delay: 200ms; }
.stats-grid > *:nth-child(7),
.noc-bar .noc-stat:nth-child(7) { animation-delay: 240ms; }
.stats-grid > *:nth-child(n+8),
.noc-bar .noc-stat:nth-child(n+8) { animation-delay: 280ms; }

/* ── 7. Card hover sheen ────────────────────────────────────────────── */
.stat-card,
.card.tv-sheen,
.noc-panel.tv-sheen {
  position: relative;
  isolation: isolate;
}
.stat-card::after,
.card.tv-sheen::after,
.noc-panel.tv-sheen::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    rgba(124, 106, 247, 0.10),
    transparent 65%
  );
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
  z-index: 0;
}
.stat-card:hover::after,
.card.tv-sheen:hover::after,
.noc-panel.tv-sheen:hover::after { opacity: 1; }
/* The card content needs to sit above the sheen layer. */
.stat-card > *,
.card.tv-sheen > *,
.noc-panel.tv-sheen > * { position: relative; z-index: 1; }

/* ── 8. Active nav indicator gradient ──────────────────────────────── */
.nav-link::before {
  background: linear-gradient(180deg, var(--accent), #b794f4);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}
.nav-link.active {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 13%, transparent),
    color-mix(in srgb, var(--accent) 4%, transparent) 60%,
    transparent);
}
/* Bottom-nav active gets the same gradient feel via a top accent line */
.bottom-nav-item.active::before {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  height: 2px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 50%, transparent);
}

/* ── 10. Hairline dividers (gradient) — applied to high-visibility seams  */
.card-header,
thead th,
.help-hdr,
.tv-modal-actions {
  border-bottom-color: transparent;
}
.card-header {
  background-image:
    linear-gradient(var(--surface), var(--surface)),
    linear-gradient(90deg, transparent, var(--border) 12%, var(--border) 88%, transparent);
  background-origin: padding-box, border-box;
  background-clip: padding-box, border-box;
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 100% 1px;
  background-position: 0 0, 0 100%;
}
.help-hdr {
  background-image:
    linear-gradient(var(--surface-2), var(--surface-2)),
    linear-gradient(90deg, transparent, var(--border) 12%, var(--border) 88%, transparent);
  background-origin: padding-box, border-box;
  background-clip: padding-box, border-box;
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 100% 1px;
  background-position: 0 0, 0 100%;
}
thead th {
  position: relative;
}
thead th::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 8%, var(--border) 92%, transparent);
}

/* ── 9. Topbar WireGuard status pill ────────────────────────────────── */
.topbar-wg-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  color: var(--text-muted);
  margin-right: 4px;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    color        var(--dur-fast) var(--ease-out),
    background   var(--dur-fast) var(--ease-out);
}
.topbar-wg-pill .topbar-wg-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  transition: background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.topbar-wg-pill.up {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
  background: color-mix(in srgb, var(--success) 8%, var(--surface-2));
}
.topbar-wg-pill.up .topbar-wg-dot {
  background: var(--success);
  box-shadow: 0 0 8px color-mix(in srgb, var(--success) 70%, transparent);
}
.topbar-wg-pill.down {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface-2));
}
@media (max-width: 540px) {
  .topbar-wg-pill .topbar-wg-text { display: none; }
  .topbar-wg-pill { padding: 4px 6px; }
}

/* ── Bottom-nav SVG sizing (paired with template change) ──────────────── */
.bottom-nav-item .icon-svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.bottom-nav-item.active .icon-svg { transform: translateY(-1px) scale(1.06); }

/* ── 6. Count-up — paired with JS; sets reset state ──────────────────── */
[data-tv-count] {
  font-variant-numeric: tabular-nums;
}


/* ════════════════════════════════════════════════════════════════════════
   v1.12.0 — Sleek polish + restructure pass
   Append-only (source order wins). Mirrors existing token / focus-ring /
   hairline patterns. No earlier rules edited.
   ════════════════════════════════════════════════════════════════════════ */

/* ── A1. Spacing + radius scale tokens (additive; alias existing) ───────── */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   var(--radius);
  --r-lg:   var(--radius-lg);
  --r-pill: 999px;
}

/* ── A2. Form states — disabled + invalid (were missing entirely) ──────── */
.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--surface-3);
}
.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
/* :user-invalid only fires AFTER user interaction, so pristine create/wizard
   forms never flag red on load. [aria-invalid] covers explicit JS-set state. */
.form-input:user-invalid, .form-select:user-invalid, .form-textarea:user-invalid,
.form-input[aria-invalid="true"], .form-select[aria-invalid="true"], .form-textarea[aria-invalid="true"] {
  border-color: var(--danger);
}
.form-input:user-invalid:focus, .form-select:user-invalid:focus, .form-textarea:user-invalid:focus,
.form-input[aria-invalid="true"]:focus, .form-select[aria-invalid="true"]:focus, .form-textarea[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 24%, transparent);
}

/* ── A3. Light-theme gap fills (scoped to .theme-light; dark unaffected) ── */
body.theme-light .stat-card-icon.purple { background: rgba(124,106,247,0.12); }
body.theme-light .stat-card-icon.green  { background: rgba(16,185,129,0.12); }
body.theme-light .stat-card-icon.blue   { background: rgba(59,130,246,0.12); }
body.theme-light .stat-card-icon.orange { background: rgba(245,158,11,0.14); }
body.theme-light .stat-card-icon.red    { background: rgba(239,68,68,0.12); }
body.theme-light .stat-card-icon.teal   { background: rgba(20,184,166,0.12); }
body.theme-light .flash-success { color: #047857; }
body.theme-light .flash-error   { color: #b91c1c; }
body.theme-light .flash-warning { color: #b45309; }
body.theme-light .flash-info    { color: #1d4ed8; }
body.theme-light .code-block    { color: #0f766e; }
body.theme-light .leaflet-container { background: #dfe3ec !important; }

/* ── B1. NOC bar legibility — labels readable, a touch more air ─────────── */
.noc-lbl { color: var(--text-muted); }
.noc-bar { gap: 9px; }

/* ── B2. NOC separators: │ glyphs → soft vertical hairlines (desktop) ───── */
@media (min-width: 769px) {
  /* a touch more vertical air — vertical-only, so no horizontal overflow */
  .noc-bar, .noc-health-bar, .noc-pihole-bar {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .noc-sep {
    color: transparent;
    font-size: 0;
    width: 1px;
    height: 13px;
    padding: 0;
    margin: 0 4px;
    display: inline-block;
    vertical-align: middle;
    background: linear-gradient(180deg, transparent, var(--border) 28%, var(--border) 72%, transparent);
  }
}

/* ── C. Tunnel-mode badges → reusable classes (were duplicated inline in
   peers/list + peers/detail). Styles mirror the originals exactly. ──────── */
.badge-cyan  { background: rgba(34,211,238,.15); color: #22d3ee; border: 1px solid rgba(34,211,238,.30); }
.badge-amber { background: rgba(251,191,36,.15); color: #fbbf24; border: 1px solid rgba(251,191,36,.30); }
body.theme-light .badge-cyan  { color: #0e7490; background: rgba(34,211,238,.16); }
body.theme-light .badge-amber { color: #b45309; background: rgba(251,191,36,.20); }

/* ── E1. Touch tap targets — topbar icon buttons ≥44px on touch devices ── */
@media (pointer: coarse) {
  .topbar-right .btn-ghost.btn-sm {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── E2. Peers table scroll affordance — soft shadows reveal when the
   horizontally-scrollable table (.table-wrap already overflow-x:auto) has
   more content off-edge. Lea-Verou technique: surface "cover" gradients
   (attachment:local) sit at the content edges and hide the shadow gradients
   (attachment:scroll) until you scroll away from that edge. ─────────────── */
.table-wrap {
  background:
    linear-gradient(90deg, var(--surface), transparent) 0 0 / 32px 100% no-repeat,
    linear-gradient(90deg, transparent, var(--surface)) 100% 0 / 32px 100% no-repeat,
    radial-gradient(farthest-side at 0 50%,   rgba(0,0,0,.35), transparent) 0 0 / 16px 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.35), transparent) 100% 0 / 16px 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}

/* ── Dashboard traffic-chart range toggle (15 min / 24h / 7d) ───────────── */
.chart-range-toggle {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  line-height: 1;
}
.chart-range-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              color      var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.chart-range-btn:hover:not(.active) { color: var(--text-muted); }
.chart-range-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px -1px color-mix(in srgb, var(--accent) 65%, transparent);
}


