/* ==========================================================================
   ARQUITECTURA DE ESTILOS ESTRUCTURALES BASE (styles_base.css)
   Aplicación de Monitoreo de Inmersiones Hidrográficas
   ========================================================================= */

/* --- 1. CONFIGURACIÓN GLOBAL, VARIABLES Y RESETEO --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    /* --- DIMENSIONAMIENTO Y SOMBRAS (Estructurales, no cambian) --- */
    --topbar-height: 70px;
    --shadow-modal-bg: rgba(0, 0, 0, 0.5);
    --shadow-popover: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-list-up: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Restringe scrolls dobles para asegurar la fijeza del mapa base */
    overflow: hidden;
}

/* Forzado de Human Interface: consistencia tipográfica en elementos nativos interactivos */
input,
select,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
}

.icon {
    width: 24px;
    height: 24px;
}


/* --- 2. BARRA SUPERIOR DE NAVEGACIÓN (TOP BAR) --- */
.top-bar {
    background-color: var(--background-color);
    color: var(--highlight-color);
    /* Cambiamos la altura fija por una dinámica para que crezca si los botones saltan de línea */
    height: auto;
    min-height: var(--topbar-height);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Permitimos que el bloque izquierdo y derecho se separen en dos líneas si chocan */
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
    z-index: 1002;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.top-bar-content-left,
.top-bar-content-right {
    display: flex;
    align-items: center;
    /* Permitimos que los botones salten de línea si la ventana de PC es muy estrecha */
    flex-wrap: wrap;
    gap: 12px;
}

.top-bar-form-logout {
    display: contents;
}

/* --- Control estricto de botones y textos en la Top Bar --- */
.top-bar .btn-primary,
.top-bar .btn-link,
.top-bar span {
    /* MAGIA ABSOLUTA: Prohíbe al navegador encoger los elementos. Si no caben, saltan intactos. */
    flex-shrink: 0;
    white-space: nowrap;
}

.top-bar .btn-primary,
.top-bar .btn-link {
    height: 40px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.95rem;
}

.top-bar span {
    font-weight: 600;
    margin: 0 8px;
}


/* ==========================================================================
   3. COMPONENTE DE FILTRADO DINÁMICO DE INMERSIONES
   ========================================================================== */
.immersion-filter {
    display: none;
    background-color: var(--background-color);
    color: var(--highlight-color);
    max-height: 265px;
    padding: 20px;
    position: absolute;
    inset-inline: 0;
    z-index: 1001;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
}

.immersion-filter[style*="display: block"],
.immersion-filter[style*="display: flex"] {
    display: flex !important;
}

.immersion-filter-user-list {
    flex: 1;
    max-height: 140px;
    overflow-y: auto;
    padding-right: 8px;
}

.immersion-filter-col-dates {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    max-width: 450px;
    width: 100%;
}

.input-date {
    background-color: var(--background-color);
    color: var(--highlight-color);
    border: 1px solid var(--highlight-color);
    border-radius: var(--border-radius-btn);
}

.immersion-filter.filter-single-col {
    justify-content: center !important;
}

.immersion-filter.filter-single-col .immersion-filter-col-dates {
    margin: 0 auto !important;
}

.immersion-filter-col-dates div {
    display: flex;
    align-items: center;
    justify-content: space-between !important;
    gap: 15px;
    width: 100%;
}

/* --- 4. VISUALIZADORES PRINCIPALES (CARTOGRAFÍA Y GRÁFICAS) --- */
#map {
    height: calc(100vh - var(--topbar-height));
    width: 100%;
    background-color: #000;
}

.wrapper-chart {
    position: relative;
    width: 100%;
    height: 300px;
}


/* ==========================================================================
   5. VENTANAS EMERGENTES (MODALES Y POPUPS)
   ========================================================================== */
.popupWindowBackground {
    position: fixed;
    inset: 0;
    background-color: var(--shadow-modal-bg);
    z-index: 9999;
}

