/* ═══════════════════════════════════════════════════════════════════
 * Systrack+ Design 2026 — "4D" deep layered dark theme
 * Specificity alta (html body ...) para ganar contra overrides MUI internos
 * ═══════════════════════════════════════════════════════════════════ */

/* Nota: el sidebar v2 custom fue eliminado; ahora usamos el sidebar nativo de
 * Traccar 6.12 (muiltr-*-sidebar). El estilado del sidebar nativo se hace más
 * abajo apuntando a sus clases Material-UI con prefijo muiltr-. */


:root {
  /* Paleta base */
  --st-bg: #05070d;
  --st-bg-elev: #0a0e1a;
  --st-surface: #0f1420;
  --st-surface-2: #141b2b;
  --st-surface-3: #1a2236;
  --st-surface-glass: rgba(15, 20, 32, 0.72);
  --st-surface-glass-strong: rgba(15, 20, 32, 0.88);

  /* Bordes y divisores */
  --st-border: rgba(148, 163, 184, 0.08);
  --st-border-strong: rgba(148, 163, 184, 0.16);
  --st-border-glow: rgba(249, 115, 22, 0.22);

  /* Text */
  --st-text: #e8edf5;
  --st-text-dim: #94a3b8;
  --st-text-muted: #64748b;

  /* Primary + semáforo */
  --st-primary: #f97316;
  --st-primary-hover: #fb923c;
  --st-primary-bg: rgba(249, 115, 22, 0.12);
  --st-primary-glow: 0 0 0 1px rgba(249, 115, 22, 0.3), 0 8px 28px -6px rgba(249, 115, 22, 0.45);
  --st-success: #10b981;
  --st-success-bg: rgba(16, 185, 129, 0.14);
  --st-warn: #f59e0b;
  --st-warn-bg: rgba(245, 158, 11, 0.14);
  --st-danger: #ef4444;
  --st-danger-bg: rgba(239, 68, 68, 0.14);
  --st-info: #3b82f6;

  /* Tipografía */
  --st-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --st-font-mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, Menlo, monospace;
  --st-font-display: 'Rajdhani', 'Inter', sans-serif;

  /* Radius */
  --st-radius-sm: 8px;
  --st-radius: 12px;
  --st-radius-lg: 16px;
  --st-radius-xl: 20px;

  /* Sombras 4D — capas reales, no simuladas */
  --st-shadow-inset-top: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  --st-shadow-inset-bottom: 0 -1px 0 rgba(0, 0, 0, 0.4) inset;
  --st-shadow-ambient: 0 0 0 1px rgba(148, 163, 184, 0.08);
  --st-shadow-drop: 0 20px 48px -16px rgba(0, 0, 0, 0.72), 0 4px 12px -4px rgba(0, 0, 0, 0.4);
  --st-shadow-card:
    var(--st-shadow-inset-top),
    var(--st-shadow-ambient),
    0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --st-shadow-lift:
    var(--st-shadow-inset-top),
    var(--st-shadow-ambient),
    0 24px 60px -16px rgba(0, 0, 0, 0.72),
    0 0 0 1px var(--st-border-glow);
  --st-shadow-primary:
    var(--st-shadow-inset-top),
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 8px 24px -6px rgba(249, 115, 22, 0.45),
    0 2px 6px -2px rgba(249, 115, 22, 0.3);
}

/* ═══ GLOBAL ═══ */
html, html body, html body #root {
  background: var(--st-bg) !important;
  color: var(--st-text);
  font-family: var(--st-font) !important;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html body, html body #root {
  background:
    radial-gradient(ellipse 70% 60% at 50% -10%, rgba(249, 115, 22, 0.06), transparent 50%),
    radial-gradient(ellipse 60% 40% at 85% 0%, rgba(59, 130, 246, 0.04), transparent 50%),
    radial-gradient(ellipse 50% 40% at 10% 100%, rgba(249, 115, 22, 0.03), transparent 50%),
    var(--st-bg) !important;
}

html body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(148, 163, 184, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.5;
}

/* Scrollbar */
html body ::-webkit-scrollbar { width: 10px; height: 10px; }
html body ::-webkit-scrollbar-track { background: transparent; }
html body ::-webkit-scrollbar-thumb {
  background: var(--st-surface-3);
  border-radius: 10px;
  border: 2px solid var(--st-bg);
}
html body ::-webkit-scrollbar-thumb:hover { background: rgba(249, 115, 22, 0.25); }

html body ::selection { background: rgba(249, 115, 22, 0.32); color: #fff; }

/* Loader inicial */
html body .loader {
  border-color: var(--st-surface-2) !important;
  border-right-color: var(--st-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * AppBar / Topbar — layer glass 4D
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiAppBar-root,
html body header.MuiPaper-root {
  background:
    linear-gradient(180deg, rgba(15, 20, 32, 0.88) 0%, rgba(10, 13, 22, 0.95) 100%) !important;
  backdrop-filter: blur(24px) saturate(1.5) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.5) !important;
  border-bottom: 1px solid var(--st-border-strong) !important;
  box-shadow:
    var(--st-shadow-inset-top),
    0 0 0 1px rgba(0, 0, 0, 0.3) inset,
    0 12px 32px -20px rgba(0, 0, 0, 0.9) !important;
  color: var(--st-text) !important;
  position: relative;
}

html body .MuiAppBar-root::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.35), transparent);
  opacity: 0.8;
  pointer-events: none;
}

