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

/* ========================================================
   SISTEMA MULTI-TEMA ENTERPRISE (Samsara / Linear / Light)
   ======================================================== */

/* 1. TEMA POR DEFECTO: DARK ENTERPRISE (Estilo Samsara / Geotab) */
:root, [data-theme="enterprise"] {
    --bg-main: #0b0f19;
    --bg-card: #111827;
    --bg-card-hover: #1e293b;
    --border-color: rgba(255, 255, 255, 0.09);
    --border-highlight: rgba(59, 130, 246, 0.35);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --input-bg: #090d16;
    --table-header-bg: #0b0f19;
    --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --map-filter: none;
}

/* 2. TEMA MINIMALIST PRO (Estilo Linear / Silicon Valley) */
[data-theme="minimalist"] {
    --bg-main: #09090b;
    --bg-card: #141416;
    --bg-card-hover: #1f1f23;
    --border-color: rgba(255, 255, 255, 0.12);
    --border-highlight: rgba(255, 255, 255, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent-blue: #6366f1; /* Indigo */
    --accent-cyan: #38bdf8;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;
    --accent-red: #f43f5e;
    --accent-purple: #a855f7;
    --input-bg: #0c0c0e;
    --table-header-bg: #09090b;
    --card-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.7);
    --map-filter: none;
}

/* 3. TEMA PLOMO CLARO CORPORATIVO (Executive Slate Light) */
[data-theme="light"] {
    --bg-main: #cbd5e1;
    --bg-card: #e2e8f0;
    --bg-card-hover: #edf2f7;
    --border-color: #94a3b8;
    --border-highlight: rgba(29, 78, 216, 0.45);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent-blue: #1d4ed8;
    --accent-cyan: #0284c7;
    --accent-green: #047857;
    --accent-yellow: #b45309;
    --accent-red: #b91c1c;
    --accent-purple: #6d28d9;
    --input-bg: #f1f5f9;
    --table-header-bg: #cbd5e1;
    --card-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.12);
    --map-filter: none;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: -0.011em;
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 16px;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Iconos Vectoriales SVG Lucide */
i[data-lucide], svg.lucide {
    width: 1.15rem;
    height: 1.15rem;
    stroke-width: 2;
    display: inline-block;
    vertical-align: -2px;
}

/* Header */
.msv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 24px;
    margin-bottom: 16px;
}

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

.msv-badge {
    background: #0369a1;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.msv-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.msv-header .model-tag {
    color: var(--accent-cyan);
    font-size: 0.85rem;
    font-weight: 500;
}

.msv-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #34d399;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.25s ease;
}

.msv-status-pill.msv-status-standby {
    background: rgba(148, 163, 184, 0.12) !important;
    border-color: rgba(148, 163, 184, 0.28) !important;
    color: #cbd5e1 !important;
}

.msv-status-pill.msv-status-online {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.45) !important;
    color: #34d399 !important;
}

.msv-status-pill.msv-status-offline {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}

