/* =============================================================================
   Orion GPS v3.0 — Premium Control Center
   Inspirado en Linear, Vercel y Apple — Elegante, sofisticado, atemporal
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Paleta refinada */
  --bg-0: #08090d;
  --bg-1: #0d0f14;
  --bg-2: #131620;
  --bg-3: #1a1e2a;
  --bg-card: rgba(19, 22, 32, 0.6);
  --bg-elevated: rgba(26, 30, 42, 0.8);
  --bg-input: rgba(8, 9, 13, 0.5);

  /* Bordes */
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(99, 102, 241, 0.3);

  /* Acentos — paleta sofisticada */
  --indigo: #6366f1;
  --indigo-light: #818cf8;
  --violet: #a78bfa;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --red: #f43f5e;

  /* Texto */
  --text-0: #f8fafc;
  --text-1: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;

  /* Layout */
  --sidebar-w: 340px;
  --nav-h: 60px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Sombras premium */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.5);
  --glow-indigo: 0 0 40px rgba(99, 102, 241, 0.15);
}

/* ===================== Tema Claro ===================== */
:root[data-theme="light"] {
  --bg-0: #f1f5f9;
  --bg-1: #ffffff;
  --bg-2: #f8fafc;
  --bg-3: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-elevated: rgba(255, 255, 255, 0.95);
  --bg-input: rgba(241, 245, 249, 0.8);

  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --border-accent: rgba(99, 102, 241, 0.3);

  --indigo: #6366f1;
  --indigo-light: #4f46e5;
  --violet: #7c3aed;
  --cyan: #0891b2;
  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --red: #dc2626;

  --text-0: #0f172a;
  --text-1: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.12);
  --glow-indigo: 0 0 40px rgba(99, 102, 241, 0.08);
}

:root[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(99, 102, 241, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(34, 211, 238, 0.04), transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(167, 139, 250, 0.03), transparent 60%);
}

/* Scrollbar tema claro */
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* Navbar tema claro */
:root[data-theme="light"] .navbar-orion {
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Sidebar tema claro */
:root[data-theme="light"] .sidebar-flota {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
}

/* Boton theme toggle */
.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.theme-toggle:hover {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.2);
  color: var(--indigo-light);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Leaflet tema claro — fondo del mapa */
:root[data-theme="light"] #map,
:root[data-theme="light"] #historyMap {
  background: #e2e8f0;
}

/* Atribucion Leaflet tema claro */
:root[data-theme="light"] .leaflet-control-attribution {
  background: rgba(255,255,255,0.7) !important;
  color: #475569 !important;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-0);
  color: var(--text-1);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Aurora background — gradiente animado sutil */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(99, 102, 241, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(34, 211, 238, 0.05), transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(167, 139, 250, 0.04), transparent 60%);
  z-index: -1;
  pointer-events: none;
}

/* Scrollbar minimalista */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ===================== Tipografía ===================== */
.brand-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.5px;
  color: var(--text-0);
}

.brand-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--indigo-light);
  margin-left: 8px;
  letter-spacing: 0.3px;
}

.font-display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.3px; }

/* ===================== Navbar ===================== */
.navbar-orion {
  background: rgba(8, 9, 13, 0.7);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  z-index: 1030;
}

/* Botones elegantes */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.btn-ghost.danger {
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--rose);
}
.btn-ghost.danger:hover {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.3);
}

.btn-primary-elegant {
  background: linear-gradient(135deg, var(--indigo), #4f46e5);
  border: none;
  color: #fff;
  border-radius: var(--r-sm);
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.25s ease;
  box-shadow: 0 1px 3px rgba(99,102,241,0.3), 0 0 0 0 rgba(99,102,241,0);
}

.btn-primary-elegant:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.4), 0 0 20px rgba(99,102,241,0.15);
  color: #fff;
}

/* Avatar elegante */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  border: 2px solid rgba(255,255,255,0.08);
}

/* Boton cerrar sesion — siempre visible y accesible */
.btn-logout {
  background: rgba(244, 63, 94, 0.06);
  border: 1px solid rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fff;
}