html body .MuiToolbar-root {
  min-height: 56px !important;
  color: var(--st-text) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Drawer (sidebar) — glass profundo con depth 4D + layout flex
 * Specificity MUY alta para ganar sobre MUI
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiDrawer-root .MuiPaper-root,
html body .MuiDrawer-paper,
html body [class*="MuiDrawer"] [class*="MuiPaper"] {
  background:
    linear-gradient(180deg, rgba(15, 20, 32, 0.92) 0%, rgba(10, 13, 22, 0.96) 100%) !important;
  background-image:
    linear-gradient(180deg, rgba(15, 20, 32, 0.92) 0%, rgba(10, 13, 22, 0.96) 100%) !important;
  background-color: rgba(10, 13, 22, 0.96) !important;
  backdrop-filter: blur(32px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(32px) saturate(1.6) !important;
  color: var(--st-text) !important;
  border-right: 1px solid var(--st-border-strong) !important;
  box-shadow:
    1px 0 0 rgba(255, 255, 255, 0.04) inset,
    -1px 0 0 rgba(0, 0, 0, 0.5) inset,
    20px 0 64px -20px rgba(0, 0, 0, 0.6) !important;
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* La lista de vehículos DEBE ser flex:1 con scroll interno para que el footer quede fijo */
html body .MuiDrawer-paper .MuiList-root,
html body .MuiDrawer-paper [class*="MuiList"] {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Footer nav del sidebar (Geocercas / Eventos / Alertas / Reportes / Config)
 * Tema dark unificado — gana sobre cualquier estilo MUI
 * ═══════════════════════════════════════════════════════════════════ */

/* Container del footer nav: SIEMPRE al fondo + dark glass */
html body .MuiDrawer-paper .MuiBottomNavigation-root,
html body .MuiDrawer-paper [class*="BottomNavigation"],
html body .MuiDrawer-paper > :last-child:not(.MuiList-root):not([class*="MuiList"]),
html body .MuiDrawer-paper .MuiPaper-root:last-child {
  flex-shrink: 0 !important;
  margin-top: auto !important;
  background: linear-gradient(180deg, rgba(15,20,32,0.92) 0%, rgba(7,9,15,0.98) 100%) !important;
  background-color: rgba(7,9,15,0.98) !important;
  background-image: linear-gradient(180deg, rgba(15,20,32,0.92) 0%, rgba(7,9,15,0.98) 100%) !important;
  backdrop-filter: blur(24px) saturate(1.5) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.5) !important;
  border-top: 1px solid var(--st-border-strong) !important;
  box-shadow:
    0 -1px 0 rgba(255,255,255,0.04) inset,
    0 -12px 32px -8px rgba(0,0,0,0.7) !important;
  padding: 10px 4px !important;
  min-height: 68px !important;
  box-sizing: border-box !important;
}

/* Item base — color gris uniforme, sin background propio */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root,
html body .MuiDrawer-paper [class*="BottomNavigationAction"],
html body .MuiDrawer-paper .st-injected-nav {
  color: #94a3b8 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: none !important;
  border-radius: 10px !important;
  min-width: 56px !important;
  max-width: 90px !important;
  padding: 8px 6px !important;
  margin: 0 2px !important;
  transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1) !important;
  font-family: var(--st-font) !important;
  cursor: pointer !important;
  text-decoration: none !important;
  position: relative;
  overflow: hidden;
}

/* Iconos: forzar color uniforme (gana sobre fill/stroke heredados) */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root svg,
html body .MuiDrawer-paper [class*="BottomNavigationAction"] svg,
html body .MuiDrawer-paper .st-injected-nav svg {
  color: inherit !important;
  fill: none !important;
  stroke: currentColor !important;
  width: 22px !important;
  height: 22px !important;
}

/* Labels (textos debajo del icono) */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root .MuiBottomNavigationAction-label,
html body .MuiDrawer-paper .MuiBottomNavigationAction-root span:last-child,
html body .MuiDrawer-paper .st-injected-nav span:last-child {
  font-size: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 0.05em !important;
  margin-top: 5px !important;
  color: inherit !important;
  text-transform: none !important;
  font-family: var(--st-font) !important;
}

/* Hover: lift + tint */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root:hover,
html body .MuiDrawer-paper [class*="BottomNavigationAction"]:hover,
html body .MuiDrawer-paper .st-injected-nav:hover {
  color: #f1f5f9 !important;
  background: rgba(148,163,184,0.08) !important;
  transform: translateY(-1px);
}

/* Selected / Active: acento naranja con glow sutil */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root.Mui-selected,
html body .MuiDrawer-paper .MuiBottomNavigationAction-root[aria-selected="true"],
html body .MuiDrawer-paper [class*="BottomNavigationAction"].Mui-selected,
html body .MuiDrawer-paper .st-injected-nav.active {
  color: var(--st-primary) !important;
  background: linear-gradient(180deg, rgba(249,115,22,0.18), rgba(249,115,22,0.04)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(249,115,22,0.25),
    0 0 14px -4px rgba(249,115,22,0.45);
}

/* Indicador inferior (línea naranja debajo del activo) */
html body .MuiDrawer-paper .MuiBottomNavigationAction-root.Mui-selected::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--st-primary);
  box-shadow: 0 0 8px rgba(249,115,22,0.6);
}

html body .MuiDrawer-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.04) 0%, transparent 40%);
  z-index: 0;
}

html body .MuiDrawer-paper > * {
  position: relative;
  z-index: 1;
}

/* Todos los subcomponentes internos del drawer heredan transparencia */
html body .MuiDrawer-paper .MuiList-root,
html body .MuiDrawer-paper .MuiListItem-root,
html body .MuiDrawer-paper .MuiBox-root,
html body .MuiDrawer-paper > div,
html body .MuiDrawer-paper > div > div {
  background: transparent !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Cards / Paper — superficie elevada 4D
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiPaper-root:not(.MuiAppBar-root):not(.MuiDrawer-paper):not(.MuiPopover-paper):not(.MuiMenu-paper):not(.MuiDialog-paper) {
  background-color: var(--st-surface) !important;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, transparent 50%) !important;
  color: var(--st-text) !important;
  border: 1px solid var(--st-border) !important;
  border-radius: var(--st-radius-lg) !important;
  box-shadow: var(--st-shadow-card) !important;
  position: relative;
  overflow: hidden;
}

