.records-page {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    min-height: 100vh;
    padding: 40px 0;
}

@media (max-width: 768px) {
    .records-page {
        padding: 10px 0 30px 0;
    }
}

.records-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ════════════════════════════════════════════
   Header
   ════════════════════════════════════════════ */
.records-header {
    text-align: center;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border-radius: 20px;
    padding: 30px 40px;
    box-shadow: 0 10px 40px rgba(79, 70, 229, 0.3);
}

@media (max-width: 768px) {
    .records-header {
        border-radius: 16px;
        padding: 20px;
        margin: 0 10px 24px 10px;
    }
}

.records-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

@media (max-width: 768px) {
    .records-title { font-size: 1.6rem; }
}

.records-date {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
}

/* ════════════════════════════════════════════
   Mapa interactivo
   ════════════════════════════════════════════ */
.map-section {
    margin-bottom: 40px;
}

.map-wrapper {
    position: relative;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    height: 600px;
}

@media (max-width: 768px) {
    .map-wrapper {
        height: 480px;
        border-radius: 16px;
        margin: 0 10px;
    }
}

#recordsMap {
    width: 100%;
    height: 100%;
}

.mapboxgl-ctrl-logo { display: none !important; }
.mapboxgl-ctrl-attrib { font-size: 9px !important; opacity: 0.5; }

/* Controles flotantes — toggle de capas */
.layer-controls {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 220px;
}

@media (max-width: 768px) {
    .layer-controls {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
        gap: 4px;
    }
}

.layer-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    user-select: none;
    flex: 1;
    min-width: 0;
}

.layer-toggle:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.layer-toggle.active {
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.layer-toggle.active.calor   { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.layer-toggle.active.frio    { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.layer-toggle.active.tornado { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }
.layer-toggle.active.granizo { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.layer-toggle.active.viento  { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.layer-toggle.active.maximos { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }

.layer-toggle .toggle-icon {
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.layer-toggle .toggle-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-toggle .toggle-count {
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.layer-toggle.active .toggle-count {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

@media (max-width: 768px) {
    .layer-toggle {
        padding: 6px 8px;
        font-size: 0.75rem;
    }
    .layer-toggle .toggle-label { display: none; }
    .layer-toggle .toggle-icon { font-size: 1rem; }
}

/* Marcadores HTML personalizados */
.cm-marker {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    cursor: pointer;
    border: 2.5px solid white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.cm-marker:hover {
    transform: scale(1.15);
    z-index: 100;
}

.cm-marker.calor   { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); }
.cm-marker.frio    { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.cm-marker.tornado { background: linear-gradient(135deg, #f97316 0%, #c2410c 100%); }
.cm-marker.granizo { background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%); }
.cm-marker.viento  { background: linear-gradient(135deg, #22c55e 0%, #15803d 100%); }
.cm-marker.maximos { background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); }

/* Marcadores destacados (récord de calor/frío y máximos del día) un poco más grandes */
.cm-marker.featured {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    border-width: 3px;
    /* El halo pulsante se hace con box-shadow animado en vez de un ::after
       con position:absolute + transform:scale, porque esa combinación rompe el
       cálculo de posicionamiento que Mapbox hace para HTML markers en zooms bajos. */
    animation: cmPulse 2.5s ease-out infinite;
}

@keyframes cmPulse {
    0% {
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.4),
            0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    100% {
        box-shadow:
            0 4px 16px rgba(0, 0, 0, 0.4),
            0 0 0 18px rgba(255, 255, 255, 0);
    }
}

/* Popups Mapbox personalizados */
.mapboxgl-popup-content {
    border-radius: 14px !important;
    padding: 0 !important;
    overflow: hidden;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18) !important;
    font-family: var(--font-body, system-ui, sans-serif);
}

.mapboxgl-popup-close-button {
    font-size: 1.4rem !important;
    padding: 4px 10px 6px !important;
    color: white !important;
    z-index: 2;
}

.cm-popup-head {
    padding: 10px 14px;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cm-popup-head.calor   { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); }
.cm-popup-head.frio    { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.cm-popup-head.tornado { background: linear-gradient(135deg, #f97316 0%, #c2410c 100%); }
.cm-popup-head.granizo { background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%); }
.cm-popup-head.viento  { background: linear-gradient(135deg, #22c55e 0%, #15803d 100%); }
.cm-popup-head.maximos { background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); }

.cm-popup-body {
    padding: 12px 14px 14px;
    min-width: 200px;
}

.cm-popup-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
    margin-bottom: 4px;
}

.cm-popup-location {
    font-size: 0.9rem;
    color: #475569;
    margin-bottom: 6px;
}

.cm-popup-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e2e8f0;
}

.cm-popup-meta strong { color: #475569; }

/* Estado vacío del mapa cuando no hay datos */
.map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 5;
    flex-direction: column;
    gap: 12px;
    color: #64748b;
}

.map-empty.hidden { display: none; }

/* ════════════════════════════════════════════
   Sections / cards (sin cambios mayores)
   ════════════════════════════════════════════ */
.records-section { margin-bottom: 40px; }

.section-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.record-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

.record-card:hover { transform: translateY(-2px); }

.record-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.record-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.record-icon.temp-max     { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.record-icon.temp-min     { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.record-icon.tornado      { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); }
.record-icon.hail         { background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); }
.record-icon.wind         { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); }
.record-icon.alert-storm  { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.record-icon.alert-tornado{ background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
.record-icon.alert-flood  { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.record-icon.airport      { background: linear-gradient(135deg, #64748b 0%, #475569 100%); }

.record-label {
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.record-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
}

.record-location {
    font-size: 0.9rem;
    color: #475569;
    margin-top: 4px;
}

/* Aeropuertos (mantenido igual) */
.airports-table-container {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.airports-table { width: 100%; border-collapse: collapse; }

.airports-table th,
.airports-table td { padding: 14px 16px; text-align: left; }

.airports-table th {
    background: #f1f5f9;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: 0.5px;
}

.airports-table tr:not(:last-child) td { border-bottom: 1px solid #e2e8f0; }
.airports-table tr:hover td { background: #f8fafc; }

.airport-code { font-family: var(--font-display); font-weight: 700; color: #1e293b; }
.airport-name { color: #475569; font-size: 0.9rem; }

.delay-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 10px; border-radius: 20px;
    font-weight: 600; font-size: 0.85rem;
}
.delay-badge.low    { background: #fef3c7; color: #92400e; }
.delay-badge.medium { background: #fed7aa; color: #c2410c; }
.delay-badge.high   { background: #fecaca; color: #b91c1c; }

.reason-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 16px;
}

.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { color: #64748b; font-size: 1rem; }

.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.update-info {
    text-align: center;
    margin-top: 30px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    color: #64748b;
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .airports-table-container { overflow-x: auto; }
    .airports-table { min-width: 600px; }
}
