/* ==========================================================================
   IWØRQH - SDR LOCAL (Versione Emerald Flat - Master CSS)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. STRUTTURA GENERALE & CONTAINER
   -------------------------------------------------------------------------- */
.radio-card {
    background: var(--card);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    border: none !important;
    box-shadow: none !important;
}

/* --- FIX LIVELLI SDR (Z-INDEX) --- */
header, .header-bar {
    position: sticky;
    top: 0;
    z-index: 1000 !important;
}

.leaflet-top, .leaflet-bottom { z-index: 800 !important; }
.leaflet-control { z-index: 800 !important; }

.spot-counter-badge {
    position: absolute;
    top: 100px;
    right: 50px;
    z-index: 950;
    background: rgba(15, 23, 42, 0.9);
    color: var(--accent-cyan, #ffff00);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 0.8rem;
    border: 1px solid #334155;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    pointer-events: none;
}

.spot-counter-badge i { margin-right: 5px; }
.spot-counter-badge span { font-family: 'Inter', monospace; }

/* --------------------------------------------------------------------------
   2. BARRA RECORD (HUD Superiore)
   -------------------------------------------------------------------------- */
.sdr-record-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.rec-segment b, .rec-segment span[id^="glob-"] {
    font-family: inherit !important;
    font-weight: 800;
    color: var(--accent) !important;
    text-shadow: none !important;
}

.rec-label { 
    color: var(--text-dim) !important; 
    font-size: 0.8rem; 
    text-transform: uppercase; 
    font-weight: 700;
    margin-right: 4px;
}

#glob-country { font-size: 1rem; font-weight: 600; }
#glob-mode, #glob-band { font-size: 1.1rem; }
#glob-time { color: var(--text-dim) !important; font-size: 0.95rem; font-weight: 500; }
.rec-divider { width: 1px; height: 24px; background: var(--border); opacity: 0.4; }

/* --------------------------------------------------------------------------
   3. INPUT & CONTROLLI
   -------------------------------------------------------------------------- */
.sdr-controls-container {
    display: flex; 
    justify-content: center; 
    align-items: flex-end;
    gap: 25px; 
    padding: 15px 0; 
    flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 8px; min-width: fit-content; }
.filter-group label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sdr-input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    height: 38px;
    box-sizing: border-box;
    cursor: pointer;
    min-width: 120px;
}

/* --------------------------------------------------------------------------
   4. BOTTONI FILTRO (Neon Style)
   -------------------------------------------------------------------------- */
.filter-btn {
    --current-color: var(--btn-color, var(--accent));
    background: rgba(var(--rgb-current, 100, 100, 100), 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 0 15px;
    height: 38px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.filter-btn:hover {
    background: rgba(var(--rgb-current, 100, 100, 100), 0.3) !important;
    border-color: var(--current-color);
}

.filter-btn.active {
    background: var(--current-color) !important;
    border-color: var(--current-color) !important;
    color: #000 !important;
    font-weight: 900;
    box-shadow: 0 0 15px var(--current-color);
    transform: translateY(-1px);
}

.filter-btn.active[style*="#8b0000"], 
.filter-btn.active[style*="#9400d3"] { color: #fff !important; }

.dynamic-group { display: flex !important; flex-wrap: wrap; gap: 6px; width: 100%; }

#reset-container button {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0 18px;
    height: 38px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
#reset-container button:hover { background: #ef4444; color: #fff; }

/* --------------------------------------------------------------------------
   5. BADGES & WSPR
   -------------------------------------------------------------------------- */
.mode-badge-simple {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: inline-block;
    min-width: 45px;
    text-align: center;
}

.mode-wspr {
    box-shadow: 0 0 10px rgba(212, 165, 255, 0.2);
    border-style: dashed !important;
}

.filter-btn[data-mode="WSPR"].active { animation: wspr-pulse 3s infinite ease-in-out; }
@keyframes wspr-pulse {
    0% { box-shadow: 0 0 5px rgba(212, 165, 255, 0.4); }
    50% { box-shadow: 0 0 15px rgba(212, 165, 255, 0.6); }
    100% { box-shadow: 0 0 5px rgba(212, 165, 255, 0.4); }
}

/* --------------------------------------------------------------------------
   6. TABELLA LIVE & DATI
   -------------------------------------------------------------------------- */
.radio-table-wrapper { 
    width: 100%; 
    max-height: 500px; 
    overflow-y: auto; 
    margin-top: 15px;
    border-radius: 8px;
    background: rgba(0,0,0,0.02);
}

.radio-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }

.radio-table thead th {
    position: sticky; top: 0;
    background: var(--card);
    z-index: 10;
    box-shadow: 0 1px 0 var(--border);
    text-align: left; padding: 15px 12px;
    color: var(--text-dim); font-size: 0.85rem;
}

.radio-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); color: var(--text-main); }

