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

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    position: fixed;
}

/* Asegurar que los contenedores de Leaflet respeten el z-index */
.leaflet-container {
    z-index: 1 !important;
}

/* NO sobrescribir el z-index de los panes - Leaflet los gestiona automáticamente */

/* ============================================================================
   PANTALLA DE CARGA - UBICACIÓN
   ============================================================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 18, 35, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-overlay-spinner {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(102, 200, 255, 0.15);
    border-top-color: rgb(102, 200, 255);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 20px rgba(102, 200, 255, 0.3);
}

.loading-overlay-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: rgba(102, 200, 255, 0.7);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Asegurar que los elementos del mapa y paneles no sean visibles hasta que se oculta el overlay */
.loading-overlay + #map,
.loading-overlay + #map ~ .top-bar,
.loading-overlay + #map ~ .bottom-panel,
.loading-overlay + #map ~ .layer-switcher {
    visibility: hidden;
}

.loading-overlay.hidden + #map,
.loading-overlay.hidden + #map ~ .top-bar,
.loading-overlay.hidden + #map ~ .bottom-panel,
.loading-overlay.hidden + #map ~ .layer-switcher {
    visibility: visible;
}

/* Barra superior con título - TEMA HOLOGRÁFICO */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(8, 18, 35, 0.75);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 10px 16px;
    box-shadow: 0 0 0 1px rgba(102, 200, 255, 0.35);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-title {
    font-size: 16px;
    font-weight: 300;
    font-family: 'Rajdhani', sans-serif;
    color: rgb(102, 200, 255);
    text-align: center;
    margin: 0;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(102, 200, 255, 0.7);
}

/* Botón de instalación PWA */
.install-btn {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 5px;
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.12) 0%, rgba(102, 200, 255, 0.05) 100%);
    border: 1px solid rgba(102, 200, 255, 0.3);
    border-radius: 6px;
    padding: 4px 8px 4px 5px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.install-btn-logo {
    width: 22px;
    height: 22px;
    display: block;
    filter: drop-shadow(0 0 4px rgba(102, 200, 255, 0.4));
}

.install-btn-label {
    font-size: 9px;
    font-weight: 600;
    font-family: 'Rajdhani', sans-serif;
    color: rgba(102, 200, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1;
}

.install-btn:hover {
    border-color: rgba(102, 200, 255, 0.55);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.2) 0%, rgba(102, 200, 255, 0.1) 100%);
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.2);
}

.install-btn:active {
    border-color: rgba(102, 200, 255, 0.7);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.25) 0%, rgba(102, 200, 255, 0.12) 100%);
}

/* Overlay de instrucciones de instalación (Safari) */
.install-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    padding-bottom: 40px;
}

.install-overlay-content {
    background: rgba(8, 18, 35, 0.92);
    border: 1px solid rgba(102, 200, 255, 0.35);
    border-radius: 12px;
    padding: 24px 28px 20px;
    max-width: 320px;
    width: calc(100% - 32px);
    text-align: center;
    box-shadow: 0 0 24px rgba(102, 200, 255, 0.15);
}

.install-overlay-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: rgb(102, 200, 255);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 16px;
    text-shadow: 0 0 8px rgba(102, 200, 255, 0.5);
}

.install-overlay-step {
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    color: rgba(102, 200, 255, 0.75);
    margin: 0 0 10px;
    line-height: 1.4;
}

.install-overlay-step strong {
    color: rgba(102, 200, 255, 0.95);
    font-weight: 600;
}

.install-overlay-share {
    color: rgba(102, 200, 255, 0.95);
    font-weight: 600;
}

.install-overlay-share-icon {
    margin: 12px 0;
    color: rgb(102, 200, 255);
    filter: drop-shadow(0 0 6px rgba(102, 200, 255, 0.4));
}