/* Base para todas las ventanas (Ajustes, Inmersiones, etc.) */
.popupWindow.modal-modern {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    display: flex;
    flex-direction: column;
    max-width: 550px;
    width: 95vw;
    max-height: 90vh;
    /* Límite estricto de altura de pantalla */
    border-radius: var(--border-radius-box);
    overflow: hidden;
    /* Corta el desbordamiento, el scroll va en el body */
    background-color: var(--background-color);
    box-shadow: var(--shadow-popover);
}

/* Modificador exclusivo para modales grandes (Inmersiones y Gráficos) */
.popupWindow.modal-wide {
    max-width: 1100px;
    width: 90vw;
}

/* --- Cabecera Fija --- */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background-color: var(--background-color);
    border-bottom: 1px solid rgba(150, 150, 150, 0.2);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--highlight-color);
}

/* --- Cuerpo Scrolleable y Grid Elástico --- */
.modal-body.form-grid {
    padding: 24px;
    overflow-y: auto;
    /* Habilita el scroll interno si el contenido excede el modal */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    flex-grow: 1;
}

/* --- Pie / Botonera Fija --- */
.modal-footer {
    padding: 16px 24px;
    background-color: var(--background-color);
    border-top: 1px solid rgba(150, 150, 150, 0.2);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.footer-actions {
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}


/* ==========================================================================
   6. ELEMENTOS INTERNOS DE MODALES (Inputs, Textos, Mapas)
   ========================================================================== */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--highlight-color);
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--highlight-color);
}

.boxSummaryImmersion {
    border: 1px solid var(--highlight-color);
    border-radius: var(--border-radius-box);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    flex-grow: 1;
}

.input-group-row {
    display: flex;
    flex-direction: row;
    gap: 20px;
    color: var(--highlight-color);
    width: max-content;
    padding: 5px 0 5px 0;
}

.full-width {
    grid-column: 1 / -1;
}

.data-value {
    font-size: 0.95rem;
    color: var(--highlight-color);
    padding: 10px 0;
    display: block;
}

.data-value-row {
    font-size: 0.95rem;
    color: var(--highlight-color);
    padding: 0;
    display: block;
}