html body .MuiCard-root {
  background-color: var(--st-surface) !important;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 60%) !important;
  border: 1px solid var(--st-border) !important;
  border-radius: var(--st-radius-lg) !important;
  box-shadow: var(--st-shadow-card) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Lista de vehículos — cards glass individuales
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiListItem-root,
html body .MuiListItemButton-root {
  background: rgba(20, 27, 43, 0.5) !important;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 50%) !important;
  border: 1px solid rgba(148, 163, 184, 0.06) !important;
  border-radius: var(--st-radius) !important;
  margin: 4px 8px !important;
  padding: 10px 12px !important;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1) !important;
  color: var(--st-text) !important;
  position: relative;
  overflow: hidden;
}

html body .MuiListItemButton-root:hover {
  background: rgba(30, 41, 59, 0.6) !important;
  border-color: rgba(148, 163, 184, 0.14) !important;
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 6px 18px -6px rgba(0, 0, 0, 0.5);
}

html body .MuiListItemButton-root.Mui-selected,
html body .MuiListItemButton-root[aria-selected="true"] {
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.18), rgba(249, 115, 22, 0.04)) !important;
  border-color: var(--st-border-glow) !important;
  box-shadow:
    inset 3px 0 0 var(--st-primary),
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 8px 24px -8px rgba(249, 115, 22, 0.3) !important;
}

html body .MuiListItemText-primary {
  color: var(--st-text) !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  letter-spacing: 0.01em;
}

html body .MuiListItemText-secondary {
  color: var(--st-text-dim) !important;
  font-size: 11px !important;
  font-family: var(--st-font-mono) !important;
  margin-top: 2px;
}

html body .MuiListItemIcon-root {
  color: var(--st-text-dim) !important;
  min-width: 36px !important;
}

html body .MuiListSubheader-root {
  background: transparent !important;
  color: var(--st-text-muted) !important;
  font-size: 10px !important;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700 !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Inputs — sumidos con depth
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiOutlinedInput-root {
  background-color: rgba(5, 7, 13, 0.6) !important;
  background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.2), transparent 50%) !important;
  border-radius: var(--st-radius) !important;
  color: var(--st-text) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset !important;
}
html body .MuiOutlinedInput-notchedOutline {
  border-color: var(--st-border-strong) !important;
  transition: border-color 0.15s ease;
}
html body .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline {
  border-color: rgba(148, 163, 184, 0.25) !important;
}
html body .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline {
  border-color: var(--st-primary) !important;
  border-width: 2px !important;
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.1);
}
html body .MuiInputBase-input { color: var(--st-text) !important; }
html body .MuiInputBase-input::placeholder {
  color: var(--st-text-muted) !important;
  opacity: 1 !important;
}
html body .MuiInputLabel-root { color: var(--st-text-dim) !important; }
html body .MuiInputLabel-root.Mui-focused { color: var(--st-primary) !important; }

/* ═══════════════════════════════════════════════════════════════════
 * Buttons — 4D con highlight/shadow
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiButton-root {
  text-transform: none !important;
  font-weight: 600 !important;
  font-family: var(--st-font) !important;
  border-radius: var(--st-radius) !important;
  letter-spacing: 0 !important;
  transition: all 0.15s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

html body .MuiButton-contained,
html body .MuiButton-containedPrimary {
  background: linear-gradient(180deg, #fb923c 0%, var(--st-primary) 50%, #ea580c 100%) !important;
  background-image: linear-gradient(180deg, #fb923c 0%, var(--st-primary) 50%, #ea580c 100%) !important;
  color: #fff !important;
  box-shadow: var(--st-shadow-primary) !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
html body .MuiButton-contained:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.25) inset,
    0 12px 32px -6px rgba(249, 115, 22, 0.6),
    0 4px 10px -2px rgba(249, 115, 22, 0.4) !important;
  filter: brightness(1.05);
}
html body .MuiButton-contained:active { transform: translateY(0); filter: brightness(0.95); }

html body .MuiButton-outlined {
  border: 1px solid var(--st-border-strong) !important;
  color: var(--st-text) !important;
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.04), transparent) !important;
  box-shadow: var(--st-shadow-inset-top), 0 4px 12px -6px rgba(0, 0, 0, 0.3) !important;
}
html body .MuiButton-outlined:hover {
  border-color: var(--st-border-glow) !important;
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.12), rgba(249, 115, 22, 0.04)) !important;
  transform: translateY(-1px);
}

html body .MuiButton-text {
  color: var(--st-text-dim) !important;
}
html body .MuiButton-text:hover {
  background-color: rgba(148, 163, 184, 0.06) !important;
  color: var(--st-text) !important;
}

html body .MuiIconButton-root {
  color: var(--st-text-dim) !important;
  transition: all 0.15s ease !important;
  border-radius: 10px !important;
}
html body .MuiIconButton-root:hover {
  background-color: rgba(148, 163, 184, 0.08) !important;
  color: var(--st-text) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Chips
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiChip-root {
  background: linear-gradient(180deg, rgba(20, 27, 43, 0.8), rgba(15, 20, 32, 0.9)) !important;
  color: var(--st-text) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 999px !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  letter-spacing: 0.02em;
  box-shadow: var(--st-shadow-inset-top), 0 2px 8px -2px rgba(0, 0, 0, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════
 * Menus / Popovers
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiPopover-paper,
html body .MuiMenu-paper {
  background: linear-gradient(180deg, rgba(15, 20, 32, 0.95), rgba(10, 13, 22, 0.98)) !important;
  backdrop-filter: blur(24px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.6) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: var(--st-radius) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 32px 72px -16px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(0, 0, 0, 0.2) !important;
  color: var(--st-text) !important;
}
html body .MuiMenuItem-root {
  color: var(--st-text) !important;
  font-size: 13px !important;
  border-radius: 6px !important;
  margin: 2px 4px !important;
}
html body .MuiMenuItem-root:hover { background: rgba(148, 163, 184, 0.08) !important; }
html body .MuiMenuItem-root.Mui-selected {
  background: var(--st-primary-bg) !important;
  color: var(--st-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Dialog — modal 4D con sombra dramática
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiDialog-paper {
  background: linear-gradient(180deg, var(--st-surface) 0%, var(--st-bg-elev) 100%) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: var(--st-radius-lg) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 48px 96px -24px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(249, 115, 22, 0.1) !important;
  color: var(--st-text) !important;
}
html body .MuiDialogTitle-root {
  color: var(--st-text) !important;
  font-family: var(--st-font-display) !important;
  font-size: 20px !important;
  font-weight: 600 !important;
}
html body .MuiDialogContent-root { color: var(--st-text-dim) !important; }
html body .MuiBackdrop-root {
  background-color: rgba(0, 0, 0, 0.7) !important;
  backdrop-filter: blur(6px);
}

/* ═══════════════════════════════════════════════════════════════════
 * Tabs
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiTabs-root { border-bottom: 1px solid var(--st-border) !important; }
html body .MuiTab-root {
  text-transform: none !important;
  color: var(--st-text-dim) !important;
  font-weight: 600 !important;
}
html body .MuiTab-root.Mui-selected { color: var(--st-primary) !important; }
html body .MuiTabs-indicator {
  background: linear-gradient(90deg, var(--st-primary), #fb923c) !important;
  height: 2px !important;
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════
 * Tooltip — floating glass
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiTooltip-tooltip {
  background: rgba(15, 20, 32, 0.96) !important;
  backdrop-filter: blur(16px);
  border: 1px solid var(--st-border-strong) !important;
  color: var(--st-text) !important;
  font-size: 11px !important;
  padding: 7px 10px !important;
  border-radius: 8px !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 12px 28px -8px rgba(0, 0, 0, 0.7);
}

/* ═══════════════════════════════════════════════════════════════════
 * Barra #stFleetBar — contadores de flota dark
 * ═══════════════════════════════════════════════════════════════════ */