.band-col {
    background: rgba(16, 185, 129, 0.08) !important;
    color: var(--accent) !important;
    text-align: center !important; 
    width: 80px; font-weight: 900; font-size: 1.2rem;
    border-right: 1px solid var(--border) !important;
}

.badge-call {
    background: rgba(255, 215, 0, 0.1); 
    color: #ffd700; 
    padding: 5px 12px; border-radius: 6px; 
    border: 1px solid rgba(255, 215, 0, 0.2);
    font-weight: 800; font-size: 1.1rem;
}

.radio-table-wrapper::-webkit-scrollbar { width: 6px; }
.radio-table-wrapper::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 10px; }

/* --------------------------------------------------------------------------
   7. MAPPA & RADAR
   -------------------------------------------------------------------------- */
#radio-map { height: 480px !important; width: 100%; background: #0a0a0a; border-radius: 12px; }

.radar-container { position: relative; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.radar-point { width: 8px; height: 8px; border-radius: 50%; z-index: 2; box-shadow: 0 0 10px var(--accent); background: var(--accent); }
.radar-ring {
    position: absolute; width: 100%; height: 100%;
    border: 2px solid var(--accent); border-radius: 50%;
    animation: radar-pulse 2s infinite ease-out; opacity: 0;
}
@keyframes radar-pulse {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

.grid-label { display: flex !important; align-items: center; justify-content: center; background: transparent !important; }
.grid-num-content {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-family: 'Inter', sans-serif; font-weight: 900; font-size: 11px; color: #fff;
    text-shadow: 0 0 4px #000; pointer-events: none;
}

.leaflet-popup-content-wrapper { background: var(--card) !important; color: var(--text-main) !important; border: 1px solid var(--border); }

/* --------------------------------------------------------------------------
   8. RECORD HERO & GRIDS (Layout Multi-Riga con Bordo Sotto)
   -------------------------------------------------------------------------- */
.record-hero {
    text-align: center;
    border: 2px solid var(--accent) !important;
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, rgba(0,0,0,0) 100%);
    padding: 40px 20px !important;
    position: relative;
    overflow: hidden;
}

.record-badge {
    position: absolute; top: 15px; left: 15px;
    background: var(--accent); color: #000;
    font-weight: 900; font-size: 0.7rem; padding: 4px 10px; border-radius: 4px;
}

.hero-main-data { display: flex; justify-content: center; align-items: baseline; gap: 20px; margin: 15px 0; }
.hero-call { font-size: 3.5rem; font-weight: 900; color: var(--text-main); line-height: 1; }
.hero-dist { font-size: 2.5rem; font-weight: 700; color: var(--accent); }

/* STRIP GRID: 3 colonne orizzontali */
.records-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.record-mini-card {
    background: var(--card);
    padding: 15px !important;
    border-radius: 8px;
    display: flex;
    flex-direction: column; /* Forza l'incolonnamento verticale */
    gap: 2px;
    border-bottom: 3px solid var(--accent); /* Bordo evidenziato sotto */
    min-height: 90px;
    transition: transform 0.2s;
    text-align: left;
}

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

.mini-band { font-size: 0.7rem; font-weight: 800; color: var(--text-dim); text-transform: uppercase; }

/* Riga superiore: Nominativo e Distanza */
.mini-header-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
}

.mini-call { font-size: 1.25rem; font-weight: 900; color: var(--text-main); }
.mini-dist { font-size: 1rem; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* Riga Nazione */
.mini-country {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    opacity: 0.9;
    margin-bottom: 5px;
}

/* Blocco metadati inferiore */
.mini-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 6px;
    line-height: 1.3;
}

.mini-meta b { color: var(--text-main); font-weight: 800; }

/* --- SDR STATISTICHE GLOBALI --- */
.stats-grid-counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stats-grid-lists {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.stat-counter-box {
    text-align: center;
    padding: 20px;
}

.stat-counter-box h4 {
    color: var(--text-dim);
    margin-top: 0;
    font-size: 0.9rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--accent);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--accent-cyan);
}

