/* ==========================================================================
   Camera Enterprise Management Dashboard - Multi-Theme & Accessible UI
   ========================================================================== */

:root, [data-theme="light-blue"] {
  --bg-dark: #f0f5fa;
  --bg-card: #ffffff;
  --bg-surface: #f7fafc;
  --bg-hover: #e3effd;
  --border-color: #d1e2f6;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-cyan: #2563eb;
  --accent-cyan-glow: rgba(37, 99, 235, 0.18);
  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.18);
  --accent-amber: #d97706;
  --accent-red: #dc2626;
  --accent-purple: #7c3aed;

  --overlay-scrim: rgba(15, 23, 42, 0.55);
  --shadow-soft: rgba(30, 41, 59, 0.08);
  --shadow-med: rgba(30, 41, 59, 0.16);
  --tint-primary-soft: rgba(37, 99, 235, 0.08);
  --tint-primary-hover: rgba(37, 99, 235, 0.14);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="maroon"] {
  --bg-dark: #fdf2f4;
  --bg-card: #ffffff;
  --bg-surface: #fff1f2;
  --bg-hover: #ffe4e6;
  --border-color: #fecdd3;

  --text-main: #4c0519;
  --text-muted: #881337;
  --text-dim: #9f1239;

  --accent-cyan: #be123c;
  --accent-cyan-glow: rgba(190, 18, 60, 0.22);
  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.18);
  --accent-amber: #d97706;
  --accent-red: #9f1239;
  --accent-purple: #831843;

  --overlay-scrim: rgba(76, 5, 25, 0.55);
  --shadow-soft: rgba(136, 19, 55, 0.08);
  --shadow-med: rgba(136, 19, 55, 0.16);
  --tint-primary-soft: rgba(190, 18, 60, 0.08);
  --tint-primary-hover: rgba(190, 18, 60, 0.14);
}

[data-theme="dark"] {
  --bg-dark: #0b0f19;
  --bg-card: #131b2e;
  --bg-surface: #1e293b;
  --bg-hover: #27354f;
  --border-color: #24324a;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #38bdf8;
  --accent-cyan-glow: rgba(56, 189, 248, 0.25);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;

  --overlay-scrim: rgba(0, 0, 0, 0.75);
  --shadow-soft: rgba(0, 0, 0, 0.35);
  --shadow-med: rgba(0, 0, 0, 0.6);
  --tint-primary-soft: rgba(56, 189, 248, 0.1);
  --tint-primary-hover: rgba(56, 189, 248, 0.18);
}

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

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

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100vw;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

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

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

.logo-icon {
  font-size: 24px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
}

.logo-text .title {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-text .sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--tint-primary-soft);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.offline {
  background: var(--accent-red);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 14px 12px 6px 12px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-section-title i {
  font-size: 10px;
  color: var(--accent-cyan);
}

.sidebar-nav ul {
  list-style: none;
  margin-bottom: 6px;
}

.nav-item {
  margin-bottom: 3px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  transition: var(--transition);
}

.nav-item a i {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.nav-item a:hover {
  background-color: var(--bg-surface);
  color: var(--text-main);
}

.nav-item.active a {
  background: linear-gradient(135deg, var(--accent-cyan), #1d4ed8);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 15px var(--accent-cyan-glow);
}

.nav-item.active a i {
  color: #fff;
}

.badge {
  margin-left: auto;
  background: var(--bg-surface);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* Header Status Pill */
.header-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tint-primary-soft);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-main);
  font-weight: 500;
}

/* Theme Switcher Header Selector */
.theme-switcher-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 3px;
  border-radius: 20px;
  gap: 2px;
}

.theme-pill-btn {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}

.theme-pill-btn:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.theme-pill-btn.active {
  background: var(--bg-card);
  color: var(--accent-cyan);
  box-shadow: 0 2px 6px var(--shadow-soft);
}

/* Quick Action Hub & Friendly Overview Cards for Common Users */
.quick-hub-section {
  margin-bottom: 24px;
}

.quick-hub-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.quick-action-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.quick-action-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: 0 6px 18px var(--shadow-med);
}