.install-overlay-close {
    margin-top: 14px;
    padding: 7px 24px;
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.15) 0%, rgba(102, 200, 255, 0.08) 100%);
    border: 1px solid rgba(102, 200, 255, 0.35);
    border-radius: 6px;
    color: rgb(102, 200, 255);
    font-family: 'Rajdhani', sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.install-overlay-close:hover {
    border-color: rgba(102, 200, 255, 0.55);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.22) 0%, rgba(102, 200, 255, 0.1) 100%);
}

/* Mapa vuelve a ocupar TODA la pantalla */
#map {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
}

/* Mover controles de zoom debajo del panel superior */
.leaflet-top.leaflet-left {
    top: 50px !important; /* 40px del panel + 10px de margen */
}

/* Control de capas en la derecha - debajo del panel superior */
.leaflet-top.leaflet-right {
    top: 50px !important;
}

/* Ocultar control de capas de Leaflet por defecto (no lo usamos) */
.leaflet-control-layers {
    display: none !important;
}

/* ============================================================================
   CONTROL DE CAPAS CUSTOM - TEMA HOLOGRÁFICO
   ============================================================================ */

.layer-switcher {
    position: fixed;
    top: 50px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2000;
}

.layer-btn {
    width: 38px;
    height: 38px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid rgba(102, 200, 255, 0.35);
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(102, 200, 255, 0.15);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    overflow: hidden;
}

#layerBtnPnoa {
    background-image: url('https://www.ign.es/wms-inspire/pnoa-ma?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=OI.OrthoimageCoverage&STYLES=&FORMAT=image/png&TRANSPARENT=false&WIDTH=64&HEIGHT=64&SRS=EPSG:4326&BBOX=-3.75,40.38,-3.68,40.45');
}

#layerBtnOsm {
    background-image: url('https://tile.openstreetmap.org/15/16370/12190.png');
}

.layer-btn:hover {
    border-color: rgba(102, 200, 255, 0.6);
    box-shadow: 0 0 10px rgba(102, 200, 255, 0.25);
}

.layer-btn.active {
    border-color: rgba(102, 200, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(102, 200, 255, 0.4), 0 0 10px rgba(102, 200, 255, 0.2);
}

/* ============================================================================
   CONTROLES DE ZOOM DE LEAFLET - TEMA HOLOGRÁFICO
   ============================================================================ */

/* Contenedor de controles zoom */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: none !important;
    border-radius: 4px !important;
    overflow: hidden;
}

/* Botones zoom +/- */
.leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    background: rgba(8, 18, 35, 0.75) !important;
    border-bottom: 1px solid rgba(102, 200, 255, 0.2) !important;
    color: rgb(102, 200, 255) !important;
    font-size: 18px !important;
    line-height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s;
    box-shadow: 0 0 0 1px rgba(102, 200, 255, 0.35);
}

.leaflet-control-zoom a:first-child {
    border-radius: 4px 4px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 4px 4px !important;
    border-bottom: none !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(102, 200, 255, 0.12) !important;
    color: rgb(102, 200, 255) !important;
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.25);
}

/* Panel inferior - TEMA HOLOGRÁFICO */
.bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 60px;
    max-height: 80vh;
    background: rgba(8, 18, 35, 0.75);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    box-shadow: 0 0 0 1px rgba(102, 200, 255, 0.35);
    z-index: 2000;
    padding: 40px 16px 16px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease-out;
}

/* Estado colapsado - OCULTAR TODO EL CONTENIDO */
.bottom-panel.collapsed {
    height: 35px !important;
    min-height: 35px !important;
    max-height: 35px !important;
    overflow: hidden !important;
    padding: 0 !important;
}

/* Ocultar todo el contenido del formulario cuando está colapsado */
.bottom-panel.collapsed .search-form,
.bottom-panel.collapsed .result-message,
.bottom-panel.collapsed .error-message,
.bottom-panel.collapsed .loading {
    display: none !important;
}

