:root {
  --bg-deep: #080c14;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(23, 33, 56, 0.82);
  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-glow: rgba(56, 189, 248, 0.4);
  
  --color-wan: #06b6d4;
  --color-gw: #10b981;
  --color-sw: #6366f1;
  --color-ap: #f59e0b;
  --color-cli: #38bdf8;
  --brand-cyan: #00e5ff;
  --brand-indigo: #818cf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
}

#app-root {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ==========================================================================
   Top Navigation
   ========================================================================== */
#top-nav {
  height: 56px;
  background: rgba(10, 15, 29, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 5000;
}

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

.brand-glyph {
  width: 32px;
  height: 32px;
  background: linear-space(135deg, #0284c7, #6366f1);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
}
.brand-glyph svg {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fff;
}
.brand-title .highlight {
  color: #38bdf8;
}
.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.mode-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 4px;
}

.mode-tab {
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 14px;
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.mode-tab:hover {
  color: #fff;
}
.mode-tab.active {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}
.dot.online {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}
.dot.live {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.client-filter-group {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.filter-label {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  padding: 0 6px 0 8px;
  letter-spacing: 0.05em;
}

.filter-chip {
  background: transparent;
  border: 1px solid transparent;
  outline: none;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  color: #fff;
}

.filter-chip.active {
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.filter-chip[data-filter="top10"].active {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}

.filter-chip[data-filter="off"].active {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.35);
}

.filter-chip.auto-zoom {
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
}

.filter-chip.auto-zoom:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: rgba(0, 229, 255, 0.4);
  color: var(--brand-cyan);
}

.filter-chip.auto-zoom.active {
  background: rgba(0, 229, 255, 0.18);
  color: var(--brand-cyan);
  border-color: var(--brand-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

.filter-chip.fly-by {
  border: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
}

.filter-chip.fly-by:hover {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(129, 140, 248, 0.5);
  color: #a5b4fc;
}

.filter-chip.fly-by.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(245, 158, 11, 0.2));
  color: #e0e7ff;
  border-color: #818cf8;
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.4);
}

/* Device Search & Pinpointing */
.search-box-wrapper {
  position: relative;
  width: 210px;
}

.search-input-container {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px 9px;
  gap: 7px;
  transition: all 0.2s ease;
}

.search-input-container:focus-within {
  border-color: var(--brand-cyan);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.3);
  width: 240px;
}

.search-box-wrapper:focus-within {
  width: 240px;
}

.search-icon {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.2s;
}

.search-input-container:focus-within .search-icon {
  color: var(--brand-cyan);
}

#device-search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 11px;
  width: 100%;
}

#device-search-input::placeholder {
  color: var(--text-dim);
  font-size: 10.5px;
}

.search-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
  line-height: 1.2;
}

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.search-clear-btn:hover {
  color: #fff;
}

.search-clear-btn.hidden {
  display: none !important;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 320px;
  max-height: 380px;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 229, 255, 0.15);
  z-index: 6000;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-results-dropdown.hidden {
  display: none !important;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  border: 1px solid transparent;
}

.search-result-item:hover, .search-result-item.highlighted {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
}

.search-result-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.search-result-icon svg {
  width: 15px;
  height: 15px;
}

.search-result-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.2);
  flex-shrink: 0;
}

.search-no-results {
  padding: 14px;
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
}

.node-rank-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  margin-right: 4px;
}