.btn-logout i {
  font-size: 0.85rem;
}

/* Dropdown premium */
.dropdown-menu-elegant {
  background: var(--bg-elevated);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xl);
  padding: 6px;
  min-width: 240px;
  z-index: 9999 !important;
  border: 1px solid rgba(255,255,255,0.1);
  margin-top: 8px !important;
}

/* Asegurar que el dropdown siempre este por encima del mapa */
.dropdown {
  position: relative;
  z-index: 1031;
}

/* Header del dropdown con info del usuario */
.dropdown-header-elegant {
  padding: 16px 12px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* Links de navegacion en navbar */
.nav-link-elegant {
  color: var(--text-2);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.nav-link-elegant:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-0);
}

.nav-link-elegant i {
  font-size: 0.78rem;
  color: var(--text-3);
}

.nav-link-elegant:hover i {
  color: var(--indigo-light);
}

.dropdown-menu-elegant .dropdown-item {
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dropdown-menu-elegant .dropdown-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-0);
}

.dropdown-menu-elegant .dropdown-item.danger:hover {
  background: rgba(244,63,94,0.08);
  color: var(--rose);
}

.dropdown-menu-elegant .dropdown-divider {
  border-color: var(--border);
  margin: 4px 0;
}

/* ===================== Layout ===================== */
.main-wrapper {
  display: flex;
  height: calc(100vh - var(--nav-h));
  position: relative;
  overflow: hidden;
}

.main-wrapper.flex-column { flex-direction: column; }

/* ===================== Sidebar ===================== */
.sidebar-flota {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1020;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

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

/* Input elegante */
.input-elegant {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-1) !important;
  border-radius: var(--r-sm) !important;
  font-size: 0.84rem !important;
  padding: 9px 12px !important;
  transition: all 0.2s ease !important;
}

.input-elegant:focus {
  border-color: rgba(99,102,241,0.4) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08) !important;
  outline: none !important;
  background: rgba(8,9,13,0.7) !important;
}

.input-elegant::placeholder { color: var(--text-3); }

.input-group-icon {
  background: rgba(99,102,241,0.06) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-3) !important;
  border-right: none !important;
  border-radius: var(--r-sm) 0 0 var(--r-sm) !important;
}

/* Filtros pills */
.filter-pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 100px;
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.filter-pill:hover {
  border-color: var(--border-hover);
  color: var(--text-1);
}

.filter-pill.active {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.3);
  color: var(--indigo-light);
}

.filter-pill.active .dot-online { background: var(--emerald); }
.filter-pill.active .dot-offline { background: var(--text-3); }
.filter-pill.active .dot-sos { background: var(--red); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-online { background: var(--emerald); }
.dot-offline { background: var(--text-3); }
.dot-sos { background: var(--red); }
.dot-all { background: var(--indigo-light); }

/* Lista de dispositivos */
.device-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Card de dispositivo — premium */
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.device-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Barra de estado lateral */
.device-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--emerald);
}

.device-card.status-offline::before { background: var(--text-3); }
.device-card.status-sos::before { background: var(--red); box-shadow: 0 0 8px var(--red); }

.device-card.status-sos {
  border-color: rgba(244,63,94,0.2);
  background: rgba(244,63,94,0.04);
}

/* Badge de estado */
.status-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.status-badge.online {
  background: rgba(52,211,153,0.1);
  color: var(--emerald);
  border: 1px solid rgba(52,211,153,0.2);
}

.status-badge.offline {
  background: rgba(100,116,139,0.1);
  color: var(--text-3);
  border: 1px solid rgba(100,116,139,0.15);
}

.status-badge.sos {
  background: rgba(244,63,94,0.1);
  color: var(--red);
  border: 1px solid rgba(244,63,94,0.2);
  animation: pulse-sos-badge 2s ease-in-out infinite;
}

@keyframes pulse-sos-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ===================== Mapa ===================== */
#map {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - var(--nav-h));
  background: var(--bg-2);
  position: relative;
  z-index: 1;
}