/* Handle para arrastrar el panel - AJUSTAR POSICIÓN */
.panel-handle {
    position: absolute;
    top: 5px; /* Más arriba (antes 8px) */
    left: 0;
    right: 0;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: grab;
    user-select: none;
    z-index: 10;
}

.panel-handle:active {
    cursor: grabbing;
}

/* Barra visual del handle */
.handle-bar {
    width: 60px;
    height: 3px;
    background: rgba(102, 200, 255, 0.35);
    border-radius: 3px;
    transition: all 0.2s;
}

.panel-handle:hover .handle-bar {
    background: rgba(102, 200, 255, 0.7);
    height: 3px;
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.4);
}

/* Formulario - LAYOUT RESPONSIVE MEJORADO */
.search-form {
    display: grid;
    grid-template-columns: 1fr auto 1fr 80px;
    gap: 10px;
    align-items: start;
}

/* Responsive para móviles - 3 INPUTS EN UNA FILA */
@media (max-width: 768px) {
    .search-form {
        grid-template-columns: 1fr auto 1fr; /* carretera | sentido centrado | pk */
        gap: 8px;
    }
    
    .search-btn {
        grid-column: 1 / -1; /* Botón ocupa toda la fila */
        margin-top: 4px;
    }
}

/* Para pantallas muy pequeñas, ajustar tamaño de inputs */
@media (max-width: 480px) {
    .input-group label {
        font-size: 8px;
    }
    
    .input-field {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .search-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
}

/* Input groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 9px;
    font-weight: 600;
    color: rgba(102, 200, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Rajdhani', sans-serif;
}

.input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(102, 200, 255, 0.25);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.08) 0%, rgba(102, 200, 255, 0.04) 100%);
    color: rgb(102, 200, 255);
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.input-field::placeholder {
    color: rgba(102, 200, 255, 0.35);
}

.input-field:focus {
    outline: none;
    border-color: rgba(102, 200, 255, 0.6);
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.2);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.12) 0%, rgba(102, 200, 255, 0.06) 100%);
}

/* Sentido toggle buttons */
.sentido-toggle {
    display: flex;
    gap: 6px;
}

.sentido-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.sentido-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(102, 200, 255, 0.25);
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.08) 0%, rgba(102, 200, 255, 0.04) 100%);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.sentido-btn .animated-arrow {
    height: 20px;
    margin: 0;
}

.sentido-btn .animated-arrow::before {
    height: 14px;
}

.sentido-btn .sentido-creciente .arrow-head {
    border-width: 0 4px 5px 4px;
}

.sentido-btn .sentido-decreciente .arrow-head {
    border-width: 5px 4px 0 4px;
}

.sentido-btn-label {
    font-size: 6px;
    color: rgba(102, 200, 255, 0.85);
    font-weight: 500;
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.3px;
    line-height: 1.1;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Deshabilitar animaciones dentro de los botones de sentido */
.sentido-btn .arrow-head {
    animation: none !important;
    filter: none !important;
    opacity: 1 !important;
}

.sentido-btn .animated-arrow::after {
    animation: none !important;
    opacity: 0 !important;
}

.sentido-btn:hover {
    border-color: rgba(102, 200, 255, 0.45);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.14) 0%, rgba(102, 200, 255, 0.08) 100%);
}

.sentido-btn.active {
    border-color: rgba(102, 200, 255, 0.6);
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.2);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.22) 0%, rgba(102, 200, 255, 0.1) 100%);
}

/* Botón de búsqueda - TEMA HOLOGRÁFICO */
.search-btn {
    align-self: end;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.15) 0%, rgba(102, 200, 255, 0.08) 100%);
    color: rgb(102, 200, 255);
    border: 1px solid rgba(102, 200, 255, 0.35);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px;
    position: relative;
}

.search-btn:hover {
    transform: translateY(0);
    border-color: rgba(102, 200, 255, 0.6);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.22) 0%, rgba(102, 200, 255, 0.12) 100%);
    box-shadow: 0 0 12px rgba(102, 200, 255, 0.25);
    color: rgb(102, 200, 255);
}

