body {
    font-family: Arial, sans-serif;
    margin: 0;
    /* Theme-aware: usa --bg-app (gradiente blanco en claro, navy en oscuro).
       En tema claro `legacy-darktheme.css` está disabled, así que esta regla
       gana. Antes era #4d6883 (azul fijo) que se veía mal en light. */
    background: var(--bg-app);
    /* `overflow-wrap` se hereda → el texto largo envuelve en vez de salirse del
       contenedor al hacer zoom o en anchos estrechos (index.html no carga reset.css). */
    overflow-wrap: break-word;
}

/* ─── TOPBAR ──────────────────────────────────────────── */
/* Grid de 3 columnas: brand a la izquierda, contexto (unidad) al centro,
   acciones a la derecha. El centro usa `justify-self: center` para quedar
   horizontalmente centrado independientemente del ancho de los laterales. */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: #f2f2f2;
    color: rgb(83, 206, 27);
    padding: 10px 20px;
    height: 48px;
    box-sizing: border-box;
    gap: 15px;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-self: start;
    min-width: 0;
}
.topbar-center {
    justify-self: center;
    text-align: center;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-self: end;
}

.topbar h1 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}
/* Brand clickable: visualmente idéntico al h1 normal (hereda color, sin
   subrayado, hover sutil). target=_blank abre el portal PLSAT en otra
   pestaña. */
.topbar h1 a {
    color: inherit;
    text-decoration: none;
    transition: opacity 0.15s;
}
.topbar h1 a:hover,
.topbar h1 a:focus {
    opacity: 0.85;
}

.topbar select {
    background: #1f2937;
    color: rgb(71, 228, 56);
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
}

/* ─── LAYOUT ─────────────────────────────────────────── */
:root {
    --sidebar-width: 220px;
    --right-panel-width: 280px;
}

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--right-panel-width);
    height: calc(100vh - 60px);
    overflow: hidden;
    transition: grid-template-columns 0.3s ease;
}

.layout.hide-sidebar {
    --sidebar-width: 0px;
}

.layout.hide-right {
    --right-panel-width: 0px;
}

.sidebar, .right-panel {
    overflow-x: hidden;
    transition: padding 0.3s ease, border 0.3s ease;
}

.layout.hide-sidebar .sidebar, 
.layout.hide-right .right-panel {
    padding: 0;
    border: none;
}

.btn-toggle {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    color: #4b5563;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle:hover {
    background: #e5e7eb;
    color: #111827;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
    /* display:block explícito: ahora .sidebar es <plsat-sidebar> (custom element,
       default inline). Como item del grid .layout se blockificaría igual, pero
       index.html no carga layout.css (que estiliza plsat-sidebar en las demás
       páginas), así que lo fijamos aquí para que no dependa de la blockificación. */
    display: block;
    background: #1f2937;
    color: white;
    padding: 12px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sidebar h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin: 0;
}

.btn-add-unit {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-add-unit:hover {
    background: #2563eb;
}

#vehicleList {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    padding: 9px 12px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 2px;
    color: #d1d5db;
}

.menu-item:hover {
    background: #374151;
    color: white;
}

.menu-item.active {
    background: #2563eb;
    color: white;
}

/* Buscador de unidades (nombre/placa/IMEI). Tokens → sigue el tema claro/oscuro. */
.unit-search {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 12px;
    outline: none;
}
.unit-search::placeholder { color: var(--text-dim); }
.unit-search:focus { border-color: var(--accent-primary); }

/* Lista de unidades acotada a ~10 filas; el resto con scroll, para no empujar
   la sección "Servicios" hasta abajo. */
.unit-scroll-legacy {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 360px;
    overflow-y: auto;
}

/* Icono de cámara clickable (abre el popup de video en vivo). Se colorea por estado:
   verde=en línea, gris=offline, rojo (pulsante)=con alerta. SVG usa currentColor. */