#historyMap {
  width: 100%;
  height: 100%;
  min-height: 400px;
  background: var(--bg-2);
  position: relative;
  z-index: 1;
}

/* Controles Leaflet elegantes */
.leaflet-pane,
.leaflet-top,
.leaflet-bottom,
.leaflet-control {
  z-index: 400 !important;
}

.leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(12px);
  color: var(--text-1) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 18px !important;
  transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background: rgba(99,102,241,0.1) !important;
  border-color: rgba(99,102,241,0.3) !important;
  color: var(--indigo-light) !important;
}

.leaflet-control-layers {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(12px);
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-layers-expanded { padding: 10px 14px !important; }
.leaflet-control-layers label {
  color: var(--text-2) !important;
  font-size: 0.8rem;
  margin-bottom: 6px;
  font-weight: 500;
}

.leaflet-control-attribution {
  background: rgba(8,9,13,0.6) !important;
  color: var(--text-3) !important;
  font-size: 0.6rem !important;
  border-radius: 4px 0 0 0;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-md) !important;
  color: var(--text-1) !important;
  box-shadow: var(--shadow-xl);
  padding: 4px;
}

.leaflet-popup-tip { background: var(--bg-elevated) !important; }
.leaflet-popup-content { margin: 10px 12px !important; }

/* ===================== Marcadores ===================== */
.orion-marker { position: relative; display: flex; align-items: center; justify-content: center; }

.marker-pin {
  width: 32px; height: 32px;
  border-radius: 50% 50% 50% 0;
  position: absolute;
  transform: rotate(-45deg);
  left: 50%; top: 50%;
  margin: -16px 0 0 -16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.4);
}

.marker-pin.online { background: var(--emerald); }
.marker-pin.offline { background: var(--text-3); }
.marker-pin.sos { background: var(--red); box-shadow: 0 3px 8px rgba(0,0,0,0.4), 0 0 12px rgba(244,63,94,0.5); }
.marker-icon { transform: rotate(45deg); color: white; font-size: 13px; }

.pulse-sos-halo {
  position: absolute; width: 50px; height: 50px;
  border-radius: 50%; background: rgba(244,63,94,0.3);
  animation: pulse-sos 1.5s infinite; pointer-events: none;
}

@keyframes pulse-sos {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* Marcador usuario */
.orion-user-marker { position: relative; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }

.user-pin {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--violet));
  border: 3px solid #fff;
  box-shadow: 0 3px 10px rgba(99,102,241,0.4);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; z-index: 2;
}

.user-pulse {
  position: absolute; width: 36px; height: 36px;
  border-radius: 50%; background: rgba(99,102,241,0.3);
  animation: pulse-user 2.5s infinite; pointer-events: none;
}

@keyframes pulse-user {
  0% { transform: scale(0.3); opacity: 0.7; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* ===================== Banner SOS ===================== */
.sos-banner {
  background: linear-gradient(90deg, rgba(244,63,94,0.95), rgba(190,18,60,0.95));
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.88rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(244,63,94,0.25);
  z-index: 1040;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* ===================== Modales ===================== */
.modal-content.dark-theme {
  background: var(--bg-elevated);
  backdrop-filter: blur(30px);
  color: var(--text-1);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
}

.modal-content.dark-theme .modal-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.modal-content.dark-theme .modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
}

.modal-content.dark-theme .modal-body { padding: 20px 24px; }
.modal-content.dark-theme .modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ===================== Formularios ===================== */
.form-elegant {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  transition: all 0.2s ease;
  width: 100%;
}

.form-elegant:focus {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
  outline: none;
  background: rgba(8,9,13,0.7);
}

.form-elegant::placeholder { color: var(--text-3); }

/* ===================== Tabs ===================== */
.nav-tabs-elegant {
  border-bottom: 1px solid var(--border);
  gap: 4px;
}

.nav-tabs-elegant .nav-link {
  color: var(--text-3);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  background: transparent;
}

.nav-tabs-elegant .nav-link:hover {
  color: var(--text-1);
}

.nav-tabs-elegant .nav-link.active {
  color: var(--indigo-light);
  border-bottom-color: var(--indigo);
}

/* Tablas */
.table-elegant {
  background: transparent;
  color: var(--text-1);
}

.table-elegant thead th {
  background: rgba(99,102,241,0.03);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
}

.table-elegant tbody tr {
  border-bottom: 1px solid var(--border);
  transition: all 0.15s ease;
}

.table-elegant tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-elegant tbody td { padding: 14px 16px; border-color: var(--border); }

/* Stat cards */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-label {
  font-size: 0.68rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text-0);
}

/* ===================== Sidebar movil ===================== */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--r-sm);
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem;
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-hover);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1019;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active { display: block; opacity: 1; }