.search-btn:active {
    transform: translateY(0);
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.3) 0%, rgba(102, 200, 255, 0.18) 100%);
}

.search-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(102, 200, 255, 0.2);
    border-top-color: rgb(102, 200, 255);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Autocompletado */
.autocomplete-container {
    position: relative;
}

.autocomplete-results {
    position: fixed !important;
    bottom: auto;
    top: auto;
    left: auto;
    right: auto;
    background: rgba(8, 18, 35, 0.9) !important;
    border: 1px solid rgba(102, 200, 255, 0.35) !important;
    border-radius: 4px !important;
    max-height: 200px !important;
    max-width: none;
    overflow-y: auto !important;
    z-index: 20000 !important;
    box-shadow: 0 0 0 1px rgba(102, 200, 255, 0.2), 0 8px 24px rgba(0, 0, 0, 0.5) !important;
    pointer-events: auto !important;
    transform: translateZ(0) !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
}

.autocomplete-results.show {
    display: block !important;
}

.autocomplete-item {
    padding: 10px 12px !important;
    cursor: pointer !important;
    border-bottom: 1px solid rgba(102, 200, 255, 0.12) !important;
    transition: background-color 0.2s !important;
    font-size: 13px !important;
    background: transparent !important;
    color: rgb(102, 200, 255) !important;
    transform: translateZ(0) !important;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: rgba(102, 200, 255, 0.08) !important;
}

.autocomplete-item-name {
    font-weight: 600 !important;
    color: rgb(102, 200, 255) !important;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.5px;
}

.autocomplete-item-info {
    font-size: 11px !important;
    color: rgba(102, 200, 255, 0.5) !important;
    margin-top: 2px !important;
    font-family: 'Rajdhani', sans-serif;
}

/* Mensajes de resultado y error - TEMA HOLOGRÁFICO */
.result-message,
.error-message {
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    font-family: 'Rajdhani', sans-serif;
}

.result-message {
    background: linear-gradient(135deg, rgba(102, 200, 255, 0.08) 0%, rgba(102, 200, 255, 0.04) 100%);
    color: rgb(102, 200, 255);
    border: 1px solid rgba(102, 200, 255, 0.25);
}

.error-message {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1) 0%, rgba(251, 146, 60, 0.05) 100%);
    color: rgba(251, 146, 60, 0.9);
    border: 1px solid rgba(251, 146, 60, 0.3);
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(102, 200, 255, 0.15);
    border-top-color: rgb(102, 200, 255);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    box-shadow: 0 0 8px rgba(102, 200, 255, 0.3);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 60px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    animation: slideInRight 0.3s ease-out;
}

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

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast.warning {
    border-left: 4px solid #ffc107;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0;
    margin-left: auto;
}

/* Forzar que cuando NO esté en focus, vuelva al estilo holográfico */
.input-field:not(:focus) {
    border-color: rgba(102, 200, 255, 0.25) !important;
    box-shadow: none !important;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 14px;
    font-size: 13px;
    line-height: 1.5;
}

.leaflet-popup-content strong {
    color: #667eea;
}

/* Forzar z-index alto para popups */
.leaflet-popup-pane {
    z-index: 5000 !important;
}

.leaflet-popup {
    z-index: 5000 !important;
}

/* Asegurar que la punta del popup también sea visible */
.leaflet-popup-tip-container {
    z-index: 5000 !important;
}

/* Cuando tiene altura automática basada en contenido */
/* ============================================================================
   POPUP HOLOGRÁFICO - Estilo minimalista con 4 esquinas marcadas
   ============================================================================ */

/* Importar fuentes modernas */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap');