html body #stFleetBar {
  background:
    linear-gradient(180deg, rgba(15, 20, 32, 0.9), rgba(10, 13, 22, 0.95)) !important;
  backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid var(--st-border-strong) !important;
  padding: 12px 14px !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 4px 12px -6px rgba(0, 0, 0, 0.5);
}
html body #stFleetBar b {
  color: var(--st-text) !important;
  font-family: var(--st-font-mono) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
}
html body #stFleetBar span span {
  color: var(--st-text-muted) !important;
  font-size: 10px !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
html body #stFleetBar svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ═══════════════════════════════════════════════════════════════════
 * Mapa — controles redark + tile claro sobre fondo dark
 * ═══════════════════════════════════════════════════════════════════ */
html body .maplibregl-ctrl-group,
html body .mapboxgl-ctrl-group,
html body .leaflet-control-zoom {
  background: rgba(15, 20, 32, 0.92) !important;
  backdrop-filter: blur(12px);
  border: 1px solid var(--st-border-strong) !important;
  border-radius: var(--st-radius) !important;
  /* overflow: visible — dejar que dropdowns como style-list se vean fuera */
  overflow: visible !important;
  filter: none !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 12px 28px -8px rgba(0, 0, 0, 0.6) !important;
}

/* border-radius en buttons (compensar la pérdida de overflow:hidden) */
html body .maplibregl-ctrl-group button:first-child,
html body .mapboxgl-ctrl-group button:first-child {
  border-top-left-radius: var(--st-radius) !important;
  border-top-right-radius: var(--st-radius) !important;
}
html body .maplibregl-ctrl-group button:last-child,
html body .mapboxgl-ctrl-group button:last-child {
  border-bottom-left-radius: var(--st-radius) !important;
  border-bottom-right-radius: var(--st-radius) !important;
}
html body .maplibregl-ctrl-group button,
html body .mapboxgl-ctrl-group button,
html body .leaflet-control-zoom a {
  background: transparent !important;
  color: var(--st-text) !important;
  border: none !important;
  border-top: 1px solid var(--st-border) !important;
}
html body .maplibregl-ctrl-group button:first-child,
html body .mapboxgl-ctrl-group button:first-child,
html body .leaflet-control-zoom a:first-child { border-top: none !important; }
html body .maplibregl-ctrl-group button:hover,
html body .mapboxgl-ctrl-group button:hover,
html body .leaflet-control-zoom a:hover {
  background: rgba(249, 115, 22, 0.14) !important;
  color: var(--st-primary) !important;
}

/* CRÍTICO: los iconos de MapLibre son <span class="maplibregl-ctrl-icon">.
   Por default son inline → width/height no aplican → invisible.
   Hay que: display block + tamaño + filter:invert (SVG es color #333). */
html body .maplibregl-ctrl-group button .maplibregl-ctrl-icon,
html body .mapboxgl-ctrl-group button .mapboxgl-ctrl-icon {
  display: block !important;
  width: 24px !important;
  height: 24px !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 22px 22px !important;
  filter: invert(1) brightness(0.95) !important;
  opacity: 1 !important;
}

html body .maplibregl-ctrl-group button:hover .maplibregl-ctrl-icon,
html body .mapboxgl-ctrl-group button:hover .mapboxgl-ctrl-icon {
  filter: invert(60%) sepia(80%) saturate(1500%) hue-rotate(360deg) brightness(105%) !important;
}

/* Geolocate active (cuando GPS está activo) */
html body .maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon {
  filter: invert(60%) sepia(80%) saturate(1800%) hue-rotate(360deg) brightness(95%) !important;
}