.top-list-header {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 10px;
    margin-top: 0;
}

.top-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.top-list-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.top-list-rank {
    font-weight: 700;
    color: var(--text-main);
}

.top-list-rank.rank-1 {
    color: gold;
    font-size: 1.1rem;
    font-weight: 800;
}

.top-list-count {
    color: var(--accent);
    font-weight: 700;
}

.top-list-count small {
    color: var(--text-dim);
    font-weight: normal;
}

/* Struttura colonna sinistra per impilare Nome e Sottotitolo */
.top-list-info {
    display: flex;
    flex-direction: column;
    max-width: 70%; /* Evita che il testo invada il contatore a destra */
}

/* Stile del sottotitolo Bande/Modi con taglio intelligente (ellipsis) */
.top-list-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 3px;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
}

/* --- MAPPA DXCC --- */
.dxcc-map-container {
    height: 700px; 
    width: 100%; 
    background: #111; 
    border-radius: 8px; 
    z-index: 1;
}

/* Stile del Popup sulla mappa */
.dxcc-popup .leaflet-popup-content-wrapper {
    background: var(--bg-card, #1e1e1e);
    color: var(--text-main, #fff);
    border: 1px solid var(--accent);
}
.dxcc-popup .leaflet-popup-tip {
    background: var(--accent);
}

/* --------------------------------------------------------------------------
   9. TITOLI & SEPARATORI (Left Aligned)
   -------------------------------------------------------------------------- */
.section-divider {
    width: 100%;
    text-align: left;
    border-bottom: 1px solid var(--border);
    line-height: 0.1em;
    margin: 45px 0 25px;
    text-transform: uppercase;
    font-size: 1rem;
    letter-spacing: 2px;
    color: var(--text-dim);
}

.section-divider span { background: var(--bg); padding-right: 20px; font-weight: 800; }
.section-divider i { color: var(--accent-cyan); margin-right: 10px; }

/* --------------------------------------------------------------------------
   10. ANALYTICS & MEDAGLIE
   -------------------------------------------------------------------------- */
.chart-box { background: var(--bg); border-radius: 12px; padding: 20px; }
.tab-btn { font-weight: 700; color: var(--text-dim); border: none; background: none; cursor: pointer; }
.tab-btn.active { color: var(--accent); border-bottom: 3px solid var(--accent); }

.gold-icon { color: #ffd700; }
.silver-icon { color: #c0c0c0; }
.bronze-icon { color: #cd7f32; }

/* --------------------------------------------------------------------------
   11. ANALYTICS & GRAFICI
   -------------------------------------------------------------------------- */

/* --- 11.1 Widget Ciclo Solare 25 --- */

/* Titolo: diamo aria per evitare che il numero mobile lo sormonti */
#ciclo-label {
    margin-bottom: 50px !important; /* Spazio vitale per il valore mobile */
    display: block;
}

.solar-cycle-container {
    background: rgba(0,0,0,0.2);
    padding: 15px; 
    border-radius: 8px;
    margin-top: 10px;
    position: relative;
}

.solar-thermometer {
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    position: relative;
    overflow: visible !important; /* Permette al numero di "galleggiare" sopra */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.solar-bar {
    height: 100%;
    width: 0%; /* Animato via JS */
    background: linear-gradient(90deg, #f1c40f 0%, #e67e22 50%, #e74c3c 100%);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.3);
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 10px;
    position: relative; 
}

/* Il numero che "cammina" sulla punta della barra */
.solar-current-value {
    position: absolute;
    right: 0; 
    top: -35px; /* Alzato sopra la barra */
    transform: translateX(50%); /* Centrato sulla punta */
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--accent);
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(0,0,0,1), 0 2px 4px rgba(0,0,0,0.8);
    z-index: 10;
}

/* Etichette MIN/MAX sotto la barra */
.cycle-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- 11.2 Griglia Indicatori Spaziali --- */
.indicator-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 colonne: MUF, KP, Vento, Raggi X */
    gap: 12px;
    margin-top: 15px;
    margin-bottom: 10px;
}

.indicator-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 8px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease;
}

.indicator-box:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.indicator-label {
    display: block;
    font-size: 0.6rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.indicator-value {
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text-main);
    display: block;
    line-height: 1;
}

/* --- 11.3 Monitoraggio Solare Live (SDO NASA) --- */
.solar-monitor-grid {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
    flex-wrap: nowrap; /* Forza le immagini sulla stessa riga su desktop */
}

.sun-card {
    text-align: center;
    flex: 1;
}

.sun-card h4, 
.sun-card .indicator-label {
    margin-bottom: 15px;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 800;
}

.sun-card img {
    width: 280px; 
    height: 280px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: #000;
}

.sun-card img:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

/* --- 11.4 Griglia Propagazione Bande (Ottimizzata) --- */
.band-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Due colonne perfette */
    gap: 10px;
    padding-bottom: 10px;
}

.band-tile {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 10px;
    border-left: 3px solid #64748b; /* Colore di default */
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: background 0.3s ease;
}

.band-tile:hover {
    background: rgba(255, 255, 255, 0.06);
}

.band-name {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: 2px;
}

.band-status {
    font-size: 1rem;
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1.1;
}

.band-note {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Colori dinamici per i bordi delle tiles */
.tile-open { border-left-color: #10b981 !important; }
.tile-fair { border-left-color: #f59e0b !important; }
.tile-closed { border-left-color: #ef4444 !important; }
.tile-aurora { border-left-color: #8b5cf6 !important; }

/* Responsive: una sola colonna su smartphone molto piccoli */
@media (max-width: 480px) {
    .band-grid { grid-template-columns: 1fr; }
}

/* --- 11.5 Footer di Stato e Analisi --- */
.status-footer {
    margin-top: 30px !important;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#hf-advice {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

#hf-details {
    font-style: italic;
    opacity: 0.8;
}

/* --- 11.6 Grafici (Chart.js) --- */
.chart-container {
    height: 500px;
    position: relative;
    margin-top: 20px;
}

canvas#correlationChart {
    width: 100% !important;
    height: 100% !important;
}

/* --- 11.7 Utility di Colore e Formattazione --- */
.text-muf { color: #00ecff !important; }
.text-accent { color: var(--accent) !important; }

/* --- 11.8 Media Queries (Responsive) --- */
@media (max-width: 992px) {
    .solar-monitor-grid {
        flex-wrap: wrap; /* Le immagini SDO vanno a capo su tablet/mobile */
    }
    .sun-card img {
        width: 220px;
        height: 220px;
    }
    .records-grid { grid-template-columns: 1fr; }
    .hero-call { font-size: 2.5rem; }
}

@media (max-width: 768px) {
    .indicator-grid {
        grid-template-columns: repeat(2, 1fr); /* Griglia indicatori 2x2 su mobile */
    }
}

/* --- 11.9 Stati Spaziali NOAA (Colori Dinamici) --- */
.status-ottimo { color: #10b981 !important; }      /* Verde Emerald */
.status-normale { color: var(--text-main) !important; } 
.status-attenzione { color: #f59e0b !important; }   /* Giallo/Arancio */
.status-allarme { 
    color: #ef4444 !important;                      /* Rosso */
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.4); 
}

.status-aurora { 
    color: #a855f7 !important; /* Viola vivace */
    font-weight: bold;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

/* --- 11.10 Timestamp Aggiornamento --- */
#last-update-container {
    font-size: 0.82rem;
    color: var(--text-dim);
    letter-spacing: 0.2px;
    opacity: 0.8;
}

#last-update-time {
    /* Mantiene i numeri allineati (monospazio) per evitare che il testo balli al refresh */
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}


/* --- 11.11 Monitor Aurora (Uniformato Nero) --- */
.aurora-map-centered {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 30px !important;
    padding: 10px 0;
    /* Rimuoviamo eventuali ombre esterne per pulizia */
}

.aurora-map-container {
    max-width: 650px;
    width: 100%;
    position: relative;
    border-radius: 12px;
    background: #000000 !important; /* Nero puro per uniformare con l'immagine NOAA */
    line-height: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); /* Aggiunge profondità sul fondo nero */
}

#aurora-live-map {
    width: 100%;
    height: auto !important;
    display: block;
    object-fit: contain;
    /* Se l'immagine ha bordi leggermente chiari, questo filtro aiuta a fonderla */
    filter: brightness(1.05) contrast(1.1); 
}

.map-overlay {
    position: absolute;
    bottom: 12px;
    right: 18px;
    background: rgba(0, 0, 0, 0.7); /* Overlay più scuro */
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 0.65rem;
    color: #a855f7; /* Testo viola per richiamare l'aurora */
    font-weight: bold;
    text-transform: uppercase;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.aurora-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
}

.aurora-stat-item-compact, .aurora-status-compact {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 15px 10px;
    text-align: center;
    transition: transform 0.2s ease;
}

.aurora-stat-item-compact:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Adattamento per Mobile */
@media (max-width: 768px) {
    .aurora-stats-row {
        grid-template-columns: repeat(2, 1fr); /* 2x2 su schermi piccoli */
    }
}

/* ==========================================================================
   --- INIZIO: SDR LOGBOOK STYLES (LAYOUT ORIGINALE) ---
   ========================================================================== */

/* 1. MAPPA LOCATOR */
.logbook-map-panel {
    margin-bottom: 20px;
}

.locator-map-container {
    height: 400px;
    width: 100%;
    background: #111;
    border-radius: 12px;
    border: 1px solid var(--border);
    z-index: 1;
}

/* ==========================================================================
   --- 2. PANNELLO FILTRI E GRIGLIA (VERSIONE COMPATTA) ---
   ========================================================================== */

.logbook-filters-panel {
    background: var(--card);
    border-radius: 12px;
    padding: 12px 18px; /* Padding ridotto */
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

/* Container principale del form */
#logbook-search-form {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Spazio minimo tra le 3 righe */
}

/* Definizione delle righe slim */
.filter-row-slim {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center;
}

/* Stile comune per input e select (altezza ridotta a 32px) */
.filter-row-slim input[type="text"],
.filter-row-slim select,
.filter-row-slim input[type="date"] {
    height: 32px !important;
    padding: 2px 10px !important;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: inherit;
    flex: 1; /* Distribuzione equa dello spazio */
    min-width: 0; /* Impedisce l'overflow */
}

/* Focus state */
.filter-row-slim input:focus,
.filter-row-slim select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Wrapper specifico per il tempo (Riga 1) */
.time-filters-wrapper {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Select Multipli (Bande/Modi) compatti */
.multi-slim {
    height: 32px !important;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg);
}

.multi-slim option { padding: 2px 4px; }

/* Pulsanti Azione Slim */
.filter-actions-slim {
    display: flex;
    gap: 8px;
}

.btn-slim {
    height: 32px !important;
    padding: 0 15px !important;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.8rem;
    text-transform: uppercase;
    transition: transform 0.1s;
    white-space: nowrap;
}

.btn-slim:hover { transform: scale(1.02); }

.btn-primary { background-color: var(--accent); color: #000 !important; }
.btn-secondary { background-color: var(--border); color: var(--text-main) !important; }

/* =========================================================
   FIX COLORE OPZIONI MENU A TENDINA (Per browser testardi)
   ========================================================= */
.filter-row-slim select option {
    background-color: var(--bg); /* Usa il colore di sfondo scuro del sito */
    color: var(--text-main);     /* Usa il testo bianco del sito */
    padding: 4px 8px;
}

/* Colore per la voce quando ci clicchi sopra (Selezionata) */
.filter-row-slim select option:checked {
    background-color: var(--accent) !important; /* Diventa verde */
    color: #000 !important;                     /* Testo nero per leggibilità */
}

/* =========================================================
   REGOLE PER LA MEGA-RIGA A 2 LIVELLI
   ========================================================= */

/* Riduce lo spazio orizzontale tra gli elementi per farceli stare tutti */
.mega-row {
    gap: 6px !important; 
}

/* Proporzioni elastiche degli input */
.mega-row .flex-2 {
    flex: 2; /* Prende il doppio dello spazio (utile per Callsign e Paese) */
    min-width: 80px;
}

.mega-row .flex-1 {
    flex: 1; /* Prende meno spazio (utile per Locator, Bande, Modi) */
    min-width: 70px;
}

/* Modifica i testi interni per risparmiare spazio */
.mega-row input::placeholder {
    font-size: 0.8rem;
}

/* Se lo schermo è troppo stretto (es. Tablet/Mobile), 
   la Mega-Riga andrà a capo in automatico in modo ordinato */
@media (max-width: 992px) {
    .mega-row {
        flex-wrap: wrap;
    }
    .mega-row > * {
        flex: 1 1 30%; /* 3 elementi per riga sui tablet */
    }
    .filter-actions-slim {
        flex: 1 1 100%;
        justify-content: center;
        margin-top: 5px;
    }
}

/* ==========================================================================
   --- SISTEMA A TAB (Tabella / Grafici / Statistiche) ---
   ========================================================================== */
.sdr-tabs-container {
    margin-top: 20px;
    margin-bottom: 40px;
}

/* Barra dei bottoni */
.sdr-tabs-nav {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 15px;
}

.sdr-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 24px;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s;
    position: relative;
}

.sdr-tab-btn:hover {
    color: var(--text-main);
    background: rgba(128, 128, 128, 0.05);
}

/* Bottone Attivo */
.sdr-tab-btn.active {
    color: var(--accent);
    background: var(--card); /* Usa il colore della card per dare senso di continuità */
}

/* La linea verde sotto il bottone attivo */
.sdr-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px; /* Si sovrappone esattamente al bordo del contenitore */
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--accent);
    border-radius: 3px 3px 0 0;
}

/* Gestione dei Pannelli */
.sdr-tab-pane {
    display: none; /* Nascosti di default */
    animation: fadeInTab 0.3s ease;
}

.sdr-tab-pane.active {
    display: block; /* Mostra solo quello attivo */
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Adattamento Mobile */
@media (max-width: 768px) {
    .filter-row-slim {
        flex-direction: column;
        align-items: stretch;
    }
}

/* 3. TABELLA RISULTATI */
.logbook-results-panel {
    background: var(--card);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid var(--border);
    margin-bottom: 40px;
}

/* Tabella con altezza massima sicura (scrolla internamente, senza rompere la pagina) */
.table-responsive {
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) var(--bg);
}

#logbook-table {
    width: 100%;
    border-collapse: collapse;
}

#logbook-table thead th {
    position: sticky; /* L'intestazione della tabella resta visibile quando la scorri */
    top: 0;
    background-color: var(--card);
    z-index: 2;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid var(--border);
    padding: 12px 10px;
    font-weight: 700;
    transition: color 0.2s;
}

#logbook-table thead th:hover { color: var(--accent); }

#logbook-table th, 
#logbook-table td {
    padding: 12px 10px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid rgba(128,128,128,0.1);
}