.node-rank-badge.top3 {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.live-pulse-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.pulse-beacon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse-ring 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

.telemetry-bar {
  display: flex;
  align-items: center;
  gap: 20px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.stat-label {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.stat-val {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}
.stat-val.throughput {
  color: #38bdf8;
}

/* ==========================================================================
   3D Viewport & Canvas
   ========================================================================== */
#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #0e172a 0%, #070b14 70%, #03050a 100%);
  cursor: grab;
}
#viewport.dragging {
  cursor: grabbing;
}

#canvas-3d {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

#nodes-3d-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* ==========================================================================
   Projected DOM Node Cards (Blueprint Layer 2)
   ========================================================================== */
.node-pill {
  position: absolute;
  pointer-events: auto;
  transform-origin: center center;
  will-change: transform, opacity;
  cursor: pointer;
  
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.node-pill:hover, .node-pill.selected {
  border-color: var(--border-glow);
  box-shadow: 0 12px 36px rgba(56, 189, 248, 0.28), 0 0 16px rgba(56, 189, 248, 0.2);
  background: rgba(28, 42, 70, 0.95);
}

.node-pill.pinpoint-target {
  border-color: var(--brand-cyan) !important;
  background: rgba(10, 35, 60, 0.98) !important;
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.7), 0 0 12px rgba(0, 229, 255, 0.9) !important;
  animation: pinpointGlow 0.9s ease-in-out 3 alternate;
  z-index: 4500 !important;
}

.node-pill.flyby-target {
  border-color: #818cf8 !important;
  background: rgba(23, 31, 64, 0.96) !important;
  box-shadow: 0 0 36px rgba(99, 102, 241, 0.65), 0 0 14px rgba(56, 189, 248, 0.7) !important;
  z-index: 4400 !important;
}

.node-pill.tier-access_point.flyby-target {
  border-color: #fbbf24 !important;
  box-shadow: 0 0 36px rgba(245, 158, 11, 0.65), 0 0 14px rgba(251, 191, 36, 0.7) !important;
}

@keyframes pinpointGlow {
  0% {
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.4), 0 0 6px rgba(0, 229, 255, 0.6);
  }
  100% {
    box-shadow: 0 0 45px rgba(0, 229, 255, 0.9), 0 0 18px rgba(0, 229, 255, 1);
  }
}

.node-pill.tier-wan {
  border-left: 3px solid var(--color-wan);
}
.node-pill.tier-gateway {
  border-left: 3px solid var(--color-gw);
}
.node-pill.tier-switch {
  border-left: 3px solid var(--color-sw);
}
.node-pill.tier-access_point {
  border-left: 3px solid var(--color-ap);
}
.node-pill.tier-client {
  border-left: 3px solid var(--color-cli);
}

.node-pill .node-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
}
.node-pill .node-icon svg {
  width: 15px;
  height: 15px;
}

.node-pill .node-content {
  display: flex;
  flex-direction: column;
}

.node-pill .node-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.node-pill .node-sub {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.node-pill .node-traffic-badge {
  font-size: 9px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.2);
  margin-left: 4px;
  transition: all 0.3s ease;
}

.node-pill .node-traffic-badge.idle {
  background: rgba(100, 116, 139, 0.12);
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.2);
}

.node-pill .node-traffic-badge.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.node-pill .node-traffic-badge.high {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}

.node-pill .node-traffic-badge.ultra {
  background: rgba(236, 72, 153, 0.22);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.6);
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.5);
  animation: pulse-ring 1.2s infinite;
}

/* ==========================================================================
   HUD & Overlays
   ========================================================================== */
#hud-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.hud-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.hud-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

.hud-btn.active {
  background: rgba(0, 229, 255, 0.22);
  border-color: var(--brand-cyan);
  color: var(--brand-cyan);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
}

/* Auto-Zoom Tracking HUD Banner */
.auto-zoom-banner {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(0, 229, 255, 0.45);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  z-index: 150;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 16px rgba(0, 229, 255, 0.22);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-main);
  transition: all 0.25s ease;
}

.auto-zoom-banner.hidden {
  display: none !important;
}

.auto-zoom-banner .target-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-cyan);
  box-shadow: 0 0 8px var(--brand-cyan);
  animation: pulseBeacon 1.2s infinite;
}

.auto-zoom-banner .banner-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--brand-cyan);
  letter-spacing: 0.05em;
}

.auto-zoom-banner .target-name {
  font-weight: 700;
  color: #ffffff;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auto-zoom-banner .target-rate {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 7px;
  border-radius: 5px;
}

.auto-zoom-banner .banner-close {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 6px;
  line-height: 1;
  transition: color 0.15s;
}

.auto-zoom-banner .banner-close:hover {
  color: #ffffff;
}

/* Fly-By Banner Extensions */
.flyby-banner {
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55), 0 0 18px rgba(99, 102, 241, 0.28);
}

.flyby-banner .flyby-pulse {
  background: #818cf8;
  box-shadow: 0 0 8px #818cf8;
  animation: pulse-ring 1.3s infinite;
}

.flyby-banner .banner-title {
  color: #a5b4fc;
}

.flyby-phase-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  letter-spacing: 0.04em;
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  border: 1px solid rgba(129, 140, 248, 0.4);
  transition: all 0.25s ease;
}