.status-dot {
    width: 9px;
    height: 9px;
    min-width: 9px;
    min-height: 9px;
    flex-shrink: 0;
    background-color: #94a3b8;
    border-radius: 50%;
    display: inline-block;
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.status-dot.pulse {
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.4); opacity: 1; box-shadow: 0 0 10px #10b981; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* KPI Cards */
.msv-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

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

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-card .kpi-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.kpi-card .kpi-sub {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    margin-top: 4px;
}

/* Main Dashboard Grid */
.msv-main-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

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

.card-panel h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#map {
    width: 100%;
    height: 380px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.telemetry-bar {
    display: flex;
    justify-content: space-around;
    background: rgba(11, 19, 41, 0.7);
    border-radius: 8px;
    padding: 10px;
    margin-top: 12px;
}

.telem-item {
    text-align: center;
}

.telem-item span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.telem-item strong {
    font-size: 1.1rem;
    color: #38bdf8;
}

/* Radar Chart Section */
.radar-container {
    position: relative;
    height: 320px;
    width: 100%;
}

.driver-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.driver-score-badge {
    font-size: 1.4rem;
    font-weight: 800;
    color: #38bdf8;
}

/* Bottom Tables Grid */
.msv-bottom-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

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

table.msv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

table.msv-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

table.msv-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.risk-pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.risk-Bajo { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.risk-Moderado { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.risk-Alto { background: rgba(249, 115, 22, 0.2); color: #fb923c; }
.risk-Critico { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* Timeline List */
.timeline-feed {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(30, 48, 96, 0.3);
    font-size: 0.8rem;
}

.timeline-time {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-size: 0.75rem;
    min-width: 55px;
}

.timeline-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* Responsividad para Celular */
@media (max-width: 900px) {
    body { padding: 8px; }
    .msv-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .msv-main-grid { grid-template-columns: 1fr; }
    .msv-bottom-grid { grid-template-columns: 1fr; }
    #map { height: 280px; }
}

/* ========================================================
   COMPONENTES ENTERPRISE: TOASTS, NAVEGACIÓN Y TABLAS
   ======================================================== */

.msv-nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.msv-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 48, 96, 0.5);
    border: 1px solid var(--border-color);
    color: #cbd5e1;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.msv-nav-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-blue);
    color: #ffffff;
}

.msv-nav-btn.active {
    background: rgba(2, 132, 199, 0.2);
    border-color: var(--accent-blue);
    color: #38bdf8;
}

/* Interacción de filas del Leaderboard */
.msv-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.msv-table tbody tr:hover {
    background-color: rgba(2, 132, 199, 0.12);
}

/* Contenedor Flotante de Toasts */
.msv-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.msv-toast {
    pointer-events: auto;
    min-width: 320px;
    max-width: 440px;
    background: rgba(19, 30, 61, 0.96);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: #f8fafc;
    font-size: 0.85rem;
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.msv-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.msv-toast.info { border-left: 4px solid var(--accent-blue); }
.msv-toast.success { border-left: 4px solid var(--accent-green); }
.msv-toast.warning { border-left: 4px solid var(--accent-yellow); }
.msv-toast.danger { border-left: 4px solid var(--accent-red); }

.msv-toast-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.msv-toast-content {
    flex: 1;
}

.msv-toast-title {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.msv-toast-msg {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.35;
}

.msv-toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.msv-toast-close:hover {
    color: #fff;
}

/* Filtro CSS Plomo Suave para Mapa (Gris Plomo / Slate Grafito en vez de negro saturado) */
#map.map-dark-filter .leaflet-tile-pane {
    filter: brightness(0.85) invert(0.86) contrast(1.15) hue-rotate(195deg) saturate(0.2);
}

#map.map-dark-filter {
    background: #252d3d;
}

/* ========================================================
   ESTILOS DE KPI CON ICONOS VECTORIALES
   ======================================================== */
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.kpi-header .kpi-label {
    margin-bottom: 0;
}

.kpi-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--accent-blue);
    opacity: 0.85;
}

/* ========================================================
   SELECTOR DE TEMAS EN CONFIGURACIÓN (ADMIN / PREFERENCIAS)
   ======================================================== */
.theme-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
    margin-bottom: 28px;
}

.theme-card-option {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.theme-card-option:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.3);
}

.theme-card-option.active {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue), 0 8px 24px -4px rgba(59, 130, 246, 0.25);
    background: var(--bg-card-hover);
}

.theme-preview-box {
    height: 70px;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-preview-enterprise {
    background: #0b0f19;
    border-color: rgba(59, 130, 246, 0.3);
}
.theme-preview-enterprise .mock-bar { background: #111827; }
.theme-preview-enterprise .mock-accent { background: #3b82f6; }

.theme-preview-minimalist {
    background: #09090b;
    border-color: rgba(255, 255, 255, 0.2);
}
.theme-preview-minimalist .mock-bar { background: #141416; }
.theme-preview-minimalist .mock-accent { background: #6366f1; }

.theme-preview-light {
    background: #cbd5e1;
    border-color: #94a3b8;
}
.theme-preview-light .mock-bar { background: #e2e8f0; }
.theme-preview-light .mock-accent { background: #1d4ed8; }

.mock-bar {
    height: 14px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
}

.mock-pill {
    width: 24px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.theme-preview-light .mock-pill {
    background: #e2e8f0;
}

.mock-accent {
    width: 14px;
    height: 6px;
    border-radius: 3px;
}

.theme-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-badge-status {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    display: none;
}

.theme-card-option.active .theme-badge-status {
    display: inline-block;
    background: var(--accent-blue);
    color: #fff;
}

.theme-card-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

/* ========================================================
   COMMAND CENTER TELEMATICS LAYOUT (MOCKUP SAMSARA / LINEAR)
   ======================================================== */

body.command-center {
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    background-color: var(--bg-main);
}

.msv-app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
}

/* Sidebar Lateral Delgado y Elegante */
.msv-sidebar {
    width: 250px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    z-index: 1000;
    transition: width 0.3s ease;
}

.msv-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 18px 6px;
    border-bottom: 1px solid var(--border-color);
}

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

.msv-brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.msv-brand-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.msv-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
    flex: 1;
}

.msv-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
}

.msv-nav-item:hover {
    color: #fff;
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.05);
}

.msv-nav-item.active {
    color: #fff !important;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.22) 0%, rgba(59, 130, 246, 0.08) 100%) !important;
    border-color: rgba(59, 130, 246, 0.45) !important;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.16) !important;
    position: relative;
}

.msv-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-blue);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px var(--accent-blue);
}

