  * { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --bg: #0a0e1a; --panel: #111827; --border: #1f2937;
    --text: #e2e8f0; --muted: #6b7280; --accent: #3b82f6;
    --green: #10b981; --yellow: #f59e0b; --red: #ef4444;
    --purple: #8b5cf6; --cyan: #06b6d4;
  }
  body { background: var(--bg); color: var(--text); font-family: 'SF Mono','Fira Code',monospace; font-size: 13px; overflow: hidden; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  .is-hidden { display: none !important; }
  .login-overlay {
    position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center;
    padding: 20px; background:
      radial-gradient(circle at 18% 12%, rgba(56,189,248,0.16), transparent 34%),
      radial-gradient(circle at 85% 85%, rgba(16,185,129,0.12), transparent 38%),
      rgba(3,8,18,0.96);
  }
  .login-card {
    width: min(440px, 100%); padding: 34px; border: 1px solid rgba(56,189,248,0.25);
    border-radius: 18px; background: rgba(12,21,38,0.94);
    box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  }
  .login-eyebrow { color: var(--cyan); font-size: 10px; letter-spacing: 0.16em; }
  .login-card h1 { margin: 10px 0 8px; font-size: 22px; }
  .login-card p { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
  .login-card input {
    width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); background: rgba(255,255,255,0.04); font: inherit;
  }
  .login-primary, .login-google {
    display: block; width: 100%; margin-top: 12px; padding: 11px; border-radius: 8px;
    border: 1px solid var(--accent); color: white; background: var(--accent);
    font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
  }
  .login-google { border-color: var(--border); background: transparent; }
  .login-error { min-height: 18px; margin-top: 12px; color: var(--red); font-size: 11px; }
  .demo-banner { display: none; background: #f59e0b; color: #000; font-size: 11px; font-weight: bold; padding: 2px 8px; border-radius: 4px; letter-spacing: .04em; }
  .demo-banner.is-visible { display: block; }

  /* ── Settings overlay ────────────────────────────── */
  #settings-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; transition: opacity 0.2s, visibility 0.2s;
    visibility: visible;
  }
  #settings-overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
  .settings-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    height: 90vh; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  }
  .settings-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
  }
  .settings-title { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: 0.05em; }
  .settings-close { background: transparent; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px; }
  .settings-close:hover { color: var(--text); }
  .settings-body { display: flex; flex: 1; overflow: hidden; }
  /* Tabs (left sidebar) */
  .settings-tabs {
    width: 80px; flex-shrink: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 12px 0; gap: 4px;
  }
  .settings-tab {
    display: flex; flex-direction: column; align-items: center;
    padding: 10px 6px; border: none; background: transparent;
    cursor: pointer; border-radius: 0; gap: 3px;
    border-left: 3px solid transparent; transition: all 0.15s;
  }
  .settings-tab:hover { background: rgba(255,255,255,0.04); }
  .settings-tab.active { background: rgba(59,130,246,0.08); border-left-color: var(--accent); }
  .tab-badge {
    font-size: 11px; font-weight: 700; font-family: 'SF Mono','Fira Code',monospace;
    color: var(--muted); letter-spacing: 0.02em;
  }
  .settings-tab.active .tab-badge { color: var(--accent); }
  .tab-name { font-size: 9px; color: var(--muted); letter-spacing: 0.06em; }
  /* Tab content (right) */
  .settings-panes { flex: 1; overflow-y: auto; padding: 20px 22px; }
  .settings-pane { display: none; }
  .settings-pane.active { display: block; }
  .pane-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 12px; font-weight: 600; color: var(--text);
    margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
    cursor: pointer; user-select: none;
  }
  .pane-title input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; }
  .section-inputs { transition: opacity 0.2s; }
  .section-inputs.disabled { opacity: 0.35; pointer-events: none; }
  .settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .form-group { margin-bottom: 12px; }
  .form-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 5px; display: block; }
  .form-input {
    width: 100%; padding: 8px 12px; background: rgba(255,255,255,0.05);
    border: 1px solid var(--border); border-radius: 6px; color: var(--text);
    font-family: inherit; font-size: 12px; transition: border-color 0.15s; outline: none;
  }
  .form-input:focus { border-color: var(--accent); }
  .connect-btn {
    width: 100%; padding: 10px; margin-top: 8px;
    background: var(--accent); border: none; border-radius: 8px;
    color: #fff; font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background 0.15s, opacity 0.15s;
  }
  .connect-btn:hover { background: #2563eb; }
  .connect-btn:disabled { opacity: 0.5; cursor: default; }
  .settings-status {
    margin-top: 12px; padding: 8px 12px; border-radius: 6px;
    font-size: 12px; display: none;
  }
  .settings-status.is-visible { display: block; }
  .settings-status.multiline { white-space: pre-line; }
  .settings-status.ok  { background: rgba(16,185,129,0.12); border: 1px solid rgba(16,185,129,0.3); color: var(--green); }
  .settings-status.err { background: rgba(239,68,68,0.12);  border: 1px solid rgba(239,68,68,0.35); color: var(--red); }
  .settings-session-section-title { cursor: default; font-size: 12px; margin-bottom: 8px; }
  .settings-session-list { font-size: 11px; }
  .settings-session-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
  .settings-session-label { flex: 1; }
  .settings-session-current { color: var(--green); font-size: 9px; margin-left: 4px; }
  .settings-session-method {
    margin-left: 6px; padding: 1px 4px; border: 1px solid var(--border);
    border-radius: 4px; color: var(--cyan); font-size: 8px;
  }
  .settings-session-role {
    margin-left: 6px; padding: 1px 4px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 8px; color: var(--muted);
  }
  .settings-session-role-admin { color: #fbbf24; }
  .settings-session-role-operator { color: var(--cyan); }
  .settings-session-role-unknown { color: var(--red, #ef4444); }
  .settings-session-seen, .settings-session-muted { color: var(--muted); font-size: 10px; }
  .settings-session-revoke-all { width: auto; padding: 5px 14px; margin-top: 8px; font-size: 10px; background: transparent; border: 1px solid var(--border); color: var(--muted); }
  .settings-security-actions { display: flex; gap: 8px; }
  .settings-security-actions .connect-btn { width: auto; min-width: 120px; }
  .settings-audit-list { max-height: 220px; overflow: auto; font-size: 10px; }
  .settings-audit-row {
    display: grid; grid-template-columns: minmax(120px, 1fr) 64px 70px 116px;
    gap: 8px; align-items: center; padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
  .settings-audit-event { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
  .settings-audit-outcome { color: var(--green); }
  .settings-audit-outcome.failure { color: var(--red); }
  .backup-list-empty { padding: 4px; }
  .settings-description-example, .settings-description-highlight { color: var(--cyan); }
  .settings-description-example { font-size: 10px; }
  .pane-title-static { cursor: default; }
  .settings-copy { font-size: 10px; color: var(--muted); line-height: 1.5; }
  .settings-copy-general { margin-top: 6px; line-height: 1.6; }
  .settings-copy-indented { margin-top: 4px; padding-left: 22px; }
  .settings-copy-block { margin-bottom: 10px; }
  .settings-form-spaced { margin-top: 18px; }
  .settings-form-narrow { max-width: 260px; }
  .settings-check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 11px; }
  .settings-check-label-large { font-size: 12px; }
  .settings-checkbox { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
  .settings-checkbox-accent { accent-color: var(--accent); }
  .settings-revoke-label { margin-bottom: 8px; }
  .settings-save-spaced { margin-top: 16px; }
  .settings-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
  .settings-subsection-title { cursor: default; font-size: 12px; margin-bottom: 8px; }
  .settings-inline-button { width: auto; padding: 6px 16px; }
  .token-regenerate-btn { background: transparent; border: 1px solid var(--red, #f87171); color: var(--red, #f87171); }
  .settings-copy-section { margin-bottom: 12px; }
  .settings-copy-left { padding-left: 22px; }
  .settings-feed-label { margin: 4px 0; }
  .settings-form-top-10 { margin-top: 10px; }
  .settings-form-top-12 { margin-top: 12px; }
  .settings-form-top-8 { margin-top: 8px; }
  .threat-feed-status { margin-top: 12px; font-size: 10px; color: var(--muted); line-height: 1.5; }
  .manual-threat-keys { display: grid; gap: 8px; }
  .manual-threat-clear { margin-top: 5px; font-size: 9px; color: var(--muted); }
  .manual-threat-lookup { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,.12); }
  .manual-threat-provider-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 12px; }
  .manual-threat-send { width: 100%; }
  .manual-threat-results { display: grid; gap: 8px; margin-top: 10px; }
  .manual-threat-result { padding: 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 10px; }
  .manual-threat-result.ok { border-color: rgba(39,201,151,.35); }
  .manual-threat-result.error { border-color: rgba(255,92,92,.35); }
  .manual-threat-result dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 3px 10px; margin: 7px 0 0; }
  .manual-threat-result dt { color: var(--muted); }
  .manual-threat-result dd { margin: 0; overflow-wrap: anywhere; }
  .ai-settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .ai-test-button { background: transparent; border: 1px solid var(--accent); color: var(--accent); }
  .ai-test-button:hover { background: rgba(59,130,246,.12); }
  .ai-key-clear { margin-top: 7px; font-size: 9px; color: var(--muted); }
  .ai-privacy-note { margin-top: 14px; line-height: 1.55; }
  .settings-pane-toggle { margin-bottom: 8px; font-size: 12px; }
  .settings-list-textarea { resize: vertical; font-family: monospace; font-size: 10px; line-height: 1.6; }
  .settings-field-hint { font-size: 9px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
  .ai-model-pricing-status.is-priced { color: var(--green); }
  .ai-model-pricing-status.is-unpriced { color: #fbbf24; }
  .settings-subsection-title-wide { margin-bottom: 12px; }
  .slack-small-button { padding: 5px 12px; width: auto; }
  .slack-verify-button { margin-top: 6px; font-size: 10px; }
  .slack-lookup-button { white-space: nowrap; font-size: 9px; flex-shrink: 0; }
  .slack-info { display: none; font-size: 10px; margin-top: 4px; }
  .slack-info.is-visible { display: block; }
  .slack-info.ok { color: var(--green); }
  .slack-info.err { color: var(--red); }
  .slack-user-row { display: flex; gap: 6px; align-items: center; }
  .slack-user-input { flex: 1; min-width: 0; }
  .slack-create-wrap { margin-top: 12px; }
  .slack-create-link { font-size: 10px; color: var(--accent); text-decoration: none; }
  .slack-actions { display: flex; gap: 8px; margin-top: 12px; }
  .slack-test-button { background: transparent; border-color: var(--accent); color: var(--accent); }
  .backup-list-section { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
  .backup-list { font-size: 11px; color: var(--muted); margin: 8px 0; max-height: 150px; overflow-y: auto; }
  .backup-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
  .backup-upload-label { cursor: pointer; }
  .backup-list-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--border); }
  .backup-list-label { flex: 1; }
  .backup-list-button { font-size: 9px; padding: 2px 6px; }
  .backup-capacity-status { display: block; margin: 7px 0; white-space: pre-line; }
  .datasource-copy { margin-bottom: 16px; }
  .settings-divider-compact { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
  .legacy-router-controls { display: none !important; }
  .router-pane-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
  .router-pane-title { margin: 0 0 5px; padding: 0; border: 0; cursor: default; }
  .router-pane-copy { color: var(--muted); font-size: 10px; line-height: 1.5; }
  .router-count { border: 1px solid var(--border); border-radius: 999px; padding: 3px 8px; color: var(--cyan); font-size: 10px; white-space: nowrap; }
  .router-list { display: grid; gap: 8px; }
  .router-empty { border: 1px dashed var(--border); border-radius: 10px; padding: 20px 12px; color: var(--muted); text-align: center; font-size: 11px; }
  .router-card { background: rgba(255,255,255,0.025); border: 1px solid var(--border); border-radius: 10px; padding: 11px; display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center; }
  .router-card-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(107,114,128,.12); }
  .router-card-dot.ready { background: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.12); }
  .router-card-dot.wait { background: var(--yellow); box-shadow: 0 0 0 3px rgba(245,158,11,.12); }
  .router-card-dot.error { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
  .router-card-name { font-size: 12px; font-weight: 700; }
  .router-card-meta { color: var(--muted); font-size: 10px; margin-top: 3px; }
  .router-card-actions { display: flex; gap: 5px; }
  .router-icon-btn { background: transparent; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; cursor: pointer; font-family: inherit; }
  .router-icon-btn:hover { border-color: var(--accent); color: var(--text); }
  .router-add-btn { margin-top: 10px; background: transparent; border: 1px dashed var(--accent); color: var(--accent); }
  .router-add-btn:hover { background: rgba(59,130,246,.1); }
  .router-editor { margin-top: 14px; border: 1px solid var(--accent); border-radius: 12px; padding: 13px; background: rgba(59,130,246,.045); }
  .router-editor.hidden, .router-enable-group.hidden { display: none; }
  .router-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; color: var(--cyan); }
  .router-enabled { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text); margin-bottom: 4px; }
  .router-editor-actions { display: grid; grid-template-columns: 1.2fr .8fr; gap: 8px; }
  .router-secondary-btn { background: transparent; border: 1px solid var(--border); color: var(--text); }
  .router-secondary-btn:hover { background: rgba(255,255,255,.06); }
  .spinner {
    display: inline-block; width: 12px; height: 12px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 6px; vertical-align: middle;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  /* ── Disconnected banner ─────────────────────────── */
  #disconnected-banner {
    display: none; padding: 8px 20px; background: rgba(239,68,68,0.12);
    border-bottom: 1px solid rgba(239,68,68,0.3); color: var(--red);
    font-size: 12px; text-align: center; flex-shrink: 0;
  }
  #disconnected-banner button {
    background: transparent; border: 1px solid var(--red); border-radius: 4px;
    color: var(--red); font-family: inherit; font-size: 11px; padding: 2px 8px;
    cursor: pointer; margin-left: 8px; transition: background 0.15s;
  }
  #disconnected-banner button:hover { background: rgba(239,68,68,0.2); }
  #disconnected-banner.is-visible { display: block; }

  /* ── Header ─────────────────────────────────────── */
  header { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); flex-shrink: 0; }
  header h1 { font-size: 15px; font-weight: 600; color: var(--accent); letter-spacing: 0.05em; }
  .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
  .status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
  .status-dot.error  { background: var(--red);   box-shadow: 0 0 6px var(--red); }
  /* ── Time filter ─────────────────────────────────── */
  .time-filter {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 3px 4px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px;
  }
  .time-filter-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding-left: 4px; }
  .time-filter select {
    background: transparent; border: none; outline: none;
    color: var(--text); font-family: inherit; font-size: 11px; cursor: pointer;
    padding: 3px 4px;
  }
  .time-filter select option { background: var(--panel); color: var(--text); }
  .time-filter.disabled { opacity: 0.35; pointer-events: none; }
  .time-custom-input {
    background: transparent; border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-family: inherit; font-size: 11px; padding: 2px 4px;
    color-scheme: dark; outline: none;
  }
  .time-custom-input:focus { border-color: var(--accent); }
  /* ── Connection badges ───────────────────────────── */
  .conn-badges { display: flex; gap: 6px; align-items: center; }
  .conn-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 8px; border: 1px solid var(--border); border-radius: 5px;
    font-size: 11px; color: var(--muted); background: var(--bg);
  }
  .conn-badge .badge-layer { font-family: 'SF Mono','Fira Code',monospace; font-weight: 700; color: var(--muted); font-size: 10px; letter-spacing: 0.02em; }
  .conn-badge .badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
  .conn-badge .badge-ip { color: var(--text); font-size: 11px; }
  .conn-badge.on  { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.08); }
  .conn-badge.on  .badge-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
  .conn-badge.on  .badge-layer { color: var(--green); }
  .conn-badge.off { border-color: rgba(107,114,128,0.3); opacity: 0.5; }
  .conn-badge.err { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }
  .conn-badge.err .badge-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
  .conn-badge.err .badge-layer { color: var(--red); }
  .conn-badge.wait { border-color: rgba(234,179,8,0.35); background: rgba(234,179,8,0.08); }
  .conn-badge.wait .badge-dot { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
  .conn-badge.wait .badge-layer { color: var(--yellow); }
  .header-stats { display: flex; gap: 24px; margin-left: auto; }
  .stat { display: flex; flex-direction: column; align-items: flex-end; }
  .stat-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
  .stat-value { font-size: 13px; font-weight: 600; }
  .value-rx { color: var(--green); }
  .value-tx { color: var(--red); }
  .custom-range { display: none; margin-left: 6px; align-items: center; gap: 4px; }
  .custom-range.is-visible { display: inline-flex; }
  .custom-range-separator { color: var(--muted); font-size: 10px; }
  /* ── View tabs ───────────────────────────────────── */
  .view-tabs { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
  .view-tab {
    padding: 4px 12px; background: transparent; border: none; border-radius: 5px;
    color: var(--muted); font-family: inherit; font-size: 11px; cursor: pointer;
    transition: background 0.15s, color 0.15s; white-space: nowrap;
  }
  .view-tab.active { background: var(--accent); color: #fff; }
  .view-tab:not(.active):hover { background: var(--border); color: var(--text); }
  /* ── Settings button ─────────────────────────────── */
  .settings-btn {
    margin-left: 8px; padding: 5px 10px; background: transparent;
    border: 1px solid var(--border); border-radius: 6px; color: var(--muted);
    font-family: inherit; font-size: 14px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
  }
  .settings-btn:hover { border-color: var(--accent); color: var(--accent); }
  .settings-btn.alert { border-color: var(--red); color: var(--red); animation: pulse-border 1.5s ease-in-out infinite; }
  @keyframes pulse-border { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); } 50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); } }

  /* ── Main layout ─────────────────────────────────── */
  .main { display: flex; flex: 1; overflow: hidden; }
  #graph-container { flex: 1; position: relative; overflow: hidden; }
  #graph-container:not(.view-active) { display: none; }
  #graph-container.view-active { display: flex; }

  .dash-pill.ok { background: rgba(34,197,94,0.15); color: #4ade80; }
  .dash-pill.bad { background: rgba(239,68,68,0.18); color: #f87171; }
  #dash-globe svg { cursor: grab; }
  #dash-globe svg:active { cursor: grabbing; }
  /* ── Zoom controls ────────────────────────────────── */
  .zoom-controls {
    position: absolute; right: 10px; bottom: 16px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: rgba(17,24,39,0.92); border: 1px solid var(--border);
    border-radius: 8px; padding: 6px; z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  .zoom-btn {
    width: 28px; height: 28px; background: transparent; border: none;
    color: var(--text); font-family: inherit; font-size: 14px;
    cursor: pointer; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
  }
  .zoom-btn:hover { background: rgba(59,130,246,0.2); color: var(--accent); }
  .zoom-slider-wrap {
    display: flex; flex-direction: column; align-items: center;
    height: 100px; margin: 4px 0; justify-content: center;
  }
  .zoom-slider {
    appearance: none; -webkit-appearance: none;
    width: 80px; height: 4px; background: var(--border); border-radius: 2px;
    outline: none; transform: rotate(-90deg); transform-origin: center;
  }
  .zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; background: var(--accent);
    border-radius: 50%; cursor: pointer; border: 2px solid var(--panel);
  }
  .zoom-slider::-moz-range-thumb {
    width: 12px; height: 12px; background: var(--accent);
    border-radius: 50%; cursor: pointer; border: 2px solid var(--panel);
  }
  .zoom-pct { font-size: 9px; color: var(--muted); font-family: 'SF Mono','Fira Code',monospace; min-width: 28px; text-align: center; }
  #graph { width: 100%; height: 100%; }
  /* ── Stats view ──────────────────────────────────── */
  #stats-container {
    flex: 1; display: none; flex-direction: column; overflow: hidden;
    background: var(--bg); padding: 10px; gap: 10px;
  }
  #stats-container.view-active { display: flex; }
  .stats-header { font-size: 12px; font-weight: 600; color: var(--text); padding: 4px 8px; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
  #stats-title, #stats-subtitle { flex-shrink: 0; }
  .stats-subtitle { color: var(--muted); font-size: 11px; }
  .stats-map-coverage {
    display: none;
    flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    padding: 3px 8px;
    border: 1px solid rgba(56,189,248,0.28); border-radius: 6px;
    background: rgba(14,165,233,0.08); color: #9ddcff;
    font-size: 10px; line-height: 1.2;
  }
  .stats-map-coverage.is-visible { display: inline; }
  .data-fetching-hdr { display: none; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); margin-left: auto; flex-shrink: 0; }
  .data-fetching-hdr.is-visible { display: flex; }
  /* Connection Log */
  .activity-view { display: none; flex-direction: column; flex: 1; overflow: hidden; background: var(--bg); padding: 10px; gap: 8px; }
  .activity-view.view-active { display: flex; }
  .ai-view {
    overflow-y: auto; padding: clamp(16px, 3vw, 40px); gap: 18px;
    background:
      radial-gradient(circle at 88% 4%, rgba(14,165,233,0.16), transparent 32%),
      radial-gradient(circle at 8% 92%, rgba(16,185,129,0.10), transparent 34%),
      var(--bg);
  }
  .ai-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
  .ai-hero-actions { display: flex; gap: 8px; }
  .ai-eyebrow { color: #38bdf8; font-size: 10px; font-weight: 800; letter-spacing: 0.18em; }
  .ai-hero h2 { margin: 5px 0 4px; font-size: clamp(24px, 4vw, 42px); letter-spacing: -0.04em; }
  .ai-hero p { margin: 0; color: var(--muted); font-size: 12px; }
  .ai-refresh { border: 1px solid rgba(56,189,248,0.4); border-radius: 999px; padding: 7px 16px; color: #7dd3fc; background: rgba(14,165,233,0.08); cursor: pointer; }
  .ai-refresh:hover { background: rgba(14,165,233,0.16); }
  .ai-period { margin-top: 4px; color: var(--muted); font-size: 11px; }
  .ai-collection { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; max-width: 1180px; width: 100%; margin: 0 auto; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: rgba(17,24,39,0.72); font-size: 11px; }
  .ai-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
  .ai-collection.is-ok .ai-pulse { background: var(--green); box-shadow: 0 0 10px var(--green); }
  .ai-collection.is-partial .ai-pulse { background: var(--yellow); box-shadow: 0 0 10px var(--yellow); }
  .ai-collection.is-error .ai-pulse { background: var(--red); box-shadow: 0 0 10px var(--red); }
  .ai-router-list { display: flex; flex-wrap: wrap; gap: 5px; }
  .ai-router { padding: 3px 7px; border-radius: 999px; background: rgba(107,114,128,0.12); color: var(--muted); }
  .ai-router.is-ready { color: #86efac; background: rgba(34,197,94,0.1); }
  .ai-router.is-error { color: #fca5a5; background: rgba(239,68,68,0.1); }
  .ai-updated { margin-left: auto; color: var(--muted); }
  .ai-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; max-width: 1180px; width: 100%; margin: 0 auto; }
  .ai-metric { min-width: 0; padding: 20px; text-align: left; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, rgba(31,41,55,0.94), rgba(17,24,39,0.84)); color: var(--text); cursor: pointer; transition: transform 0.18s, border-color 0.18s; }
  .ai-metric:hover { transform: translateY(-2px); border-color: rgba(56,189,248,0.55); }
  .ai-metric-label { display: block; color: var(--muted); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
  .ai-metric strong { display: block; margin: 9px 0 7px; font-size: clamp(24px, 3vw, 38px); font-weight: 760; letter-spacing: -0.04em; }
  .ai-delta { color: var(--muted); font-size: 10px; }
  .ai-delta.is-up { color: #7dd3fc; }
  .ai-delta.is-down { color: #86efac; }
  .ai-metric-warn.has-findings { border-color: rgba(234,179,8,0.6); background: linear-gradient(145deg, rgba(113,63,18,0.32), rgba(17,24,39,0.9)); }
  .ai-metric-danger.has-findings { border-color: rgba(239,68,68,0.65); background: linear-gradient(145deg, rgba(127,29,29,0.34), rgba(17,24,39,0.9)); }
  .ai-usage-summary { max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 20px; border: 1px solid rgba(56,189,248,0.2); border-radius: 14px; background: rgba(17,24,39,0.66); }
  .ai-usage-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
  .ai-usage-head h3 { margin: 0 0 4px; font-size: 13px; }
  .ai-usage-head p { margin: 0; color: var(--muted); font-size: 10px; }
  .ai-usage-currency { padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; color: #7dd3fc; font-size: 9px; letter-spacing: 0.12em; }
  .ai-usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
  .ai-usage-card { min-width: 0; padding: 14px 16px; border-radius: 11px; background: rgba(3,7,18,0.42); }
  .ai-usage-period, .ai-usage-detail { display: block; color: var(--muted); font-size: 10px; }
  .ai-usage-card strong { display: block; margin: 6px 0 3px; font-size: 22px; letter-spacing: -0.03em; }
  .ai-usage-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; color: #bae6fd; font-size: 10px; }
  .ai-usage-caveat { min-height: 1em; margin: 8px 0 0; color: #fbbf24; font-size: 9px; }
  .ai-usage-unpriced { min-height: 1em; color: #fbbf24; font-size: 9px; }
  .ai-error { display: none; max-width: 1180px; width: 100%; margin: 0 auto; color: #fca5a5; }
  .ai-error.is-visible { display: block; }
  .ai-analysis { display: flex; align-items: flex-start; gap: 16px; max-width: 1180px; width: 100%; margin: 2px auto 0; padding: 24px; border: 1px solid rgba(56,189,248,0.32); border-radius: 14px; background: linear-gradient(135deg, rgba(14,165,233,0.08), rgba(17,24,39,0.82)); }
  .ai-analysis-body { min-width: 0; flex: 1; }
  .ai-analysis-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
  .ai-analysis-cancel { border: 0; color: #fca5a5; background: transparent; cursor: pointer; }
  .ai-analysis-cancel.is-hidden { display: none; }
  .ai-analysis-meta { color: var(--muted); font-size: 10px; }
  .ai-analysis-result { min-height: 80px; margin: 0; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 10px; background: rgba(3,7,18,0.55); color: var(--text); font: 12px/1.75 inherit; }
  .ai-placeholder-mark { font-size: 28px; color: #38bdf8; }
  .ai-analysis h3 { margin: 0 0 5px; font-size: 14px; }
  .ai-analysis p { margin: 0; color: var(--muted); font-size: 11px; }
  .ai-chat { max-width: 1180px; width: 100%; margin: 0 auto; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: rgba(17,24,39,0.72); }
  .ai-chat-head, .ai-chat-tools, .ai-chat-compose { display: flex; align-items: center; gap: 10px; }
  .ai-chat-head { justify-content: space-between; align-items: flex-start; }
  .ai-chat h3 { margin: 0 0 5px; font-size: 14px; }
  .ai-chat p { margin: 0; color: var(--muted); font-size: 11px; }
  .ai-chat-tools select { min-width: 180px; }
  .ai-chat-messages { display: flex; flex-direction: column; gap: 8px; min-height: 100px; max-height: 340px; margin: 16px 0; overflow: auto; }
  .ai-chat-message { max-width: 82%; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.6; }
  .ai-chat-message.is-user { align-self: flex-end; background: rgba(14,165,233,0.18); }
  .ai-chat-message.is-assistant { align-self: flex-start; background: rgba(31,41,55,0.92); }
  .ai-chat-message.is-failed { color: #fca5a5; border: 1px solid rgba(239,68,68,0.35); }
  .ai-chat-message.is-pending { color: var(--muted); font-style: italic; }
  .ai-chat-message-meta { margin-top: 7px; padding-top: 6px; border-top: 1px solid rgba(148,163,184,0.16); color: var(--muted); font-size: 10px; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
  .ai-chat-compose textarea { flex: 1; resize: vertical; }
  .ai-notification-modal { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 18px; background: rgba(2,6,23,0.78); backdrop-filter: blur(8px); }
  .ai-notification-modal.is-hidden { display: none; }
  .ai-notification-brief { max-width: 30rem; color: var(--muted); font-size: 0.72rem; line-height: 1.35; text-align: right; }
  .ai-notification-card { width: min(760px, 100%); max-height: min(850px, 92vh); overflow: auto; padding: 24px; border: 1px solid rgba(56,189,248,0.35); border-radius: 18px; background: #0f1726; box-shadow: 0 24px 80px rgba(0,0,0,0.55); }
  .notification-settings-card { width: 100%; }
  .notification-settings-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
  .notification-rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-notification-confirm-modal { z-index: 1210; }
  .ai-notification-confirm-card { width: min(520px, 100%); }
  .ai-notification-summary { display: grid; grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.5fr); margin: 20px 0 0; border-top: 1px solid var(--border); }
  .ai-notification-summary-row { display: contents; }
  .ai-notification-summary dt, .ai-notification-summary dd { margin: 0; padding: 10px 8px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
  .ai-notification-summary dt { color: var(--muted); font-size: 10px; }
  .ai-notification-summary dd { color: var(--text); font-size: 11px; }
  .ai-notification-head { display: flex; justify-content: space-between; gap: 18px; }
  .ai-notification-head h3, .ai-notification-history h4 { margin: 0 0 5px; }
  .ai-notification-head p { margin: 0; color: var(--muted); font-size: 11px; }
  .ai-notification-close { border: 0; color: var(--muted); background: transparent; font-size: 25px; cursor: pointer; }
  .ai-notification-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
  .ai-notification-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
  .ai-notification-fieldset { display: flex; flex-wrap: wrap; gap: 14px; margin: 18px 0 0; padding: 14px; border: 1px solid var(--border); border-radius: 11px; }
  .ai-notification-fieldset legend { padding: 0 6px; color: #bae6fd; font-size: 11px; }
  .ai-notification-fieldset .ai-notification-grid { flex-basis: 100%; margin-top: 2px; }
  .ai-notification-consent { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 10px; line-height: 1.5; }
  .ai-notification-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
  .ai-notification-history { margin-top: 20px; }
  .ai-notification-event { padding: 10px 12px; border-top: 1px solid var(--border); }
  .ai-notification-event strong, .ai-notification-event span { display: block; }
  .ai-notification-event span { margin-top: 3px; color: var(--muted); font-size: 10px; }
  .ai-notification-event pre { max-height: 130px; overflow: auto; margin: 8px 0 0; white-space: pre-wrap; color: var(--text); font: 10px/1.55 inherit; }
  @media (max-width: 700px) { .ai-chat-head, .ai-chat-tools, .ai-chat-compose { align-items: stretch; flex-direction: column; } .ai-chat-message { max-width: 95%; } }
  .log-header { font-size: 12px; font-weight: 600; color: var(--text); padding: 4px 8px; display: flex; align-items: center; gap: 8px; }
  .log-title { font-size: 13px; }
  .activity-count { color: var(--muted); font-size: 11px; }
  .activity-count-spaced, .activity-filter-spaced { margin-left: 8px; }
  .activity-filter { display: none; }
  .activity-filter.is-visible { display: inline; }
  .activity-refresh { margin-left: auto; padding: 3px 10px; font-size: 11px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--text); cursor: pointer; }
  .log-export-controls { margin-left: auto; display: flex; align-items: center; gap: 5px; }
  .log-export-controls select, .log-export-controls button {
    border: 1px solid var(--border); border-radius: 5px; background: var(--panel);
    color: var(--text); font-family: inherit; font-size: 10px; padding: 3px 7px;
  }
  .log-export-controls button { cursor: pointer; }
  .log-export-controls button:hover { border-color: var(--accent); color: var(--accent); }
  .log-export-controls button:disabled { opacity: 0.55; cursor: wait; }
  .log-header .data-fetching-hdr { margin-left: 0; }
  .log-pagination { display: none; align-items: center; gap: 8px; padding: 4px 8px; font-size: 12px; color: var(--muted); }
  .log-pagination.is-visible { display: flex; }
  .log-threat-badge { background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
  .log-table-wrap { flex: 1; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
  .log-table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .log-table th { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; font-weight: 600; color: var(--muted); white-space: nowrap; }
  .log-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
  .log-table tr:hover { background: rgba(59,130,246,0.06); }
  .log-table tr.threat-row { background: rgba(239,68,68,0.08); }
  .log-table tr.threat-row:hover { background: rgba(239,68,68,0.14); }
  .log-threat-icon { color: #ef4444; font-weight: bold; }
  .log-threat-tag { font-size: 9px; color: #ef4444; max-width: 200px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: middle; cursor: default; }
  .log-badge-danger { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 700; background: #ef444433; color: #ef4444; border: 1px solid #ef444455; margin-right: 4px; }
  .log-badge-warn { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 700; background: #f59e0b33; color: #f59e0b; border: 1px solid #f59e0b55; margin-right: 4px; }
  .log-threat-low { color: #f59e0b; }
  .log-table tr.warn-row { background: rgba(245,158,11,0.06); }
  .log-table tr.warn-row:hover { background: rgba(245,158,11,0.12); }
  .log-badge-safe { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 600; background: #22c55e22; color: #4ade80; border: 1px solid #22c55e44; }
  .log-badge-clickable { cursor: pointer; transition: box-shadow 0.15s, transform 0.1s; }
  .log-badge-clickable:hover { box-shadow: 0 0 0 2px rgba(255,255,255,0.15); transform: scale(1.05); }
  #log-threat-count .log-badge-clickable { margin-right: 4px; }
  .log-status-text { color: var(--muted); font-size: 11px; }
  .log-device-filter-chip { background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 7px; font-size: 11px; cursor: pointer; }
  .log-table td.log-scroll-sentinel-cell { height: 1px; padding: 0; border: none; }
  .log-app-cell { font-size: 11px; color: var(--muted); }
  .log-org-cell { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .notif-log-clickable-row { cursor: pointer; }
  .notif-log-empty-cell { text-align: center; color: var(--muted); padding: 32px; }
  .notif-log-error-cell { text-align: center; color: var(--red); padding: 24px; }
  .notif-log-type-threat { color: var(--red); font-weight: 700; }
  .notif-log-type-device, .notif-log-slack-sent { color: var(--green); }
  .notif-log-time-cell { white-space: nowrap; font-size: 11px; }
  .notif-log-subtext { color: var(--muted); font-size: 10px; }
  .notif-log-threat-text { color: var(--red); font-size: 11px; }
  .notif-log-subtle-text, .notif-log-org-cell { color: var(--muted); font-size: 11px; }
  .notif-log-slack-cell, .notif-log-slack-sent { text-align: center; }
  .log-filter-active { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.08); }

  /* ── Beacon banner ────────────────────────────────────────────── */
  /* flex-shrink:0 — the banner keeps its natural height inside #log-container's
     flex column; the candidate list scrolls internally (max-height) so the
     log table below always retains its own space and scrollbar */
  #beacon-banner { display: none; flex-shrink: 0; border-bottom: 1px solid rgba(251,191,36,0.25); background: rgba(251,191,36,0.07); }
  #beacon-banner.is-visible { display: block; }
  #beacon-banner-bar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; cursor: pointer; user-select: none; font-size: 12px; font-weight: 600; color: #fbbf24; }
  #beacon-banner-bar:hover { background: rgba(251,191,36,0.12); }
  .beacon-chevron { font-size: 9px; transition: transform 0.2s; }
  .beacon-chevron.open { transform: rotate(180deg); }
  #beacon-list { display: none; padding: 0 8px 8px; max-height: 40vh; overflow-y: auto; }
  #beacon-list.is-visible { display: block; }
  .beacon-table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .beacon-table th { color: var(--muted); font-weight: 600; text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); }
  .beacon-table td { padding: 5px 6px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
  .beacon-table tr:last-child td { border-bottom: none; }
  .beacon-table tr:hover td { background: rgba(255,255,255,0.03); }
  .beacon-destination-ip, .beacon-time-cell { color: var(--muted); font-size: 10px; }
  .beacon-nowrap, .beacon-time-cell { white-space: nowrap; }
  .beacon-muted { color: var(--muted); }
  .beacon-cov-low  { color: #4ade80; font-weight: 700; }
  .beacon-cov-mid  { color: #fbbf24; font-weight: 700; }
  .beacon-cov-high { color: #f97316; font-weight: 700; }
  .beacon-dismiss-btn { font-size: 10px; padding: 2px 7px; border-radius: 3px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
  .beacon-dismiss-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

  .threat-clickable { cursor: pointer; }
  .threat-detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; align-items: center; justify-content: center; }
  .threat-detail-overlay.hidden { display: none; }
  .threat-detail-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: 520px; max-width: calc(100vw - 20px); max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
  .threat-detail-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; color: #ef4444; }
  .threat-detail-body { padding: 16px 18px; }
  .threat-detail-body table { width: 100%; border-collapse: collapse; font-size: 11px; }
  .threat-detail-body th { text-align: left; padding: 5px 8px; color: var(--muted); font-weight: 600; white-space: nowrap; width: 30%; vertical-align: top; }
  .threat-detail-body td { padding: 5px 8px; word-break: break-all; }
  .threat-detail-body tr { border-bottom: 1px solid var(--border); }
  .threat-detail-body .section-title { font-size: 11px; font-weight: 700; color: var(--accent); margin: 12px 0 6px; padding-top: 8px; border-top: 1px solid var(--border); }
  .threat-confidence-wrap { margin: 8px 0; }
  .threat-confidence-badge { padding: 3px 8px; font-size: 11px; }
  .threat-guidance { margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.03); color: var(--text); font-size: 11px; line-height: 1.6; white-space: pre-wrap; }
  .threat-url-value { font-size: 10px; word-break: break-all; }
  .threat-note-wrap { margin-bottom: 8px; }
  .threat-detail-note { width: 100%; min-height: 60px; padding: 8px; resize: vertical; border: 1px solid var(--border); border-radius: 6px; background: rgba(255,255,255,0.04); color: var(--text); font-family: inherit; font-size: 11px; }
  .threat-detail-actions { display: flex; gap: 6px; }
  .threat-detail-action { flex: 1; padding: 5px 10px; font-size: 11px; }
  .threat-detail-status { margin-top: 6px; color: var(--muted); font-size: 10px; }
  .log-sort-icon { cursor: pointer; opacity: 0.4; font-size: 10px; margin-left: 2px; }
  .log-sort-icon:hover { opacity: 1; }
  .log-sort-icon.active { color: var(--accent); }
  .log-sort-icon.asc::after { content: ' ↑'; }
  .log-sort-icon.desc::after { content: ' ↓'; }
  .log-search-icon { cursor: pointer; opacity: 0.4; font-size: 10px; margin-left: 3px; }
  .log-search-icon:hover { opacity: 1; }
  .log-search-icon.active { opacity: 1; color: var(--accent); }
  .log-search-popup { position: absolute; z-index: 1000; }
  .log-search-popup.hidden { display: none; }
  .log-search-popup-inner { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); min-width: 220px; }
  .log-search-popup-title { font-size: 11px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
  .log-search-popup select, .log-search-popup input[type="text"] { width: 100%; padding: 5px 8px; margin-bottom: 6px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 11px; font-family: inherit; }
  .log-search-popup input:focus { border-color: var(--accent); outline: none; }
  .log-date-input { width: 100%; padding: 5px 8px; margin-bottom: 4px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 11px; font-family: inherit; }
  .log-date-input:focus { border-color: var(--accent); outline: none; }
  .log-date-range { display: none; flex-direction: column; gap: 2px; }
  .log-date-range.is-visible { display: flex; }
  .log-date-label { color: var(--muted); font-size: 10px; }
  .log-date-label-spaced { margin-top: 4px; }
  .log-search-popup-actions { display: flex; gap: 4px; }
  .log-search-popup-actions button { flex: 1; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--text); font-size: 10px; cursor: pointer; }
  .log-search-popup-actions button:hover { border-color: var(--accent); }
  #log-search-apply, #dv-search-apply { background: var(--accent); color: #fff; border-color: var(--accent); }
  /* ── Device detail panel ── */
  #dv-detail-panel { width: 360px; min-width: 280px; border-left: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
  #dv-detail-panel.hidden { display: none !important; }
  .dv-detail-header { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
  .dv-detail-title { font-size: 13px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dv-detail-body { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
  .dv-detail-row { display: flex; gap: 6px; font-size: 11px; }
  .dv-detail-label { color: var(--muted); min-width: 76px; flex-shrink: 0; }
  .dv-detail-value { color: var(--text); word-break: break-all; }
  .dv-detail-note-ta { width: 100%; min-height: 160px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 5px; color: var(--text); font-size: 11px; font-family: inherit; padding: 6px 8px; resize: vertical; box-sizing: border-box; }
  .dv-detail-note-ta:focus { border-color: var(--accent); outline: none; }
  .dv-detail-actions { display: flex; gap: 6px; padding: 0 12px 12px; }
  .dv-detail-actions button { flex: 1; padding: 5px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--text); cursor: pointer; }
  .dv-detail-actions button:hover { border-color: var(--accent); color: var(--accent); }
  .dv-detail-actions .btn-save { background: var(--accent); color: #fff; border-color: var(--accent); }
  .dv-detail-actions .btn-save:hover { opacity: 0.85; }
  #dv-detail-filter-badge { margin-left: 8px; }
  .dv-main-area { display: flex; flex: 1; overflow: hidden; min-height: 0; }
  .dv-table-column { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-width: 0; gap: 8px; }
  .dv-search-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .dv-search-input { flex: 1; min-width: 180px; max-width: 320px; padding: 4px 8px; font-size: 11px; border: 1px solid var(--border); border-radius: 5px; background: var(--panel); color: var(--text); }
  .dv-table-wrap { position: relative; }
  .dv-clear-filters { display: none; margin-left: 6px; padding: 2px 8px; font-size: 10px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
  .dv-clear-filters.is-visible { display: inline-block; }
  .dv-detail-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 4px; }
  .dv-table-row { cursor: pointer; }
  .dv-cell-mono { font-family: monospace; }
  .dv-cell-muted { color: var(--muted); }
  .dv-cell-mono-small { font-family: monospace; font-size: 10px; color: var(--muted); }
  .dv-cell-small-muted { color: var(--muted); font-size: 10px; }
  .dv-placeholder { color: var(--muted); opacity: .4; }
  .dv-detail-small { font-size: 10px; }
  .dv-detail-ipv6 { font-family: monospace; font-size: 10px; }
  .dv-detail-ipv6-line { display: block; }
  .dv-detail-note-label { margin-top: 4px; margin-bottom: 2px; font-size: 11px; color: var(--muted); }
  .dv-investigate-result { margin-top: 4px; color: var(--muted); font-size: 10px; white-space: pre-wrap; }
  /* ── P1-8: status filter bar ── */
  .dv-status-bar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
  .dv-status-btn { padding: 2px 10px; font-size: 11px; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; transition: border-color .15s, color .15s; }
  .dv-status-btn:hover { border-color: var(--accent); color: var(--text); }
  .dv-status-btn.sel { border-color: var(--accent); color: var(--accent); background: rgba(59,130,246,0.08); }
  .dv-status-count { font-size: 10px; opacity: .7; }
  /* status dots used in table rows and detail panel */
  .s-active   { color: #10b981; }
  .s-recent   { color: #3b82f6; }
  .s-stale    { color: #f59e0b; }
  .s-archived { color: var(--muted); }
  /* row dimming by status */
  tr.row-stale   td { opacity: .65; }
  tr.row-archived td { opacity: .45; text-decoration: line-through; }
  /* ── Merge candidate cards ── */
  .dv-merge-section { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; display: flex; flex-direction: column; gap: 6px; }
  .dv-merge-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .dv-merge-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 11px; display: flex; flex-direction: column; gap: 3px; }
  .dv-merge-card-info { color: var(--text); word-break: break-all; }
  .dv-merge-card-score { color: var(--muted); font-size: 10px; }
  .dv-merge-card-btns { display: flex; gap: 6px; margin-top: 4px; }
  .dv-merge-card-btns button { flex: 1; padding: 3px 6px; font-size: 10px; border-radius: 4px; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--text); }
  .dv-merge-card-btns .btn-merge { background: #10b981; color: #fff; border-color: #10b981; }
  .dv-merge-card-btns .btn-merge:hover { opacity: 0.85; }
  .dv-merge-card-btns .btn-reject:hover { border-color: #ef4444; color: #ef4444; }
  /* Threat indicator in conn-panel */
  .conn-threat { color: #ef4444; font-size: 10px; margin-left: 4px; }
  .stats-chart {
    flex: 1; min-height: 180px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; display: flex; flex-direction: column; overflow: hidden;
  }
  .stats-chart-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
  .stats-chart-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; flex-shrink: 0; }
  .stats-chart svg { flex: 1; width: 100%; height: 100%; }
  /* Bar chart: scroll when content is large */
  #stats-bar { overflow-y: auto; }
  #stats-bar svg { flex: none; width: 100%; height: auto; }
  /* Chart mode toggle */
  .chart-mode-toggle { display: flex; gap: 1px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px; }
  .chart-mode-btn {
    padding: 2px 8px; background: transparent; border: none; border-radius: 4px;
    color: var(--muted); font-family: inherit; font-size: 10px; cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .chart-mode-btn.active { background: var(--accent); color: #fff; }
  .chart-mode-btn:not(.active):hover { background: var(--border); color: var(--text); }
  .stats-axis path, .stats-axis line { stroke: var(--border); }
  .stats-axis text { fill: var(--muted); font-size: 10px; font-family: inherit; }
  .stats-line { fill: none; stroke-width: 1.6; }
  .stats-bar { transition: opacity 0.15s; }
  .stats-bar:hover { opacity: 0.7; }
  .stats-legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 10px; color: var(--muted); margin-top: 4px; }
  .stats-legend-item { display: flex; align-items: center; gap: 4px; }
  .stats-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  /* ── Stats maps (globe + flat) ──────────────────────── */
  .stats-maps {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr) minmax(0, 1fr); gap: 8px;
    height: 300px; flex-shrink: 0;
  }
  .stats-map-cell {
    position: relative; background: #050a14;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  }
  .stats-map-cell svg { display: block; width: 100%; height: 100%; }
  .stats-app-pie { background: var(--panel); }
  .stats-empty { display: none; padding: 40px; text-align: center; color: var(--muted); }
  .stats-empty.is-visible { display: block; }
  .stats-empty-hint { font-size: 10px; }
  /* Pie chart scan line */
  .pie-scan { animation: pie-scan 6s linear infinite; }
  @keyframes pie-scan { to { transform: rotate(360deg); } }
  .stats-map-label {
    position: absolute; top: 6px; left: 8px;
    font-size: 10px; font-weight: 600; color: #7c8aa3;
    letter-spacing: 0.03em; pointer-events: none; z-index: 3;
  }
  .globe-controls {
    position: absolute; bottom: 8px; right: 8px;
    display: flex; gap: 3px; z-index: 4;
  }
  .globe-ctrl-btn {
    width: 22px; height: 22px; padding: 0;
    background: rgba(8,16,36,0.82); border: 1px solid #1e3a5f;
    border-radius: 5px; color: #7c8aa3; font-size: 12px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit; line-height: 1; user-select: none;
  }
  .globe-ctrl-btn:hover:not(:disabled) { background: rgba(56,189,248,0.15); color: #38bdf8; border-color: #38bdf8; }
  .globe-ctrl-btn:disabled { opacity: 0.3; cursor: default; }
  /* ── Flat map zoom/pan controls ─────────────────────── */
  .flatmap-controls {
    position: absolute; bottom: 8px; right: 8px;
    display: flex; flex-direction: column; align-items: center; gap: 3px; z-index: 4;
  }
  .fmc-zoom-row { display: flex; gap: 3px; }
  .fmc-dpad {
    display: grid;
    grid-template-columns: repeat(3, 22px);
    grid-template-rows: repeat(3, 22px);
    gap: 2px;
  }
  .fmc-btn {
    width: 22px; height: 22px; padding: 0;
    background: rgba(8,16,36,0.82); border: 1px solid #1e3a5f;
    border-radius: 5px; color: #7c8aa3; font-size: 12px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit; line-height: 1; user-select: none;
  }
  .fmc-btn:hover { background: rgba(56,189,248,0.15); color: #38bdf8; border-color: #38bdf8; }
  .fmc-btn-reset:hover { background: rgba(56,189,248,0.22); color: #fff; border-color: #38bdf8; }
  /* ── Stats charts row (bar + timeline) ──────────────── */
  .stats-charts {
    flex: 1; min-height: 0; display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.618fr); gap: 8px;
  }
  .stats-charts.is-hidden { display: none; }
  .stats-charts .stats-chart { flex: none; height: 100%; min-height: 0; }

  .graph-tooltip {
    position: absolute; pointer-events: none; background: rgba(17,24,39,0.95);
    border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px;
    font-size: 12px; line-height: 1.6; max-width: 240px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); z-index: 100; display: none;
  }
  .graph-tooltip.is-visible { display: block; }
  .graph-tooltip-heading { font-weight: 600; margin-bottom: 4px; }
  .graph-tooltip-muted { font-size: 10px; color: #9ca3af; }
  .graph-tooltip-detail { font-size: 10px; }
  .graph-tooltip-summary { margin-top: 4px; color: #ddd6fe; }
  .graph-tooltip-summary-destination { color: #ddd6fe; }
  .tooltip-name { font-weight: 700; font-size: 13px; color: var(--accent); margin-bottom: 4px; }
  .tooltip-row { display: flex; justify-content: space-between; gap: 12px; }
  .tooltip-key { color: var(--muted); } .tooltip-val { color: var(--text); font-weight: 600; }

  /* ── Side panel ──────────────────────────────────── */
  .side-panel { width: 373px; background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
  .panel-header { padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 40px; }
  .panel-header-title { flex: 1; }
  .device-search { flex: 0 0 auto; display: flex; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; gap: 5px; transition: border-color 0.15s; width: 130px; }
  .device-search:focus-within { border-color: var(--accent); }
  .device-search svg { flex-shrink: 0; opacity: 0.4; }
  .device-search input { background: transparent; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 11px; width: 100%; text-transform: none; letter-spacing: 0; }
  .device-search input::placeholder { color: var(--muted); }
  .device-list { flex: 1; overflow-y: auto; padding: 8px; }
  .device-list::-webkit-scrollbar { width: 4px; }
  .device-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .device-card { padding: 10px 12px; border-radius: 8px; margin-bottom: 6px; border: 1px solid var(--border); cursor: pointer; transition: border-color 0.15s, background 0.15s; position: relative; }
  .device-card-header { display: flex; align-items: center; gap: 4px; }
  .device-card-header .device-title { flex: 1; }
  /* Note body: scroll up to 3 lines, read-only (display only) */
  .device-note {
    display: block; font-size: 11px; margin-top: 4px;
    line-height: 1.3em; max-height: 3.9em; overflow-y: auto;
    color: var(--cyan); background: rgba(6,182,212,0.06);
    border-left: 2px solid var(--cyan); padding: 4px 6px;
    border-radius: 0 4px 4px 0;
    white-space: pre-wrap; word-break: break-word; cursor: default;
  }
  .device-note.empty { display: none; }
  .device-note::-webkit-scrollbar { width: 4px; }
  .device-note::-webkit-scrollbar-thumb { background: var(--cyan); opacity: 0.4; border-radius: 2px; }
  /* Edit icon: always visible, triggers edit modal */
  .device-note-edit {
    display: inline-block; cursor: pointer; padding: 1px 5px;
    margin-left: 6px; color: var(--muted); border-radius: 4px;
    font-size: 11px; transition: background 0.15s, color 0.15s;
  }
  .device-note-edit:hover { background: rgba(59,130,246,0.15); color: var(--accent); }
  #note-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1001; }
  #note-overlay.hidden { display: none !important; }
  .note-modal-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 20px 22px; width: 460px; max-width: calc(100vw - 20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  }
  .note-modal-card textarea {
    width: 100%; min-height: 100px; background: rgba(255,255,255,0.04);
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); font-family: inherit; font-size: 12px; padding: 8px 10px;
    outline: none; resize: vertical;
  }
  .note-modal-card textarea:focus { border-color: var(--accent); }
  .note-modal-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
  .note-modal-actions button {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px;
    background: transparent; color: var(--text); font-family: inherit; font-size: 12px;
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
  }
  .note-modal-actions button:hover { border-color: var(--accent); }
  .note-modal-actions .btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
  .note-modal-actions .btn-primary:hover { background: #2563eb; }
  .note-modal-actions .btn-investigate { color: var(--cyan); border-color: var(--cyan); }
  .note-modal-header { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
  .note-modal-sub { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
  .device-card:hover, .device-card.selected { border-color: var(--accent); background: rgba(59,130,246,0.08); }
  .device-card.is-filtered { display: none; }
  .device-card.wired   { border-left: 3px solid #ef4444; }
  .device-card.wifi-2g { border-left: 3px solid var(--green); }
  .device-card.wifi-5g { border-left: 3px solid var(--purple); }
  .device-card.wifi-6g { border-left: 3px solid #eab308; }
  .node-badge {
    --node-color: #6b7280;
    display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px;
    margin-left: 6px; vertical-align: middle; font-weight: 600;
    color: var(--node-color);
    background: color-mix(in srgb, var(--node-color) 13%, transparent);
    border: 1px solid color-mix(in srgb, var(--node-color) 27%, transparent);
  }
  .new-badge { display: inline-block; font-size: 8px; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: #0d4f2a; color: #3fb950; border: 1px solid #3fb95044; text-transform: uppercase; letter-spacing: 0.05em; margin-left: 4px; vertical-align: middle; }
  .proto-badges { display: none; }
  .proto-badge { display: inline-block; font-size: 8px; padding: 1px 4px; border-radius: 3px; font-weight: 700; letter-spacing: 0.3px; vertical-align: middle; margin-right: 2px; }
  .proto-v4 { background: #22c55e33; color: #22c55e; border: 1px solid #22c55e55; }
  .proto-v6-green { background: #22c55e33; color: #22c55e; border: 1px solid #22c55e55; }
  .proto-v6-grey { background: #6b728033; color: #9ca3af; border: 1px solid #6b728055; }
  .filter-tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .tab-btn { padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-family: inherit; font-size: 10px; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
  .tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
  .tab-btn:hover:not(.active) { border-color: var(--accent); color: var(--text); }
  /* Line 1: IP / MAC (title) */
  .device-title {
    font-weight: 600; font-size: 12px;
    font-family: 'SF Mono','Fira Code',monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text);
  }
  /* Line 2: device name (if present and different from IP) */
  .device-name {
    font-size: 11px; color: var(--accent); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .device-name.empty { display: none; }
  /* Line 3: vendor (OUI) · connection type */
  .device-meta {
    font-size: 10px; color: var(--muted); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .device-meta.empty { display: none; }
  /* Line 4: name resolution (DNS / mDNS) */
  .device-resolved {
    font-size: 10px; color: var(--green); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    opacity: 0.85;
  }
  .device-resolved.empty { display: none; }
  .device-traffic { display: flex; gap: 8px; margin-top: 6px; }
  .device-traffic-bars { margin-top: 6px; }
  .traffic-pill { display: flex; align-items: center; gap: 4px; font-size: 10px; padding: 1px 6px; border-radius: 4px; }
  .traffic-pill.rx { background: rgba(16,185,129,0.15); color: var(--green); }
  .traffic-pill.tx { background: rgba(239,68,68,0.15); color: var(--red); }
  .traffic-bar { height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 2px; }
  .traffic-bar-spaced { margin-top: 3px; }
  .traffic-bar-fill { width: 0; height: 100%; border-radius: 2px; transition: width 0.4s ease; }
  .traffic-bar-fill.rx { background: var(--green); }
  .traffic-bar-fill.tx { background: var(--red); }
  .log-loading-cell { text-align: center; padding: 32px; color: var(--muted); }
  .conn-panel { display: none; border-top: 1px solid var(--border); flex-shrink: 0; max-height: 240px; flex-direction: column; }
  .conn-panel.is-visible { display: flex; }
  .conn-panel-header { padding: 8px 16px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
  .conn-count { color: var(--accent); }
  .conn-list { overflow-y: auto; flex: 1; }
  .conn-list::-webkit-scrollbar { width: 4px; }
  .conn-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .conn-row { padding: 5px 12px; border-bottom: 1px solid rgba(31,41,55,0.5); font-size: 11px; display: flex; align-items: flex-start; gap: 6px; }
  .conn-proto { font-size: 9px; padding: 1px 4px; border-radius: 3px; background: rgba(59,130,246,0.2); color: var(--accent); font-weight: 700; flex-shrink: 0; margin-top: 2px; }
  .conn-host { flex: 1; color: var(--text); min-width: 0; }
  .conn-hostname { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .conn-rdap { display: block; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
  .conn-port { color: var(--muted); font-size: 10px; flex-shrink: 0; margin-top: 2px; }
  .conn-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 11px; }
  .wan-panel { padding: 12px 16px; border-top: 1px solid var(--border); }
  .wan-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
  .wan-bar-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-bottom: 2px; }
  .wan-traffic-bar { margin-bottom: 6px; }
  .legend { position: absolute; bottom: 16px; left: 16px; display: flex; flex-direction: column; gap: 6px; background: rgba(17,24,39,0.85); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); }
  .legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
  .legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
  .legend-wired { background: #ef4444; }
  .legend-wifi-2g { background: #10b981; }
  .legend-wifi-5g { background: #8b5cf6; }
  .legend-wifi-6g { background: #eab308; }
  .legend-main-router { background: #f59e0b; }
  .legend-aimesh { background: #f97316; }
  .legend-internet { background: #6b7280; }
  .graph-notice { display: none; position: absolute; left: 50%; transform: translateX(-50%); border-radius: 6px; font-size: 11px; pointer-events: none; }
  .graph-summary-notice { top: 10px; background: rgba(124,58,237,0.18); border: 1px solid rgba(167,139,250,0.65); padding: 5px 12px; color: #ddd6fe; box-shadow: 0 0 18px rgba(124,58,237,0.18); }
  .last-update { position: absolute; top: 10px; right: 10px; font-size: 10px; color: var(--muted); }
  .data-fetching { display: none; position: absolute; top: 26px; right: 10px; font-size: 10px; color: var(--muted); align-items: center; gap: 4px; }
  .data-fetching.is-visible { display: flex; }
  .spinner-xs { display: inline-block; width: 8px; height: 8px; border: 1.5px solid rgba(255,255,255,0.2); border-top-color: var(--muted); border-radius: 50%; animation: spin 0.8s linear infinite; flex-shrink: 0; }
  #error-banner { display: none; background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4); color: var(--red); padding: 8px 16px; font-size: 12px; text-align: center; flex-shrink: 0; }
  #toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
  .toast { background: #161b22; border: 1px solid #3fb95066; color: #e6edf3; padding: 10px 16px; border-radius: 8px; font-size: 0.85rem; box-shadow: 0 4px 16px rgba(0,0,0,0.4); opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 320px; }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.multiline { white-space: pre-line; }
  #error-banner.is-visible { display: block; }
  .graph-notice.is-visible { display: block; }

  /* ── Mobile layout (≤768px) ─────────────────────── */
  @media (max-width: 768px) {
    /* Mobile: scroll the whole page (body), not just .main.
       Header is position:sticky and stays at the top. */
    body { overflow-y: auto; overflow-x: hidden; height: auto; min-height: 100dvh; }
    .main { flex-direction: column; overflow: visible; }
    /* Graph/Stats use fixed heights (only the active one is shown via display) */
    #graph-container, #stats-container { flex: 0 0 auto; height: 38vh; min-height: 220px; }
    /* In stats mode: allow full height and vertical scroll */
    body.is-stats-mode #stats-container { height: auto; flex: 1; overflow-y: auto; }
    /* Mobile: stack map cells vertically */
    .stats-maps { grid-template-columns: 1fr; height: auto; }
    .stats-map-cell { height: 180px; }
    #st-app-pie { height: 360px; }
    .stats-charts { grid-template-columns: 1fr; }
    /* Mobile: shrink chart padding, compact legend */
    .stats-chart { padding: 6px 8px; }
    .stats-chart-title { font-size: 9px; }
    .chart-mode-btn { padding: 2px 5px; font-size: 9px; }
    .stats-legend { font-size: 9px; gap: 4px; }
    .stats-axis text { font-size: 9px; }
    /* Device list + connections panel: fill remaining space, no bottom gap */
    .side-panel {
      width: 100% !important;
      flex: 1 1 auto;
      min-height: 45vh;
      max-height: none;
      border-left: none;
      border-top: 1px solid var(--border);
    }
    /* Make device list and connections panel the same height (50%/50%);
       device list uses the full area when connections panel is hidden */
    .device-list { flex: 1 1 0; min-height: 0; }
    .conn-panel  { flex: 1 1 0; max-height: none !important; min-height: 0; }
    /* Header: pin to top, allow wrapping, keep compact */
    header {
      position: sticky; top: 0; z-index: 20;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr) auto auto auto;
      gap: 6px; padding: 6px 8px;
    }
    header .status-dot { grid-column: 1; grid-row: 1; }
    header h1 { grid-column: 2; grid-row: 1; min-width: 0; }
    header .demo-banner { grid-column: 3; grid-row: 1; }
    header .conn-badges { grid-column: 4; grid-row: 1; }
    header .settings-btn { grid-column: 5; grid-row: 1; }
    header h1 { font-size: 13px; }
    .header-stats { display: none; }
    .conn-badges { gap: 3px; }
    .conn-badge { padding: 2px 5px; }
    .conn-badge .badge-layer { font-size: 8px; }
    .conn-badge .badge-dot { width: 5px; height: 5px; }
    .conn-badge .badge-ip { font-size: 9px; }
    .view-tabs {
      grid-column: 1 / -1; grid-row: 2;
      display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
      width: 100%; padding: 2px;
    }
    .view-tab {
      min-width: 0; min-height: 38px; padding: 3px 2px;
      font-size: 9px; line-height: 1.25; white-space: normal;
    }
    .time-filter {
      grid-column: 1 / -1; grid-row: 3;
      width: 100%; padding: 2px 4px; gap: 4px;
    }
    .time-filter-label { display: none; }
    .time-filter select { flex: 1; min-width: 0; font-size: 10px; padding: 4px 2px; }
    .custom-range.is-visible { display: grid; grid-template-columns: 1fr auto 1fr; width: 100%; margin-left: 0; }
    .time-custom-input { font-size: 9px; padding: 1px 2px; max-width: 110px; }
    .settings-btn { margin-left: 0; min-width: 34px; min-height: 34px; padding: 3px 6px; font-size: 12px; }
    .activity-view { padding: 6px; gap: 6px; }
    .activity-view.view-active { min-height: calc(100dvh - 132px); }
    .ai-view { padding: 16px 10px; }
    .ai-hero { align-items: flex-start; }
    .ai-hero-actions { flex-direction: column; align-items: flex-end; }
    .ai-notification-brief { max-width: 12rem; font-size: 0.65rem; }
    .ai-hero p { max-width: 250px; }
    .ai-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ai-usage-grid { grid-template-columns: 1fr; }
    .ai-metric:first-child { grid-column: 1 / -1; }
    .ai-metric { padding: 15px; }
    .ai-updated { width: 100%; margin-left: 17px; }
    .ai-notification-grid { grid-template-columns: 1fr; }
    .notification-rules { grid-template-columns: 1fr; }
    .ai-notification-summary { grid-template-columns: 1fr; }
    .ai-notification-summary dt { padding-bottom: 2px; border-bottom: 0; }
    .ai-notification-summary dd { padding-top: 2px; }
    .log-header { flex-wrap: wrap; min-height: 38px; padding: 4px; }
    .log-export-controls { margin-left: 0; }
    .activity-refresh { min-height: 34px; }
    .log-table-wrap {
      min-height: 45vh;
      overscroll-behavior: contain;
      -webkit-overflow-scrolling: touch;
    }
    .log-table th, .log-table td { padding: 8px; }
    .log-table th:first-child {
      left: 0; z-index: 3; box-shadow: 1px 0 0 var(--border);
    }
    .log-table td:first-child {
      position: sticky; left: 0; z-index: 1;
      background: var(--panel); box-shadow: 1px 0 0 var(--border);
    }
    .log-table tr.threat-row td:first-child { background: #211923; }
    .log-table tr.warn-row td:first-child { background: #201d1c; }
    .dv-main-area { position: relative; min-height: 62vh; }
    #dv-detail-panel {
      position: absolute; inset: 0; z-index: 5;
      width: 100%; min-width: 0; border-left: none;
      box-shadow: 0 0 24px rgba(0,0,0,0.55);
    }
    .dv-detail-close, .dv-detail-actions button, .dv-status-btn { min-height: 36px; }
    .log-search-popup { max-width: calc(100vw - 16px); }
    .log-search-popup-inner { min-width: min(280px, calc(100vw - 16px)); }
    .threat-detail-card { max-height: calc(100dvh - 20px); }
    #toast-container { right: 10px; bottom: 10px; left: 10px; }
    .toast { max-width: none; }
    /* Hide legend (gets in the way on small screens) */
    .legend { display: none; }
    .last-update { font-size: 9px; top: 4px; right: 6px; }
    /* Smaller device cards */
    .device-card { padding: 6px 10px; }
    /* Make the settings modal fit the screen width */
    .settings-card { width: calc(100vw - 20px); max-width: 460px; }
    .settings-tabs { width: 64px; }
    .tab-name { font-size: 8px; }
    /* Smaller device search box */
    .device-search { width: 100px; }
  }
  /* Even narrower screens (small phones in portrait) */
  @media (max-width: 480px) {
    /* Show full brand name even on small screens (wraps to its own line) */
    header h1 { font-size: 11px; }
    /* Connection badges hidden to free up horizontal space */
    .conn-badges { display: none; }
    /* Even more compact tabs */
    .view-tab { padding: 3px 1px; font-size: 8px; }
    .panel-header { font-size: 10px; }
  }
