/* ==========================================================================
   JIP NETWORK & INTERNET MONITOR - LUXURY CYBER-GLASS DESIGN SYSTEM
   Diskominfo Pemerintah Kabupaten Madiun (LibreNMS + The Dude v6)
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-base: #060911;
  --bg-surface: #0b1120;
  --bg-surface-elevated: #111a2f;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(22, 33, 62, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(56, 189, 248, 0.25);
  --border-green: rgba(34, 197, 94, 0.3);
  --border-red: rgba(239, 68, 68, 0.3);
  --border-purple: rgba(168, 85, 247, 0.3);
  
  /* Text Colors */
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  /* Accent Colors */
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-emerald: #10b981;
  --accent-yellow: #eab308;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  
  /* Shadows & Glows */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.35);
  --glow-green: 0 0 15px rgba(34, 197, 94, 0.35);
  --glow-red: 0 0 15px rgba(239, 68, 68, 0.45);
  --glow-purple: 0 0 15px rgba(168, 85, 247, 0.45);
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* Ambient Background Light Spheres */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #0284c7 0%, rgba(2, 132, 199, 0) 70%);
  top: -150px;
  left: 10%;
  animation: pulseGlow 12s infinite alternate ease-in-out;
}

.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #7c3aed 0%, rgba(124, 58, 237, 0) 70%);
  top: 30%;
  right: -100px;
  animation: pulseGlow 15s infinite alternate-reverse ease-in-out;
}

.glow-3 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #dc2626 0%, rgba(220, 38, 38, 0) 70%);
  bottom: 5%;
  left: 20%;
  animation: pulseGlow 18s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
  0% { transform: scale(1) translateY(0); opacity: 0.35; }
  50% { transform: scale(1.15) translateY(30px); opacity: 0.55; }
  100% { transform: scale(0.95) translateY(-20px); opacity: 0.35; }
}

/* App Container Layout */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Section */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: rgba(13, 20, 36, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

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

.logo-box {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  position: relative;
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
}

.logo-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  border: 2px solid #38bdf8;
  animation: logoRipples 2.5s infinite ease-out;
}

@keyframes logoRipples {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.brand-title span {
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Center Status Banner: Global Internet */
.global-internet-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.85);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.15);
}

.isp-icon {
  width: 34px;
  height: 34px;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-green);
  font-size: 16px;
}

.isp-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

.isp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-green);
}

.dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  animation: blinkPulse 1.8s infinite;
}

@keyframes blinkPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.isp-details {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--text-muted);
  border-left: 1px solid var(--border-subtle);
  padding-left: 12px;
}

.isp-details code {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-size: 10px;
}

/* NMS Sources Header Chips */
.nms-sources-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nms-source-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
}

.chip-librenms {
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.chip-dude {
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.nms-chip-ip {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.8;
}

/* Header Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-clock-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
}

.auto-refresh-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.refresh-dropdown, .sort-dropdown {
  background: transparent;
  color: var(--text-main);
  border: none;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.refresh-dropdown option, .sort-dropdown option {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}

.btn-refresh:hover {
  transform: translateY(-1px);
}

/* Source Navigation Bar (LibreNMS vs The Dude) */
.source-nav-bar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(13, 20, 36, 0.9);
  border: 1px solid var(--border-subtle);
}

.source-nav-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  text-transform: uppercase;
  white-space: nowrap;
}

.source-nav-pills {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.source-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.source-pill .badge {
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
}

.source-pill:hover {
  background: var(--bg-surface-elevated);
  color: #fff;
}

.source-pill.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(37, 99, 235, 0.5);
}

.source-pill.pill-librenms.active {
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  border-color: #c084fc;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.5);
}

.source-pill.pill-dude.active {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  border-color: #f87171;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.badge-purple { background: rgba(168, 85, 247, 0.3) !important; color: #c084fc; }
.badge-red { background: rgba(239, 68, 68, 0.3) !important; color: #f87171; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.kpi-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.6), transparent);
}

.kpi-card.kpi-success::before {
  background: linear-gradient(90deg, transparent, rgba(34, 197, 94, 0.8), transparent);
}

.kpi-card.kpi-danger::before {
  background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.8), transparent);
}

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

.kpi-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.icon-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.icon-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.icon-yellow { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.icon-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.kpi-value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}