.quick-action-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.quick-action-icon.blue {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.quick-action-icon.green {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

.quick-action-icon.purple {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
}

.quick-action-icon.amber {
  background: rgba(217, 119, 6, 0.12);
  color: #d97706;
}

.quick-action-icon.red {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}

.quick-action-text {
  display: flex;
  flex-direction: column;
}

.quick-action-text .title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.quick-action-text .desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 1-Click Fix & Start Service Button */
.btn-quick-fix {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff !important;
  border: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: var(--transition);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-quick-fix:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

[data-theme="maroon"] .btn-quick-fix {
  background: linear-gradient(135deg, #be123c, #9f1239);
  box-shadow: 0 2px 6px rgba(190, 18, 60, 0.25);
}

[data-theme="maroon"] .btn-quick-fix:hover {
  box-shadow: 0 4px 12px rgba(190, 18, 60, 0.4);
}

[data-theme="dark"] .btn-quick-fix {
  background: linear-gradient(135deg, #0284c7, #0369a1);
}

/* Sub-Navigation Pill Bar (3-in-1 Map Hub & Views) */
.subtab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.subtab-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.subtab-pill:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.subtab-pill.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.map-subview {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 165px);
  min-height: 500px;
}

.map-subview.hidden {
  display: none !important;
}

.badge-alert {
  background: var(--accent-red);
  color: #fff;
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 10px rgba(185, 28, 28, 0.6); }
  100% { transform: scale(1); }
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(37, 99, 235, 0.035);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 10px;
  color: var(--accent-cyan);
}

.plan-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

/* Plan gating: elements that require a higher tier than the deployment's current plan.
   Left interactive (not disabled) so clicking still surfaces the upgrade toast / the
   server's own 403 - this is a visual cue, not the enforcement mechanism. */
[data-feature].feature-locked {
  opacity: 0.4;
  filter: grayscale(0.6);
  position: relative;
}

[data-feature].feature-locked::after {
  content: "\f023";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 9px;
  position: absolute;
  top: 2px;
  right: 2px;
  color: #f59e0b;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-dark);
}

/* Top Bar */
.top-header {
  height: 70px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title-container h1 {
  font-size: 20px;
  font-weight: 700;
}

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

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

.quick-stat {
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-surface);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

/* Alert Banner */
.alert-banner {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid var(--accent-red);
  color: #fff;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

/* Content Views */
.content-view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.content-view.active {
  display: block;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 6px -1px var(--shadow-soft);
}

.kpi-icon-box {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.kpi-icon-box.cyan { background: rgba(37, 99, 235, 0.15); color: var(--accent-cyan); }
.kpi-icon-box.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.kpi-icon-box.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.kpi-icon-box.red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

.kpi-details .kpi-title {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.kpi-details .kpi-value {
  display: block;
  font-size: 26px;
  font-weight: 700;
}

.kpi-details .kpi-sub {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
}

/* Dashboard Split Grid */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

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

.panel-header h3 {
  font-size: 15px;
  font-weight: 600;
}

/* .panel-header's default is a single-row "title left, subtitle right" layout - correct
   for two children, but a 3rd child (an eyebrow badge above the title) has nowhere to go
   in a row and fights the other two for space in narrow columns. This stacks all of them
   as a normal top-to-bottom card header instead. */
.panel-header.panel-header-stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.panel-header.panel-header-stack p {
  margin: 0;
}

.panel-body {
  padding: 20px;
}

.panel-body.p-0 {
  padding: 0;
}

.map-view {
  width: 100%;
  height: 480px;
  border-radius: 8px;
  background: #111;
}

/* Incident Items */
.incident-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.incident-item:last-child {
  border-bottom: none;
}

.incident-badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.incident-badge.critical { background: var(--accent-red); color: #fff; }
.incident-badge.warning { background: var(--accent-amber); color: #fff; }
.incident-badge.info { background: var(--accent-cyan); color: #fff; }

.incident-info .incident-msg {
  display: block;
  font-size: 13px;
  font-weight: 500;
}

.incident-info .incident-time {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* Quick Operations */
.quick-operations-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.btn-op {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.btn-op:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
}

.btn-op i {
  font-size: 24px;
}

.btn-op span {
  font-size: 12px;
  font-weight: 600;
}

/* CCTV Matrix */
.cctv-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.cctv-layout-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.cctv-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.cctv-grid.grid-2x2 { grid-template-columns: repeat(2, 1fr); }
.cctv-grid.grid-3x3 { grid-template-columns: repeat(3, 1fr); }
.cctv-grid.single-camera { grid-template-columns: 1fr; max-width: 720px; }
.cctv-grid.grid-1x1 { grid-template-columns: 1fr; }

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.camera-card-header {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.camera-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

.camera-overlay-info {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
  color: var(--accent-green);
}

.camera-motion-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
  display: none;
}

.camera-card-controls {
  padding: 10px 14px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.control-btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Snapshot Gallery */
.snapshot-gallery {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.snapshot-thumb {
  width: 160px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.snapshot-thumb:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.snapshot-thumb img {
  width: 100%;
  height: 90px;
  object-fit: cover;
}

.snapshot-thumb .snap-meta {
  padding: 6px;
  background: var(--bg-surface);
  font-size: 10px;
  color: var(--text-muted);
}

/* Live Fleet Tracking Layout */
.tracker-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  height: calc(100vh - 120px);
}

.tracker-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tracker-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.filter-pills {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

.device-tracking-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.device-track-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.device-track-card:hover, .device-track-card.active {
  border-color: var(--accent-cyan);
  background: var(--bg-hover);
}

.device-track-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.device-track-card-header .name {
  font-size: 13px;
  font-weight: 600;
}

.device-track-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.tracker-map-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.tracker-map-container .map-view {
  height: 100%;
}

.map-floating-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 999;
  display: flex;
  gap: 8px;
}

/* History Playback */
.history-controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.playback-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-surface);
  padding: 10px 16px;
  border-radius: 8px;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scrubber-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider {
  flex: 1;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.timestamp-display {
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
}

.history-split-view {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.history-map-container .map-view {
  height: 540px;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 8px;
}

.stat-box .label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-box .val {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.stops-list {
  max-height: 260px;
  overflow-y: auto;
  margin-top: 10px;
}

.stop-item {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
}

/* Geofence Layout */
.geofence-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.geofence-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.geofence-sidebar .sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.geofence-list {
  flex: 1;
  overflow-y: auto;
}

.geofence-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.geofence-card h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.geofence-card p {
  font-size: 11px;
  color: var(--text-muted);
}

.geofence-map-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.geofence-map-container .map-view {
  height: 100%;
}

.geofence-instructions {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: rgba(19, 27, 46, 0.9);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  z-index: 999;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

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

.data-table th {
  background: var(--bg-surface);
  padding: 14px 18px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

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

.data-table tbody tr:hover {
  background: var(--bg-surface);
}

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-pill.online { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.status-pill.offline { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.status-pill.alert { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* Forms & Inputs */
.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.search-input:focus {
  border-color: var(--accent-cyan);
}

.form-control {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-cyan);
}

.search-and-filters {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-danger:hover {
  background: #7f1d1d;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-surface);
  border-color: var(--accent-cyan);
}

.btn-dark {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1px solid var(--border-color);
}

.btn-dark:hover {
  background: #000;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.btn-icon.active {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 500px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px var(--shadow-med);
}

.modal-dialog.modal-lg {
  width: 800px;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

/* The login screen is the first thing anyone sees - nothing sits behind it to dim,
   so it gets its own soft full-page gradient instead of the generic modal scrim. */
#login-overlay {
  background: linear-gradient(160deg, #eef3fb 0%, #dbe7fb 100%);
  backdrop-filter: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 36px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 25px 50px -12px rgba(30, 41, 59, 0.22);
}

.brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-icon {
  font-size: 48px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  filter: drop-shadow(0 0 16px var(--accent-cyan-glow));
}

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

.badge-enterprise {
  font-size: 10px;
  background: var(--accent-cyan);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.compliance-notice-box {
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid var(--accent-cyan);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--text-main);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent-cyan);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .col {
  flex: 1;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input {
  width: auto;
}

.form-check label {
  margin-bottom: 0;
  cursor: pointer;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-dim);
}

/* Enrollment Hub */
.enrollment-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.qr-generator-panel {
  display: flex;
  flex-direction: column;
}

.qr-code-frame {
  background: #fff;
  padding: 16px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  min-width: 220px;
  min-height: 220px;
  box-shadow: 0 4px 12px var(--shadow-med);
}

.step-badge-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.badge-step1 { background: rgba(37, 99, 235, 0.15); color: var(--accent-cyan); border: 1px solid rgba(37, 99, 235, 0.3); }
.badge-step2 { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }

.deployment-steps {
  padding-left: 20px;
}

.deployment-steps li {
  margin-bottom: 16px;
  font-size: 13px;
}

.deployment-steps p {
  color: var(--text-muted);
  margin-top: 4px;
}

.deployment-steps code {
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
}

/* Utilities */
.hidden { display: none !important; }
.text-cyan { color: var(--accent-cyan); }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-amber { color: var(--accent-amber); }
.text-purple { color: var(--accent-purple); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.empty-text { color: var(--text-dim); font-size: 13px; text-align: center; padding: 20px; }

/* Live Battery & Stealth Mode Styles */
.badge-stealth {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(168, 85, 247, 0.15);
  color: #7c3aed;
  border: 1px solid rgba(168, 85, 247, 0.4);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.25);
  animation: stealth-pulse 2.5s infinite ease-in-out;
}

@keyframes stealth-pulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); box-shadow: 0 0 14px rgba(168, 85, 247, 0.4); }
}

.battery-badge-widget {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  min-width: 100px;
}

.battery-main-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.battery-sub-meta {
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
}

.battery-progress-track {
  width: 100%;
  height: 6px;
  background: rgba(23, 35, 59, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}

.battery-progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.power-profile-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.power-profile-normal { background: rgba(37, 99, 235, 0.15); color: var(--accent-cyan); border: 1px solid rgba(37, 99, 235, 0.3); }
.power-profile-balanced { background: rgba(217, 119, 6, 0.15); color: #b45309; border: 1px solid rgba(217, 119, 6, 0.3); }
.power-profile-extreme { background: rgba(5, 150, 105, 0.15); color: #047857; border: 1px solid rgba(5, 150, 105, 0.3); }

.stealth-control-box {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  padding: 14px;
  margin-top: 16px;
}

/* ==========================================
   REMOTE DEVICE CONTROL & SCREEN MIRRORING
   ========================================== */

.remote-control-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .remote-control-layout {
    grid-template-columns: 1fr;
  }
}

.rc-screen-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone-mirror-frame {
  width: 100%;
  max-width: 360px;
  background: #090d16;
  border: 3px solid #334155;
  border-radius: 28px;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(29, 78, 216, 0.2);
  display: flex;
  flex-direction: column;
  position: relative;
}

.phone-mirror-notch {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 4px 0 8px 0;
}

.notch-speaker {
  width: 48px;
  height: 4px;
  background: #334155;
  border-radius: 2px;
}

.notch-camera {
  width: 10px;
  height: 10px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 50%;
}

.phone-screen-viewport {
  width: 100%;
  height: 580px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  user-select: none;
}

.phone-screen-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.phone-screen-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.touch-ripple {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.4);
  border: 2px solid #2563eb;
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}

.animate-ripple {
  animation: ripple-pulse 0.45s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes ripple-pulse {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

.phone-nav-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 4px 2px 4px;
  background: #0f172a;
  border-radius: 0 0 16px 16px;
  margin-top: 6px;
  border-top: 1px solid #1e293b;
}

.phone-nav-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.phone-nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
}

.phone-nav-btn i {
  font-size: 14px;
}

.rc-quick-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
  max-width: 360px;
}

.rc-deck-column {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  min-height: 600px;
  display: flex;
  flex-direction: column;
}

.rc-deck-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.rc-tab-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.rc-tab-btn.active {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

.rc-tab-content {
  display: none;
  flex: 1;
}

.rc-tab-content.active {
  display: flex;
  flex-direction: column;
}

.rc-tab-intro {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.settings-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.settings-card {
  background: rgba(37, 99, 235, 0.055);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.settings-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.settings-card-info {
  flex: 1;
  min-width: 0;
}

.settings-card-info .title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-card-info .desc {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apps-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.app-filter-pills {
  display: flex;
  gap: 4px;
}

.custom-launch-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  background: rgba(37, 99, 235, 0.05);
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.installed-apps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}

.installed-app-item {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.installed-app-item:hover {
  background: rgba(37, 99, 235, 0.11);
  border-color: rgba(37, 99, 235, 0.3);
}

.app-icon-badge {
  width: 32px;
  height: 32px;
  background: rgba(37, 99, 235, 0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 14px;
  flex-shrink: 0;
}

.app-meta {
  flex: 1;
  min-width: 0;
}

.app-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-pkg {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deck-section-box {
  background: rgba(37, 99, 235, 0.055);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
}

.deck-section-box h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.screen-nodes-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.screen-node-item {
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.screen-node-item:hover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--accent-cyan);
}

/* ==========================================================================
   Responsive Multi-Device & Mobile Layout Support
   ========================================================================== */

/* Mobile Hamburger Button */
.mobile-menu-btn {
  display: none;
  margin-right: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.mobile-menu-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
}

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-scrim);
  backdrop-filter: blur(4px);
  z-index: 1050;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.hidden {
  display: none;
}

/* ==========================================================================
   Mobile-First Navigation & Flawless Responsive Experience
   ========================================================================== */

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 992px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -320px;
    width: 290px;
    height: 100vh;
    z-index: 1200;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 40px rgba(30, 41, 59, 0.25);
  }

  .sidebar.mobile-open {
    transform: translateX(320px);
  }

  .main-content {
    width: 100vw;
    margin-left: 0;
    height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .top-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
    height: auto;
    min-height: 70px;
  }

  .page-title-text h1 {
    font-size: 17px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .dashboard-split-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .tracker-layout {
    flex-direction: column;
    height: auto;
  }

  .tracker-sidebar {
    width: 100%;
    max-height: 260px;
  }

  .tracker-map-container {
    height: 420px;
  }

  .history-split-view {
    flex-direction: column;
  }

  .history-map-container {
    height: 380px;
  }

  .geofence-layout {
    flex-direction: column;
  }

  .geofence-sidebar {
    width: 100%;
    max-height: 260px;
  }

  .geofence-map-container {
    height: 380px;
  }

  .remote-control-layout {
    flex-direction: column;
    gap: 16px;
  }

  .rc-screen-column {
    align-items: center;
    width: 100%;
  }

  .rc-deck-column {
    min-height: auto;
    width: 100%;
  }

  .modal-dialog.modal-xl {
    width: 98vw;
    max-height: 96vh;
    margin: 2vh auto;
  }
}

@media (max-width: 768px) {
  /* Native Mobile Bottom Navigation Bar */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(19, 27, 46, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 1050;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px calc(env(safe-area-inset-bottom, 0px) + 2px);
    box-shadow: 0 -4px 25px var(--shadow-med);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-btn i {
    font-size: 18px;
    transition: transform 0.2s ease, color 0.2s ease;
  }

  .mobile-nav-btn.active {
    color: var(--accent-cyan);
  }

  .mobile-nav-btn.active i {
    transform: translateY(-2px);
    color: var(--accent-cyan);
    filter: drop-shadow(0 0 8px var(--accent-cyan-glow));
  }

  .nav-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-dot-badge {
    position: absolute;
    top: -2px;
    right: -6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-cyan);
    box-shadow: 0 0 6px var(--accent-cyan);
    display: none;
  }

  .nav-dot-badge.visible {
    display: block;
  }

  .nav-dot-badge.alert {
    background: var(--accent-red);
    box-shadow: 0 0 6px var(--accent-red);
  }

  .main-content {
    padding-bottom: 80px !important;
  }

  .content-view {
    padding: 12px 10px 24px 10px;
  }

  /* Compact sticky top header on mobile */
  .top-header {
    position: sticky;
    top: 0;
    z-index: 950;
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto;
    min-height: 52px;
  }

  .page-title-container {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
  }

  .page-title-text h1 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    margin: 0;
  }

  .page-subtitle {
    display: none;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .header-status-pill {
    font-size: 11px;
    padding: 4px 8px;
    white-space: nowrap;
  }

  #btn-header-download-apk span,
  #btn-global-broadcast span {
    display: none;
  }

  /* The theme switcher's 3 text-labeled pills ("Blue"/"Maroon"/"Dark") were never given the
     same icon-only treatment as the other header buttons below, so on phones they alone need
     more width than the entire header row has - collapse them to icon-only pills here. */
  .theme-switcher-group {
    padding: 2px;
    gap: 0;
  }

  .theme-pill-btn {
    padding: 6px 8px;
  }

  .theme-pill-btn span {
    display: none;
  }

  .header-actions .btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 34px;
    height: 34px;
  }

  /* CCTV Controls & Toolbar on Mobile */
  .cctv-controls-bar {
    padding: 8px 12px;
    margin-bottom: 12px;
  }

  .cctv-layout-switcher {
    display: none;
  }

  .cctv-actions {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .cctv-actions .btn {
    flex: 1;
    height: 36px;
    font-size: 12px;
    padding: 6px;
    justify-content: center;
  }

  /* CCTV Streams in Single Column */
  .cctv-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .camera-card {
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-soft);
  }

  .camera-viewport {
    aspect-ratio: 16 / 9;
    height: auto !important;
    max-height: 240px;
  }

  .camera-card-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }

  .control-btn-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
  }

  .control-btn-group .btn-icon {
    flex: 1;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: rgba(37, 99, 235, 0.06);
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }

  .control-btn-group .btn {
    flex: 1;
    height: 38px;
    font-size: 11px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .panel-header h3 {
    font-size: 14px;
  }

  .panel-header .text-muted {
    font-size: 11px;
  }

  /* Subtab scrollable pill bar */
  .subtab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .subtab-pill {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 6px 12px;
  }

  /* Mobile Fullscreen Modals */
  .modal-overlay {
    padding: 0;
  }

  .modal-dialog {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }

  .remote-control-layout {
    flex-direction: column;
    gap: 12px;
  }

  .phone-mirror-frame {
    width: 100% !important;
    max-width: 280px;
    margin: 0 auto;
  }

  .phone-screen-viewport {
    height: 380px !important;
  }

  .rc-deck-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 4px;
  }

  .rc-tab-btn {
    flex: 0 0 auto;
    font-size: 11px;
    padding: 6px 10px;
  }

  .data-table th, .data-table td {
    padding: 8px 10px;
    font-size: 11px;
  }

  .settings-shortcuts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .page-title-text h1 {
    font-size: 14px;
    max-width: 130px;
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn span {
    display: none;
  }

  .header-actions .btn {
    padding: 6px 8px;
  }
}

/* Subscription & Billing */
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

.status-pill.status-new { background: rgba(37, 99, 235, 0.15); color: var(--accent-cyan); }
.status-pill.status-contacted { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.status-pill.status-closed { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }

.badge-type {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-type-lead { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
.badge-type-upgrade { background: rgba(37, 99, 235, 0.15); color: var(--accent-cyan); }

.subscription-grid {
  display: grid;
  gap: 20px;
}

.tier-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.plan-tier-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.plan-tier-card.tier-pro { border-top-color: var(--accent-cyan); }
.plan-tier-card.tier-enterprise { border-top-color: var(--accent-amber); }
.plan-tier-card.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 1px var(--accent-green), 0 0 24px var(--accent-green-glow);
}

.plan-tier-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.plan-tier-header i {
  font-size: 20px;
  color: var(--text-muted);
  width: 28px;
  text-align: center;
}
.plan-tier-card.tier-pro .plan-tier-header i { color: var(--accent-cyan); }
.plan-tier-card.tier-enterprise .plan-tier-header i { color: var(--accent-amber); }

.plan-tier-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.plan-tier-tagline {
  font-size: 12px;
  color: var(--text-muted);
}

.plan-tier-features {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: grid;
  gap: 9px;
  flex: 1;
}
.plan-tier-features li {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.plan-tier-features li i {
  color: var(--accent-green);
  font-size: 11px;
}

.plan-tier-actions { margin-top: auto; }

.plan-active-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
  font-size: 12.5px;
  font-weight: 700;
}