#logbook-table td:nth-child(2), 
#logbook-table td:nth-child(6) { text-align: left; }

#logbook-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#logbook-table tbody tr:hover { background-color: rgba(16, 185, 129, 0.1); }

/* ==========================================================================
   --- FINE: SDR LOGBOOK STYLES ---
   ========================================================================== */
   
   /* ==========================================================================
   --- GRIGLIA GRAFICI A CIAMBELLA ---
   ========================================================================== */
.doughnut-grid {
    display: flex;
    gap: 20px;
    height: 100%;
    width: 100%;
}

.doughnut-box {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (max-width: 768px) {
    .doughnut-grid {
        flex-direction: column;
        height: 600px; /* Più altezza su mobile per ospitarli entrambi in colonna */
    }
}

/* ==========================================================================
   --- GRIGLIA STATISTICHE ---
   ========================================================================== */
.stats-section-title {
    color: var(--text-main);
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}

.stats-grid {
    display: grid;
    /* Crea colonne reattive: su PC si affiancano, su smartphone vanno in colonna */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background-color: var(--card); /* Usa il colore card del tuo main-global.css */
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent); /* Effetto hover leggero sul bordo */
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-value {
    color: var(--accent); /* Il tuo colore primario per dare risalto al numero */
    font-size: 2rem;
    font-weight: 700;
}

/* ==========================================================================
   --- PILLOLE DETTAGLIO TRAFFICO ---
   ========================================================================== */
.stats-tags-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stats-tags-group {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
}

.stats-tags-header {
    color: var(--text-dim);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.stats-tags-container {
    display: flex;
    flex-wrap: wrap; /* Manda a capo le pillole se non c'è spazio */
    gap: 10px;
}

.stat-tag {
    display: flex;
    align-items: center;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 20px; /* Bordo arrotondato stile pillola */
    overflow: hidden;
    font-size: 0.9rem;
}

.stat-tag-label {
    background-color: var(--border); /* Sfondo per la parte di testo (es. "20m") */
    color: var(--text-main);
    padding: 5px 12px;
    font-weight: 600;
}

.stat-tag-value {
    color: var(--accent); /* Numero in risalto */
    padding: 5px 12px;
    font-weight: 700;
}