* { box-sizing: border-box; }
html, body {
    height: 100%;
    overflow: hidden;
    margin: 0;
    font-family: Arial, sans-serif;
}
body {
    overflow: hidden;
}
#mapa {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}
.titulo-flotante {
    position: fixed;
    top: 16px;
    left: 48px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    padding: 8px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    font-size: 15px;
    font-weight: bold;
    color: #0f172a;
}
.titulo-flotante .hora-flotante {
    font-size: 11px;
    font-weight: normal;
    color: #64748b;
    border-left: 1px solid #e2e8f0;
    padding-left: 10px;
}
.titulo-flotante.modo-historico {
    background: rgba(245, 243, 255, 0.96);
    border: 1px solid #ddd6fe;
}
.titulo-flotante.modo-historico .hora-flotante {
    color: #6d28d9;
    font-weight: bold;
    border-left-color: #ddd6fe;
}
.panel-datos {
    position: fixed;
    top: 64px;
    left: 48px;
    z-index: 999;
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 6px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    padding: 8px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.dato-panel {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    min-width: 100px;
}
.etiqueta-panel {
    display: block;
    font-size: 9px;
    font-weight: bold;
    text-transform: uppercase;
    color: #64748b;
}
.valor-panel {
    font-size: 14px;
    font-weight: bold;
    color: #0f172a;
    white-space: nowrap;
}
#panelVelocidad {
    color: #AF043C;
}
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 280px;
    z-index: 1000;
    background: linear-gradient(165deg, #AF043C, #7A022A);
    color: #fff5f7;
    padding: 22px 18px;
    overflow-y: auto;
    box-shadow: 6px 0 24px rgba(0,0,0,0.25);
    transition: transform 0.3s ease;
    transform: translateX(-100%);
}
.sidebar.abierta {
    transform: translateX(0);
}
.toggle-btn {
    position: fixed;
    top: 16px;
    left: 0px;
    z-index: 1001;
    background: #AF043C;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 15px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
    transition: left 0.3s ease;
}
.titulo-sidebar {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}
.estado-vivo {
    font-size: 12px;
    color: #ffe4e9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 14px 0 18px;
}
.punto {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 6px #22c55e;
}
.seccion {
    margin-bottom: 20px;
}
.seccion-titulo {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffe4e9;
    font-weight: bold;
    margin-bottom: 10px;
}
.datos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.dato-item {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 8px 10px;
}
.dato-item .etiqueta {
    display: block;
    font-size: 9px;
    color: #ffe4e9;
    font-weight: bold;
    text-transform: uppercase;
}
.dato-item .valor {
    font-size: 12px;
    font-weight: bold;
    color: #ffffff;
    word-break: break-all;
}
.campo-fecha {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    color: #0f172a;
    margin-bottom: 8px;
}
label {
    font-size: 11px;
    color: #ffe4e9;
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}
.btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 4px;
}
.btn-ver {
    background: #0f172a;
    color: white;
}
.btn-volver {
    background: rgba(255,255,255,0.18);
    color: white;
    display: none;
}
.lista-recorridos {
    margin-top: 12px;
}
.lista-titulo {
    font-size: 11px;
    color: #ffe4e9;
    font-weight: bold;
    margin-bottom: 6px;
}
.item-recorrido {
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 6px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.12);
    color: white;
    font-size: 12px;
    cursor: pointer;
}
.item-recorrido.activo {
    background: #7c3aed;
    border-color: #7c3aed;
    font-weight: bold;
}
.flatpickr-day.selected {
    background: #AF043C;
    border-color: #AF043C;
}
.leaflet-popup-content ul {
    margin: 4px 0;
    padding-left: 18px;
}
.veces-popup {
    margin: 4px 0 6px;
}
.veces-popup summary {
    cursor: pointer;
    color: #AF043C;
    font-weight: bold;
}
.veces-popup ul {
    max-height: 140px;
    overflow-y: auto;
}
.aviso-lugar {
    display: none;
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: #AF043C;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    pointer-events: none;
}
#mapa.modo-lugar {
    cursor: crosshair;
}
.btn-marcar {
    display: block;
    margin: 8px auto 0;
    padding: 7px 14px;
    border: none;
    border-radius: 20px;
    background: #AF043C;
    color: white;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}
.titulo-tiempo {
    text-align: center;
    font-size: 11px;
    color: #64748b;
    margin-bottom: 2px;
}
.barra-tiempo {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: min(520px, calc(100% - 32px));
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 16px 12px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.texto-tiempo {
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    color: #0f172a;
    margin-bottom: 6px;
}
#sliderTiempo {
    width: 100%;
    accent-color: #AF043C;
    cursor: pointer;
}

@media (max-width: 600px) {
    .titulo-flotante {
        right: 60px;
        flex-wrap: wrap;
        gap: 2px 8px;
        padding: 6px 12px;
        font-size: 14px;
    }
    .titulo-flotante .hora-flotante {
        border-left: none;
        padding-left: 0;
    }
    .panel-datos {
        top: 84px;
        left: 12px;
        right: 12px;
        grid-template-columns: 1fr 1fr;
    }
    .dato-panel {
        min-width: 0;
    }
    .barra-tiempo {
        bottom: calc(12px + env(safe-area-inset-bottom));
    }
    #sliderTiempo {
        height: 28px;
    }
    .aviso-lugar {
        bottom: calc(150px + env(safe-area-inset-bottom));
    }
}