/* Override de estilos base de Leaflet popup */
.leaflet-popup-content-wrapper {
    background: rgba(8, 18, 35, 0.75) !important; /* Estilo correcto por defecto - 75% opaco */
    backdrop-filter: none !important; /* SIN blur */
    -webkit-backdrop-filter: none !important;
    border-radius: 6px !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(102, 200, 255, 0.35) !important;
    padding: 0 !important;
    overflow: visible !important;
    position: relative !important;
    animation: popupAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes popupAppear {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
    width: auto !important;
}

/* Container ultra compacto */
.popup-compact {
    position: relative;
    padding: 9px;
    min-width: 150px;
    max-width: 150px;
}

/* 4 ESQUINAS MARCADAS - Estilo del botón Google Maps */
.popup-compact::before,
.popup-compact::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 6px;
    pointer-events: none;
    background: transparent;
}

/* Esquina superior izquierda */
.popup-compact::before {
    top: -1px;
    left: -1px;
    border-radius: 6px 0 0 0;
    border: none;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
}

/* Esquina inferior derecha */
.popup-compact::after {
    bottom: -1px;
    right: -1px;
    border-radius: 0 0 6px 0;
    border: none;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
}

/* Esquinas adicionales usando pseudo-elementos del wrapper */
.leaflet-popup-content-wrapper::before,
.leaflet-popup-content-wrapper::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 6px;
    pointer-events: none;
    z-index: 10;
    background: transparent;
}

/* Esquina superior derecha */
.leaflet-popup-content-wrapper::before {
    top: -1px;
    right: -1px;
    border-radius: 0 6px 0 0;
    border: none;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
}

/* Esquina inferior izquierda */
.leaflet-popup-content-wrapper::after {
    bottom: -1px;
    left: -1px;
    border-radius: 0 0 0 6px;
    border: none;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
}

/* Efecto de escaneo holográfico muy sutil */
.popup-glow-effect {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(102, 200, 255, 0.02) 50%,
        transparent 100%
    );
    animation: scanLine 5s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes scanLine {
    0%, 100% {
        transform: translateY(-100%);
    }
    50% {
        transform: translateY(100%);
    }
}

/* Nombre de la carretera - EN PANEL CON ESQUINAS - MISMO FORMATO QUE PK */
.popup-road-name {
    font-size: 21px;
    font-weight: 300; /* Mismo peso que el PK */
    font-family: 'Rajdhani', sans-serif;
    color: rgb(102, 200, 255);
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(102, 200, 255, 0.7); /* Mismo glow que el PK */
    position: relative;
    z-index: 1;
    padding: 6px 8px;
    background: linear-gradient(135deg,
        rgba(102, 200, 255, 0.08) 0%, /* Fondo más visible */
        rgba(102, 200, 255, 0.04) 100%);
    /* backdrop-filter: blur(10px); */ /* Mantiene blur en paneles internos */
    /* -webkit-backdrop-filter: blur(10px); */
    border: 1px solid rgba(102, 200, 255, 0.3);
    border-radius: 4px;
}

/* Esquinas para el panel del nombre */
.popup-road-name::before,
.popup-road-name::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 6px;
    pointer-events: none;
    background: transparent;
}

.popup-road-name::before {
    top: -1px;
    left: -1px;
    border-radius: 6px 0 0 0;
    border: none;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
}

.popup-road-name::after {
    bottom: -1px;
    right: -1px;
    border-radius: 0 0 6px 0;
    border: none;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
}

/* Grid compacto */
.popup-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 3px;
    background: linear-gradient(135deg,
        rgba(102, 200, 255, 0.08) 0%, /* Más visible */
        rgba(102, 200, 255, 0.04) 100%);
    /* backdrop-filter: blur(10px); */ /* Mantiene blur en paneles internos */
    /* -webkit-backdrop-filter: blur(10px); */
    border: 1px solid rgba(102, 200, 255, 0.25);
    border-radius: 4px;
    min-height: 60px;
    position: relative;
}

/* Esquina superior izquierda */
.info-item::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 12px;
    height: 12px;
    border-radius: 6px 0 0 0;
    border: none;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
    pointer-events: none;
    background: transparent;
}

