/* ---- Web font self-hosted: Inter (SIL OFL, vedi fonts/OFL.txt) ---- */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/public/assets/fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/public/assets/fonts/Inter-Medium.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/public/assets/fonts/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/public/assets/fonts/Inter-Bold.woff2") format("woff2");
}

:root {
    /* Ancorato al tema dell'app (non all'OS): così la tendina nativa delle <select>,
       gli scrollbar e gli altri controlli seguono chiaro/scuro come il portale. */
    color-scheme: light;
    --blue: #123a5f;
    --blue-dark: #0b243b;
    --primary: var(--blue);
    --red: #b4232f;
    --green: #147a45;
    --amber: #b7791f;
    --gray-50: #f6f8fb;
    --gray-100: #eceff4;
    --gray-200: #dfe5ee;
    --gray-300: #c4ccd8;
    --gray-600: #5a6675;
    --gray-800: #161d29;
    --text: #11161f;
    --white: #ffffff;
    /* Token semantici (tema chiaro) */
    --bg: var(--gray-50);
    --surface: #ffffff;
    --surface-2: #fbfcfe;
    --text-muted: var(--gray-600);
    /* Look "operativo ad alta densità": bordi più marcati, zebra, hover riga */
    --border-color: #cfd6e0;
    --border-strong: #b7c0cd;
    --row-alt: #f4f7fb;
    --row-hover: #eaf1f9;
    --header-bg: var(--blue-dark);
    /* Tinte di stato (sfondo/bordo) */
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --info-bg: #eef4fa;
    --font-sans: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
    --radius: 6px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .08);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, .12);
}

/* ---- Tema scuro: forzato (data-theme="dark") o di sistema (senza override) ---- */
[data-theme="dark"] {
    color-scheme: dark;
    --gray-50: #11161f;
    --gray-100: #1b2331;
    --gray-200: #2a3342;
    --gray-300: #3a4556;
    --gray-600: #9aa6b5;
    --gray-800: #e6ebf2;
    --text: #e6ebf2;
    --bg: #0f141b;
    --surface: #161d29;
    --surface-2: #1b2331;
    --text-muted: #9aa6b5;
    --border-color: #2a3342;
    --border-strong: #3a4556;
    --row-alt: #1b2331;
    --row-hover: #222c3c;
    --header-bg: #0b1018;
    --success-bg: #0f2f22;
    --success-border: #1c5440;
    --warning-bg: #332905;
    --warning-border: #6b550f;
    --danger-bg: #3a1414;
    --danger-border: #6b1f1f;
    --info-bg: #102234;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .5);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --gray-50: #11161f;
        --gray-100: #1b2331;
        --gray-200: #2a3342;
        --gray-300: #3a4556;
        --gray-600: #9aa6b5;
        --gray-800: #e6ebf2;
        --text: #e6ebf2;
        --bg: #0f141b;
        --surface: #161d29;
        --surface-2: #1b2331;
        --text-muted: #9aa6b5;
        --border-color: #2a3342;
        --border-strong: #3a4556;
        --row-alt: #1b2331;
        --row-hover: #222c3c;
        --header-bg: #0b1018;
        --success-bg: #0f2f22;
        --success-border: #1c5440;
        --warning-bg: #332905;
        --warning-border: #6b550f;
        --danger-bg: #3a1414;
        --danger-border: #6b1f1f;
        --info-bg: #102234;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, .5);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.4;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--blue);
}

.app-header {
    min-height: 58px;
    background: var(--header-accent, var(--header-bg));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 20px;
    box-shadow: var(--shadow-md);
    border-bottom: 3px solid var(--red);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    background: var(--red);
    color: var(--white);
    font-weight: 800;
    border-radius: var(--radius-sm);
    letter-spacing: .04em;
}

/* Badge ambiente: stessa "pill" di header dell'Opera come (traslucida su accento),
   con un pallino colorato che distingue local/dev/prod. */
.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 26px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    color: var(--white, #fff);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.env-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.env-badge.env-local::before { color: var(--gray-300); }
.env-badge.env-dev::before   { color: var(--amber); }
.env-badge.env-prod::before  { color: var(--green); }

/* Fuori dall'header (es. pagina Stato deploy) il badge sta su una card chiara:
   testo bianco su bianco sparisce col tema chiaro. Usa i token di superficie. */
.card .env-badge {
    background: var(--surface-2);
    border-color: var(--border-color);
    color: var(--text);
}

.version-badge {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    height: 26px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .02em;
}

.brand small,
.user-box small {
    display: block;
    opacity: .86;
    margin-top: 2px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.notification-link {
    color: var(--white);
    font-weight: 700;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    min-height: calc(100vh - 112px);
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    padding: 10px 8px;
}

.sidebar nav {
    display: grid;
    gap: 1px;
}

.sidebar a,
.mobile-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--gray-800);
    padding: 7px 10px;
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.sidebar a .icon,
.mobile-nav a .icon {
    flex: none;
    color: var(--gray-600);
}

.sidebar a.is-active .icon {
    color: var(--red);
}

.sidebar a:hover,
.mobile-nav a:hover {
    border-color: var(--red);
    background: var(--row-hover);
}

.mobile-nav {
    display: none;
}

.content {
    padding: 18px 20px;
    max-width: 1400px;
    width: 100%;
    min-width: 0;
}

.app-footer {
    border-top: 1px solid var(--gray-200);
    background: var(--surface);
    color: var(--gray-600);
    padding: 12px 22px;
    font-size: 14px;
}

.page-title {
    margin: 0 0 14px;
    color: var(--blue);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
}

/* Intestazione di pagina uniforme: titolo+sottotitolo a sinistra, azioni a destra */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--blue);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.page-head-text {
    min-width: 0;
}

.page-head .page-title {
    margin: 0;
}

.page-head-text .muted {
    margin: 4px 0 0;
}

.page-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Toolbar filtri: campi GET su una riga compatta */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.filter-bar .form-row {
    margin: 0;
    min-width: 150px;
    flex: 1 1 150px;
}

.filter-bar > button,
.filter-bar > .button {
    align-self: flex-end;
}

@media (max-width: 640px) {
    .filter-bar .form-row {
        flex-basis: 100%;
    }
}

/* Banda di intestazione automatica per le pagine titolo+sottotitolo
   (senza azioni): stessa linea separatrice di .page-head, zero markup. */
.page-title + .muted {
    margin: -8px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* Dentro .page-head la banda è già gestita dal contenitore: niente doppio bordo. */
.page-head .page-title + .muted {
    margin: 4px 0 0;
    padding-bottom: 0;
    border-bottom: 0;
}

@media (max-width: 640px) {
    .page-head-actions {
        width: 100%;
    }
    .page-head-actions .button {
        flex: 1;
    }
}

.muted {
    color: var(--gray-600);
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.card h2,
.card h3 {
    margin-top: 0;
}

.dashboard-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.dashboard-card-link:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.admin-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.admin-card-icon {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--info-bg);
    color: var(--blue);
}

.admin-card-body {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.admin-card-body strong {
    color: var(--text);
}

.admin-card-go {
    margin-left: auto;
    flex: none;
    color: var(--gray-600);
    transform: rotate(-90deg);
}

/* Tessera statistica coerente per le dashboard (helper stat_card()). */
.stat-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
}
.stat-card-icon {
    grid-row: 1 / span 2;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--info-bg);
    color: var(--blue);
}
.stat-card .stat-number {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text);
}
.stat-card .stat-label {
    grid-column: 2 / 3;
    color: var(--gray-600);
    font-size: 13px;
}
.stat-card .stat-card-go {
    grid-row: 1 / span 2;
    grid-column: 3;
    color: var(--gray-600);
    transform: rotate(-90deg);
}

.button,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid transparent;
    background: var(--blue);
    color: var(--white);
    padding: 7px 13px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    gap: 8px;
    white-space: nowrap;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
    filter: brightness(.96);
}

.button-danger {
    background: var(--red);
}

.button-secondary {
    background: #475569;
}

.button-light {
    background: var(--gray-100);
    color: var(--text);
    border: 1px solid var(--gray-200);
}

.button-ghost {
    border: 1px solid var(--gray-300);
    background: var(--surface);
    color: var(--blue);
}

.button-ghost:hover {
    background: var(--surface-2);
    filter: none;
}

.app-header .button-ghost,
.user-box .button-ghost {
    border: 1px solid rgba(255, 255, 255, .75);
    background: transparent;
    color: var(--white);
}

button:disabled,
.button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 13px;
}

.table th,
.table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
    /* Annulla l'overflow-wrap:anywhere ereditato dal body: le parole non si
       spezzano più a metà nelle colonne strette (le colonne si dimensionano
       sulla parola più lunga); i token lunghissimi (email/URL) possono ancora
       andare a capo se necessario. Pattern globale per tutte le tabelle-elenco. */
    overflow-wrap: break-word;
}

.table th {
    color: var(--white);
    background: var(--blue);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody tr:nth-child(even) {
    background: var(--row-alt);
}

.table tbody tr:hover {
    background: var(--row-hover);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

/* Riepilogo Allerto: usa tutta la larghezza disponibile e resta leggibile con
   molte colonne; su schermi stretti si scorre in orizzontale mantenendo visibile la sede. */
.form-card > .allerto-overview-wrap {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}
.allerto-overview {
    width: max-content;
    min-width: 1500px;
    table-layout: auto;
}
.allerto-overview th {
    min-width: 105px;
    max-width: 170px;
    white-space: normal;
    vertical-align: bottom;
}
.allerto-overview th:first-child,
.allerto-overview td:first-child {
    position: sticky;
    left: 0;
    min-width: 160px;
    white-space: nowrap;
    background: var(--surface);
    box-shadow: 2px 0 4px rgba(15, 36, 55, .08);
}
.allerto-overview thead th:first-child {
    z-index: 2;
    background: var(--blue);
    color: var(--white);
}
.allerto-overview tbody tr:nth-child(even) td:first-child {
    background: var(--row-alt);
}

/* Tabella OdG Comando: prime 3 colonne su una riga, oggetto libero di andare a capo. */
.odg-table td {
    vertical-align: middle;
}
.odg-table td:nth-child(1),
.odg-table th:nth-child(1),
.odg-table td:nth-child(2),
.odg-table th:nth-child(2),
.odg-table td:nth-child(3),
.odg-table th:nth-child(3) {
    white-space: nowrap;
}
.odg-table td:nth-child(1) {
    font-variant-numeric: tabular-nums;
}
.odg-table td:nth-child(4) {
    white-space: normal;
    min-width: 340px;
    line-height: 1.35;
}
.odg-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}
.odg-table .actions-cell .button {
    vertical-align: middle;
}

.table th[data-sortable="true"] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
}

.table th[data-sortable="true"]::after {
    content: "↕";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: rgba(255, 255, 255, .55);
}

.table th[data-sort-direction="asc"]::after {
    content: "↑";
    color: var(--white);
}

.table th[data-sort-direction="desc"]::after {
    content: "↓";
    color: var(--white);
}

.form-row {
    display: grid;
    gap: 5px;
    margin-bottom: 11px;
}

label {
    font-weight: 600;
    /* Annulla l'overflow-wrap:anywhere del body: le etichette (es. "Anno", "Mese")
       non si spezzano mai a metà parola; vanno a capo solo tra parole. */
    overflow-wrap: normal;
    word-break: keep-all;
}

input,
select,
textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Select: rimuove la grafica nativa e usa una freccia custom coerente col tema */
select:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7585' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

[data-theme="dark"] select:not([multiple]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa6b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) select:not([multiple]) {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa6b5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }
}

select[multiple] {
    padding: 6px;
    min-height: 96px;
}

select[multiple] option {
    padding: 4px 6px;
    border-radius: var(--radius-sm);
}

option {
    color: var(--text);
    background: var(--surface);
}

/* ---- Select custom: pannello a tendina (sostituisce la lista nativa dell'OS) ----
   La <select> resta nel DOM; questo pannello è body-appended e posizionato via JS. */
.cselect-panel {
    position: fixed; z-index: 1000;
    display: flex; flex-direction: column;
    min-width: 160px; overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}
.cselect-search {
    margin: 6px; width: calc(100% - 12px);
    padding: 6px 8px; font: inherit;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
}
.cselect-list { overflow: auto; padding: 4px; }
.cselect-group {
    padding: 6px 8px 2px; font-size: .78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted);
}
.cselect-opt {
    padding: 7px 10px; border-radius: var(--radius-sm);
    cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text);
}
.cselect-opt.is-active { background: var(--row-hover); }
.cselect-opt.is-selected { font-weight: 600; color: var(--blue); }
.cselect-opt.is-selected::after { content: '✓'; float: right; margin-left: 12px; }
.cselect-opt.is-disabled { color: var(--text-muted); cursor: default; opacity: .6; }

/* Struttura canonica dei form: card tematica con campi su griglia responsive.
   Convertire un form = cambiare class="card" in class="form-card". */
.form-card {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px 16px;
    align-items: start;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.form-card .form-row {
    margin-bottom: 0;
}

/* Elementi a tutta larghezza: titoli, testo, flash, sezioni annidate, textarea, azioni */
.form-card > h2,
.form-card > h3,
.form-card > p,
.form-card > hr,
.form-card > section,
.form-card > fieldset,
.form-card > .flash,
.form-card > .form-actions,
.form-card .form-span-2,
.form-card .form-row.full-width,
.form-card .check-grid,
.form-card .form-row:has(textarea),
.form-card .form-row:has(select[multiple]) {
    grid-column: 1 / -1;
}

/* Bottoni/azioni: a tutta riga ma allineati a sinistra, non stirati */
.form-card > .form-actions,
.form-card > button,
.form-card > input[type="submit"],
.form-card > .button {
    grid-column: 1 / -1;
    justify-self: start;
}

.form-card .form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Form-card annidata in un'altra card/sezione: appiattita (niente box nel box) */
.card > .form-card,
.profile-section > .form-card,
.form-section > .form-card {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
}

/* Sezione tematica per form multi-blocco (riusa l'aspetto profile-section) */
.form-section {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(18, 58, 95, .14);
    border-color: var(--blue);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

.profile-form {
    display: grid;
    gap: 18px;
}

.page-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-md);
}