.msv-nav-item.active i {
    color: var(--accent-blue) !important;
}

.msv-sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msv-operator-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 10px;
}

.msv-operator-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.msv-operator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.msv-operator-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.msv-operator-status {
    font-size: 0.7rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Área de Contenido Principal Fluid */
.msv-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    gap: 20px;
    overflow-y: auto;
    min-width: 0;
}

/* Fila Superior de KPIs Ejecutivos */
.msv-top-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.kpi-card-v2 {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--card-shadow);
}

.kpi-card-v2:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

.kpi-v2-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kpi-v2-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi-v2-val {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: baseline;
    gap: 4px;
    letter-spacing: -0.02em;
}

.kpi-v2-val small {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-v2-sub {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-v2-visual {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Mini Anillo Circular SVG para el Score */
.circle-progress-svg {
    transform: rotate(-90deg);
}

.circle-progress-bg {
    stroke: rgba(255, 255, 255, 0.08);
}

.circle-progress-fill {
    stroke: #10b981;
    transition: stroke-dashoffset 0.8s ease;
}

/* Hero Canvas: Mapa (46%) + Inspector Conductor (54%) */
.msv-hero-canvas {
    display: grid;
    grid-template-columns: 1.35fr 1.65fr;
    gap: 20px;
    align-items: stretch;
}

/* Card del Mapa */
.msv-map-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 500px;
    box-shadow: var(--card-shadow);
}

.msv-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.msv-map-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.msv-map-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 440px;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 440px;
    border: none;
    border-radius: 0;
}

/* Floating Glassmorphism Telemetry HUD */
.msv-map-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.15);
}

.msv-hud-speed-gauge {
    position: relative;
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msv-hud-speed-gauge svg {
    transform: rotate(-90deg);
}

.msv-hud-speed-gauge .speed-circle-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.msv-hud-speed-gauge .speed-circle-val {
    stroke: #38bdf8;
    transition: stroke-dashoffset 0.5s ease;
}

.msv-hud-gauge-icon {
    position: absolute;
    color: #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msv-hud-data {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msv-hud-speed-text {
    font-size: 1.55rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.msv-hud-speed-text small {
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
}

.msv-hud-heading {
    font-size: 0.8rem;
    color: #38bdf8;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msv-hud-coords {
    font-size: 0.72rem;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

/* Panel Inspector de Conductor (Driver Inspector) */
.msv-driver-inspector {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--card-shadow);
}

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

.driver-inspector-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.driver-profile-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(14, 165, 233, 0.22);
    border-radius: 12px;
    padding: 10px 14px;
}

.driver-avatar-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.driver-avatar-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e293b, #334155);
    border: 2px solid var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.driver-info-block strong {
    display: block;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.driver-info-block span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.driver-score-circle {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid #10b981;
    color: #34d399;
    font-weight: 800;
    font-size: 1.15rem;
    line-height: 1;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.25);
}

.driver-score-circle small {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* 2 Columnas Internas: Barras a la Izquierda (Cortas) y Radar a la Derecha (Grande) */
.driver-inspector-body {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-height: 260px;
}

.competency-bars-list {
    width: 145px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.competency-bar-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

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

.competency-bar-track {
    width: 100%;
    height: 5px;
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.competency-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.driver-radar-area {
    position: relative;
    height: 260px;
    flex: 1;
    min-width: 0;
}

/* Grilla Inferior Operativa: Tabla de Flota + Log de Eventos */
.msv-bottom-grid-v2 {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 20px;
}

.fleet-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--card-shadow);
}

.fleet-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.fleet-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    min-width: 240px;
}

.fleet-search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    outline: none;
    width: 100%;
    font-size: 0.82rem;
}