/* Esquina inferior derecha */
.info-item::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 0 0 6px 0;
    border: none;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
    pointer-events: none;
    background: transparent;
}

.info-label {
    font-size: 7px;
    color: rgba(102, 200, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    font-family: 'Rajdhani', sans-serif;
}

/* ============================================================================
   FLECHA ANIMADA VERTICAL CONTINUA (LÍNEA SÓLIDA)
   ============================================================================ */

.animated-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0; /* Sin gaps, línea continua */
    height: 28px;
    position: relative;
    margin: 2px 0;
}

/* Línea vertical continua */
.arrow-segment {
    display: none; /* Ocultamos los segmentos individuales */
}

/* Crear línea vertical continua con ::before */
.animated-arrow::before {
    content: '';
    position: absolute;
    width: 3px;
    height: 21px; /* Línea continua */
    background: rgba(102, 200, 255, 0.2);
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
}

/* Animación de relleno sobre la línea */
.animated-arrow::after {
    content: '';
    position: absolute;
    width: 3px;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
}

/* Punta de la flecha hacia ARRIBA (creciente) */
.sentido-creciente .arrow-head {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 5px 6px 5px;
    border-color: transparent transparent rgba(34, 211, 238, 0.9) transparent;
    animation: arrowHeadGlow 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.7));
    position: absolute;
    top: 0;
}

/* Punta de la flecha hacia ABAJO (decreciente) */
.sentido-decreciente .arrow-head {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 5px 0 5px;
    border-color: rgba(251, 146, 60, 0.9) transparent transparent transparent;
    animation: arrowHeadGlow 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 5px rgba(251, 146, 60, 0.7));
    position: absolute;
    bottom: 0;
}

/* ANIMACIÓN PARA SENTIDO CRECIENTE (Cian hacia arriba) */
.sentido-creciente .animated-arrow::after {
    background: linear-gradient(180deg, 
        rgb(34, 211, 238),
        rgba(34, 211, 238, 0.7),
        transparent
    );
    animation: arrowFillUp 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.7);
    height: 21px;
}

/* ANIMACIÓN PARA SENTIDO DECRECIENTE (Naranja hacia abajo) */
.sentido-decreciente .animated-arrow::after {
    background: linear-gradient(180deg, 
        transparent,
        rgba(251, 146, 60, 0.7),
        rgb(251, 146, 60)
    );
    animation: arrowFillDown 1.5s ease-in-out infinite;
    box-shadow: 0 0 6px rgba(251, 146, 60, 0.7);
    height: 21px;
}

/* Animación de relleno hacia ARRIBA */
@keyframes arrowFillUp {
    0% {
        height: 0;
        opacity: 0;
        bottom: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        height: 21px;
        opacity: 0;
        bottom: 0;
    }
}

/* Animación de relleno hacia ABAJO */
@keyframes arrowFillDown {
    0% {
        height: 0;
        opacity: 0;
        top: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        height: 21px;
        opacity: 0;
        top: 0;
    }
}

/* Animación de la punta */
@keyframes arrowHeadGlow {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

/* Texto del sentido */
.info-value-text {
    font-size: 8px;
    color: rgba(102, 200, 255, 0.85);
    font-weight: 500;
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.3px;
    line-height: 1.1;
}

/* Valor grande (PK) */
.info-value-large {
    font-size: 21px;
    font-weight: 300;
    color: rgb(102, 200, 255);
    text-shadow: 0 0 10px rgba(102, 200, 255, 0.7);
    line-height: 1;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 1px;
}

.info-unit {
    font-size: 7px;
    color: rgba(102, 200, 255, 0.6);
    font-weight: 400;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.5px;
}

/* ============================================================================
   BOTÓN DE GOOGLE MAPS
   ============================================================================ */

.gmaps-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 auto;
    background: linear-gradient(135deg, 
        rgba(102, 200, 255, 0.08) 0%, 
        rgba(102, 200, 255, 0.04) 100%);
    /* backdrop-filter: blur(10px); */ /* Mantiene blur en paneles internos */
    /* -webkit-backdrop-filter: blur(10px); */
    border: 1px solid rgba(102, 200, 255, 0.35);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.gmaps-icon-btn::before,
.gmaps-icon-btn::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 6px;
    transition: all 0.3s;
    background: transparent; /* Sin fondo */
}

