/* ═══════════════════════════════════════════════════════════════════════════
   LoRa Sensor Monitoring Design System v4.0
   Premium dark-mode dashboard with glassmorphism, micro-animations,
   responsive breakpoints, and dynamic visual feedback.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg-main: #060911;
  --bg-surface: #0f1520;
  --bg-card: rgba(14, 21, 35, 0.82);
  --bg-glass: rgba(22, 31, 52, 0.55);
  --bg-glass-hover: rgba(30, 42, 68, 0.65);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-glow: rgba(99, 102, 241, 0.3);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #818cf8;
  --primary-deep: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --primary-bg: rgba(99, 102, 241, 0.1);

  --emerald: #34d399;
  --emerald-deep: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.1);
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --rose: #fb7185;
  --rose-deep: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.1);
  --rose-glow: rgba(244, 63, 94, 0.3);
  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.1);
  --cyan: #22d3ee;
  --cyan-deep: #06b6d4;
  --cyan-bg: rgba(6, 182, 212, 0.08);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px -5px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.08);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);

  --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(ellipse at 15% 5%, rgba(99, 102, 241, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 95%, rgba(6, 182, 212, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(244, 63, 94, 0.02) 0%, transparent 70%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ─── Page Entry Animation ──────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 5px currentColor; }
  50%      { box-shadow: 0 0 15px currentColor; }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container > * {
  animation: fadeInUp 0.5s ease-out both;
}
.container > *:nth-child(2) { animation-delay: 0.05s; }
.container > *:nth-child(3) { animation-delay: 0.1s; }
.container > *:nth-child(4) { animation-delay: 0.15s; }
.container > *:nth-child(5) { animation-delay: 0.2s; }
.container > *:nth-child(6) { animation-delay: 0.25s; }

/* ═══════════════════════════════════════════════════════════════════════════
   NAVBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.navbar {
  background: rgba(6, 9, 17, 0.8);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.4s ease-out;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary-deep), var(--cyan-deep));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--primary-glow);
  transition: var(--transition);
}
.brand:hover .brand-icon {
  box-shadow: 0 0 20px var(--primary-glow);
  transform: scale(1.05);
}

.brand-port {
  font-size: 0.7rem;
  color: var(--cyan);
  font-weight: 500;
  opacity: 0.8;
}

/* Nav Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  position: relative;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-bg);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

/* Nav right controls */
.nav-right {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-shrink: 0;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-family: inherit;
  transition: var(--transition-fast);
  white-space: nowrap;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
  color: var(--text-muted);
}

/* Mobile hamburger */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-xs);
}
.hamburger:hover {
  background: rgba(255, 255, 255, 0.06);
}
.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  margin: 4px 0;
  border-radius: 1px;
  transition: var(--transition-fast);
}

/* ─── Status Indicators ─────────────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--emerald);
  box-shadow: 0 0 6px var(--emerald);
  animation: pulseDot 2s ease-in-out infinite;
}
.status-dot.connecting {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
  animation: pulseDot 1s ease-in-out infinite;
}
.status-dot.disconnected, .status-dot.error {
  background: var(--rose);
  box-shadow: 0 0 6px var(--rose);
}

@keyframes pulseDot {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50%      { transform: scale(1.15); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.container {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-desc {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-top: 0.25rem;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.breadcrumb a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.83rem;
  transition: var(--transition-fast);
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep {
  color: var(--text-dim);
  font-size: 0.75rem;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-deep), transparent);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-lg);
}
.stat-card:hover::before {
  opacity: 1;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.stat-val {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0.35rem 0 0.15rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
  animation: countUp 0.5s ease-out;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ─── Telemetry Bar ─────────────────────────────────────────────────────── */
.telemetry-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan-deep);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.35rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.telemetry-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-main);
}

.telemetry-items {
  display: flex;
  gap: 1.25rem;
  font-size: 0.82rem;
  flex-wrap: wrap;
  color: var(--text-muted);
}

.telemetry-items strong {
  color: var(--text-main);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SENSOR GRID & CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-title .count {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-weight: 500;
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.15rem;
  margin-bottom: 2rem;
}

.sensor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.sensor-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: var(--transition);
  pointer-events: none;
}

.sensor-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* Alert state glow */
.sensor-card.state-alert {
  border-color: rgba(244, 63, 94, 0.25);
}
.sensor-card.state-alert::after {
  box-shadow: inset 0 0 30px rgba(244, 63, 94, 0.04);
  opacity: 1;
}
.sensor-card.state-safe {
  border-color: rgba(16, 185, 129, 0.12);
}
.sensor-card.state-offline {
  border-color: rgba(244, 63, 94, 0.3);
}

.sensor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.sensor-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.sensor-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.4rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
  align-items: center;
}

