/* =========================================================
   TRACKBHAI - NEXT-GEN FAMILY SAFETY & DEVICE PORTAL STYLING
   Author: TrackBhai Engineering
   Design: Cyber-Emerald & Slate Dark Glassmorphism
   ========================================================= */

:root {
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(16, 185, 129, 0.4);
  
  --emerald-500: #10b981;
  --emerald-400: #34d399;
  --emerald-600: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  
  --cyan-500: #06b6d4;
  --cyan-400: #22d3ee;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  
  --purple-500: #8b5cf6;
  --purple-400: #a78bfa;
  
  --coral-500: #f43f5e;
  --coral-400: #fb7185;
  --coral-glow: rgba(244, 63, 94, 0.25);
  
  --amber-500: #f59e0b;
  --amber-400: #fbbf24;
  
  --teal-500: #14b8a6;
  --indigo-500: #6366f1;
  --rose-500: #e11d48;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --sidebar-width: 280px;
  --header-height: 72px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -5px var(--emerald-glow);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.dark-theme {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 40%);
}

/* ==================== HEADER ==================== */
.portal-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-toggle-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
  color: var(--emerald-400);
  border-color: var(--emerald-500);
  background: rgba(16, 185, 129, 0.1);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  box-shadow: 0 0 20px var(--emerald-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.brand-accent {
  color: var(--emerald-400);
}

.brand-edition {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 700;
}

/* Device Status Selector */
.header-device-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-pill {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.device-pill:hover {
  border-color: var(--emerald-500);
}

.device-pulse-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
}

.device-pulse-indicator.online {
  background: var(--emerald-400);
  box-shadow: 0 0 10px var(--emerald-500);
}

.device-pulse-indicator.offline {
  background: var(--coral-500);
  box-shadow: 0 0 10px var(--coral-500);
}

.device-pulse-indicator.online::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--emerald-400);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

.device-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.device-sync-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.quick-telemetry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.telemetry-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.battery-chip i { color: var(--coral-400); }
.network-chip i { color: var(--cyan-400); }
.gps-chip i { color: var(--emerald-400); }

/* Header Right Actions */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.sim-badge-btn {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan-400);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.sim-badge-btn:hover {
  background: rgba(6, 182, 212, 0.25);
}

.siren-btn {
  background: linear-gradient(135deg, var(--coral-500), var(--rose-500));
  color: #fff;
  box-shadow: 0 4px 15px var(--coral-glow);
}

.siren-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.4);
}

.icon-round-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-round-btn:hover {
  color: #fff;
  border-color: var(--emerald-500);
  transform: rotate(180deg);
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upgrade-gold-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  transition: all 0.2s;
}

.upgrade-gold-btn:hover {
  transform: scale(1.05);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

/* ==================== LAYOUT ==================== */
.portal-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* ==================== SIDEBAR ==================== */
.portal-sidebar {
  width: var(--sidebar-width);
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s;
}

.portal-sidebar.collapsed {
  transform: translateX(-100%);
  width: 0;
}

.sidebar-scroller {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 800;
  padding: 0 12px;
  margin-bottom: -10px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  position: relative;
}

.nav-item .nav-link i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  color: var(--text-muted);
  transition: color 0.2s;
}

.nav-item:hover .nav-link {
  background: rgba(30, 41, 59, 0.7);
  color: #fff;
}

.nav-item:hover .nav-link i {
  color: var(--emerald-400);
}

.nav-item.active .nav-link {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.02));
  color: var(--emerald-400);
  border-left: 3px solid var(--emerald-400);
  font-weight: 700;
}