.flyby-phase-badge.phase-zoom-in {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.45);
}

.flyby-phase-badge.phase-hold {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.flyby-phase-badge.phase-zoom-out {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.45);
}

.flyby-skip-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 2px;
  transition: all 0.15s ease;
}

.flyby-skip-btn:hover {
  background: rgba(129, 140, 248, 0.25);
  border-color: #818cf8;
  color: #fff;
}

#tier-legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  z-index: 100;
}
.legend-tier {
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.badge-dot.wan { background: var(--color-wan); box-shadow: 0 0 6px var(--color-wan); }
.badge-dot.gw  { background: var(--color-gw);  box-shadow: 0 0 6px var(--color-gw); }
.badge-dot.sw  { background: var(--color-sw);  box-shadow: 0 0 6px var(--color-sw); }
.badge-dot.ap  { background: var(--color-ap);  box-shadow: 0 0 6px var(--color-ap); }
.badge-dot.cli { background: var(--color-cli); box-shadow: 0 0 6px var(--color-cli); }

/* ==========================================================================
   Side Drawer ("Chamber Mode")
   ========================================================================== */
#device-drawer {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 335px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  padding: 20px;
  z-index: 4000;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#device-drawer.hidden {
  transform: translateX(350px);
  opacity: 0;
  pointer-events: none;
}

.close-drawer-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-dim);
  cursor: pointer;
}
.close-drawer-btn:hover {
  color: #fff;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.drawer-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
}
.drawer-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.d-meta {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.m-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
}
.m-title {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 4px;
}
.m-val {
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 700;
}
.text-cyan { color: #38bdf8; }
.text-green { color: #10b981; }

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11.5px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  margin-bottom: 16px;
}

/* ==========================================================================
   Application & DPI Traffic Insights Styles
   ========================================================================== */
.app-insights-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.insights-title {
  font-size: 9.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.insights-badge {
  font-size: 8.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.primary-app-banner {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.app-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: pulse-ring 1.5s infinite;
}

.app-banner-text {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.app-banner-sub {
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.app-banner-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.app-banner-domain {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: #38bdf8;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 6px;
  border-radius: 4px;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.app-name-box {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f1f5f9;
  font-weight: 600;
}

.app-category-tag {
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 4px;
  border-radius: 3px;
}

.app-row-stats {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.app-bar-bg {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.app-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  transition: width 0.4s ease;
}

.app-bar-fill.streaming { background: linear-gradient(90deg, #ef4444, #f97316); }
.app-bar-fill.gaming    { background: linear-gradient(90deg, #8b5cf6, #ec4899); }
.app-bar-fill.audio     { background: linear-gradient(90deg, #10b981, #06b6d4); }
.app-bar-fill.cloud     { background: linear-gradient(90deg, #3b82f6, #38bdf8); }

.security-meta-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
}

.sec-item {
  display: flex;
  flex-direction: column;
}

.sec-label {
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.sec-val {
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: #10b981;
}
.field-row {
  display: flex;
  justify-content: space-between;
}
.f-label {
  color: var(--text-muted);
}
.f-val {
  font-family: var(--font-mono);
  color: #fff;
  font-weight: 500;
}

.drawer-actions {
  display: flex;
  gap: 8px;
}
.action-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}
.action-btn.primary {
  background: #0284c7;
  color: #fff;
}
.action-btn.primary:hover {
  background: #0ea5e9;
}

/* ==========================================================================
   UniFi Credentials Modal
   ========================================================================== */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6000;
}
.modal-backdrop.hidden {
  display: none;
}
.modal-card {
  width: 420px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-glow);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.modal-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-row {
  display: flex;
  gap: 12px;
}
.flex-1 { flex: 1; }

label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
input[type="text"], input[type="password"], input[type="number"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus {
  border-color: #38bdf8;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.form-check label {
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.unifi-saved-hint {
  font-size: 11px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.unifi-saved-hint.hidden {
  display: none;
}
.form-error {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  border-radius: 8px;
  font-size: 11px;
  margin-bottom: 14px;
}
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.modal-actions-spacer {
  flex: 1;
}
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}
.btn.text-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 4px;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  border: none;
  transition: color 0.15s ease;
}
.btn.text-btn:hover {
  color: #f87171;
}
.btn.text-btn.hidden {
  display: none;
}
.btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.btn.primary {
  background: #0284c7;
  color: #fff;
}