/* Inputs textuales y textareas */
.input-modern {
    padding: 10px 14px;
    border: 1px solid #d2d2d2;
    border-radius: var(--border-radius-box);
    font-size: 0.95rem;
    color: var(--highlight-color);
    background-color: var(--background-color);
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.input-modal-title {
    margin-right: 20px;
    font-size: 1.25rem;
}

/* Selectores nativos modernos */
.input-group select {
    width: fit-content;
    margin: 0 5px 0 5px;
    padding: 10px 14px;
    border: 1px solid #d2d2d2;
    border-radius: var(--border-radius-box);
    font-size: 0.95rem;
    color: var(--highlight-color);
    background-color: var(--background-color);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
    background: none;
}

.input-group select:hover {
    border-color: color-mix(in srgb, var(--highlight-color) 85%, black);
    color: color-mix(in srgb, var(--highlight-color) 85%, black);
}

.input-group select:focus,
.input-modern:focus {
    outline: none;
    border-color: var(--highlight-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* Contenedores especiales */
.pre-modern {
    background-color: rgba(0, 0, 0, 0.04);
    padding: 12px;
    border-radius: var(--border-radius-box);
    white-space: pre-wrap;
    font-family: monospace;
    margin: 0;
    border: 1px solid #e0e0e0;
}

.map-modern {
    height: 300px !important;
    width: 100%;
    border-radius: var(--border-radius-box);
    border: 1px solid #d2d2d2;
    z-index: 1;
}

/* --- Botones --- */
.btn-primary,
.btn-link {
    background-color: var(--highlight-color);
    color: var(--background-color);
    border: none;
    padding: 10px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-btn);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn-primary:hover,
.btn-link:hover {
    background-color: color-mix(in srgb, var(--highlight-color) 85%, black);
    color: color-mix(in srgb, var(--background-color) 90%, white);
}

.btn-danger {
    background-color: #e74c3c;
    color: #fff;
    border: none;
    padding: 10px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-btn);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-secondary {
    background-color: transparent;
    color: var(--highlight-color);
    border: 1px solid var(--highlight-color);
    padding: 9px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-btn);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background-color: color-mix(in srgb, var(--highlight-color) 10%, transparent);
}

.btn-primary:active,
.btn-link:active,
.btn-danger:active,
.btn-secondary:active {
    transform: scale(0.97);
}

.grouped-chart-list-panel button {
    border-radius: var(--border-radius-btn);
    padding: 10px 28px;
    margin: 4px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-btn);
    cursor: pointer;
}


/* ==========================================================================
   7. LISTA INFERIOR DE INMERSIONES
   ========================================================================== */
.immersion-list {
    background-color: var(--background-color);
    color: var(--highlight-color);
    position: absolute;
    bottom: 0;
    inset-inline: 0;
    z-index: 1001;
    max-height: 30vh;
    overflow-y: auto;
    box-shadow: var(--shadow-list-up);
    padding: 10px;
}

.immersion-list:hover {
    cursor: pointer;
}

.immersion-list li {
    margin: auto;
    margin-bottom: 10px;
    list-style-type: none;
    width: 280px;
    display: inline-flex;
}

.immersion-list li button {
    margin: auto;
    display: block;
    width: inherit;
}

.immersion-list img {
    /* Altura fija para que queden alineados */
    height: 20px;
    width: auto;
    margin-left: 5px;
    margin-right: 5px;
}

.immersion-list summary::marker {
    display: none;
}

.immersion-list summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
}

.map-tooltip {
    padding: 20px;
    background-color: var(--background-color);
    color: var(--highlight-color);
    border: 0px solid transparent;
    border-radius: var(--border-radius-box);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
}

.map-tooltip.leaflet-tooltip-top:before {
    /* Cambia el color de la flecha del tooltip */
    border-top-color: transparent;
}


/* ==========================================================================
   8. ADAPTACIÓN EXCLUSIVA PARA DISPOSITIVOS TÁCTILES (MÓVILES Y TABLETS)
   ========================================================================== */