.nav-item.active .nav-link i {
  color: var(--emerald-400);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.nav-badge.emerald { background: rgba(16, 185, 129, 0.2); color: var(--emerald-400); }
.nav-badge.cyan { background: rgba(6, 182, 212, 0.2); color: var(--cyan-400); }
.nav-badge.coral { background: rgba(244, 63, 94, 0.2); color: var(--coral-400); }
.nav-badge.purple { background: rgba(139, 92, 246, 0.2); color: var(--purple-400); }
.nav-badge.orange { background: rgba(249, 115, 22, 0.2); color: #fb923c; }

.nav-badge-pill {
  margin-left: auto;
  font-size: 0.65rem;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--coral-500);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Sidebar Footer Storage Widget */
.sidebar-footer-card {
  margin-top: auto;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.storage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.storage-value {
  color: var(--emerald-400);
  font-weight: 700;
}

.storage-bar {
  height: 6px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 3px;
  overflow: hidden;
}

.storage-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-500), var(--cyan-500));
  border-radius: 3px;
}

.security-stamp {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.security-stamp i {
  color: var(--emerald-400);
}

/* ==================== MAIN CONTENT AREA ==================== */
.portal-main {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
  max-width: 1600px;
}

/* Freemium Banner */
.freemium-info-banner {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-left: 5px solid var(--amber-500);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.banner-icon {
  font-size: 1.8rem;
  color: var(--amber-400);
}

.banner-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}

.banner-content p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.banner-btn {
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-500));
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--emerald-glow);
  transition: all 0.2s;
}

.banner-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Tab Panels */
.tab-panel {
  display: none;
  animation: fadeInTab 0.3s ease-in-out;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeInTab {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.panel-header-row h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Status Metric Cards */
.device-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.status-metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, border-color 0.2s;
}

.status-metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.metric-icon-wrap.emerald { background: rgba(16, 185, 129, 0.15); color: var(--emerald-400); }
.metric-icon-wrap.coral { background: rgba(244, 63, 94, 0.15); color: var(--coral-400); }
.metric-icon-wrap.cyan { background: rgba(6, 182, 212, 0.15); color: var(--cyan-400); }
.metric-icon-wrap.purple { background: rgba(139, 92, 246, 0.15); color: var(--purple-400); }

.metric-data {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin: 2px 0;
}

.location-text {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Colorful Grid Cards */
.dashboard-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.grid-card {
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.grid-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.4);
}

.grid-card-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.grid-icon {
  font-size: 2.2rem;
  opacity: 0.85;
}

.grid-content {
  text-align: right;
}

.grid-count {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  display: block;
}

.grid-title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 6px;
  display: block;
  opacity: 0.9;
}

.grid-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  opacity: 0.85;
}

