/* Custom Styles */

:root {
    --primary-color: #31942e;
    --secondary-color: #f1ea42;
    --primary-dark: #256822;
    --primary-light: #4aad46;
    --secondary-dark: #d4d138;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
}

/* Navbar styles */
.navbar {
    padding: 0.5rem 1rem;
}

.navbar-brand {
    font-weight: bold;
    color: white !important;
}

/* Force white text on bg-success for Admin UI consistency */
.bg-success,
.btn-success,
.badge.bg-success {
    color: #ffffff !important;
}

.navbar .container-fluid {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* Prevent duplicate navbars - Hide any nav that doesn't have proper structure */
nav.navbar:not(:has(.container-fluid)),
nav.navbar:not(:has(.navbar-brand)) {
    display: none !important;
}

/* Hide duplicate navbars - keep only the first one */
body>nav.navbar:not(:first-of-type) {
    display: none !important;
}

nav.navbar~nav.navbar {
    display: none !important;
}

/* Cards */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid rgba(0, 0, 0, 0.125);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-secondary,
.btn-warning {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #333;
}

.btn-secondary:hover,
.btn-warning:hover {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
    color: #333;
}

/* Badges */
.badge.bg-primary,
.badge.bg-success {
    background-color: var(--primary-color) !important;
}

.badge.bg-warning {
    background-color: var(--secondary-color) !important;
    color: #333;
}

/* Links */
a {
    color: var(--primary-color);
}

a:hover {
    color: var(--primary-dark);
}

/* Form controls */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(49, 148, 46, 0.25);
}

/* Table */
.table thead th {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-dark);
}