@media (pointer: coarse) {

    /* --- Ajustes de Tipografía Base --- */
    body {
        font-size: 16px;
    }

    .top-bar {
        height: auto;
        padding: 10px 16px;
        flex-direction: column;
        /* Permitimos que los hijos ocupen el ancho */
        align-items: stretch;
        gap: 8px;
    }

    .top-bar-content-left,
    .top-bar-content-right {
        width: 100%;
        justify-content: flex-start;
        /* EL CAMBIO CLAVE: Permitimos que salte de línea */
        flex-wrap: wrap;
        /* Eliminamos el scroll horizontal */
        overflow-x: visible;
        gap: 8px;
        padding-bottom: 0;
    }

    .logo-odm {
        display: block;
        /* width: 100%; */
        height: auto !important;
    }

    .top-bar a,
    .top-bar button {
        /* Mantenemos el tamaño, pero permitimos que se acomoden */
        height: 40px;
        padding: 0 12px;
        font-size: 0.9rem;
    }

    /* Ajuste para que el nombre de usuario no se corte */
    .top-bar span {
        flex-shrink: 0;
        margin: 0 8px;
        padding: 5px 0;
    }

    /* Le damos un poco de margen final al formulario de logout para que el scroll no termine de golpe */
    .top-bar-form-logout button {
        margin-right: 16px;
    }

    /* --- Recálculo de área cartográfica --- */
    #map {
        /* Al no apilarse en mil filas, la barra ocupa menos, le devolvemos altura al mapa */
        height: calc(100vh - 120px);
    }

    /* --- Filtro Desplegable Fluido --- */
    .immersion-filter {
        flex-direction: column;
        height: auto;
        max-height: 80vh;
        overflow-y: auto;
        gap: 24px;
        padding: 24px 16px;
        position: relative;
        top: 0 !important;
        inset-inline: auto;
        width: 100% !important;
    }

    .immersion-filter-user-list {
        width: 100% !important;
        max-height: 160px;
    }

    .immersion-filter-user-list div {
        padding: 8px 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .immersion-filter-user-list input[type="checkbox"] {
        transform: scale(1.3);
        margin-right: 8px;
    }

    button.txtSelectDeselectAll {
        width: 100% !important;
        height: 48px;
        margin-top: 12px;
    }

    .immersion-filter-col-dates {
        width: 100% !important;
        max-width: 100% !important;
        gap: 14px;
    }

    .immersion-filter-col-dates div {
        display: flex;
        flex-direction: column;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        width: 100%;
        gap: 6px;
    }

    .immersion-filter-col-dates input[type="date"],
    .immersion-filter-col-dates button.txtFilter {
        width: 100% !important;
        height: 48px;
        font-size: 16px;
        align-self: stretch !important;
    }

    /* --- Modales en Móviles --- */
    .popupWindow.modal-wide {
        width: 95vw;
    }

    .footer-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        width: 100%;
    }

    .footer-actions button,
    .footer-actions a {
        width: 100%;
        margin: 0;
    }

    .map-modern {
        height: 40vh !important;
    }

    /* --- Listados Inferiores --- */
    .immersion-list {
        max-height: 35vh;
    }

    .immersion-list summary {
        padding: 14px;
        font-size: 16px;
    }
}

/* --- INTEGRACIÓN FORMULARIO CSV --- */
.form-csv-container {
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid rgba(150, 150, 150, 0.2);
}

.csv-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--highlight-color);
    margin-bottom: 12px;
}

.csv-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

/* Forzamos que el input file no rompa la estética moderna */
.csv-actions .file-input {
    flex: 1;
    min-width: 240px;
}

/* Ajuste adaptativo para móviles en la zona CSV */
@media (pointer: coarse) {
    .csv-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .csv-actions .file-input,
    .csv-actions button {
        width: 100% !important;
    }
}

/* ==========================================================================
   9. SISTEMA DE NOTIFICACIONES FLOTANTES (ALERTS)
   ========================================================================== */
.alert-container {
    position: fixed;
    top: calc(var(--topbar-height) + 20px);
    right: 20px;
    z-index: 10000;
    /* Por encima de modales (9999) */
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    width: calc(100vw - 40px);
}

.alert-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-radius: var(--border-radius-box);
    box-shadow: var(--shadow-popover);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    animation: slideInAlert 0.3s ease forward;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Variaciones de estilo según el flujo de la vista */
.alert-success {
    background-color: #2ecc71;
    color: #fff;
}

.alert-warning {
    background-color: #f39c12;
    color: #fff;
}

.alert-error {
    background-color: #e74c3c;
    color: #fff;
}

/* Botón de cierre interno */
.alert-close-btn {
    background: none;
    border: none;
    color: currentColor;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0 0 15px;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
}

.alert-close-btn:hover {
    opacity: 1;
}

/* Animación de entrada fluida */
@keyframes slideInAlert {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Adaptación estricta para pantallas táctiles/móviles */
@media (pointer: coarse) {
    .alert-container {
        top: 20px;
        /* Si la barra superior cambia en móvil */
        right: 20px;
        left: 20px;
        width: auto;
        max-width: none;
    }

    .alert-box {
        padding: 18px;
        font-size: 1rem;
    }
}

/* ==========================================================================
   10. PANTALLA DE CARGA GLOBAL (LOADING OVERLAY)
   ========================================================================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 11000;
    /* Asegura estar por encima de modales (9999) y alertas (10000) */
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeInOverlay 0.25s ease-out forwards;
}