.gmaps-icon-btn::before {
    top: -1px;
    border-radius: 6px 0 0 0;
    left: -1px;
    border: none;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
}

.gmaps-icon-btn::after {
    border-radius: 0 0 6px 0;
    bottom: -1px;
    right: -1px;
    border: none;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
}

.gmaps-icon-btn:hover {
    transform: translateY(-2px);
    border-color: rgba(102, 200, 255, 0.6);
    background: rgba(102, 200, 255, 0.12);
    box-shadow: 
        0 4px 12px rgba(102, 200, 255, 0.3),
        0 0 20px rgba(102, 200, 255, 0.2);
}

.gmaps-icon-btn:hover::before,
.gmaps-icon-btn:hover::after {
    width: 16px;
    height: 16px;
    box-shadow: 0 0 10px rgba(102, 200, 255, 0.8);
    background: transparent; /* Mantener sin fondo en hover */
}

.gmaps-icon-btn img {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

/* Punta del popup - OCULTA */
.leaflet-popup-tip-container {
    display: none !important;
}

.leaflet-popup-tip {
    display: none !important;
}

/* Botón de cerrar - OCULTO (se cierra clickando fuera) */
.leaflet-popup-close-button {
    display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
    .popup-compact {
        min-width: 140px;
        max-width: 140px;
    }
    
    .popup-road-name {
        font-size: 16px;
    }
    
    .info-value-large {
        font-size: 19px;
    }
}

/* Esquinas adicionales para botón Google Maps (superior derecha e inferior izquierda) */
.gmaps-icon-btn {
    overflow: visible;

/* ============================================================================
   ESTILOS CONDICIONALES SEGÚN CAPA BASE ACTIVA
   ============================================================================ */

/* ============================================================================
   MARCADOR PERSONALIZADO FUTURISTA
   ============================================================================ */

/* Forzar visibilidad del marcador de Leaflet */
.leaflet-marker-icon {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    z-index: 1000 !important;
}

.custom-marker {
    background: transparent !important;
    border: none !important;
    opacity: 1 !important;
}

/* Marcador SVG */
.custom-marker-svg {
    background: transparent !important;
    border: none !important;
    opacity: 1 !important;
}

.marker-pin {
    position: relative;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    animation: markerDrop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation-fill-mode: forwards;
    opacity: 1 !important; /* Asegurar que siempre sea visible */
    visibility: visible !important;
}

/* Asegurar que los elementos internos también sean visibles */
.marker-glow,
.marker-icon {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Animación de caída del marcador */
@keyframes markerDrop {
    0% {
        transform: translateY(-200px) scale(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Efecto de resplandor pulsante detrás del marcador */
.marker-glow {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(
        circle,
        rgba(102, 200, 255, 0.6) 0%,
        rgba(102, 200, 255, 0.3) 40%,
        transparent 70%
    );
    border-radius: 50%;
    animation: markerPulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes markerPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Icono del marcador */
.marker-icon {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    background: linear-gradient(135deg, rgb(102, 200, 255) 0%, rgb(34, 211, 238) 100%) !important;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 
        0 4px 15px rgba(102, 200, 255, 0.6),
        0 0 30px rgba(102, 200, 255, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    animation: markerRotate 3s ease-in-out infinite;
    position: relative; /* Asegurar posicionamiento */
    z-index: 10; /* Asegurar que esté visible */
    opacity: 1 !important;
    visibility: visible !important;
}

/* El emoji dentro debe rotar de vuelta para quedar vertical */
.marker-icon::after {
    content: '📍';
    transform: rotate(45deg);
    display: block;
    font-size: 22px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

@keyframes markerRotate {
    0%, 100% {
        transform: rotate(-45deg) scale(1);
    }
    50% {
        transform: rotate(-45deg) scale(1.1);
    }
}

/* Ondas expansivas al hacer click */
.marker-pin::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid rgba(102, 200, 255, 0.5);
    border-radius: 50%;
    animation: ripple 1.5s ease-out infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Al hacer hover en el marcador */
.custom-marker:hover .marker-icon {
    animation: markerBounce 0.6s ease-in-out;
    box-shadow: 
        0 6px 20px rgba(102, 200, 255, 0.8),
        0 0 50px rgba(102, 200, 255, 0.6),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

@keyframes markerBounce {
    0%, 100% {
        transform: rotate(-45deg) translateY(0);
    }
    50% {
        transform: rotate(-45deg) translateY(-10px);
    }
}
/* CAPA OSM (clara) - Fondo oscuro para buen contraste (por defecto es este) */
body.layer-osm .leaflet-popup.tech-popup-compact .leaflet-popup-content-wrapper {
    background: rgba(8, 18, 35, 0.75) !important; /* 75% opaco - Contraste óptimo */
}

body.layer-osm .leaflet-popup.tech-popup-compact .leaflet-popup-tip {
    background: rgba(8, 18, 35, 0.75) !important; /* Mismo tono */
}

/* Si el selector anterior no funciona, intentar sin la clase del popup */
body.layer-osm .leaflet-popup-content-wrapper {
    background: rgba(8, 18, 35, 0.75) !important; /* 75% opaco */
}

body.layer-osm .leaflet-popup-tip {
    background: rgba(8, 18, 35, 0.75) !important; /* Mismo tono */
}

/* CAPA PNOA (oscura) - Fondo semi-oscuro */
body.layer-pnoa .leaflet-popup.tech-popup-compact .leaflet-popup-content-wrapper {
    background: rgba(5, 15, 30, 0.55) !important; /* 55% opaco - deja ver satélite */
}

body.layer-pnoa .leaflet-popup.tech-popup-compact .leaflet-popup-tip {
    background: rgba(5, 15, 30, 0.55) !important; /* Mismo tono */
}

/* Si el selector anterior no funciona, intentar sin la clase del popup */
body.layer-pnoa .leaflet-popup-content-wrapper {
    background: rgba(5, 15, 30, 0.55) !important; /* 55% opaco */
}

body.layer-pnoa .leaflet-popup-tip {
    background: rgba(5, 15, 30, 0.55) !important; /* Mismo tono */
}

/* Los paneles internos mantienen su blur y opacidad en ambos casos */}

/* ============================================================================
   ESQUINAS ADICIONALES (superior derecha e inferior izquierda)
   Inyectadas vía JavaScript para completar las 4 esquinas
   ============================================================================ */

.corner-extra {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border: none;
    pointer-events: none;
    background: transparent;
}

/* Esquina superior derecha */
.corner-tr {
    top: -1px;
    right: -1px;
    border-top: 2px solid rgba(102, 200, 255, 0.8);
    border-right: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 0 6px 0 0;
}

/* Esquina inferior izquierda */
.corner-bl {
    bottom: -1px;
    left: -1px;
    border-bottom: 2px solid rgba(102, 200, 255, 0.8);
    border-left: 2px solid rgba(102, 200, 255, 0.8);
    border-radius: 0 0 0 6px;
}

/* Hover para botón gmaps - las esquinas adicionales también crecen */
.gmaps-icon-btn:hover .corner-tr,
.gmaps-icon-btn:hover .corner-bl {
    width: 16px;
    height: 16px;
}

/* Asegurar que los hover del botón gmaps incluyen todas las esquinas */
.gmaps-icon-btn:hover::before,
.gmaps-icon-btn:hover::after {
    width: 16px;
    height: 16px;
}