.hero-person {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: var(--surface-2);
    border: 1px solid var(--gray-200);
    color: var(--blue);
    font-size: 22px;
    font-weight: 800;
}

.badge,
.pill,
.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm, 6px);
    background: var(--surface);
    color: var(--gray-800);
    padding: 5px 9px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success,
.chip-ok {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--green);
}

.badge-warning,
.chip-warn {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--amber);
}

.badge-danger,
.chip-bad {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--red);
}

.badge-info {
    background: color-mix(in srgb, var(--blue, #123a5f) 12%, transparent);
    border-color: color-mix(in srgb, var(--blue, #123a5f) 30%, transparent);
    color: var(--blue, #123a5f);
}

.badge-muted {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-600);
}

.profile-shell {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.profile-sidebar {
    position: sticky;
    top: 18px;
}

.summary-list {
    display: grid;
    gap: 12px;
}

.summary-label {
    margin: 0;
    color: var(--gray-600);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.summary-value {
    color: var(--gray-800);
    font-weight: 750;
    word-break: break-word;
}

.summary-divider {
    border: 0;
    border-top: 1px solid var(--gray-200);
    margin: 4px 0;
}

.profile-section {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}

.subsection-block {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
    background: var(--surface-2);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin: 0;
    color: var(--blue);
}

.section-heading span {
    color: var(--gray-600);
    font-size: 14px;
    text-align: right;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

.form-span-2 {
    grid-column: span 2;
}

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

.document-panel {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 14px;
}

.document-panel h3 {
    margin: 0 0 12px;
    color: var(--blue);
}

.document-upload {
    border-top: 1px solid var(--gray-200);
    padding-top: 10px;
}

.file-current {
    display: block;
    color: var(--gray-600);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    padding: 8px;
    word-break: break-all;
    font-size: 13px;
}

/* Restyle globale checkbox native (accent VVF + spunta custom). I componenti
   .switch/.segmented, definiti più avanti, prevalgono per source-order. */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 18px;
    min-width: 18px;
    height: 18px;
    max-width: 18px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: background .12s ease, border-color .12s ease;
}
input[type="checkbox"]:hover {
    border-color: var(--blue);
}
input[type="checkbox"]:checked {
    background: var(--blue);
    border-color: var(--blue);
}
input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}
input[type="checkbox"]:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
}

.inline-check input,
.check-grid input {
    width: auto;
}

.roles-card {
    display: grid;
    gap: 18px;
}

.roles-section {
    display: grid;
    gap: 14px;
}

.roles-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
}

.organization-selection-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.selection-item {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-weight: 600;
    cursor: pointer;
}

.selection-item:hover {
    border-color: var(--gray-300);
    background: var(--surface);
}

.selection-item input {
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
}

.selection-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.selection-copy strong {
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.35;
}

.selection-copy small {
    color: var(--gray-600);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
}

.action-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.import-section textarea {
    min-height: 260px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Elenco corsi: colonne brevi mai spezzate a metà parola (il body ha
   overflow-wrap:anywhere), colonna "Corso" e requisiti a capo normale. */
#courses-table th,
#courses-table td { white-space: nowrap; vertical-align: top; }
#courses-table .course-name-cell,
#courses-table .course-name-cell * { white-space: normal; overflow-wrap: normal; }
#courses-table .actions-cell { min-width: auto; }
#courses-table .actions-cell .row-actions { flex-wrap: nowrap; gap: 6px; }

/* Elenco automezzi: azioni solo-icona sempre su una riga (la tabella scrolla in .table-wrap) */
#vehicles-table .actions-cell { min-width: auto; }
#vehicles-table .actions-cell .row-actions { flex-wrap: nowrap; gap: 6px; }

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* Filtro mese coerente in tutto il portale */
.month-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.month-filter label {
    font-weight: 600;
    color: var(--text-muted, #5b6472);
    margin: 0;
    white-space: nowrap;
}

.month-filter input[type="month"] {
    min-width: 168px;
    margin: 0;
}

/* E-learning: quiz e liste */
.quiz-question {
    border: 1px solid var(--border-color, #d8dee6);
    border-radius: 10px;
    padding: 16px 18px;
    margin: 0 0 16px;
    background: var(--surface, #fff);
}
.quiz-question legend {
    font-weight: 600;
    font-size: 1.02rem;
    line-height: 1.4;
    padding: 0;
    margin-bottom: 10px;
    color: var(--text, #1c2430);
}
.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    border: 1px solid var(--border-color, #d8dee6);
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.quiz-option:hover { background: var(--gray-50, #f3f5f8); }
.quiz-option input[type="radio"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 2px 0 0;
    flex: 0 0 auto;
    appearance: auto;
    -webkit-appearance: radio;
}
.quiz-option span { flex: 1 1 auto; min-width: 0; }
.quiz-option:has(input:checked) {
    border-color: var(--primary, #005ac8);
    background: color-mix(in srgb, var(--primary, #005ac8) 8%, transparent);
}
.clean-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.clean-list li { padding: 8px 10px; border: 1px solid var(--border-color, #d8dee6); border-radius: 8px; }

/* Riga di raggruppamento (es. elenco iscritti corso per distaccamento) */
.table .group-row td { background: var(--gray-50, #eef2f7); }

/* Modalità "solo icona": sui bottoni che CONTENGONO un'icona il testo viene nascosto
   (font-size:0 azzera i nodi di testo, l'icona SVG mantiene la sua dimensione), lasciando
   il tooltip via title. I bottoni SENZA icona restano invariati (fallback sicuro). */
.ui-btn-icononly .button:has(> .icon),
.ui-btn-icononly button:has(> .icon) {
    font-size: 0;
    gap: 0;
}
.ui-btn-icononly .button:has(> .icon) .icon,
.ui-btn-icononly button:has(> .icon) .icon {
    font-size: initial;
}
/* Le voci dei menu a tendina (Operi come, notifiche, menu utente) devono SEMPRE
   mostrare l'etichetta: la modalità solo-icona vale per i bottoni d'azione, non per i menu. */
.ui-btn-icononly .operate-as-option,
.ui-btn-icononly .operate-as-option > span,
.ui-btn-icononly .notif-panel button,
.ui-btn-icononly .user-menu-panel button,
.ui-btn-icononly .user-menu-panel a {
    font-size: 0.9rem;
    gap: 8px;
}
/* La .btn-label resta accessibile agli screen reader anche in solo-icona. */
.ui-btn-icononly .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Tabella iscritti corso: azioni compatte e leggibili */
.course-enrollments-table .req-cell { font-size: 12px; line-height: 1.5; }
.course-enrollments-table .contacts-cell { font-size: 12px; }
.course-enrollment-action-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.course-enrollment-action-form .priority-input {
    width: 90px;
    min-width: 90px;
    min-height: 32px;
    padding: 4px 8px;
}
.course-enrollment-action-form .button { min-height: 32px; padding: 5px 10px; }

/* Colonne Azioni compatte in stile elenco Corsi: bottoni solo-icona in fila,
   con a-capo morbido; input inline mantenuti stretti. .actions-stack sulle <td>. */
.actions-stack { min-width: auto; }
.actions-stack .row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.actions-stack .inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.actions-stack input:not([type=hidden]),
.actions-stack select { max-width: 150px; }
.course-enrollments-table .course-enrollment-action-form {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    vertical-align: top;
}

/* Chip "Operi come" nell'header + menu di selezione */
.operate-as-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--radius-sm, 6px);
    background: rgba(255, 255, 255, 0.15);
    color: var(--white, #fff);
    font-size: 0.82rem;
    white-space: nowrap;
}
.operate-as-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 8px 4px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-color, #d8dee6);
}
.operate-as-menu form { margin: 0; }

/* Selettore "Opera come" dedicato nell'header — pill piatto su una riga */
.operate-as-switch { position: relative; }
.operate-as-switch > summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px 0 12px;
    cursor: pointer;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    color: var(--white, #fff);
    white-space: nowrap;
    list-style: none;
    transition: background .12s, border-color .12s;
}
.operate-as-switch > summary:hover { background: rgba(255, 255, 255, 0.18); }
.operate-as-switch > summary::-webkit-details-marker { display: none; }
.operate-as-switch > summary .icon { opacity: .9; flex: 0 0 auto; }
.operate-as-switch.is-active > summary {
    background: rgba(255, 255, 255, 0.20);
    border-color: rgba(255, 255, 255, 0.45);
}
.operate-as-switch .operate-as-label {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    line-height: 1;
}
.operate-as-switch .operate-as-caption { font-size: 0.8rem; font-weight: 600; opacity: .8; }
.operate-as-switch .operate-as-caption::after { content: ":"; }
.operate-as-switch .operate-as-label strong { font-size: 0.9rem; }
.operate-as-switch .icon-chevron-down { transition: transform .15s; }
.operate-as-switch[open] > summary .icon-chevron-down { transform: rotate(180deg); }

/* Pannello opzioni ruolo */
.operate-as-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 8px;
}
.operate-as-head {
    margin: 0 0 8px;
    font-size: 0.8rem;
    color: var(--text-muted, #5b6472);
}
.operate-as-panel form { margin: 0; }
.operate-as-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: flex-start;
    background: transparent;
    color: var(--text, #11161f);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 10px;
    text-align: left;
    min-height: 40px;
}
.operate-as-option:hover { background: var(--gray-50, #f3f5f8); }
.operate-as-option > span { flex: 1 1 auto; }
.operate-as-option.is-current {
    background: color-mix(in srgb, var(--primary, #005ac8) 12%, transparent);
    border-color: color-mix(in srgb, var(--primary, #005ac8) 35%, transparent);
    color: var(--primary, #005ac8);
    font-weight: 700;
}
@media (max-width: 640px) {
    .operate-as-switch .operate-as-label { display: none; }
}

/* Chip d'indicazione ambito nelle pagine di lettura */
.scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--border-color, #d8dee6);
    border-radius: var(--radius-sm, 6px);
    background: var(--surface, #f4f6fa);
    font-size: 0.85rem;
    color: var(--text-muted, #5b6472);
}

.scope-chip .icon {
    color: var(--primary, #005ac8);
}

.actions-cell {
    min-width: 230px;
}

.mobile-only {
    display: none !important;
}

.flash,
.impersonation-banner {
    padding: 12px 16px;
    margin-bottom: 16px;
}

.flash-success {
    border-left: 4px solid var(--green);
    background: var(--success-bg);
}

.flash-error {
    border-left: 4px solid var(--red);
    background: var(--danger-bg);
}

.flash-info {
    border-left: 4px solid var(--blue);
    background: var(--info-bg);
}

.flash-warning {
    border-left: 4px solid var(--amber);
    background: var(--warning-bg);
}

/* ---- File input uniforme (pulsante "Scegli file" con icona) ---- */
.file-field { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* input nativo nascosto ma funzionante/accessibile */
.file-field input[type="file"] {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.file-field-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 14px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: border-color .15s, background .15s, color .15s;
}
.file-field-btn:hover { border-color: var(--blue); color: var(--blue); }
.file-field-btn .icon { flex: 0 0 auto; }
.file-field-btn.is-focused { border-color: var(--blue); box-shadow: 0 0 0 3px var(--info-bg); }
.file-field-name { color: var(--text-muted); font-size: 14px; word-break: break-word; }

/* Fallback senza JS: restyle del pulsante nativo ::file-selector-button */
input[type="file"]:not([data-file-enhanced])::file-selector-button {
    height: 34px; margin-right: 10px; padding: 0 14px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font-size: 14px; font-weight: 600; cursor: pointer;
}
input[type="file"]:not([data-file-enhanced])::file-selector-button:hover { border-color: var(--blue); color: var(--blue); }

/* ---- Aiuto contestuale: drawer + indice moduli + novità ---- */
.help-drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 90;
    opacity: 0; transition: opacity .2s;
}
.help-drawer-overlay.is-open { opacity: 1; }
.help-drawer {
    position: fixed; top: 0; right: 0; z-index: 91; height: 100vh; width: 420px; max-width: 92vw;
    background: var(--surface); border-left: 1px solid var(--border-color); box-shadow: var(--shadow-md);
    display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease;
}
.help-drawer.is-open { transform: translateX(0); }
.help-drawer-head, .help-drawer-foot {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-color);
}
.help-drawer-foot { border-bottom: 0; border-top: 1px solid var(--border-color); margin-top: auto; }
.help-drawer-title { margin: 0; font-size: 18px; flex: 1; }
.help-drawer-body { padding: 16px; overflow: auto; flex: 1; }
.help-drawer-body h1, .help-drawer-body h2 { font-size: 17px; margin: 4px 0 8px; }
.help-drawer-body h3 { font-size: 15px; margin: 14px 0 6px; }

/* Indice moduli nella pagina Aiuto */
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.help-toc a {
    display: inline-flex; padding: 6px 12px; border: 1px solid var(--border-color);
    border-radius: 999px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--text);
}
.help-toc a:hover { border-color: var(--blue); color: var(--blue); }

/* Blocco "Novità recenti" */
.help-changes { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--border-color); }
.help-changes h3 { display: flex; align-items: center; gap: 6px; font-size: 15px; margin: 0 0 8px; }
.help-changes ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.help-changes li { font-size: 14px; line-height: 1.5; }
.help-change-date { margin: 0 6px; font-size: 12px; }
.help-panel-more { margin-top: 14px; }

/* ---- Report: multiselect filtri + barra filtri/azioni ---- */
#report-filters .multiselect { position: relative; }
#report-filters .multiselect-toggle {
    min-width: 150px; height: 38px; text-align: left; position: relative;
    padding: 0 30px 0 11px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
#report-filters .multiselect-toggle::after {
    content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
    border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
#report-filters .multiselect-toggle.has-selection { border-color: var(--blue); color: var(--blue); font-weight: 600; }
#report-filters .multiselect.is-open .multiselect-toggle { border-color: var(--blue); }
#report-filters .multiselect-panel {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 220px;
    background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 6px; display: none; flex-direction: column; gap: 2px; max-height: 300px; overflow: auto;
}
#report-filters .multiselect.is-open .multiselect-panel { display: flex; }
#report-filters .multiselect-panel .inline-check {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm);
    font-weight: 500; cursor: pointer; white-space: nowrap;
}
#report-filters .multiselect-panel .inline-check:hover { background: var(--row-hover); }
#report-filters .section-heading { margin: 6px 0 8px; }
#report-filters .form-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 18px; margin-bottom: 6px;
}
#report-filters .form-grid .form-row { margin: 0; }
@media (max-width: 820px) { #report-filters .form-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { #report-filters .form-grid { grid-template-columns: 1fr; } }
.report-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.report-actions-sep { flex: 1 1 auto; }
@media (max-width: 560px) { .report-actions-sep { flex-basis: 100%; } }

.impersonation-banner {
    margin: 0;
    background: var(--red);
    color: var(--white);
    text-align: center;
    font-weight: 700;
}

.impersonation-banner a {
    color: var(--white);
}

.impersonation-banner form {
    display: inline;
}

/* ---- Consolidamento: sistema training_hours (ex <style> inline) ---- */
.toolbar-actions,
.picker-actions,
.badge-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}
.attendee-search {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 6px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm, 6px);
    background: var(--surface);
    color: var(--text);
}
/* Tabella presenti: altezza limitata con intestazione fissa per liste lunghe. */
#attendee_table { margin-top: 8px; }
.form-row .table-wrap { max-height: 380px; overflow-y: auto; }
#attendee_table thead th { position: sticky; top: 0; z-index: 1; }

.session-head {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.grid-form,
.compact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-form .form-row,
.compact-grid .form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

.grid-form .form-row.full-width,
.compact-grid .form-row.full-width {
    grid-column: 1 / -1;
}

.checkbox-row {
    justify-content: flex-end;
}

.form-actions {
    align-items: flex-start;
}

/* Barra azioni orizzontale (dentro le griglie form): i bottoni non si impilano */
.grid-form .form-row.form-actions,
.compact-grid .form-row.form-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Spinge le azioni successive a destra (separa il submit dagli export) */
.form-actions .toolbar-spacer {
    margin-left: auto;
}
@media (max-width: 720px) {
    .form-actions .toolbar-spacer { margin-left: 0; flex-basis: 100%; height: 0; }
}

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

.attendee-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.attendee-item input {
    margin-right: 8px;
}

.attendee-main {
    font-weight: 600;
}

.attendee-meta {
    font-size: .92rem;
    color: var(--gray-600);
}

.attendee-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Badge a doppia classe (.badge.success/.warning/.danger/.muted) mappati sui token */
.badge.success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--green);
}

.badge.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--amber);
}

.badge.danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--red);
}

.badge.muted {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-600);
}

.badge.info {
    background: color-mix(in srgb, var(--blue, #123a5f) 12%, transparent);
    border-color: color-mix(in srgb, var(--blue, #123a5f) 30%, transparent);
    color: var(--blue, #123a5f);
}

.qr-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qr-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.qr-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.qr-panel {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
}

.qr-panel img {
    max-width: 100%;
    height: auto;
}

.qr-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qr-link input {
    width: 100%;
}

/* ---- Pagine standalone di autenticazione (login, MFA, check-in, installer) ---- */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(460px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--red);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.auth-card.auth-card-wide {
    width: min(880px, 100%);
}

.auth-card h1 {
    margin: 0 0 8px;
    color: var(--blue);
}

.auth-card form label {
    display: block;
    margin-top: 14px;
}

.auth-card form button[type="submit"] {
    width: 100%;
    margin-top: 18px;
}

.auth-alt {
    margin-top: 16px;
    font-size: 14px;
}

.auth-meta {
    margin: 16px 0;
    padding: 14px;
    background: var(--surface-2);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.auth-error,
.auth-success,
.auth-notice {
    padding: 12px 14px;
    margin: 16px 0;
    border-radius: 6px;
}

.auth-error {
    border-left: 4px solid var(--red);
    background: var(--danger-bg);
}

.auth-success {
    border-left: 4px solid var(--green);
    background: var(--success-bg);
}

.auth-notice {
    border-left: 4px solid var(--blue);
    background: var(--info-bg);
}

.code-input {
    font-size: 20px;
    letter-spacing: 4px;
    text-align: center;
}

.auth-card fieldset {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin: 18px 0;
    padding: 14px;
}

.auth-card fieldset legend {
    font-weight: 700;
    color: var(--blue);
}

.status-ok {
    color: var(--green);
    font-weight: 700;
}

.status-ko {
    color: var(--red);
    font-weight: 700;
}

/* ---- Navigazione: stato attivo, skip-link, menu account, breadcrumb ---- */
.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    z-index: 100;
    background: var(--blue-dark);
    color: var(--white);
    padding: 10px 14px;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 0;
}

.sidebar a.is-active,
.mobile-nav a.is-active {
    border-left-color: transparent;
    background: var(--blue);
    color: var(--white);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.sidebar a.is-active .icon,
.mobile-nav a.is-active .icon {
    color: var(--white);
}

.user-menu {
    position: relative;
}

.user-menu > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    color: var(--white);
    font-weight: 700;
}

.user-menu > summary::-webkit-details-marker {
    display: none;
}

.user-menu > summary small {
    display: block;
    opacity: .86;
    font-weight: 600;
}

.user-menu[open] > summary::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 950;
    min-width: 220px;
    display: grid;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 8px;
}

.user-menu-panel a {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 6px;
}

.user-menu-panel a:hover {
    background: var(--gray-100);
}

.user-menu-panel form {
    margin: 0;
}

.user-menu-panel .button {
    width: 100%;
}

/* Campanello notifiche (riusa .user-menu / <details>) */
.notif-menu > summary { position: relative; gap: 0; }
.notif-dot {
    position: absolute; top: -6px; right: -8px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: var(--danger, #d33); color: #fff;
    font-size: 10px; line-height: 16px; text-align: center; font-weight: 700;
}
.notif-panel { min-width: 300px; max-width: 360px; }
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.notif-panel-head form, .notif-panel-head .button { width: auto; }
.notif-item { display: block; padding: 8px; border-radius: 8px; }
.notif-item strong { display: block; }
.notif-item.is-unread { background: rgba(0, 90, 200, .08); }
.notif-all { display: block; text-align: center; margin-top: 6px; font-weight: 600; }
tr.is-unread { font-weight: 600; }

/* Grafici a barre (server-side, senza JS) */
.chart-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.chart-bar-row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; align-items: center; gap: 10px; }
.chart-bar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { background: rgba(0,0,0,.08); border-radius: 999px; height: 14px; overflow: hidden; }
.chart-bar-fill { display: block; height: 100%; background: var(--primary, #005ac8); border-radius: 999px; min-width: 2px; }
.chart-bar-value { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.dashboard-widget-details { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border, rgba(0,0,0,.12)); }
.dashboard-widget-details > summary { cursor: pointer; color: var(--primary, #005ac8); font-weight: 650; }
.dashboard-widget-details[open] > .chart-bars { max-height: 55vh; overflow-y: auto; padding-right: 8px; }

/* Gauge semicircolare (SVG, senza JS) */
.gauge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.gauge svg { width: 100%; max-width: 220px; height: auto; }
.gauge-track { stroke: rgba(0,0,0,.10); stroke-width: 12; stroke-linecap: round; }
.gauge-fill { stroke-width: 12; stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.gauge-value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: -6px; }
.gauge-label { font-size: 13px; color: var(--text-muted); text-align: center; }

/* Ciambella (SVG, senza JS) */
.donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.donut svg { width: 120px; height: 120px; flex: 0 0 auto; }
.donut-track { stroke: rgba(0,0,0,.08); stroke-width: 14; }
.donut-seg { stroke-width: 14; transition: stroke-dasharray .4s ease; }
.donut-center { font-size: 22px; font-weight: 800; fill: var(--text); font-variant-numeric: tabular-nums; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1 1 auto; }
.donut-legend-item { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.donut-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.donut-legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Dark theme: tracce più chiare per gauge/donut/barre */
[data-theme="dark"] .gauge-track,
[data-theme="dark"] .donut-track { stroke: rgba(255,255,255,.14); }
[data-theme="dark"] .chart-bar-track { background: rgba(255,255,255,.12); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .gauge-track,
    :root:not([data-theme="light"]) .donut-track { stroke: rgba(255,255,255,.14); }
    :root:not([data-theme="light"]) .chart-bar-track { background: rgba(255,255,255,.12); }
}

@media print {
    .gauge svg, .donut svg { max-width: 180px; }
}

/* Calendario turni a squadre */
.cal-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-toolbar .button { min-width: 40px; }
.turni-legend { display: flex; gap: 16px; margin: 10px 0; font-size: 13px; flex-wrap: wrap; color: var(--text-muted); }
.turni-legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.turni-legend .lg-notte::before { background: var(--primary, #005ac8); }
.turni-legend .lg-festivo::before { background: #d97706; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-weight: 600; font-size: 12px; text-align: center; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding: 2px 0; }
.cal-day { min-height: 78px; border: 1px solid var(--border-color); border-radius: 10px; padding: 6px 8px; background: var(--surface); display: flex; flex-direction: column; gap: 3px; }
.cal-day--empty { background: transparent; border: 0; }
.cal-day--notte { border-left: 4px solid var(--primary, #005ac8); }
.cal-day--festivo { border-left: 4px solid #d97706; background: var(--warning-bg); }
.cal-day-num { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.cal-squad { font-weight: 700; font-size: 13px; line-height: 1.1; }
.cal-capo { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-entry { display: block; border-radius: 6px; padding: 2px 5px; margin-top: 2px; border-left: 3px solid transparent; }
.cal-entry--notte { background: rgba(0,90,200,.08); border-left-color: var(--primary, #005ac8); }
.cal-entry--festivo { background: var(--warning-bg); border-left-color: #d97706; }
.cal-entry .cal-squad { font-size: 12px; }
@media (max-width: 680px) {
    .cal-grid { gap: 3px; }
    .cal-day { min-height: 58px; padding: 4px; border-radius: 8px; }
    .cal-head { font-size: 10px; }
    .cal-capo { display: none; }
}
.turni-vigili { display: flex; flex-direction: column; gap: 2px; max-height: 150px; overflow: auto; padding: 4px; border: 1px solid var(--border-color); border-radius: 6px; }
.turni-vigili .inline-check { font-size: 13px; }
.turni-selected { font-size: 12px; line-height: 1.35; vertical-align: top; min-width: 12rem; }
.cal-chip { display: block; font-size: 11px; font-weight: 600; background: rgba(0,90,200,.10); border-radius: 5px; padding: 1px 5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Barra azioni di massa (elimina selezionati/tutti) */
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; padding: 8px 10px; background: var(--gray-50, #f3f5f8); border: 1px solid var(--border-color); border-radius: 8px; }
.bulk-bar .muted { margin-right: auto; }
.cal-chip-names { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 680px) { .cal-chip-names { display: none; } }

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .75);
    color: var(--white);
    min-height: 40px;
}

.breadcrumb {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--gray-600);
}

.breadcrumb a {
    text-decoration: none;
}

.breadcrumb span[aria-current] {
    color: var(--gray-800);
    font-weight: 700;
}

.empty-state {
    color: var(--gray-600);
    text-align: center;
    padding: 14px;
}

/* ---- Aiuto: ancoraggio contestuale ---- */
.profile-section { scroll-margin-top: 78px; }
.profile-section.help-target {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
    transition: outline-color .4s ease;
}

/* ---- Documentazione web (admin) ---- */
.docs-layout {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 720px) {
    .docs-layout { grid-template-columns: 1fr; }
}
.docs-index { display: flex; flex-direction: column; gap: 4px; }
@media (min-width: 721px) { .docs-index { position: sticky; top: 16px; } }
.docs-index-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 9px 11px; border: 1px solid var(--border-color); border-radius: var(--radius);
    background: var(--surface); color: var(--text); text-decoration: none;
}
.docs-index-item:hover { border-color: var(--blue); background: var(--surface-2); }
.docs-index-item.is-active { border-color: var(--blue); background: var(--info-bg); }
.docs-index-icon { display: inline-flex; color: var(--blue); margin-top: 1px; }
.docs-index-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.docs-index-title { font-weight: 600; font-size: .92rem; }
.docs-index-desc { font-size: .78rem; color: var(--text-muted); }
.docs-content { max-width: 80ch; }
.markdown-body { line-height: 1.6; overflow-wrap: anywhere; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin-top: 1.2em; }
.markdown-body h1:first-child, .markdown-body h2:first-child { margin-top: 0; }
.markdown-body pre { background: var(--surface-2); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; }
.markdown-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body hr { border: 0; border-top: 1px solid var(--border-color); margin: 1.2em 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 13px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-color); padding: 6px 9px; text-align: left; vertical-align: top; }
.markdown-body thead th { background: var(--surface-2); }

/* ---- Changelog / Novità (timeline) ---- */
.changelog-timeline { display: flex; flex-direction: column; gap: 18px; max-width: 900px; }
.changelog-day { display: grid; grid-template-columns: 160px 1fr; gap: 16px; align-items: start; }
.changelog-date {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 700; color: var(--blue); font-size: .95rem;
    position: sticky; top: 16px;
}
.changelog-entries { display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--border-color); padding-left: 16px; }
.changelog-entry {
    background: var(--surface); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 10px 12px; position: relative;
}
.changelog-entry::before {
    content: ""; position: absolute; left: -22px; top: 14px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--blue); box-shadow: 0 0 0 3px var(--bg);
}
.changelog-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 5px; }
.cl-area {
    display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em; color: var(--blue);
    background: var(--info-bg); border: 1px solid var(--border-color);
    padding: 1px 7px; border-radius: var(--radius-sm, 6px);
}
.cl-migr {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
    color: var(--text-muted); background: var(--surface-2);
    border: 1px solid var(--border-color); padding: 1px 7px; border-radius: var(--radius-sm, 6px);
}
.changelog-text { margin: 0; line-height: 1.5; }
@media (max-width: 640px) {
    .changelog-day { grid-template-columns: 1fr; gap: 6px; }
    .changelog-date { position: static; }
}

/* Tab di switch tra le viste changelog */
.changelog-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.changelog-tabs a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; text-decoration: none; color: var(--text-muted);
    font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.changelog-tabs a:hover { color: var(--text); }
.changelog-tabs a.is-active { color: var(--blue); border-bottom-color: var(--blue); }

/* Categoria (Tipo) — pill/etichetta colorata, usata sia inline (timeline) sia come h3 (versione) */
.cl-cat {
    display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .03em; padding: 1px 8px; border-radius: var(--radius-sm, 6px);
    border: 1px solid transparent;
}
h3.cl-cat { margin: 0 0 8px; }
.cl-cat--add { background: var(--success-bg); color: var(--green); border-color: var(--success-border); }
.cl-cat--chg { background: var(--info-bg); color: var(--blue); border-color: var(--border-color); }
.cl-cat--fix { background: var(--warning-bg); color: #92660a; border-color: var(--warning-border); }
.cl-cat--sec { background: var(--danger-bg); color: var(--red); border-color: var(--danger-border); }
.cl-cat--rem, .cl-cat--dep { background: var(--surface-2); color: var(--text-muted); border-color: var(--border-color); }

/* Vista per versione (Keep a Changelog) */
.changelog-versions { display: flex; flex-direction: column; gap: 22px; max-width: 900px; }
.cl-version { border: 1px solid var(--border-color); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.cl-version-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; margin-bottom: 12px; }
.cl-version-head h2 { margin: 0; color: var(--blue); }
.cl-cat-block { margin: 12px 0; }
.cl-cat-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; line-height: 1.5; }
.cl-cat-list li { padding-left: 2px; }

/* ---- Ricerca live + scroll infinito / filtro liste ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.table-search > .form-row,
.list-filter {
    margin-bottom: 12px;
    max-width: 420px;
}

input[type="search"] {
    width: 100%;
}

.list-sentinel {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.list-sentinel.is-loading::after {
    content: "…";
}

:focus-visible {
    outline: 3px solid rgba(18, 58, 95, .35);
    outline-offset: 2px;
}

/* ---- Pulsanti icona in topbar, toggle tema, header-right ---- */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    min-height: 38px;
    width: 38px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .35);
    color: var(--white);
    border-radius: var(--radius-sm);
}

.icon-button:hover {
    background: rgba(255, 255, 255, .12);
    filter: none;
}

.theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-sun { display: inline-grid; }
[data-theme="dark"] .theme-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-sun { display: inline-grid; }
    :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}

/* La compressione sidebar è desktop-only (su mobile vale l'hamburger). */
.sidebar-toggle { display: none; }

/* ---- Sidebar collassata: rail solo-icone ---- */
@media (min-width: 821px) {
    .sidebar-toggle { display: inline-grid; }

    html.sidebar-collapsed .app-shell {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    html.sidebar-collapsed .sidebar {
        padding: 10px 6px;
    }

    html.sidebar-collapsed .sidebar a {
        justify-content: center;
        padding: 9px 0;
        gap: 0;
    }

    html.sidebar-collapsed .sidebar .nav-label {
        display: none;
    }
}

/* ---- Dialog modale ---- */
.modal {
    border: 0;
    padding: 0;
    border-radius: var(--radius);
    background: transparent;
    max-width: 460px;
    width: calc(100% - 32px);
}

.modal::backdrop {
    background: rgba(8, 12, 18, .55);
}

.modal-card {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 20px;
    display: grid;
    gap: 12px;
}

.modal-title {
    margin: 0;
    color: var(--blue);
    font-size: 18px;
}

.modal-message {
    margin: 0;
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Modale di contenuto (form add/edit) */
.modal-lg {
    max-width: 760px;
    width: calc(100% - 32px);
}

.modal-lg .modal-card {
    max-height: 90vh;
    overflow: auto;
    gap: 0;
    padding: 0;
}

.modal-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.modal-head .modal-title {
    margin: 0;
}

.modal-close {
    border-color: var(--border-color);
    color: var(--text);
}

.modal-close:hover {
    background: var(--surface-2);
}

.modal-body {
    padding: 18px;
}

/* Il contenuto iniettato non ridisegna la propria intestazione di pagina */
.modal-body .page-title,
.modal-body .breadcrumb,
.modal-body .page-head {
    display: none;
}

.modal-body .card,
.modal-body .profile-section,
.modal-body .form-section,
.modal-body .form-card {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.modal-body .form-card {
    gap: 14px;
    display: grid;
}

.modal-busy {
    opacity: .5;
    pointer-events: none;
}

/* Sezioni della sidebar */
.nav-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--gray-600);
    padding: 12px 10px 4px;
}

html.sidebar-collapsed .nav-section {
    display: none;
}

html.sidebar-collapsed .sidebar nav + .nav-section,
html.sidebar-collapsed .nav-section {
    border-top: 1px solid var(--border-color);
    padding: 6px 0;
}

/* Pulsanti "add" solo icona */
.button.icon-only {
    width: 36px;
    padding: 0;
}

.button.icon-only .icon {
    margin: 0;
}

/* ---- Accordion (sezioni collassabili) ---- */
[data-accordion] .section-heading,
.profile-section[data-accordion] .section-heading {
    cursor: pointer;
    user-select: none;
}

[data-accordion] .section-heading .accordion-chevron,
.profile-section[data-accordion] .section-heading .accordion-chevron {
    transition: transform .15s ease;
    color: var(--gray-600);
    margin-left: auto;
}

[data-accordion] .profile-section.is-collapsed .accordion-chevron,
.profile-section[data-accordion].is-collapsed .accordion-chevron {
    transform: rotate(-90deg);
}

[data-accordion] .profile-section.is-collapsed > :not(.section-heading),
.profile-section[data-accordion].is-collapsed > :not(.section-heading) {
    display: none;
}

/* ---- Utility ---- */
.mt-1 { margin-top: 8px; }
.row-actions,
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.text-success { color: var(--green); font-weight: 700; }
.text-danger { color: var(--red); font-weight: 700; }

@media (max-width: 820px) {
    .app-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .user-box {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 10px 14px;
        text-align: left;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .mobile-nav {
        display: none;
        flex-direction: column;
        gap: 4px;
        padding: 10px 12px;
        background: var(--surface);
        border-bottom: 1px solid var(--gray-200);
    }

    .mobile-nav.is-open {
        display: flex;
    }

    .mobile-nav a {
        border-left: 4px solid transparent;
        padding: 12px;
    }

    .grid-form,
    .compact-grid {
        grid-template-columns: 1fr;
    }

    .user-menu-panel {
        position: static;
        box-shadow: none;
        border: 0;
        padding: 0;
        min-width: 0;
    }

    .content {
        padding: 16px 12px 24px;
    }

    .page-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px;
    }

    .profile-shell {
        grid-template-columns: 1fr;
    }

    .profile-sidebar {
        position: static;
    }

    .section-heading {
        display: block;
    }

    .section-heading span {
        display: block;
        margin-top: 6px;
        text-align: left;
    }

    .form-span-2 {
        grid-column: auto;
    }

    .action-section {
        align-items: stretch;
        flex-direction: column;
    }

    .action-section > .button,
    .action-section > button,
    .action-section > input[type="submit"] {
        width: 100%;
    }

    .inline-form,
    .course-enrollment-action-form,
    .inline-action-form {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .inline-form select,
    .inline-form input,
    .course-enrollment-action-form input,
    .course-enrollment-action-form button,
    .inline-action-form button {
        width: 100%;
    }

    .actions-cell {
        min-width: 0;
    }

    .card {
        padding: 14px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .document-grid,
    .roles-selection-grid,
    .organization-selection-grid,
    .check-grid {
        grid-template-columns: 1fr;
    }

    .selection-item {
        grid-template-columns: 22px minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .brand {
        align-items: flex-start;
    }

    .brand > div,
    .brand strong,
    .brand small {
        min-width: 0;
    }

    .brand strong {
        display: block;
        font-size: 15px;
        line-height: 1.25;
    }

    .brand small {
        font-size: 12px;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .page-title {
        font-size: 22px;
    }

    .app-footer {
        padding: 12px;
        font-size: 12px;
    }

    .table-wrap,
    .table {
        border: 0;
        background: transparent;
    }

    .table.responsive-table thead {
        display: none;
    }

    .table.responsive-table tbody,
    .table.responsive-table tr,
    .table.responsive-table td {
        display: block;
        width: 100%;
    }

    .table.responsive-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius);
        background: var(--surface);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
    }

    .table.responsive-table td {
        border-bottom: 1px solid var(--gray-200);
        padding: 10px 12px;
        min-height: 44px;
    }

    .table.responsive-table td:last-child {
        border-bottom: 0;
    }

    .table.responsive-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--gray-600);
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
    }

    .table.responsive-table td.actions-cell,
    .table.responsive-table td:last-child {
        background: var(--surface-2);
    }

    .table.responsive-table td.actions-cell .button,
    .table.responsive-table td.actions-cell button,
    .table.responsive-table td:last-child .button,
    .table.responsive-table td:last-child button {
        width: 100%;
    }

    .mobile-nav {
        gap: 4px;
        padding: 8px 10px;
    }

    .mobile-nav a {
        padding: 9px 10px;
        font-size: 13px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }
}

/* ============================================================
   Rifinitura grafica generale: micro-interazioni e coerenza
   ============================================================ */

::selection {
    background: rgba(18, 58, 95, .18);
}
[data-theme="dark"] ::selection {
    background: rgba(120, 170, 220, .28);
}

/* Transizioni morbide su elementi interattivi */
.button,
button,
input[type="submit"],
.icon-button,
input,
select,
textarea,
a.card,
.admin-card,
.hub-card {
    transition: background-color .15s ease, border-color .15s ease,
                box-shadow .15s ease, transform .12s ease, filter .15s ease;
}

/* Feedback "premuto" sui pulsanti */
.button:active,
button:active,
input[type="submit"]:active {
    transform: translateY(1px);
}

/* Card cliccabili (hub/admin): sollevamento all'hover */
a.card,
.card:has(> .admin-card) {
    cursor: pointer;
}
a.card:hover,
.card:has(> .admin-card):hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
a.card:hover .admin-card-go,
.card:hover .admin-card-go {
    color: var(--blue);
}

/* Le righe-azione mantengono allineamento e spaziatura coerenti */
.actions-cell .row-actions {
    align-items: center;
}

/* Le tabelle ottengono profondità coerente con le card */
.table {
    box-shadow: var(--shadow-sm);
}

/* Stato vuoto più riconoscibile */
.empty-state {
    font-style: italic;
}

/* Rispetto delle preferenze di movimento ridotto */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .app-header,
    .sidebar,
    .mobile-nav,
    .app-footer,
    .button,
    button,
    form {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .content {
        padding: 0;
        max-width: none;
    }

    body {
        background: #fff;
    }
}

/* Controllo segmentato: radio mascherati da pulsanti (esiti checklist). Nessun JS. */
.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
}
.segmented label {
    position: relative;
    margin: 0;
}
.segmented input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.segmented span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.segmented label:hover span {
    border-color: var(--blue);
}
.segmented input:focus-visible + span {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}
/* Stato selezionato: neutro (blu), positivo (verde), negativo (rosso). */
.segmented input:checked + span {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}
.segmented input:checked + span.seg-ok {
    background: var(--green);
    border-color: var(--green);
}
.segmented input:checked + span.seg-ko {
    background: var(--red);
    border-color: var(--red);
}

/* Interruttore on/off per checkbox (es. "presente"). */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: auto;
    margin: 0;
}
.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .slider {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--gray-300);
    transition: background .15s ease;
}
.switch .slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease;
}
.switch input:checked + .slider {
    background: var(--green);
}
.switch input:checked + .slider::before {
    transform: translateX(18px);
}
.switch input:focus-visible + .slider {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}

/* Gruppi di pagina collassabili (es. gruppi di template). */
.tpl-group {
    margin-top: 18px;
}
.tpl-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--blue);
    font-size: 1.15rem;
    font-weight: 700;
    padding: 4px 0 8px;
    cursor: pointer;
    min-height: 0;
}
.tpl-group-head:hover {
    filter: none;
    color: var(--blue);
}
.tpl-group-head .accordion-chevron {
    margin-left: auto;
    color: var(--gray-600);
    transition: transform .15s ease;
    display: inline-flex;
}
.tpl-group.is-collapsed .tpl-group-head .accordion-chevron {
    transform: rotate(-90deg);
}
.tpl-group.is-collapsed .tpl-group-body {
    display: none;
}
.tpl-group-desc {
    margin-top: 8px;
}
.collapse-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

/* Sezioni sidebar collassabili: la label diventa un pulsante con chevron. */
.nav-group {
    display: grid;
    gap: 1px;
}
button.nav-section {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 12px 10px 4px;
    min-height: 0;
    cursor: pointer;
    border-radius: 0;
}
button.nav-section:hover {
    filter: none;
    color: var(--text);
}
.nav-section-chevron {
    margin-left: auto;
    display: inline-flex;
    transition: transform .15s ease;
}
.nav-group.is-collapsed .nav-section-chevron {
    transform: rotate(-90deg);
}
.nav-group.is-collapsed .nav-group-items {
    display: none;
}

/* Badge di stato sulle voci di menu (Base/Beta/pallino) */
.nav-badge {
    margin-left: auto;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 1px 6px;
    border-radius: var(--radius-sm, 6px);
    line-height: 1.5;
    flex: 0 0 auto;
}
/* Palette badge (colore scelto in admin) */
.nav-badge--color-blue { background: var(--info-bg); color: var(--blue); border: 1px solid var(--border-color); }
.nav-badge--color-green { background: var(--success-bg); color: var(--green); border: 1px solid var(--success-border); }
.nav-badge--color-amber { background: var(--warning-bg); color: #92660a; border: 1px solid var(--warning-border); }
.nav-badge--color-red { background: var(--danger-bg); color: var(--red); border: 1px solid var(--danger-border); }
.nav-badge--color-purple { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.nav-badge--color-gray { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-color); }
.nav-badge--dot { width: 8px; height: 8px; padding: 0; background: var(--red); border-radius: 50%; }
/* In modalità rail (solo icone) i badge testuali sono nascosti col resto delle label. */
html.sidebar-collapsed .nav-badge { display: none; }

/* Configurazione badge voci menu (admin) */
.badge-config { display: flex; flex-direction: column; gap: 6px; }
.badge-config-row { display: flex; align-items: center; gap: 12px; }
.badge-config-label { display: inline-flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.badge-config-row select { max-width: 160px; }

/* Config moduli (admin): matrice moduli × tipi ente */
.module-matrix { width: 100%; border-collapse: collapse; }
.module-matrix th, .module-matrix td { border: 1px solid var(--border-color); padding: 6px 9px; text-align: center; }
.module-matrix th:first-child, .module-matrix td:first-child { text-align: left; font-weight: 600; }
.module-matrix thead th { background: var(--surface-2); font-size: 12px; }
.module-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.module-toggle-row:last-child { border-bottom: 0; }
.badge-types-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.badge-type-row { display: flex; align-items: center; gap: 10px; }

/* Ricerca globale (header) */
/* Box ricerca: stessa "pill" di header dell'Opera come (traslucida su accento). */
.global-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 10px 0 34px;
    border-radius: var(--radius-sm, 8px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
    transition: background .12s, border-color .12s;
}
.global-search:hover,
.global-search:focus-within { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.45); }
.global-search-icon {
    position: absolute;
    left: 11px;
    display: inline-flex;
    color: var(--white, #fff);
    opacity: .9;
    pointer-events: none;
}
.global-search input[type="search"] {
    width: 220px;
    max-width: 42vw;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--white, #fff);
    font-size: .9rem;
}
.global-search input[type="search"]:focus { outline: none; }
.global-search input[type="search"]::placeholder { color: rgba(255, 255, 255, 0.7); }
.global-search-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 380px;
    max-width: 90vw;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 60;
    padding: 6px;
}
.global-search-group + .global-search-group {
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 4px;
}
.global-search-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    padding: 6px 8px 2px;
    margin: 0;
}
.global-search-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
}
.global-search-item:hover,
.global-search-item.is-active {
    background: var(--row-hover);
}
.global-search-item .gs-title {
    font-weight: 600;
    font-size: .9rem;
}
.global-search-item .gs-sub {
    font-size: .78rem;
    color: var(--text-muted);
}
.global-search-all {
    font-weight: 600;
    font-size: .85rem;
    color: var(--blue);
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 9px;
}
/* Pagina risultati ricerca */
.search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.search-results-list li + li {
    border-top: 1px solid var(--border-color);
}
.search-results-list a {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--text);
}
.search-results-list a:hover {
    background: var(--row-hover);
}
.search-results-list .gs-title { font-weight: 600; }
.search-results-list .gs-sub { font-size: .82rem; color: var(--text-muted); }
.global-search-empty {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    margin: 0;
}
@media (max-width: 820px) {
    .global-search input[type="search"] { width: 150px; }
    .global-search-panel { position: fixed; left: 8px; right: 8px; width: auto; }
}

/* Evidenziazione del termine cercato (dropdown + pagina) */
mark, .gs-title mark, .gs-sub mark {
    background: color-mix(in srgb, var(--blue) 22%, transparent);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

/* Footer del dropdown: conteggio + hint tastiera */
.global-search-footer {
    padding: 8px 10px 4px;
    margin-top: 4px;
    border-top: 1px solid var(--border-color);
    font-size: .74rem;
    color: var(--text-muted);
    text-align: center;
}
.global-search-footer kbd,
.search-tip kbd {
    font: inherit;
    background: var(--row-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0 4px;
}

/* Skeleton di caricamento del dropdown */
.gs-skeleton { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.gs-skeleton span {
    height: 12px; border-radius: 6px;
    background: linear-gradient(90deg, var(--row-hover) 25%, var(--border-color) 37%, var(--row-hover) 63%);
    background-size: 400% 100%;
    animation: gs-shimmer 1.2s ease-in-out infinite;
}
.gs-skeleton span:nth-child(odd) { width: 70%; }
.gs-skeleton span:nth-child(even) { width: 90%; }
@keyframes gs-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---- Pagina ricerca: barra prominente, chip filtro, empty-state ---- */
.search-page-bar {
    display: flex; align-items: center; gap: 8px;
    position: relative;
    margin-bottom: 16px;
}
.search-page-bar .search-page-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none; display: inline-flex;
}
.search-page-bar input[type="search"] {
    flex: 1 1 auto;
    height: 48px;
    padding: 0 14px 0 44px;
    font-size: 1.05rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface); color: var(--text);
}
.search-page-bar input[type="search"]:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent);
}
.search-page-bar button { height: 48px; white-space: nowrap; }

.search-count { margin: 0 0 12px; }

.search-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.search-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color); border-radius: 999px;
    background: var(--surface); color: var(--text);
    text-decoration: none; font-size: .85rem; font-weight: 600;
    transition: background .12s, border-color .12s, color .12s;
}
.search-chip:hover { background: var(--row-hover); }
.search-chip .badge { background: var(--row-hover); color: var(--text-muted); }
.search-chip.is-active {
    background: var(--blue); border-color: var(--blue); color: #fff;
}
.search-chip.is-active .badge { background: rgba(255, 255, 255, .25); color: #fff; }

.search-more {
    display: inline-block; margin-top: 8px;
    color: var(--blue); font-weight: 600; font-size: .88rem; text-decoration: none;
}
.search-more:hover { text-decoration: underline; }

.search-empty-hint { padding: 8px 0 4px; }
.search-empty-cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.search-cat {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--row-hover); color: var(--text-muted);
    font-size: .85rem; font-weight: 600;
}
.search-tip { font-size: .85rem; }

/* Aggiornamento realtime dei risultati: dim durante il fetch */
[data-search-live].is-loading { opacity: .55; transition: opacity .12s; pointer-events: none; }

/* Liste ordinabili (drag&drop voci checklist) */
.sortable-list li[data-item-id] {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sortable-list .drag-handle {
    display: inline-flex;
    color: var(--text-muted);
    cursor: grab;
}
.sortable-list .sortable-label {
    flex: 1 1 auto;
}
.sortable-list li.dragging {
    opacity: .5;
}
.sortable-list li[data-item-id]:hover {
    background: var(--row-alt);
    border-radius: var(--radius-sm);
}

/* ---- Dev Board: toolbar, viste tabella/kanban, realtime ---- */
#dev-board .filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    align-items: flex-start;
    padding: 14px 16px;
}
/* Ogni gruppo: etichetta in alto, controllo sotto, larghezze coerenti */
#dev-board .filter-bar .form-row { margin: 0; display: flex; flex-direction: column; gap: 6px; }
#dev-board .filter-bar .form-row > label {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-muted); margin: 0;
}
#dev-board .db-search { flex: 1 1 240px; min-width: 200px; }
#dev-board .db-search input { width: 100%; }
#dev-board .filter-bar input[type="search"],
#dev-board .filter-bar input[list],
#dev-board .filter-bar select { height: 38px; }

/* Filtro multiselect a tendina */
#dev-board .multiselect { position: relative; }
#dev-board .multiselect-toggle {
    min-width: 150px; height: 38px; text-align: left; position: relative;
    padding: 0 30px 0 11px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
#dev-board .multiselect-toggle::after {
    content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
    border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
#dev-board .multiselect-toggle.has-selection { border-color: var(--blue); color: var(--blue); font-weight: 600; }
#dev-board .multiselect.is-open .multiselect-toggle { border-color: var(--blue); }
#dev-board .multiselect-panel {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 200px;
    background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 6px; display: none; flex-direction: column; gap: 2px; max-height: 280px; overflow: auto;
}
/* Visibile solo con la tendina aperta: l'attributo hidden da solo verrebbe
   sovrascritto dalla specificità della regola sopra. */
#dev-board .multiselect.is-open .multiselect-panel { display: flex; }
#dev-board .multiselect-panel .inline-check {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm);
    font-weight: 500; cursor: pointer; white-space: nowrap;
}
#dev-board .multiselect-panel .inline-check:hover { background: var(--row-hover); }

/* Completate + azioni: a destra, allineate in basso */
#dev-board .filter-bar .db-completed { align-self: flex-end; }
.db-toolbar-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; align-self: flex-end; }
.db-view-toggle { display: inline-flex; }
.db-view-toggle .button { border-radius: 0; }

/* ---- Form ticket Dev Board: griglia, multiselect moduli, danger zone ---- */
#dev-task-form .section-heading { margin: 18px 0 8px; }
#dev-task-form .section-heading:first-of-type { margin-top: 0; }
#dev-task-form .form-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px;
}
#dev-task-form .form-grid .form-row { margin: 0; }
@media (max-width: 640px) { #dev-task-form .form-grid { grid-template-columns: 1fr; } }
#dev-task-form #module-area-other { margin-top: 8px; }

/* Multiselect riusato nel form (stesso look del filtro board) */
#dev-task-form .multiselect { position: relative; max-width: 420px; }
#dev-task-form .multiselect-toggle {
    min-width: 150px; height: 38px; text-align: left; position: relative;
    padding: 0 30px 0 11px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%;
}
#dev-task-form .multiselect-toggle::after {
    content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px;
    border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
#dev-task-form .multiselect-toggle.has-selection { border-color: var(--blue); color: var(--blue); font-weight: 600; }
#dev-task-form .multiselect.is-open .multiselect-toggle { border-color: var(--blue); }
#dev-task-form .multiselect-panel {
    position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 220px;
    background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 6px; display: none; flex-direction: column; gap: 2px; max-height: 300px; overflow: auto;
}
#dev-task-form .multiselect.is-open .multiselect-panel { display: flex; }
#dev-task-form .multiselect-panel .inline-check {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm);
    font-weight: 500; cursor: pointer; white-space: nowrap;
}
#dev-task-form .multiselect-panel .inline-check:hover { background: var(--row-hover); }

/* Zona pericolosa: archivia / elimina */
.db-danger-zone .db-manage-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.db-danger-zone { border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 14px 16px; }
.db-view-toggle .button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.db-view-toggle .button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.db-view-toggle .button.is-active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* Cambio stato rapido in tabella */
.db-quick-status { padding: 3px 6px; font-size: 13px; }
.db-due-over { color: var(--red); font-weight: 700; }
.db-due-soon { color: var(--amber); font-weight: 700; }

/* Kanban */
.db-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.db-col { background: var(--surface-2); border: 1px solid var(--border-color); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 120px; }
.db-col-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--border-color); }
.db-col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; flex: 1; }
.db-col-body.is-over { background: var(--row-hover); outline: 2px dashed var(--blue); outline-offset: -4px; }
.db-card { background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 9px 10px; box-shadow: var(--shadow-sm); cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.db-card.is-dragging { opacity: .5; }
.db-card-title { font-weight: 600; text-decoration: none; color: var(--text); }
.db-card-title:hover { text-decoration: underline; }
.db-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.db-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.db-card-assignee { display: inline-flex; align-items: center; gap: 4px; }

/* Toast notifiche realtime */
.db-toast { position: fixed; right: 18px; bottom: 18px; z-index: 1000; background: var(--gray-800); color: var(--surface); padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-weight: 600; opacity: 1; transition: opacity .5s ease, transform .5s ease; }
.db-toast.is-out { opacity: 0; transform: translateY(8px); }

/* Console URV — navigazione tra le sei aree del modulo */
.urv-training-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.urv-training-tabs .urv-training-tab { display: inline-flex; align-items: center; padding: 9px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; }
.urv-training-tabs .urv-training-tab:hover { background: var(--row-hover); }
.urv-training-tabs .urv-training-tab.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }


/* ---- Home semplice per volontari e responsabili di sede ---- */
.portal-home {
    --portal-accent: #b4232f;
    --portal-accent-soft: #fff1ed;
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 4px 0 28px;
}
.portal-welcome {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    min-height: 220px;
    overflow: hidden;
    margin: 0 0 28px;
    padding: clamp(26px, 5vw, 48px);
    color: #202a36;
    background:
        radial-gradient(circle at 90% 14%, rgba(180, 35, 47, .11), transparent 24%),
        radial-gradient(circle at 78% 100%, rgba(18, 58, 95, .08), transparent 34%),
        linear-gradient(118deg, #fffaf7 0%, #fff 66%, #f8f5f1 100%);
    border: 1px solid #eaded8;
    border-radius: 22px;
    box-shadow: 0 10px 28px rgba(30, 41, 59, .07);
}
.portal-welcome::before {
    position: absolute;
    right: 94px;
    bottom: -145px;
    width: 300px;
    height: 300px;
    content: "";
    border: 1px solid rgba(180, 35, 47, .11);
    border-radius: 50%;
    box-shadow: 0 0 0 24px rgba(180, 35, 47, .025), 0 0 0 48px rgba(18, 58, 95, .025);
    pointer-events: none;
}
.portal-welcome-copy {
    position: relative;
    z-index: 1;
    max-width: 680px;
}
.portal-eyebrow {
    margin: 0 0 12px;
    color: #9b2b32;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
}
.portal-welcome h1 {
    margin: 0;
    color: #17283a;
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.12;
    letter-spacing: -.035em;
}
.portal-welcome-copy > p:not(.portal-eyebrow) {
    max-width: 560px;
    margin: 13px 0 0;
    color: #4e5966;
    font-size: 17px;
    line-height: 1.55;
}
.portal-station-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 17px;
    padding: 8px 12px;
    color: #163957;
    background: rgba(255, 255, 255, .82);
    border: 1px solid #d9e1e8;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}
.portal-welcome-art {
    position: relative;
    z-index: 1;
    display: grid;
    flex: 0 0 116px;
    place-items: center;
    width: 116px;
    height: 116px;
    color: #a52a32;
    background: linear-gradient(145deg, #fff 0%, #fde7de 100%);
    border: 1px solid rgba(180, 35, 47, .12);
    border-radius: 34px;
    box-shadow: 0 14px 30px rgba(123, 41, 37, .11);
    transform: rotate(3deg);
}
.portal-welcome-art .icon {
    width: 58px;
    height: 58px;
}
.portal-notice {
    margin: -7px 0 24px;
}
.portal-quick-section {
    margin: 0 0 28px;
}
.portal-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 15px;
}
.portal-section-heading h2 {
    margin: 0;
    color: var(--text);
    font-size: 21px;
    letter-spacing: -.02em;
}
.portal-section-heading p {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}
.portal-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 13px;
}
.portal-action-card {
    display: flex;
    align-items: center;
    min-height: 100px;
    gap: 14px;
    padding: 17px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.portal-action-card:hover {
    color: var(--text);
    border-color: rgba(180, 35, 47, .38);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.portal-action-card:focus-visible {
    outline: 3px solid rgba(180, 35, 47, .42);
    outline-offset: 3px;
}
.portal-action-icon {
    display: grid;
    flex: 0 0 46px;
    place-items: center;
    width: 46px;
    height: 46px;
    color: #a52a32;
    background: var(--portal-accent-soft);
    border-radius: 14px;
}
.portal-action-icon .icon {
    width: 22px;
    height: 22px;
}
.portal-action-copy {
    display: grid;
    min-width: 0;
    gap: 5px;
}
.portal-action-copy strong {
    font-size: 15px;
    line-height: 1.25;
}
.portal-action-copy > span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}
.portal-action-arrow {
    display: grid;
    flex: 0 0 28px;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-left: auto;
    color: var(--text-muted);
    background: var(--surface-2);
    border-radius: 50%;
    transform: rotate(-90deg);
}
.portal-action-arrow .icon {
    width: 16px;
    height: 16px;
}
.portal-widgets .profile-section {
    margin-top: 22px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.portal-widgets .section-heading {
    margin-bottom: 12px;
}
.portal-widgets .section-heading h2 {
    font-size: 19px;
}
.portal-widgets .stat-card,
.portal-widgets .card {
    border-radius: 16px;
}
.dashboard-operativity {
    margin: 20px 0;
    border-radius: 18px;
}
.dashboard-operativity .section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.dashboard-operativity-content {
    display: grid;
    grid-template-columns: minmax(150px, .55fr) minmax(0, 1fr);
    align-items: center;
    gap: 20px;
}
.dashboard-operativity-gauge {
    display: flex;
    justify-content: center;
    min-width: 0;
}
.dashboard-operativity-detail > strong {
    display: block;
    margin-bottom: 8px;
    color: var(--blue);
    font-size: 22px;
}
.dashboard-operativity-metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.dashboard-operativity-metrics span {
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 13px;
}
.dashboard-operativity-detail p,
.dashboard-operativity-scale {
    margin: 10px 0 0;
}
.operativity-row.is-non-operational { background: color-mix(in srgb, #c62828 5%, transparent); }
.operativity-row.is-non-operational td:first-child { border-left: 4px solid #c62828; font-weight: 700; }
.operativity-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}
.operativity-status.is-non-operational { color: #8f1717; background: #fde7e7; }
.operativity-status.is-operational { color: #176b48; background: #e1f3e9; }
.operativity-row td { vertical-align: middle; }
@media (max-width: 560px) {
    .dashboard-operativity-content {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
[data-theme="dark"] .portal-welcome {
    color: var(--text);
    background:
        radial-gradient(circle at 90% 14%, rgba(180, 35, 47, .17), transparent 24%),
        radial-gradient(circle at 78% 100%, rgba(18, 58, 95, .22), transparent 34%),
        linear-gradient(118deg, var(--surface) 0%, var(--surface-2) 100%);
    border-color: var(--border-color);
}
[data-theme="dark"] .portal-welcome h1 { color: var(--text); }
[data-theme="dark"] .portal-welcome-copy > p:not(.portal-eyebrow) { color: var(--text-muted); }
[data-theme="dark"] .portal-station-chip {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-color);
}
[data-theme="dark"] .portal-welcome-art {
    color: #ffb5a7;
    background: linear-gradient(145deg, var(--surface) 0%, #40262a 100%);
    border-color: var(--border-color);
}
[data-theme="dark"] .portal-action-icon {
    color: #ffb5a7;
    background: rgba(180, 35, 47, .18);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .portal-welcome {
        color: var(--text);
        background:
            radial-gradient(circle at 90% 14%, rgba(180, 35, 47, .17), transparent 24%),
            radial-gradient(circle at 78% 100%, rgba(18, 58, 95, .22), transparent 34%),
            linear-gradient(118deg, var(--surface) 0%, var(--surface-2) 100%);
        border-color: var(--border-color);
    }
    :root:not([data-theme="light"]) .portal-welcome h1 { color: var(--text); }
    :root:not([data-theme="light"]) .portal-welcome-copy > p:not(.portal-eyebrow) { color: var(--text-muted); }
    :root:not([data-theme="light"]) .portal-station-chip {
        color: var(--text);
        background: var(--surface);
        border-color: var(--border-color);
    }
    :root:not([data-theme="light"]) .portal-welcome-art {
        color: #ffb5a7;
        background: linear-gradient(145deg, var(--surface) 0%, #40262a 100%);
        border-color: var(--border-color);
    }
    :root:not([data-theme="light"]) .portal-action-icon {
        color: #ffb5a7;
        background: rgba(180, 35, 47, .18);
    }
}
@media (max-width: 960px) {
    .portal-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .portal-home { padding-top: 0; }
    .portal-welcome {
        min-height: 0;
        margin-bottom: 22px;
        padding: 25px 21px;
        border-radius: 18px;
    }
    .portal-welcome::before { right: -140px; bottom: -165px; }
    .portal-welcome-art {
        position: absolute;
        top: 15px;
        right: 13px;
        width: 58px;
        height: 58px;
        border-radius: 18px;
        opacity: .88;
    }
    .portal-welcome-art .icon { width: 32px; height: 32px; }
    .portal-welcome-copy { padding-right: 45px; }
    .portal-welcome h1 { font-size: 30px; }
    .portal-welcome-copy > p:not(.portal-eyebrow) { font-size: 15px; }
    .portal-quick-grid { grid-template-columns: 1fr; gap: 10px; }
    .portal-action-card { min-height: 86px; padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
    .portal-action-card { transition: none; }
    .portal-action-card:hover { transform: none; }
}



/* ---- Portale comune: superfici accoglienti e responsive globale ---- */
:root {
    --blue: #183b56;
    --blue-dark: #102b40;
    --primary: var(--blue);
    --red: #b23a3b;
    --bg: #f5f6f5;
    --surface: #fff;
    --surface-2: #faf9f7;
    --border-color: #e3e6e7;
    --border-strong: #d2d8db;
    --row-alt: #f7f8f8;
    --row-hover: #f1f4f5;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 2px 8px rgba(18, 42, 58, .055);
    --shadow-md: 0 10px 28px rgba(18, 42, 58, .10);
}
html, body {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
body {
    line-height: 1.5;
    overflow-x: clip;
}
img, svg, video, canvas, iframe {
    max-width: 100%;
}
.app-header {
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 10px clamp(14px, 2.5vw, 30px);
    border-bottom-width: 2px;
}
.brand {
    min-width: 0;
    flex: 1 1 320px;
}
.brand > div {
    min-width: 0;
}
.brand > div strong,
.brand > div small {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.header-right {
    min-width: 0;
    flex-wrap: wrap;
}
.app-shell,
.content,
.sidebar,
.mobile-nav,
.page-head,
.page-head-text,
.page-head-actions,
.profile-section,
.card,
.form-card,
.grid,
.grid-form,
.compact-grid,
.toolbar-actions,
.filter-bar,
.form-actions,
.table-wrap {
    min-width: 0;
    max-width: 100%;
}
.app-shell {
    grid-template-columns: 244px minmax(0, 1fr);
}
.sidebar {
    padding: 14px 10px;
    background: var(--surface);
}
.sidebar nav {
    gap: 4px;
}
.sidebar a,
.mobile-nav a {
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 10px;
}
.sidebar a:hover,
.mobile-nav a:hover {
    background: var(--row-hover);
}
.content {
    padding: clamp(14px, 2.3vw, 30px);
}
.page-head,
.card,
.profile-section,
.form-card,
.auth-card,
.stat-card {
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}
.page-head {
    border-left-width: 3px;
    padding: 18px 20px;
}
.page-title {
    font-size: clamp(22px, 2.5vw, 28px);
    line-height: 1.2;
}
.card,
.profile-section {
    padding: 18px;
}
button, .button, input[type="submit"] {
    min-height: 40px;
    border-radius: 10px;
}
input:not([type="checkbox"]):not([type="radio"]),
select, textarea {
    max-width: 100%;
}
.table-wrap {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-radius: 12px;
}
.table {
    min-width: 560px;
}
.table-wrap .table {
    max-width: none;
}
.portal-home {
    width: min(100%, 1240px);
    padding: 8px 0 36px;
}
.portal-welcome {
    min-height: 270px;
    padding: clamp(28px, 5vw, 58px);
    color: #fff;
    border: 0;
    border-radius: 24px;
    box-shadow: 0 16px 42px rgba(17, 40, 58, .19);
    background:
        linear-gradient(90deg, rgba(10, 31, 48, .92) 0%, rgba(10, 31, 48, .72) 40%, rgba(10, 31, 48, .12) 100%),
        url("/public/assets/img/portal-home-hero.jpg") center 47% / cover no-repeat,
        linear-gradient(120deg, #183b56, #b23a3b);
}
.portal-welcome::before {
    display: none;
}
.portal-welcome h1,
.portal-welcome-copy > p:not(.portal-eyebrow) {
    color: #fff;
}
.portal-eyebrow {
    color: #ffd0c5;
}
.portal-welcome-art {
    display: none;
}
.portal-station-chip {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .35);
    backdrop-filter: blur(8px);
}
.portal-quick-section {
    margin-top: 30px;
}
.portal-action-card {
    min-height: 112px;
    padding: 19px;
    border-radius: 18px;
}
.portal-action-icon {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
    border-radius: 15px;
}
[data-theme="dark"] .portal-welcome,
:root:not([data-theme="light"]) .portal-welcome {
    color: #fff;
    background:
        linear-gradient(90deg, rgba(10, 31, 48, .92) 0%, rgba(10, 31, 48, .72) 40%, rgba(10, 31, 48, .12) 100%),
        url("/public/assets/img/portal-home-hero.jpg") center 47% / cover no-repeat,
        linear-gradient(120deg, #183b56, #b23a3b);
    border-color: transparent;
}
[data-theme="dark"] .portal-welcome h1,
:root:not([data-theme="light"]) .portal-welcome h1,
[data-theme="dark"] .portal-welcome-copy > p:not(.portal-eyebrow),
:root:not([data-theme="light"]) .portal-welcome-copy > p:not(.portal-eyebrow) {
    color: #fff;
}
[data-theme="dark"] .portal-station-chip,
:root:not([data-theme="light"]) .portal-station-chip {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .35);
}
@media (max-width: 980px) {
    .app-shell {
        display: block;
        min-height: calc(100vh - 72px);
    }
    .sidebar {
        display: none;
    }
    .nav-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 42px;
        padding: 0;
        border-radius: 12px;
        background: rgba(255,255,255,.12);
        border-color: rgba(255,255,255,.28);
        color: #fff;
    }
    .sidebar-toggle {
        display: none;
    }
    .mobile-nav {
        display: none;
    }
    .mobile-nav.is-open {
        position: fixed;
        z-index: 1000;
        inset: 78px 12px max(14px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        gap: 6px;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 14px;
        background: var(--surface);
        border: 1px solid var(--border-color);
        border-radius: 20px;
        box-shadow: 0 18px 60px rgba(10, 31, 48, .24);
    }
    .mobile-nav a {
        align-items: flex-start;
        min-height: 52px;
        padding: 11px 10px;
        border: 1px solid var(--border-color);
        background: var(--surface-2);
        font-size: 13px;
        line-height: 1.25;
    }
    .mobile-nav a.is-active {
        background: var(--blue);
        color: #fff;
    }
    .header-right {
        flex: 1 1 100%;
        justify-content: flex-end;
    }
    .content {
        padding: 18px clamp(12px, 3vw, 24px);
    }
}
@media (max-width: 680px) {
    .app-header {
        position: relative;
        align-items: flex-start;
        padding: 10px 12px;
        gap: 9px;
    }
    .brand {
        flex: 1 1 100%;
        gap: 9px;
    }
    .brand-mark {
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
    }
    .brand > div {
        flex: 1 1 auto;
        font-size: 13px;
    }
    .brand > div small {
        font-size: 11px;
    }
    .env-badge,
    .version-badge {
        font-size: 10px;
    }
    .header-right {
        justify-content: flex-start;
        gap: 8px;
    }
    .global-search {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        order: 2;
    }
    .global-search input[type="search"] {
        width: 100%;
        max-width: 100%;
    }
    .mobile-nav.is-open {
        inset: 118px 10px max(10px, env(safe-area-inset-bottom));
        grid-template-columns: 1fr;
        padding: 11px;
        border-radius: 16px;
    }
    .mobile-nav a {
        min-height: 46px;
        align-items: center;
        font-size: 14px;
    }
    .content {
        padding: 14px 12px calc(22px + env(safe-area-inset-bottom));
    }
    .page-head {
        align-items: flex-start;
        padding: 15px;
        border-radius: 14px;
    }
    .page-head-actions {
        gap: 7px;
    }
    .page-head-actions .button,
    .page-head-actions button {
        flex: 1 1 auto;
    }
    .form-card {
        grid-template-columns: minmax(0, 1fr);
        padding: 14px;
        gap: 12px;
    }
    .grid-form,
    .compact-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .grid-form .form-row.full-width,
    .compact-grid .form-row.full-width {
        grid-column: auto;
    }
    .filter-bar {
        align-items: stretch;
    }
    .filter-bar > *,
    .filter-bar .form-row {
        min-width: 0;
        max-width: 100%;
    }
    .filter-bar .form-row {
        flex: 1 1 100%;
    }
    .form-actions {
        width: 100%;
    }
    .form-actions .button,
    .form-actions button,
    .form-actions input[type="submit"] {
        max-width: 100%;
        white-space: normal;
    }
    .table-wrap {
        margin-inline: -2px;
    }
    .table {
        min-width: 520px;
        font-size: 12px;
    }
    .auth-shell {
        padding: 12px;
    }
    .auth-card {
        padding: 20px 16px;
    }
    .portal-home {
        padding: 0 0 26px;
    }
    .portal-welcome {
        min-height: 300px;
        align-items: flex-end;
        margin: 0 -12px 22px;
        padding: 25px 20px;
        border-radius: 0 0 22px 22px;
        background-position: center, 62% center, center;
    }
    .portal-welcome-copy {
        padding: 0;
    }
    .portal-welcome h1 {
        font-size: clamp(28px, 8vw, 38px);
    }
    .portal-welcome-copy > p:not(.portal-eyebrow) {
        font-size: 15px;
    }
    .portal-quick-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    .portal-action-card {
        min-height: 84px;
        padding: 14px;
    }
    .portal-section-heading {
        align-items: flex-start;
    }
}
@media (max-width: 380px) {
    .brand > div strong {
        font-size: 12px;
    }
    .env-badge {
        padding: 0 7px;
    }
    .portal-welcome {
        min-height: 280px;
    }
    .portal-action-arrow {
        display: none;
    }
}

@media (max-width: 680px) {
    /* Anche le tabelle legacy prive di .table-wrap restano confinate alla pagina. */
    .content table:not(.responsive-table) {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }
}


/* ---- Stile comune "Portale personale" (approvato) ---- */
:root {
    --blue: #263944;
    --blue-dark: #263944;
    --primary: #c93622;
    --red: #c93622;
    --bg: #f7f2ee;
    --surface: #fffdfb;
    --surface-2: #fbf5f1;
    --text: #17191d;
    --text-muted: #63656a;
    --gray-50: #f7f2ee;
    --gray-100: #f3ebe5;
    --gray-200: #e8ded7;
    --gray-300: #d7cbc3;
    --gray-600: #63656a;
    --gray-800: #202328;
    --border-color: #eee5df;
    --border-strong: #e3d8d0;
    --row-alt: #fcf8f5;
    --row-hover: #f6eee8;
    --header-bg: #fffdfb;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 3px 12px rgba(47, 35, 27, .07);
    --shadow-md: 0 10px 28px rgba(47, 35, 27, .12);
}
[data-theme="dark"] {
    --blue: #d8e4eb;
    --blue-dark: #151b20;
    --primary: #ff7158;
    --red: #ff7158;
    --bg: #15191c;
    --surface: #202528;
    --surface-2: #282e31;
    --text: #f3f0ed;
    --text-muted: #b8b5b2;
    --gray-50: #15191c;
    --gray-100: #202528;
    --gray-200: #353c40;
    --gray-300: #475056;
    --gray-600: #b8b5b2;
    --gray-800: #f3f0ed;
    --border-color: #353c40;
    --border-strong: #475056;
    --row-alt: #242a2d;
    --row-hover: #30383b;
    --header-bg: #202528;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --blue: #d8e4eb;
        --blue-dark: #151b20;
        --primary: #ff7158;
        --red: #ff7158;
        --bg: #15191c;
        --surface: #202528;
        --surface-2: #282e31;
        --text: #f3f0ed;
        --text-muted: #b8b5b2;
        --gray-50: #15191c;
        --gray-100: #202528;
        --gray-200: #353c40;
        --gray-300: #475056;
        --gray-600: #b8b5b2;
        --gray-800: #f3f0ed;
        --border-color: #353c40;
        --border-strong: #475056;
        --row-alt: #242a2d;
        --row-hover: #30383b;
        --header-bg: #202528;
    }
}
html, body { min-width: 320px; }
body {
    background: var(--bg);
    color: var(--text);
    overflow-x: clip;
}
a { color: var(--primary); }
.app-header {
    position: sticky;
    top: 0;
    z-index: 900;
    min-height: 64px;
    padding: 9px clamp(14px, 2.4vw, 30px);
    color: var(--text);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 3px 14px rgba(47, 35, 27, .06);
}
.brand-mark {
    border-radius: 13px;
    background: #f2d5c7;
    color: #17191d;
}
.brand > div strong { color: var(--text); }
.brand small, .user-box small { color: var(--text-muted); }
.notification-link { color: var(--text); }
.version-badge, .env-badge {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-color);
}
.app-header .button-ghost, .user-box .button-ghost, .nav-toggle {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-color);
}
.nav-toggle { border-radius: 12px; }
.app-shell { grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
    background: var(--surface);
    border-right-color: var(--border-color);
}
.sidebar a {
    min-height: 42px;
    margin: 2px 0;
    padding: 9px 12px;
    border: 0;
    border-radius: 12px;
    color: var(--text);
}
.sidebar a.is-active {
    color: var(--primary);
    background: #fff0ea;
}
[data-theme="dark"] .sidebar a.is-active,
:root:not([data-theme="light"]) .sidebar a.is-active {
    background: #3a2925;
}
.sidebar a:hover { background: var(--row-hover); }
.content { max-width: 1600px; padding: clamp(16px, 2.3vw, 32px); }
.page-title { color: var(--text); }
.page-head, .card, .form-card, .profile-section, .stat-card, .auth-card,
.modal-card, .dashboard-card-link {
    border-color: var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
}
.page-head {
    border-left: 0;
    padding: 20px 22px;
}
.card, .form-card { padding: 18px; }
.grid { gap: 14px; }
.dashboard-card-link:hover {
    border-color: #e5c7b9;
    box-shadow: var(--shadow-md);
}
.admin-card-icon, .stat-card-icon {
    color: var(--primary);
    background: #fff0ea;
    border-radius: 14px;
}
[data-theme="dark"] .admin-card-icon,
[data-theme="dark"] .stat-card-icon,
:root:not([data-theme="light"]) .admin-card-icon,
:root:not([data-theme="light"]) .stat-card-icon {
    color: #ff9b86;
    background: #3a2925;
}
.button, button, input[type="submit"] {
    min-height: 40px;
    border-radius: 12px;
}
.button:not(.button-light):not(.button-secondary):not(.button-ghost),
button:not(.button-light):not(.button-secondary):not(.button-ghost),
input[type="submit"] {
    background-color: var(--primary);
}
.button-secondary { background: #4a5156; }
.button-light, .button-ghost {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-color);
}
.app-header .button-ghost, .user-box .button-ghost, .nav-toggle {
    color: var(--text);
    background: var(--surface);
}
input, select, textarea { border-radius: 12px; border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
    outline: 3px solid rgba(201, 54, 34, .16);
    border-color: var(--primary);
}
.table {
    border-color: var(--border-color);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(47, 35, 27, .04);
}
.table th {
    color: var(--text);
    background: #f5eee9;
    border-color: var(--border-color);
}
[data-theme="dark"] .table th,
:root:not([data-theme="light"]) .table th { color: var(--text); background: #30383b; }
.app-footer {
    color: var(--text-muted);
    background: var(--surface);
    border-color: var(--border-color);
}
.portal-welcome {
    min-height: 300px;
    color: #fff;
    border: 0;
    border-radius: 24px;
    background:
        linear-gradient(90deg, rgba(16, 25, 29, .76) 0%, rgba(16, 25, 29, .43) 48%, rgba(16, 25, 29, .06) 100%),
        url("/public/assets/img/portal-home-hero.png") center 48% / cover no-repeat;
}
.portal-welcome h1, .portal-welcome-copy > p:not(.portal-eyebrow) { color: #fff; }
.portal-eyebrow { color: #ffd1c2; }
[data-theme="dark"] .portal-welcome,
:root:not([data-theme="light"]) .portal-welcome {
    color: #fff;
    background:
        linear-gradient(90deg, rgba(16, 25, 29, .76) 0%, rgba(16, 25, 29, .43) 48%, rgba(16, 25, 29, .06) 100%),
        url("/public/assets/img/portal-home-hero.png") center 48% / cover no-repeat;
}
.portal-action-card { border-radius: 18px; }
.mobile-bottom-nav { display: none; }

@media (max-width: 980px) {
    .app-header { position: sticky; }
    .nav-toggle {
        display: inline-flex;
        flex: 0 0 42px;
        width: 42px;
        color: var(--text);
        background: var(--surface);
        border-color: var(--border-color);
    }
    .mobile-nav.is-open {
        inset: 78px 12px 14px;
        padding: 14px;
        border-radius: 20px;
        background: var(--surface);
        box-shadow: 0 18px 56px rgba(38, 30, 24, .2);
    }
    .mobile-nav a {
        align-items: center;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        background: var(--surface-2);
        color: var(--text);
    }
    .mobile-nav a.is-active {
        border-color: #efd3c5;
        background: #fff0ea;
        color: var(--primary);
    }
}
@media (max-width: 680px) {
    body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
    .app-header {
        align-items: center;
        padding: 9px 12px;
        gap: 8px;
    }
    .brand { flex: 1 1 auto; min-width: 0; }
    .brand > div { min-width: 0; }
    .brand > div strong { font-size: 13px; }
    .header-right { flex: 0 1 auto; width: auto; }
    .content { padding: 14px 12px 30px; }
    .mobile-nav.is-open {
        inset: auto 10px calc(82px + env(safe-area-inset-bottom));
        max-height: calc(100svh - 112px - env(safe-area-inset-top));
        grid-template-columns: 1fr;
        overflow-y: auto;
        padding: 10px;
    }
    .mobile-nav a { min-height: 46px; }
    .mobile-bottom-nav {
        position: fixed;
        z-index: 950;
        left: 10px;
        right: 10px;
        bottom: max(9px, env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 2px;
        padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
        border: 1px solid rgba(226, 215, 207, .9);
        border-radius: 24px;
        background: rgba(255, 253, 251, .96);
        box-shadow: 0 8px 30px rgba(47, 35, 27, .16);
        backdrop-filter: blur(18px);
    }
    [data-theme="dark"] .mobile-bottom-nav,
    :root:not([data-theme="light"]) .mobile-bottom-nav {
        background: rgba(32, 37, 40, .96);
        border-color: var(--border-color);
    }
    .mobile-bottom-nav a, .mobile-bottom-nav button {
        display: flex;
        min-width: 0;
        min-height: 48px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 3px 1px;
        border: 0;
        border-radius: 14px;
        color: var(--text-muted);
        background: transparent;
        text-decoration: none;
        white-space: nowrap;
        font-size: 9px;
        font-weight: 600;
        line-height: 1.1;
    }
    .mobile-bottom-nav .icon { width: 21px; height: 21px; }
    .mobile-bottom-nav a.is-active {
        color: var(--primary);
        background: #fff0ea;
    }
    [data-theme="dark"] .mobile-bottom-nav a.is-active,
    :root:not([data-theme="light"]) .mobile-bottom-nav a.is-active { background: #3a2925; }
    .mobile-bottom-nav .mobile-more-toggle[aria-expanded="true"] {
        color: var(--primary);
        background: #fff0ea;
    }
    .mobile-more-dots { font-size: 23px; line-height: 18px; height: 21px; letter-spacing: 1px; }
    .portal-welcome {
        min-height: 300px;
        margin-inline: -12px;
        border-radius: 0 0 22px 22px;
        background-position: center, 58% center;
    }
    .table { min-width: 520px; }
}
@media (max-width: 380px) {
    .mobile-bottom-nav { left: 7px; right: 7px; }
    .mobile-bottom-nav a, .mobile-bottom-nav button { font-size: 8px; }
    .portal-welcome { min-height: 280px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}


/* ---- Mobile: contenuti contenuti e selettori nativi touch ---- */
@media (max-width: 680px) {
    html, body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    .app-header {
        flex-wrap: wrap;
        min-width: 0;
    }
    .brand, .brand > div, .header-right, .user-box {
        min-width: 0;
        max-width: 100%;
    }
    .header-right, .user-box {
        flex-wrap: wrap;
    }
    .app-shell, .app-shell > *, .content {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    .content > *,
    .content section,
    .content article,
    .content form,
    .content fieldset,
    .content .card,
    .content .form-card,
    .content .page-head,
    .content .page-head-text,
    .content .page-head-actions,
    .content .filter-bar,
    .content .form-actions,
    .content .grid,
    .content .grid-form,
    .content .compact-grid {
        min-width: 0;
        max-width: 100%;
    }
    .content img, .content video, .content iframe, .content canvas {
        max-width: 100%;
    }
    .content pre, .content code, .content .code-block {
        max-width: 100%;
        overflow-x: auto;
        overflow-wrap: anywhere;
    }
    .content input, .content select, .content textarea {
        min-width: 0;
        max-width: 100%;
    }
    .filter-bar .form-row {
        min-width: 0;
        flex: 1 1 100%;
    }
    .page-head-actions > *,
    .form-actions > * {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .table-wrap {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    .table-wrap > .table {
        width: max-content;
        min-width: 520px;
        max-width: none;
    }
    .content table:not(.responsive-table) {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
}
/* Su touch e schermi telefonici lasciamo al browser il selettore nativo.
   Il pannello custom desktop era soggetto ai resize della viewport mobile e
   poteva richiudersi quando compariva la tastiera o cambiava la barra del browser. */
@media (max-width: 680px), (pointer: coarse) {
    select:not([multiple]) {
        appearance: auto;
        -webkit-appearance: menulist;
        -moz-appearance: menulist;
        padding-right: 10px;
        background-image: none !important;
    }
}


/* Tema chiaro: ricerca globale nell'header chiaro deve mantenere testo leggibile. */
:root:not([data-theme="dark"]) .app-header .global-search {
    border-color: var(--border-strong);
    background: var(--surface-2);
}
:root:not([data-theme="dark"]) .app-header .global-search:hover,
:root:not([data-theme="dark"]) .app-header .global-search:focus-within {
    border-color: var(--primary);
    background: var(--surface);
}
:root:not([data-theme="dark"]) .app-header .global-search-icon,
:root:not([data-theme="dark"]) .app-header .global-search input[type="search"] {
    color: var(--text);
}
:root:not([data-theme="dark"]) .app-header .global-search input[type="search"]::placeholder {
    color: var(--text-muted);
    opacity: 1;
}


/* Hero della dashboard: fondo stabile sotto al testo chiaro, indipendente dai dettagli della foto. */
.portal-welcome-copy {
    padding: clamp(14px, 2.5vw, 22px);
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 18px;
    background: linear-gradient(120deg, rgba(12, 21, 26, .88), rgba(12, 21, 26, .68));
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}


/* Header chiaro: rendi distinguibili aiuto, notifiche e selettore profilo. */
:root:not([data-theme="dark"]) .app-header .icon-button:not(.theme-toggle) {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-strong);
}
:root:not([data-theme="dark"]) .app-header .icon-button:not(.theme-toggle):hover {
    background: var(--row-hover);
}
:root:not([data-theme="dark"]) .app-header .user-menu > summary {
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 6px 10px;
}
:root:not([data-theme="dark"]) .app-header .operate-as-switch > summary {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-strong);
}
:root:not([data-theme="dark"]) .app-header .operate-as-switch > summary:hover {
    background: var(--row-hover);
}


/* Il pannello ruoli su mobile viene ancorato alla viewport da app.js. */
@media (max-width: 680px) {
    .operate-as-panel {
        position: fixed;
        top: 12px;
        left: 12px;
        right: auto;
        width: min(280px, calc(100vw - 24px));
        min-width: 0;
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}


/* Contrasto del ruolo attivo: evita testo e fondo entrambi impostati sul colore d'accento. */
.operate-as-panel button.operate-as-option {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-color);
}
.operate-as-panel button.operate-as-option:hover {
    color: var(--text);
    background: var(--row-hover);
    border-color: var(--border-strong);
}
.operate-as-panel button.operate-as-option.is-current {
    color: var(--text);
    background: var(--info-bg);
    border-color: var(--primary);
    box-shadow: inset 3px 0 var(--primary);
}

 
/* Azioni della sede con elementi in attesa */
.portal-action-card--pending {
    position: relative;
    border: 2px solid #168a4a;
    box-shadow: 0 0 0 0 rgba(22, 138, 74, .42);
    animation: portal-pending-pulse 1.8s ease-out infinite;
}
.portal-action-pending-badge {
    position: absolute;
    top: .55rem;
    right: .6rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: .25rem .55rem;
    color: #fff;
    background: #168a4a;
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.2;
}
@keyframes portal-pending-pulse {
    0% { box-shadow: 0 0 0 0 rgba(22, 138, 74, .42); }
    70% { box-shadow: 0 0 0 .55rem rgba(22, 138, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 138, 74, 0); }
}
.portal-pending-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(12, 27, 44, .62);
}
.portal-pending-dialog {
    position: relative;
    width: min(100%, 32rem);
    padding: 2rem;
    border: 2px solid #168a4a;
    border-radius: 1.25rem;
    background: #fff;
    color: #17212b;
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, .28);
}
.portal-pending-dialog h2 {
    margin: .35rem 2rem .5rem 0;
    color: #17212b;
}
.portal-pending-dialog p {
    color: #344454;
}
.portal-pending-close {
    position: absolute;
    top: .6rem;
    right: .75rem;
    border: 0;
    background: transparent;
    color: #344454;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}
.dashboard-station-interventions {
    margin-top: 1rem;
}
.dashboard-station-intervention-total {
    margin: 0;
    color: var(--text-strong, #18212b);
    font-size: 2.25rem;
    font-weight: 800;
}
@media (prefers-reduced-motion: reduce) {
    .portal-action-card--pending { animation: none; }
}
@media (max-width: 600px) {
    .portal-pending-overlay { align-items: end; padding: .75rem; }
    .portal-pending-dialog { width: 100%; padding: 1.5rem; border-radius: 1rem; }
    .portal-action-pending-badge { top: .35rem; right: .35rem; font-size: .68rem; }
}


/* Grafici riuniti nella dashboard del distaccamento */
.dashboard-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
    gap: 1rem;
}
.dashboard-stat-chart {
    min-width: 0;
    padding: 1.1rem;
    border-radius: 1rem;
    background: linear-gradient(145deg, var(--surface, #fff), color-mix(in srgb, var(--surface, #fff) 92%, var(--blue, #245b87)));
    box-shadow: var(--shadow-sm);
}
.dashboard-stat-chart h3 {
    margin: 0 0 .8rem;
    color: var(--text-strong, #18212b);
    font-size: 1rem;
    line-height: 1.35;
}
.dashboard-stat-chart > * {
    max-width: 100%;
}
@media (max-width: 640px) {
    .dashboard-stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .dashboard-stat-chart {
        padding: .9rem;
    }
}

/* Riepilogo della sede nella dashboard personale del vigile */
.dashboard-personal-station {
    display: grid;
    gap: 1rem;
    min-width: 0;
}
.dashboard-personal-station-hero {
    padding: clamp(1rem, 3vw, 1.5rem);
    color: #fff;
    border-radius: 1.25rem;
    background:
        radial-gradient(circle at 90% 5%, rgba(255,255,255,.18), transparent 28%),
        linear-gradient(130deg, #173d61 0%, #245f83 58%, #b83a2a 140%);
    box-shadow: 0 12px 32px rgba(20, 52, 78, .18);
}
.dashboard-personal-station-title {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-width: 0;
}
.dashboard-personal-station-icon,
.dashboard-personal-station-metric-icon {
    display: grid;
    flex: 0 0 2.8rem;
    place-items: center;
    width: 2.8rem;
    height: 2.8rem;
    color: #fff;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.24);
    border-radius: .9rem;
}
.dashboard-personal-station-title h3,
.dashboard-personal-station-title p {
    margin: 0;
    color: #fff;
}
.dashboard-personal-station-eyebrow {
    margin-bottom: .18rem !important;
    color: rgba(255,255,255,.78) !important;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}
.dashboard-personal-station-stats {
    display: grid;
    grid-template-columns: minmax(9rem, .75fr) minmax(0, 1.5fr);
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}
.dashboard-personal-station-gauge {
    padding: .25rem .5rem;
    background: rgba(255,255,255,.1);
    border-radius: 1rem;
}
.dashboard-personal-station .gauge-value,
.dashboard-personal-station .gauge-label {
    color: #fff !important;
}
.dashboard-personal-station .gauge-track {
    stroke: rgba(255,255,255,.28);
}
.dashboard-personal-station-copy {
    display: grid;
    gap: .35rem;
    min-width: 0;
}
.dashboard-personal-station-kicker {
    color: rgba(255,255,255,.8);
    font-size: .9rem;
}
.dashboard-personal-station-copy > strong {
    font-size: clamp(2.5rem, 8vw, 4rem);
    line-height: 1;
}
.dashboard-personal-station-copy > strong small {
    font-size: 1.2rem;
    font-weight: 600;
}
.dashboard-personal-station-copy p,
.dashboard-personal-station-copy > small {
    margin: 0;
    color: rgba(255,255,255,.82);
}
.dashboard-personal-station-progress {
    display: block;
    height: .55rem;
    overflow: hidden;
    background: rgba(255,255,255,.22);
    border-radius: 99px;
}
.dashboard-personal-station-progress span {
    display: block;
    height: 100%;
    background: #b7e5a2;
    border-radius: inherit;
}
.dashboard-personal-station-metric {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: .8rem;
    padding: 1rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border-color, #dce3e8);
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
}
.dashboard-personal-station-metric-icon {
    color: #a83225;
    background: rgba(198, 57, 39, .1);
    border-color: transparent;
}
.dashboard-personal-station-metric > div {
    display: grid;
    gap: .1rem;
}
.dashboard-personal-station-metric > div strong {
    color: var(--text-strong, #17212b);
    font-size: 1.7rem;
    line-height: 1;
}
.dashboard-personal-station-metric > div span,
.dashboard-personal-station-metric > small {
    color: var(--text-muted, #5b6874);
}
.dashboard-personal-station-metric > small {
    grid-column: 2;
    line-height: 1.4;
}
.dashboard-personal-station-chart {
    min-width: 0;
    padding: 1rem;
    background: var(--surface, #fff);
    border: 1px solid var(--border-color, #dce3e8);
    border-radius: 1rem;
}
.dashboard-personal-station-chart h4 {
    margin: 0 0 .75rem;
    color: var(--text-strong, #17212b);
}
.dashboard-personal-station .chart-bar-label {
    max-width: 45%;
}
.dashboard-personal-station-footnote {
    margin: 0;
    color: var(--text-muted, #5b6874);
    font-size: .85rem;
}
@media (max-width: 600px) {
    .dashboard-personal-station-stats {
        grid-template-columns: minmax(0, 1fr);
    }
    .dashboard-personal-station-gauge {
        max-width: 18rem;
        width: 100%;
        margin-inline: auto;
    }
}
[data-theme="dark"] .dashboard-personal-station-metric,
[data-theme="dark"] .dashboard-personal-station-chart {
    background: var(--surface-2, #202a35);
    border-color: var(--border-color, #34414e);
}

.turni-crew-list {
    display: grid;
    gap: 5px;
    min-width: 12rem;
}
.turni-crew-person {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    line-height: 1.35;
}
.turni-crew-person > span {
    color: var(--primary, #e76f32);
    font-size: .78rem;
    font-weight: 800;
}
.turni-crew-person > strong {
    overflow-wrap: anywhere;
    font-weight: 600;
}


/* Menu account e notifiche: pannelli ancorati alla viewport sui telefoni,
   così restano cliccabili anche quando la barra header si riadatta. */
@media (max-width: 680px) {
    .user-menu-panel {
        position: fixed;
        z-index: 1000;
        top: 12px;
        right: auto;
        max-width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}


/* Operatività per sedi e tabelle */
.operativity-disclosure > summary { display:flex; align-items:center; cursor:pointer; list-style:none; gap:12px; padding:4px 0; }
.operativity-disclosure > summary::-webkit-details-marker { display:none; }
.operativity-disclosure > summary .operativity-summary-copy { display:grid; gap:4px; text-align:left; }
.operativity-disclosure > summary::before { content:"＋"; color:var(--blue); font-size:20px; }
.operativity-disclosure[open] > summary::before { content:"−"; }
.operativity-disclosure > summary strong { display:block; font-size:19px; }
.operativity-disclosure > summary small { display:block; color:var(--text-muted); margin-top:3px; }
.operativity-disclosure-content { padding-top:14px; }
.operativity-filters { display:flex; align-items:end; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.operativity-filters > label { display:grid; gap:5px; font-size:13px; }
.operativity-filters select { min-width:220px; }
.operativity-training-filter { display:flex !important; align-items:center; gap:8px !important; min-height:40px; }
.operativity-row.is-grade-non-operational { background:color-mix(in srgb, #c62828 6%, transparent); }
.operativity-row.is-grade-poor { background:color-mix(in srgb, #ed7d1a 5%, transparent); }
.operativity-row.is-grade-sufficient { background:color-mix(in srgb, #d5a500 5%, transparent); }
.operativity-row.is-grade-good { background:color-mix(in srgb, #2779bd 5%, transparent); }
.operativity-row.is-grade-distinct { background:color-mix(in srgb, #168b8b 5%, transparent); }
.operativity-row.is-grade-excellent { background:color-mix(in srgb, #1b8b54 6%, transparent); }
.operativity-row.is-grade-non-operational td:first-child { border-left:4px solid #c62828; font-weight:700; }
.operativity-row.is-grade-poor td:first-child { border-left:4px solid #ed7d1a; }
.operativity-row.is-grade-sufficient td:first-child { border-left:4px solid #d5a500; }
.operativity-row.is-grade-good td:first-child { border-left:4px solid #2779bd; }
.operativity-row.is-grade-distinct td:first-child { border-left:4px solid #168b8b; }
.operativity-row.is-grade-excellent td:first-child { border-left:4px solid #1b8b54; font-weight:700; }
.operativity-status.is-grade-non-operational { color:#8f1717; background:#fde7e7; }
.operativity-status.is-grade-poor { color:#99500d; background:#fff0dc; }
.operativity-status.is-grade-sufficient { color:#755c00; background:#fff7cf; }
.operativity-status.is-grade-good { color:#155c91; background:#e1f1ff; }
.operativity-status.is-grade-distinct { color:#086766; background:#dff6f3; }
.operativity-status.is-grade-excellent { color:#176b48; background:#e1f3e9; }
.allerto-team-hours { grid-column:1 / -1; }
.allerto-team-hours-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap:12px; }
.allerto-team-hours-card { min-width:0; padding:14px 16px; border:1px solid var(--border-color); border-radius:14px; background:var(--surface); }
.allerto-team-hours-card h4 { margin:0 0 10px; font-size:16px; }
.allerto-team-hours-row { display:grid; grid-template-columns:10px minmax(0, 1fr) auto; align-items:center; gap:9px; padding:7px 0; border-top:1px solid var(--border-color); font-size:13px; }
.allerto-team-hours-row strong { font-variant-numeric:tabular-nums; white-space:nowrap; }
.allerto-team-hours-dot { width:9px; height:9px; border-radius:50%; background:var(--team-color); }
@media (max-width:680px) { .operativity-filters select { min-width:0; } .allerto-team-hours-grid { grid-template-columns:minmax(0, 1fr); } }