.loading-box {
    background-color: var(--background-color);
    padding: 32px 40px;
    border-radius: var(--border-radius-box);
    box-shadow: var(--shadow-popover);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 360px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(150, 150, 150, 0.2);
    border-top-color: var(--highlight-color);
    border-radius: 50%;
    animation: spinSpinner 1s linear infinite;
}

.loading-message {
    color: var(--highlight-color);
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.5;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes spinSpinner {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (pointer: coarse) {
    .loading-box {
        width: 85vw;
        padding: 24px;
    }

    .loading-message {
        font-size: 0.95rem;
    }
}

/* Shared application design system. Brand colors and geometry come from the theme files. */
body.app-shell {
    --topbar-height: 72px;
    display: flex;
    height: 100dvh;
    flex-direction: column;
    background: var(--page-background);
    color: var(--text-color);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.app-shell :where(button, input, select, textarea, a) {
    -webkit-tap-highlight-color: transparent;
}

.app-shell :where(button, a, input, select, textarea, summary):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

.top-bar {
    min-height: var(--topbar-height);
    padding: 12px clamp(16px, 3vw, 36px);
    background: var(--surface-color);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    gap: 16px;
}

.top-bar-content-left,
.top-bar-content-right {
    gap: 8px;
}

.top-bar-content-right > span {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.top-bar .btn-primary,
.top-bar .btn-link {
    min-height: 40px;
    height: auto;
    padding: 8px 14px;
    border-radius: var(--border-radius-btn);
    font-size: 0.875rem;
}

.top-bar .btn-link {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.top-bar .btn-link:hover {
    background: var(--surface-muted);
    color: var(--highlight-color);
}

.logo-odm img {
    display: block;
    width: auto;
    height: 36px;
}

.immersion-filter {
    position: fixed;
    top: calc(var(--topbar-height) + 12px);
    left: 50%;
    right: auto;
    width: min(940px, calc(100vw - 32px));
    max-height: min(72vh, 620px);
    overflow-y: auto;
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    align-items: start;
    justify-content: stretch;
    gap: 20px;
    padding: 22px;
    padding-top: 44px;
    transform: translateX(-50%);
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-box);
    box-shadow: var(--shadow-popover);
}

.immersion-filter[style*="display: block"],
.immersion-filter[style*="display: flex"] {
    display: grid !important;
}

.immersion-filter-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 1;
    padding: 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.immersion-filter-close:hover {
    background: transparent;
    color: var(--text-color);
}

.immersion-filter details {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
    background: var(--surface-raised);
}

.immersion-filter details > summary {
    width: fit-content !important;
    min-height: 38px;
    padding: 8px 14px !important;
    color: var(--button-text-color);
    background: var(--highlight-color);
    border-radius: var(--border-radius-btn);
    font-size: 0.88rem;
    font-weight: 650;
}

.immersion-filter-user-list {
    width: 100%;
    max-height: 190px;
    margin-top: 12px;
    color: var(--text-color);
}

.immersion-filter-user-list > div {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 4px;
    border-bottom: 1px solid var(--border-color);
}

.immersion-filter-user-list label {
    color: var(--text-color);
    font-size: 0.9rem;
}

.immersion-filter-user-list input[type="checkbox"] {
    accent-color: var(--highlight-color);
}

.immersion-filter .txtSelectDeselectAll {
    width: fit-content !important;
    margin-top: 12px !important;
}

.immersion-filter-col-dates {
    align-self: stretch;
    justify-content: center;
    gap: 12px;
    max-width: none;
    padding: 16px;
    color: var(--text-color);
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
}

.immersion-filter-col-dates div {
    justify-content: space-between !important;
    gap: 12px;
}

.input-date,
.immersion-filter-col-dates input[type="date"] {
    min-height: 42px;
    padding: 8px 10px;
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
}

.immersion-filter > .immersion-filter-submit {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 42px;
    padding: 9px 16px;
}

#map {
    min-height: 0;
    height: auto;
    flex: 1 1 auto;
    background: var(--page-background);
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
    color: #23384a !important;
}

.popupWindowBackground {
    display: block;
    padding: 24px;
    background: var(--shadow-modal-bg);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.popupWindow.modal-modern {
    width: min(560px, 100%);
    max-height: min(90vh, 900px);
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-box);
    box-shadow: var(--shadow-popover);
}

.popupWindow.modal-wide {
    width: min(1180px, 100%);
}

.modal-header,
.modal-footer {
    padding: 18px 24px;
    color: var(--text-color);
    background: var(--surface-color);
    border-color: var(--border-color);
}

.modal-header h2 {
    color: var(--text-color);
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-body.form-grid {
    gap: 20px;
    padding: 24px;
    color: var(--text-color);
    background: var(--surface-color);
}

.input-group,
.input-group label {
    color: var(--text-muted);
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.045em;
}

.data-value,
.data-value-row {
    color: var(--text-color);
    font-size: 0.95rem;
}

.input-modern,
.input-group select,
.input-group input[type="file"] {
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text-color);
    background-color: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
}

.input-group select {
    width: 100%;
    margin: 0;
    appearance: auto;
    -webkit-appearance: auto;
    background-image: none;
}

.input-group select option {
    color: var(--text-color);
    background: var(--surface-color);
}

.input-modal-title {
    min-height: 46px;
    margin-right: 16px;
    font-size: 1.15rem;
    font-weight: 700;
}

.input-modern::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.input-modern:focus,
.input-group select:focus,
.input-date:focus {
    border-color: var(--highlight-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.boxSummaryImmersion {
    gap: 12px;
    padding: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
}

.input-group-row {
    width: auto;
    min-width: 0;
    align-items: center;
    gap: 10px;
    color: var(--text-color);
}

.icon {
    flex: 0 0 auto;
    object-fit: contain;
}

.pre-modern {
    color: var(--text-color);
    background: var(--surface-raised);
    border-color: var(--border-color);
    border-radius: var(--border-radius-control);
    font-size: 0.82rem;
    line-height: 1.65;
}

.map-modern {
    border-color: var(--border-color);
    border-radius: var(--border-radius-control);
    overflow: hidden;
}

.wrapper-chart {
    min-height: 260px;
    padding: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
}

.btn-primary,
.btn-link,
.btn-secondary,
.btn-danger {
    min-height: 42px;
    padding: 10px 17px;
    border-radius: var(--border-radius-btn);
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1.2;
    transition: background-color 160ms ease, border-color 160ms ease,
        color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.btn-primary,
.btn-link {
    color: var(--button-text-color);
    background: var(--highlight-color);
}

.btn-primary:hover,
.btn-link:hover {
    color: var(--button-text-color);
    background: color-mix(in srgb, var(--highlight-color) 85%, black);
    box-shadow: 0 5px 14px var(--focus-ring);
}

.btn-secondary {
    color: var(--highlight-color);
    background: transparent;
    border: 1px solid var(--highlight-color);
}

.btn-secondary:hover {
    background: var(--surface-muted);
}

.btn-danger {
    background: #c74747;
}

.btn-danger:hover {
    background: #a93636;
    box-shadow: 0 5px 14px rgba(199, 71, 71, 0.24);
}

.immersion-list {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    z-index: 1001;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 100%;
    max-height: min(32vh, 300px);
    padding: 0 18px 12px;
    color: var(--text-color);
    background: var(--surface-color);
    border: 0;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    scrollbar-color: var(--text-muted) transparent;
}

.immersion-list[open] {
    max-height: min(48vh, 430px);
}

.immersion-list summary {
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 58px;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
    color: var(--text-color);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 700;
}

.immersion-list summary > div:first-child {
    display: flex;
    align-items: center;
    gap: 5px;
}

.immersion-list summary > div:last-child {
    display: flex;
    align-items: center;
    gap: 10px;
}

.immersion-list img {
    max-width: 92px;
    height: 22px;
    margin: 0;
    object-fit: contain;
}

.immersion-list ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 14px 0 2px;
}

.immersion-list li {
    width: auto;
    margin: 0;
}

.immersion-list li button {
    width: 100%;
    min-width: 210px;
    min-height: 58px;
    padding: 10px 14px;
    color: var(--text-color);
    text-align: left;
    background: var(--surface-raised);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
    font-size: 0.85rem;
    line-height: 1.5;
}

.immersion-list li button:hover {
    color: var(--highlight-color);
    border-color: var(--highlight-color);
    background: var(--surface-muted);
}

.map-tooltip {
    padding: 12px 15px;
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-control);
    box-shadow: var(--shadow-card);
    line-height: 1.5;
}

.form-csv-container {
    padding-top: 18px;
    border-color: var(--border-color);
}

.csv-title {
    color: var(--text-color);
}

.alert-box {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--border-radius-control);
    box-shadow: var(--shadow-popover);
    animation: slideInAlert 0.3s ease forwards;
}

.loading-box {
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-box);
    box-shadow: var(--shadow-popover);
}

@media (max-width: 760px) {
    .top-bar {
        padding: 10px 14px;
        gap: 8px;
    }

    .top-bar-content-left,
    .top-bar-content-right {
        gap: 6px;
    }

    .top-bar .btn-primary,
    .top-bar .btn-link {
        min-height: 38px;
        padding: 7px 11px;
        font-size: 0.82rem;
    }

    .top-bar-content-right > span {
        max-width: 110px;
    }

    #map {
        height: auto;
    }

    .immersion-filter {
        position: fixed;
        top: calc(var(--topbar-height) + 8px);
        left: 12px;
        right: 12px;
        width: auto !important;
        max-height: min(72dvh, 620px);
        padding: 14px;
        padding-top: 44px;
        transform: none;
        gap: 12px;
    }

    .immersion-filter details,
    .immersion-filter-col-dates {
        width: 100% !important;
        max-width: none;
        padding: 12px;
    }

    .immersion-filter-col-dates div {
        flex-direction: row;
        align-items: center !important;
    }

    .immersion-filter-col-dates input[type="date"] {
        width: min(62%, 220px) !important;
    }

    .popupWindowBackground {
        padding: 12px;
    }

    .popupWindow.modal-modern,
    .popupWindow.modal-wide {
        width: 100%;
        max-height: calc(100dvh - 24px);
    }

    .modal-header,
    .modal-footer {
        padding: 14px 16px;
    }

    .modal-body.form-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 15px;
        padding: 16px;
    }

    .input-group-row {
        width: 100%;
        gap: 8px;
    }

    .boxSummaryImmersion {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 12px;
    }

    .footer-actions {
        flex-direction: row;
        justify-content: stretch;
        gap: 8px;
    }

    .footer-actions button,
    .footer-actions a {
        width: auto;
        flex: 1 1 calc(50% - 8px);
        margin: 0;
        padding: 9px 10px;
        font-size: 0.82rem;
    }

    .immersion-list {
        max-height: 34dvh;
        padding: 0 12px 10px;
    }

    .immersion-list[open] {
        max-height: 48dvh;
    }

    .immersion-list summary {
        min-height: 50px;
        font-size: 0.82rem;
    }

    .immersion-list img {
        max-width: 62px;
        height: 18px;
    }

    .immersion-list li {
        flex: 1 1 100%;
    }

    .immersion-list li button {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-shell *,
    .app-shell *::before,
    .app-shell *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* --- Modo demo --- */
.top-bar .demo-badge {
    padding: 4px 10px;
    border: 1px solid #f39c12;
    border-radius: 999px;
    color: #f39c12;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.alert-warning .alert-message a {
    color: #fff;
    font-weight: 700;
    text-decoration: underline;
}