.event-log-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--card-shadow);
}

/* Breakpoints Responsivos */
@media (max-width: 1280px) {
    .msv-hero-canvas {
        grid-template-columns: 1fr;
    }
    .msv-bottom-grid-v2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px) {
    .msv-top-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
    .msv-sidebar {
        width: 72px;
        padding: 16px 8px;
    }
    .msv-brand-text, .msv-nav-item span, .msv-operator-name, .msv-operator-status {
        display: none;
    }
    .msv-nav-item {
        justify-content: center;
        padding: 10px;
    }
    .msv-operator-card {
        justify-content: center;
        padding: 6px;
    }
}

@media (max-width: 640px) {
    .msv-app-layout {
        flex-direction: column;
    }
    .msv-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
    }
    .msv-sidebar-nav {
        flex-direction: row;
        margin-top: 0;
    }
    .msv-sidebar-footer {
        display: none;
    }
    .msv-top-kpis {
        grid-template-columns: 1fr;
    }
    .msv-main-content {
        padding: 12px;
    }
    .driver-inspector-body {
        flex-direction: column;
    }
    .competency-bars-list {
        width: 100%;
    }
}

/* ========================================================
   CABINA VIRTUAL EN VIVO: COPILOTO AURA DRIVE (JT/T 808 0x8300)
   ======================================================== */

.msv-copilot-hud-banner {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 999;
    background: rgba(11, 15, 25, 0.90);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(6, 182, 212, 0.35);
    border-radius: 12px;
    padding: 10px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(6, 182, 212, 0.15);
    transition: all 0.35s ease;
}

.msv-copilot-hud-banner.idle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(11, 15, 25, 0.75);
    border-color: rgba(6, 182, 212, 0.25);
}

.copilot-hud-idle-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.copilot-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #06b6d4;
    box-shadow: 0 0 8px #06b6d4;
    animation: copilot-pulse 2s infinite ease-in-out;
}

@keyframes copilot-pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 14px #06b6d4; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.msv-copilot-hud-banner.active {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-color: #06b6d4;
    box-shadow: 0 12px 35px rgba(0,0,0,0.7), 0 0 25px rgba(6, 182, 212, 0.3);
}

.msv-copilot-hud-banner.autocorrected {
    border-color: #10b981 !important;
    box-shadow: 0 12px 35px rgba(0,0,0,0.7), 0 0 25px rgba(16, 185, 129, 0.4) !important;
}

.msv-copilot-hud-banner.penalized {
    border-color: #ef4444 !important;
    box-shadow: 0 12px 35px rgba(0,0,0,0.7), 0 0 25px rgba(239, 68, 68, 0.3) !important;
}

.copilot-active-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.copilot-speaker-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
}

.copilot-speaker-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.copilot-speech-bubble {
    font-size: 0.8rem;
    color: #f1f5f9;
    line-height: 1.35;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.copilot-speech-bubble strong {
    color: #38bdf8;
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.copilot-countdown-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    width: 52px;
    height: 52px;
}

.copilot-countdown-wrap svg {
    transform: rotate(-90deg);
}

.copilot-countdown-num {
    position: absolute;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.copilot-reactive-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.copilot-condition-text {
    color: #38bdf8;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==================== SELECTOR DE IDIOMA (i18n) ==================== */
.msv-lang-picker {
    position: relative;
    display: inline-block;
}

.msv-lang-trigger {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.msv-lang-trigger:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: #64748b;
    color: #fff;
}

.msv-lang-trigger i {
    width: 15px;
    height: 15px;
    color: var(--accent-blue);
}

.msv-lang-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 6px;
    min-width: 170px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 1200;
}

/* En header (como admin.html), despliega hacia abajo */
.header-lang-picker .msv-lang-menu {
    bottom: auto;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
}

.msv-lang-menu.show {
    display: flex;
}

.msv-lang-option {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    transition: all 0.15s ease;
}

.msv-lang-option:hover {
    background: rgba(56, 189, 248, 0.12);
    color: #f1f5f9;
}

.msv-lang-option.active {
    background: rgba(59, 130, 246, 0.2);
    color: #38bdf8;
    font-weight: 700;
}

.msv-lang-option .flag {
    font-size: 1rem;
}

.msv-lang-option .code {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-family: monospace;
}