.cam-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 2px 3px;
    border-radius: 4px;
    vertical-align: middle;
    color: var(--text-dim);
}
.cam-btn svg { display: block; }
.cam-btn:hover { background: rgba(139, 92, 246, 0.22); }
.cam-btn.cam-on    { color: #22c55e; }
.cam-btn.cam-off   { color: #9ca3af; }
.cam-btn.cam-alert { color: #ef4444; animation: cam-pulse 1.2s ease-in-out infinite; }
.cam-icon-static { display: inline-flex; align-items: center; color: var(--text-dim); vertical-align: middle; }
.cam-icon-static svg { display: block; }
@keyframes cam-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }

/* ─── Sidebar legacy en TEMA CLARO ───────────────────────
   styles.css pinta el sidebar oscuro fijo (#1f2937) — era el diseño original
   (sidebar oscuro + contenido claro). En modo claro (data-theme="light", con
   legacy-darktheme.css desactivado) lo aclaramos con tokens para que siga el tema,
   igual que el sidebar del design-system. En oscuro manda legacy-darktheme.css. */
html[data-theme="light"] .sidebar {
    background: var(--bg-card-solid);
    color: var(--text-main);
    border-right: 1px solid var(--glass-border);
}
html[data-theme="light"] .sidebar h3 { color: var(--text-dim); }
html[data-theme="light"] .menu-item { color: var(--text-muted); }
html[data-theme="light"] .menu-item:hover { background: var(--bg-card-hover); color: var(--text-main); }
html[data-theme="light"] .menu-item.active { background: var(--accent-primary); color: var(--plsat-brand-blue); font-weight: 600; }

/* ─── MAIN CONTENT ───────────────────────────────────── */
.main-content {
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─── ROW 1: Mapa + Gráfica (mitad / mitad) ─────────── */
.row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.map-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Unit info bar */
.unit-info-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.unit-badge {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 5px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 56px;
}

.unit-badge-label {
    font-size: 9px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.unit-badge-value {
    font-size: 12px;
    font-weight: 700;
    color: #111827;
    margin-top: 1px;
}

div[id^="map"] {
    border-radius: 10px;
    height: 204px;   /* -15% (antes 240px) */
    background: #cbd5e1;
}

/* Chart column */
.chart-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-filter-panel {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 6px;
    align-items: stretch;
}

.date-input {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.date-field {
    border: none;
    outline: none;
    font-size: 11px;
    font-family: inherit;
    color: #111827;
    background: transparent;
    width: 100%;
}

.date-field::-webkit-calendar-picker-indicator {
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.btn-filter {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.btn-filter:hover {
    background: #2563eb;
}

.kpi-label {
    font-size: 9px;
    color: #9ca3af;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── GENERIC PANEL ──────────────────────────────────── */
.panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.panel-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #374151;
    padding: 9px 12px;
    border-bottom: 1px solid #f3f4f6;
    background: #f9fafb;
    text-align: center;
}

.panel-body {
    padding: 12px;
    min-height: 80px;
    color: #9ca3af;
    font-size: 12px;
}

.panel-list {
    list-style: none;
    padding: 10px 12px;
    margin: 0;
    min-height: 60px;
    color: #9ca3af;
    font-size: 12px;
}

#alertsList {
    max-height: 450px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#alertsList::-webkit-scrollbar {
    width: 6px;
}

#alertsList::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* ─── KPI GRID (4 tarjetas con gauge) ───────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    flex: 1;
}

.kpi-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 6px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
    overflow: hidden;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.kpi-card h4 {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin: 0 0 2px;
    white-space: nowrap;
}

.kpi-card canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 70px;
}

.kpi-card p {
    font-size: 13px;
    font-weight: 800;
    color: #111827;
    margin: 0;
    line-height: 1.2;
}

/* ─── UNIT INFO TABLE (4 columnas) ──────────────────── */
.unit-table-panel {
    margin-top: 8px;
}

.unit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.unit-table tr {
    border-bottom: 1px solid #f3f4f6;
}

.unit-table tr:last-child {
    border-bottom: none;
}

.unit-table td {
    padding: 4px 8px;
}

.ut-label {
    color: #9ca3af;
    font-weight: 600;
    white-space: nowrap;
    width: 22%;
    border-right: 1px solid #f3f4f6;
}

.ut-value {
    font-weight: 700;
    color: #111827;
    width: 28%;
    padding-right: 12px;
}

/* ─── ROW 2: Motor + Energía + Viajes (1fr 0.5fr 0.5fr aprox) ────── */
/* Filas de paneles en FLEX (no grid): así, al ocultar un panel, el espacio se
   reparte HORIZONTALMENTE entre los que quedan (flex-grow proporcional, basis 0) en
   vez de dejar un hueco. Si se ocultan todos, la fila colapsa a 0 (sin hueco vertical).
   min-width:0 evita que tablas/canvas fuercen overflow al encogerse. */
.row-two {
    display: flex;
    gap: 12px;
}
/* Base: TODO panel de la fila crece (flex-grow≥1, basis 0). Así, si queda uno
   solo, llena el ancho completo (no deja un cuadro vacío al lado). Los overrides
   solo ajustan la proporción cuando hay varios visibles. */
.row-two > .panel { flex: 1 1 0; min-width: 0; }
.row-two > [data-panel="motor"] { flex-grow: 1.2; }
.row-two > [data-panel="energia"],
.row-two > [data-panel="trip"]  { flex-grow: 0.9; }

/* El panel de Viajes es ahora un mini-dashboard con controles internos (pastillas,
   traza, filas clickables): ya no se "levanta" como un único botón. El hover vive
   en cada sub-elemento (.trip-recent-item, .trip-route, .panel-header-cta). */

/* ─── ROW 3: Combustible + RPM + 3 sensores (misma fila, misma altura) ─────
   Todos crecen por igual (flex 1 1 0); Combustible un poco más ancho. Como a lo
   mucho hay ~2 visibles, se reparten el ancho y se ven completos. */
.row-three {
    display: flex;
    gap: 12px;
}
.row-three > .panel { flex: 1 1 0; min-width: 0; }
.row-three > [data-panel="combustible"] { flex-grow: 1.3; }

/* Todos los paneles de la fila 3 a la MISMA altura (gráficas, viajes y sensores). */
.fuel-panel .panel-body,
.rpm-panel .panel-body,
.trip-dash-body,
.sensor-placeholder {
    height: 300px;
}
.sensor-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
}

/* ─── RIGHT PANEL ────────────────────────────────────── */
.right-panel {
    background: #f9fafb;
    border-left: 1px solid #e5e7eb;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─── ALERTAS DE FLOTA (vista general): en vivo + históricas ─────────────────── */
#rightPanelGeneral { display: flex; flex-direction: column; gap: 12px; }
.alert-hdr-btn {
    background: #fff; border: none; border-radius: 4px; padding: 2px 9px;
    font-size: 10px; cursor: pointer; color: #ef4444; font-weight: bold;
}
.alert-hdr-btn-dark { color: #374151; }
.fleet-alert-live-body { padding: 8px; background: #f9fafb; }
.fleet-alert-hist-body {
    padding: 8px; background: #f9fafb;
    max-height: 55vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 6px;
}
.fleet-alert-empty { padding: 18px; text-align: center; color: #9ca3af; font-size: 11px; }
.fleet-alert-card {
    background: #fff; border: 1px solid #e5e7eb; border-left: 5px solid #f59e0b;
    border-radius: 8px; padding: 8px 10px; cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,.05); transition: background .15s;
}
.fleet-alert-card:hover { background: #f9fafb; }
.fleet-alert-card.is-live { border-left-width: 6px; box-shadow: 0 2px 12px rgba(239,68,68,.18); }
.fa-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.fa-unit {
    font-weight: 700; font-size: 12px; color: #111827; flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fa-plate {
    font-size: 10px; font-weight: 700; background: #eef2ff; color: #3730a3;
    border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.fa-time { font-size: 10px; color: #9ca3af; font-weight: 600; white-space: nowrap; }
.fa-msg { font-size: 12px; font-weight: 600; line-height: 1.3; }

/* ─── STATUS BADGE COLORS ──────────────────────────── */
.unit-badge.status-on {
    background-color: #ecfdf5;
    border-color: #10b981;
}
.unit-badge.status-on .unit-badge-value { color: #059669; }

.unit-badge.status-off {
    background-color: #fef2f2;
    border-color: #ef4444;
}
.unit-badge.status-off .unit-badge-value { color: #dc2626; }

.unit-badge.status-warn {
    background-color: #fffbeb;
    border-color: #f59e0b;
}
.unit-badge.status-warn .unit-badge-value { color: #d97706; }

.unit-badge.status-info {
    background-color: #eff6ff;
    border-color: #3b82f6;
}
.unit-badge.status-info .unit-badge-value { color: #2563eb; }

.unit-badge.status-event {
    background-color: #f5f3ff;
    border-color: #8b5cf6;
}
.unit-badge.status-event .unit-badge-value { color: #7c3aed; }

/* ─── VISTA GENERAL (FLOTA) ────────────────────────── */
.general-layout {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 15px;
    min-height: 100%;      /* puede crecer más que el viewport → la página hace scroll */
    align-items: start;    /* las columnas no se estiran entre sí */
    padding: 5px;
}

.left-column {
    display: grid;
    grid-template-rows: auto auto auto;   /* el mapa (3ª fila) toma su altura del aspect-ratio, no estira */
    gap: 15px;
}

.right-column {
    display: grid;
    grid-template-rows: auto auto auto;   /* cada panel se dimensiona a su contenido (encabezado + tabla de 5 filas) */
    align-content: start;
    gap: 15px;
}

.fleet-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.summary-grid {
    display: contents;
}

/* Mapa de flota: la altura sigue al ancho (no se toca el ancho). El ancho lo da la
   columna; aspect-ratio 5/4 deja la altura al 80% del ancho (20% menos que cuadrado). */
.fleet-map {
    aspect-ratio: 5 / 4;
    height: auto;
    min-height: 0;
}

#mapFleet {
    height: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Paneles de flota: encabezado fijo arriba + área de tabla con scroll propio. */
.fleet-table-container {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Encabezado con título + filtro (Estado Detallado) en una sola línea. */
.fleet-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
}

/* Títulos de tabla que NAVEGAN (Estado Detallado, Rendimiento, Resumen de Viajes).
   Antes parecían texto plano y el usuario no sabía que eran clickables: ahora se
   ven como un botón (borde + fondo tenue + chevron) y resaltan al pasar el mouse.
   Quedan alineados a la izquierda (los contiene un .fleet-panel-head text-align:left). */
.panel-title-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border, #d1d5db);
    background: color-mix(in srgb, var(--plsat-green, #9BCB3C) 12%, transparent);
    color: inherit;
    cursor: pointer;
    transition: background-color .18s, border-color .18s, transform .18s, box-shadow .18s;
}
.panel-title-link::after {
    content: "›";
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    opacity: .6;
    margin-left: 1px;
}
.panel-title-link:hover {
    background: color-mix(in srgb, var(--plsat-green, #9BCB3C) 28%, transparent);
    border-color: var(--plsat-green, #9BCB3C);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.panel-title-link:hover::after { opacity: .9; }
.fleet-filter {
    flex: 0 1 140px;
    min-width: 0;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #111827;
}

/* Área scrolleable de cada tabla de flota: muestra ~5 filas; el resto con barra. */
.fleet-table-scroll {
    overflow-y: auto;
    max-height: 264px;
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 #e5e7eb;
}
.fleet-table-scroll::-webkit-scrollbar {
    width: 6px;
}
.fleet-table-scroll::-webkit-scrollbar-track {
    background: #e5e7eb;
}
.fleet-table-scroll::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 10px;
}

.fleet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.fleet-table th, .fleet-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

.fleet-table th {
    background: #f9fafb;
    position: sticky;
    top: 0;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
}

/* Hover de fila: MISMO verde claro que las tarjetas del resumen (marca PLSAT
   mezclada con blanco) + transición suave. Solo tbody → el header sticky no vira. */
.fleet-table tbody tr {
    transition: background-color 0.15s;
}
.fleet-table tbody tr:hover {
    background: color-mix(in srgb, var(--plsat-green, #9BCB3C) 16%, #fff);
}

/* Time color codes */
.time-green { color: #10b981; font-weight: bold; }
.time-blue { color: #3b82f6; font-weight: bold; }
.time-yellow { color: #f59e0b; font-weight: bold; }
.time-red { color: #ef4444; font-weight: bold; }

.health-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: white;
}
.health-excellent { background: #064e3b; }
.health-good { background: #059669; }
.health-fair { background: #d97706; }
.health-poor { background: #ea580c; }
.health-critical { background: #991b1b; }

/* ─── PREMIUM DASHBOARD SUMMARY ────────────────────── */
.fleet-header {
    margin-bottom: 15px;
}

.fleet-header h3 {
    font-size: 14px;
    font-weight: 800;
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

/* ─── Marcadores PLSAT (mapa flota + unidad) ───────────────────────────────────
   Icono PLSAT (assets/icons/plsat) que cambia según el evento + tarjeta de info
   SIEMPRE visible (unidad + último evento + velocidad). divIcon transparente. */
.plsat-marker-wrap { background: transparent; border: none; }
.plsat-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}
.plsat-marker-img {
    width: 40px;
    height: 40px;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.plsat-marker.is-offline .plsat-marker-img {
    opacity: 0.45;
    filter: grayscale(0.85);
}
/* Tarjeta de info bajo el icono (blanca para legibilidad sobre el mapa, en ambos
   temas). Siempre visible — reemplaza al popup de click. */
.plsat-marker-card {
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(9, 77, 140, 0.25);
    border-radius: 5px;
    padding: 2px 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    max-width: 150px;
}
.plsat-marker-card .pm-plate {
    font-size: 11px;
    font-weight: 800;
    color: var(--plsat-brand-blue, #094d8c);
    max-width: 138px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.plsat-marker-card .pm-row {
    font-size: 9px;
    font-weight: 600;
    color: #475569;
    line-height: 1.3;
    max-width: 138px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* SOLO mapa de FLOTA: con vista amplia (zoom bajo) se ve solo la placa; al acercar
   (zoom ≥ umbral) el contenedor recibe .plsat-zoomed y aparecen los renglones de
   evento + velocidad. El mapa de unidad muestra la tarjeta completa siempre. */
.plsat-fleetmap:not(.plsat-zoomed) .plsat-marker-card .pm-row { display: none; }

/* Hover (junto con riseOnHover de Leaflet, que lo sube al frente): resalta el
   marcador activo para distinguirlo del que tenía encima/debajo. */
.plsat-marker-wrap:hover .plsat-marker-card {
    border-color: var(--plsat-green, #9BCB3C);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* Botones custom del mapa (centrar / ampliar) — bajo el zoom. Heredan el look de
   .leaflet-bar; solo centramos el SVG (currentColor) dentro del <a> de 26px. */
.plsat-map-btn a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: #333;
}
.plsat-map-btn a svg { width: 16px; height: 16px; }

/* ─── Ventana emergente del mapa de unidad (botón "ampliar") ──────────────────── */
.plsat-map-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center; justify-content: center;
    z-index: 9999;
    padding: 16px;
}
.plsat-map-modal-backdrop.is-open { display: flex; }
.plsat-map-modal {
    background: var(--bg-card-solid, #0f172a);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.12));
    border-radius: 10px;
    width: 92vw; max-width: 1200px;
    height: 86vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.55);
}
.plsat-map-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
    flex: 0 0 auto;
}
.plsat-map-modal-head h3 {
    margin: 0; font-size: 15px; font-weight: 700;
    color: var(--text-main, #e5e7eb);
}
.plsat-map-modal-map { flex: 1; min-height: 0; width: 100%; }

.fleet-summary-premium {
    display: grid;
    grid-template-columns: 1.5fr 2.5fr;
    gap: 15px;
    margin-bottom: 20px;
}

.summary-grid-left {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
}

.card-content-vertical {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    flex: 1;
    gap: 10px;
}

.fleet-status-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    margin-top: 5px;
}

.donut-container-medium {
    width: 75px;
    height: 75px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-center-text-medium {
    position: absolute;
    font-size: 11px;
    font-weight: 800;
    color: #3b82f6;
}

.donut-legend-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.legend-item-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1.15;
    color: #94a3b8;
    margin-bottom: 0;
    white-space: nowrap;
}

.legend-grid-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.summary-grid-small {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Fila 1: Alertas + Eco (absorbe el alto sobrante = 1fr). Filas 2-3: las 4
       barras de acceso, compactas (alto = su contenido). */
    grid-template-rows: 1fr auto auto;
    gap: 6px;
}

/* Accesos rápidos como barras HORIZONTALES (ícono + etiqueta a la izquierda).
   Mantienen el look/hover de .summary-card-small pero en una sola línea baja. */
.summary-card-small.access-bar {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    min-height: 0;
}
.access-bar .access-ico {
    font-size: 22px;
    line-height: 1;
    flex: 0 0 auto;
}
.access-bar .access-label {
    font-size: 11px;
    font-weight: 700;
    color: inherit;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    line-height: 1.2;
}

.summary-card-small {
    background: #111827;
    border-radius: 12px;
    padding: 6px 10px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    /* Todas las tarjetas del resumen son clickables (navegan a su detalle) → mano. */
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* Hover: se eleva y el fondo vira a un verde claro acorde al tema (la marca PLSAT
   #9BCB3C mezclada con el fondo del card). */
.summary-card-small:hover {
    transform: translateY(-2px);
    background: color-mix(in srgb, var(--plsat-green, #9BCB3C) 22%, #111827);
    box-shadow: 0 6px 16px rgba(155, 203, 60, 0.25);
}
html[data-theme="light"] .summary-card-small:hover {
    background: color-mix(in srgb, var(--plsat-green, #9BCB3C) 16%, #fff);
    border-color: color-mix(in srgb, var(--plsat-green, #9BCB3C) 55%, transparent);
    box-shadow: 0 6px 16px rgba(155, 203, 60, 0.18);
}

/* Resumen Global de Flota — tema claro: las tarjetas quedaban con fondo
   dark (#111827) aunque el tema fuera claro. En light theme cambiamos a
   fondo blanco con texto oscuro para que coincida con el resto. Incluye
   overrides para los textos internos que estaban pensados para dark
   (legend gray, etc.). */
html[data-theme="light"] .summary-card-small {
    background: var(--bg-card-solid);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}
html[data-theme="light"] .summary-card-small .card-title {
    color: var(--text-dim);
}
html[data-theme="light"] .summary-card-small .legend-item {
    color: var(--text-muted);
}
html[data-theme="light"] .summary-card-small .donut-center-text {
    color: var(--plsat-brand-blue);
}

.card-title {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-align: center;
}

.card-content-donut {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex: 1;
}

.fleet-status-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.donut-container {
    width: 140px;
    height: 140px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-center-text {
    position: absolute;
    font-size: 20px;
    font-weight: 800;
    color: #3b82f6;
    text-align: center;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #cbd5e1;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.card-content-alerts {
    display: flex;
    gap: 30px;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.alert-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.alert-count {
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}

.alert-count.red { color: #ef4444; }
.alert-count.yellow { color: #eab308; }

.alert-label {
    font-size: 9px;
    color: #94a3b8;
    margin-top: 4px;
    text-transform: uppercase;
}

/* Altura ORIGINAL (60px): no debe crecer ni usar flex-fill — eso disparaba un
   loop de resize en Chart.js que estiraba el gauge y empujaba el mapa. */
.card-content-gauge {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    height: 60px;
}

/* Card "Conducción Ecológica": número del score SUPERPUESTO al gauge (posición
   absoluta → NO agrega alto a la tarjeta). Mismo lugar que el donut central de
   eco_driving.html (gauge media-dona, número sobre la base del arco). */
.eco-gauge-wrap { position: relative; }
.eco-gauge-score {
    position: absolute;
    left: 50%;
    top: 58%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    color: var(--text-main, #f1f5f9);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
html[data-theme="light"] .eco-gauge-score { color: var(--text-main, #0f172a); }

.card-content-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 2px;
}

/* Ícono de tarjeta (⛽ combustible, 🏎️ velocidad) más grande para llenar el
   espacio en blanco que YA existía dentro del card, sin cambiar su tamaño: el
   alto de estas tarjetas lo fija la rejilla (columna de donuts), no su contenido. */
.card-icon-lg {
    font-size: 40px;
    line-height: 1;
}

/* Ícono SVG de tarjeta (velocímetro). Hereda el color del texto del card vía
   currentColor → visible en claro y oscuro. Mismo "peso visual" que .card-icon-lg
   sin agregar alto a la tarjeta. */
.card-svg-icon {
    width: 56px;
    height: 56px;
    display: block;
}

.value-main {
    font-size: 28px;
    font-weight: 800;
    color: #10b981;
}

.value-sub {
    font-size: 10px;
    color: #64748b;
    text-transform: uppercase;
}

.speed-value-main {
    font-size: 20px;
    font-weight: 800;
    color: white;
}
html[data-theme="light"] .speed-value-main { color: var(--text-main, #0f172a); }

$liveAlertStyles
$extraStyles
$sidebarStyles
$subMenuStyles