/* Paginazione coerente col design system (helper paginationLinks) */
.pagination { gap: .3rem; flex-wrap: wrap; }
.pagination .page-link {
    border: 1px solid #e9ecef;
    color: #334155;
    border-radius: .6rem;
    font-weight: 600;
    font-size: .85rem;
    padding: .4rem .7rem;
    min-width: 38px;
    text-align: center;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pagination .page-link:hover {
    background-color: rgba(34, 197, 94, .1);
    border-color: rgba(34, 197, 94, .4);
    color: #15803d;
}
.pagination .page-link:focus {
    box-shadow: 0 0 0 .2rem rgba(34, 197, 94, .25);
    color: #15803d;
}
.pagination .page-item.active .page-link {
    background-color: #22c55e;
    border-color: #22c55e;
    color: #fff;
    box-shadow: 0 .25rem .6rem rgba(34, 197, 94, .35);
}
.pagination .page-item.disabled .page-link {
    color: #adb5bd;
    background-color: #f8f9fa;
    border-color: #f1f3f5;
}

/* =====================================================================
   Design system condiviso (componenti riusabili tra le pagine)
   ===================================================================== */

/* Scala di raggi unificata */
:root {
    --card-radius-lg: 1rem;
    --card-radius-md: 0.85rem;
    --card-radius-sm: 0.65rem;
}

/* Stato vuoto premium (es. "Nessuna stagione attiva") */
.season-empty {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--card-radius-md);
    background: linear-gradient(180deg, #fffdf6 0%, #fff6e6 100%);
    border: 1px solid rgba(180, 120, 20, 0.16);
}
.season-empty-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
    font-size: 1.1rem;
}
.season-empty-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.season-empty-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #92400e;
}
.season-empty-sub {
    font-size: 0.78rem;
    color: #a16207;
}
.season-empty-sub a { color: #92400e; font-weight: 700; text-decoration: none; }
.season-empty-sub a:hover { text-decoration: underline; }

/* Pulsanti azione per righe di lista (Dettagli / Modifica / Elimina) */
.row-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.row-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.row-action:hover { transform: translateY(-1px); }
.row-action-view {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
    border-color: rgba(34, 197, 94, 0.22);
}
.row-action-view:hover { background: rgba(34, 197, 94, 0.2); color: #166534; }
.row-action-edit {
    background: #f1f3f5;
    color: #475569;
    border-color: rgba(20, 30, 40, 0.06);
}
.row-action-edit:hover { background: #e2e6ea; color: #1f2937; }
.row-action-delete {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.18);
}
.row-action-delete:hover { background: rgba(220, 38, 38, 0.18); color: #991b1b; }

/* Variante compatta a sola icona (mobile) */
.row-action-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
}

/* Lista densa (es. giocatori) */
.player-list {
    display: flex;
    flex-direction: column;
}
.player-row {
    display: flex;
    align-items: center;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    transition: background 0.12s ease;
}
.player-row:last-child { border-bottom: 0; }
.player-row:hover { background: rgba(34, 197, 94, 0.05); }
.player-row-main {
    flex: 1 1 auto;
    min-width: 0;
    cursor: pointer;
}
.player-row-name {
    display: block;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-row-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.85rem;
    margin-top: 3px;
    font-size: 0.72rem;
    color: #94a3b8;
}
.player-meta-att {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.player-meta-val {
    font-weight: 600;
    color: #64748b;
    min-width: 2.1em;
}
.player-meta-bar {
    width: 46px;
    height: 4px;
    border-radius: 999px;
    background: rgba(20, 48, 31, 0.08);
    overflow: hidden;
}
.player-meta-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
}

/* Hover-reveal delle azioni su desktop (solo dispositivi con hover) */
@media (hover: hover) and (min-width: 768px) {
    .player-row .row-actions {
        opacity: 0;
        transition: opacity 0.12s ease;
    }
    .player-row:hover .row-actions,
    .player-row:focus-within .row-actions {
        opacity: 1;
    }
}

/* Su mobile le azioni di riga diventano solo icona */
@media (max-width: 767.98px) {
    .row-action-label { display: none; }
    /* Le 3 icone azione restano sempre su una sola riga */
    .player-row .row-actions { flex-wrap: nowrap; flex-shrink: 0; gap: 0.3rem; }
    .player-row .row-action { padding: 0.42rem 0.55rem; }
    .player-row .row-action-icon { width: 34px; height: 34px; }
    .player-row-meta {
        gap: 0.25rem 0.75rem;
        font-size: 0.72rem;
    }
    /* Le barre minuscole non sono leggibili su mobile: mostro solo icona + % */
    .player-meta-bar { display: none; }
    .player-meta-att { gap: 0.3rem; }
    .player-meta-val { min-width: 0; }
}

/* Barra filtri sticky su desktop */
@media (min-width: 768px) {
    .players-filter-sticky {
        position: sticky;
        top: 12px;
        z-index: 20;
    }
}

/* Contact items */
.contact-item {
    border-left: 3px solid var(--primary-color);
}

/* Alerts */
.alert-primary,
.alert-success {
    background-color: rgba(49, 148, 46, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.alert-warning {
    background-color: rgba(241, 234, 66, 0.2);
    border-color: var(--secondary-color);
    color: #856404;
}

/* Statistics cards */
.stat-card {
    transition: transform 0.2s;
}

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

.bg-primary,
.bg-success {
    background-color: var(--primary-color) !important;
}

.bg-warning {
    background-color: var(--secondary-color) !important;
    color: #333;
}

.text-primary {
    color: var(--primary-color) !important;
}

/* ===== Eventi — card mobile stile "agenda" ===== */
.ev-mcard {
    border: 1px solid rgba(0, 0, 0, .08);
    border-left: 4px solid var(--primary-color);
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 .125rem .4rem rgba(0, 0, 0, .06);
}
.ev-mcard.ev-match { border-left-color: var(--secondary-color); }
.ev-datetile {
    width: 58px;
    min-width: 58px;
    border-radius: .8rem;
    background: var(--primary-color);
    color: #fff;
    text-align: center;
    padding: .4rem .2rem;
    line-height: 1.05;
}
.ev-mcard.ev-match .ev-datetile { background: var(--secondary-color); color: #1f2937; }
.ev-datetile .ev-d { display: block; font-size: 1.5rem; font-weight: 800; }
.ev-datetile .ev-mo { display: block; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.ev-datetile .ev-t { display: block; margin-top: .12rem; font-size: .68rem; font-weight: 600; opacity: .92; }
.ev-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    padding: .28rem .55rem;
}
.ev-minw0 { min-width: 0; }
.ev-actions .btn { min-height: 44px; font-size: .82rem; }

/* Icone di stato cliccabili: "Presenze mancanti" e "Seduta mancante" diventano
   <button> per chi puo' sollecitare. Qui si tolgono i default del bottone,
   perche' devono restare le stesse icone di prima. */
button.ev-remind {
    border: 0;
    background: none;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    transition: transform .12s ease;
}
button.ev-remind:disabled { cursor: default; opacity: .55; }
button.ev-remind:not(:disabled):hover { transform: scale(1.15); }

/* Bersaglio da 44px anche sulla tabella desktop, dove l'icona da 20px sta in una
   cella tutta sua e allargare l'area non tocca nessun vicino. Serve sui tablet,
   che vedono la tabella e non le card. */
td > button.ev-remind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

/* Variante chip della card mobile. Il chip di stato e' alto una ventina di pixel:
   col pollice non si centra, e un'icona identica a quelle accanto non dice che si
   tocca. Quando e' sollecitabile diventa quindi un pulsante con l'etichetta, alto
   40px e col bordo. Il chip NON sollecitabile resta piccolo com'era, cosi' l'unica
   cosa grande della riga e' l'unica su cui si puo' agire. */
button.ev-remind.ev-chip {
    display: inline-flex;
    min-height: 40px;
    padding: .45rem .8rem;
    gap: .35rem;
    font-size: .74rem;
    letter-spacing: .02em;
    margin-inline: .1rem;
    border: 1px solid currentColor;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
button.ev-remind.ev-chip i { font-size: .95rem; }
button.ev-remind.ev-chip:active { transform: scale(.96); }

/* ===== Eventi — vista desktop "agenda" (tabella) ===== */
.events-agenda tbody td { border-top: 1px solid rgba(0, 0, 0, .05); }
.events-agenda tbody tr { transition: background-color .12s ease; }
.events-agenda tbody tr:hover { background-color: rgba(49, 148, 46, .035); }

/* Tile data compatto per la cella "Data" */
.ev-dtile {
    width: 52px;
    min-width: 52px;
    border-radius: .7rem;
    text-align: center;
    padding: .35rem .2rem;
    line-height: 1.05;
    background: var(--primary-color);
    color: #fff;
}
.ev-dtile.is-match { background: var(--secondary-color); color: #1f2937; }
.ev-dtile .d { display: block; font-size: 1.3rem; font-weight: 800; }
.ev-dtile .mo { display: block; font-size: .56rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.ev-dtile .t { display: block; margin-top: .1rem; font-size: .62rem; font-weight: 600; opacity: .92; }

/* Pill tipo evento */
.ev-type-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-radius: 999px;
    padding: .3rem .65rem;
}
.ev-type-pill.training { background: rgba(49, 148, 46, .12); color: var(--primary-dark); }
.ev-type-pill.match { background: rgba(241, 234, 66, .45); color: #6f6500; }
/* Partite di calendario: campionato=blu, torneo=viola */
.ev-type-pill.championship { background: rgba(13, 110, 253, .14); color: #0a58ca; }
.ev-type-pill.tournament { background: rgba(111, 66, 193, .14); color: #59359a; }

/* Scoreboard partita: punteggio in evidenza + esito colorato */
.ev-scoreboard {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: .6rem;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    vertical-align: middle;
}
.ev-scoreboard .sb-score {
    display: flex;
    align-items: center;
    padding: .32rem .6rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1f2937;
    background: #fff;
}
.ev-scoreboard .sb-tag {
    display: flex;
    align-items: center;
    padding: .32rem .55rem;
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #fff;
}
.ev-scoreboard.win { border-color: var(--primary-color); }
.ev-scoreboard.win .sb-tag { background: var(--primary-color); }
.ev-scoreboard.draw { border-color: #6c757d; }
.ev-scoreboard.draw .sb-tag { background: #6c757d; }
.ev-scoreboard.loss { border-color: #dc3545; }
.ev-scoreboard.loss .sb-tag { background: #dc3545; }

/* ===== Eventi — vista calendario (mese / settimana / giorno) =====
   Il colore squadra arriva come variabile inline --evcal-team; l'icona
   distingue il tipo di impegno. Vedi assets/js/events-calendar.js. */

/* Selettore Lista/Calendario: segmented control, solo la voce attiva e' "piena"
   (nessun bordo sulla voce inattiva, che altrimenti sembra un secondo pulsante). */
.events-viewtoggle {
    display: inline-flex;
    gap: .15rem;
    padding: .25rem;
    border-radius: 999px;
    background: #eef0ef;
}
.events-viewtoggle .btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 0;
    border-radius: 999px;
    padding: .38rem 1.05rem;
    font-size: .85rem;
    font-weight: 700;
    color: #5f6b66;
    background: transparent;
    box-shadow: none;
}
.events-viewtoggle .btn:hover { color: var(--primary-dark); }
.events-viewtoggle .btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.events-viewtoggle .btn.active,
.events-viewtoggle .btn-check:checked + .btn {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 .15rem .4rem rgba(49, 148, 46, .28);
}
/* Stesso selettore riusato nella modale di export, dove le voci sono radio */
.events-viewtoggle .btn-check:focus-visible + .btn { outline: 2px solid var(--primary-color); outline-offset: 2px; }

.evcal-export { white-space: nowrap; }
@media (max-width: 575.98px) {
    .evcal-export span, .evcal-export { font-size: .8rem; }
}
.evcal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .9rem;
}
.evcal-minw0 { min-width: 0; }
.evcal-navbtn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}
.evcal-switch .btn { padding-inline: .7rem; }

/* Riga sotto la toolbar: filtro sede a sinistra, legenda squadre a destra */
.evcal-subbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem .9rem;
    margin-bottom: .9rem;
}
.evcal-venue {
    display: inline-flex;
    gap: .1rem;
    padding: .2rem;
    border-radius: 999px;
    background: #eef0ef;
    flex-shrink: 0;
}
.evcal-venue .btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: 0;
    border-radius: 999px;
    padding: .25rem .75rem;
    font-size: .78rem;
    font-weight: 700;
    color: #5f6b66;
    background: transparent;
    box-shadow: none;
}
.evcal-venue .btn:hover { color: var(--primary-dark); }
.evcal-venue .btn.active { background: #fff; color: var(--primary-dark); box-shadow: 0 .1rem .3rem rgba(0, 0, 0, .12); }

/* Gruppo azioni della toolbar: Esporta, Oggi e il selettore di vista */
.evcal-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* Tipi di evento della modale export: una sola riga, a capo solo se non c'è spazio */
.planning-kinds { display: flex; flex-wrap: wrap; gap: .2rem .9rem; }
.planning-kinds .form-check { margin-bottom: 0; }
.planning-kinds .form-check-label { font-size: .84rem; white-space: nowrap; }

.evcal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .9rem;
    font-size: .78rem;
    font-weight: 600;
    color: #495057;
}
.evcal-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.evcal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--evcal-team, #6c757d);
    flex-shrink: 0;
}

/* Griglia mese */
.evcal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}
.evcal-dow {
    text-align: center;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6c757d;
    padding-bottom: .25rem;
}
.evcal-cell {
    min-height: 96px;
    border: 1px solid rgba(0, 0, 0, .07);
    border-radius: .7rem;
    background: #fff;
    padding: .25rem;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease;
}
.evcal-cell:hover { border-color: rgba(49, 148, 46, .45); }
.evcal-cell.is-out { background: #f8f9fa; opacity: .6; }
.evcal-cell.is-today { border-color: var(--primary-color); box-shadow: inset 0 0 0 1px var(--primary-color); }
.evcal-cell.is-selected { background: rgba(49, 148, 46, .07); border-color: var(--primary-color); }
.evcal-daynum {
    display: block;
    margin-left: auto;
    border: 0;
    background: transparent;
    font-size: .78rem;
    font-weight: 700;
    color: #495057;
    line-height: 1.1;
    padding: .1rem .25rem;
    border-radius: .4rem;
}
.evcal-cell.is-today .evcal-daynum { background: var(--primary-color); color: #fff; }
.evcal-cell-body { display: flex; flex-direction: column; gap: 2px; margin-top: .15rem; }

.evcal-pill {
    display: flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
    padding: .16rem .35rem;
    border-radius: .4rem;
    background: var(--evcal-team, #6c757d);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    line-height: 1.25;
    text-decoration: none;
}
.evcal-pill:hover { color: #fff; filter: brightness(1.12); }
.evcal-pill i { font-size: .7rem; flex-shrink: 0; }
.evcal-pill-time { font-weight: 800; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.evcal-pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evcal-more {
    border: 0;
    background: transparent;
    text-align: left;
    padding: .05rem .35rem;
    font-size: .66rem;
    font-weight: 700;
    color: #6c757d;
}
.evcal-more:hover { color: var(--primary-dark); }

.evcal-dots {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin-top: .2rem;
}
.evcal-dots-more { font-size: .6rem; font-weight: 800; color: #6c757d; line-height: 1; }

/* Elenco eventi: usato da settimana, giorno e pannello del giorno selezionato */
.evcal-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .65rem;
    margin-bottom: .35rem;
    border: 1px solid rgba(0, 0, 0, .08);
    border-left: 4px solid var(--evcal-team, #6c757d);
    border-radius: .7rem;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .12s ease;
}
.evcal-item:hover { box-shadow: 0 .125rem .5rem rgba(0, 0, 0, .1); color: inherit; }
.evcal-item-time {
    font-size: .92rem;
    font-weight: 800;
    color: var(--evcal-team, #6c757d);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.evcal-item-body { min-width: 0; flex-grow: 1; }
.evcal-item-title {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .88rem;
    font-weight: 700;
    color: #212529;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.evcal-item-sub {
    display: block;
    font-size: .74rem;
    color: #6c757d;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.evcal-item-flags { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.evcal-item-score {
    font-size: .78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    padding: .1rem .35rem;
    border-radius: .35rem;
    background: #f1f3f5;
    color: #1f2937;
}
.evcal-item-score.win { background: rgba(49, 148, 46, .15); color: var(--primary-dark); }
.evcal-item-score.loss { background: rgba(220, 53, 69, .12); color: #b02a37; }

.evcal-empty {
    margin: 0;
    padding: .35rem .1rem;
    font-size: .8rem;
    font-style: italic;
    color: #adb5bd;
}

/* Vista settimana/giorno: un blocco per giornata */
.evcal-agday {
    display: flex;
    gap: .75rem;
    padding: .6rem 0;
    border-top: 1px solid rgba(0, 0, 0, .06);
}
.evcal-agday:first-child { border-top: 0; }
.evcal-agday-head {
    width: 58px;
    min-width: 58px;
    text-align: center;
    line-height: 1.1;
}
.evcal-agday.is-today .evcal-agday-head { color: var(--primary-dark); }
.evcal-agday-dow { display: block; font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #6c757d; }
.evcal-agday.is-today .evcal-agday-dow { color: var(--primary-dark); }
.evcal-agday-num { display: block; font-size: 1.4rem; font-weight: 800; }
.evcal-agday-mon { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; color: #adb5bd; }
.evcal-agday-body { flex-grow: 1; min-width: 0; }

/* Pannello del giorno selezionato (sotto la griglia del mese) */
.evcal-day { margin-top: 1rem; }
.evcal-day-head {
    display: flex;
    align-items: center;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #495057;
    margin-bottom: .5rem;
}
.evcal-day-today {
    margin-left: .5rem;
    padding: .1rem .45rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font-size: .62rem;
    letter-spacing: .06em;
}

@media (max-width: 767.98px) {
    .evcal-toolbar { flex-direction: column; align-items: stretch; gap: .5rem; }
    .evcal-toolbar > div { width: 100%; justify-content: center; }

    /* Sotto i 768px una regola globale porta ogni .btn a .75rem 1.5rem di padding
       (vedi "Larger touch targets on mobile" più sotto): senza queste misure la
       toolbar del calendario non ci sta in larghezza e i pulsanti escono dallo
       schermo. Le tre viste prendono una riga intera, Oggi ed Esporta la successiva. */
    .evcal-actions { flex-wrap: wrap; row-gap: .5rem; }
    .evcal-actions .btn { padding: .5rem .8rem !important; font-size: .82rem; }
    .evcal-switch { order: 1; width: 100%; }
    .evcal-switch .btn { flex: 1 1 0; padding: .5rem .3rem !important; }
    .evcal-actions [data-evcal-today] { order: 2; flex: 1 1 auto; }
    .evcal-export { order: 3; flex: 2 1 auto; }
    .evcal-toolbar .evcal-navbtn { padding: 0 !important; width: 34px; height: 34px; flex-shrink: 0; }
    #evcal-title { font-size: 1rem; }

    /* Su mobile la legenda squadre occupa troppe righe prima della griglia:
       il colore resta leggibile nelle pastiglie e nel pannello del giorno. */
    .evcal-legend { display: none; }
    .evcal-subbar { justify-content: center; }

    .evcal-grid { gap: 2px; }
    .evcal-cell { min-height: 52px; padding: .15rem; text-align: center; }
    .evcal-daynum { margin: 0 auto; font-size: .8rem; }
    .evcal-agday-head { width: 46px; min-width: 46px; }
}

/* Nella modale di export c'è un <form> tra .modal-content e header/body/footer:
   così il corpo NON è un flex item di .modal-content e modal-dialog-scrollable non
   riesce a rimpicciolirlo, quindi non scorre e viene solo tagliato. Rendendo anche
   il form un contenitore flex in colonna la catena si ricompone. */
#planningExportModal .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

/* La modale di export su mobile: su iOS e Android `height: 100%` di un elemento
   fixed si riferisce al viewport di layout, più alto di quello visibile quando la
   barra degli indirizzi è a schermo — il footer con "Scarica PDF" finiva sotto il
   bordo e non era raggiungibile. Con dvh il limite è l'area davvero visibile. */
@media (max-width: 767.98px) {
    #planningExportModal .modal-dialog {
        margin: .5rem;
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
    }
    #planningExportModal .modal-content {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 1rem);
        max-height: calc(100dvh - 1rem);
        overflow: hidden;
    }
    /* min-height: 0 è indispensabile: senza, il corpo (flex item) non scende sotto
       l'altezza del suo contenuto, quindi non diventa mai area scrollabile e viene
       solo tagliato dall'overflow del contenitore. */
    #planningExportModal .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    /* Su mobile le barre di scorrimento sono a scomparsa: senza un indicatore
       sempre visibile non si capisce che il contenuto continua. */
    #planningExportModal .modal-body { scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.3) transparent; }
    #planningExportModal .modal-body::-webkit-scrollbar { width: 5px; }
    #planningExportModal .modal-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.28); border-radius: 3px; }
    #planningExportModal .modal-footer {
        flex-shrink: 0;
        background: #fff;
        box-shadow: 0 -.35rem .6rem rgba(0, 0, 0, .07);
    }
    #planningExportModal .btn { padding: .55rem 1rem !important; font-size: .9rem; }
    #planningExportModal .events-viewtoggle .btn { padding: .5rem .4rem !important; font-size: .84rem; }
    #planningExportModal .btn-link { padding: 0 !important; font-size: .84rem; }
    #planningExportModal .mb-3 { margin-bottom: .85rem !important; }
    #planningExportModal .planning-teams-box { max-height: 132px; }
}

/* ===== Hero dashboard (stile app, palette brand) ===== */
.app-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1.25rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 1.6rem 1.75rem;
    box-shadow: 0 .5rem 1.5rem rgba(37, 104, 34, .25);
}
/* Linee da campo (touchline + linea/cerchio di centrocampo) disegnate in CSS */
.app-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: .5;
    background:
        radial-gradient(circle at 88% 50%, transparent 0 34px, rgba(255, 255, 255, .18) 34px 36px, transparent 36px),
        linear-gradient(rgba(255, 255, 255, .18), rgba(255, 255, 255, .18)) 88% 50% / 2px 100% no-repeat,
        linear-gradient(rgba(255, 255, 255, .16), rgba(255, 255, 255, .16)) 0 8px / 100% 2px no-repeat,
        linear-gradient(rgba(255, 255, 255, .16), rgba(255, 255, 255, .16)) 0 calc(100% - 8px) / 100% 2px no-repeat;
}
.app-hero > * { position: relative; z-index: 1; }
/* Dropdown dentro l'hero (es. selettore squadra per chi ne allena più di una):
   l'overflow:hidden dell'hero taglierebbe il menu e lo stacking di default lo
   farebbe dipingere sotto la card che segue. Mentre il menu è aperto, main.js
   aggiunge .hero-menu-open: il clipping si sospende e l'hero sale di livello.
   La classe è pilotata da JS e non da :has(), che manca sui browser più vecchi.
   Lo z-index basta che superi la card seguente (z-index auto): tenerlo basso
   evita che l'hero scavalchi navbar e overlay, che stanno nei livelli alti. */
.app-hero.hero-menu-open { overflow: visible; z-index: 3; }
/* Senza clipping il motivo "linee da campo" sborderebbe dagli angoli arrotondati */
.app-hero.hero-menu-open::before { border-radius: inherit; }
/* Con molte squadre il menu diventa lungo quanto lo schermo: lo limitiamo e lo
   rendiamo scorrevole, così resta dentro il viewport e non arriva a toccare
   la navbar (che a quel punto potrebbe ri-andare a capo per la scrollbar) */
.app-hero .dropdown-menu { max-height: min(60vh, 22rem); overflow-y: auto; }
.app-hero .hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: .18em;
    font-size: .7rem;
    font-weight: 700;
    opacity: .9;
    margin: 0;
}
.app-hero .hero-title { font-weight: 800; letter-spacing: -.01em; line-height: 1.05; margin: .2rem 0 0; }
.app-hero .hero-sub { opacity: .92; margin: .35rem 0 0; }
.app-hero .hero-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border-radius: 999px;
    padding: .32rem .8rem;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
}
.app-hero .hero-chip.accent { background: var(--secondary-color); color: #1f2937; }
.app-hero .btn-hero { background: #fff; color: var(--primary-dark); font-weight: 700; border: 0; }
.app-hero .btn-hero:hover { background: #eef0ee; color: var(--primary-dark); }
/* Toggle Lista/Calendario della pagina Eventi, versione "vetro" per stare dentro l'hero verde
   (stessa struttura di .events-viewtoggle, riusata anche nella modale export planning) */
.events-viewtoggle-hero {
    display: inline-flex;
    gap: .15rem;
    padding: .25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
}
.events-viewtoggle-hero .btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 0;
    border-radius: 999px;
    padding: .38rem 1.05rem;
    font-size: .85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, .85);
    background: transparent;
    box-shadow: none;
}
.events-viewtoggle-hero .btn:hover { color: #fff; }
.events-viewtoggle-hero .btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.events-viewtoggle-hero .btn.active {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: 0 .15rem .4rem rgba(0, 0, 0, .15);
}
@media (prefers-reduced-motion: no-preference) {
    .app-hero { animation: appHeroIn .4s ease both; }
    @keyframes appHeroIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
}
@media (max-width: 575.98px) {
    .app-hero { padding: 1.25rem 1.25rem; border-radius: 1rem; }
    .app-hero .hero-title { font-size: 1.4rem; }
}

/* Mobile-First Styles */

/* Touch Targets - Minimum 44x44px for all interactive elements */
.btn-touch,
.btn-touch label,
.attendance-btn,
.quick-action-card,
.player-item,
input[type="radio"]+label,
input[type="checkbox"]+label {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Form controls mobile-friendly */
.form-control-lg,
.form-select-lg {
    min-height: 48px;
    font-size: 16px;
    /* Prevents zoom on iOS */
}

/* Sticky Save Container for Attendance Form */
.sticky-save-container {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: white;
    margin-top: 1rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 0 1rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Safe Area Support for iOS */
@supports (padding: max(0px)) {
    .sticky-save-container {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Attendance Form Mobile Optimizations */
.attendance-form-mobile .player-item {
    transition: background-color 0.2s ease;
}

.attendance-form-mobile .player-item:hover {
    background-color: #f8f9fa;
}

.attendance-form-mobile .player-item-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.attendance-form-mobile .player-name {
    flex-shrink: 0;
}

.attendance-form-mobile .attendance-toggle.btn-group {
    display: flex;
    width: 100%;
    gap: 0;
    flex-wrap: nowrap;
    align-items: stretch;
}

.attendance-form-mobile .attendance-toggle.btn-group>label {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.attendance-form-mobile .attendance-btn {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attendance-form-mobile .attendance-btn:active {
    transform: scale(0.95);
}

/* Desktop layout for attendance form */
@media (min-width: 768px) {
    .attendance-form-mobile .player-item-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .attendance-form-mobile .player-name {
        margin-bottom: 0;
        margin-right: 1rem;
        flex-shrink: 0;
    }

    .attendance-form-mobile .attendance-toggle.btn-group {
        width: auto;
        flex-shrink: 0;
    }

    .attendance-form-mobile .attendance-toggle.btn-group>label {
        flex: 0 0 auto;
    }

    .attendance-form-mobile .attendance-btn {
        min-width: 100px;
        width: auto;
    }
}

/* Event Create Form Mobile */
.event-create-mobile .btn-group {
    display: flex;
    width: 100%;
}

.event-create-mobile .btn-group label {
    flex: 1;
    min-height: 56px;
}

/* Quick Action Cards */
.quick-action-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid transparent;
}

.quick-action-card:hover,
.quick-action-card:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.quick-action-card:active {
    transform: translateY(0);
}

/* Event Cards Mobile */
.event-card-mobile {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.event-card-mobile:active {
    transform: scale(0.98);
}

/* Smooth Animations */
.card,
.btn,
.badge {
    transition: all 0.2s ease;
}

/* Mobile-specific spacing */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Larger touch targets on mobile */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .btn-sm {
        padding: 0.5rem 1rem;
        min-height: 44px;
    }

    .btn-lg {
        padding: 1rem 2rem;
        font-size: 1.1rem;
        min-height: 56px;
    }

    /* Better spacing for mobile lists */
    .list-group-item {
        padding: 1rem;
        min-height: 60px;
    }

    /* Optimize card spacing */
    .card {
        margin-bottom: 1rem;
    }

    /* Full width buttons on mobile */
    .d-grid .btn {
        width: 100%;
    }

    /* Better form spacing */
    .mb-3 {
        margin-bottom: 1.25rem !important;
    }

    /* Hide desktop elements */
    .d-md-none {
        display: block !important;
    }

    .d-none.d-md-block {
        display: none !important;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .btn-touch {
        min-height: 40px;
    }
}

/* Prevent text selection on buttons (better UX) */
.btn,
.btn-touch,
.attendance-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Loading states */
.btn:disabled,
.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Focus states for accessibility */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Improved badge visibility on mobile */
.badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    font-weight: 500;
}

@media (max-width: 768px) {
    .badge {
        font-size: 0.7rem;
        padding: 0.4em 0.7em;
    }
}

/* Badge Partita personalizzato */
.badge.bg-match {
    background-color: #198754 !important;
    color: #fff !important;
}

/* File input mobile optimization */
.file-input-mobile {
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    position: relative !important;
    z-index: 1056 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
    visibility: visible !important;
}

#file-input-wrapper {
    position: relative !important;
    z-index: 1055 !important;
    width: 100%;
}

/* Assicura che l'input nel modal sia sopra tutto */
.modal .file-input-mobile {
    z-index: 1056 !important;
}

.modal #file-input-wrapper {
    z-index: 1055 !important;
}

#file-debug-messages,
#file-debug-messages-admin {
    max-height: 200px;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
    font-family: monospace;
    font-size: 0.7rem;
    line-height: 1.4;
}

#file-input-wrapper-admin {
    position: relative;
    z-index: 1;
}

.file-input-mobile::-webkit-file-upload-button {
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    color: #212529;
    cursor: pointer;
    font-size: 0.875rem;
    min-height: 44px;
    -webkit-appearance: button;
}

.file-input-mobile::-webkit-file-upload-button:hover {
    background-color: #e9ecef;
}

/* Firefox file input styling */
.file-input-mobile::file-selector-button {
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    color: #212529;
    cursor: pointer;
    font-size: 0.875rem;
    min-height: 44px;
}

.file-input-mobile::file-selector-button:hover {
    background-color: #e9ecef;
}

/* Mobile specific improvements */
@media (max-width: 768px) {
    .file-input-mobile {
        width: 100%;
        padding: 0.75rem;
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        min-height: 48px;
    }

    .file-input-mobile::-webkit-file-upload-button {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .file-input-mobile::file-selector-button {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Flatpickr Date Picker Styles */
.date-input {
    cursor: pointer;
}

.flatpickr-calendar {
    font-size: 14px;
    box-shadow: 0 3px 13px rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
}

.flatpickr-day.today {
    border-color: var(--primary-color);
}

.flatpickr-day.today:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.flatpickr-months .flatpickr-month {
    background: var(--primary-color);
    color: white;
    border-radius: 5px 5px 0 0;
}

.flatpickr-weekdays {
    background: var(--primary-dark);
}

.flatpickr-weekday {
    color: white;
    font-weight: 600;
}

/* Mobile optimizations for Flatpickr */
@media (max-width: 768px) {
    .flatpickr-calendar {
        width: 100%;
        max-width: 100%;
    }

    .flatpickr-day {
        height: 44px;
        line-height: 44px;
        min-width: 44px;
    }

    .flatpickr-months .flatpickr-prev-month,
    .flatpickr-months .flatpickr-next-month {
        height: 44px;
        width: 44px;
        padding: 0;
    }
}

/* Login page vertical centering */
body:has(.login-container) .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    margin-top: 0 !important;
}

.login-container {
    width: 100%;
    margin-top: auto;
    margin-bottom: auto;
}

/* On mobile, ensure messages appear above login form */
@media (max-width: 767.98px) {
    body:has(.login-container) .container {
        flex-direction: column;
    }

    body:has(.login-container) .container>.alert {
        order: -1;
        width: 100%;
        margin-bottom: 1rem;
    }

    .login-container {
        order: 1;
    }
}

/* Notes toggle button styling */
.transition-transform {
    transition: transform 0.3s ease;
}

#notes-toggle-btn:hover {
    background-color: #f8f9fa;
    border-color: #6c757d;
    color: #212529 !important;
}

#notes-toggle-btn:hover strong,
#notes-toggle-btn:hover i,
#notes-toggle-btn:hover small {
    color: inherit;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Flex: senza min-width:0 un flex item non scende sotto la larghezza del contenuto
   e i text-truncate nei figli non troncano mai (la riga sborda invece di accorciarsi) */
.min-width-0 {
    min-width: 0;
}

/* Hide mobile nav elements on desktop by default */
.mobile-bottom-nav,
.mobile-menu-overlay {
    display: none !important;
}

/* Con un modal aperto la bottom nav (z-index 9999) coprirebbe il footer del
   modal Bootstrap (z-index 1055) nascondendo i pulsanti di salvataggio,
   e resterebbe cliccabile sopra il backdrop: va nascosta finché il modal è aperto. */
body.modal-open .mobile-bottom-nav {
    display: none !important;
}

/* Mobile Navigation - Encapsulated in Media Query */
@media (max-width: 767.98px) {

    /* Un overflow orizzontale su mobile allarga il layout viewport e "sgancia"
       la bottom-nav (fixed) dal visual viewport: scrollando sparisce.
       clip (non hidden) perché hidden disattiverebbe i position:sticky interni. */
    html,
    body {
        overflow-x: clip;
    }

    /* Navbar in cima (logo + hamburger): sotto i 768px la navigazione la fa
       già la bottom-nav fissa, quindi la barra era solo un logo che non
       apriva nulla (toggler/collapse già nascosti sotto) — la togliamo
       del tutto per recuperare spazio verticale in cima ad ogni pagina. */
    .navbar {
        display: none !important;
    }

    /* Body padding: spazio per il menu in basso, che cresce con la safe area
       (gesture bar). Il padding deve seguirlo, altrimenti l'ultimo elemento
       della pagina finisce sotto la bottom-nav. */
    body {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }

    /* Mobile Bottom Navigation */
    .mobile-bottom-nav {
        position: fixed !important;
        bottom: 0 !important;
        left: 0;
        right: 0;
        width: 100%;
        background: #f8f9fa;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around;
        align-items: center;
        padding: 8px 0 max(8px, env(safe-area-inset-bottom));
        z-index: 9999 !important;
        border-top: 1px solid #e0e0e0;
    }

    /* I dropdown Bootstrap stanno a z-index 1000, la bottom nav a 9999: un menu
       aperto vicino al fondo pagina (es. colonna "Azioni" delle tabelle) finisce
       sotto il menu mobile e le ultime voci diventano incliccabili.
       Popper non ribalta il menu verso l'alto perche' ragiona sul viewport e non
       sa che la nav copre gli ultimi ~80px.
       Solo .show: un menu chiuso non partecipa all'impilamento. */
    .dropdown-menu.show {
        z-index: 10000;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #666;
        font-size: 0.65rem;
        padding: 4px 2px;
        flex: 1;
        max-width: 20%;
        transition: all 0.2s ease;
    }

    .mobile-nav-item i {
        font-size: 1.5rem;
        margin-bottom: 2px;
        color: var(--primary-color);
    }

    .mobile-nav-item span {
        font-weight: 500;
    }

    /* Badge notifiche sul bottone "Menu" della bottom nav */
    .mobile-nav-icon {
        position: relative;
        display: inline-flex;
    }

    .mobile-nav-badge {
        position: absolute;
        top: -3px;
        right: -10px;
        background: #dc3545;
        color: #fff;
        font-size: 0.6rem;
        font-weight: 700;
        line-height: 1;
        padding: 2px 5px;
        border-radius: 999px;
        border: 2px solid #f8f9fa;
    }

    .mobile-nav-item:hover,
    .mobile-nav-item:active {
        color: var(--primary-color);
        text-decoration: none;
        background-color: rgba(49, 148, 46, 0.05);
        border-radius: 8px;
    }

    .mobile-nav-item.active {
        color: var(--primary-color);
    }

    /* Mobile Menu Overlay */
    .mobile-menu-overlay {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        /* Sopra i dropdown (10000): quando si apre un menu a scomparsa lo scrim
           deve coprire anche un eventuale dropdown rimasto aperto. */
        z-index: 10001;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .mobile-menu-overlay.active {}

    .mobile-menu-items {
        padding: 10px 0;
    }

    .mobile-menu-section {
        margin-bottom: 0;
    }

    .mobile-menu-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        text-decoration: none;
        color: #333;
        font-size: 1rem;
        transition: all 0.2s ease;
        border-bottom: 1px solid #f0f0f0;
    }

    .mobile-menu-item:hover {
        background: #f8f9fa;
        color: var(--primary-color);
        text-decoration: none;
    }

    .mobile-menu-item-content {
        display: flex;
        align-items: center;
        gap: 15px;
    }

    .mobile-menu-item-content i {
        font-size: 1.3rem;
        color: var(--primary-color);
        width: 30px;
        text-align: center;
    }

    .mobile-menu-arrow {
        font-size: 1rem;
        color: #999;
        transition: transform 0.3s ease;
    }

    /* Mobile Submenu */
    .mobile-submenu {
        max-height: 0;
        overflow: hidden;
        background: #f8f9fa;
        transition: max-height 0.3s ease;
    }

    .mobile-submenu.active {
        max-height: 300px;
    }

    .mobile-submenu-item {
        display: flex;
        align-items: center;
        gap: 15px;
        padding: 14px 20px 14px 65px;
        text-decoration: none;
        color: #555;
        font-size: 0.95rem;
        transition: all 0.2s ease;
        border-bottom: 1px solid #e8e8e8;
    }

    .mobile-submenu-item:last-child {
        border-bottom: none;
    }

    /* Le dichiarazioni erano divise fra due copie della stessa sezione: quella
       piu' in basso vinceva la cascata e le proprieta' erano disgiunte, quindi
       l'effetto reale era l'unione. Qui sono unite in un'unica regola. */
    .mobile-submenu-item:hover {
        background: #e9ecef;
        color: var(--primary-color);
        text-decoration: none;
        transition: transform 0.3s ease;
    }

    .mobile-submenu-item i {
        font-size: 1.1rem;
        color: var(--primary-color);
        width: 24px;
        text-align: center;
    }

}

/* Segmented Date Input Styles */
.date-segment-container {
    width: 100%;
}

.date-segment-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--primary-color);
    /* Green border */
    border-radius: 0.5rem;
    /* Rounded */
    overflow: hidden;
    background-color: #fff;
    width: 100%;
    transition: box-shadow 0.15s ease-in-out;
}

.date-segment-group:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(49, 148, 46, 0.25);
}

.segment-wrapper {
    flex: 1;
    border-right: 1px solid var(--primary-color);
    padding: 0.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.segment-input {
    border: none;
    background: transparent;
    width: 100%;
    text-align: center;
    font-size: 1rem;
    color: #212529;
    outline: none;
    padding: 0;
    -moz-appearance: textfield;
}

.segment-input::-webkit-outer-spin-button,
.segment-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.segment-input::placeholder {
    color: #6c757d;
    opacity: 0.6;
}

.segment-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    color: var(--primary-color);
    background-color: rgba(49, 148, 46, 0.1);
    align-self: stretch;
    border-left: 1px solid var(--primary-color);
}

/* ---------------------------------------------------------------------
   Toast dei download (assets/js/main.js, link con data-download)

   In basso e al centro perché è dove arriva il pollice e perché il pulsante
   che lo accende sta quasi sempre in fondo a una lista lunga: un alert in
   cima alla pagina richiederebbe di risalire per sapere com'è andata.

   Sotto i 768px deve stare SOPRA la bottom nav, che è fixed a z-index 9999
   e alta ~80px più la safe area (vedi .mobile-bottom-nav): da qui il bottom
   calcolato e lo z-index 10000, lo stesso rialzo di cui hanno bisogno i
   dropdown per non finire sotto il menu.
   --------------------------------------------------------------------- */
/* Toast. Nato per i download e poi usato anche dai solleciti sugli eventi:
   stesso componente con due nomi, perche' rinominare .download-toast avrebbe
   toccato il flusso PDF senza alcun motivo. Sfondo PIENO di proposito: le
   .alert-* di questo file hanno sfondi rgba(...,.1-.2) e dentro una card
   bianca si leggono, ma un messaggio in position:fixed sopra la pagina no. */
.download-toast,
.fi-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: min(92vw, 26rem);
    padding: 0.75rem 1.15rem;
    border-radius: 999px;
    background-color: #212529;
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.35;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.3);
    /* Non intercetta i click: è un avviso, non un ostacolo tra il dito e la
       pagina, e resta visibile fino a 6 secondi. */
    pointer-events: none;
    opacity: 0;
    transform: translateX(-50%) translateY(0.75rem);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.download-toast.is-visible,
.fi-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.download-toast--done,
.fi-toast--done {
    background-color: #146c43;
}

.download-toast--warn,
.fi-toast--warn {
    background-color: #9a6700;
}

.fi-toast--error {
    background-color: #b02a37;
}

.download-toast-icon,
.fi-toast-icon {
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    .download-toast,
    .fi-toast {
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}