/* ===================== Hint geo ===================== */
#geoHint {
  display: none;
  background: rgba(99,102,241,0.08);
  color: var(--indigo-light);
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(99,102,241,0.15);
  max-width: 280px;
}

/* ===================== Panel filtros historial ===================== */
.filter-panel {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

/* ===================== Player historial ===================== */
.playback-bar {
  background: var(--bg-elevated) !important;
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-hover) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-xl);
}

.playback-btn {
  background: linear-gradient(135deg, var(--indigo), #4f46e5);
  border: none;
  color: #fff;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(99,102,241,0.3);
  transition: all 0.2s ease;
}

.playback-btn:hover {
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  transform: scale(1.05);
}

input[type="range"].playback-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

input[type="range"].playback-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--indigo-light);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(99,102,241,0.4);
  border: 2px solid #fff;
}

input[type="range"].playback-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--indigo-light);
  cursor: pointer;
  border: 2px solid #fff;
}

.speed-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
}

.speed-btn:hover { border-color: var(--border-hover); color: var(--text-1); }
.speed-btn.active {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.3);
  color: var(--indigo-light);
}

/* Animaciones */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.4s ease-out; }

@keyframes pulse-red-border {
  0% { box-shadow: 0 0 0 0 rgba(244,63,94,0.3); }
  70% { box-shadow: 0 0 0 8px rgba(244,63,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(244,63,94,0); }
}

@keyframes pulse-badge {
  from { opacity: 0.8; }
  to { opacity: 1; }
}

.badge-sos { animation: pulse-badge 1.5s infinite alternate; }

/* ===================== Responsive ===================== */
@media (max-width: 1024px) {
  :root { --sidebar-w: 300px; }
  .brand-badge { display: none; }
}

@media (max-width: 768px) {
  :root { --nav-h: 54px; }

  .navbar-orion { padding: 0 12px; }
  .brand-text { font-size: 1rem; }
  .brand-badge { display: none; }

  .sidebar-flota {
    position: fixed;
    top: var(--nav-h); left: 0; bottom: 0;
    width: 85vw; max-width: 320px;
    min-width: auto;
    transform: translateX(-100%);
    z-index: 1025;
    box-shadow: var(--shadow-xl);
  }

  .sidebar-flota.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }

  #navUserName, #navUserRole { display: none; }

  .sos-banner {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
    text-align: center;
    font-size: 0.82rem;
  }
  .sos-banner > div:last-child { width: 100%; justify-content: center; }

  #map { min-height: calc(100vh - var(--nav-h)); }

  .filter-pill { font-size: 0.7rem; padding: 5px 10px; }

  .device-card { padding: 12px 14px; }

  .playback-bar { width: 95% !important; padding: 12px !important; }
  .stat-card .stat-value { font-size: 1.2rem; }
  #geoHint { display: none !important; }
}

@media (max-width: 480px) {
  .brand-text { font-size: 0.9rem; }
  .filter-pill { font-size: 0.68rem; padding: 4px 8px; }
  .device-card { padding: 10px 12px; margin-bottom: 6px; }
  .modal-content.dark-theme { margin: 12px; border-radius: var(--r-md); }
}