.sensor-meta-divider {
  opacity: 0.3;
}

/* Sensor state display */
.sensor-state-display {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin: 0.65rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
}

.state-label-sm {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.state-large {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.state-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.sensor-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.sensor-footer-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.detail-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  transition: var(--transition-fast);
}
.detail-link:hover {
  color: var(--primary-deep);
}

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-open, .badge-panic {
  background: var(--rose-bg);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.25);
  animation: pulseGlow 2.5s ease-in-out infinite;
}
.badge-closed, .badge-normal, .badge-rest {
  background: var(--emerald-bg);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.2);
}
.badge-unknown {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.2);
}
.badge-offline {
  background: var(--rose-bg);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.3);
}
.badge-online, .badge-healthy {
  background: var(--emerald-bg);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.2);
}

/* Location filter pills */
.filter-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.22rem 0.6rem;
  font-size: 0.73rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: var(--transition-fast);
}
.filter-pill:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}
.filter-pill.active {
  background: var(--primary-deep);
  color: white;
  border-color: var(--primary-deep);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════ */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.table-header-bar {
  padding: 1rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-title {
  font-size: 1rem;
  font-weight: 700;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  background: var(--bg-surface);
  color: var(--text-dim);
  font-weight: 600;
  padding: 0.7rem 1.15rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

td {
  padding: 0.8rem 1.15rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  transition: var(--transition-fast);
}

tr:last-child td { border-bottom: none; }

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
}

.hex-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORMS & BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
}
.btn:active::after {
  opacity: 1;
  transition: opacity 0s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-deep), var(--primary));
  color: white;
  box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-deep));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: var(--text-main);
}

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.25);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.2);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 0.2rem;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { color: var(--text-main); }

/* Form Controls */
.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-control::placeholder {
  color: var(--text-dim);
  opacity: 0.7;
}

/* Custom checkbox */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-dim);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}
input[type="checkbox"]:checked {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Settings card */
.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: var(--transition);
}
.settings-card:hover {
  border-color: var(--border-hover);
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Monitoring hours panel */
.monitor-panel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin: 0.85rem 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-backdrop.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--radius-xs);
  transition: var(--transition-fast);
}
.close-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transform: translateY(calc(100% + 2rem));
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 200;
  max-width: 420px;
  font-size: 0.88rem;
  font-weight: 500;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Toast Color Variants */
#toast.show.success {
  border-left: 3px solid var(--emerald);
}
#toast.show.success svg { color: var(--emerald); }

#toast.show.error {
  border-left: 3px solid var(--rose);
}
#toast.show.error svg { color: var(--rose); }

#toast.show.info {
  border-left: 3px solid var(--cyan);
}
#toast.show.info svg { color: var(--cyan); }

#toast.show.warning {
  border-left: 3px solid var(--amber);
}
#toast.show.warning svg { color: var(--amber); }

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */
footer {
  text-align: center;
  padding: 1.5rem 2rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
footer p { opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-dim);
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}
.empty-state-text {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS GRID
   ═══════════════════════════════════════════════════════════════════════════ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════════════════ */
.flex-row { display: flex; align-items: center; }
.flex-col { display: flex; flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-xs { gap: 0.35rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.gap-xl { gap: 1.5rem; }
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-cyan { color: var(--cyan); }
.text-amber { color: var(--amber); }
.text-dim { color: var(--text-dim); }
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.w-full { width: 100%; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .sensor-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body { font-size: 14px; }

  .navbar {
    padding: 0 1rem;
    height: 54px;
  }

  .hamburger {
    display: block;
    order: -1;
  }

  .nav-links {
    display: none;
    position: fixed;
    top: 54px;
    left: 0;
    right: 0;
    background: rgba(6, 9, 17, 0.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    gap: 0.25rem;
    z-index: 49;
    animation: slideDown 0.25s ease-out;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-link {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
  }

  .nav-right {
    gap: 0.4rem;
  }

  .nav-btn span {
    display: none;
  }

  .container {
    padding: 1.25rem 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .stat-card {
    padding: 0.85rem 1rem;
  }
  .stat-val {
    font-size: 1.4rem;
  }

  .sensor-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    padding: 0.6rem 0.85rem;
    font-size: 0.78rem;
  }

  .telemetry-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .telemetry-items {
    gap: 0.75rem;
    font-size: 0.78rem;
  }

  #toast {
    left: 1rem;
    right: 1rem;
    max-width: none;
    bottom: 1rem;
  }

  .modal {
    margin: 0.5rem;
    padding: 1.25rem;
  }

  .filter-pills {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.25rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .stat-card { padding: 0.7rem 0.85rem; }
  .stat-val { font-size: 1.2rem; }
  .stat-label { font-size: 0.7rem; }
}