/* Style switcher (selector de capas) — usamos mask + background-color para
 * pintar el icon de capas en blanco / naranja en hover. Es más confiable que
 * SVG inline con fill — el background-image puede ser overrideado por otros
 * selectores del bundle. */
html body .maplibregl-style-switcher {
  background-image: none !important;
  background-color: transparent !important;
  position: relative !important;
  overflow: visible !important;
  /* El plugin nativo pone style="display:none" inline al click para esconder el botón
     mientras muestra el dropdown. Forzar visible para no perder el icono. */
  display: block !important;
}
html body .maplibregl-style-switcher::before {
  content: '' !important;
  position: absolute !important;
  inset: 0 !important;
  background-color: #e8edf5 !important;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 16l-9-7 9-4 9 4-9 7zm0 4.5l-9-7v-2.5l9 7 9-7v2.5l-9 7zm0 4l-9-7v-2.5l9 7 9-7v2.5l-9 7z'/></svg>") !important;
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><path d='M12 16l-9-7 9-4 9 4-9 7zm0 4.5l-9-7v-2.5l9 7 9-7v2.5l-9 7zm0 4l-9-7v-2.5l9 7 9-7v2.5l-9 7z'/></svg>") !important;
  -webkit-mask-size: 22px 22px !important;
  mask-size: 22px 22px !important;
  -webkit-mask-position: center !important;
  mask-position: center !important;
  -webkit-mask-repeat: no-repeat !important;
  mask-repeat: no-repeat !important;
  pointer-events: none !important;
  filter: none !important;
}
html body .maplibregl-style-switcher:hover::before {
  background-color: #fb923c !important;
}
/* Dropdown del switcher — posicionarlo a la izquierda del botón con z-index alto.
 * NO sobrescribir display — Traccar lo controla (none por default, flex al click).
 * Mostrar solo cuando hay clase 'open' o cuando está visible (Traccar usa display:flex). */
html body .maplibregl-style-list {
  position: absolute !important;
  right: 50px !important;
  top: 0 !important;
  background: rgba(15, 20, 32, 0.96) !important;
  color: var(--st-text) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 10px !important;
  padding: 6px !important;
  min-width: 180px !important;
  z-index: 9999 !important;
  flex-direction: column;
  gap: 2px !important;
  filter: none !important;
  box-shadow: 0 16px 40px -8px rgba(0,0,0,0.7) !important;
  backdrop-filter: blur(20px) saturate(1.4) !important;
}
/* Por default el dropdown está oculto. Se abre con clase .st-switcher-open
   que el script systrack-switcher.js togglea al click sobre el botón.
   Antes lo controlábamos por :hover pero el gap entre botón y dropdown causaba
   que se perdiera el hover al cruzar — UX rota. */
html body .maplibregl-ctrl-group:has(.maplibregl-style-switcher) .maplibregl-style-list {
  display: none !important;
}
html body .maplibregl-ctrl-group.st-switcher-open .maplibregl-style-list {
  display: flex !important;
}
html body .maplibregl-style-list button,
html body .maplibregl-ctrl-group .maplibregl-style-list button {
  color: var(--st-text) !important;
  background: transparent !important;
  background-image: none !important;
  filter: none !important;
  padding: 9px 12px !important;
  border-radius: 6px !important;
  border: none !important;
  border-top: none !important;
  text-align: left !important;
  font-family: var(--st-font) !important;
  font-size: 13px !important;
  cursor: pointer !important;
  transition: all 0.12s ease !important;
  width: 100% !important;
  min-width: 180px !important;
  height: auto !important;
  display: block !important;
  white-space: nowrap !important;
}
html body .maplibregl-style-list button:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}
html body .maplibregl-style-list button.maplibregl-style-active,
html body .maplibregl-style-list button.active {
  background: linear-gradient(90deg, rgba(249,115,22,0.22), rgba(249,115,22,0.06)) !important;
  color: var(--st-primary) !important;
  font-weight: 600 !important;
}

/* Geocoder (search) — colapsado=icon 44x44, expandido=input wide */
html body .maplibregl-ctrl-geocoder {
  background: rgba(15, 20, 32, 0.92) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6) !important;
  position: relative !important;
  transition: width 0.2s ease !important;
}
/* Colapsado = button cuadrado */
html body .maplibregl-ctrl-geocoder.maplibregl-ctrl-geocoder--collapsed {
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  cursor: pointer;
}
/* Expandido = input ancho */
html body .maplibregl-ctrl-geocoder:not(.maplibregl-ctrl-geocoder--collapsed) {
  width: 280px !important;
  min-width: 280px !important;
  height: 44px !important;
}
/* Input dentro */
html body .maplibregl-ctrl-geocoder--input {
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
  color: var(--st-text) !important;
  border: none !important;
  outline: none !important;
  font-family: var(--st-font) !important;
  font-size: 13px !important;
  padding: 0 36px 0 38px !important;
  box-sizing: border-box !important;
}
html body .maplibregl-ctrl-geocoder--input::placeholder {
  color: var(--st-text-muted) !important;
}
/* Si está colapsado, ocultar el input */
html body .maplibregl-ctrl-geocoder--collapsed .maplibregl-ctrl-geocoder--input {
  display: none !important;
}
/* SVG icons del geocoder: color blanco con fill currentColor */
html body .maplibregl-ctrl-geocoder svg {
  fill: var(--st-text) !important;
  color: var(--st-text) !important;
}
html body .maplibregl-ctrl-geocoder--icon {
  width: 20px !important;
  height: 20px !important;
}
/* Icon search posicionado a la izquierda del input (cuando expandido)
 * o centrado (cuando colapsado) */
