/* ── reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 13px; }
body { height: 100%; overflow: hidden; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
pre { font: inherit; white-space: pre-wrap; }

/* ── design tokens — light base ────────────────────────────────────────────── */
:root {
  --bg:          #edf2f9;
  --surface:     #f8faff;
  --surface2:    #e4ecf8;
  --surface3:    #d5e1f2;
  --border:      #c0cfea;
  --border2:     #9ab0d4;
  --accent:      #0072ab;
  --accent-glow: rgba(0, 114, 171, 0.12);
  --accent-text: #005580;
  --text:        #0c1828;
  --text-dim:    #496480;
  --text-muted:  #7a98b8;
  --red:         #c92540;
  --red-dim:     rgba(201, 37, 64, 0.10);
  --green:       #009952;
  --green-dim:   rgba(0, 153, 82, 0.10);
  --amber:       #c07000;
  --amber-dim:   rgba(192, 112, 0, 0.10);
  --cyan:        #0072ab;
  --sidebar-w:   220px;
  --topbar-h:    48px;
  --radius:      6px;
  --radius-lg:   10px;
  font-family: 'SF Mono', 'Cascadia Code', 'JetBrains Mono', 'Fira Code', ui-monospace, 'Courier New', monospace;
}

/* ── dark — system preference ──────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #06090f;
    --surface:     #0b1222;
    --surface2:    #101c34;
    --surface3:    #172648;
    --border:      #1a2e50;
    --border2:     #234070;
    --accent:      #00c8f0;
    --accent-glow: rgba(0,200,240,0.11);
    --accent-text: #00c8f0;
    --text:        #d4e6f8;
    --text-dim:    #526e8a;
    --text-muted:  #2e4560;
    --red:         #ff3050;
    --red-dim:     rgba(255,48,80,0.11);
    --green:       #00df78;
    --green-dim:   rgba(0,223,120,0.11);
    --amber:       #ffaa00;
    --amber-dim:   rgba(255,170,0,0.11);
    --cyan:        #00c8f0;
  }
}

/* ── dark — explicit toggle ────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg:          #06090f;
  --surface:     #0b1222;
  --surface2:    #101c34;
  --surface3:    #172648;
  --border:      #1a2e50;
  --border2:     #234070;
  --accent:      #00c8f0;
  --accent-glow: rgba(0,200,240,0.11);
  --accent-text: #00c8f0;
  --text:        #d4e6f8;
  --text-dim:    #526e8a;
  --text-muted:  #2e4560;
  --red:         #ff3050;
  --red-dim:     rgba(255,48,80,0.11);
  --green:       #00df78;
  --green-dim:   rgba(0,223,120,0.11);
  --amber:       #ffaa00;
  --amber-dim:   rgba(255,170,0,0.11);
  --cyan:        #00c8f0;
}

/* ── layout ────────────────────────────────────────────────────────────────── */
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; }

#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 18px; gap: 16px;
  flex-shrink: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: baseline; gap: 6px; }
.topbar-brand-name { font-size: 14px; font-weight: 700; color: var(--accent-text); letter-spacing: 0.12em; }
.topbar-brand-sub { font-size: 10px; color: var(--text-muted); letter-spacing: 0.15em; }
.topbar-nodes { display: flex; align-items: center; gap: 8px; margin-left: 8px; }
.node-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px;
  border: 1px solid var(--border); font-size: 10px;
  color: var(--text-dim); letter-spacing: 0.05em;
}
.node-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2.5s ease-in-out infinite;
}
.node-dot.offline { background: var(--red); box-shadow: 0 0 6px var(--red); animation: none; }
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.4} }
.topbar-spacer { flex: 1; }
.topbar-nav { display: flex; align-items: center; gap: 2px; }
.nav-item {
  padding: 5px 12px; border-radius: var(--radius);
  font-size: 11px; letter-spacing: 0.07em;
  color: var(--text-dim); cursor: pointer;
  transition: color 0.14s, background 0.14s;
  border: 1px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent-text); background: var(--accent-glow); border-color: var(--accent); }