/* Card Themes */
.card-cyan { background: linear-gradient(135deg, #0284c7, #0369a1); color: #fff; }
.card-teal { background: linear-gradient(135deg, #0d9488, #0f766e); color: #fff; }
.card-purple { background: linear-gradient(135deg, #7c3aed, #6d28d9); color: #fff; }
.card-rose { background: linear-gradient(135deg, #e11d48, #be123c); color: #fff; }
.card-amber { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.card-orange { background: linear-gradient(135deg, #ea580c, #c2410c); color: #fff; }
.card-emerald { background: linear-gradient(135deg, #059669, #047857); color: #fff; }
.card-indigo { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; }

/* Dashboard Split Section (Radar Map + Live Events) */
.dashboard-split-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

@media (max-width: 1100px) {
  .dashboard-split-section {
    grid-template-columns: 1fr;
  }
}

.preview-map-box, .preview-events-box {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header-titles {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-titles h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

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

.speed-indicator {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan-400);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tiny-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tiny-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.map-container-wrapper {
  height: 380px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
}

.leaflet-map-canvas {
  width: 100%;
  height: 100%;
}

.badge-live-pulse {
  background: rgba(244, 63, 94, 0.2);
  color: var(--coral-400);
  border: 1px solid rgba(244, 63, 94, 0.4);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

/* Event Feed List */
.events-feed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
}

.event-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.event-item:hover {
  background: rgba(30, 41, 59, 0.8);
}

.event-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.event-info {
  flex: 1;
}

.event-title-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.event-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.event-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.event-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ==================== FULL MAP VIEW (TAB 2) ==================== */
.full-map-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
  position: relative;
}

.full-canvas {
  height: 520px;
}

.map-floating-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 800;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.overlay-stat {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
}

.stat-lbl {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.route-playback-controller {
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-subtle);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.playback-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--emerald-500);
  color: #fff;
  border: none;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 15px var(--emerald-glow);
  transition: transform 0.2s;
}

.playback-btn:hover {
  transform: scale(1.1);
}

.timeline-slider-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-slider {
  width: 100%;
  accent-color: var(--emerald-400);
  cursor: pointer;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==================== DATA TABLES ==================== */
.panel-card-table {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 320px;
}

.search-box input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}

.table-responsive {
  overflow-x: auto;
}

.modern-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.modern-data-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 14px 18px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--border-subtle);
}

.modern-data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.modern-data-table tbody tr {
  transition: background 0.15s;
}

.modern-data-table tbody tr:hover {
  background: rgba(51, 65, 85, 0.35);
  color: #fff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-badge.incoming { background: rgba(6, 182, 212, 0.2); color: var(--cyan-400); }
.status-badge.outgoing { background: rgba(16, 185, 129, 0.2); color: var(--emerald-400); }
.status-badge.missed { background: rgba(244, 63, 94, 0.2); color: var(--coral-400); }

/* Audio Play button in Table */
.audio-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.2);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: var(--cyan-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 6px;
}

.audio-action-btn:hover {
  background: var(--cyan-500);
  color: #fff;
  transform: scale(1.1);
}

/* Audio Master Player Card */
.audio-master-player {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  border: 1px solid var(--cyan-500);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 0 25px var(--cyan-glow);
}

.player-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cyan-500);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: transform 0.2s;
}

.waveform-animator {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.waveform-animator span {
  width: 3px;
  background: var(--cyan-400);
  border-radius: 2px;
  animation: waveAnim 1.2s infinite ease-in-out;
}

.waveform-animator span:nth-child(2) { animation-delay: 0.1s; }
.waveform-animator span:nth-child(3) { animation-delay: 0.2s; }
.waveform-animator span:nth-child(4) { animation-delay: 0.3s; }
.waveform-animator span:nth-child(5) { animation-delay: 0.4s; }
.waveform-animator span:nth-child(6) { animation-delay: 0.5s; }
.waveform-animator span:nth-child(7) { animation-delay: 0.6s; }

@keyframes waveAnim {
  0%, 100% { height: 4px; }
  50% { height: 22px; }
}

/* ==================== REMOTE CONTROL PANEL (TAB 5) ==================== */
.remote-commands-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .remote-commands-grid {
    grid-template-columns: 1fr;
  }
}

.command-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.command-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-card);
}

.command-card.danger-card {
  border-color: rgba(244, 63, 94, 0.3);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(244, 63, 94, 0.05));
}

.card-head {
  display: flex;
  gap: 14px;
}

.card-head i {
  font-size: 1.5rem;
  margin-top: 2px;
}

.card-head h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.card-head p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.btn-command {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-cyan { background: var(--cyan-500); color: #fff; }
.btn-cyan-outline { background: transparent; border: 1px solid var(--cyan-500); color: var(--cyan-400); }
.btn-orange { background: #ea580c; color: #fff; }
.btn-purple { background: var(--purple-500); color: #fff; }
.btn-purple-outline { background: transparent; border: 1px solid var(--purple-500); color: var(--purple-400); }
.btn-emerald { background: var(--emerald-500); color: #fff; }
.btn-coral { background: var(--coral-500); color: #fff; }
.btn-teal { background: var(--teal-500); color: #fff; }
.btn-indigo { background: var(--indigo-500); color: #fff; }
.btn-amber { background: var(--amber-500); color: #fff; }
.btn-amber-outline { background: transparent; border: 1px solid var(--amber-500); color: var(--amber-400); }
.btn-danger { background: var(--rose-500); color: #fff; }

.btn-command:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.command-options, .command-options-split {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  align-items: center;
}

.command-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.command-form input, .command-form textarea, .modern-input, .modern-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
}

.command-form input:focus, .command-form textarea:focus, .modern-input:focus {
  border-color: var(--emerald-500);
}

/* ==================== LIVE VIEWING (TAB 6) ==================== */
.live-viewing-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.live-mode-selector {
  display: flex;
  gap: 16px;
}

.live-mode-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.live-mode-card.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--emerald-400);
  color: var(--emerald-400);
  box-shadow: 0 0 20px var(--emerald-glow);
}

.stream-screen-frame {
  height: 480px;
  background: #000;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stream-placeholder {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}

.stream-placeholder i {
  font-size: 3rem;
  color: var(--emerald-400);
}

.stream-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.hud-live-tag {
  background: rgba(244, 63, 94, 0.8);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.blink-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulseDot 1s infinite;
}

.stream-controls-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.control-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-col label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.control-col select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-start-stream {
  background: linear-gradient(135deg, var(--emerald-500), var(--teal-500));
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px var(--emerald-glow);
  transition: all 0.2s;
}

.btn-start-stream:hover {
  transform: scale(1.05);
}

/* ==================== SOCIAL MESSAGING (TAB 7) ==================== */
.social-apps-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 600px;
}

.social-nav-sidebar {
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.6);
  overflow-y: auto;
}

.social-app-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.social-app-item.active {
  background: rgba(30, 41, 59, 0.9);
  color: #fff;
  border-left: 3px solid var(--emerald-400);
}

.social-chat-viewer {
  display: flex;
  flex-direction: column;
}

.chat-viewer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--emerald-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.chat-messages-bubble-list {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-bubble {
  max-width: 65%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.88rem;
  position: relative;
}

.chat-bubble.incoming {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-subtle);
  color: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-bubble.outgoing {
  background: linear-gradient(135deg, var(--emerald-600), var(--emerald-500));
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble-meta {
  font-size: 0.68rem;
  opacity: 0.7;
  margin-top: 4px;
  display: block;
  text-align: right;
}

/* ==================== PRICING MATRIX (TAB 13) ==================== */
.pricing-matrix-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.pricing-matrix-table th, .pricing-matrix-table td {
  padding: 16px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.pricing-matrix-table th.feature-col, .pricing-matrix-table td:first-child {
  text-align: left;
  font-weight: 700;
}

.pricing-matrix-table th.featured {
  background: rgba(16, 185, 129, 0.1);
  border-top: 3px solid var(--emerald-400);
}

.best-value-badge {
  background: var(--emerald-500);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 6px;
}

.plan-price {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  display: block;
}

.btn-tier {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tier-primary { background: var(--emerald-500); color: #fff; }
.btn-tier-secondary { background: var(--cyan-500); color: #fff; }
.btn-tier-amber { background: var(--amber-500); color: #fff; }
.btn-tier.current-btn { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }

/* ==================== SIMULATOR DOCK ==================== */
.simulation-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(6, 182, 212, 0.4);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1200;
  box-shadow: 0 -4px 25px rgba(0, 0, 0, 0.5);
}

.sim-dock-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sim-blinker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan-400);
  box-shadow: 0 0 10px var(--cyan-400);
  animation: pulseDot 1.5s infinite;
}

.sim-dock-text {
  display: flex;
  flex-direction: column;
}

.sim-dock-text strong {
  font-size: 0.85rem;
  color: var(--cyan-400);
}

.sim-dock-text span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

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

.sim-action-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sim-action-btn:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: var(--cyan-400);
}

.sim-toggle-btn {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid var(--coral-500);
  color: var(--coral-400);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

/* Toast Alerts */
.toast-container {
  position: fixed;
  top: 84px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  animation: slideInToast 0.3s ease-out;
}

.toast.emerald { border-left: 4px solid var(--emerald-400); }
.toast.coral { border-left: 4px solid var(--coral-400); }
.toast.cyan { border-left: 4px solid var(--cyan-400); }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

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

.modal-body {
  padding: 22px;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-confirm {
  background: var(--emerald-500);
  border: none;
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
}


/* ==========================================================================
   100% MOBILE RESPONSIVE OVERHAUL (REQUIREMENT 11)
   Optimized for Android & iOS Mobile Viewports (320px - 768px)
   ========================================================================== */

/* Mobile Sticky Bottom Navigation Bar */
.portal-mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(10, 17, 34, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 9999;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.mobile-bottom-btn {
  background: none;
  border: none;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  min-width: 58px;
}

.mobile-bottom-btn i {
  font-size: 18px;
  transition: transform 0.2s;
}

.mobile-bottom-btn.active {
  color: #10b981;
}

.mobile-bottom-btn.active i {
  transform: translateY(-2px);
  color: #10b981;
}

/* TABLET & MOBILE MEDIA QUERIES (max-width: 900px) */
@media (max-width: 900px) {
  .portal-layout {
    flex-direction: column;
  }

  .portal-sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    z-index: 99998;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.8);
    background: #0b1329 !important;
  }

  .portal-sidebar.open {
    left: 0;
  }

  /* Backdrop for mobile drawer */
  .portal-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 99997;
  }

  .portal-sidebar-backdrop.active {
    display: block;
  }

  .portal-main {
    margin-left: 0 !important;
    width: 100% !important;
    padding-bottom: 74px !important; /* Space for bottom bar */
  }

  .portal-mobile-bottom-bar {
    display: flex;
  }
}

/* MOBILE PHONES (max-width: 768px) */
@media (max-width: 768px) {
  .portal-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .portal-header-left {
    gap: 8px;
  }

  .device-quick-pill {
    padding: 4px 8px;
    font-size: 11px;
  }

  .portal-content {
    padding: 12px 14px !important;
  }

  /* Expiry Banner Mobile */
  #smartExpiryBanner {
    margin: 10px 0 16px !important;
    padding: 12px 14px !important;
    flex-direction: column;
    align-items: flex-start !important;
  }

  #smartExpiryBanner button {
    width: 100%;
    justify-content: center;
  }

  /* OVERVIEW TAB: KPI Grid */
  .stat-cards-grid,
  .telemetry-grid,
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .stat-card-widget {
    padding: 12px !important;
  }

  .stat-card-widget .stat-number {
    font-size: 20px !important;
  }

  /* MAP TAB: Locations */
  #mapContainer,
  #liveGpsMap {
    height: 380px !important;
    min-height: 380px !important;
    border-radius: 12px !important;
  }

  .map-overlay-card {
    position: static !important;
    width: 100% !important;
    margin-top: 10px !important;
    border-radius: 10px !important;
  }

  /* REMOTE CONTROL TAB: 2-column big buttons */
  .remote-control-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .remote-btn-card {
    padding: 14px 10px !important;
    min-height: 90px !important;
  }

  .remote-btn-card i {
    font-size: 22px !important;
  }

  .remote-btn-card span {
    font-size: 12px !important;
  }

  /* SMS & CALLS TAB: Responsive Chat & Table */
  .sms-chat-wrap,
  .calls-log-wrap {
    flex-direction: column !important;
  }

  .sms-thread-sidebar {
    width: 100% !important;
    max-height: 180px !important;
    margin-bottom: 10px;
  }

  .sms-bubble {
    max-width: 90% !important;
    font-size: 13px !important;
  }

  /* LIVE VIEWING TAB: 100% fit */
  .camera-stream-frame,
  .screen-stream-frame {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/9;
  }

  /* INSTANT MESSAGING: WhatsApp Style */
  .im-container {
    height: 480px !important;
  }

  /* FILE EXPLORER TAB: 2-column cards */
  .media-grid-explorer {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* SCHEDULE RESTRICTIONS */
  .days-chips-row {
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  /* SETTINGS TAB: 1 column */
  #tab-settings > div {
    grid-template-columns: 1fr !important;
  }

  /* ALL TABLES IN DASHBOARD: Horizontally swipeable */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .table-responsive table {
    min-width: 600px;
  }
}

/* SMALL MOBILE SCREENS (max-width: 480px) */
@media (max-width: 480px) {
  .stat-cards-grid,
  .telemetry-grid {
    grid-template-columns: 1fr !important;
  }

  .remote-control-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .portal-mobile-bottom-bar {
    height: 58px;
  }

  .mobile-bottom-btn {
    font-size: 10px;
    padding: 4px 6px;
    min-width: 50px;
  }

  .mobile-bottom-btn i {
    font-size: 16px;
  }
}

@media (max-width: 900px) { .mobile-drawer-btn { display: flex !important; } }

/* =========================================================
   TOP-LEFT USER PROFILE IDENTITY BADGE
   ========================================================= */
.top-left-user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  padding: 6px 14px;
  margin-left: 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: all 0.25s ease;
}

.top-left-user-badge:hover {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(30, 41, 59, 0.9);
  transform: translateY(-1px);
}

.user-badge-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}

.user-badge-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.user-badge-row-1 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-badge-name {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.2px;
}

.user-badge-role {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.user-badge-row-2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #94a3b8;
}

.user-badge-email, .user-badge-phone {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #cbd5e1;
}

.user-badge-email i {
  color: #38bdf8;
  font-size: 10px;
}

.user-badge-phone i {
  color: #34d399;
  font-size: 10px;
}

.user-badge-sep {
  color: #64748b;
  font-size: 10px;
}

@media (max-width: 768px) {
  .top-left-user-badge {
    padding: 4px 8px;
    margin-left: 6px;
  }
  .user-badge-row-2 {
    display: none;
  }
}

/* =========================================================
   PROMINENT ACTIVE DEVICE CARD ON DASHBOARD
   ========================================================= */
.active-device-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.9));
  border: 1.5px solid rgba(16, 185, 129, 0.35);
  border-radius: 16px;
  padding: 18px 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.5), 0 0 20px -5px rgba(16, 185, 129, 0.2);
  position: relative;
  overflow: hidden;
}

.active-device-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #10b981, #06b6d4);
}

.hero-card-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 280px;
}

.hero-device-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #34d399;
  font-size: 24px;
  position: relative;
  flex-shrink: 0;
}

.hero-device-pulse {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #090d16;
  box-shadow: 0 0 10px #10b981;
  animation: pulseHero 2s infinite;
}

@keyframes pulseHero {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.hero-device-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.live-pill i {
  font-size: 7px;
  animation: blinkLive 1.5s infinite;
}

@keyframes blinkLive {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.model-badge {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.guard-pill {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.hero-device-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
}

.hero-device-title small {
  font-size: 0.85rem;
  font-weight: 500;
  color: #94a3b8;
}

.hero-device-meta-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #cbd5e1;
}

.hero-device-meta-pills span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hero-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hero-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.hero-act-btn.btn-camera {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

.hero-act-btn.btn-camera:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(234, 88, 12, 0.45);
}

.hero-act-btn.btn-contacts {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.hero-act-btn.btn-contacts:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.hero-act-btn.btn-locate {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.hero-act-btn.btn-locate:hover {
  background: rgba(56, 189, 248, 0.15);
  transform: translateY(-2px);
}

/* =========================================================
   CAMERA SNAPSHOT VIEWER MODAL
   ========================================================= */
.camera-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.25s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.camera-modal-window {
  width: 100%;
  max-width: 820px;
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 35px rgba(14, 165, 233, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.camera-modal-header {
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.camera-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
}

.camera-modal-title i {
  color: #f97316;
}

.camera-modal-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}

.camera-modal-close:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.camera-lens-tabs {
  display: flex;
  padding: 10px 20px;
  background: #0b1120;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 10px;
}

.lens-tab-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.lens-tab-btn.active {
  background: rgba(14, 165, 233, 0.18);
  border-color: #0ea5e9;
  color: #38bdf8;
}

.camera-viewport-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #050811;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera-viewport-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shutter-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
}

.shutter-flash.flash-active {
  opacity: 0.85;
}

.camera-modal-footer {
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.camera-footer-meta {
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.camera-footer-meta strong {
  color: #38bdf8;
}

.camera-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