html body .maplibregl-ctrl-geocoder--icon-search {
  position: absolute !important;
  top: 50% !important;
  left: 12px !important;
  transform: translateY(-50%) !important;
  pointer-events: none !important;
}
html body .maplibregl-ctrl-geocoder--collapsed .maplibregl-ctrl-geocoder--icon-search {
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
}
/* Icon close (limpiar búsqueda) */
html body .maplibregl-ctrl-geocoder--button {
  position: absolute !important;
  top: 50% !important;
  right: 8px !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: none !important;
  padding: 4px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
}
html body .maplibregl-ctrl-geocoder--button:hover {
  background: rgba(249, 115, 22, 0.15) !important;
}
html body .maplibregl-ctrl-geocoder--icon-close {
  fill: var(--st-text-dim) !important;
  width: 16px !important;
  height: 16px !important;
}
/* Loading spinner */
html body .maplibregl-ctrl-geocoder--icon-loading {
  fill: var(--st-primary) !important;
}
/* Lista de resultados */
html body .maplibregl-ctrl-geocoder .suggestions {
  background: rgba(15, 20, 32, 0.96) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 10px !important;
  margin-top: 4px !important;
  overflow: hidden !important;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7) !important;
}
html body .maplibregl-ctrl-geocoder .suggestions > li > a {
  color: var(--st-text) !important;
  background: transparent !important;
  padding: 10px 12px !important;
  font-size: 13px !important;
}
html body .maplibregl-ctrl-geocoder .suggestions > li > a:hover,
html body .maplibregl-ctrl-geocoder .suggestions > .active > a {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}

/* Posición del grupo top-right alineado con el topbar.
 * align-items: flex-end evita que los ctrl-groups se estiren cuando la lupa
 * se expande de 44px a 320px (stretch por default en flex-column). */
html body .maplibregl-ctrl-top-right,
html body .mapboxgl-ctrl-top-right {
  top: 80px !important;
  right: 16px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  gap: 8px !important;
}

/* ─── Geofence draw controls (mapbox-gl-draw / terra-draw)
 *     usados en /geofences para dibujar polígono/línea/borrar.
 *     Los iconos son SVG inline con fill negro → invisibles sobre fondo oscuro.
 *     Especificidad alta para ganar sobre el CSS del bundle de mapbox-gl-draw. */
html body .maplibregl-ctrl-group:has(button[class*="mapbox-gl-draw"]),
html body .mapboxgl-ctrl-group:has(button[class*="mapbox-gl-draw"]) {
  background: rgba(15, 20, 32, 0.92) !important;
  border: 1px solid rgba(148, 163, 184, 0.18) !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.5) !important;
}
html body .maplibregl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn,
html body .mapboxgl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn {
  background-color: transparent !important;
  border: none !important;
  /* invert(1) convierte el SVG negro en blanco; brightness suaviza el contraste */
  filter: invert(1) brightness(0.92) !important;
  transition: background-color 0.15s ease !important;
}
html body .maplibregl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn:hover,
html body .mapboxgl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn:hover {
  background-color: rgba(249, 115, 22, 0.18) !important;
}
/* Estado activo (herramienta seleccionada) */
html body .maplibregl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn.active,
html body .maplibregl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn[aria-pressed="true"],
html body .mapboxgl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn.active,
html body .mapboxgl-ctrl-group button.mapbox-gl-draw_ctrl-draw-btn[aria-pressed="true"] {
  background-color: rgba(249, 115, 22, 0.28) !important;
  box-shadow: inset 0 0 0 1px rgba(249, 115, 22, 0.5) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * SystrackSearch — geocoder custom (Nominatim local)
 * Reemplaza el plugin MapLibre geocoder roto de Traccar 6.12
 * Se monta dentro del contenedor existente .maplibregl-ctrl-geocoder
 * ═══════════════════════════════════════════════════════════════════ */
html body .maplibregl-ctrl-geocoder.st-search {
  display: flex !important;
  align-items: center !important;
  gap: 0 !important;
  padding: 0 !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  background: rgba(15, 20, 32, 0.92) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6) !important;
  overflow: visible !important;
  transition: width 0.2s ease, min-width 0.2s ease !important;
  position: relative !important;
}
html body .maplibregl-ctrl-geocoder.st-search.st-search-open {
  width: 320px !important;
  min-width: 320px !important;
}

html body .maplibregl-ctrl-geocoder.st-search .st-search-btn {
  width: 44px !important;
  height: 44px !important;
  flex: 0 0 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: none !important;
  color: var(--st-text) !important;
  cursor: pointer !important;
  padding: 0 !important;
  border-radius: 12px !important;
  transition: background 0.15s ease !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-btn:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}