.topbar-logout {
  padding: 5px 10px; border-radius: var(--radius);
  font-size: 10px; letter-spacing: 0.08em;
  color: var(--text-muted); border: 1px solid var(--border);
  transition: all 0.14s;
}
.topbar-logout:hover { color: var(--red); border-color: var(--red); }

.content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 26px 30px; min-height: 0;
}
.page { display: none; }
.page.active { display: block; }

/* ── login ─────────────────────────────────────────────────────────────────── */
#login-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 100;
}
.login-box {
  width: 440px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 40px 44px;
}
.login-logo {
  font-size: 9.5px; line-height: 1.2; color: var(--accent-text);
  letter-spacing: 0; margin-bottom: 6px; white-space: pre;
}
.logo-sub { display: block; font-size: 11px; letter-spacing: 0.5em; color: var(--text-muted); margin-top: 6px; }
.login-tagline { font-size: 10px; color: var(--text-muted); letter-spacing: 0.06em; margin: 12px 0 26px; }
.west { color: var(--accent-text); }
.login-prompt { font-size: 11px; letter-spacing: 0.12em; color: var(--text-dim); margin-bottom: 18px; }
.login-error {
  font-size: 11px; color: var(--red); letter-spacing: 0.05em;
  margin-bottom: 14px; padding: 8px 12px;
  background: var(--red-dim); border-radius: var(--radius); border: 1px solid var(--red);
}
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-field { display: flex; align-items: center; gap: 10px; }
.login-label { font-size: 10px; letter-spacing: 0.12em; color: var(--text-dim); width: 56px; flex-shrink: 0; }
.login-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; color: var(--text); outline: none;
  transition: border-color 0.14s;
}
.login-input:focus { border-color: var(--accent); }
.login-btn {
  margin-top: 8px; padding: 10px;
  background: var(--accent-glow); border: 1px solid var(--accent);
  border-radius: var(--radius); color: var(--accent-text);
  letter-spacing: 0.1em; font-size: 11px; transition: all 0.14s;
}
.login-btn:hover { background: var(--accent); color: var(--bg); }
.login-footer { margin-top: 22px; font-size: 10px; color: var(--text-muted); letter-spacing: 0.05em; }
.tech-name { color: var(--text-dim); }

/* ── page chrome ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-title { font-size: 17px; font-weight: 700; letter-spacing: 0.05em; }
.page-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.04em; }

.section { margin-bottom: 28px; }
.section-title {
  font-size: 10px; letter-spacing: 0.16em; color: var(--text-muted);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* ── buttons ───────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 11px; letter-spacing: 0.07em;
  border: 1px solid var(--border); color: var(--text-dim);
  background: var(--surface2); transition: all 0.14s; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface3); }
.btn-primary { background: var(--accent-glow); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.btn-danger { border-color: var(--red); color: var(--red); background: var(--red-dim); }
.btn-danger:hover { background: var(--red); color: var(--bg); }
.btn-green { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.btn-green:hover { background: var(--green); color: var(--bg); }
.btn-amber { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }
.btn-amber:hover { background: var(--amber); color: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 10px; }

/* ── inputs ────────────────────────────────────────────────────────────────── */
.input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 10px;
  color: var(--text); outline: none; transition: border-color 0.14s; font-size: 12px;
}
.input:focus { border-color: var(--accent); }
.input-wide { width: 220px; }

/* ── profile cards ─────────────────────────────────────────────────────────── */
.profiles-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(276px, 1fr)); gap: 12px;
}
.profile-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--card-color, var(--accent));
  border-radius: var(--radius-lg); padding: 18px 20px;
  cursor: pointer; transition: all 0.17s;
}
.profile-card:hover {
  border-color: var(--card-color, var(--border2));
  background: var(--surface2); transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}
