/* ============================================================ */
/* DpoCentric - stili condivisi                                    */
/* Come FitDesk, con i colori del logo (petrolio e salvia).     */
/* ============================================================ */

:root {
    --brand-50: #edf6f6;
    --brand-100: #d2e8ea;
    --brand-500: #2a8293;
    --brand-600: #13606f;
    --brand-700: #0f4c5c;
    --brand-900: #0a2f38;
    --accent-400: #9cc9ad;
    --ink-900: #0f172a;
    --ink-600: #475569;
    --ink-400: #94a3b8;
    --surface: #ffffff;
    --line: #e2e8f0;
    --sidebar-bg: #111827;
    --sidebar-larga: 260px;
    --sidebar-stretta: 72px;
}

body { background: #f5f7fb; color: var(--ink-900); }

/* ================================================================ */
/* LAYOUT                                                            */
/* ================================================================ */
.app-main { flex-grow: 1; min-width: 0; min-height: 100vh; }

.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ================================================================ */
/* SIDEBAR con gruppi e sottomenu                                    */
/* - gruppo = <button data-bs-toggle="collapse"> + <ul class="collapse sottomenu">  */
/* - compressa (desktop): solo icone; il sottomenu compare a lato al passaggio */
/* - < 992px: a scomparsa, sempre espansa                           */
/* ================================================================ */
.app-sidebar {
    width: var(--sidebar-larga);
    min-height: 100vh;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: #fff;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .2s ease;
    z-index: 1030;
}
.app-sidebar .sidebar-header { min-height: 48px; }
.app-sidebar .sidebar-marchio {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
}
.app-sidebar .sidebar-marchio .logo-intero { height: 38px; width: auto; max-width: 190px; }
.app-sidebar .sidebar-marchio .marchio-icona { width: 32px; height: 32px; flex-shrink: 0; display: none; }

.app-sidebar .nav-link,
.app-sidebar .voce-gruppo {
    display: flex;
    align-items: center;
    width: 100%;
    gap: .6rem;
    color: rgba(255, 255, 255, .78);
    padding: .55rem .75rem;
    border-radius: 10px;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: .93rem;
    white-space: nowrap;
}
.app-sidebar .nav-link:hover,
.app-sidebar .voce-gruppo:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.app-sidebar .nav-link.active {
    background: var(--brand-600);
    color: #fff;
    box-shadow: 0 4px 14px rgba(19, 96, 111, .35);
}
.app-sidebar .sidebar-icon { font-size: 1.1rem; width: 1.4rem; text-align: center; flex-shrink: 0; }
.app-sidebar .voce-gruppo .freccia { margin-left: auto; font-size: .75rem; transition: transform .2s ease; }
.app-sidebar .voce-gruppo[aria-expanded="true"] .freccia { transform: rotate(90deg); }
.app-sidebar .voce-gruppo.contiene-attiva { color: #fff; }

/* Sottomenu: rientrato, con una linea a sinistra */
.app-sidebar .sottomenu {
    list-style: none;
    margin: .15rem 0 .35rem 1.35rem;
    padding: 0 0 0 .55rem;
    border-left: 1px solid rgba(255, 255, 255, .12);
}
.app-sidebar .sottomenu .nav-link { font-size: .88rem; padding: .42rem .65rem; }
.app-sidebar .sottomenu .titolo-flyout { display: none; }
.app-sidebar .voce-futura {
    display: flex; align-items: center; gap: .6rem;
    color: rgba(255, 255, 255, .38);
    padding: .42rem .65rem; font-size: .88rem; white-space: nowrap; cursor: default;
}
.app-sidebar .voce-futura .nota {
    margin-left: auto; font-size: .68rem; border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px; padding: 0 .45rem;
}

.sidebar-toggle { color: rgba(255, 255, 255, .55); }
.sidebar-toggle:hover { color: #fff; }

/* ---------- Compressa (solo desktop) ---------- */
@media (min-width: 992px) {
    .app-sidebar.collapsed { width: var(--sidebar-stretta); overflow: visible; }
    .app-sidebar.collapsed .sidebar-label,
    .app-sidebar.collapsed .freccia,
    .app-sidebar.collapsed .sidebar-marchio .logo-intero { display: none; }
    .app-sidebar.collapsed .sidebar-marchio .marchio-icona { display: block; }
    .app-sidebar.collapsed .sidebar-header { flex-direction: column; gap: .5rem; }
    .app-sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }
    .app-sidebar.collapsed .nav-link,
    .app-sidebar.collapsed .voce-gruppo { justify-content: center; padding: .6rem 0; }

    /* Il sottomenu diventa un riquadro a lato dell'icona (al passaggio o col focus da tastiera) */
    .app-sidebar.collapsed .gruppo { position: relative; }
    .app-sidebar.collapsed .gruppo > .sottomenu {
        display: none !important;
        position: absolute;
        left: calc(100% + 6px);
        top: 0;
        min-width: 240px;
        margin: 0;
        padding: .5rem;
        background: var(--sidebar-bg);
        border: 1px solid rgba(255, 255, 255, .12);
        border-radius: 12px;
        box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
        z-index: 1040;
    }
    .app-sidebar.collapsed .gruppo:hover > .sottomenu,
    .app-sidebar.collapsed .gruppo:focus-within > .sottomenu { display: block !important; }
    .app-sidebar.collapsed .gruppo > .sottomenu .sidebar-label { display: inline; }
    .app-sidebar.collapsed .gruppo > .sottomenu .nav-link { justify-content: flex-start; padding: .42rem .65rem; }
    .app-sidebar.collapsed .gruppo > .sottomenu .titolo-flyout {
        display: block; color: rgba(255, 255, 255, .5); font-size: .72rem; text-transform: uppercase;
        letter-spacing: .05em; padding: .2rem .65rem .4rem;
    }
    /* Un ponte invisibile tra icona e riquadro: il mouse non "cade" nel vuoto */
    .app-sidebar.collapsed .gruppo > .sottomenu::before {
        content: ""; position: absolute; left: -8px; top: 0; bottom: 0; width: 8px;
    }
}

/* ---------- Smartphone e tablet verticale: a scomparsa ---------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 1045;
    }
    .app-sidebar.mobile-open { transform: translateX(0); }
    .app-sidebar .sidebar-toggle { display: none; }
    .sidebar-backdrop.show {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1040;
    }
}

/* ================================================================ */
/* HEADER                                                            */
/* ================================================================ */
.app-header {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.app-header .contesto {
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0;
}
/* Telefono e tablet: in alto menu, account e uscita su una riga; sotto dove si lavora (studio, azienda) */
@media (max-width: 991.98px) {
    .app-header { gap: .5rem; margin-bottom: 1rem; }
    .app-header .contesto { order: 3; flex: 1 1 100%; }
}
@media (max-width: 575.98px) {
    /* Filtri delle liste uno per riga, larghi come lo schermo (le tendine con voci lunghe non escono più) */
    .toolbar > .form-control, .toolbar > .form-select, .toolbar > .input-group { flex: 1 1 100%; width: 100% !important; min-width: 0 !important; }
    .dash-header { padding: 1.1rem 1.1rem 1rem; }
}
.toolbar .form-select { max-width: 100%; }
.chip-contesto {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
    padding: .3rem .75rem; font-size: .85rem; color: var(--ink-600); max-width: 100%;
}
.chip-contesto strong { color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-azienda { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-700); }
/* Logo dell'azienda nell'header (azienda/logo :: testata): al posto dell'icona, su fondo bianco */
.logo-testata { display: inline-flex; align-items: center; }
.logo-testata img { height: 26px; max-width: 110px; object-fit: contain; background: #fff; border-radius: 6px; padding: 1px 3px; }
.chip-azienda:has(.logo-testata img) { padding-top: .2rem; padding-bottom: .2rem; padding-left: .3rem; }

/* ================================================================ */
/* INTESTAZIONE DELLE PAGINE, TOOLBAR, TABELLE                       */
/* ================================================================ */
.dash-header {
    position: relative;
    padding: 1.5rem 1.5rem 1.25rem;
    border-radius: 18px;
    background:
            radial-gradient(600px 200px at 10% 0%, rgba(156, 201, 173, .18), transparent 60%),
            linear-gradient(135deg, var(--brand-50) 0%, #fff 60%);
    border: 1px solid rgba(99, 102, 241, .15);
    /* niente overflow: hidden, taglierebbe i menu a tendina dei pulsanti (Nuovo trattamento, Stampa) */
}
.dash-header::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    border-radius: 17px 17px 0 0;
    background: linear-gradient(90deg, var(--accent-400), var(--brand-600), var(--brand-900));
}
.dash-header h1 { color: var(--brand-900); letter-spacing: -.02em; font-weight: 700; font-size: 1.6rem; }

.toolbar {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: .9rem 1rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.btn-brand { background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 600; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-ghost {
    background: #fff; border: 1px solid var(--line); color: var(--ink-600); font-size: .88rem;
}
.btn-ghost:hover { border-color: var(--brand-500); color: var(--brand-700); background: var(--brand-50); }
.btn-azione {
    width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink-600); text-decoration: none;
}
.btn-azione:hover { color: var(--brand-700); border-color: var(--brand-500); background: var(--brand-50); }
.btn-azione.pericolo:hover { color: #be123c; border-color: #fda4af; background: #fff1f2; }

.table-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
    overflow: hidden; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.table-card table { margin-bottom: 0; }
.table-card thead th {
    background: #f8fafc; color: var(--ink-600); font-weight: 600; font-size: .78rem;
    text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line);
    padding: .85rem 1rem; white-space: nowrap;
}
.table-card tbody td {
    padding: .8rem 1rem; vertical-align: middle; border-color: #f1f5f9; font-size: .9rem;
}
.table-card tbody tr:hover { background: #f8fafc; }
.table-card tbody tr.non-attiva td { color: var(--ink-400); }

.avatar {
    width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand-50), var(--brand-100)); color: var(--brand-700);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem;
}

.badge-stato { font-weight: 600; border-radius: 999px; padding: .3em .7em; font-size: .75rem; }
.badge-attivo { background: #dcfce7; color: #166534; }
.badge-spento { background: #f1f5f9; color: #64748b; }
.badge-ruolo { background: var(--brand-50); color: var(--brand-700); }
.badge-avviso { background: #fef3c7; color: #92400e; }
/* Criticità degli asset (il più alto tra riservatezza, integrità e disponibilità) */
.crit-alto { background: #fee2e2; color: #991b1b; }
.crit-medio { background: #fef3c7; color: #92400e; }
.crit-basso { background: #dcfce7; color: #166534; }

.card-pannello {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04); padding: 1.25rem;
}
.card-pannello h2 { font-size: 1.05rem; font-weight: 700; color: var(--brand-900); }
.dati-lista dt { font-weight: 600; color: var(--ink-600); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
.dati-lista dd { margin-bottom: .8rem; }

.numero-grande { font-size: 2rem; font-weight: 700; color: var(--brand-900); line-height: 1; }
.numero-grande.urgenza-scaduta { color: #b91c1c; }
.numero-grande.urgenza-in_scadenza { color: #b45309; }

/* ================================================================ */
/* GRAFICI (common/fragments/grafici): barre orizzontali e colonne   */
/* in HTML. Serie singola blu #2a78d6 (validata), barre <= 24px,     */
/* estremità arrotondata 4px e base dritta, griglia appena visibile, */
/* testi con i colori del testo (mai quello della serie).            */
/* ================================================================ */
:root {
    --serie-1: #2a78d6;
    --griglia: #e1e0d9;
    --asse: #c3c2b7;
    --stato-buono: #0ca30c;
    --stato-attenzione: #fab219;
    --stato-critico: #d03b3b;
    --stato-neutro: #a3a29a;
}
.grafico-barre { display: grid; grid-template-columns: minmax(0, 40%) 1fr; gap: 6px 12px; align-items: center; }
.grafico-barre .etichetta { font-size: .85rem; color: var(--ink-600); text-align: right; overflow-wrap: anywhere; }
.grafico-barre .traccia { display: flex; align-items: center; gap: 8px; border-left: 1px solid var(--asse); min-height: 24px; }
.grafico-barre .barra { height: 18px; background: var(--serie-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.grafico-barre .barra.zero { background: transparent; }
.grafico-barre .valore { font-size: .85rem; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.grafico-colonne { display: flex; align-items: flex-end; gap: 6px; height: 160px; border-bottom: 1px solid var(--asse);
    background-image: linear-gradient(var(--griglia) 1px, transparent 1px); background-size: 100% 40px; background-position: 0 -1px; }
.grafico-colonne .colonna { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.grafico-colonne .cima { font-size: .75rem; color: var(--ink-600); line-height: 1.4; min-height: 1.1em; }
.grafico-colonne .barra { width: 100%; max-width: 24px; background: var(--serie-1); border-radius: 4px 4px 0 0; }
.grafico-colonne .colonna:hover .barra, .grafico-barre .traccia:hover .barra { filter: brightness(.88); }
.grafico-mesi { display: flex; gap: 6px; margin-top: 4px; }
.grafico-mesi span { flex: 1 1 0; text-align: center; font-size: .72rem; color: #898781; min-width: 0; }
.misuratore { height: 10px; border-radius: 999px; background: var(--brand-50); overflow: hidden; }
.misuratore > div { height: 100%; border-radius: 999px; }
.misuratore.buono > div { background: var(--stato-buono); }
.misuratore.medio > div { background: var(--stato-attenzione); }
.misuratore.basso > div { background: var(--stato-critico); }
.legenda { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--ink-600); }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.stati-riga { border-left: 1px solid var(--asse); padding: 3px 0 3px 8px; min-width: 0; }
.pila { display: flex; gap: 2px; height: 16px; }
.pila > span { flex-basis: 0; min-width: 4px; }
.pila > span:last-child { border-radius: 0 4px 4px 0; }
.stati-numeri { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: .75rem; color: var(--ink-600); margin-top: 2px; }
.seg-regola { background: var(--stato-buono); }
.seg-scadenza { background: var(--stato-attenzione); }
.seg-scaduti { background: var(--stato-critico); }
.seg-dafare { background: var(--stato-neutro); }
.cifra-eroe { font-size: 3.25rem; font-weight: 700; line-height: 1; color: var(--ink-900); }
.tabella-grafico { font-size: .82rem; }

/* Registro attività: dettagli "prima → dopo" */
.dettagli-registro { white-space: pre-line; font-size: .82rem; color: var(--ink-600); margin: .25rem 0 0; }

/* Form lunghi divisi in sezioni (trattamento) */
.sezione-form { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.25rem; }
.sezione-form:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.sezione-form legend { font-size: 1rem; font-weight: 700; color: var(--brand-900); margin-bottom: .75rem; }
.elenco-voci { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .75rem; }

/* Gestione delegata: tabella dei moduli con i tre livelli */
.livelli .btn-check:checked + .btn { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

/* ================================================================ */
/* TABELLE RESPONSIVE: sotto i 1200px ogni riga diventa una card     */
/* Ogni <td> ha data-label; la prima senza data-label = avatar        */
/* (nascosta), l'ultima senza = azioni.                               */
/* ================================================================ */
@media (max-width: 1199.98px) {
    .table-card:has(table) { background: transparent; border: none; box-shadow: none; overflow: visible; }
    .table-card .table-responsive { overflow: visible; }
    .table-card table, .table-card table tbody { display: block; width: 100%; }
    .table-card table thead { display: none; }
    .table-card table tbody tr {
        display: block; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
        padding: 12px 16px; margin-bottom: 12px; border: 1px solid #e5e7eb;
    }
    .table-card table tbody tr:hover { background: #fff; }
    /* Etichetta a sinistra, contenuto tutto insieme a destra (anche con più elementi: nome e reparto, più basi giuridiche) */
    .table-card table tbody td {
        display: block; padding: 8px 0; border: none; border-bottom: 1px solid #f3f4f6; text-align: right;
        min-width: 0; overflow-wrap: anywhere;
    }
    .table-card table tbody td::before {
        content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; font-weight: 600; font-size: .75rem;
        color: #6b7280; text-transform: uppercase; letter-spacing: .03em; text-align: left; line-height: 1.6;
    }
    .table-card table tbody td::after { content: ""; display: table; clear: both; }
    .table-card table tbody td:not([data-label]):first-child { display: none; }
    .table-card table tbody td:last-child:not([data-label]) {
        display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; border-bottom: none; padding-top: 10px;
    }
    .table-card table tbody td:last-child:not([data-label])::after { content: none; }
    .table-card table tbody td:last-child:not([data-label])::before { content: none; }
    .table-card table tbody td.vuota { display: block; text-align: center; }
    .table-card table tbody td.vuota::before { content: none; }
}

/* ================================================================ */
/* ACCESSO (login, scelta, password)                                 */
/* ================================================================ */
.pagina-accesso {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
    background:
            radial-gradient(900px 400px at 0% 0%, rgba(156, 201, 173, .25), transparent 60%),
            radial-gradient(700px 400px at 100% 100%, rgba(19, 96, 111, .18), transparent 60%),
            #f5f7fb;
}
.riquadro-accesso {
    width: 100%; max-width: 440px; background: #fff; border-radius: 20px; padding: 2rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .12); border: 1px solid var(--line);
}
.riquadro-accesso.largo { max-width: 640px; }
.marchio-accesso { display: flex; align-items: center; gap: .6rem; color: var(--brand-900); font-weight: 700; font-size: 1.3rem; }
.marchio-accesso .logo-accesso { height: 56px; width: auto; max-width: 100%; }
.card-accesso {
    display: flex; align-items: center; gap: .9rem; width: 100%; text-align: left;
    border: 1px solid var(--line); border-radius: 14px; padding: .9rem 1rem; background: #fff;
}
.card-accesso:hover { border-color: var(--brand-500); background: var(--brand-50); }
.card-accesso .icona {
    width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-50); color: var(--brand-700); font-size: 1.3rem; flex-shrink: 0;
}

/* ================================================================ */
/* NOTIFICHE TOAST (js/toast.js, copiato da FitDesk)                 */
/* ================================================================ */
.toast-area {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    z-index: 1090; width: 380px; max-width: calc(100vw - 32px);
    display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast-app {
    --toast-colore: var(--brand-600);
    width: 100%; pointer-events: auto; background: #fff; border: 1px solid var(--line);
    border-left: 5px solid var(--toast-colore); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .15); overflow: hidden;
}
.toast-app.fade { transition: opacity .6s ease, transform .6s ease; }
.toast-app.showing, .toast-app:not(.show) { transform: translateY(-8px); }
.toast-app.toast-success { --toast-colore: #16a34a; }
.toast-app.toast-danger  { --toast-colore: #dc2626; }
.toast-app.toast-warning { --toast-colore: #d97706; }
.toast-app.toast-info    { --toast-colore: #0284c7; }
.toast-app .toast-body { display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; font-size: .95rem; }
.toast-app .toast-icona { color: var(--toast-colore); font-size: 1.2rem; line-height: 1.2; flex-shrink: 0; }
.toast-app .toast-testo { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.toast-app .btn-close { flex-shrink: 0; padding: 8px; margin: -6px -4px -6px 0; }
.toast-app .toast-barra {
    height: 3px; background: var(--toast-colore); opacity: .5; transform-origin: left;
    animation: toast-tempo linear forwards;
}
.toast-app.toast-pausa .toast-barra { animation-play-state: paused; }
.toast-app.toast-fermata .toast-barra { visibility: hidden; }
@keyframes toast-tempo { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 575.98px) {
    .toast-area {
        top: calc(10px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px));
        right: calc(10px + env(safe-area-inset-right, 0px)); width: auto; max-width: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    .toast-app .toast-barra { animation: none; visibility: hidden; }
    .toast-app.showing, .toast-app:not(.show) { transform: none; }
}

/* ================================================================ */
/* CAMPI DEI FORM: i colori del marchio al posto del blu di Bootstrap */
/* ================================================================ */
.form-check-input:checked { background-color: var(--brand-600); border-color: var(--brand-600); }
.form-check-input:focus, .form-control:focus, .form-select:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 .25rem rgba(19, 96, 111, .18);
}

/* ================================================================ */
/* VEDI COME: fascia in alto durante la visione in sola lettura      */
/* ================================================================ */
.fascia-vedi-come {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    background: #b45309; color: #fff; border-radius: 12px; padding: .65rem 1rem;
    box-shadow: 0 4px 14px rgba(180, 83, 9, .25);
}

/* ================================================================ */
/* SCHEDA AZIENDA: intestazione da biglietto da visita e riquadri   */
/* ================================================================ */
.scheda-intestazione { display: flex; align-items: center; gap: 1.25rem; }
/* Logo nella scheda azienda (azienda/logo :: riquadro), al posto della sigla */
.scheda-logo-box { flex-shrink: 0; text-align: center; }
.scheda-logo { display: block; max-width: 180px; max-height: 80px; object-fit: contain; }
.scheda-sigla {
    width: 72px; height: 72px; border-radius: 18px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-900)); color: #fff;
    font-size: 2rem; font-weight: 700; box-shadow: 0 6px 18px rgba(19, 96, 111, .25);
}
.scheda-nome { font-size: 1.5rem; font-weight: 700; color: var(--brand-900); margin: 0; letter-spacing: -.01em; }
.scheda-indirizzo { color: var(--ink-600); }
.etichetta-sezione { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); font-weight: 600; }
.riquadro-titolo { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--brand-900); margin-bottom: 1rem; }
.riquadro-icona {
    width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-50); color: var(--brand-700);
}
.lista-info { list-style: none; padding: 0; margin: 0; }
.lista-info li { display: flex; align-items: baseline; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.lista-info li:last-child { border-bottom: 0; }
.lista-info li > .bi { color: var(--brand-600); width: 1.1rem; flex-shrink: 0; }
.lista-info .nome { color: var(--ink-600); min-width: 9.5rem; font-size: .9rem; }
@media (max-width: 575.98px) {
    .scheda-intestazione { flex-direction: column; align-items: flex-start; }
    /* sul telefono: icona ed etichetta sulla stessa riga, il valore sotto, allineato all'etichetta */
    .lista-info li { flex-wrap: wrap; row-gap: .15rem; }
    .lista-info .nome { min-width: 0; flex: 1 1 auto; }
    .lista-info li > :not(.bi):not(.nome) { flex-basis: 100%; padding-left: 1.7rem; }
    .lista-info li > .badge-stato:not(.bi):not(.nome) { flex: 0 0 auto; padding-left: .6rem; margin-left: 1.7rem; }
}

/* Elenco "Scegli" (chi è nominato): lungo, con lo scorrimento */
.elenco-scegli { max-height: 320px; overflow-y: auto; min-width: 280px; }
/* Casella Cerca in cima al menu Aggiungi (common/fragments/suggerimenti): resta in vista scorrendo le voci */
.elenco-scegli .filtro-voci { position: sticky; top: 0; z-index: 1; background: #fff; padding: .5rem .5rem .35rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }

/* DPIA: punteggio complessivo e mappe dei rischi (dpia/pagina :: mappa) */
.dpia-punteggio { font-size: 1.5rem; display: flex; align-items: center; }
.dpia-mappa table { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.dpia-mappa td { height: 46px; border-radius: 6px; text-align: center; vertical-align: middle; padding: 2px; }
.dpia-mappa th.asse { width: 78px; font-size: .7rem; font-weight: 500; color: var(--ink-600); text-align: right; padding-right: 4px; }
.dpia-mappa th.asse-x { font-size: .7rem; font-weight: 500; color: var(--ink-600); text-align: center; overflow: hidden; text-overflow: ellipsis; }
.dpia-mappa .mappa-basso { background: #dcfce7; }
.dpia-mappa .mappa-medio { background: #fef3c7; }
.dpia-mappa .mappa-alto { background: #fecdd3; }
.mappa-rischio { display: inline-block; font-size: .7rem; font-weight: 700; background: #fff; border: 1px solid var(--line);
                 border-radius: 999px; padding: 0 .35rem; margin: 1px; color: var(--ink-900); }
.dpia-misure { background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 10px; padding: .6rem .8rem; }
.dpia-misure-vuote { background: #fff1f2; border-color: #fecdd3; }
.guida-segnaposto summary { cursor: pointer; }
.guida-segnaposto code { white-space: nowrap; }

/* Un figlio flex che deve potersi restringere (testi troncati, schede su telefono): Bootstrap 5.3 non ha questa classe */
.min-w-0 { min-width: 0 !important; }
/* Testo troncato da computer, a capo sul telefono (dove il taglio nasconderebbe l'informazione) */
@media (max-width: 575.98px) { .a-capo-telefono { white-space: normal !important; overflow: visible !important; } }