.kpi-value small {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
}

.text-green { color: #4ade80; }
.text-red { color: #f87171; }
.text-yellow { color: #facc15; }
.text-purple { color: #c084fc; }

.kpi-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.kpi-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #94a3b8;
}

.tag-green { color: #4ade80; }
.tag-red { color: #f87171; }
.tag-yellow { color: #facc15; }
.tag-purple { color: #c084fc; }

.kpi-sub {
  color: var(--text-subtle);
  font-size: 11px;
}

/* Controls Panel */
.controls-panel {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-bar-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--text-subtle);
  font-size: 15px;
}

.search-bar-box input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 12px 42px 12px 45px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.search-bar-box input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
  background: var(--bg-surface-elevated);
}

.btn-clear-search {
  position: absolute;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 14px;
  display: none;
}

.filter-groups {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 13px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
}

.pill-btn .badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
}

.pill-btn.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border-color: #38bdf8;
}

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

.status-filter-group, .view-switch-group {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
}

.status-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-btn.active {
  background: var(--bg-surface-elevated);
  color: #fff;
}

.dot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.dot-red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
.dot-purple { background: var(--accent-purple); box-shadow: 0 0 6px var(--accent-purple); }

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  width: 32px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
}

.view-btn.active {
  background: #2563eb;
  color: #fff;
}

/* Results Header Bar */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.highlight-count {
  color: #38bdf8;
  font-weight: 700;
}

.sort-selector-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* Devices Grid */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

/* Single Device Card */
.device-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.device-card:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.6);
  background: var(--bg-card-hover);
}

.device-card.card-source-librenms {
  border-left: 3px solid #a855f7;
}

.device-card.card-source-dude {
  border-left: 3px solid #ef4444;
}

.device-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.node-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-top-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tag-source {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tag-source-librenms {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.tag-source-dude {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.node-category-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #38bdf8;
}

.node-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.node-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill-online {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.pill-offline {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.pill-warning {
  background: rgba(234, 179, 8, 0.2);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.node-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

.meta-val {
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-val code {
  font-family: var(--font-mono);
  color: #67e8f9;
}

.node-perf-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.perf-latency {
  display: flex;
  flex-direction: column;
}

.perf-latency-val {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.perf-latency-val small {
  font-size: 11px;
  color: var(--text-muted);
}

.sparkline-container {
  width: 120px;
  height: 32px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.spark-bar {
  flex: 1;
  background: #0284c7;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}

.spark-bar.spark-green { background: #22c55e; }
.spark-bar.spark-yellow { background: #eab308; }
.spark-bar.spark-red { background: #ef4444; }

.node-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-subtle);
}

.btn-card-detail {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-card-detail:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
}

/* Devices Table View */
.devices-table-container {
  overflow-x: auto;
}

.devices-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.devices-table th {
  padding: 12px 14px;
  color: var(--text-subtle);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
}

.devices-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.devices-table tbody tr:hover {
  background: rgba(56, 189, 248, 0.06);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  font-size: 40px;
  color: var(--text-subtle);
}

.btn-reset {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Modal Overlay & Details */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease-in-out;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 780px;
  background: #0d1527;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(2, 132, 199, 0.2);
  transform: scale(0.95);
  transition: transform 0.25s ease-out;
  overflow: hidden;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.8);
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-title-box h2 {
  font-family: var(--font-heading);
  font-size: 17px;
  color: #fff;
}

.modal-title-box p {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.m-metric {
  background: rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.m-label {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
}

.m-val {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.chart-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.chart-header h4 {
  font-size: 13px;
  color: #fff;
  font-weight: 600;
}

.chart-sub {
  font-size: 11px;
  color: var(--text-subtle);
}

.canvas-wrapper {
  height: 200px;
  position: relative;
  width: 100%;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.6);
}

.modal-footer-note {
  font-size: 11px;
  color: var(--text-subtle);
}

.btn-modal-close-action {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* Footer */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-subtle);
}

.app-footer a {
  color: #38bdf8;
  text-decoration: none;
}

.sep {
  color: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Responsive */
@media (max-width: 1024px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 12px;
    gap: 14px;
  }
  .devices-grid {
    grid-template-columns: 1fr;
  }
  .filter-groups {
    flex-direction: column;
    align-items: stretch;
  }
}