.profile-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.profile-icon { font-size: 22px; line-height: 1; }
.profile-card-name { font-size: 14px; font-weight: 700; letter-spacing: 0.03em; }
.profile-card-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 14px; min-height: 16px; }
.profile-card-stats { display: flex; gap: 20px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.stat-label { font-size: 9px; letter-spacing: 0.12em; color: var(--text-muted); }

/* ── profile detail ────────────────────────────────────────────────────────── */
.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim); letter-spacing: 0.07em;
  cursor: pointer; margin-bottom: 18px; padding: 3px 0;
  transition: color 0.14s;
}
.back-link:hover { color: var(--accent-text); }
.detail-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  margin-bottom: 26px; padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.detail-title-group { display: flex; align-items: center; gap: 14px; }
.detail-icon { font-size: 30px; line-height: 1; }
.detail-name { font-size: 20px; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 4px; }
.detail-doh { font-size: 10px; color: var(--text-muted); letter-spacing: 0.03em; }
.detail-doh span { color: var(--accent-text); }
.detail-actions { display: flex; gap: 7px; flex-shrink: 0; }
.detail-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start;
}
@media (max-width: 840px) { .detail-cols { grid-template-columns: 1fr; } }

/* ── category pills ────────────────────────────────────────────────────────── */
.cat-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.cat-pill {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 9px; border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer;
  user-select: none; transition: all 0.14s;
  background: var(--surface);
}
.cat-pill:hover { border-color: var(--border2); background: var(--surface2); }
.cat-pill.enabled {
  border-color: var(--pill-color, var(--accent));
  background: color-mix(in srgb, var(--pill-color, var(--accent)) 9%, var(--surface));
}
.cat-pill input { display: none; }
.cat-pill-icon { font-size: 13px; flex-shrink: 0; }
.cat-pill-name { font-size: 10px; color: var(--text-dim); flex: 1; transition: color 0.14s; }
.cat-pill.enabled .cat-pill-name { color: var(--text); }
.cat-pill-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--border); flex-shrink: 0; transition: all 0.14s;
}
.cat-pill.enabled .cat-pill-dot {
  background: var(--pill-color, var(--accent));
  box-shadow: 0 0 5px var(--pill-color, var(--accent));
}

/* ── security toggles ──────────────────────────────────────────────────────── */
.security-rows { display: flex; flex-direction: column; gap: 5px; }
.security-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); gap: 12px; cursor: pointer;
  transition: border-color 0.14s;
}
.security-row:hover { border-color: var(--border2); }
.security-name { font-size: 11px; color: var(--text); margin-bottom: 2px; }
.security-desc { font-size: 10px; color: var(--text-muted); }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--surface3); border-radius: 20px;
  border: 1px solid var(--border); transition: all 0.18s; cursor: pointer;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  left: 2px; top: 2px;
  background: var(--text-muted); transition: all 0.18s;
}
.toggle input:checked + .toggle-slider { background: var(--accent-glow); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { left: 18px; background: var(--accent); }

/* ── exit node cards ───────────────────────────────────────────────────────── */
.exit-node-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 7px;
  margin-bottom: 8px;
}
.exit-card {
  padding: 11px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.14s; text-align: center;
}
.exit-card:hover { border-color: var(--border2); background: var(--surface2); }
.exit-card.active { border-color: var(--accent); background: var(--accent-glow); }
.exit-card-flag { font-size: 20px; margin-bottom: 4px; line-height: 1; }
.exit-card-name { font-size: 10px; letter-spacing: 0.05em; color: var(--text-dim); }
.exit-card.active .exit-card-name { color: var(--accent-text); }
.exit-desc { font-size: 10px; color: var(--text-muted); margin-top: 7px; min-height: 14px; }

/* ── custom domains ────────────────────────────────────────────────────────── */
.custom-domain-form { display: flex; gap: 6px; margin-bottom: 9px; flex-wrap: wrap; }
.custom-domain-list { display: flex; flex-direction: column; gap: 4px; }
.custom-domain-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; background: var(--surface2);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.custom-domain-badge {
  font-size: 9px; letter-spacing: 0.1em;
  padding: 2px 7px; border-radius: 20px; font-weight: 700; flex-shrink: 0;
}
.custom-domain-badge.block { background: var(--red-dim); color: var(--red); }
.custom-domain-badge.allow { background: var(--green-dim); color: var(--green); }
.custom-domain-name { font-size: 11px; color: var(--text); flex: 1; }

