/* ==========================================
   ATLAS CLANDESTINO - CORE CSS (VERSIÓN DEFINITIVA: CONTRASTE AA + PC INTACTO)
=========================================== */

/* --- 1. SCROLL TÁCTICO NARANJA --- */
.dash-wrapper *::-webkit-scrollbar { width: 6px; }
.dash-wrapper *::-webkit-scrollbar-track { background: var(--color-background, #1E2328); }
.dash-wrapper *::-webkit-scrollbar-thumb { background: var(--color-primary, #FF5E14); border-radius: 10px; }

/* OCULTAR ELEMENTOS MÓVILES EN ESCRITORIO */
.desktop-only { display: inherit; }
.fab-container, .modal-close, .modal-close-btn, .mobile-only-modal-header { display: none !important; }

/* --- 2. ESTRUCTURA PRINCIPAL --- */
.dash-wrapper { display: flex; min-height: 100vh !important; height: auto !important; background-color: var(--color-background, #1E2328); color: var(--color-text-primary, #F0F2F5); font-family: var(--font-body, 'Inter', sans-serif); width: 100%; overflow: visible !important; }

/* SIDEBAR ESCRITORIO */
.dash-sidebar { width: 260px; background-color: var(--color-surface, #262C33); border-right: 1px solid var(--color-border, #343B42); display: flex; flex-direction: column; padding: 25px 20px; z-index: 10; height: 100%; overflow-y: auto; padding-bottom: 80px; }
.sidebar-header-brand { font-family: var(--font-heading, 'Luckiest Guy', cursive); font-size: 1.4rem; color: var(--color-primary, #FF5E14); display: flex; align-items: center; gap: 10px; margin-bottom: 25px; letter-spacing: 1px; }
.sidebar-label { font-family: var(--font-subheading, sans-serif); font-size: 0.75rem; color: var(--color-text-secondary, #C9D1D9); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; font-weight: 600; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { background: transparent; border: 1px solid transparent; color: var(--color-text-secondary, #C9D1D9); padding: 10px 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; font-family: var(--font-subheading, sans-serif); font-size: 0.85rem; transition: all 0.2s ease; border-radius: 8px; }
.nav-item:hover, .nav-item:focus { background-color: rgba(255, 94, 20, 0.08); color: #fff; outline:none;}
.nav-item.active { background-color: var(--color-primary, #FF5E14); color: #fff; font-weight: 600; }
.nav-count { margin-left: auto; font-size: 0.7rem; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 12px; color:#fff; font-weight: 500;}

/* MAIN CONTENT */
.dash-main { flex: 1; padding: 20px 25px; display: flex; flex-direction: column; gap: 15px; height: auto !important; overflow: visible !important; }
.top-controls { display: flex; justify-content: flex-end; margin-bottom: -5px; min-height: 35px;}

/* BOTONES TÁCTICOS */
.btn-tactical { background-color: transparent; border: 2px solid var(--color-primary, #FF5E14); color: var(--color-primary, #FF5E14); padding: 8px 16px; font-family: var(--font-subheading, sans-serif); font-size: 0.8rem; cursor: pointer; border-radius: 8px; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.btn-tactical:hover, .btn-tactical:focus { background-color: var(--color-primary, #FF5E14); color: #111417; box-shadow: 0 4px 12px rgba(255,94,20,0.2);}
.btn-tactical-sm { background-color: transparent; border: 2px solid var(--color-border, #343B42); color: var(--color-text-primary, #F0F2F5); padding: 5px 10px; font-size: 0.7rem; cursor: pointer; text-decoration: none; transition: all 0.2s; border-radius: 6px; font-weight: 800; }
.btn-tactical-sm:hover, .btn-tactical-sm:focus { border-color: #fff; outline:none;}

/* PANELES Y TARJETAS */
.dash-card { background-color: var(--color-surface, #262C33); border: 1px solid var(--color-border, #343B42); border-radius: 10px; padding: 15px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); position: relative; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--color-border, #343B42); padding-bottom: 8px;}
.card-title { font-family: var(--font-subheading, sans-serif); font-size: 0.9rem; color: var(--color-text-secondary, #C9D1D9); margin: 0; font-weight: 600;}

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; flex-shrink: 0; }
.kpi-card { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-radius: 10px; border: 1px solid var(--color-border, #343B42); border-left: 4px solid var(--color-border, #343B42); transition: 0.2s;}
.kpi-card:hover { border-left-color: var(--color-primary, #FF5E14); }
.kpi-clickable { cursor: pointer; }
.kpi-clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(255, 46, 99, 0.15); border-left-color: #FF2E63; }
.kpi-card.active-filter { border-color: #FF2E63; background: rgba(255, 46, 99, 0.1); box-shadow: 0 0 15px rgba(255, 46, 99, 0.2); border-left-width: 6px;}

.kpi-info { display: flex; flex-direction: column; width: 100%;}
.kpi-label { font-family: var(--font-subheading, sans-serif); font-size: 0.7rem; color: var(--color-text-secondary, #C9D1D9); letter-spacing: 0.5px; margin-bottom: 4px; font-weight:600;}
.kpi-value { font-family: var(--font-heading, sans-serif); font-size: 1.8rem; line-height: 1; color: var(--color-text-primary, #F0F2F5); }
.kpi-trend { font-size: 0.7rem; margin-top:6px; font-weight: 600;}
.kpi-chart { width: 55px; height: 28px; opacity: 0.8; margin-left: 10px;}

.primary-text { color: var(--color-primary, #FF5E14); } .amber-text { color: #FFB74D; } .magenta-text { color: #FF2E63; } .text-white { color: #fff; } .magenta-trend { color: #FF2E63; }

/* MAPA Y GRÁFICO (PROPORCIONES DE ESCRITORIO AL 75% Y 25%) */
.content-grid-top { display: flex; gap: 15px; height: 550px !important; min-height: 550px; margin-bottom: 20px; }
.map-container { flex: 3; padding: 0; overflow: hidden; display: flex; flex-direction: column; border-radius: 10px; height: 100% !important; position: relative; }
.map-area { flex: 1; background: #111; z-index: 1;}

/* CONTENEDORES MAPA ESCRITORIO */
.map-ui-top {
    position: absolute; top: 15px; left: 15px; right: 15px; z-index: 10000;
    display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.map-ui-top > * { pointer-events: auto; }

.map-title-overlay {
    position: relative; background: rgba(30,35,40,0.9); padding: 6px 15px; 
    border-radius: 6px; border-left: 4px solid var(--color-primary, #FF5E14); width: fit-content; max-width: 100%;
}
.map-title-overlay h2 { font-family: var(--font-subheading, sans-serif); font-size: 1rem; color: #fff; margin:0; text-transform: uppercase; font-weight: 700;}

.route-intel-panel { 
    position: relative; background: rgba(30, 35, 40, 0.95); border: 1px solid var(--color-primary, #FF5E14); border-radius: 8px; padding: 15px; width: 260px; max-height: 50vh; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.6); backdrop-filter: blur(4px); 
}
.route-intel-panel h4 { font-family: var(--font-subheading, sans-serif); color: var(--color-primary, #FF5E14); margin: 0 0 12px 0; border-bottom: 1px solid rgba(255,94,20,0.3); padding-bottom: 8px;}
.route-intel-panel ul { margin: 0; padding: 0; list-style: none;}
.route-step-item { margin-bottom: 8px; padding: 6px 8px; font-size: 0.75rem; color: #E1E4E8; cursor: pointer; border-radius: 4px; transition: 0.2s; border: 1px solid transparent; display: flex; align-items: flex-start; gap: 8px; }
.route-step-item:hover { background: rgba(255, 94, 20, 0.1); color: var(--color-primary, #FF5E14); border-color: rgba(255, 94, 20, 0.3);}
.route-step-item.active { background: rgba(255, 94, 20, 0.2); color: #fff; border-color: var(--color-primary, #FF5E14); font-weight: bold;}

.map-controls-overlay { position: absolute; z-index: 999999 !important; top: 15px; right: 15px; display:flex; gap:10px;}

.chart-container { flex: 1; display: flex; flex-direction: column; min-width: 250px; max-width: 320px; height: 100% !important; }
.chart-wrapper { flex: 1; position: relative; min-height: 120px; margin-top: 10px;}
.cat-pills-container { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; justify-content: center; overflow-y:auto; max-height: 140px; padding-bottom: 5px;}

/* ANIMACIÓN */
.pulse-marker { animation: tacticalPulse 1.5s infinite; border: 2px solid #1E2328; }
.light-theme .pulse-marker { border-color: #ffffff; }
.pulse-step { animation: tacticalPulseAmber 1.5s infinite; }
@keyframes tacticalPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 94, 20, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(255, 94, 20, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 94, 20, 0); } }
@keyframes tacticalPulseAmber { 0% { box-shadow: 0 0 0 0 rgba(255, 183, 77, 0.7); } 70% { box-shadow: 0 0 0 8px rgba(255, 183, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 183, 77, 0); } }

/* PANTALLA COMPLETA MAPA */
.map-fullscreen { position: fixed !important; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 99999; border-radius: 0; border: none; }

/* BOTONES MAPA */
.btn-map-action { background-color: #1E2328; color: #fff; border: 2px solid var(--color-primary, #FF5E14); padding: 6px 12px; font-size: 0.9rem; cursor: pointer; border-radius: 6px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.3); font-weight: 800; pointer-events: auto;}
.btn-map-action:hover { background-color: var(--color-primary, #FF5E14); color: #111417; }
.btn-reset-action { background-color: #111; border-color: #FF2E63; color:#FF2E63; font-size: 0.75rem;}
.btn-reset-action:hover { background-color: #FF2E63; color: #111417; }

/* POPUPS MAPA */
.leaflet-popup-content-wrapper { background: #1E2328; color: #fff; border: 2px solid var(--color-primary, #FF5E14); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.6);}
.leaflet-popup-tip { background: #1E2328; }
.popup-title { font-family: var(--font-subheading, sans-serif); color: #fff; font-size: 1rem; margin: 0 0 12px 0; font-weight: 700;}
.popup-actions { display: flex; gap: 8px; }
.dash-popup-btn { padding: 8px 10px; font-size: 0.7rem; text-decoration: none; text-align: center; flex: 1; background: transparent; border-radius: 4px; font-weight: 800; cursor: pointer; font-family: var(--font-subheading, sans-serif); transition: 0.2s; }
.tactical-tooltip { background: #1E2328; color: #fff; border: 2px solid #FFB74D; border-radius: 6px; font-family: var(--font-body, sans-serif); font-size: 0.8rem; padding: 8px 12px;}
.tactical-tooltip strong { color: #FFB74D; display:block; margin-bottom: 4px;}
.leaflet-tooltip-top:before { border-top-color: #FFB74D; }

/* TABLA SCROLL */
.recents-container { flex: none; display: flex; flex-direction: column; height: auto; min-height: 280px; max-height: 400px; margin-bottom: 40px; }
.recents-table-wrapper { flex: 1; overflow-y: auto; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--color-primary, #FF5E14) transparent; }
.recents-table-wrapper::-webkit-scrollbar { width: 6px; }
.recents-table-wrapper::-webkit-scrollbar-thumb { background: var(--color-border, #343B42); border-radius:10px; }
.recents-table-wrapper::-webkit-scrollbar-thumb:hover { background: var(--color-primary, #FF5E14); }

.tactical-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; text-align: left; }
.tactical-table th { position: sticky; top: 0; background: var(--color-surface, #262C33); color: var(--color-text-secondary, #C9D1D9); font-family: var(--font-tactical, sans-serif); font-size: 0.65rem; padding: 12px 10px; border-bottom: 2px solid rgba(255, 255, 255, 0.15); z-index: 2; font-weight: 700; letter-spacing: 0.5px; }
.tactical-table td { padding: 16px 10px !important; border-bottom: 1px solid rgba(255, 255, 255, 0.08); color: var(--color-text-primary, #F0F2F5); pointer-events: auto !important; }
.tactical-table tr { transition: background-color 0.2s; outline:none; }
.tactical-table tr:hover { background-color: rgba(255, 94, 20, 0.08); cursor: pointer;}
.badge-type { padding: 4px 8px; border: 1px solid; border-radius: 4px; font-size: 0.7rem; font-weight: 600; display: inline-block;}
.col-action { display: flex; gap: 8px; justify-content: flex-end;}
.btn-icon { background: transparent; color: var(--color-text-secondary, #C9D1D9); border: 2px solid var(--color-border, #343B42); width: 30px; height: 30px; border-radius: 4px; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; text-decoration: none; font-size: 0.8rem; font-weight: 800; }

.col-id { width: 50px; color: var(--color-text-secondary, #C9D1D9) !important; } .col-title { font-weight: 600; } .col-type { width: 140px; } .col-days { width: 80px; color: var(--color-text-secondary, #C9D1D9) !important;} .col-action { width: 120px; text-align: right; display:flex; gap:8px;}

/* BOTONES NEÓN MÚLTIPLES */
.cat-pill { background: transparent; border: 2px solid; padding: 6px 12px; border-radius: 20px; font-size: 0.7rem; cursor: pointer; font-weight: 800; text-transform: uppercase; transition: all 0.2s; font-family: var(--font-subheading, sans-serif); letter-spacing: 0.5px; border-color: var(--color-primary, #FF5E14); color: var(--color-primary, #FF5E14); }
.cat-pill:hover, .cat-pill.active { background-color: var(--color-primary, #FF5E14); color: #111417; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.2); }

.popup-actions .dash-popup-btn:nth-child(1) { border: 2px solid #FF5E14 !important; color: #FF5E14 !important; } .popup-actions .dash-popup-btn:nth-child(1):hover { background: #FF5E14 !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,94,20,0.5);}
.popup-actions .dash-popup-btn:nth-child(2) { border: 2px solid #FF2E63 !important; color: #FF2E63 !important; } .popup-actions .dash-popup-btn:nth-child(2):hover { background: #FF2E63 !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,46,99,0.5);}
.popup-actions .dash-popup-btn:nth-child(3) { border: 2px solid #FFB74D !important; color: #FFB74D !important; } .popup-actions .dash-popup-btn:nth-child(3):hover { background: #FFB74D !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,183,77,0.5);}

.col-action .btn-icon:nth-child(1) { border-color: #FF2E63 !important; color: #FF2E63 !important; } .col-action .btn-icon:nth-child(1):hover { background: #FF2E63 !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,46,99,0.5);}
.col-action .btn-icon:nth-child(2) { border-color: #FFB74D !important; color: #FFB74D !important; } .col-action .btn-icon:nth-child(2):hover { background: #FFB74D !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,183,77,0.5);}
.col-action .btn-icon:nth-child(3) { border-color: #FF5E14 !important; color: #FF5E14 !important; } .col-action .btn-icon:nth-child(3):hover { background: #FF5E14 !important; color: #111417 !important; box-shadow: 0 0 12px rgba(255,94,20,0.5);}
.btn-icon.btn-plan.added-active { background: #FFB74D !important; color: #111417 !important; }

/* =========================================================
   MODO CLARO (LIGHT THEME) - CONSOLIDADO
========================================================= */
.light-theme .dash-wrapper { background-color: #F8FAFC; color: #0F172A; }
.light-theme .dash-sidebar { background-color: #FFFFFF; border-color: #CBD5E1; }
.light-theme .dash-card, .light-theme .recents-container { background-color: #FFFFFF; border-color: #CBD5E1; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.light-theme .kpi-label, .light-theme .sidebar-label, .light-theme .card-title { color: #334155 !important; }
.light-theme .text-white, .light-theme .kpi-value { color: #0F172A !important; }
.light-theme .kpi-value.primary-text { color: #C2410C !important; }

.light-theme .nav-item { color: #334155 !important; }
.light-theme .nav-item:hover, .light-theme .nav-item:focus { background-color: #F1F5F9 !important; color: #0F172A !important; }
.light-theme .nav-item.active { background-color: rgba(194, 65, 12, 0.08) !important; color: #C2410C !important; border: 1px solid #C2410C !important; }
.light-theme .nav-count { background: #E2E8F0 !important; color: #334155 !important; border: 1px solid #CBD5E1; }

.light-theme .map-container { border-color: #CBD5E1; }
.light-theme .map-area { background: #F1F5F9; } 
.light-theme .map-title-overlay { background: rgba(255,255,255,0.95); border-left-color: #C2410C; }
.light-theme .map-title-overlay h2 { color: #0F172A !important; }
.light-theme .route-intel-panel { background: rgba(255,255,255,0.95); border-color: #C2410C; box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.light-theme .route-intel-panel h4 { color: #C2410C !important; border-bottom-color: rgba(194, 65, 12, 0.2); }
.light-theme .route-step-item { color: #334155 !important; }
.light-theme .route-step-item:hover { background: rgba(194, 65, 12, 0.08); color: #C2410C !important; border-color: rgba(194, 65, 12, 0.2); }
.light-theme .route-step-item.active { background: rgba(194, 65, 12, 0.15); color: #C2410C !important; border-color: #C2410C; }
.light-theme .leaflet-popup-content-wrapper { background: #FFFFFF !important; color: #0F172A !important; border-color: #CBD5E1 !important; }
.light-theme .leaflet-popup-tip { background: #FFFFFF !important; }
.light-theme .popup-title { color: #0F172A !important; }
.light-theme .tactical-tooltip { background: #FFFFFF !important; color: #0F172A !important; border-color: #B45309 !important; }
.light-theme .tactical-tooltip strong { color: #B45309 !important; }
.light-theme .tactical-table th { background-color: #F1F5F9 !important; color: #334155 !important; border-bottom: 2px solid #CBD5E1 !important; }
.light-theme .tactical-table td { border-bottom: 1px solid #E2E8F0 !important; color: #0F172A !important; }
.light-theme .tactical-table tr:hover { background-color: #F8FAFC !important; }
.light-theme .col-id, .light-theme .col-days { color: #334155 !important; }
.light-theme .col-title { color: #0F172A !important; }
.light-theme .cat-pill, .light-theme .badge-type { border-color: #C2410C !important; color: #C2410C !important; border-width: 2px !important; font-weight: 700 !important; }
.light-theme .cat-pill:hover, .light-theme .cat-pill.active { background-color: #C2410C !important; color: #FFFFFF !important; }
.light-theme .btn-tactical, .light-theme .btn-map-action { background-color: #FFFFFF !important; border-color: #C2410C !important; color: #C2410C !important; }
.light-theme .btn-tactical:hover, .light-theme .btn-map-action:hover { background-color: #C2410C !important; color: #FFFFFF !important; }
.light-theme .col-action .btn-icon { background: #F8FAFC !important; border-color: #CBD5E1 !important; color: #334155 !important; }

/* =========================================================
   EVOLUCIÓN MÓVIL: MODO INFILTRACIÓN TOTAL (DOMINIO ABSOLUTO)
========================================================= */
@media (max-width: 900px) {
    /* 1. LIMPIEZA DE INTERFAZ */
    .desktop-only, .kpi-grid, .top-controls { display: none !important; }
    .dash-sidebar, .chart-container, .recents-container { display: none !important; }

    /* 2. ESTRUCTURA CON MARCO Y SCROLL RECUPERADO */
    .dash-wrapper { 
        flex-direction: column; 
        height: auto !important; /* Liberamos el scroll nativo de la página */
        min-height: 100vh !important;
        overflow: visible !important; 
        padding-bottom: 100px; /* Margen extra inferior para que la página baje y no tape los FABs */
    }
    .dash-main { 
        padding: 15px !important; /* EL MARCO VUELVE: Salva el scroll del usuario */
        gap: 15px !important; 
        height: auto !important; 
        position: relative; 
    }
    .content-grid-top { height: auto !important; min-height: auto !important; margin: 0 !important; }
    
    .map-container { 
        height: 70vh !important; /* Ocupa el 70% de la pantalla, dejando hueco */
        min-height: 450px !important; 
        border-radius: 10px !important; /* Bordes redondeados restaurados */
        border: 1px solid var(--color-border, #343B42) !important; 
        margin-bottom: 0 !important; 
    }

    /* 3. TRIPLE BOTONERA (FAB) ALINEADA AL MEDIO LADO DERECHO */
    .fab-container { 
        display: flex !important; flex-direction: column; gap: 15px; 
        position: fixed; top: 50% !important; transform: translateY(-50%); 
        right: 15px !important; z-index: 2147483602 !important; 
    }
    .fab-action-btn { 
        width: 55px; height: 55px; border-radius: 50%; display: flex; justify-content: center; align-items: center; 
        font-size: 1.3rem; box-shadow: 0 4px 15px rgba(0,0,0,0.5); border: 2px solid #111417; cursor: pointer; transition: 0.2s; 
    }
    .fab-action-btn:active { transform: scale(0.9); }

    /* 4. LOS 3 MODALES EN PRIMER PLANO (Territorios, Categorías y Misiones) */
    .recents-container, .chart-container { max-height: none !important; }
    
    .dash-sidebar.mobile-modal-active, .chart-container.mobile-modal-active, .recents-container.active {
        display: flex !important; flex-direction: column !important; position: fixed !important;
        top: var(--header-height, 70px) !important; left: 0 !important; width: 100vw !important;
        height: calc(100vh - var(--header-height, 70px)) !important; max-height: 100vh !important;
        background: var(--color-background, #1E2328) !important; z-index: 2147483645 !important;
        padding: 20px !important; overflow-y: auto !important; border-radius: 0 !important;
        border: none !important; margin: 0 !important; max-width: 100% !important;
        animation: slideUpTactical 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .mobile-only-modal-header { display: flex !important; }
    .nav-item { background-color: var(--color-surface, #262C33); border: 1px solid var(--color-border, #343B42); padding: 16px 15px; border-radius: 8px; margin-bottom: 10px; font-size: 1rem; width: 100%; }
    
    .light-theme .dash-sidebar.mobile-modal-active, 
    .light-theme .chart-container.mobile-modal-active, 
    .light-theme .recents-container.active { background: #F8FAFC !important; }
    .light-theme .nav-item { background-color: #FFFFFF !important; border: 1px solid #CBD5E1 !important; color: #334155 !important; }
    .light-theme .nav-item.active { background-color: rgba(194, 65, 12, 0.08) !important; color: #C2410C !important; border: 2px solid #C2410C !important; }

    .chart-container.mobile-modal-active .chart-wrapper { display: none !important; }
    .chart-container.mobile-modal-active .cat-pills-container { max-height: none !important; overflow-y: visible !important; margin-top: 20px !important; padding-bottom: 30px !important;}
    .modal-close, .modal-close-btn { display: inline-flex !important; align-items: center; gap: 8px; background: transparent; border: 2px solid #FF2E63; color: #FF2E63; padding: 8px 16px; border-radius: 6px; font-weight: 800; cursor: pointer; }
    /* ---------------------------------------------------
       REORGANIZACIÓN DE TABLA EN MÓVIL (DISEÑO TARJETA)
    --------------------------------------------------- */
    .tactical-table thead { 
        display: none !important; /* Ocultamos las cabeceras (ID, MISIÓN...) para ganar espacio vertical */
    }
    
    .tactical-table tbody, .tactical-table tr, .tactical-table td {
        display: block !important; /* Rompemos la estructura rígida de tabla */
        width: 100% !important;
    }
    
    .tactical-table tr {
        padding: 15px !important;
        margin-bottom: 12px !important;
        background: var(--color-surface, #262C33) !important;
        border: 1px solid var(--color-border, #343B42) !important;
        border-radius: 8px !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: flex-start !important;
    }
    
    .tactical-table td {
        padding: 0 !important;
        border: none !important;
    }
    
    .col-type, .col-days { 
        display: none !important; /* Mantenemos ocultos el tipo y los días en móvil */
    }
    
    /* El ID se convierte en una etiqueta superior */
    .col-id {
        width: auto !important;
        font-size: 0.75rem !important;
        background: rgba(255, 94, 20, 0.1) !important;
        color: var(--color-primary, #FF5E14) !important;
        padding: 4px 8px !important;
        border-radius: 4px;
        margin-right: 10px !important;
        margin-bottom: 12px !important;
        font-weight: 800 !important;
    }
    
    /* El título gana todo el espacio de la derecha */
    .col-title {
        flex: 1 !important;
        min-width: 60% !important;
        font-size: 0.95rem !important;
        margin-bottom: 12px !important;
        line-height: 1.4 !important;
        padding-right: 0 !important;
    }
    
    /* Los botones fuerzan el salto de línea para tener su propio espacio */
    .col-action {
        width: 100% !important;
        min-width: 100% !important; 
        justify-content: flex-end !important;
        padding-top: 12px !important;
        border-top: 1px dashed rgba(255, 255, 255, 0.1) !important; /* Separador sutil */
    }

    /* Adaptación de las tarjetas para el modo claro en móvil */
    .light-theme .tactical-table tr {
        background: #FFFFFF !important;
        border-color: #CBD5E1 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
    }
    .light-theme .col-action {
        border-top-color: #E2E8F0 !important;
    }
    
    /* 🚀 5. INFILTRACIÓN BAJO EL HEADER Y CERO COLISIONES 🚀 */
    
    /* Se baja el z-index de 2147483641 a 800. Así, al hacer scroll, el mapa pasa por debajo del header de tu web. */
    .map-ui-top { left: 10px !important; right: 10px !important; top: 10px !important; gap: 5px !important; z-index: 800 !important; }
    .map-title-overlay { padding: 8px 12px !important; z-index: 800 !important; }
    .map-title-overlay h2 { font-size: 0.85rem !important; line-height: 1.2; word-wrap: break-word; }
    .route-intel-panel { width: 100% !important; max-width: 100% !important; z-index: 805 !important; }

    /* BOTONES DE PANTALLA COMPLETA Y RESET (Esquina Inferior Izquierda) */
    .map-controls-overlay { 
        top: auto !important; 
        bottom: 20px !important; 
        left: 15px !important; right: auto !important; 
        flex-direction: column-reverse; align-items: flex-start; 
        z-index: 800 !important; /* Capa inferior al header */
    }

    /* COMPORTAMIENTO PANTALLA COMPLETA EN MÓVIL */
    .map-fullscreen {
        position: fixed !important;
        top: 0 !important; left: 0 !important;
        width: 100vw !important; 
        height: 100dvh !important; /* 🚀 dHV: Dynamic viewport, ignora barras del navegador */
        z-index: 999999 !important; /* En modo fullscreen sí necesitamos taparlo todo */
        border-radius: 0 !important; border: none !important;
    }
    
    /* 🚀 CORRECCIÓN DEL BOTÓN DE SALIDA DE FULLSCREEN 🚀 */
    /* Lo anclamos arriba a la derecha cuando está en pantalla completa para que ninguna barra inferior lo tape jamás */
    .map-fullscreen .map-controls-overlay {
        top: 20px !important; 
        bottom: auto !important; 
        left: auto !important; 
        right: 15px !important; 
        flex-direction: column !important; 
        align-items: flex-end !important;
        z-index: 999999 !important;
    }
    .map-fullscreen .map-ui-top {
        top: 80px !important; 
    }
}

@keyframes slideUpTactical { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Elevar la cabecera y el menú móvil por encima del mapa de atlas.php */
.site-header { 
    z-index: 9999999 !important; 
}
.mobile-navigation { 
    z-index: 9999998 !important; 
}
.menu-toggle-button { 
    z-index: 9999999 !important; 
    position: relative; 
}

/* =========================================================
   FIX DEFINITIVO V2: BOTONES CUADRADOS, CENTRADOS Y SIN OVERLAP
========================================================= */

/* 0. Centrado vertical estricto de las celdas de la tabla */
.tactical-table td {
    vertical-align: middle !important; 
}

/* 1. Protección del texto: Evita que el título se meta debajo de los botones en móvil */
.col-title {
    padding-right: 15px !important;
    word-break: break-word; 
}

/* 2. Contenedor de botones: ANCHO CORREGIDO para que quepan los 3 botones */
.col-action {
    display: flex !important;
    align-items: center !important;       
    justify-content: flex-end !important; 
    gap: 10px !important;                 /* Separación óptima */
    height: 100% !important;              
    margin: 0 !important;
    min-width: 145px !important;          /* EL SECRETO: Espacio real para los 3 botones */
    width: auto !important;
}

/* 3. Botones de la tabla: 38px (Punto dulce visual y accesible) */
.col-action .btn-icon {
    width: 38px !important;  
    height: 38px !important;
    min-width: 38px !important;
    flex-shrink: 0 !important;            /* Evita que se aplasten */
    font-size: 0.85rem !important;
    position: relative;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

/* 4. Recuperar botón de cerrar mapa sobre el header */
.map-fullscreen {
    z-index: 10000000 !important; 
}

/* 5. Tooltip Táctico: Solo el nuestro, limpio y oscuro */
.col-action .btn-icon[aria-label]:hover::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 10px);
    right: 50%;
    transform: translateX(50%);
    background: #111;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.7rem;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    border: 1px solid var(--color-primary);
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* Eliminar tooltips nativos o duplicados */
.col-action .btn-icon[aria-label]:hover::before { display: none !important; }