html body .maplibregl-ctrl-geocoder.st-search .st-search-input {
  flex: 1 1 auto !important;
  height: 44px !important;
  background: transparent !important;
  color: var(--st-text) !important;
  border: none !important;
  outline: none !important;
  font: 500 13px/1 var(--st-font) !important;
  padding: 0 8px 0 0 !important;
  display: none !important;
  min-width: 0 !important;
}
html body .maplibregl-ctrl-geocoder.st-search.st-search-open .st-search-input {
  display: block !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-input::placeholder {
  color: var(--st-text-muted) !important;
}

html body .maplibregl-ctrl-geocoder.st-search .st-search-clear {
  display: none !important;
  width: 32px !important;
  height: 32px !important;
  flex: 0 0 32px !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: none !important;
  color: var(--st-text-dim) !important;
  cursor: pointer !important;
  border-radius: 8px !important;
  margin-right: 4px !important;
  padding: 0 !important;
}
html body .maplibregl-ctrl-geocoder.st-search.st-search-open .st-search-clear {
  display: flex !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-clear:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}

html body .maplibregl-ctrl-geocoder.st-search .st-search-list {
  display: none;
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 !important;
  padding: 6px !important;
  list-style: none !important;
  background: rgba(15, 20, 32, 0.98) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.7) !important;
  max-height: 360px !important;
  overflow-y: auto !important;
  z-index: 1000 !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-list.st-search-list-open {
  display: block !important;
}

html body .maplibregl-ctrl-geocoder.st-search .st-search-item {
  display: flex !important;
  align-items: flex-start !important;
  gap: 10px !important;
  padding: 10px 12px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  color: var(--st-text) !important;
  font-size: 12.5px !important;
  line-height: 1.35 !important;
  transition: background 0.12s ease !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-item:hover {
  background: rgba(249, 115, 22, 0.12) !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-item.st-search-empty {
  color: var(--st-text-muted) !important;
  font-style: italic !important;
  cursor: default !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-item.st-search-empty:hover {
  background: transparent !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-pin {
  flex: 0 0 14px !important;
  margin-top: 3px !important;
  color: var(--st-primary) !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-text {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-main {
  font-weight: 600 !important;
  color: var(--st-text) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
html body .maplibregl-ctrl-geocoder.st-search .st-search-rest {
  font-size: 11.5px !important;
  color: var(--st-text-muted) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  margin-top: 2px !important;
}

/* ─── Toast del resultado de búsqueda (fallback cuando no hay flyTo) ─── */
html body .st-search-toast {
  position: fixed !important;
  top: 80px !important;
  right: 80px !important;
  z-index: 9999 !important;
  width: 340px !important;
  background: rgba(15, 20, 32, 0.98) !important;
  backdrop-filter: blur(16px) saturate(1.4) !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.4) !important;
  border: 1px solid var(--st-border-strong) !important;
  border-radius: 14px !important;
  padding: 14px !important;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7) !important;
  color: var(--st-text) !important;
  font-family: var(--st-font) !important;
  opacity: 0 !important;
  transform: translateY(-8px) !important;
  transition: opacity 0.22s ease, transform 0.22s ease !important;
}
html body .st-search-toast.st-search-toast-show {
  opacity: 1 !important;
  transform: translateY(0) !important;
}
html body .st-search-toast .st-search-toast-head {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  color: var(--st-primary) !important;
  font-size: 14px !important;
  margin-bottom: 6px !important;
}
html body .st-search-toast .st-search-toast-head strong {
  flex: 1 1 auto !important;
  color: var(--st-text) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
html body .st-search-toast .st-search-toast-close {
  background: transparent !important;
  border: none !important;
  color: var(--st-text-dim) !important;
  cursor: pointer !important;
  padding: 4px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 auto !important;
}
html body .st-search-toast .st-search-toast-close:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}
html body .st-search-toast .st-search-toast-rest {
  font-size: 12px !important;
  color: var(--st-text-muted) !important;
  margin-bottom: 8px !important;
  line-height: 1.4 !important;
}
html body .st-search-toast .st-search-toast-coords {
  font: 600 11.5px/1 var(--st-font-mono, 'JetBrains Mono', monospace) !important;
  color: var(--st-text-dim) !important;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: 6px !important;
  padding: 6px 8px !important;
  margin-bottom: 10px !important;
}
html body .st-search-toast .st-search-toast-actions {
  display: flex !important;
  gap: 6px !important;
}
html body .st-search-toast .st-search-toast-btn {
  flex: 1 1 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 8px 10px !important;
  border-radius: 8px !important;
  font: 600 12px/1 var(--st-font) !important;
  cursor: pointer !important;
  text-decoration: none !important;
  transition: background 0.15s ease, color 0.15s ease !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(148, 163, 184, 0.14) !important;
  color: var(--st-text) !important;
}
html body .st-search-toast .st-search-toast-btn:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}
html body .st-search-toast .st-search-toast-primary {
  background: linear-gradient(135deg, rgba(249,115,22,0.22), rgba(249,115,22,0.10)) !important;
  border-color: rgba(249,115,22,0.4) !important;
  color: var(--st-primary) !important;
}

/* ─── Botón 3D en top-right ─── */
html body .maplibregl-ctrl-group.st-3d-ctrl {
  background: rgba(15,20,32,0.88) !important;
  backdrop-filter: blur(14px) saturate(1.4) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.4) !important;
  border: 1px solid rgba(148,163,184,0.14) !important;
  border-radius: 10px !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -6px rgba(0,0,0,0.5) !important;
  overflow: hidden !important;
  margin: 0 !important;
}
html body .maplibregl-ctrl-group.st-3d-ctrl button.st-3d-inner {
  width: 38px !important;
  height: 38px !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #cbd5e1 !important;
  transition: background 0.15s ease, color 0.15s ease !important;
}
html body .maplibregl-ctrl-group.st-3d-ctrl button.st-3d-inner:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: var(--st-primary) !important;
}
html body .maplibregl-ctrl-group.st-3d-ctrl button.st-3d-inner .st-3d-label {
  font: 800 11px/1 var(--st-font) !important;
  letter-spacing: 0.5px !important;
}
html body .maplibregl-ctrl-group.st-3d-ctrl.st-3d-active,
html body .maplibregl-ctrl-group.st-3d-ctrl button.st-3d-active {
  background: linear-gradient(135deg, rgba(249,115,22,0.28), rgba(249,115,22,0.12)) !important;
  border-color: rgba(249,115,22,0.4) !important;
  color: var(--st-primary) !important;
}

/* ─── Toast de sesión expirada ─── */
html body .st-session-toast {
  position: fixed !important;
  top: 24px !important;
  left: 50% !important;
  transform: translateX(-50%) translateY(-20px) !important;
  z-index: 99999 !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  background: rgba(15, 20, 32, 0.98) !important;
  border: 1px solid rgba(251, 191, 36, 0.4) !important;
  border-radius: 14px !important;
  padding: 14px 18px !important;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7) !important;
  color: var(--st-text) !important;
  font-family: var(--st-font) !important;
  font-size: 13px !important;
  opacity: 0 !important;
  transition: opacity 0.25s ease, transform 0.25s ease !important;
  min-width: 300px !important;
}
html body .st-session-toast.st-session-toast-show {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(0) !important;
}
html body .st-session-toast svg {
  color: #fbbf24 !important;
  flex: 0 0 auto !important;
}
html body .st-session-toast strong {
  color: var(--st-text) !important;
  font-weight: 600 !important;
  display: block !important;
}
html body .st-session-toast .st-session-toast-sub {
  color: var(--st-text-muted) !important;
  font-size: 11.5px !important;
  margin-top: 2px !important;
}

/* Ocultar notificación duplicada (custom Traccar) */
html body .maplibre-ctrl-notification,
html body .maplibre-ctrl-notification-on,
html body .maplibre-ctrl-notification-off {
  display: none !important;
}

html body .maplibregl-ctrl-attrib,
html body .mapboxgl-ctrl-attrib {
  background: rgba(15, 20, 32, 0.9) !important;
  color: var(--st-text-muted) !important;
  font-size: 10px !important;
  border-radius: 4px 0 0 0 !important;
}

/* Tile dark — invertir colores sutilmente para armonizar con UI dark */
html body .maplibregl-map,
html body .mapboxgl-map,
html body .leaflet-container {
  background: #0a0e1a !important;
}
html body .maplibregl-map .mapboxgl-canvas-container canvas,
html body .mapboxgl-map .mapboxgl-canvas-container canvas {
  /* Si el tile es claro, aplicamos un filter hue-rotate + invert leve
     para que se vea más estilo "satellite night". Desactivar esto si
     el tile ya es dark. */
  /* filter: invert(1) hue-rotate(180deg) brightness(0.95) saturate(0.85); */
}

/* ═══════════════════════════════════════════════════════════════════
 * Typography
 * ═══════════════════════════════════════════════════════════════════ */
html body h1, html body h2, html body h3, html body h4,
html body .MuiTypography-h1, html body .MuiTypography-h2, html body .MuiTypography-h3,
html body .MuiTypography-h4, html body .MuiTypography-h5, html body .MuiTypography-h6 {
  font-family: var(--st-font-display) !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  color: var(--st-text) !important;
}

html body .MuiTypography-root { color: inherit; }
html body code, html body kbd, html body samp, html body pre,
html body .mono, html body [class*="mono"], html body .MuiTypography-caption {
  font-family: var(--st-font-mono) !important;
  font-feature-settings: 'tnum' 1;
}

/* ═══════════════════════════════════════════════════════════════════
 * Badges (lucide badges de notificaciones, e.g. "8" en tickets)
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiBadge-badge {
  background: linear-gradient(180deg, var(--st-primary), #ea580c) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px var(--st-surface), 0 4px 8px -2px rgba(249, 115, 22, 0.5);
  font-weight: 700 !important;
  font-family: var(--st-font-mono) !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Animaciones
 * ═══════════════════════════════════════════════════════════════════ */
@keyframes st-pulse-ring {
  0%, 100% { box-shadow: inset 3px 0 0 var(--st-primary), 0 0 0 0 rgba(249, 115, 22, 0); }
  50% { box-shadow: inset 3px 0 0 var(--st-primary), 0 0 0 4px rgba(249, 115, 22, 0.15); }
}

@keyframes st-fade-slide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

html body .MuiDialog-paper { animation: st-fade-slide 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
html body .MuiListItemButton-root.Mui-selected { animation: st-pulse-ring 2.5s ease-in-out infinite; }

/* ═══════════════════════════════════════════════════════════════════
 * Utilidades
 * ═══════════════════════════════════════════════════════════════════ */
html body .st-glass {
  background: var(--st-surface-glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--st-border-strong);
  box-shadow: var(--st-shadow-card);
}


/* ═══════════════════════════════════════════════════════════════════
 * StatusCard popup — corregir contraste de texto en la tarjeta de
 * información del vehículo (click sobre un device). Traccar usa un
 * MuiTable dentro de un MuiCard con colores heredados del tema claro.
 * ═══════════════════════════════════════════════════════════════════ */
html body .MuiTableCell-root,
html body .MuiTable-root,
html body .MuiTableBody-root,
html body .MuiTableRow-root,
html body .MuiTableHead-root {
  color: var(--st-text) !important;
  border-color: var(--st-border) !important;
  background: transparent !important;
}

html body .MuiTableCell-root {
  font-family: 'Inter', -apple-system, sans-serif !important;
  font-size: 13px !important;
  padding: 6px 10px !important;
}

/* Labels (primera columna, usan variante body2 / caption) */
html body .MuiTableCell-body:first-child,
html body .MuiTableCell-head {
  color: var(--st-text-muted, #94a3b8) !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

/* Valores (segunda columna) */
html body .MuiTableCell-body + .MuiTableCell-body {
  color: var(--st-text) !important;
  font-weight: 600 !important;
  text-align: right !important;
}

/* Botones de acción dentro del StatusCard (share/edit/replay/delete) */
html body .MuiCardActions-root .MuiIconButton-root {
  color: var(--st-text-muted, #94a3b8) !important;
  transition: color 0.15s, background 0.15s !important;
}
html body .MuiCardActions-root .MuiIconButton-root:hover {
  color: var(--st-accent, #f97316) !important;
  background: rgba(249, 115, 22, 0.1) !important;
}

/* Botón "Más detalles" (link) */
html body .MuiCardActions-root .MuiButton-root,
html body .MuiCardContent-root .MuiLink-root {
  color: var(--st-accent, #f97316) !important;
  font-weight: 500 !important;
  font-size: 12.5px !important;
}

/* Botón de cerrar (X) */
html body .MuiCardHeader-action .MuiIconButton-root svg {
  color: var(--st-text-muted, #94a3b8) !important;
}

/* Título del popup — "Systrack Teltonika #1" */
html body .MuiCardHeader-title {
  color: var(--st-text) !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  letter-spacing: 0.01em !important;
}