/* ── services ──────────────────────────────────────────────────────────────── */
.services-search { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 6px; }
.service-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; transition: border-color 0.14s;
}
.service-card.block { border-color: var(--red); background: var(--red-dim); }
.service-card.allow { border-color: var(--green); background: var(--green-dim); }
.service-emoji { font-size: 18px; margin-bottom: 4px; }
.service-name { font-size: 11px; color: var(--text); margin-bottom: 1px; font-weight: 600; }
.service-cat { font-size: 9px; color: var(--text-muted); letter-spacing: 0.05em; margin-bottom: 8px; }
.service-actions { display: flex; gap: 3px; }
.service-btn {
  flex: 1; padding: 3px 0; font-size: 9px; letter-spacing: 0.05em;
  border: 1px solid var(--border); border-radius: 3px;
  color: var(--text-dim); background: var(--surface2); transition: all 0.12s;
}
.service-btn:hover { border-color: var(--border2); color: var(--text); }
.service-btn.active-block { background: var(--red); border-color: var(--red); color: #fff; }
.service-btn.active-allow { background: var(--green); border-color: var(--green); color: #fff; }

/* ── devices ───────────────────────────────────────────────────────────────── */
.devices-list { display: flex; flex-direction: column; gap: 7px; }
.device-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); transition: border-color 0.14s;
}
.device-row:hover { border-color: var(--border2); }
.device-type { font-size: 22px; flex-shrink: 0; width: 28px; text-align: center; }
.device-info { flex: 1; min-width: 0; }
.device-name { font-size: 13px; font-weight: 700; color: var(--text); }
.device-doh { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-profile { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.device-actions { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* device query log */
.device-log {
  background: var(--surface); border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 12px 14px; max-height: 260px; overflow-y: auto;
}
.log-row {
  display: grid;
  grid-template-columns: 68px 1fr 36px 44px 68px;
  gap: 8px; align-items: center;
  padding: 4px 0; border-bottom: 1px solid var(--border);
  font-size: 10px;
}
.log-row:last-child { border-bottom: none; }
.log-result {
  font-size: 9px; letter-spacing: 0.07em;
  padding: 1px 5px; border-radius: 3px;
  text-align: center; font-weight: 700;
}
.log-blocked   .log-result { background: var(--red-dim);    color: var(--red);   }
.log-resolved  .log-result { background: var(--green-dim);  color: var(--green); }
.log-cached    .log-result { background: var(--accent-glow);color: var(--accent-text); }
.log-safesearch .log-result{ background: var(--amber-dim);  color: var(--amber); }
.log-domain { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.log-type, .log-ms, .log-ts { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ── analytics ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
}
.stat-card-val {
  font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text); line-height: 1; margin-bottom: 6px;
}
.stat-card-label { font-size: 9px; letter-spacing: 0.13em; color: var(--text-muted); }
.stat-bar { margin-top: 8px; height: 2px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.log-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.log-table th {
  text-align: left; font-size: 9px; letter-spacing: 0.12em;
  color: var(--text-muted); padding: 6px 10px; border-bottom: 1px solid var(--border);
}
.log-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--border);
  color: var(--text); font-variant-numeric: tabular-nums;
}
.log-table tr:last-child td { border-bottom: none; }
.log-blocked { color: var(--red); }
.log-allowed { color: var(--green); }
.log-table-wrap { overflow-x: auto; }

/* ── nodes ─────────────────────────────────────────────────────────────────── */
.nodes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.node-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.node-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.node-flag { font-size: 24px; }
.node-name { font-size: 14px; font-weight: 700; }
.node-id-tag { font-size: 9px; color: var(--text-muted); letter-spacing: 0.06em; }
.node-field { margin-bottom: 8px; }
.node-field label { font-size: 9px; letter-spacing: 0.11em; color: var(--text-muted); display: block; margin-bottom: 3px; }
.node-field .input { width: 100%; font-size: 11px; }
.node-secret {
  font-size: 10px; color: var(--text-dim); background: var(--surface2);
  border-radius: var(--radius); padding: 6px 8px; word-break: break-all;
  border: 1px solid var(--border);
}
.node-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ── modal ─────────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; backdrop-filter: blur(2px);
}
#modal-overlay.hidden { display: none; }
#modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  max-width: 580px; width: 90%; max-height: 85vh; overflow-y: auto;
}
.modal-title { font-size: 14px; font-weight: 700; letter-spacing: 0.07em; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-group { margin-bottom: 14px; }
.form-label { font-size: 10px; letter-spacing: 0.1em; color: var(--text-dim); display: block; margin-bottom: 5px; }
.form-control { width: 100%; }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.emoji-opt {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; transition: all 0.12s;
}
.emoji-opt:hover { border-color: var(--border2); background: var(--surface2); }
.emoji-opt.selected { border-color: var(--accent); background: var(--accent-glow); }
.os-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.os-tab {
  padding: 5px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  font-size: 11px; cursor: pointer; color: var(--text-dim); transition: all 0.12s;
}
.os-tab:hover { color: var(--text); border-color: var(--border2); }
.os-tab.active { color: var(--accent-text); border-color: var(--accent); background: var(--accent-glow); }
.os-panel { display: none; }
.os-panel.active { display: block; }
.os-step { margin-bottom: 16px; }
.os-step-title { font-size: 11px; color: var(--text-dim); letter-spacing: 0.03em; margin-bottom: 6px; }
.os-code {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; font-size: 11px;
  color: var(--text); position: relative; white-space: pre-wrap; word-break: break-all;
}
.copy-code-btn {
  position: absolute; top: 6px; right: 6px;
  padding: 3px 8px; font-size: 9px; border-radius: 3px;
  border: 1px solid var(--border); color: var(--text-dim);
  background: var(--surface); letter-spacing: 0.05em; transition: all 0.12s;
}
.copy-code-btn:hover { color: var(--text); border-color: var(--border2); }
.os-note { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.download-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); color: var(--accent-text);
  background: var(--accent-glow); font-size: 11px;
  letter-spacing: 0.05em; transition: all 0.14s;
}
.download-btn:hover { background: var(--accent); color: var(--bg); }

/* ── empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 30px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-text { font-size: 13px; margin-bottom: 16px; }

/* ── utils ─────────────────────────────────────────────────────────────────── */
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-accent { color: var(--accent-text); }

/* ── analytics v2 ──────────────────────────────────────────────────────────── */
.analytics-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
@media (max-width: 900px) { .analytics-layout { grid-template-columns: 1fr; } }
.analytics-left {}
.analytics-right {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; position: sticky; top: 16px;
  max-height: calc(100vh - 80px); overflow-y: auto;
}
.analytics-detail-empty { color: var(--text-muted); font-size: 11px; padding: 40px 0; text-align: center; }
.analytics-detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 22px; }
.analytics-header-row {
  display: grid; grid-template-columns: 1fr 100px 70px 50px 1fr;
  gap: 8px; font-size: 9px; letter-spacing: 0.12em; color: var(--text-muted);
  padding: 6px 0; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.analytics-device-row {
  display: grid; grid-template-columns: 1fr 100px 70px 50px 1fr;
  gap: 8px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--border); cursor: pointer;
  border-radius: var(--radius); transition: background 0.1s;
}
.analytics-device-row:hover, .analytics-device-row.selected { background: var(--surface2); }
.analytics-device-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.analytics-device-prof { font-size: 9px; color: var(--text-muted); font-weight: 400; }
.analytics-bars { display: contents; }
.analytics-bar-wrap { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.analytics-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
.analytics-num { font-size: 10px; font-variant-numeric: tabular-nums; color: var(--text-dim); text-align: right; }
.analytics-rate { font-size: 10px; font-variant-numeric: tabular-nums; font-weight: 700; }
.analytics-rate.rate-high { color: var(--red); }
.analytics-rate.rate-med { color: var(--amber); }
.analytics-top-blocked { display: flex; flex-wrap: wrap; gap: 4px; }
.blocked-chip {
  font-size: 9px; padding: 2px 5px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 3px; color: var(--text-dim);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* hourly chart */
.hourly-chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 80px; padding: 4px 0; border-bottom: 1px solid var(--border);
}
.chart-col { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 0; cursor: default; }
.chart-bar-wrap { position: relative; width: 100%; }
.chart-bar-q { background: var(--cyan); opacity: 0.35; border-radius: 2px 2px 0 0; }
.chart-bar-b { background: var(--red); position: absolute; bottom: 0; left: 0; width: 100%; border-radius: 2px 2px 0 0; }
.chart-legend { display: flex; gap: 12px; font-size: 9px; color: var(--text-muted); margin-top: 5px; }

/* top blocked + cat hits */
.analytics-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.top-blocked-list, .cat-hits-list { display: flex; flex-direction: column; gap: 3px; }
.top-blocked-row { display: flex; justify-content: space-between; align-items: center; font-size: 10px; padding: 2px 0; }
.top-blocked-domain { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.top-blocked-count { font-variant-numeric: tabular-nums; color: var(--red); font-size: 10px; margin-left: 6px; flex-shrink: 0; }
.cat-hit-row { display: flex; justify-content: space-between; font-size: 10px; padding: 2px 0; }

/* node selector */
.node-selector {
  display: flex; gap: 4px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 2px;
}
.node-sel-btn {
  font-size: 10px; letter-spacing: 0.07em; padding: 3px 8px;
  border-radius: calc(var(--radius) - 2px); cursor: pointer;
  color: var(--text-muted); transition: all 0.12s;
}
.node-sel-btn.active, .node-sel-btn:hover { background: var(--accent); color: #000; }

/* resolver pool */
.resolver-list { display: flex; flex-direction: column; gap: 6px; }
.resolver-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 11px;
}
.resolver-row.resolver-down { opacity: 0.55; border-color: var(--red); }
.resolver-id { font-weight: 700; color: var(--cyan); min-width: 60px; }
.resolver-type { color: var(--text-muted); font-size: 10px; flex: 1; }
.resolver-health { font-size: 10px; font-weight: 600; }
.health-ok { color: var(--green); }
.health-down { color: var(--red); }

/* webhooks */
.webhook-add-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 8px;
}
.wh-event-toggles { display: flex; gap: 10px; font-size: 11px; color: var(--text-dim); }
.wh-event-toggles label { display: flex; align-items: center; gap: 4px; }
.webhook-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px;
}
.webhook-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.webhook-url { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.webhook-events { font-size: 9px; color: var(--text-muted); letter-spacing: 0.07em; }
.webhook-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* dns records section */
.muted { color: var(--text-muted); }

/* exit nodes page */
.exits-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; padding: 20px;
}
.exit-node-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; display: flex;
  flex-direction: column; gap: 12px;
}
.exit-node-card.up { border-color: var(--green); }
.exit-node-card.down { opacity: 0.7; }
.enc-header { display: flex; align-items: center; gap: 12px; }
.enc-flag { font-size: 28px; line-height: 1; }
.enc-info { flex: 1; min-width: 0; }
.enc-name { font-size: 13px; font-weight: 700; letter-spacing: 0.05em; }
.enc-meta { font-size: 10px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enc-status { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; }
.enc-status.up { color: var(--green); }
.enc-status.down { color: var(--red); }
.enc-footer { display: flex; gap: 8px; }
.btn-xs { font-size: 9px; padding: 4px 8px; }
.btn-warning { border-color: var(--yellow, #facc15); color: var(--yellow, #facc15); }
.btn-warning:hover { background: color-mix(in srgb, var(--yellow, #facc15) 15%, transparent); }

/* WG exit card in profile picker */
.exit-card.wg { position: relative; }
.exit-card-vpn { font-size: 8px; letter-spacing: 0.1em; color: var(--green); margin-top: 2px; }
.exit-card.wg.active .exit-card-vpn { color: var(--accent-text); }

/* Query log domain override */
.btn-override { font-size: 9px; padding: 2px 7px; margin-left: auto; border-color: var(--green); color: var(--green); opacity: 0.7; flex-shrink: 0; }
.btn-override:hover { background: color-mix(in srgb, var(--green) 15%, transparent); opacity: 1; }
.log-overridden { opacity: 0.45; text-decoration: line-through; }
.log-overridden .btn-override { border-color: var(--text-muted); color: var(--text-muted); text-decoration: none; }
