/* FILE: public/assets/css/app.css */
/* Stile di base EDHUB: pagine pubbliche/di accesso + layout applicativo
   (barra superiore, menu laterale, tema chiaro/scuro).

   Palette/forma/tipografia allineate allo stile di EDSCORM (stesso brand,
   richiesto dall'utente il 2026-10-22, da applicare retroattivamente a tutto
   ciò che è stato costruito finora e a tutto ciò che verrà costruito dopo):
   navy/indigo, bordi arrotondati, ombre morbide, font Inter/Sora. EDSCORM
   carica Inter/Sora da Google Fonts; EDHUB no (nessun CDN esterno, mai, in
   tutta questa app) — qui c'è solo il NOME del font in cima alla pila dei
   font di sistema: se un visitatore ha Inter installato lo vedrà, altrimenti
   ricade sui font di sistema (che gli somigliano molto) senza alcuna
   richiesta di rete.

   Tecnica: EDHUB usa Bootstrap 5.3 "di serie" (niente ricompilazione SASS,
   solo il CSS precompilato in assets/vendor/bootstrap). Bootstrap 5.3 legge
   quasi tutti i colori/raggi/ombre dei suoi componenti (card, tabella,
   badge, dropdown, list-group, pulsanti, form...) da variabili CSS --bs-*
   definite a livello di :root — sovrascrivendole qui si re-skinnano TUTTI i
   componenti Bootstrap già in uso in ogni pagina esistente, senza toccare
   un solo file di vista, e vale automaticamente anche per le pagine future
   finché continuano a usare le stesse classi Bootstrap (come fatto finora).
   Scelta deliberata: non tocchiamo le variabili semantiche --bs-success/
   --bs-warning/--bs-danger (il contrasto testo/sfondo di Bootstrap per
   .text-bg-warning ecc. è calcolato/fissato in fase di build — cambiarle
   qui rischierebbe badge/alert illeggibili su pagine che non possiamo
   verificare visivamente una per una in questo ambiente). */

:root {
    /* --- Palette EDSCORM (chiaro) --- */
    --bg: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #f9f9fd;
    --fg: #1c1d33;
    --muted: #6b6d85;
    --border: #e3e5f0;
    --border-strong: #cfd2e6;
    --primary: #4b56e0;
    --primary-hover: #3a44c8;
    --primary-soft: #eef0fd;
    --primary-rgb: 75, 86, 224;
    --heading: #0e0b52;
    --navy: #0e0b52;
    --navy-deep: #070531;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(14, 11, 82, .05);
    --shadow: 0 1px 2px rgba(14, 11, 82, .05), 0 4px 16px rgba(14, 11, 82, .05);
    --sidebar-bg: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
    --sidebar-fg: #e4e5fb;
    --sidebar-muted: #a9abd9;
    --sidebar-active-bg: var(--primary);
    --topbar-bg: rgba(255, 255, 255, .92);
    --required-bg: #fff4e0;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* --- Variante scura, derivata dalla stessa famiglia navy/indigo
           (EDSCORM non ne ha una propria: questa è la naturale estensione
           della sua palette, non esisteva prima in EDSCORM) --- */
        --bg: #0f0e2e;
        --surface: #17154a;
        --surface-2: #1c1a56;
        --fg: #e7e8f7;
        --muted: #a2a4d6;
        --border: #2d2a68;
        --border-strong: #3d3a80;
        --primary: #6d76ec;
        --primary-hover: #8990f0;
        --primary-soft: rgba(109, 118, 236, .18);
        --primary-rgb: 109, 118, 236;
        --heading: #c7c9f5;
        --topbar-bg: rgba(23, 21, 74, .92);
        --required-bg: #332b12;
    }
}

:root[data-theme="dark"] {
    --bg: #0f0e2e;
    --surface: #17154a;
    --surface-2: #1c1a56;
    --fg: #e7e8f7;
    --muted: #a2a4d6;
    --border: #2d2a68;
    --border-strong: #3d3a80;
    --primary: #6d76ec;
    --primary-hover: #8990f0;
    --primary-soft: rgba(109, 118, 236, .18);
    --primary-rgb: 109, 118, 236;
    --heading: #c7c9f5;
    --topbar-bg: rgba(23, 21, 74, .92);
    --required-bg: #332b12;
}

/* --- Ponte verso le variabili di Bootstrap: un solo punto da cambiare
       (sopra) per re-skinnare ogni componente Bootstrap già usato in ogni
       vista esistente (card, tabelle, badge, dropdown, list-group, form,
       pulsanti, link) --- */
:root {
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--fg);
    --bs-emphasis-color: var(--fg);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--border);
    --bs-border-color-translucent: var(--border);
    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-link-color: var(--primary);
    --bs-link-color-rgb: var(--primary-rgb);
    --bs-link-hover-color: var(--primary-hover);
    --bs-border-radius: var(--radius);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius);
    --bs-border-radius-pill: 999px;
    --bs-badge-border-radius: 999px;
    --bs-box-shadow: var(--shadow);
    --bs-box-shadow-sm: var(--shadow-sm);
    --bs-font-sans-serif: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-secondary-bg: var(--surface-2);
    --bs-tertiary-bg: var(--surface-2);
    --bs-card-bg: var(--surface);
    --bs-card-border-color: var(--border);
    --bs-card-color: var(--fg);
    --bs-card-cap-bg: var(--surface-2);
    --bs-table-border-color: var(--border);
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-border-color: var(--border);
    --bs-dropdown-link-color: var(--fg);
    --bs-dropdown-link-hover-bg: var(--primary-soft);
    --bs-dropdown-link-hover-color: var(--primary);
    --bs-dropdown-link-active-bg: var(--primary);
    --bs-list-group-bg: var(--surface);
    --bs-list-group-color: var(--fg);
    --bs-list-group-border-color: var(--border);
    --bs-list-group-action-hover-bg: var(--surface-2);
    --bs-list-group-active-bg: var(--primary);
    --bs-list-group-active-border-color: var(--primary);
    --bs-btn-border-radius: var(--radius-sm);
    --bs-btn-border-radius-sm: var(--radius-sm);
    --bs-btn-border-radius-lg: var(--radius-sm);
    --bs-nav-pills-link-active-bg: var(--primary);
    --bs-alert-border-radius: var(--radius-sm);
    --bs-modal-bg: var(--surface);
    --bs-modal-border-color: var(--border);
    --bs-offcanvas-bg: var(--surface);
    --bs-offcanvas-color: var(--fg);
    --bs-pagination-bg: var(--surface);
    --bs-pagination-color: var(--fg);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-border-radius: var(--radius-sm);
    --bs-pagination-hover-bg: var(--primary-soft);
    --bs-pagination-hover-color: var(--primary);
    --bs-pagination-hover-border-color: var(--border);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-disabled-bg: var(--surface);
    --bs-pagination-disabled-color: var(--muted);
}

/* ---------- Variabili Bootstrap "rilocalizzate" dal componente stesso ----------
   Scoperto con cura (non assunto dalla documentazione) verificando via
   document.styleSheets/getComputedStyle quali regole vincono davvero: alcuni componenti
   di Bootstrap 5.3 (in questa build precompilata) ridichiarano localmente, sul proprio
   selettore (es. `.list-group{--bs-list-group-active-bg:#0d6efd;...}`), le stesse
   variabili già sovrascritte sopra a :root. Una variabile CSS personalizzata si risolve
   dall'antenato più VICINO che la definisce, non da quello con la regola più "forte": la
   ridichiarazione locale del componente vince sempre sul semplice override a :root, anche
   se la regola a :root è scritta dopo nel file. Alcune di queste ridichiarazioni locali
   sono innocue (puntano comunque a `var(--bs-body-bg)`, che eredita correttamente — solo
   una sfumatura in meno rispetto al bianco di --surface); altre sono valori FISSI
   (`#0d6efd`, l'azzurro di serie di Bootstrap) che finora hanno vanificato del tutto
   l'override — bug reale segnalato dall'utente ("sfondo azzurro" sulla riga selezionata di
   Messaggi, invece del nostro indaco). Qui si corregge puntando le stesse variabili
   direttamente sul selettore del componente, l'unico punto dove contano davvero. */
/* Sfondo chiaro invece che indaco pieno: su un elenco con testo da leggere (es. un
   messaggio selezionato in Messaggi, con mittente/oggetto/anteprima) uno sfondo scuro a
   piena saturazione con testo bianco è faticoso da leggere — segnalato dall'utente
   ("troppo scuro"). Testo e bordo restano nel colore di marca, solo lo sfondo è tenue. */
.list-group {
    --bs-list-group-active-bg: var(--primary-soft);
    --bs-list-group-active-color: var(--fg);
    --bs-list-group-active-border-color: var(--primary);
}

.dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-link-active-bg: var(--primary);
}

.pagination {
    --bs-pagination-bg: var(--surface);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
}

.nav-pills {
    --bs-nav-pills-link-active-bg: var(--primary);
}

/* Stesso bug: `.form-check-input{--bs-form-check-bg:var(--bs-body-bg);...}` ridichiara lo
   sfondo sulla pagina stessa (--bg, lo stesso colore dello sfondo intorno) col bordo che usa
   semplicemente --bs-border-color (--border, quasi identico) — una casella di spunta quasi
   invisibile su sfondo chiaro, segnalato dall'utente. Sfondo --surface (bianco in chiaro) e
   bordo --border-strong, decisamente più leggibili. */
.form-check-input {
    --bs-form-check-bg: var(--surface);
    border-color: var(--border-strong);
}

/* Sezioni di una form (Attività/Compiti e in futuro altre) racchiuse con un bordo fine e
   arrotondato, richiuse/apribili col pattern data-collapse-* già usato altrove (cartelle di
   Messaggi) — di default aperte (nessuna chiave salvata finché l'utente non ne chiude una). */
.form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem 1rem .25rem;
}

.form-section > legend {
    width: auto;
    padding: 0 .4rem;
    margin: -1.5rem 0 1rem -.25rem;
    background: var(--surface);
}

.form-section-toggle {
    color: var(--muted);
}

.form-section-toggle .bi {
    transition: transform .15s ease-in-out;
}

.form-section-toggle[aria-pressed="true"] .bi {
    transform: rotate(-90deg);
}

/* Vista Calendario (app/views/calendar/index.php): griglia settimanale a mezz'ore, Attività
   posizionate in assoluto dentro la colonna del giorno in base all'orario, Compiti come
   fascia di "chip" sopra — stessa larghezza di colonna tempo (56px) tra fascia Compiti e
   griglia sotto, per restare allineate. */
.cal-grid {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
}

.cal-grid-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.cal-header-row {
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
}

.cal-day-header {
    text-align: center;
    padding: .5rem .25rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--heading);
    border-left: 1px solid var(--border);
}

.cal-day-header.cal-today {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.cal-time-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--muted);
    text-align: right;
    padding-right: .4rem;
    transform: translateY(-.6em);
}

.cal-day-col {
    position: relative;
    border-left: 1px solid var(--border);
}

.cal-day-col.cal-today {
    background: var(--primary-soft);
}

.cal-slot {
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.cal-slot:hover {
    background: var(--primary-soft);
}

.cal-event {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    color: #fff;
    font-size: .68rem;
    padding: 1px 4px;
    overflow: hidden;
    text-decoration: none;
    line-height: 1.2;
    z-index: 1;
}

.cal-event:hover {
    opacity: .9;
    color: #fff;
}

/* Slot "Occupato": si vede il colore del titolare ma non il contenuto (nessun permesso di
   lettura sul record) — righe diagonali al posto del pieno, per non confonderlo con un vero
   evento, e cursore normale perché non è cliccabile. */
.cal-event-busy {
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .35) 0 6px, transparent 6px 12px);
    cursor: default;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Una riga di griglia per Compito (grid-column/grid-row assegnati inline da
   calendar/index.php, Gantt-style da Data di inizio a Data chiusura) invece di un blocco
   ripetuto in ogni giorno, che sforava sotto il pannello utenti — segnalato dall'utente. */
.cal-tasks-band {
    row-gap: 3px;
    column-gap: 0;
    resize: vertical;
    overflow-y: auto;
    height: 30px;
    min-height: 30px;
    max-height: 60vh;
    padding-bottom: 4px;
}

.cal-task-bar {
    display: flex;
    align-items: center;
    font-size: .7rem;
    padding: 1px 6px;
    margin: 0 2px;
    border: 1px solid;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Vista "Risorse" del Calendario (richiesta esplicitamente dall'utente): un "mattoncino" per
   Attività dentro la cella risorsa/giorno, impilati — a differenza di .cal-event (posizionato
   assolutamente nella griglia oraria della Settimana), qui è un blocco normale nel flusso
   della cella della tabella, il bordo colorato a sinistra sostituisce lo sfondo pieno per
   restare leggibile anche quando ce ne sono tanti in una cella piccola. */
.cal-res-chip {
    display: block;
    font-size: .72rem;
    padding: 2px 5px;
    margin-bottom: 3px;
    border-left: 3px solid;
    border-radius: 3px;
    background: var(--surface-2);
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-res-chip:last-child {
    margin-bottom: 0;
}

.cal-res-chip.cal-event-busy {
    color: #fff;
    border-left-color: transparent;
}

.cal-resources-table th.cal-today,
.cal-resources-table td.cal-today {
    background: var(--surface-2);
}

.card {
    --bs-card-bg: var(--surface);
}

.modal {
    --bs-modal-bg: var(--surface);
}

/* Modale "Crea" del Calendario: le due schede Evento/Compito hanno ciascuna la propria
   <form>/.modal-body dentro .tab-content, non figlia diretta di .modal-content come si
   aspetta il meccanismo flex di .modal-dialog-scrollable di Bootstrap (che quindi qui non
   funziona: niente scroll, segnalato dall'utente) — si vincola l'altezza di .modal-body
   direttamente, indipendentemente da quanti livelli di wrapper ci sono sopra. */
#cal-create-modal .modal-body {
    max-height: 65vh;
    overflow-y: auto;
}

.offcanvas, .offcanvas-sm, .offcanvas-md, .offcanvas-lg, .offcanvas-xl, .offcanvas-xxl {
    --bs-offcanvas-bg: var(--surface);
}

.btn {
    --bs-btn-border-radius: var(--radius-sm);
}

.badge {
    --bs-badge-border-radius: 999px;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--bs-font-sans-serif);
}

/* Bootstrap 5.3 (in questa build precompilata) non espone variabili --bs-input-*
   per .form-control/.form-select: lo sfondo/colore/bordo leggono direttamente
   da --bs-body-bg/--bs-body-color/--bs-border-color (la pagina), e il raggio
   da --bs-border-radius (12px, quello delle card) — qui si danno ai campi uno
   sfondo bianco distinto dalla pagina e il raggio "piccolo" di EDSCORM (8px),
   come nell'originale, senza toccare le variabili condivise con il resto. */
.form-control, .form-select {
    background-color: var(--surface);
    color: var(--fg);
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
}

.form-control:focus, .form-select:focus {
    background-color: var(--surface);
    color: var(--fg);
    border-color: var(--primary);
    box-shadow: 0 0 0 .25rem var(--primary-soft);
}

h1, h2, h3, h4, h5, h6, legend {
    color: var(--heading);
    font-weight: 700;
    letter-spacing: -.01em;
}

.card, .navbar, .dropdown-menu {
    background: var(--surface);
    color: var(--fg);
}

.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.error-page .code {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 20% 10%, #262191 0%, var(--navy) 40%, var(--navy-deep) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

.auth-brand {
    font-size: 1.5rem;
}

/* --- Layout applicativo: barra superiore + menu laterale --- */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--topbar-bg);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
}

.app-topbar .brand {
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    white-space: nowrap;
}

.app-topbar .brand .brand-logo {
    height: 28px;
    width: auto;
    vertical-align: middle;
}

.app-topbar .brand .brand-logo-dark {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .app-topbar .brand .brand-logo-light {
        display: none;
    }
    :root:not([data-theme="light"]) .app-topbar .brand .brand-logo-dark {
        display: inline;
    }
}

:root[data-theme="dark"] .app-topbar .brand .brand-logo-light {
    display: none;
}

:root[data-theme="dark"] .app-topbar .brand .brand-logo-dark {
    display: inline;
}

.app-topbar .search {
    flex: 1 1 auto;
    max-width: 420px;
}

.app-topbar .topbar-icons {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}

.app-topbar .topbar-icons .btn {
    color: var(--muted);
}

.app-topbar .topbar-icons .btn.disabled {
    opacity: .35;
}

/* I pulsanti Accetta/Rifiuta/Apri dentro il menu Notifiche sono anche loro ".btn" dentro
   ".topbar-icons": la regola sopra (pensata solo per le icone grigie della barra) vinceva
   per specificità anche sui loro colori di Bootstrap (verde/rosso/grigio), persino al passaggio
   del mouse — segnalato dall'utente, testo sempre grigio e illeggibile sullo sfondo pieno
   dell'hover. Qui si ridà la parola alle variabili colore di Bootstrap, con una specificità
   ancora più alta per vincere anche sull'hover dei vari .btn-outline-*. */
.app-topbar .topbar-icons .dropdown-menu .btn {
    color: var(--bs-btn-color);
}

.app-topbar .topbar-icons .dropdown-menu .btn:hover {
    color: var(--bs-btn-hover-color);
}

.app-topbar .topbar-icon-badge {
    position: absolute;
    /* Spostato fuori dall'angolo del pulsante (non più top:0/right:0, appoggiato sopra
       l'icona): con numeri a 2-3 cifre ("99+") copriva il simbolo sotto, rendendolo
       illeggibile — segnalato dall'utente. Il bordo dello stesso colore dello sfondo della
       barra lo stacca visivamente dall'icona invece di sembrarci incollato sopra. */
    top: -5px;
    right: -6px;
    min-width: 18px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--danger, #dc3545);
    color: #fff;
    font-size: .625rem;
    line-height: 16px;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
    pointer-events: none;
}

.topbar-notifications-menu {
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
}

.app-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
}

.app-body {
    display: flex;
    min-height: calc(100vh - 56px);
}

.app-sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    border-right: 1px solid var(--border);
    padding: 1rem .5rem;
    overflow-y: auto;
}

.app-body.is-collapsed .app-sidebar {
    width: 64px;
    flex-basis: 64px;
}

.app-body.is-collapsed .app-sidebar .area-label,
.app-body.is-collapsed .app-sidebar .module-label {
    display: none;
}

.app-sidebar .area-label {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .04em;
    color: var(--sidebar-muted);
    padding: .75rem .75rem .25rem;
}

.app-sidebar .module-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-fg);
    text-decoration: none;
}

.app-sidebar .module-link:hover {
    background: rgba(255, 255, 255, .07);
}

.app-sidebar .module-link.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(75, 86, 224, .45);
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.5rem;
}

.sidebar-empty {
    color: var(--sidebar-muted);
    font-size: .85rem;
    padding: .5rem .75rem;
}

/* Il bootstrap.min.css incluso nel pacchetto non contiene le regole responsive
   di .offcanvas-md (rimosse da un tool di purge mai usato su un offcanvas):
   le ripristiniamo qui perché il menu laterale torni statico da md in su. */
@media (min-width: 992px) {
    .app-sidebar.offcanvas-lg {
        position: static;
        z-index: auto;
        display: flex !important;
        visibility: visible !important;
        background-color: transparent;
        box-shadow: none;
        transform: none;
        transition: none;
    }

    .app-sidebar.offcanvas-lg .offcanvas-body {
        display: flex;
        flex-grow: 1;
        padding: 0;
        overflow-y: visible;
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        inset: 56px 0 0 auto;
        width: 80%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform .2s ease;
        z-index: 1040;
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-body.is-collapsed .app-sidebar {
        width: 80%;
        flex-basis: auto;
    }

    .app-body.is-collapsed .app-sidebar .area-label,
    .app-body.is-collapsed .app-sidebar .module-label {
        display: block;
    }
}

/* Guida online "i" (app/views/partials/_help.php): testo più piccolo del resto
   dell'app, e gli esempi dentro un blockquote risaltano rispetto al resto della guida. */
.help-view,
.help-edit [data-rte] {
    font-size: .875rem;
}

.help-view blockquote,
.help-edit [data-rte] blockquote {
    margin: .75rem 0;
    padding: .5rem .9rem;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    font-style: italic;
}

/* Campo obbligatorio in un form (le viste form.php di ogni modulo): sfondo chiaro
   per farlo risaltare rispetto ai campi facoltativi, come richiesto dall'utente. */
.is-required-field {
    background-color: var(--required-bg);
}

/* Bootstrap non ha un'utility "min-width:0": serve per far restringere un elemento
   dentro un contenitore flex (altrimenti un figlio flex non si restringe mai sotto la
   larghezza naturale del suo contenuto, anche con .text-truncate sopra — un indirizzo
   email lungo può così "spingere" oltre la colonna invece di troncarsi). Bug reale
   trovato nell'elenco Messaggi con un mittente lungo (comunicazioni@staff.aruba.it): il
   testo sconfinava nella colonna di lettura accanto. */
.min-w-0 {
    min-width: 0;
}


/* ---------- Pagine interne: breadcrumb, intestazione, pannello filtri, tabelle ----------
   Stile EDSCORM (richiesto il 2026-10-22, vedi la nota in cima al file): elenchi come
   "Aziende" vanno vestiti come lo screen allegato dall'utente (breadcrumb "dove ti trovi",
   intestazione con eventuale pulsante indietro e azione primaria, un pannello distinto per
   i filtri, intestazioni di tabella in maiuscolo, righe con un lieve sfondo al passaggio
   del mouse, paginazione a pillole). Niente di questo cambia il COMPORTAMENTO di nessuna
   pagina — solo l'aspetto — e si applica da solo a ogni tabella/paginazione esistente
   (classi Bootstrap già in uso ovunque); breadcrumb e pannello filtri vanno invece aggiunti
   vista per vista (classi nuove, markup che prima non c'era). */

.breadcrumb {
    font-size: .8rem;
    --bs-breadcrumb-divider: ">";
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: .75rem;
}

.page-head-left {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.page-head .page-sub {
    margin: .25rem 0 0;
    color: var(--muted);
    font-size: .9rem;
}

.page-head-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.btn-back {
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .4rem .75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-weight: 500;
    text-decoration: none !important;
}

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

.filters-panel {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    padding: .75rem .875rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: .75rem;
}

.table > thead > tr > th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.table > thead > tr > th a {
    color: inherit;
    text-decoration: none;
}

/* Tutte le tabelle di EDHUB usano .table senza il modificatore .table-hover di
   Bootstrap (mai aggiunto vista per vista): qui l'evidenziazione al passaggio del
   mouse si applica direttamente a .table, per averla ovunque senza doverla
   aggiungere a ogni tabella esistente. */
.table > tbody > tr:hover > * {
    background-color: var(--surface-2);
}

/* ---------- Messaggi: colonna cartelle comprimibile (più spazio per leggere) ----------
   Richiesto dall'utente: un'icona per comprimere la colonna delle cartelle IMAP a sole
   icone, come il menu laterale principale dell'app. Stato ricordato solo nel browser di chi
   guarda (localStorage, vedi data-collapse-toggle in app.js) — non è un dato da salvare per
   l'utente, cambia da un dispositivo all'altro senza bisogno di una preferenza sul server. */
.messages-row.folders-collapsed .messages-folders-col {
    flex: 0 0 56px;
    max-width: 56px;
}

.messages-row.folders-collapsed .messages-folders-label {
    display: none !important;
}

.messages-row.folders-collapsed .messages-folders-col .list-group-item {
    justify-content: center;
    padding-left: .25rem;
    padding-right: .25rem;
}

.messages-row.folders-collapsed .messages-list-col {
    flex: 0 0 41.6667%;
    max-width: 41.6667%;
}

.messages-row.folders-collapsed .messages-reading-col {
    flex: 1 1 0;
    max-width: none;
}

/* Freccetta accanto al nome dell'account (comprimi/espandi le sue cartelle, come in Outlook):
   ruota quando è compresso — lo stesso meccanismo generico data-collapse-toggle imposta
   aria-pressed sul pulsante stesso. */
[data-collapse-toggle^="messages-account-"][aria-pressed="true"] .bi-chevron-down {
    transform: rotate(-90deg);
}
[data-collapse-toggle^="messages-account-"] .bi-chevron-down {
    display: inline-block;
    transition: transform .15s ease;
}

/* Pallino "da leggere" nell'elenco messaggi, accanto al grassetto già esistente — come
   nella webmail di riferimento dello screen allegato dall'utente. */
.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

/* Widget "To Do List" della Home: timeline verticale (richiesta esplicitamente dall'utente,
   con uno screen di riferimento da "abbellire", non da copiare letteralmente — qui adattata
   a una colonna stretta di finestra: un solo filo a sinistra, non lo zig-zag a due colonne
   dello screen, pensato per una pagina intera). Un segmento di filo per voce (non un'unica
   riga continua) così si interrompe correttamente dopo l'ultima, senza un pezzo di filo che
   "pende nel vuoto" sotto l'ultimo pallino. */
.todo-timeline {
    position: relative;
    padding: .75rem 1rem .75rem 2.5rem;
}

.todo-timeline-item {
    position: relative;
    padding-bottom: 1.1rem;
}

.todo-timeline-item:last-child {
    padding-bottom: 0;
}

.todo-timeline-item::before {
    content: '';
    position: absolute;
    left: -1.6rem;
    top: 1.3rem;
    bottom: -0.2rem;
    width: 2px;
    background: var(--border);
}

.todo-timeline-item:last-child::before {
    display: none;
}

.todo-timeline-dot {
    position: absolute;
    left: -1.95rem;
    top: 0.05rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    color: #fff;
}

.todo-timeline-item.is-done .todo-timeline-dot {
    border-color: var(--bs-success);
    background: var(--bs-success);
}

/* Spinner "in caricamento" su un pulsante d'invio (richiesto dall'utente — "come quando
   clicco per scaricare l'email", ma generico su ogni form dell'app): attenuato e bloccato ai
   clic finché la pagina non ricarica, lo spinner prende il colore del testo del pulsante
   (currentColor, già previsto da Bootstrap) quindi si adatta da solo a ogni variante/tema
   senza bisogno di colori scritti qui. Vedi app.js. */
.btn.is-loading {
    pointer-events: none;
    opacity: .75;
}

.btn.is-loading .spinner-border {
    width: .85em;
    height: .85em;
    border-width: .15em;
    vertical-align: -.125em;
}

/* Gestione avanzata del Catalogo (porting SALES HUB, /catalog-products/manage): trascina
   un prodotto su una soluzione per riassegnarlo — vedi catalog-manage.js. */
.cm-sol-drop {
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.cm-sol-drop.cm-selected {
    border-color: var(--bs-primary) !important;
    background: var(--bs-primary-bg-subtle, rgba(13, 110, 253, .08));
}

.cm-sol-drop.cm-drag-over,
#cm-unassigned-zone.cm-drag-over {
    border-color: var(--bs-primary) !important;
    border-style: dashed !important;
    background: var(--bs-primary-bg-subtle, rgba(13, 110, 253, .08));
}

.cm-prod-card {
    cursor: grab;
}

.cm-prod-card.cm-dragging {
    opacity: .5;
}

.cm-prod-card.cm-unassigned {
    border-style: dashed !important;
}

.border-dashed {
    border-style: dashed !important;
}

/* Campo "Testo lungo" con editor formattato (partials/_rte_field.php) e la sua resa in scheda. */
.rte-editor {
    min-height: 12rem;
    max-height: 60vh;
    overflow-y: auto;
    resize: vertical;
}
.rte-editor:focus { outline: 0; box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15); }
.rte-editor[contenteditable="false"] { background: var(--bs-secondary-bg); }
.rte-view > :last-child, .rte-editor > :last-child { margin-bottom: 0; }
.rte-view h3, .rte-editor h3 { font-size: 1.1rem; }
.rte-view h4, .rte-editor h4 { font-size: 1rem; }
.rte-view blockquote, .rte-editor blockquote {
    border-left: 3px solid var(--bs-primary);
    padding: .25rem .75rem;
    background: var(--bs-tertiary-bg);
    margin: .5rem 0;
}

/* Immagine prodotto (migrazione 055) */
.product-image { max-width: 100%; max-height: 260px; border-radius: .5rem; border: 1px solid var(--bs-border-color); background: #fff; object-fit: contain; }
.product-image-thumb { width: 96px; height: 96px; object-fit: contain; border-radius: .5rem; border: 1px solid var(--bs-border-color); background: #fff; }

/* Competenze Pre-Sales nella scheda Utente (migrazione 056) */
.presales-tree { max-height: 360px; overflow-y: auto; }

/* Spia di ritardo (richieste Pre-Sales in attesa oltre soglia). Testo sempre accanto: il colore non è l'unica informazione. */
.edh-alert-dot, .edh-warn-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; position: relative; vertical-align: middle; margin-right: .25rem; }
.edh-alert-dot { background: var(--bs-danger); }
.edh-alert-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--bs-danger); animation: edh-pulse 1.4s ease-out infinite; }
.edh-warn-dot { background: var(--bs-warning); }
@keyframes edh-pulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .edh-alert-dot::after { animation: none; } }

/* ===== Home: To Do List scaduti e widget commerciali (brief widget, 31/10/2026) ===== */
:root { --chart-1: #4b56e0; --chart-2: #18a999; --chart-3: #f0a43a; --chart-4: #9aa0c7; --chart-5: #d6457a; --chart-6: #6b6d85; --chart-grid: rgba(14, 11, 82, .08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-1: #8990f0; --chart-2: #3cc9b8; --chart-3: #f4b860; --chart-4: #7d80b3; --chart-5: #ec6f9c; --chart-6: #c3c5e6; --chart-grid: rgba(231, 232, 247, .10); } }
:root[data-theme="dark"] { --chart-1: #8990f0; --chart-2: #3cc9b8; --chart-3: #f4b860; --chart-4: #7d80b3; --chart-5: #ec6f9c; --chart-6: #c3c5e6; --chart-grid: rgba(231, 232, 247, .10); }

.todo-timeline-dot.todo-alert-dot { border-color: var(--bs-danger); background: var(--bs-danger); }
.todo-timeline-dot.todo-alert-dot::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; background: var(--bs-danger); animation: edh-pulse 1.4s ease-out infinite; }
.todo-timeline-dot.todo-warn-dot { border-color: var(--bs-warning); background: var(--bs-warning); }
.todo-section-head { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem 1rem 0; }
.todo-section-head.todo-section-alert { color: var(--bs-danger); }
.edh-badge-pulse { position: relative; }
.edh-badge-pulse::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(var(--bs-danger-rgb), .6); animation: edh-badge-pulse 1.6s ease-out infinite; }
@keyframes edh-badge-pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--bs-danger-rgb), .55); } 100% { box-shadow: 0 0 0 8px rgba(var(--bs-danger-rgb), 0); } }
@media (prefers-reduced-motion: reduce) { .todo-timeline-dot.todo-alert-dot::after, .edh-badge-pulse::after { animation: none; } }
.edh-widget-menu { max-height: 70vh; overflow-y: auto; }

.edh-stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; background: var(--surface); overflow: hidden; }
/* linee tra i riquadri disegnate dai riquadri stessi: se l'ultima riga non è piena, lo spazio vuoto resta bianco (non grigio) */
.edh-stat-tiles > .edh-stat-tile { box-shadow: 0 0 0 1px var(--border); }
.edh-stat-tiles:empty { display: none; }
.edh-stat-tile { background: var(--surface); padding: .75rem 1rem; display: block; color: inherit; text-decoration: none; }
a.edh-stat-tile:hover { background: var(--surface-2); }
.edh-stat-tile .lbl { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.edh-stat-tile .val { font-size: 1.35rem; font-weight: 600; color: var(--heading); line-height: 1.25; font-variant-numeric: tabular-nums; }
.edh-stat-tile .sub { font-size: .75rem; color: var(--muted); }
.edh-stat-tile .delta-up { color: var(--bs-success); }
.edh-stat-tile .delta-down { color: var(--bs-danger); }
.edh-stat-tile.is-alert .val { color: var(--bs-danger); }
.edh-stat-chart { position: relative; height: 240px; padding: .75rem 1rem; }
.edh-stat-chart.is-tall { height: 380px; }
.edh-stat-skeleton { display: grid; gap: .5rem; padding: 1rem; }
.edh-stat-skeleton span { display: block; height: 14px; border-radius: 6px; background: var(--border); animation: edh-skel 1.2s ease-in-out infinite alternate; }
.edh-stat-skeleton span:nth-child(2) { width: 80%; } .edh-stat-skeleton span:nth-child(3) { width: 55%; }
@keyframes edh-skel { from { opacity: .45; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .edh-stat-skeleton span { animation: none; } }

/* ===== Home: griglia a righe allineate e finestre ben distinte (richiesta 31/10/2026) ===== */
.edh-dash-grid { display: grid; grid-template-columns: repeat(var(--edh-dash-cols, 2), minmax(0, 1fr)); gap: 1rem; align-items: stretch; }
/* Colonne secondo lo spazio davvero disponibile (non la larghezza dello schermo): ogni finestra resta larga almeno
   ~330 px. Con meno colonne di quelle scelte le finestre scorrono in ordine di lettura e i "buchi" spariscono. */
.edh-dash { container: edhdash / inline-size; }
@container edhdash (max-width: 1379.98px) { .edh-dash-grid[data-cols="4"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } .edh-dash-grid[data-cols="4"] .edh-dash-filler { display: none; } }
@container edhdash (max-width: 1039.98px) { .edh-dash-grid[data-cols="3"], .edh-dash-grid[data-cols="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } .edh-dash-grid[data-cols="3"] .edh-dash-filler { display: none; } }
@container edhdash (max-width: 699.98px) { .edh-dash-grid, .edh-dash-grid[data-cols] { grid-template-columns: minmax(0, 1fr); } .edh-dash-filler, .edh-dash-empty { display: none; } }
@media (max-width: 767.98px) { .edh-dash-grid, .edh-dash-grid[data-cols] { grid-template-columns: minmax(0, 1fr); } .edh-dash-filler { display: none; } }
.edh-dash-card { display: flex; flex-direction: column; min-width: 0; margin: 0; background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.edh-dash-card > .card-header { background: var(--primary-soft); border-bottom: 1px solid var(--border-strong);
    border-left: 4px solid var(--primary); padding: .6rem .9rem; color: var(--heading); }
.edh-dash-card .edh-dash-title { font-weight: 600; }
.edh-dash-card .edh-dash-subtitle { color: var(--muted); }
.edh-dash-body { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.edh-dash-body > :last-child.border-top { margin-top: auto; }
.edh-dash-body > .table-responsive, .edh-dash-body > div:not(.border-top):not(.edh-stat) { flex: 0 0 auto; }
.edh-dash-body > .edh-stat { flex: 1 1 auto; display: flex; flex-direction: column; }
.edh-dash-body .edh-stat-chart { flex: 1 1 auto; height: auto; min-height: 220px; }
.edh-dash-body .edh-stat-chart > canvas { position: absolute; inset: .75rem 1rem; }

/* ===== Numeri nel menu laterale (MenuBadges) ===== */
.app-sidebar .module-link { position: relative; }
.app-sidebar .menu-badge { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px;
    background: #6d76ec; color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; flex: 0 0 auto; }
.app-sidebar .menu-badge.is-alert { background: var(--bs-danger, #dc3545); }
.app-sidebar .module-link.active .menu-badge { background: #fff; color: var(--primary); }
.app-sidebar .module-link.active .menu-badge.is-alert { background: #fff; color: var(--bs-danger, #dc3545); }
.app-body.is-collapsed .app-sidebar .menu-badge { position: absolute; top: 2px; left: 30px; margin: 0; min-width: 16px; height: 15px; line-height: 15px; font-size: .6rem; padding: 0 4px;
    box-shadow: 0 0 0 2px var(--navy); }
@media (max-width: 991.98px) { .app-body.is-collapsed .app-sidebar .menu-badge { position: static; margin-left: auto; box-shadow: none; } }

/* ===== Assistente AI (barra in alto + pannello laterale, migrazione 062) ===== */
.app-topbar .ai-launch { color: var(--primary); border: 1px solid var(--border-strong); background: var(--primary-soft); font-weight: 600; white-space: nowrap; }
.app-topbar .ai-launch:hover { background: var(--primary); color: #fff; }
.ai-panel { --bs-offcanvas-width: 440px; background: var(--surface); color: var(--fg); }
.ai-panel .offcanvas-header { border-bottom: 1px solid var(--border); }
.ai-messages { overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--bg); }
.ai-welcome { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; }
.ai-msg { max-width: 92%; padding: .55rem .8rem; border-radius: 12px; font-size: .9rem; line-height: 1.45; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 .4rem; } .ai-msg p:last-child { margin-bottom: 0; }
.ai-msg ul, .ai-msg ol { margin: 0 0 .4rem; padding-left: 1.2rem; }
.ai-user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ai-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-error { border-color: var(--bs-danger); color: var(--bs-danger); }
.ai-code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .5rem; font-size: .8rem; white-space: pre-wrap; margin: .3rem 0; }
.ai-composer { background: var(--surface); }
.ai-composer textarea { resize: none; }
.ai-history { max-height: 50vh; overflow-y: auto; max-width: 320px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: ai-blink 1.2s infinite ease-in-out; }
.ai-dots span:nth-child(2) { animation-delay: .2s; } .ai-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-dots span { animation: none; } }
.ai-panel { box-shadow: -8px 0 24px rgba(14, 11, 82, .15); }

/* =====================================================================================
   NUOVA GRAFICA (31/10/2026, allineata a EDASSIST): font Sora + Inter serviti in locale,
   menu laterale blu notte a tutta altezza con il marchio, barra in alto chiara nella colonna
   dei contenuti, intestazioni di pagina con icona, tabelle in card, badge "morbidi", KPI.
   Le regole qui sotto vengono dopo quelle storiche e le sostituiscono dove serve.
   ===================================================================================== */
@font-face { font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: Inter; font-style: italic; font-weight: 100 900; font-display: swap; src: url("../fonts/inter-latin-wght-italic.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Sora; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/sora-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Sora; font-style: normal; font-weight: 100 800; font-display: swap; src: url("../fonts/sora-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
    --sidebar-w: 252px;
    --sidebar-w-collapsed: 68px;
    --ok: #0b8a4a; --ok-soft: #e6f5ec;
    --warn: #b26a00; --warn-soft: #fff4e0;
    --danger: #c62834; --danger-soft: #fdecee;
    --accent-soft: #eef0fd;
    --neutral-soft: #eef0f5; --neutral: #5d6079;
    --font-heading: Sora, Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ok: #4fd18b; --ok-soft: rgba(79, 209, 139, .14); --warn: #f4b860; --warn-soft: rgba(244, 184, 96, .14);
        --danger: #ff8a93; --danger-soft: rgba(255, 138, 147, .14); --accent-soft: rgba(109, 118, 236, .18);
        --neutral-soft: rgba(162, 164, 214, .14); --neutral: #c3c5e6;
    }
}
:root[data-theme="dark"] {
    --ok: #4fd18b; --ok-soft: rgba(79, 209, 139, .14); --warn: #f4b860; --warn-soft: rgba(244, 184, 96, .14);
    --danger: #ff8a93; --danger-soft: rgba(255, 138, 147, .14); --accent-soft: rgba(109, 118, 236, .18);
    --neutral-soft: rgba(162, 164, 214, .14); --neutral: #c3c5e6;
}

body { font-size: 14px; background: var(--bg); }
h1, h2, h3, h4, h5, h6, legend, .h1, .h2, .h3, .h4, .h5, .h6 { font-family: var(--font-heading); color: var(--heading); letter-spacing: -.01em; }
h1.h4, .page-head h1 { font-size: 1.375rem; font-weight: 700; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn, .nav-link, .dropdown-item, .list-group-item-action, .card-link, .page-link, .kpi-card, .ticket-card, .module-link, .nav-item, .file-chip { text-decoration: none !important; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover);
    --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); box-shadow: 0 1px 2px rgba(14, 11, 82, .12); font-weight: 600; }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--primary-soft); --bs-btn-hover-color: var(--primary);
    --bs-btn-hover-border-color: var(--primary); --bs-btn-active-bg: var(--primary); --bs-btn-active-border-color: var(--primary); font-weight: 500; }
.btn-outline-secondary { --bs-btn-color: var(--fg); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--primary); --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-soft); --bs-btn-active-color: var(--primary); --bs-btn-active-border-color: var(--primary); background: var(--surface); }
.card { border-color: var(--border); box-shadow: var(--shadow); border-radius: var(--radius); }
.card > .card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-family: var(--font-heading); font-weight: 600; color: var(--heading); padding: .8rem 1rem; }
.card > .card-footer { background: var(--surface-2); border-top: 1px solid var(--border); }
.card-accent { border-top: 3px solid var(--primary); }
.border-dashed { border-style: dashed !important; box-shadow: none; }
.breadcrumb { font-size: .8125rem; --bs-breadcrumb-divider-color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.form-label { font-weight: 500; color: var(--fg); }
.form-control, .form-select { border-color: var(--border-strong); }
.alert { border-radius: var(--radius-sm); }

/* --- Struttura: menu a tutta altezza + colonna con barra e contenuto --- */
.app-body { display: flex; min-height: 100vh; }
.app-column { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-main { flex: 1 1 auto; padding: 1.25rem clamp(1rem, 2.2vw, 2rem) 2rem; }
.app-topbar { position: sticky; top: 0; height: 60px; padding: 0 clamp(.75rem, 2vw, 1.5rem); z-index: 1020; }
.app-topbar .search .form-control { border-radius: 999px; background: var(--surface-2); padding-left: 1rem; }
.app-sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); padding: 0; border-right: 0; display: flex; flex-direction: column; }
.sidebar-brand { display: flex; align-items: center; gap: .5rem; padding: 14px 14px 12px; border-bottom: 1px solid rgba(255, 255, 255, .08); min-height: 60px; }
.sidebar-brand-link { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none !important; min-width: 0; flex: 1 1 auto; }
.sidebar-mark { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #6d76ec 0%, #4b56e0 55%, #2a2f9e 100%); color: #fff; font-family: var(--font-heading); font-weight: 800; font-size: 15px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .22), 0 4px 12px rgba(0, 0, 0, .35); }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand-text strong { font-family: var(--font-heading); font-size: 16px; letter-spacing: .06em; }
.sidebar-brand-text small { font-size: 11px; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logo-full { max-height: 36px; max-width: 180px; width: auto; }
.sidebar-logo-small { display: none; font-family: var(--font-heading); font-weight: 800; }
.sidebar-logo-small img { max-height: 32px; max-width: 40px; }
.sidebar-scroll { padding: .5rem .6rem 1rem !important; overflow-y: auto; flex: 1 1 auto; }
.app-sidebar .area-label { font-size: 10.5px; letter-spacing: .1em; color: #8e90c9; padding: 1rem .6rem .35rem; font-weight: 600; }
.app-sidebar .module-link { padding: .45rem .65rem; font-size: 14px; font-weight: 500; color: #e4e5fb; margin-bottom: 1px; }
.app-sidebar .module-link .bi { width: 18px; text-align: center; opacity: .85; font-size: 15px; }
.app-sidebar .module-link.active .bi { opacity: 1; }
.app-body.is-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
.app-body.is-collapsed .sidebar-brand-text, .app-body.is-collapsed .sidebar-logo-full { display: none; }
.app-body.is-collapsed .sidebar-logo-small { display: inline-flex; color: #fff; }
.app-body.is-collapsed .sidebar-brand { justify-content: center; padding-left: 8px; padding-right: 8px; }
.app-body.is-collapsed .app-sidebar .module-link { justify-content: center; }
@media (min-width: 992px) {
    .app-sidebar.offcanvas-lg { position: sticky; top: 0; height: 100vh; background: var(--sidebar-bg); }
    .app-sidebar.offcanvas-lg .offcanvas-body { display: block; overflow-y: auto; }
}
@media (max-width: 991.98px) {
    .app-sidebar { inset: 0 0 0 auto; width: 84%; max-width: 310px; background: var(--sidebar-bg); }
    .app-topbar { height: 56px; }
    .app-topbar .brand { font-family: var(--font-heading); }
}

/* --- Intestazione di pagina --- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head-left { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.page-head-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.page-sub { margin: .2rem 0 0; color: var(--muted); }
.page-icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary-soft); color: var(--primary); font-size: 20px; box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), .15); }

/* --- Tabelle degli elenchi: dentro una "card" --- */
.app-main .table-responsive > .table, .portal-content .table-responsive > .table {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; box-shadow: var(--shadow); }
.app-main .table-responsive { border-radius: var(--radius); }
/* Gli elementi "visually-hidden" (position:absolute) nelle celle restano dentro la tabella che scorre: senza questo allargavano la pagina sul telefono */
.table-responsive { position: relative; }
.table > thead > tr:first-child > th { background: var(--surface-2); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; border-bottom-color: var(--border); white-space: nowrap; }
.table > thead a { color: var(--muted); }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding: .45rem .6rem; }
.app-main .table-responsive > .table > tbody > tr:hover > td { background: var(--surface-2); }
.card .table { margin-bottom: 0; }
.filters-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* --- Badge "morbidi", SLA, KPI --- */
.soft-badge { display: inline-flex; align-items: center; gap: .2rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.soft-accent { background: var(--accent-soft); color: var(--primary); }
.soft-ok { background: var(--ok-soft); color: var(--ok); }
.soft-warn { background: var(--warn-soft); color: var(--warn); }
.soft-danger { background: var(--danger-soft); color: var(--danger); }
.soft-neutral { background: var(--neutral-soft); color: var(--neutral); }
a.soft-badge:hover { filter: brightness(.96); }
.sla-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.sla-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sla-ok { color: var(--ok); } .sla-warn { color: var(--warn); } .sla-danger { color: var(--danger); } .sla-none { color: var(--muted); }
.sla-none::before { display: none; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; }
.kpi-card { display: flex; flex-direction: column; gap: .15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); color: var(--fg); transition: border-color .15s, transform .15s; }
a.kpi-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.kpi-card .kpi-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi-card .kpi-value { font-family: var(--font-heading); font-size: 1.6rem; font-weight: 700; color: var(--heading); line-height: 1.2; }
.kpi-card .kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-card.kpi-warn { border-color: #f4c46b; } .kpi-card.kpi-danger { border-color: #f1a5ab; } .kpi-card.kpi-ok { border-color: rgba(11, 138, 74, .35); }
.kpi-card.kpi-danger .kpi-value { color: var(--danger); } .kpi-card.kpi-warn .kpi-value { color: var(--warn); }
.kpi-card.kpi-wide { grid-column: span 2; }
@media (max-width: 575.98px) { .kpi-card.kpi-wide { grid-column: span 1; } }
.quick-filters .nav-link { border-radius: 999px; padding: .3rem .85rem; color: var(--fg); font-weight: 500; font-size: .875rem; }
.quick-filters .nav-link:not(.active):hover { background: var(--primary-soft); color: var(--primary); }
.settings-tabs .nav-link { border-radius: 999px; padding: .35rem .9rem; color: var(--fg); font-size: .875rem; }
.settings-tabs .nav-link:not(.active):hover { background: var(--primary-soft); color: var(--primary); }
.meter { font-size: .8rem; }
.meter-top { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); margin-bottom: .25rem; }
.meter-bar { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.meter.lvl-warn .meter-bar i { background: #e69b13; } .meter.lvl-danger .meter-bar i { background: var(--danger); }
.meter-sm .meter-bar { height: 5px; }
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty-state .bi { font-size: 2rem; color: var(--border-strong); display: block; margin-bottom: .5rem; }
.card-link { color: var(--fg); transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.details-list dt { color: var(--muted); font-weight: 500; }
.details-list dd { margin-bottom: .45rem; }

/* --- Ticket: conversazione, file, chat, storico --- */
.ticket-tabs { border-bottom-color: var(--border); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.ticket-tabs .nav-item { flex: 0 0 auto; }
.ticket-tabs .nav-link { color: var(--muted); font-weight: 500; border: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding-left: .8rem; padding-right: .8rem; }
.ticket-tabs .nav-link.active { color: var(--primary); background: transparent; border-bottom-color: var(--primary); }
.msg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .75rem; box-shadow: var(--shadow-sm); }
.msg-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .875rem; }
.msg-date { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; background: var(--neutral-soft); color: var(--neutral); }
.msg-staff { border-left: 3px solid var(--primary); }
.msg-staff .msg-avatar { background: var(--primary); color: #fff; }
.msg-customer .msg-avatar { background: var(--accent-soft); color: var(--primary); }
.msg-internal { background: var(--warn-soft); border-color: #f4c46b; border-left: 3px solid #e69b13; }
.msg-system { background: var(--surface-2); border-style: dashed; }
.msg-body { overflow-wrap: anywhere; }
.msg-body > :last-child, .rich-text > :last-child { margin-bottom: 0; }
.rich-text blockquote { border-left: 3px solid var(--border-strong); padding-left: .75rem; color: var(--muted); }
.rich-text img { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.msg-files { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.file-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; background: var(--surface-2); color: var(--fg); max-width: 100%; }
.file-chip:hover { border-color: var(--primary); color: var(--primary); }
.chat-list { max-height: 360px; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .5rem; background: var(--surface-2); }
.chat-msg { max-width: 85%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .45rem .7rem; align-self: flex-start; }
.chat-msg.is-mine { align-self: flex-end; background: var(--primary-soft); border-color: rgba(var(--primary-rgb), .25); }
.chat-msg.is-system { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: .8rem; text-align: center; }
.chat-head { font-size: .72rem; color: var(--muted); margin-bottom: .1rem; }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .875rem; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 .5rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; display: flex; gap: .75rem; padding: 0 0 .9rem .9rem; }
.timeline-dot { position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.private-note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .65rem; margin-bottom: .5rem; font-size: .875rem; }
.checklist .check-btn { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.stars { color: #f4b400; letter-spacing: 1px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 35%) 1fr 64px; align-items: center; gap: .5rem; font-size: .82rem; margin-bottom: .35rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--neutral-soft); border-radius: 999px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: linear-gradient(90deg, #6d76ec, var(--primary)); border-radius: 999px; }
.hbar-val { text-align: right; font-weight: 600; }
.check-list { max-height: 340px; overflow-y: auto; columns: 2 260px; column-gap: 1.5rem; }
.check-group { break-inside: avoid; margin-bottom: .75rem; }
.check-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: .2rem; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .35rem; }
.recovery-codes span { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .15rem .5rem; text-align: center; }
.qr-box svg { width: 168px; height: 168px; background: #fff; border-radius: 8px; padding: 4px; }
.howto-body { font-size: 15px; line-height: 1.6; }

/* --- Editor immagini degli how-to --- */
.image-editor { position: fixed; inset: 0; z-index: 2000; background: rgba(7, 5, 49, .72); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.image-editor[hidden] { display: none; }
.image-editor-panel { background: var(--surface); border-radius: var(--radius); max-width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.image-editor-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
.image-editor-canvas { overflow: auto; padding: .75rem; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 20px 20px; }
.image-editor-canvas canvas { max-width: 100%; height: auto; cursor: crosshair; touch-action: none; display: block; margin: 0 auto; box-shadow: var(--shadow); }

/* --- Visualizzatore documenti con filigrana --- */
.viewer-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.viewer-stage { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; max-height: 78vh; overflow: auto; user-select: none; -webkit-user-select: none; }
.viewer-page { display: block; margin: 0 auto 12px; box-shadow: var(--shadow); background: #fff; }
.viewer-text { background: #fff; color: #1c1d33; padding: 1rem; border-radius: 6px; white-space: pre-wrap; background-repeat: repeat; }

/* --- Customer Portal --- */
.portal-shell { display: flex; min-height: 100vh; }
.portal-sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--sidebar-bg); color: #d9daf5; }
.portal-brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; color: #fff; text-decoration: none !important; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.portal-brand strong { display: block; font-family: var(--font-heading); font-size: 15px; letter-spacing: .02em; }
.portal-brand small { display: block; font-size: 11px; color: #a9abd9; }
.portal-brand-mark { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: #fff; color: var(--primary);
    font-size: 20px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255, 255, 255, .22), 0 4px 12px rgba(0, 0, 0, .35); }
.portal-brand-mark img { max-width: 34px; max-height: 34px; }
.portal-nav { padding: 10px; flex: 1 1 auto; overflow-y: auto; }
.portal-nav .nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #8e90c9; margin: 14px 8px 6px; font-weight: 600; }
.portal-nav .nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #e4e5fb; font-weight: 500; }
.portal-nav .nav-item:hover { background: rgba(255, 255, 255, .07); }
.portal-nav .nav-item.is-active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(75, 86, 224, .45); }
.portal-nav .nav-item .bi { width: 18px; text-align: center; }
.nav-badge { margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: #f4b400; color: #1c1d33; font-size: .7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.portal-help { margin: 0 12px 16px; padding: 12px; background: rgba(255, 255, 255, .06); border-radius: 10px; font-size: 12.5px; color: #c9cbf0; }
.portal-help a { color: #fff; }
.portal-help-title { font-weight: 600; color: #fff; margin-bottom: 6px; }
.portal-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.portal-topbar { position: sticky; top: 0; z-index: 1020; height: 60px; display: flex; align-items: center; gap: .75rem; padding: 0 clamp(.75rem, 2vw, 1.75rem);
    background: var(--topbar-bg); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
.portal-topbar .topbar-icon-badge { position: absolute; top: -4px; right: -6px; min-width: 18px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff;
    font-size: .625rem; line-height: 16px; font-weight: 700; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.portal-bell { color: var(--muted); font-size: 1.1rem; }
.portal-user { display: inline-flex; align-items: center; gap: .5rem; color: var(--fg); text-decoration: none !important; }
.tenant-pill { background: var(--accent-soft); color: var(--primary); padding: 3px 12px; border-radius: 999px; font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.portal-content { padding: 1.25rem clamp(1rem, 2.4vw, 2.25rem) 2rem; flex: 1 1 auto; }
.portal-footer { padding: .9rem clamp(1rem, 2.4vw, 2.25rem); color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }
@media (min-width: 768px) {
    .portal-sidebar.offcanvas-md { position: sticky; top: 0; height: 100vh; display: flex !important; visibility: visible !important; transform: none; transition: none; z-index: auto; }
    .portal-sidebar.offcanvas-md .offcanvas-body { display: flex; }
}
@media (max-width: 767.98px) {
    .portal-sidebar.offcanvas-md { position: fixed; top: 0; bottom: 0; left: 0; width: 84%; max-width: 300px; z-index: 1045; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease; }
    .portal-sidebar.offcanvas-md.show, .portal-sidebar.offcanvas-md.showing { transform: none; visibility: visible; }
    .portal-topbar { height: 56px; }
}
.ticket-cards { display: flex; flex-direction: column; gap: .5rem; }
.ticket-card { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); transition: border-color .15s, box-shadow .15s; }
.ticket-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.ticket-card.is-waiting { border-left: 3px solid #e69b13; }
.ticket-card-main { min-width: 0; }
.ticket-card-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ticket-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; flex: 0 0 auto; }
@media (max-width: 575.98px) { .ticket-card { flex-direction: column; align-items: flex-start; } .ticket-card-side { flex-direction: row; align-items: center; } }
.faq-suggest { margin-top: .5rem; padding: .6rem .8rem; border: 1px solid rgba(var(--primary-rgb), .25); background: var(--primary-soft); border-radius: var(--radius-sm); }
.faq-accordion .accordion-button { font-weight: 600; }
.faq-accordion .accordion-button:not(.collapsed) { background: var(--primary-soft); color: var(--heading); }
.star-rating { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: .15rem; }
.star-rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-rating label { font-size: 2rem; line-height: 1; color: var(--border-strong); cursor: pointer; transition: color .1s; }
.star-rating input:checked ~ label, .star-rating label:hover, .star-rating label:hover ~ label { color: #f4b400; }
.star-rating input:focus-visible + label { outline: 2px solid var(--primary); border-radius: 4px; }
.portal-auth-body { background: radial-gradient(1200px 600px at 10% -10%, #2a2f9e 0%, transparent 60%), linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%); min-height: 100vh; }
.portal-auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; }
.portal-auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 1.75rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.portal-auth-card.is-wide { max-width: 1000px; }
.portal-auth-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.portal-auth-brand strong { display: block; font-family: var(--font-heading); font-size: 1.1rem; color: var(--heading); }
.portal-auth-brand small { display: block; color: var(--muted); }
.portal-auth-brand .portal-brand-mark { background: var(--primary-soft); box-shadow: none; }
.portal-auth-foot { color: #a9abd9; font-size: 12px; margin-top: 1rem; }

/* Avvisi chiari leggibili anche nel tema scuro */
.alert-light { background: var(--accent-soft); border-color: var(--border) !important; color: inherit; }

/* ==== SURVEY ==== (questionari al cliente: domande, template, pagina pubblica) */
.survey-section { margin-bottom: 1.25rem; border: 0; padding: 0; }
.survey-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: .75rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); width: 100%; }
.survey-q { margin-bottom: 1rem; }
.survey-q.is-added { border-left: 3px solid var(--warn, #e69b13); padding-left: .75rem; }
.survey-q.has-error .form-label { color: var(--danger); }
.survey-meta { font-size: .75rem; color: var(--muted); margin: -.6rem 0 1rem; }
.survey-meta:empty { display: none; }
.survey-need, .survey-intro { white-space: pre-line; }
.survey-narrow { max-width: 220px; }
.survey-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .25rem 1rem; }
.survey-round { color: var(--muted); border-top: 1px dashed var(--border); padding-top: .75rem; }
.survey-tpl-row { border: 1px solid var(--border); border-radius: .5rem; padding: .75rem; margin-bottom: .5rem; background: var(--neutral-soft); }
.survey-public { text-align: left; }

/* Modalità DEMO: striscia di avviso in cima al contenuto */
.demo-strip { background: var(--warn-soft, #fff4e0); color: var(--warn, #9a5b00); border: 1px solid currentColor; border-radius: .6rem; padding: .45rem .8rem; font-size: .85rem; margin-bottom: 1rem; }
.demo-strip a { color: inherit; text-decoration: underline; }

/* Relazioni (colonna destra delle schede): numero in un pallino, verde quando ci sono record collegati */
.rel-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .45rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1; background: var(--neutral-soft, #eef0f6); color: var(--muted, #8a8ca5); }
.rel-count.has-items { background: #1e9e5a; color: #fff; box-shadow: 0 0 0 3px rgba(30, 158, 90, .15); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rel-count.has-items { background: #2fbf73; color: #06210f; } }
:root[data-theme="dark"] .rel-count.has-items { background: #2fbf73; color: #06210f; }

/* Barra in alto: icone più distanziate, così i numeri non si sovrappongono all'icona accanto */
.app-topbar .topbar-icons { gap: .7rem; }
.app-topbar .topbar-icons > .btn, .app-topbar .topbar-icons > .dropdown > .btn { padding-left: .45rem; padding-right: .45rem; }
/* Elenchi Conversazioni / Note: righe con novità in evidenza */
.list-group-item.is-unread { background: var(--accent-soft); }

/* Richiesta di offerta: Aree a scelta multipla */
.qr-scopes .btn-check:not(:checked) + .btn .qr-check { display: none; }

/* Formazione: riquadri della dashboard */
.tr-kpi { color: inherit; transition: border-color .15s; }
.tr-kpi:hover { border-color: var(--bs-primary); }
.tr-kpi-ok { color: var(--bs-success); }
.tr-kpi-warn { color: var(--bs-warning-text-emphasis); }
.tr-kpi-danger { color: var(--bs-danger); }
.tr-kpi-accent { color: var(--bs-primary); }

/* Report: tabella "live" e costruttore */
.report-table .rv-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; font-weight: 600; text-align: inherit; white-space: nowrap; }
.report-table .rv-filters th { padding-top: 0; font-weight: normal; }
.report-table .rv-filters input { min-width: 90px; }
[data-report-view].rv-loading tbody { opacity: .5; }
.rb-list .rb-item { display: flex; gap: .5rem; align-items: center; padding: .35rem .5rem; border: 1px solid var(--bs-border-color); border-radius: .375rem; margin-bottom: .35rem; background: var(--bs-body-bg); }
.rb-list .rb-item .rb-grow { flex: 1 1 auto; min-width: 0; }
.rb-fields { max-height: 360px; overflow: auto; }
.rb-fields .rb-field { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .2rem .4rem; border-radius: .25rem; font-size: .875rem; }
.rb-fields .rb-field:hover { background: var(--bs-tertiary-bg); }
.rb-fields .rb-field.used { color: var(--bs-secondary-color); }
.rb-sticky { position: sticky; top: 76px; }

/* ===== Storico operazioni (timeline del record) ===== */
.hist-timeline { position: relative; padding-left: 0; }
.hist-timeline::before { content: ""; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--bs-border-color); }
.hist-day { position: relative; margin: 1.1rem 0 .6rem 44px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); font-weight: 600; }
.hist-day:first-child { margin-top: 0; }
.hist-item { position: relative; display: flex; gap: .75rem; margin-bottom: .75rem; }
.hist-dot { position: relative; z-index: 1; flex: 0 0 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: .95rem; box-shadow: 0 0 0 4px var(--bs-body-bg); }
.hist-create { background: #1e9e5a; } .hist-change { background: #2f6fde; } .hist-action { background: #6c757d; }
.hist-email { background: #8a4fd8; } .hist-note { background: #d99a06; } .hist-comment { background: #0f9fb0; }
.hist-body { flex: 1 1 auto; min-width: 0; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .6rem; padding: .6rem .8rem; }
.hist-changes th { font-size: .75rem; color: var(--bs-secondary-color); font-weight: 600; background: transparent; }
.hist-changes td { font-size: .875rem; word-break: break-word; background: transparent; }
.hist-old { color: #b42318; text-decoration: line-through; text-decoration-color: rgba(180, 35, 24, .35); }
.hist-new { color: #116b3a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hist-old { color: #ff8a80; } :root:not([data-theme="light"]) .hist-new { color: #6fdc9b; } }
:root[data-theme="dark"] .hist-old { color: #ff8a80; } :root[data-theme="dark"] .hist-new { color: #6fdc9b; }

/* ===== Template Email: legenda dei campi ===== */
.tpl-legend { position: sticky; top: 1rem; }
.tpl-legend-body { max-height: 60vh; overflow-y: auto; }
.tpl-legend-head { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .4rem .3rem; font-weight: 600; font-size: .85rem; color: var(--bs-body-color); }
.tpl-legend-head .bi { display: inline-block; transition: transform .15s; font-size: .75rem; }
.tpl-legend-head[aria-expanded="true"] .bi { transform: rotate(90deg); }
.tpl-token { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: .5rem; text-align: left; background: none; border: 1px solid transparent; border-radius: .4rem; padding: .25rem .45rem; font-size: .82rem; color: var(--bs-body-color); }
.tpl-token:hover, .tpl-token:focus-visible { background: var(--bs-tertiary-bg); border-color: var(--bs-border-color); }
.tpl-token code { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }

/* ===== Progetti: Gantt ===== */
.gantt { border: 1px solid var(--bs-border-color); border-radius: .5rem; overflow-x: auto; font-size: .85rem; }
.gantt-row { display: grid; grid-template-columns: 220px minmax(var(--gantt-min, 520px), 1fr); width: max-content; min-width: 100%; border-top: 1px solid var(--bs-border-color-translucent); }
.gantt-row:first-child { border-top: 0; }
.gantt-label { padding: .35rem .6rem; border-right: 1px solid var(--bs-border-color); min-width: 0; background: var(--bs-body-bg); position: sticky; left: 0; z-index: 2; }
.gantt-meta { font-size: .75rem; color: var(--bs-secondary-color); }
.gantt-track { position: relative; min-height: 42px; }
.gantt-head .gantt-label, .gantt-head .gantt-track { background: var(--bs-tertiary-bg); font-weight: 600; font-size: .75rem; color: var(--bs-secondary-color); min-height: 34px; }
.gantt-col { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--bs-border-color-translucent); padding: .15rem .2rem 0; text-align: center; overflow: hidden; white-space: nowrap; line-height: 1.1; }
.gantt-col b { display: block; font-size: .68rem; text-transform: uppercase; color: var(--bs-body-color); }
.gantt-col.we { background: rgba(127, 127, 127, .08); }
.gantt-group { background: var(--bs-tertiary-bg); }
.gantt-group .gantt-label { background: var(--bs-tertiary-bg); font-weight: 600; }
.gantt-group .gantt-track { min-height: 30px; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #d92d20; opacity: .7; z-index: 1; }
.gantt-bar { position: absolute; top: 9px; height: 24px; border-radius: 6px; overflow: hidden; text-decoration: none; color: #fff; display: flex; align-items: center; z-index: 1; min-width: 6px; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.gantt-bar:hover { filter: brightness(1.08); color: #fff; }
.gantt-progress { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0, 0, 0, .22); }
.gantt-text { position: relative; padding: 0 .4rem; font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-bar.is-todo, .gantt-legend .is-todo { background: #7a8699; }
.gantt-bar.is-work, .gantt-legend .is-work { background: #2f6fde; }
.gantt-bar.is-wait, .gantt-legend .is-wait { background: #d99a06; }
.gantt-bar.is-late, .gantt-legend .is-late { background: #d92d20; }
.gantt-bar.is-done, .gantt-legend .is-done { background: #1e9e5a; }
.gantt-bar.is-cancel { background: #adb5bd; opacity: .6; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 1rem; }
.gantt-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.gantt-legend .gantt-today-key { width: 2px; background: #d92d20; }

/* ===== Nuova offerta guidata ===== */
.qw-head-icon { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; }
.qw-steps { position: relative; margin: .25rem 0 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1rem .6rem; }
.qw-steps ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5rem; position: relative; z-index: 1; }
.qw-step-btn { display: flex; align-items: center; gap: .6rem; width: 100%; background: none; border: 0; padding: .25rem; text-align: left; color: var(--muted); border-radius: var(--radius-sm); }
.qw-step-btn:not(:disabled):hover { background: var(--primary-soft); }
.qw-step-btn:disabled { cursor: default; opacity: .75; }
.qw-step-dot { flex: 0 0 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted); transition: all .2s; }
.qw-step-done { display: none; }
.qw-step-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.qw-step-label { font-weight: 600; font-size: .88rem; color: var(--fg); }
.qw-step-sub { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1em; }
.qw-step.is-active .qw-step-dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 5px rgba(var(--primary-rgb), .15); }
.qw-step.is-active .qw-step-label { color: var(--primary); }
.qw-step.is-done .qw-step-dot { background: #1e9e5a; border-color: #1e9e5a; color: #fff; }
.qw-step.is-done .qw-step-num { display: none; }
.qw-step.is-done .qw-step-done { display: inline; }
.qw-progress { height: 4px; background: var(--border); border-radius: 4px; margin-top: .7rem; overflow: hidden; }
.qw-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #8b5cf6); border-radius: 4px; transition: width .35s ease; }
.qw-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); animation: qwIn .25s ease; }
@keyframes qwIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .qw-panel { animation: none; } .qw-progress span { transition: none; } }
.qw-panel-head { display: flex; gap: .9rem; align-items: flex-start; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.qw-panel-head h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 .15rem; color: var(--heading); }
.qw-panel-head p { margin: 0; color: var(--muted); font-size: .9rem; }
.qw-panel-icon { flex: 0 0 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.qw-panel-body { padding: 1.25rem; }
.qw-search { position: relative; }
.qw-search > .bi { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.qw-search input { padding-left: 2.6rem; border-radius: 999px; }
.qw-account-list { display: grid; gap: .5rem; margin-top: .5rem; }
.qw-account { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; color: var(--fg); transition: border-color .15s, transform .15s; }
button.qw-account:hover { border-color: var(--primary); transform: translateY(-1px); }
.qw-account.is-chosen { background: var(--primary-soft); border-color: rgba(var(--primary-rgb), .35); }
.qw-account-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.qw-avatar { flex: 0 0 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8b5cf6); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.qw-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.qw-pill, .qw-chip { border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; transition: all .15s; }
.qw-pill:hover, .qw-chip:hover { border-color: var(--primary); }
.qw-pill.active, .qw-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.qw-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.qw-mode { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .45rem; border-radius: 999px; vertical-align: 1px; }
.qw-mode-shelf { background: rgba(30, 158, 90, .12); color: #11753f; }
.qw-mode-project { background: rgba(139, 92, 246, .14); color: #6d3fd8; }
.qw-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.qw-product { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.qw-product:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.qw-product.is-in { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12); }
.qw-product-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.qw-code { font-family: var(--bs-font-monospace); font-size: .72rem; color: var(--muted); }
.qw-product h3 { font-size: .95rem; font-weight: 700; margin: 0 0 .15rem; color: var(--heading); }
.qw-product-path { font-size: .75rem; color: var(--muted); margin-bottom: .35rem; }
.qw-product-descr { font-size: .8rem; color: var(--fg); opacity: .85; margin: 0 0 .5rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qw-product-foot { margin-top: auto; display: flex; align-items: center; gap: .4rem; }
.qw-price { font-weight: 700; color: var(--heading); margin-right: auto; }
.qw-price small { font-weight: 500; color: var(--muted); }
.qw-qty { display: inline-flex; align-items: center; gap: .3rem; }
.qw-qty span { min-width: 1.6rem; text-align: center; font-weight: 600; }
.qw-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 2rem 0; }
.qw-empty .bi { font-size: 1.6rem; display: block; margin-bottom: .3rem; }
.qw-ai { border: 1px dashed rgba(139, 92, 246, .5); background: linear-gradient(135deg, rgba(var(--primary-rgb), .06), rgba(139, 92, 246, .08)); border-radius: var(--radius-sm); padding: .75rem .9rem; margin-bottom: 1rem; }
.qw-ai > div > .bi { color: #8b5cf6; font-size: 1.2rem; }
.qw-ai-out { margin-top: .75rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.qw-ai-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .4rem; }
.qw-ai-list li { display: flex; justify-content: space-between; gap: .5rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .6rem; }
.qw-caps { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .75rem; }
.qw-lines th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.qw-lines td { vertical-align: top; }
.qw-line-note { font-size: .78rem; }
.qw-project-note { color: #6d3fd8; margin-bottom: .75rem; }
.qw-totals { display: grid; grid-template-columns: minmax(180px, 220px) 1fr; gap: 1rem 1.5rem; align-items: start; border-top: 1px solid var(--border); padding-top: 1rem; }
.qw-extra { grid-column: 1 / -1; order: 2; background: #fff7e6; border: 1px solid #f4c46b; border-radius: var(--radius-sm); padding: .6rem .75rem; color: #6b4a00; }
.qw-sum { margin: 0; display: grid; gap: .25rem; }
.qw-sum > div { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.qw-sum dt { font-weight: 500; color: var(--muted); }
.qw-sum dd { margin: 0; font-weight: 600; text-align: right; }
.qw-sum .is-total { border-top: 1px solid var(--border); padding-top: .35rem; margin-top: .15rem; font-size: 1.05rem; }
.qw-sum .is-total dt { color: var(--fg); font-weight: 700; }
.qw-sum .is-total dd { color: var(--heading); font-weight: 800; }
.qw-sum .is-margin dd { color: #11753f; }
.qw-sum .is-neg dd { color: #b42318; }
.qw-conds { display: grid; gap: 1rem; }
.qw-cond { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .9rem .8rem; margin: 0; }
.qw-cond legend { float: none; width: auto; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); padding: 0 .35rem; margin: 0; }
.qw-cond-opts { display: grid; gap: .4rem; }
.qw-cond-opt { display: flex; gap: .6rem; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .65rem; cursor: pointer; transition: border-color .15s, background .15s; }
.qw-cond-opt:hover { border-color: var(--border-strong); }
.qw-cond-opt.is-on { border-color: var(--primary); background: var(--primary-soft); }
.qw-cond-opt .form-check-input { margin-top: .2rem; flex: 0 0 auto; }
.qw-cond-none { padding-block: .35rem; }
.qw-cond-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qw-cond-edit { margin-top: .5rem; }
.qw-review { display: grid; gap: .75rem; }
.qw-review-sec { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; }
.qw-review-head { display: flex; justify-content: space-between; align-items: center; }
.qw-review-head h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); margin: 0 0 .35rem; }
.qw-presales-card { border: 1px solid rgba(139, 92, 246, .45); background: rgba(139, 92, 246, .07); border-radius: var(--radius-sm); padding: .85rem 1rem; }
.qw-presales-card > div > .bi { color: #8b5cf6; }
.qw-nav { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: .75rem; margin-top: 1rem; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(14, 11, 82, .06); }
.qw-nav-msg { flex: 1 1 auto; text-align: center; }
.qw-final { display: flex; gap: .5rem; }
.qw-final:not(.d-none) ~ * { display: none; }
.qw-aside { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.qw-aside-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); margin-bottom: .6rem; }
.qw-aside-client { border-bottom: 1px solid var(--border); padding-bottom: .6rem; margin-bottom: .6rem; }
.qw-type { font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.qw-type.is-shelf { background: rgba(30, 158, 90, .12); border-color: transparent; color: #11753f; }
.qw-type.is-project { background: rgba(139, 92, 246, .14); border-color: transparent; color: #6d3fd8; }
.qw-cart { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .3rem; max-height: 280px; overflow-y: auto; }
.qw-cart li { display: flex; align-items: center; gap: .5rem; font-size: .86rem; }
.qw-cart-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qw-cart-qty { color: var(--muted); font-size: .8rem; }
.qw-sum-aside { border-top: 1px solid var(--border); padding-top: .6rem; }
.qw-type-help { margin-top: .75rem; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .65rem; }
@media (max-width: 991.98px) {
  .qw-steps ol { grid-template-columns: repeat(5, auto); overflow-x: auto; }
  .qw-step-text { display: none; }
  .qw-step.is-active .qw-step-text { display: flex; }
  .qw-totals { grid-template-columns: 1fr; }
}
@media (max-width: 1199.98px) { .qw-aside { position: static; } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .qw-mode-shelf, :root:not([data-theme="light"]) .qw-type.is-shelf { color: #6fdc9b; }
  :root:not([data-theme="light"]) .qw-mode-project, :root:not([data-theme="light"]) .qw-type.is-project, :root:not([data-theme="light"]) .qw-project-note { color: #c4b1ff; }
  :root:not([data-theme="light"]) .qw-extra { background: rgba(244, 196, 107, .12); color: #f4d48b; }
}
:root[data-theme="dark"] .qw-mode-shelf, :root[data-theme="dark"] .qw-type.is-shelf { color: #6fdc9b; }
:root[data-theme="dark"] .qw-mode-project, :root[data-theme="dark"] .qw-type.is-project, :root[data-theme="dark"] .qw-project-note { color: #c4b1ff; }
:root[data-theme="dark"] .qw-extra { background: rgba(244, 196, 107, .12); color: #f4d48b; }

/* ===== Menu laterale: sezioni apribili e ricerca ===== */
.app-sidebar .area-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; background: none; border: 0; text-transform: uppercase; text-align: left; border-radius: 6px; cursor: pointer; }
.app-sidebar .area-toggle:hover { color: #fff; }
.app-sidebar .area-toggle:focus-visible { outline: 2px solid rgba(255, 255, 255, .5); outline-offset: 1px; }
.app-sidebar .area-toggle .bi { font-size: .7rem; transition: transform .2s; opacity: .7; }
.app-sidebar .area-toggle[aria-expanded="false"] .bi { transform: rotate(-90deg); }
.app-sidebar .area-group.is-closed { display: none; }
.app-sidebar.is-filtering .area-group.is-closed { display: block; }
.app-sidebar.is-filtering .area-toggle .bi { visibility: hidden; }
.app-body.is-collapsed .app-sidebar .area-group.is-closed { display: block; }
.sidebar-search { display: flex; align-items: center; gap: .3rem; padding: .6rem .7rem .8rem; border-top: 1px solid rgba(255, 255, 255, .08); flex: 0 0 auto; }
.sidebar-search-field { position: relative; flex: 1 1 auto; min-width: 0; }
.sidebar-search-field .bi { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--sidebar-muted); font-size: .85rem; }
.sidebar-all-btn { flex: 0 0 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06); color: var(--sidebar-fg); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.sidebar-all-btn:hover, .sidebar-all-btn:focus-visible { background: rgba(255, 255, 255, .18); color: #fff; }
.sidebar-search input { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); color: #fff; border-radius: 999px; padding-left: 2rem; }
.sidebar-search input::placeholder { color: var(--sidebar-muted); }
.sidebar-search input:focus { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: none; }
.app-body.is-collapsed .sidebar-search { display: none; }
.sidebar-search-empty { color: var(--sidebar-muted); font-size: .85rem; padding: .5rem .7rem; }

/* ===== Cerca nella barra in alto ===== */
.gsearch { position: relative; flex: 0 1 420px; min-width: 0; }
.gsearch-field { position: relative; display: flex; align-items: center; }
.gsearch-field > .bi { position: absolute; left: .8rem; color: var(--muted); font-size: .85rem; pointer-events: none; z-index: 2; }
.app-topbar .gsearch .form-control { padding-left: 2.1rem; }
.gsearch-chip { position: absolute; left: 2rem; z-index: 2; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font-size: .72rem; font-weight: 600; padding: .1rem .55rem; }
.gsearch-chip::after { content: " ×"; opacity: .8; }
.gsearch-panel { position: absolute; top: calc(100% + .5rem); left: 0; width: min(1000px, calc(100vw - 2rem)); max-height: calc(100vh - 90px); overflow-y: auto; z-index: 1060;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(14, 11, 82, .18); padding: .9rem; }
.gsearch-all { display: block; width: 100%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); border-radius: 999px; padding: .45rem; font-weight: 700; font-size: .88rem; margin-bottom: .8rem; }
.gsearch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem .75rem; }
.gsearch-col { display: flex; flex-direction: column; gap: .35rem; }
.gsearch-area { border: 1px solid rgba(var(--primary-rgb), .35); background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: .3rem .6rem; font-size: .8rem; font-weight: 700; }
.gsearch-mod { display: flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 999px; padding: .3rem .6rem; font-size: .82rem; }
.gsearch-mod .bi { color: var(--muted); }
.gsearch-all:hover, .gsearch-area:hover, .gsearch-mod:hover { border-color: var(--primary); }
.gsearch-all.active, .gsearch-area.active, .gsearch-mod.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.gsearch-mod.active .bi { color: #fff; }
.gsearch-foot { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--border); margin-top: .9rem; padding-top: .6rem; font-size: .78rem; color: var(--muted); }
.gsearch-live { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .8rem; overflow: hidden; }
.gsearch-live-head { display: flex; justify-content: space-between; padding: .4rem .7rem; background: var(--surface-2); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.gsearch-live-head a { text-transform: none; letter-spacing: 0; font-weight: 600; }
.gsearch-hit { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; color: var(--fg); border-top: 1px solid var(--border); }
.gsearch-hit:hover, .gsearch-hit:focus { background: var(--primary-soft); }
.gsearch-hit > .bi { color: var(--primary); }
.gsearch-hit-text { display: flex; flex-direction: column; min-width: 0; }
.gsearch-hit-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-hit-sub { font-size: .75rem; color: var(--muted); }
.gsearch-none { padding: .6rem .7rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.search-group mark { padding: 0 .1em; border-radius: 3px; background: rgba(var(--primary-rgb), .18); color: inherit; }
@media (max-width: 767.98px) { .gsearch-panel { position: fixed; top: 60px; left: .5rem; right: .5rem; width: auto; } }

/* ===== Offerta guidata: riepilogo live delle condizioni ===== */
.qw-cond-summary { border: 1px solid rgba(var(--primary-rgb), .3); background: linear-gradient(var(--primary-soft), var(--primary-soft)), var(--surface); border-radius: var(--radius-sm); padding: .7rem .9rem; margin-bottom: 1rem; position: sticky; top: 68px; z-index: 3; box-shadow: var(--shadow); background-clip: padding-box; }
.qw-cond-summary h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--primary); margin: 0 0 .4rem; }
.qw-cond-summary ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem .9rem; }
.qw-cond-summary li a { display: flex; gap: .4rem; font-size: .84rem; color: var(--fg); padding: .1rem 0; }
.qw-cond-summary li a:hover .qw-cs-val { text-decoration: underline; }
.qw-cs-tipo { color: var(--muted); flex: 0 0 auto; }
.qw-cs-val { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qw-cs-none .qw-cs-val { font-weight: 400; color: var(--muted); font-style: italic; }
.qw-cs-flash { animation: qwFlash .9s ease; }
@keyframes qwFlash { 0% { background: rgba(var(--primary-rgb), .3); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .qw-cs-flash { animation: none; } }

/* ===== Offerta guidata: durata, scheda prodotto e confronto ===== */
.qw-pill-ut { border-style: dashed; }
.qw-durata { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .65rem .85rem; margin-bottom: 1rem; background: var(--surface-2); }
.qw-durata > .bi { font-size: 1.2rem; color: var(--primary); margin-top: .1rem; }
.qw-durata.is-needed { border-color: #f1a5ab; background: rgba(217, 45, 32, .05); }
.qw-durata-ut > .bi { color: #11753f; }
.qw-info-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: .85rem; }
.qw-info-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.qw-feat-mini { list-style: none; padding: 0; margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .25rem; }
.qw-feat-mini li { font-size: .72rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .05rem .5rem; }
.qw-feat-mini span { color: var(--muted); }
.qw-info-h { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--muted); margin-bottom: .5rem; }
.qw-feat { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; margin: 0; }
.qw-feat > div { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .7rem; background: var(--surface-2); }
.qw-feat dt { font-size: .75rem; font-weight: 500; color: var(--muted); }
.qw-feat dd { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--heading); }
.qw-pre { white-space: pre-line; }
.qw-info-facts { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem; background: var(--surface-2); }
.qw-rel { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .5rem; }
.qw-rel-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .55rem .7rem; }
.qw-rel-card.is-on { border-color: var(--primary); background: var(--primary-soft); }
.qw-rel-card.is-in { box-shadow: inset 0 3px 0 #1e9e5a; }
.qw-compare th, .qw-compare td { font-size: .85rem; }
.qw-compare thead th { vertical-align: top; min-width: 150px; }
.qw-compare tbody th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.qw-compare { border-collapse: separate; border-spacing: 0; }
.qw-compare td, .qw-compare th { border-bottom: 1px solid var(--border); }
.qw-compare .is-current { background: rgba(var(--primary-rgb), .09); box-shadow: inset 2px 0 0 var(--primary), inset -2px 0 0 var(--primary); }
.qw-compare thead th.is-current { box-shadow: inset 2px 0 0 var(--primary), inset -2px 0 0 var(--primary), inset 0 3px 0 var(--primary); border-top-left-radius: 8px; border-top-right-radius: 8px; }
.qw-compare tbody tr:last-child td.is-current { box-shadow: inset 2px 0 0 var(--primary), inset -2px 0 0 var(--primary), inset 0 -2px 0 var(--primary); }
.qw-compare .is-in:not(.is-current) { background: rgba(30, 158, 90, .08); }
.qw-compare thead th.is-in:not(.is-current) { box-shadow: inset 0 3px 0 #1e9e5a; }
.qw-compare tr.qw-diff > th, .qw-compare tr.qw-diff > td { background-color: rgba(245, 158, 11, .13); }
.qw-compare tr.qw-diff > td.is-current { background-color: rgba(245, 158, 11, .2); }
.qw-compare tr.qw-diff > th { color: #8a5a00; font-weight: 700; box-shadow: inset 4px 0 0 #f59e0b; }
.qw-compare tr.qw-diff > td { font-weight: 700; color: var(--heading); }
.qw-compare tr.qw-same > td { color: var(--muted); }
.qw-cmp-tags { min-height: 1.4rem; display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .25rem; }
.qw-cmp-tag { font-size: .68rem; font-weight: 700; text-transform: none; letter-spacing: 0; border-radius: 999px; padding: .1rem .5rem; }
.qw-cmp-tag.qw-tag-cur { background: var(--primary); color: #fff; }
.qw-cmp-tag.qw-tag-in { background: #1e9e5a; color: #fff; }
.qw-cmp-legend { display: flex; flex-wrap: wrap; gap: 1rem; color: var(--muted); margin-top: .5rem; }
.qw-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: .35rem; vertical-align: -2px; }
.qw-key-diff { background: rgba(245, 158, 11, .35); box-shadow: inset 3px 0 0 #f59e0b; }
.qw-key-cur { background: rgba(var(--primary-rgb), .15); border: 2px solid var(--primary); }
.qw-key-in { background: rgba(30, 158, 90, .2); border-top: 3px solid #1e9e5a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qw-compare tr.qw-diff > th { color: #f7c66b; } }
:root[data-theme="dark"] .qw-compare tr.qw-diff > th { color: #f7c66b; }

/* Numeri della sezione chiusa sul suo nome */
.app-sidebar .area-badge { display: none; text-transform: none; letter-spacing: 0; }
.app-sidebar .area-toggle[aria-expanded="false"] .area-badge { display: inline-flex; }
.app-sidebar.is-filtering .area-badge { display: none !important; }

.qw-product { position: relative; }
.qw-product.is-in { background: linear-gradient(var(--primary-soft), var(--primary-soft)), var(--surface); border-width: 2px; }
.qw-in-ribbon { align-self: flex-start; font-size: .7rem; font-weight: 700; background: #1e9e5a; color: #fff; border-radius: 999px; padding: .1rem .55rem; margin-bottom: .35rem; }

/* ===================== Marketing: Campagne, Newsletter, Target (078) ===================== */
.mkt-kpi { padding: .85rem 1rem; border-left: 4px solid var(--border-strong); color: inherit; }
.mkt-kpi.is-primary { border-left-color: var(--primary); }
.mkt-kpi.is-success { border-left-color: var(--bs-success); }
.mkt-kpi.is-danger { border-left-color: var(--bs-danger); }
a.mkt-kpi:hover { background: var(--surface-2); }
.mkt-kpi-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkt-kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--bs-body-color); }
.mkt-kpi-rate { font-size: .85rem; font-weight: 600; color: var(--primary); }
.mkt-card { transition: box-shadow .15s ease, transform .15s ease; }
.mkt-card:hover { box-shadow: 0 6px 20px rgba(var(--primary-rgb), .12); transform: translateY(-1px); }
.mkt-chart { position: relative; height: 260px; }
.mkt-chart-sm { height: 240px; }
.mkt-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.mkt-bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.mkt-step { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; margin-right: .5rem; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; }
.mkt-choice { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; height: 100%; }
.mkt-choice:hover { border-color: var(--border-strong); background: var(--surface-2); }
.mkt-choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.mkt-choice > span { min-width: 0; }
.mkt-launch .mkt-scheduled { background: var(--primary-soft); }
.mkt-preview { background: var(--surface-2); }
.mkt-preview > div { background: #fff; padding: 1.25rem; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.06); color: #1b2a33; }
.mkt-sends-table .mkt-clicks-row td { background: var(--surface-2); }
.tpl-unsub { border-color: var(--primary); background: var(--primary-soft); }

/* ===================== Fatture (079) ===================== */
@media (min-width: 1200px) { .inv-summary { position: sticky; top: 80px; } }
.inv-lines textarea { min-height: 34px; resize: vertical; }
.inv-lines td { vertical-align: top; }
.inv-lines td[data-c="tot"] { padding-top: .55rem; }
.inv-doc { border-top: 4px solid var(--primary); }
.inv-lines tbody[data-inv-line] tr:first-child td { border-bottom: 0; padding-top: .6rem; }
.inv-lines tr.inv-sub td { padding-top: 0; padding-bottom: .6rem; }
.inv-lines tbody[data-inv-line] + tbody[data-inv-line] tr:first-child td { border-top: 1px solid var(--border); }
.inv-lines input[data-c], .inv-lines select[data-c] { padding-left: .35rem; padding-right: .35rem; }
.inv-lines select[data-c] { background-position: right .2rem center; padding-right: 1.1rem; }
.inv-fic { background: var(--surface-2); border: 1px solid var(--border); }

/* Colorazione Viste per Lista: blocchetto a sinistra (081) */
tr.lc-stripe > td:first-child { box-shadow: inset 6px 0 0 var(--lc); }

/* Customer Portal: icona nei Contatti (082) */
.portal-ico { font-size: 1rem; margin-left: .35rem; vertical-align: -1px; cursor: help; }
.portal-ico.is-ok { color: #2e9d48; }
.portal-ico.is-warn { color: #e0912c; }
.portal-ico.is-grey { color: #9aa0ad; }
.portal-ico.is-invited { color: var(--primary); }
.portal-ico.is-off { color: #c62834; opacity: .75; }

/* Niente testo/pulsanti fuori dai riquadri */
.card-body { overflow-wrap: break-word; }
.card, .card-body, .card-body dd, .card-body [class*="col-"] { min-width: 0; }
.soft-badge, .sla-chip { max-width: 100%; }
.card-body dd .soft-badge, .card-body p .soft-badge, .card-body div:not(.d-flex) > .soft-badge { white-space: normal; text-align: left; border-radius: .7rem; }
td .soft-badge, th .soft-badge, .card-header .soft-badge { white-space: nowrap; }
/* .card-body che è anche .row: i margini negativi della griglia non escono dal riquadro */
.card > .card-body.row { margin-left: 0; margin-right: 0; padding-left: calc(1rem - var(--bs-gutter-x, 1.5rem) * .5); padding-right: calc(1rem - var(--bs-gutter-x, 1.5rem) * .5); }

/* Messaggi: intestazione di ogni account di posta ben distinta; con l'account chiuso il numero dei nuovi messaggi */
.messages-acc-head { display: flex; align-items: center; gap: .4rem; margin: .6rem 0 .35rem; padding: .4rem .55rem; border-radius: .6rem;
    background: var(--accent-soft); border: 1px solid transparent; color: var(--primary); cursor: pointer; user-select: none; min-width: 0; }
.messages-acc-head:hover { border-color: var(--primary); }
.messages-acc-head:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.messages-acc-head.is-current { border-color: var(--primary); }
.messages-acc-name { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.messages-acc-mail { font-size: .72rem; color: var(--muted); }
.messages-acc-chevron { display: inline-block; transition: transform .15s ease; flex-shrink: 0; }
.messages-acc-head[aria-pressed="true"] .messages-acc-chevron { transform: rotate(-90deg); }
.messages-acc-ico { display: none; flex-shrink: 0; }
.messages-acc-unread { display: none; flex-shrink: 0; }
.messages-acc-head[aria-pressed="true"] .messages-acc-unread { display: inline-block; }
.messages-acc-tools .btn { padding: .1rem .4rem; line-height: 1.4; flex-shrink: 0; }
/* colonna cartelle compressa a icone: busta dell'account, con il numero dei nuovi messaggi */
.messages-row.folders-collapsed .messages-acc-head { justify-content: center; padding: .4rem .2rem; position: relative; }
.messages-row.folders-collapsed .messages-acc-ico { display: inline-block; }
.messages-row.folders-collapsed .messages-acc-unread { display: inline-block; position: absolute; top: -.35rem; right: -.2rem; font-size: .62rem; }
/* Messaggi: sintesi dei nuovi messaggi per account (al passaggio del mouse o con il tasto Tab) */
.messages-acc-summary { position: relative; display: flex; align-items: center; gap: .4rem; cursor: default; border-radius: .5rem; padding: .1rem .15rem; }
.messages-acc-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.messages-acc-bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.7rem; border-radius: .5rem; background: var(--accent-soft); color: var(--primary); flex-shrink: 0; }
.messages-acc-bell .badge { position: absolute; top: -.45rem; right: -.55rem; font-size: .6rem; padding: .2em .45em; }
.messages-acc-summary-panel { display: none; position: absolute; top: calc(100% + .35rem); left: 0; z-index: 1060; width: 260px; max-width: 80vw; padding: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: .6rem; box-shadow: 0 8px 24px rgba(15, 23, 42, .15); }
.messages-acc-summary:hover .messages-acc-summary-panel, .messages-acc-summary:focus-within .messages-acc-summary-panel { display: block; }
.messages-acc-summary-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 0 .25rem .35rem; }
.messages-acc-summary-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .4rem; border-radius: .45rem; color: var(--fg); text-decoration: none; font-size: .82rem; }
.messages-acc-summary-row:hover { background: var(--accent-soft); color: var(--fg); }
.messages-acc-summary-foot { font-size: .7rem; color: var(--muted); margin: .35rem .25rem 0; }
/* colonna cartelle ridotta a icone: niente "Le mie cartelle"; numeri piccoli nell'angolo, non sopra l'icona */
.messages-row.folders-collapsed .messages-folders-col { flex: 0 0 62px; max-width: 62px; }
.messages-row.folders-collapsed .messages-custom-folders { display: none; }
.messages-row.folders-collapsed .messages-acc-tools { justify-content: center; }
.messages-row.folders-collapsed .messages-acc-summary { flex-grow: 0 !important; }
.messages-row.folders-collapsed .messages-folders-col .list-group-item { position: relative; padding-top: .45rem !important; padding-bottom: .45rem !important; }
.messages-row.folders-collapsed .messages-folders-col .list-group-item .badge { position: absolute; top: 2px; right: 2px; font-size: .58rem; padding: .18em .4em; line-height: 1; }
.messages-row.folders-collapsed .messages-acc-unread { top: -.4rem !important; right: -.3rem !important; font-size: .58rem !important; padding: .2em .42em; line-height: 1; }
.messages-row.folders-collapsed .messages-acc-head { margin-top: .9rem; }
.messages-acc-summary-label { font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
@media (min-width: 992px) and (max-width: 1469.98px) { .messages-acc-summary-label { display: none; } }
.messages-folders-col .list-group-item > .messages-folders-label { min-width: 0; overflow-wrap: anywhere; }
.messages-folders-col .list-group-item .badge { flex-shrink: 0; }
/* Icona che gira (sincronizzazione posta in corso) */
.bi.spin { display: inline-block; animation: edh-spin 1.2s linear infinite; }
@keyframes edh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bi.spin { animation: none; } }
/* Offerta guidata: nuovo referente al volo */
.qw-newcontact { border: 1px solid var(--border); border-radius: .6rem; padding: .75rem; background: var(--accent-soft); }
/* Offerta: sintesi delle Condizioni Commerciali */
.qcond-summary { border: 1px solid var(--border); border-radius: .6rem; padding: .6rem .75rem; background: var(--accent-soft); }
.qcond-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: .6rem; align-items: start; padding: .35rem .25rem; border-top: 1px solid var(--border); color: var(--fg); text-decoration: none; border-radius: .35rem; }
.qcond-row:first-of-type { border-top: 0; }
.qcond-row:hover { background: var(--surface); color: var(--fg); }
.qcond-row.is-dirty { background: var(--warn-soft); }
.qcond-type { font-size: .72rem; font-weight: 700; text-transform: uppercase; color: var(--primary); padding-top: .15rem; overflow-wrap: anywhere; }
.qcond-flags { display: flex; flex-direction: column; gap: .2rem; align-items: flex-end; }
@media (max-width: 575.98px) { .qcond-row { grid-template-columns: 1fr; } .qcond-flags { align-items: flex-start; flex-direction: row; } }
/* Offerta: nuovo prodotto a Catalogo al volo */
.np-panel { border: 1px solid var(--border); border-radius: .6rem; padding: .75rem; background: var(--accent-soft); }
.np-solnew { border: 1px dashed var(--border); border-radius: .5rem; padding: .5rem .6rem; margin: 0; background: var(--surface); }

/* ===================== Chat interna (087) ===================== */
.chat-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; border: 2px solid var(--surface); background: #9aa3b2; flex-shrink: 0; }
.chat-dot.is-online { background: #22a861; }
.chat-dot.is-busy { background: #dc3545; }
.chat-dot.is-away { background: #f0ad1d; }
.chat-dot.is-offline { background: #9aa3b2; }
.chatw { position: fixed; right: 1rem; bottom: 1rem; z-index: 1040; }
.chatw-launcher { position: relative; width: 3.25rem; height: 3.25rem; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 1.35rem; box-shadow: 0 6px 20px rgba(15, 23, 42, .25); display: flex; align-items: center; justify-content: center; }
.chatw-launcher:hover { filter: brightness(1.08); }
.chatw.is-open .chatw-launcher { display: none; }
.chatw-launcher-badge { position: absolute; top: -.2rem; right: -.2rem; min-width: 1.3rem; height: 1.3rem; padding: 0 .3rem; border-radius: 999px; background: #dc3545; color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.3rem; border: 2px solid var(--surface); }
.chatw.has-unread .chatw-launcher { animation: chatw-pulse 2s ease-out infinite; }
@keyframes chatw-pulse { 0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, .45); } 70% { box-shadow: 0 0 0 12px rgba(220, 53, 69, 0); } 100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); } }
@media (prefers-reduced-motion: reduce) { .chatw.has-unread .chatw-launcher { animation: none; } }
.chatw-me-dot { position: absolute; bottom: .1rem; right: .1rem; }
.chatw-panel { width: 370px; height: min(560px, calc(100vh - 2rem)); background: var(--surface); border: 1px solid var(--border); border-radius: .9rem; box-shadow: 0 12px 40px rgba(15, 23, 42, .25); overflow: hidden; display: flex; }
.chatw-panel .chat-app { flex: 1; min-width: 0; display: flex; }
@media (max-width: 575.98px) { .chatw { right: .75rem; bottom: .75rem; } .chatw.is-open { inset: 0; } .chatw-panel { width: 100vw; height: 100dvh; border-radius: 0; } }
.chat-shell { display: flex; flex: 1; min-width: 0; min-height: 0; }
.chat-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.chatw-panel .chat-app:not(.is-room) .chat-main, .chatw-panel .chat-app.is-room .chat-side { display: none; }
.ichat-head, .chat-room-head { display: flex; align-items: center; gap: .4rem; padding: .55rem .65rem; border-bottom: 1px solid var(--border); min-height: 3.1rem; }
.ichat-head-title { flex: 1; font-size: 1rem; color: var(--primary); }
.chat-me { display: inline-flex; align-items: center; gap: .1rem; border: 1px solid var(--border); border-radius: 999px; padding: .15rem .55rem; font-size: .75rem; }
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: .5rem; color: var(--muted); }
.btn-icon:hover { background: var(--accent-soft); color: var(--primary); }
.chat-notify-hint { font-size: .75rem; padding: .4rem .65rem; background: var(--accent-soft); color: var(--fg); }
.chat-tabs { display: flex; gap: .25rem; padding: .45rem .65rem 0; }
.chat-tabs button { flex: 1; border: 0; background: none; padding: .35rem; font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.chat-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.chat-search { position: relative; padding: .5rem .65rem; }
.chat-search i { position: absolute; left: 1.15rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; }
.chat-search input { width: 100%; border: 1px solid var(--border); border-radius: 999px; padding: .3rem .75rem .3rem 1.9rem; font-size: .82rem; background: var(--bg, transparent); color: var(--fg); }
.ichat-list { flex: 1; overflow-y: auto; min-height: 0; }
.ichat-list-empty { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem .75rem; }
.chat-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .65rem; border: 0; background: none; text-align: left; color: var(--fg); border-bottom: 1px solid var(--border); }
.chat-item:hover, .chat-item.is-active { background: var(--accent-soft); }
.chat-avatar { position: relative; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--accent-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.chat-avatar.is-group { background: var(--primary); color: #fff; }
.chat-avatar .chat-dot { position: absolute; right: -.05rem; bottom: -.05rem; }
.chat-item-text { flex: 1; min-width: 0; }
.chat-item-top, .chat-item-bottom { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.chat-item-name { flex: 1; min-width: 0; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-when { font-size: .7rem; color: var(--muted); flex-shrink: 0; }
.chat-item-preview { flex: 1; min-width: 0; font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.is-unread .chat-item-preview { color: var(--fg); font-weight: 600; }
.chat-unread { background: #22a861; color: #fff; border-radius: 999px; font-size: .68rem; font-weight: 700; padding: .05rem .4rem; flex-shrink: 0; }
.chat-foot { display: flex; justify-content: space-around; border-top: 1px solid var(--border); padding: .4rem; font-size: .78rem; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 2rem; }
.chat-empty i { font-size: 2.5rem; opacity: .4; }
.chat-room-title { flex: 1; min-width: 0; line-height: 1.15; overflow: hidden; }
.chat-room-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ichat-msgs { flex: 1; overflow-y: auto; min-height: 0; padding: .6rem .7rem; background: var(--accent-soft); display: flex; flex-direction: column; gap: .2rem; }
.ichat-msgs.is-drop { outline: 2px dashed var(--primary); outline-offset: -6px; }
.chat-day { text-align: center; margin: .5rem 0 .3rem; }
.chat-day span { background: var(--surface); color: var(--muted); font-size: .7rem; padding: .15rem .6rem; border-radius: 999px; border: 1px solid var(--border); }
.ichat-msg { display: flex; align-items: flex-end; gap: .25rem; max-width: 100%; }
.ichat-msg.is-mine { flex-direction: row-reverse; }
.chat-bubble { max-width: min(80%, 520px); background: var(--surface); border: 1px solid var(--border); border-radius: .8rem .8rem .8rem .2rem; padding: .35rem .55rem .2rem; font-size: .86rem; overflow-wrap: anywhere; min-width: 0; }
.ichat-msg.is-mine .chat-bubble { background: #dcf3e6; border-color: #c3e7d2; border-radius: .8rem .8rem .2rem .8rem; color: #0f2a1c; }
.ichat-msg.is-focus .chat-bubble { outline: 2px solid var(--primary); }
.chat-author { font-size: .72rem; font-weight: 700; color: var(--primary); margin-bottom: .1rem; }
.chat-text a { overflow-wrap: anywhere; }
.chat-meta { font-size: .65rem; color: var(--muted); text-align: right; margin-top: .1rem; white-space: nowrap; }
.ichat-msg.is-mine .chat-meta { color: #4b6b58; }
.chat-tick { margin-left: .2rem; }
.chat-tick.is-read { color: #0d6efd; }
.chat-deleted { font-style: italic; color: var(--muted); }
.chat-del { border: 0; background: none; color: var(--muted); opacity: 0; padding: .1rem .2rem; font-size: .75rem; }
.ichat-msg:hover .chat-del, .chat-del:focus { opacity: 1; }
.chat-img img { display: block; max-width: 100%; max-height: 220px; border-radius: .5rem; margin-bottom: .2rem; }
.chat-file { display: flex; align-items: center; gap: .45rem; padding: .35rem .45rem; border-radius: .5rem; background: rgba(0, 0, 0, .04); color: inherit; text-decoration: none; margin-bottom: .2rem; min-width: 0; max-width: 260px; }
.chat-file i { font-size: 1.3rem; color: var(--primary); }
.chat-file > span { min-width: 0; }
.chat-file small { color: var(--muted); }
.chat-composer { border-top: 1px solid var(--border); padding: .45rem .55rem; background: var(--surface); }
.chat-composer.is-sending { opacity: .6; pointer-events: none; }
.chat-composer-row { display: flex; align-items: flex-end; gap: .35rem; }
.chat-composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--border); border-radius: 1rem; padding: .4rem .75rem; font-size: .88rem; max-height: 140px; background: var(--surface); color: var(--fg); }
.chat-composer textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.chat-send { border-radius: 50%; width: 2.2rem; height: 2.2rem; padding: 0; flex-shrink: 0; }
.chat-file-chip { display: flex; align-items: center; gap: .4rem; font-size: .78rem; background: var(--accent-soft); border-radius: .5rem; padding: .3rem .5rem; margin-bottom: .35rem; min-width: 0; }
.chat-file-chip small { color: var(--muted); flex-shrink: 0; }
/* pagina intera */
.chat-app-page { display: flex; height: calc(100vh - 210px); min-height: 460px; border: 1px solid var(--border); border-radius: .9rem; background: var(--surface); overflow: hidden; }
.chat-app-page .chat-side { flex: 0 0 320px; max-width: 320px; border-right: 1px solid var(--border); }
@media (max-width: 767.98px) {
  .chat-app-page { height: calc(100vh - 170px); }
  .chat-app-page .chat-side { flex: 1; max-width: none; border-right: 0; }
  .chat-app-page:not(.is-room) .chat-main, .chat-app-page.is-room .chat-side { display: none; }
}
@media print { .chatw { display: none !important; } }
@media (min-width: 768px) { .chat-app-page .chat-back { display: none; } }
.chat-bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; }
.chat-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 2px; }
.chat-bar span { display: block; width: 100%; min-height: 1px; background: var(--primary); border-radius: 2px 2px 0 0; opacity: .85; }
.chat-settings-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: .5rem; padding: .4rem .6rem; }
/* Barra in alto su telefono e tablet: le icone non escono dallo schermo (prima la pagina diventava larga quasi il doppio) */
@media (max-width: 1199.98px) {
  .app-topbar .topbar-icons { gap: .1rem; min-width: 0; }
  .app-topbar .topbar-icons > .btn.disabled { display: none; }
  .app-topbar .topbar-icons > .btn, .app-topbar .topbar-icons > .dropdown > .btn { padding-left: .3rem; padding-right: .3rem; }
  .app-topbar .topbar-icons .dropdown-toggle::after { display: none; }
}
@media (max-width: 419.98px) { .app-topbar .topbar-icons .topbar-minor { display: none; } }
/* La fila di icone non allarga mai la pagina: se non c'è posto scorre di lato (i menu a tendina si aprono "fissi", vedi app.js) */
.app-topbar .topbar-icons { flex: 0 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.app-topbar .topbar-icons::-webkit-scrollbar { display: none; }
.app-topbar .topbar-icons > * { flex-shrink: 0; }
.app-topbar .topbar-icons .topbar-icon-badge { top: 0; }
.ref-dep { background: var(--accent-soft); border-radius: .5rem; padding: .35rem .6rem; color: var(--fg); }
/* Survey: anteprima del questionario e dell'email (Impostazioni → Survey) */
.survey-preview-bar { border: 1px dashed var(--primary); background: var(--primary-soft); border-radius: .6rem; padding: .6rem .8rem; margin-bottom: 1rem; font-size: .875rem; }
.survey-mail-preview { border: 1px solid var(--border); border-radius: .6rem; padding: .75rem; background: var(--primary-soft); }
.survey-mail-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .8rem 1rem; }
.survey-mail-body { font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
/* ===== Responsive (telefono e tablet, 03/11/2026) ===== */
/* Intestazione delle schede (titolo + pulsanti): i pulsanti vanno a capo invece di schiacciare il titolo */
.app-main .d-flex.justify-content-between:has(> h1) { flex-wrap: wrap; row-gap: .6rem; column-gap: 1rem; }
.app-main .d-flex.justify-content-between:has(> h1) > div { flex-wrap: wrap; }
@media (max-width: 767.98px) {
  .app-main .d-flex.justify-content-between:has(> h1) > h1 { flex: 1 1 100%; }
  .app-main .d-flex.justify-content-between:has(> h1) > div { justify-content: flex-start; }
  .page-head { align-items: flex-start; }
  .page-head-actions { width: 100%; }
  .app-main { padding-left: .75rem; padding-right: .75rem; }
  .card-header.d-flex { flex-wrap: wrap; row-gap: .4rem; }
  .modal-dialog { margin: .5rem; }
}
/* Tablet (anche in orizzontale): un po' più di respiro per il contenuto */
@media (min-width: 768px) and (max-width: 1279.98px) {
  .app-main { padding-left: 1rem; padding-right: 1rem; }
}
/* iPhone/iPad: i campi con testo sotto i 16px fanno zoomare la pagina al tocco; sui touch li portiamo a 16px */
@media (pointer: coarse) and (max-width: 1199.98px) {
  .app-main input.form-control, .app-main select.form-select, .app-main textarea.form-control,
  .modal input.form-control, .modal select.form-select, .modal textarea.form-control,
  .offcanvas input.form-control, .offcanvas textarea.form-control, .app-topbar input.form-control { font-size: 16px; }
}
@media (max-width: 575.98px) {
  /* Numeri riassuntivi (Ticket, Progetti, Survey, Report…): due per riga invece di uno, più compatti */
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .kpi-card { padding: .6rem .75rem; }
  .kpi-card .kpi-value { font-size: 1.3rem; }
  .kpi-card.kpi-wide { grid-column: span 2; }
  /* Sottomenu verticali delle Impostazioni (colonna a sinistra): sul telefono una riga che scorre di lato */
  .app-main .nav-pills.flex-column { flex-direction: row !important; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: .25rem; }
  .app-main .nav-pills.flex-column::-webkit-scrollbar { display: none; }
  .app-main .nav-pills.flex-column > .nav-item { flex: 0 0 auto; }
  .app-main .nav-pills.flex-column .nav-link { white-space: nowrap; padding: .35rem .7rem; }
}
/* Menu laterale a scomparsa (telefono e tablet): sopra lo sfondo scuro, e la bolla della chat non lo copre */
@media (max-width: 991.98px) {
  .app-sidebar.offcanvas-lg { z-index: 1050; }
  body:has(#appSidebar.show) .chatw, body:has(#appSidebar.showing) .chatw { display: none; }
}

/* ===== Web App per smartphone (03/11/2026): barra in basso, "+", Home compatta (/m) ===== */
.wa-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around; align-items: stretch;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(14, 11, 82, .06);
  padding: .2rem .25rem calc(.2rem + env(safe-area-inset-bottom)); }
.wa-bar-item { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0 .15rem;
  color: var(--muted); font-size: .68rem; font-weight: 500; text-decoration: none; background: none; border: 0; border-radius: .6rem; }
.wa-bar-item .bi { font-size: 1.3rem; line-height: 1; }
.wa-bar-item.is-active { color: var(--primary); }
.wa-bar-item:active { background: var(--primary-soft); }
.wa-bar-badge { position: absolute; top: .1rem; left: calc(50% + .35rem); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bs-danger, #dc3545);
  color: #fff; font-size: .62rem; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.wa-fab { position: fixed; right: 1rem; bottom: calc(4.4rem + env(safe-area-inset-bottom)); z-index: 1031; width: 3.4rem; height: 3.4rem; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font-size: 1.6rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(14, 11, 82, .3); }
.wa-fab:active { transform: scale(.95); }
.wa-sheet { --bs-offcanvas-height: auto; max-height: 85vh; border-radius: 1.1rem 1.1rem 0 0; padding-bottom: env(safe-area-inset-bottom); }
.wa-sheet-tall { --bs-offcanvas-height: 75vh; }
.wa-sheet .offcanvas-body { overflow-y: auto; }
.wa-sheet-foot { display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; border-top: 1px solid var(--border); }
.wa-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .5rem; padding-bottom: .5rem; }
.wa-action { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .6rem .25rem; border-radius: .8rem; color: var(--fg); text-decoration: none;
  font-size: .78rem; text-align: center; line-height: 1.2; }
.wa-action:active, .wa-action:hover { background: var(--surface-2); }
.wa-action-icon { width: 3rem; height: 3rem; border-radius: 1rem; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); font-size: 1.35rem; }
@media (max-width: 767.98px) {
  .has-wa-bar .app-main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  /* la Chat è nella barra in basso: niente bolla in basso a destra (si apre comunque a tutto schermo) */
  .has-wa-bar .chatw:not(.is-open) { display: none; }
  .has-wa-bar .qw-nav { bottom: calc(3.9rem + env(safe-area-inset-bottom)); }
}
body:has(.offcanvas.show) .wa-fab { display: none; }

/* Home (/m) */
.wa-home { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: .75rem; }
.wa-hello { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.wa-hello strong { color: var(--heading); }
.wa-card { background: var(--surface); border: 1px solid var(--border); border-radius: 1rem; box-shadow: var(--shadow); padding: .75rem .85rem; }
.wa-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.wa-head h2 { font-size: 1rem; font-weight: 700; margin: 0; color: var(--heading); display: flex; align-items: center; gap: .4rem; }
.wa-head h2 .bi { color: var(--primary); }
.wa-head a { font-size: .8rem; text-decoration: none; white-space: nowrap; }
.wa-count { font-size: .7rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: .1rem .45rem; }
.wa-agenda-bar { display: flex; justify-content: space-between; align-items: center; margin: .15rem 0 .3rem; }
.wa-month { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.wa-people-btn { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg);
  border-radius: 999px; padding: .2rem .65rem; }
.wa-days { display: flex; gap: .3rem; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: .1rem .05rem .35rem; margin: 0 -.2rem; }
.wa-days::-webkit-scrollbar { display: none; }
.wa-day { flex: 0 0 3rem; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: .05rem; padding: .35rem 0 .3rem;
  border: 1px solid transparent; border-radius: .8rem; background: none; color: var(--fg); position: relative; }
.wa-day-wd { font-size: .68rem; color: var(--muted); text-transform: capitalize; }
.wa-day-num { font-size: 1.2rem; font-weight: 600; line-height: 1.1; }
.wa-day.is-weekend .wa-day-num { color: var(--muted); }
.wa-day.is-today { border-color: var(--primary); }
.wa-day.is-selected { background: var(--primary); color: #fff; }
.wa-day.is-selected .wa-day-wd, .wa-day.is-selected .wa-day-num { color: #fff; }
.wa-day-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.wa-day.has-events .wa-day-dot { background: var(--primary); }
.wa-day.is-selected.has-events .wa-day-dot { background: #fff; }
.wa-events { min-height: 3rem; transition: opacity .15s; }
.wa-events.is-loading { opacity: .45; }
.wa-row { display: flex; align-items: center; gap: .65rem; padding: .55rem .15rem; border-top: 1px solid var(--border); color: var(--fg); text-decoration: none;
  width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.wa-card .wa-row:first-of-type, .wa-events .wa-row:first-child { border-top: 0; }
a.wa-row:active, button.wa-row:active { background: var(--surface-2); }
.wa-row-icon { flex: 0 0 2.2rem; height: 2.2rem; border-radius: .7rem; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); }
.wa-row-icon.is-late { background: var(--danger-soft); color: var(--danger); }
.wa-row-icon.is-today { background: var(--warn-soft); color: var(--warn); }
.wa-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.wa-row-title { font-weight: 600; font-size: .9rem; color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-row-sub { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-clamp { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wa-row-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.wa-row-go { color: var(--muted); font-size: .8rem; }
.wa-unread { min-width: 20px; height: 20px; border-radius: 10px; background: var(--primary); color: #fff; font-size: .68rem; line-height: 20px; text-align: center; padding: 0 6px; }
.wa-ev.is-busy .wa-row-title { color: var(--muted); font-style: italic; }
.wa-ev.is-done .wa-row-title, .wa-ev.is-cancelled .wa-row-title { text-decoration: line-through; color: var(--muted); }
.wa-ev-who { font-size: .72rem; color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.wa-person-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.wa-avatar { position: relative; flex: 0 0 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; }
.wa-avatar.is-group { border-radius: .8rem; background: #0ea5a3; }
.wa-avatar .chat-dot { position: absolute; right: -1px; bottom: -1px; box-shadow: 0 0 0 2px var(--surface); }
.wa-empty { display: flex; align-items: center; justify-content: center; gap: .45rem; padding: .9rem .5rem; color: var(--muted); font-size: .85rem; }
.wa-empty .bi { font-size: 1.1rem; }
.wa-link-add { display: flex; align-items: center; gap: .4rem; padding: .55rem .15rem .1rem; border-top: 1px solid var(--border); font-size: .85rem; text-decoration: none; font-weight: 500; }
.wa-people-list { display: flex; flex-direction: column; }
.wa-person { display: flex; align-items: center; gap: .6rem; padding: .55rem .2rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.wa-person .form-check-input { margin: 0; width: 1.2rem; height: 1.2rem; }
.wa-note-results { margin-top: .25rem; max-height: 50vh; overflow-y: auto; }
.wa-note-chosen { display: flex; align-items: center; gap: .4rem; background: var(--primary-soft); border-radius: .6rem; padding: .4rem .6rem; font-size: .9rem; font-weight: 500; }
/* Home: elenchi delle finestre "a modulo" (Compiti aperti, Attività imminenti, Ticket…) con testo piccolo come la To Do List */
.edh-dash-list { font-size: .8125rem; }
.edh-dash-list > thead > tr > th { font-size: .66rem; }
.edh-dash-list td.small { font-size: .78rem; }
/* Home: Email non lette — mittente e data/ora, oggetto sotto */
.edh-mail-list > li + li { border-top: 1px solid var(--border); }
.edh-mail-item { display: block; padding: .45rem .9rem; color: inherit; text-decoration: none; font-size: .8125rem; line-height: 1.35; }
.edh-mail-item:hover { background: var(--surface-2); }
.edh-mail-top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.edh-mail-from { font-weight: 600; color: var(--heading); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edh-mail-when { flex: 0 0 auto; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.edh-mail-subject { display: block; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edh-mail-item:hover .edh-mail-subject { text-decoration: underline; }
.wa-push-banner { display: flex; align-items: center; gap: .6rem; }
.wa-push-banner.d-none { display: none !important; }
.list-group-item.active-soft { background: var(--primary-soft); }

/* ===================== Anteprima email "documento" (Composer newsletter, 092) ===================== */
.mail-preview-stage { background: #e9edf1; padding: 12px; display: flex; justify-content: center; overflow-x: auto; }
.mail-preview-frame { width: 100%; max-width: 100%; min-height: 200px; border: 0; background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.08); transition: width .2s; }

/* ===================== Composer newsletter a blocchi (092) ===================== */
.app-main:has(> .nc) { padding: 0; }
.nc { display: flex; flex-direction: column; height: calc(100vh - 60px); min-height: 560px; background: var(--surface-2, #f4f6f8); position: relative; }
.nc-top { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; background: var(--surface, #fff); border-bottom: 1px solid var(--border-color, #dee2e6); flex-wrap: wrap; }
.nc-top-fields { display: flex; gap: .4rem; flex: 1 1 380px; min-width: 0; }
.nc-name { flex: 0 1 240px; font-weight: 600; }
.nc-subject { flex: 1 1 auto; }
.nc-top-actions { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.nc-status { white-space: nowrap; }
.nc-warn { border-radius: 0; padding: .5rem .75rem; }
.nc-body { flex: 1 1 auto; display: grid; grid-template-columns: 230px minmax(0, 1fr) 310px; min-height: 0; }
.nc-left, .nc-right { background: var(--surface, #fff); overflow-y: auto; padding: .6rem; }
.nc-left { border-right: 1px solid var(--border-color, #dee2e6); }
.nc-right { border-left: 1px solid var(--border-color, #dee2e6); }
.nc-tabs { margin-bottom: .6rem; gap: .25rem; }
.nc-tabs .nav-link { padding: .3rem .5rem; font-size: .85rem; }
.nc-palette { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.nc-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; min-height: 68px; padding: .4rem; font-size: .78rem;
  border: 1px solid var(--border-color, #dee2e6); border-radius: 8px; background: var(--surface, #fff); color: inherit; cursor: grab; transition: border-color .15s, box-shadow .15s; }
.nc-tile:hover, .nc-tile:focus-visible { border-color: var(--primary, #0d6efd); box-shadow: 0 2px 8px rgba(13,110,253,.12); }
.nc-tile:active { cursor: grabbing; }
.nc-palette-rows { grid-template-columns: 1fr; }
.nc-tile-row { flex-direction: row; justify-content: flex-start; gap: .6rem; min-height: 46px; }
.nc-sketch { display: flex; gap: 3px; width: 64px; height: 22px; flex: 0 0 64px; }
.nc-sketch > span { background: var(--primary-soft, #e7efff); border: 1px solid var(--primary, #0d6efd); border-radius: 3px; opacity: .8; }
.nc-hint { margin-top: .75rem; }
.nc-center { overflow: auto; min-width: 0; }
.nc-canvas { min-height: 100%; display: flex; flex-direction: column; align-items: center; }
.nc-preheader { font-size: .75rem; color: #6b7c86; background: rgba(255,255,255,.7); border-radius: 4px; padding: 2px 8px; margin-bottom: 6px; max-width: 600px; }
.nc-mail { max-width: 100%; box-shadow: 0 2px 14px rgba(0,0,0,.08); line-height: 1.45; transition: width .2s; overflow: visible; }
.nc-mail a, .nc-mail .nc-text a, .nc-mail .nc-h a { color: var(--nc-link); }
.nc-mail p { margin: 0 0 10px; }
.nc-mail p:last-child, .nc-mail ul:last-child, .nc-mail ol:last-child { margin-bottom: 0; }
.nc-empty-mail { padding: 60px 20px; text-align: center; color: #8a98a3; border: 2px dashed #cfd8de; margin: 16px; border-radius: 8px; }
.nc-row { position: relative; outline: 1px dashed transparent; outline-offset: -1px; }
.nc-row:hover { outline-color: #9ec5fe; }
.nc-row.is-selected { outline: 2px solid #0d6efd; z-index: 1; }
.nc-row-bar, .nc-block-bar { position: absolute; display: none; align-items: center; gap: 1px; z-index: 5; background: #0d6efd; color: #fff; border-radius: 4px; padding: 1px 3px; font-family: system-ui, sans-serif; font-size: 11px; line-height: 1; }
.nc-row-bar { left: 0; top: -21px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.nc-row:hover > .nc-row-bar, .nc-row.is-selected > .nc-row-bar { display: flex; }
.nc-block-bar { right: 0; top: -20px; background: #6f42c1; }
.nc-block:hover > .nc-block-bar, .nc-block.is-selected > .nc-block-bar { display: flex; }
.nc-row-label, .nc-block-label { padding: 3px 5px; cursor: grab; white-space: nowrap; }
.nc-tool { border: 0; background: transparent; color: #fff; padding: 2px 4px; line-height: 1; border-radius: 3px; font-size: 12px; }
.nc-tool:hover { background: rgba(255,255,255,.2); }
.nc-cols { display: flex; flex-wrap: nowrap; }
.nc-cols.nc-stacked { flex-wrap: wrap; }
.nc-col { min-width: 0; min-height: 30px; position: relative; }
.nc-row:hover .nc-col + .nc-col { box-shadow: inset 1px 0 0 #cfe2ff; }
.nc-col-empty { border: 1px dashed #b6c2cc; border-radius: 6px; color: #8a98a3; font-size: 12px; text-align: center; padding: 18px 6px; cursor: pointer; font-family: system-ui, sans-serif; }
.nc-block { position: relative; outline: 1px dashed transparent; outline-offset: -1px; }
.nc-block:hover { outline-color: #c5a8f0; }
.nc-block.is-selected { outline: 2px solid #6f42c1; z-index: 2; }
.nc-block.is-dragging, .nc-row.is-dragging { opacity: .35; }
.nc-hidden-m { opacity: .3; }
.nc-hidden-m::after { content: "Nascosto sul telefono"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 600 11px system-ui, sans-serif; color: #6f42c1; }
.nc-content [contenteditable] { outline: none; cursor: text; min-height: 1em; }
.nc-content [contenteditable]:focus { box-shadow: 0 0 0 2px rgba(111,66,193,.25); border-radius: 2px; }
.nc-h { word-break: break-word; }
.nc-btn { text-decoration: none; text-align: center; line-height: 1.2; }
.nc-img-ph { background: repeating-linear-gradient(45deg, #eef1f4, #eef1f4 10px, #e6eaee 10px, #e6eaee 20px); color: #7d8b96; border-radius: 4px; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 10px; font-family: system-ui, sans-serif; }
.nc-img-ph.is-over { outline: 2px dashed #0d6efd; background: #e7f1ff; }
.nc-b-logo .nc-img-ph { min-height: 60px; }
.nc-content img { max-width: 100%; height: auto; display: inline-block; }
.nc-spacer { background: repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(13,110,253,.06) 4px, rgba(13,110,253,.06) 8px); }
.nc-social { display: block; }
.nc-pill { display: inline-block; padding: 5px 12px; border-radius: 16px; border: 1px solid; font-weight: bold; margin: 2px 3px; line-height: 1.2; }
.nc-pill-nourl { opacity: .45; border-style: dashed; }
.nc-footer { line-height: 1.5; }
.nc-footer-company:empty::before { content: attr(data-placeholder); color: #b0bac2; }
.nc-unsub { text-decoration: underline; cursor: help; }
.nc-html { min-height: 20px; }
.nc-drop-marker { height: 4px; background: #6f42c1; border-radius: 2px; margin: 2px 0; box-shadow: 0 0 0 3px rgba(111,66,193,.2); }
.nc-drop-marker-row { background: #0d6efd; box-shadow: 0 0 0 3px rgba(13,110,253,.2); height: 5px; }
.nc-dragging .nc-col { box-shadow: inset 0 0 0 1px #d6c6f3; }
.nc-props-empty { text-align: center; color: var(--text-muted, #6c757d); padding: 1.5rem .5rem; }
.nc-props-head { display: flex; align-items: center; gap: .5rem; padding-bottom: .4rem; margin-bottom: .5rem; border-bottom: 1px solid var(--border-color, #dee2e6); }
.nc-field { margin-bottom: .6rem; }
.nc-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted, #6c757d); font-weight: 600; margin: .9rem 0 .3rem; }
.nc-num { width: 64px; flex: 0 0 64px; }
.nc-hex { width: 92px; flex: 0 0 92px; font-family: monospace; }
.nc-code { font-family: monospace; font-size: .78rem; }
.nc-note { background: var(--primary-soft, #e7efff); border-radius: 6px; padding: .45rem .6rem; margin-bottom: .6rem; }
.nc-format { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: .35rem; margin-bottom: .6rem; border: 1px solid var(--border-color, #dee2e6); border-radius: 6px; background: var(--surface-2, #f8f9fa); }
.nc-format .btn { padding: .15rem .4rem; }
.nc-format-color { width: 30px; height: 28px; padding: 2px; }
.nc-format-fields { width: auto; max-width: 130px; font-size: .78rem; }
.nc-unlink { position: relative; }
.nc-unlink::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; border-top: 1.5px solid currentColor; transform: rotate(-35deg); }
.nc-layout-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.nc-layout-opt { border: 1px solid var(--border-color, #dee2e6); border-radius: 6px; background: var(--surface, #fff); padding: .4rem; display: flex; justify-content: center; }
.nc-layout-opt.active { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13,110,253,.25); }
.nc-img-prev { border: 1px solid var(--border-color, #dee2e6); border-radius: 6px; min-height: 60px; display: flex; align-items: center; justify-content: center; background: #f4f6f8; overflow: hidden; }
.nc-img-prev img { max-width: 100%; max-height: 140px; }
.nc-social-net { flex: 0 0 112px; width: 112px; }
.nc-drop { display: block; text-align: center; border: 2px dashed #b6c2cc; border-radius: 10px; padding: 1.2rem; cursor: pointer; color: #5c6b77; }
.nc-drop.is-over { border-color: #0d6efd; background: #e7f1ff; }
.nc-img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.nc-img-item { border: 1px solid var(--border-color, #dee2e6); border-radius: 8px; padding: .3rem; background: var(--surface, #fff); display: flex; flex-direction: column; gap: .25rem; text-align: left; min-width: 0; }
.nc-img-item:hover { border-color: #0d6efd; }
.nc-img-item img { width: 100%; height: 90px; object-fit: contain; background: #f4f6f8; border-radius: 4px; }
.nc-starter { width: 100%; height: 100%; border: 1px solid var(--border-color, #dee2e6); border-radius: 10px; background: var(--surface, #fff); padding: 0; text-align: left; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.nc-starter:hover, .nc-starter:focus-visible { border-color: #0d6efd; box-shadow: 0 4px 16px rgba(13,110,253,.15); }
.nc-starter-text { padding: .6rem .75rem; }
.nc-mini { padding: 10px 18px; height: 190px; overflow: hidden; }
.nc-mini-mail { box-shadow: 0 1px 4px rgba(0,0,0,.1); border-radius: 3px; overflow: hidden; }
.nc-mini-row { display: flex; gap: 4px; padding: 4px 6px; }
.nc-mini-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nc-mini-b { height: 3px; background: #cfd8de; border-radius: 1px; }
.nc-mini-heading { height: 5px; background: #6c7a86; width: 70%; }
.nc-mini-image { height: 22px; background: #bcd3f2; }
.nc-mini-logo { height: 7px; width: 34%; margin: 0 auto; background: #0e0b52; }
.nc-mini-button { height: 6px; width: 38%; background: #0e0b52; border-radius: 2px; }
.nc-mini-divider { height: 1px; }
.nc-mini-spacer { background: transparent; }
.nc-mini-social { height: 4px; width: 46%; margin: 0 auto; background: #8fb4e8; }
.nc-mini-footer { height: 2px; width: 60%; margin: 0 auto; background: #dde3e8; }
.nc-toast { position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 20px); background: #1b2a33; color: #fff; padding: .5rem .9rem; border-radius: 8px; font-size: .85rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 1060; display: flex; align-items: center; }
.nc-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
@media (max-width: 1199.98px) { .nc-body { grid-template-columns: 190px minmax(0, 1fr) 280px; } }
@media (max-width: 991.98px) {
  .nc { height: auto; }
  .nc-body { grid-template-columns: 1fr; }
  .nc-left, .nc-right { border: 0; border-bottom: 1px solid var(--border-color, #dee2e6); }
  .nc-palette { grid-template-columns: repeat(5, 1fr); }
  .nc-palette-rows { grid-template-columns: repeat(3, 1fr); }
  .nc-center { overflow: visible; }
  .nc-canvas { padding-left: 0 !important; padding-right: 0 !important; }
}
@media (max-width: 575.98px) { .nc-top-fields { flex-direction: column; flex-basis: 100%; } .nc-name { flex-basis: auto; } }
/* Galleria dei template del Composer */
.nc-gallery-body { background: var(--surface-2, #f4f6f8); min-height: 60vh; }
.nc-gallery-tabs .nav-link { font-size: .9rem; }
.nc-gcard { background: var(--surface, #fff); border: 1px solid var(--border-color, #dee2e6); border-radius: 10px; overflow: hidden; height: 100%; display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s; }
.nc-gcard:hover { border-color: #0d6efd; box-shadow: 0 6px 20px rgba(13,110,253,.14); }
.nc-thumb { --s: .45; position: relative; display: block; width: 100%; height: 280px; overflow: hidden; border: 0; padding: 0; background: #e9edf1; cursor: pointer; }
.nc-thumb iframe { width: 680px; height: calc(280px / var(--s)); border: 0; transform: scale(var(--s)); transform-origin: 0 0; pointer-events: none; background: #fff; }
.nc-thumb-use { position: absolute; inset: auto 0 0 0; padding: .5rem; background: linear-gradient(transparent, rgba(13,110,253,.92) 45%); color: #fff; font-weight: 600; font-size: .85rem; opacity: 0; transition: opacity .15s; }
.nc-thumb:hover .nc-thumb-use, .nc-thumb:focus-visible .nc-thumb-use { opacity: 1; }
.nc-gcard-body { padding: .55rem .7rem .7rem; }

/* ===================== Formazione clienti (094) ===================== */
.soft-muted { background: var(--surface-2, #eef1f4); color: var(--text-muted, #6c757d); }
.tc-missing { color: var(--warn); font-size: .78rem; }
.tc-kpi .fs-4 { line-height: 1.1; }
.tc-lic { height: 8px; }
.tc-sticky { position: sticky; top: 72px; }
.tc-pick-list { max-height: 320px; overflow: auto; }
.tc-items td { vertical-align: middle; }

/* Processi (097): editor visuale a oggetti */
.wf-canvas { background-color: var(--bs-tertiary-bg); background-image: radial-gradient(var(--bs-border-color) 1px, transparent 1px); background-size: 18px 18px; min-height: 420px; overflow-x: auto; }
.wf-list { display: flex; flex-direction: column; align-items: stretch; }
.wf-node { display: flex; flex-direction: column; width: 100%; max-width: 760px; margin: 0 auto; border: 1px solid var(--bs-border-color); border-left-width: 4px; border-radius: .6rem; background: var(--bs-body-bg); text-align: left; padding: 0; color: inherit; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }
.wf-start { flex-direction: row; align-items: center; gap: .65rem; padding: .6rem .8rem; border-left-color: #f0a020; cursor: pointer; }
.wf-step.wf-action { border-left-color: var(--bs-primary); }
.wf-step.wf-logic { border-left-color: #8a63d2; }
.wf-node.is-selected { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
.wf-node.has-warn { border-color: #e0a800; }
.wf-node-head { display: flex; align-items: center; gap: .65rem; padding: .55rem .8rem; cursor: pointer; }
.wf-node-head:focus-visible, .wf-start:focus-visible { outline: 2px solid var(--bs-primary); }
.wf-node-icon { flex: 0 0 2rem; height: 2rem; border-radius: .5rem; display: inline-flex; align-items: center; justify-content: center; background: var(--bs-secondary-bg); font-size: 1rem; }
.wf-start .wf-node-icon { background: rgba(240, 160, 32, .16); color: #c27c00; }
.wf-action .wf-node-icon { background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); }
.wf-logic .wf-node-icon { background: rgba(138, 99, 210, .14); color: #7a52c8; }
.wf-node-body { display: flex; flex-direction: column; min-width: 9rem; flex: 1; }
.wf-node-kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); }
.wf-node-title { font-weight: 600; font-size: .9rem; }
.wf-node-sum { font-size: .82rem; overflow-wrap: anywhere; }
.wf-node-warn { font-size: .78rem; color: #b07800; }
.wf-node-tools { display: flex; opacity: .35; transition: opacity .15s; }
.wf-node-head:hover .wf-node-tools, .wf-node.is-selected > .wf-node-head .wf-node-tools, .wf-node-head:focus-within .wf-node-tools { opacity: 1; }
.wf-branches { display: flex; flex-wrap: wrap; gap: .6rem; padding: 0 .6rem .6rem; }
.wf-branch { flex: 1 1 260px; min-width: 0; border: 1px dashed var(--bs-border-color); border-radius: .5rem; padding: .35rem .4rem; background: var(--bs-tertiary-bg); }
.wf-branch-label { font-size: .75rem; font-weight: 600; margin-bottom: .1rem; }
.wf-yes .wf-branch-label { color: #1f8a4c; } .wf-no .wf-branch-label { color: #c0392b; } .wf-loop .wf-branch-label { color: #7a52c8; }
.wf-gap { display: flex; justify-content: center; position: relative; padding: .3rem 0; }
.wf-gap::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 2px solid var(--bs-border-color); }
.wf-add { position: relative; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-secondary-color); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; padding: 0; }
.wf-add:hover, .wf-add:focus-visible { background: var(--bs-primary); color: #fff; border-color: var(--bs-primary); }
.wf-end { text-align: center; font-size: .8rem; color: var(--bs-secondary-color); margin-top: .1rem; }
.wf-menu { position: absolute; z-index: 1080; width: 330px; max-width: calc(100vw - 16px); background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .6rem; padding: .35rem; }
.wf-menu-h { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); padding: .3rem .5rem .1rem; }
.wf-menu-item { display: flex; gap: .6rem; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: .4rem .5rem; border-radius: .4rem; color: inherit; }
.wf-menu-item .bi { font-size: 1.05rem; color: var(--bs-primary); margin-top: .1rem; }
.wf-menu-item span { display: flex; flex-direction: column; } .wf-menu-item strong { font-size: .86rem; } .wf-menu-item small { color: var(--bs-secondary-color); font-size: .76rem; }
.wf-menu-item:hover, .wf-menu-item:focus-visible { background: var(--bs-secondary-bg); outline: none; }
.wf-menu-item.is-off { opacity: .5; }
.wf-cond { border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: .35rem; margin-bottom: .4rem; background: var(--bs-tertiary-bg); }
.wf-side { position: sticky; top: 72px; }
.wf-log li { padding: .1rem 0; }
.wf-template { border-top: 3px solid var(--bs-primary); }
@media (max-width: 767.98px) { .wf-branches { flex-direction: column; } .wf-branch { min-width: 0; } .wf-side { position: static; } }

/* Sottoscrizione offerta e privacy (098) */
.contract-preview { max-height: 340px; overflow-y: auto; background: var(--bs-body-bg); }
.contract-preview h1 { font-size: 1.1rem; } .contract-preview h2 { font-size: 1rem; margin-top: 1rem; } .contract-preview h3 { font-size: .9rem; margin: .75rem 0 .25rem; }
.sign-option { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .6rem .8rem; }
.sign-option > summary { cursor: pointer; }
.privacy-notice h2 { font-size: 1.25rem; } .privacy-notice h3 { font-size: 1rem; margin-top: 1rem; }
.columns-2 { columns: 2; } @media (max-width: 767.98px) { .columns-2 { columns: 1; } }
.contract-snippet { overflow-wrap: anywhere; }

/* Sistemi di gestione (099) */
.sgi-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--bs-border-color); padding-bottom: .4rem; }
.sgi-tab { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .6rem; border-radius: .4rem; font-size: .82rem; color: var(--bs-secondary-color); text-decoration: none; }
.sgi-tab:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.sgi-tab.is-active { background: rgba(var(--bs-primary-rgb), .12); color: var(--bs-primary); font-weight: 600; }
.sgi-tile { color: inherit; border-left: 4px solid var(--bs-border-color); }
.sgi-tile.is-danger { border-left-color: #dc3545; } .sgi-tile.is-warn { border-left-color: #f0a020; } .sgi-tile.is-accent { border-left-color: var(--bs-primary); }
.sgi-step.is-done { opacity: .75; } .sgi-step.is-next { border-left: 4px solid var(--bs-primary); }
.sgi-step details summary { cursor: pointer; color: var(--bs-secondary-color); }
.sgi-matrix { border-collapse: separate; border-spacing: 3px; }
.sgi-matrix th { font-weight: 500; color: var(--bs-secondary-color); text-align: center; padding: 0 .3rem; font-size: .75rem; }
.sgi-matrix td { width: 2.6rem; height: 2rem; text-align: center; font-weight: 600; border-radius: .3rem; }
.sgi-matrix .m-lo { background: rgba(31, 138, 76, .16); } .sgi-matrix .m-mid { background: rgba(240, 160, 32, .25); } .sgi-matrix .m-hi { background: rgba(220, 53, 69, .28); }
.sgi-doc { max-width: 880px; } .sgi-doc h2 { font-size: 1.2rem; margin-top: 1rem; } .sgi-doc h3 { font-size: 1rem; margin-top: .9rem; }
.sgi-doc table { border-collapse: collapse; margin: .5rem 0; } .sgi-doc td, .sgi-doc th { border: 1px solid var(--bs-border-color); padding: .25rem .5rem; vertical-align: top; }
.sgi-doc .doc-head { width: 100%; margin-bottom: 1rem; } .sgi-doc .doc-head td { width: 33%; }
.sgi-doc-frame { width: 100%; height: 75vh; border: 1px solid var(--bs-border-color); border-radius: .4rem; }
.sgi-controls-pick { max-height: 340px; overflow-y: auto; border: 1px solid var(--bs-border-color); border-radius: .4rem; padding: .4rem .6rem; }
.sgi-sticky-save { position: sticky; bottom: 0; background: var(--bs-body-bg); z-index: 2; }
.sgi-state.is-ok { border-color: #1f8a4c; } .sgi-state.is-accent { border-color: var(--bs-primary); } .sgi-state.is-warn { border-color: #f0a020; }

/* SGI: lampadina con la spiegazione pratica della pagina */
.sgi-tip-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid #e0a800; background: #fff8db; color: #c99500; display: inline-flex; align-items: center; justify-content: center; padding: 0; font-size: .95rem; line-height: 1; flex: none; }
.sgi-tip-btn:hover, .sgi-tip-btn:focus-visible { background: #ffc107; color: #3d2e00; border-color: #ffc107; }
.sgi-tip-head { background: #fff8db; }
.sgi-tip-head .modal-title { color: #5c4500; font-weight: 600; }
.sgi-tip-head .bi-lightbulb-fill { color: #e0a800; }
.sgi-tip-h { font-weight: 600; margin-top: 1rem; margin-bottom: .5rem; color: var(--bs-emphasis-color, #212529); }
.sgi-tip-h:first-child { margin-top: 0; }
.sgi-tip-who { display: grid; grid-template-columns: minmax(140px, 30%) 1fr; gap: .35rem .75rem; margin-bottom: .5rem; }
.sgi-tip-who dt { font-weight: 600; margin: 0; }
.sgi-tip-who dd { margin: 0; }
@media (max-width: 575.98px) { .sgi-tip-who { grid-template-columns: 1fr; } .sgi-tip-who dd { margin-bottom: .4rem; } }
.sgi-tip-ex li { margin-bottom: .35rem; }
.sgi-tip ol li, .sgi-tip ul li { margin-bottom: .25rem; }
[data-bs-theme="dark"] .sgi-tip-btn { background: #3d2e00; color: #ffc107; border-color: #8a6d00; }
[data-bs-theme="dark"] .sgi-tip-head { background: #2f2600; }
[data-bs-theme="dark"] .sgi-tip-head .modal-title { color: #ffd966; }

/* Timesheet mensile e Rimborso spese (100) */
.ts-totals { display: flex; flex-wrap: wrap; gap: .5rem; }
.ts-tot { background: var(--bs-body-bg, #fff); border: 1px solid #e3e6ef; border-radius: .5rem; padding: .35rem .7rem; min-width: 104px; }
.ts-tot span { display: block; font-size: .72rem; color: #6c7389; text-transform: uppercase; letter-spacing: .02em; }
.ts-tot strong { font-size: 1.05rem; }
.ts-tot.is-ref { background: #f3f5fb; }
.ts-tot.is-alert { border-color: #dc3545; background: #fff1f2; }
.ts-table th, .ts-table td { white-space: nowrap; }
.ts-table .ts-h { width: 62px; text-align: right; }
.ts-table .ts-c { width: 132px; }
.ts-table .ts-w { width: 140px; }
.ts-table .ts-n { min-width: 160px; }
.ts-table thead th { position: sticky; top: 0; background: #f3f5fb; z-index: 2; font-size: .78rem; }
.ts-table tbody th { position: sticky; left: 0; background: var(--bs-body-bg, #fff); z-index: 1; min-width: 92px; }
.ts-table tr.ts-off > *, .ts-grid .ts-off { background: #f4f5f8; color: #7a8094; }
.ts-table tr.ts-off .form-control, .ts-table tr.ts-off .form-select { background-color: #f9fafc; }
.ts-table tr.ts-today th { box-shadow: inset 3px 0 0 #4b56e0; }
.ts-table tr.table-danger > * { background: #fde8ea; }
.ts-wd { display: inline-block; width: 2.2em; color: #6c7389; font-weight: 400; }
.ts-foot td, .ts-foot th { font-weight: 600; background: #f3f5fb; }
.ts-wrap { max-height: 70vh; }
.ts-grid { font-size: .76rem; }
.ts-grid th, .ts-grid td { padding: .2rem .25rem; min-width: 34px; }
.ts-grid .ts-grid-name { position: sticky; left: 0; background: var(--bs-body-bg, #fff); z-index: 1; min-width: 150px; }
.ts-grid td.ts-abs { background: #fff6e0; }
.ts-code { display: block; font-size: .65rem; font-weight: 600; color: #b26b00; line-height: 1; }
.ts-bars { display: flex; align-items: flex-end; gap: .35rem; height: 150px; }
.ts-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.ts-bar-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.ts-bar { width: 42%; min-height: 1px; border-radius: 3px 3px 0 0; }
.ts-bar.is-work, .ts-key.is-work { background: #4b56e0; }
.ts-bar.is-abs, .ts-key.is-abs { background: #e0a14b; }
.ts-bar.is-money { width: 70%; background: #2fa36a; }
.ts-bar-l { font-size: .7rem; color: #6c7389; margin-top: 2px; }
.ts-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.ts-reminder { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .7rem 1rem; margin-bottom: 1rem; border-radius: .6rem;
  background: #fff4d6; border: 1px solid #f0c24b; border-left: 6px solid #e0a800; color: #4d3a00; }
.ts-reminder.is-late { background: #fde8ea; border-color: #f1a5ad; border-left-color: #dc3545; color: #5c1219; }
.ts-reminder a:not(.btn) { color: inherit; font-weight: 600; }
.ts-reminder-head { background: #fff4d6; }
.ts-reminder-head.is-late { background: #fde8ea; }
.rs-file { display: inline-flex; align-items: center; gap: .2rem; border: 1px solid #e3e6ef; border-radius: .4rem; padding: .15rem .3rem; font-size: .75rem; background: #fafbfd; }
.rs-file img { height: 44px; width: 44px; object-fit: cover; border-radius: .25rem; }
.rs-file form { display: inline; }
.rs-company th { width: 42%; }
/* Sabato, domenica e festivi in rosso (Timesheet e griglia della Direzione) */
.ts-red, .ts-red .ts-wd, .ts-table tr.ts-off > th.ts-red, .ts-grid th.ts-red { color: #c62828; }
.ts-red .ts-dn { font-weight: 700; }
.table.ts-grid > thead > tr:first-child > th.ts-red { color: #c62828; }

/* Link condivisi (102) */
.sh-card { border-radius: 14px; }
.sh-icon { font-size: 2.6rem; color: #4b56e0; line-height: 1; }
.sh-meta dd { margin-bottom: .35rem; }
.sh-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sh-url { font-family: var(--bs-font-monospace); font-size: .8rem; }
.lk-row-req { background: #fff6e0; }
.lk-badge { position: absolute; top: -6px; right: -8px; }

/* ===== Agenda del giorno e promemoria delle attività (106) ===== */
.agenda-head { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.agenda-head .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.agenda-list { border-left: 2px solid var(--bs-border-color); margin-left: .25rem; }
.agenda-item { display: flex; align-items: flex-start; gap: .9rem; padding: .55rem 0 .55rem .9rem; position: relative; }
.agenda-item::before { content: ""; position: absolute; left: -6px; top: 1rem; width: 10px; height: 10px; border-radius: 50%; background: #4f46e5; }
.agenda-item.is-past { opacity: .55; }
.agenda-item.is-past::before { background: var(--bs-secondary-color); }
.agenda-time { min-width: 4.2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.agenda-time span { display: block; font-weight: 400; font-size: .8rem; color: var(--bs-secondary-color); }
.agenda-body { flex: 1; min-width: 0; }
.agenda-join { white-space: nowrap; align-self: center; }
@media (max-width: 575.98px) { .agenda-item { flex-wrap: wrap; } .agenda-join { width: 100%; } }
.edh-rem-stack { position: fixed; top: 4.5rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .75rem; width: min(380px, calc(100vw - 2rem)); }
.edh-rem-card { background: var(--bs-body-bg); border-radius: .8rem; box-shadow: 0 .75rem 2.5rem rgba(0,0,0,.28); overflow: hidden; border: 2px solid #f59e0b; animation: edh-rem-in .35s ease-out; }
.edh-rem-head { display: flex; align-items: center; justify-content: space-between; background: #f59e0b; color: #1f1300; padding: .5rem .8rem; font-weight: 700; }
.edh-rem-head .btn-close-white { filter: none; }
.edh-rem-when::before { content: "\23F0  "; }
.edh-rem-body { padding: .75rem .9rem .8rem; }
.edh-rem-title { font-size: 1.1rem; font-weight: 700; line-height: 1.25; margin-bottom: .2rem; }
.edh-rem-meta { color: var(--bs-secondary-color); font-size: .875rem; }
.edh-rem-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .65rem; }
@keyframes edh-rem-in { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 575.98px) { .edh-rem-stack { top: auto; bottom: 1rem; right: 1rem; } }
.ics-box { border: 1px solid #c7d2fe; background: #eef2ff; border-radius: .6rem; padding: .7rem .9rem; margin-bottom: .75rem; }
[data-bs-theme="dark"] .ics-box { background: #1e1b4b; border-color: #3730a3; }
.cal-event.cal-event-pending { outline: 2px dashed #f59e0b; outline-offset: -2px; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); }
.cal-event.cal-event-cancelled { text-decoration: line-through; opacity: .6; }
.invite-answer.is-pending { border-left: 3px solid #f59e0b; padding-left: .6rem; }
.edh-rem-card.is-invite { border-color: #6366f1; }
.edh-rem-card.is-invite .edh-rem-head { background: #6366f1; color: #fff; }
.edh-rem-card.is-invite .edh-rem-when::before { content: "\2709  "; }
.edh-rem-card.is-invite .btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }
.pref-card > .card-header { font-weight: 600; background: var(--bs-tertiary-bg); }
.pref-card .card-header .bi { color: var(--bs-primary); }
.pref-user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .1rem 1rem; }
.pref-save-bar { position: sticky; bottom: 0; z-index: 5; padding: .75rem 0; background: linear-gradient(to top, var(--bs-body-bg) 70%, transparent); }
.agenda-head, .agenda-head .modal-title, .agenda-head .modal-title span, .agenda-head .bi { color: #fff !important; }
.agenda-head .modal-title span { opacity: .9; }

/* ===== Schede dei moduli: tutta la larghezza e liste correlate ben distinte ===== */
.edh-record { max-width: none; }
.rel-divider { display: flex; align-items: center; gap: .75rem; margin: 1.5rem 0 .75rem; color: var(--bs-secondary-color); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rel-divider::before, .rel-divider::after { content: ""; flex: 1; border-top: 2px dashed var(--bs-border-color); }
.rel-card { border-color: #c7d2fe; }
.rel-card > .card-header { background: #eef2ff; border-left: 4px solid #6366f1; color: #312e81; }
.rel-card > .card-header .bi { color: #6366f1; }
.rel-card .rel-count { font-weight: 400; color: #6366f1; }
.rel-card .rel-cfg { color: #6366f1; padding: 0 .35rem; }
[data-bs-theme="dark"] .rel-card { border-color: #3730a3; }
[data-bs-theme="dark"] .rel-card > .card-header { background: #1e1b4b; color: #e0e7ff; }
[data-bs-theme="dark"] .rel-card > .card-header .bi, [data-bs-theme="dark"] .rel-card .rel-count { color: #a5b4fc; }

/* Colonne con ordine (viste salvate, liste correlate): spuntate in alto, frecce per spostarle */
.col-order { max-height: 420px; overflow-y: auto; border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .25rem; background: var(--bs-body-bg); }
.col-order-item { display: flex; align-items: center; gap: .25rem; padding: .2rem .5rem; border-radius: .375rem; }
.col-order-item:nth-child(odd) { background: var(--bs-tertiary-bg); }
.col-order-item.is-checked { background: rgba(var(--bs-primary-rgb), .08); }
.col-order-item.is-system .form-check-label { font-style: italic; }
.col-order-sep { font-size: .75rem; color: var(--bs-secondary-color); padding: .35rem .5rem .1rem; text-transform: uppercase; letter-spacing: .03em; }

/* Posta: indirizzi riconosciuti tra i Contatti (icona con riquadro) e "Crea contatto" */
.mail-person { white-space: normal; }
.mc-wrap { position: relative; display: inline-block; margin-left: .25rem; }
.mc-link { text-decoration: none; font-weight: 600; background: rgba(var(--bs-primary-rgb), .08); border-radius: 1rem; padding: .05rem .5rem; }
.mc-link:hover { background: rgba(var(--bs-primary-rgb), .16); }
.mc-card { display: none; position: absolute; left: 0; top: calc(100% + 4px); z-index: 1070; min-width: 260px; max-width: 340px;
  background: var(--bs-body-bg); color: var(--bs-body-color); border: 1px solid var(--bs-border-color); border-radius: .5rem;
  box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .15); padding: .6rem .75rem; font-size: .85rem; }
.mc-wrap:hover .mc-card, .mc-wrap:focus-within .mc-card { display: block; }
.mc-card::before { content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 6px; }
.mc-card-name { display: block; font-weight: 700; margin-bottom: .2rem; }
.mc-card-row { display: flex; gap: .45rem; align-items: baseline; line-height: 1.5; }
.mc-card-row > .bi { width: 1rem; flex: none; color: var(--bs-secondary-color); }
.mc-card-row > .portal-ico { color: inherit; }
.mc-card-row > .portal-ico.is-ok { color: #2e9d48; }
.mc-new { font-size: .8rem; margin-left: .25rem; }

/* Spiegazioni dei campi a scelta (field-help.js) */
.fh-btn { font-size: .95em; line-height: 1; color: var(--bs-primary); }
.fh-panel { background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .6rem .75rem; margin: .25rem 0 .5rem; font-size: .85rem; max-height: 340px; overflow-y: auto; }
.fh-panel-help { margin-bottom: .4rem; color: var(--bs-secondary-color); }
.fh-list { margin: 0; }
.fh-list dt { font-weight: 600; margin-top: .35rem; }
.fh-list dd { margin: 0 0 .1rem; }
.fh-note { margin-top: .35rem; font-size: .82rem; background: rgba(var(--bs-info-rgb), .08); border-left: 3px solid var(--bs-info); border-radius: .25rem; padding: .35rem .55rem; overflow-wrap: anywhere; }
.fh-note-item + .fh-note-item { margin-top: .3rem; }
.fh-flow { color: var(--bs-secondary-color); font-size: .78rem; margin-top: .15rem; }

/* Canali di vendita: etichetta colorata del canale (prezzi, ordini, prodotti) */
.ch-badge { color: #fff; font-weight: 600; letter-spacing: .01em; }
.ch-hint { padding: .35rem .55rem; border-radius: .375rem; background: var(--bs-tertiary-bg); flex-basis: 100%; }
.ch-hint.is-warn { background: rgba(var(--bs-danger-rgb), .1); color: var(--bs-danger-text-emphasis); border: 1px solid rgba(var(--bs-danger-rgb), .35); }
.ch-col { box-shadow: inset 0 3px 0 var(--ch-color, #6c757d); background: color-mix(in srgb, var(--ch-color, #6c757d) 7%, transparent); }
.ch-price-row.is-off { opacity: .6; }
.table > :not(caption) > * > .ch-col { background-color: color-mix(in srgb, var(--ch-color, #6c757d) 9%, var(--bs-body-bg)) !important; border-left: 2px solid var(--ch-color, #6c757d); }
.table > thead > * > .ch-col { color: var(--ch-color, #6c757d) !important; box-shadow: inset 0 3px 0 var(--ch-color, #6c757d); }
.ch-edit { border: 1px solid var(--bs-border-color); border-left: 4px solid var(--ch-color, #6c757d); border-radius: .375rem; background: color-mix(in srgb, var(--ch-color, #6c757d) 5%, var(--bs-body-bg)); }

/* Messaggi: "Le mie cartelle" a scomparsa (chiuse per default) */
.messages-custom-summary { cursor: pointer; list-style: none; user-select: none; display: flex; align-items: center; gap: .25rem; }
.messages-custom-summary::-webkit-details-marker { display: none; }
.messages-custom-summary:hover { color: var(--bs-body-color) !important; }
.messages-custom-chevron { font-size: .7rem; transition: transform .15s ease; }
details[open] > .messages-custom-summary .messages-custom-chevron { transform: rotate(90deg); }

/* Account di posta → Test connessione: dettaglio con le risposte del server */
.mail-test-detail { white-space: pre-wrap; word-break: break-word; background: var(--bs-tertiary-bg); border-radius: .375rem; padding: .5rem .65rem; font-size: .78rem; max-height: 320px; overflow: auto; }

/* Calendario: passando sopra uno spazio libero si vede l'ora d'inizio (clic = crea Attività/Compito a quell'ora) */
.cal-slot { position: relative; }
.cal-slot:hover::after {
    content: "+ " attr(data-time);
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
    color: var(--primary);
    pointer-events: none;
    white-space: nowrap;
}

/* Logo dell'Azienda (scheda e Statistiche) */
.acc-logo-sm { height: 32px; width: auto; max-width: 120px; object-fit: contain; border-radius: .25rem; background: #fff; padding: 2px; border: 1px solid var(--border); }
.acc-logo-box { height: 80px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: .5rem; background: #fff; padding: .5rem; }
.acc-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Modali con <form> tra modal-content e modal-body: lo scroll interno di .modal-dialog-scrollable deve funzionare
   anche così (es. Editor Picklist → Spiegazioni con molti valori) */
.modal-dialog-scrollable .modal-content > form { display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
.modal-dialog-scrollable .modal-content > form > .modal-body { overflow-y: auto; }

/* Legenda valori */
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; border: 1px solid rgba(0,0,0,.15); }
.legend-btn { height: 28px; }
/* la modale nasce dentro il titolo h1 della pagina: testo normale */
#value-legend .modal-content { font-size: .9rem; font-weight: 400; line-height: 1.5; letter-spacing: normal; text-transform: none; }
#value-legend .modal-title { font-size: 1.05rem; font-weight: 600; }
#value-legend td.fw-semibold { font-weight: 600; }

/* Logo del Fornitore negli Ordini di Acquisto (elenco, scheda, creazione guidata — migrazione 130) */
.sup-logo { width: 64px; height: 28px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border, #dee2e6); border-radius: .35rem; background: #fff; padding: 2px 4px; }
.sup-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sup-logo .sup-ini { font-weight: 700; font-size: .8rem; color: var(--primary, #1f2a6b); letter-spacing: .02em; }
.sup-logo-lg { width: 96px; height: 40px; }
.sup-logo-lg .sup-ini { font-size: 1rem; }
.sup-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.po-steps .btn { border-radius: 999px; }
.po-steps .btn.po-step-on, .po-steps .btn.po-step-on:hover, .po-steps .btn.po-step-on:focus { background: var(--bs-primary, #1f2a6b); border-color: var(--bs-primary, #1f2a6b); color: #fff; }
.po-steps .btn.po-step-on .badge { background: #fff !important; color: var(--bs-primary, #1f2a6b) !important; }
.po-list td { white-space: nowrap; max-width: 22rem; overflow: hidden; text-overflow: ellipsis; }
.po-confirm .po-tipo-choice { padding: .35rem .75rem .35rem 2rem; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .5rem; }
.po-confirm .po-tipo-choice.po-tipo-on { border-color: var(--bs-warning, #ffc107); background: var(--bs-warning-bg-subtle, #fff3cd); }
/* Anteprima file in finestra (file-preview.js) */
.file-preview-stage { background: var(--surface-2, #f1f2f6); min-height: 60vh; }
.file-preview-page { display: block; margin: 0 auto 12px; background: #fff; box-shadow: var(--shadow, 0 1px 4px rgba(0,0,0,.15)); }
.file-preview-img { display: block; max-width: 100%; height: auto; margin: 0 auto; background: #fff; }
/* Selettore record: tipologia/stato accanto al nome (RecordPickerController::DETAILS) */
.ref-badge { background: var(--surface-2, #eef0f6); color: var(--text, #1c1d33); border: 1px solid var(--border, #dee2e6); font-weight: 600; }
.ref-badge-cliente { background: #e3f4ea; color: #146c43; border-color: #a3cfbb; }
.ref-badge-fornitore { background: #fff1d6; color: #8a5300; border-color: #f2c66d; }
.ref-badge-partner { background: #e7e9fb; color: #2f3aa8; border-color: #b4baf0; }
.ref-badge-prospect { background: #eef5fb; color: #0b5c8a; border-color: #a9cde6; }
/* Elenchi a tutta larghezza (Offerte): numeri, date, importi e stati su una riga; i testi lunghi vanno a capo con
   una larghezza minima, così la tabella usa tutto lo spazio senza colonne strette e righe alte. */
.list-fit td { white-space: nowrap; }
.list-fit td.lf-wrap { white-space: normal; min-width: 12rem; }
.list-fit thead input.form-control, .list-fit thead select.form-select { min-width: 6.5rem; }
/* Parole chiave a etichette (tags-input.js) */
.tags-input { min-height: calc(1.5em + .75rem + 2px); height: auto; cursor: text; }
.tags-input .tag-chip { background: var(--surface-2, #eef0f6); color: var(--text, #1c1d33); border: 1px solid var(--border, #dee2e6); font-weight: 500; display: inline-flex; align-items: center; }
.tags-input .tag-chip .btn-close { width: .5em; height: .5em; padding: .15em; }
.tags-input-field { border: 0; outline: 0; min-width: 10rem; background: transparent; color: inherit; }

/* ===================== Calcolatrice (barra in alto, Alt+C) ===================== */
.app-topbar .calc-launch { color: var(--fg); border: 1px solid var(--border-strong); background: var(--surface); white-space: nowrap; }
.app-topbar .calc-launch:hover, .app-topbar .calc-launch[aria-expanded="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.edh-calc { position: fixed; top: 64px; right: 16px; width: 340px; max-height: calc(100vh - 72px); overflow-y: auto; max-width: calc(100vw - 24px); z-index: 1080; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: 0 18px 48px rgba(15, 23, 42, .22); display: none; user-select: none; }
.edh-calc.open { display: block; }
.edh-calc-head { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); cursor: move; font-weight: 600; font-size: .9rem; }
.edh-calc-head .btn { padding: .1rem .35rem; }
.edh-calc-screen { padding: .5rem .75rem .25rem; text-align: right; }
.edh-calc-expr { min-height: 1.2rem; font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edh-calc-value { font-size: 1.85rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow-x: auto; user-select: text; }
.edh-calc-quick { display: grid; grid-template-columns: repeat(6, 1fr); gap: .3rem; padding: 0 .75rem .3rem; }
.edh-calc-quick .btn, .edh-calc-keys .btn { padding: .38rem 0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.edh-calc-quick .btn { font-size: .78rem; padding: .3rem 0; }
.edh-calc-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .2rem .75rem; }
.edh-calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; padding: .3rem .75rem .6rem; }
.edh-calc-keys .op { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 600; }
.edh-calc-keys .eq { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.edh-calc-table { margin: 0 .75rem .5rem; font-size: .8rem; }
.edh-calc-table td { padding: .15rem .3rem; font-variant-numeric: tabular-nums; }
.edh-calc-table tr { cursor: pointer; }
.edh-calc-table tr:hover td { background: var(--primary-soft); }
.edh-calc-tape { max-height: 120px; overflow-y: auto; margin: 0 .75rem .6rem; font-size: .78rem; border-top: 1px dashed var(--border); padding-top: .3rem; }
.edh-calc-tape div { display: flex; justify-content: space-between; gap: .5rem; cursor: pointer; padding: .05rem .2rem; border-radius: 4px; }
.edh-calc-tape div:hover { background: var(--primary-soft); }
.edh-calc-tape span:first-child { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) { .edh-calc { right: 8px; left: 8px; width: auto; top: 58px; } }

/* ===== Modifica dei record: tutta la larghezza e blocchi come le schede (bianchi, con intestazione) ===== */
.edh-form form > fieldset { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 1rem 1rem; margin-bottom: 1rem !important; min-width: 0; }
.edh-form form > fieldset > legend { float: left; width: calc(100% + 2rem); margin: 0 -1rem .25rem; padding: .8rem 1rem; font-family: var(--font-heading); font-weight: 600; font-size: 1rem; color: var(--heading); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.edh-form form > fieldset > legend + * { clear: both; margin-top: 0; }
.edh-form form > fieldset::after { content: ""; display: block; clear: both; }

/* Licenze clienti (143): linea temporale */
.lic-gantt-wrap{overflow-x:auto}
.lic-gantt{min-width:900px;position:relative}
.lic-row{display:flex;border-bottom:1px solid var(--bs-border-color-translucent,#eee);min-height:34px;align-items:stretch}
.lic-label{flex:0 0 260px;max-width:260px;padding:4px 8px;overflow:hidden}
.lic-track{position:relative;flex:1 1 auto;min-height:30px}
.lic-head{min-height:30px;font-size:.75rem;color:#6c757d}
.lic-month{position:absolute;top:6px;padding-left:3px;border-left:1px solid #e3e6ef;height:calc(100% - 6px);white-space:nowrap}
.lic-month.lic-year{border-left-color:#b9c0d4;font-weight:600}
.lic-group{background:#f4f6fb}
.lic-seg{position:absolute;top:7px;height:20px;background:#c7d2fe;border-left:1px solid #fff;font-size:.72rem;font-weight:600;text-align:center;line-height:20px;overflow:hidden;color:#1e2a78}
.lic-bar{position:absolute;top:6px;height:22px;border-radius:4px;font-size:.72rem;line-height:22px;padding:0 6px;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:3px}
.lic-attiva{background:#2e7d32}.lic-in_scadenza{background:#ef6c00}.lic-scaduta{background:#9e9e9e}.lic-futura{background:#1e88e5}
.lic-est{background-image:repeating-linear-gradient(45deg,rgba(255,255,255,.25) 0 6px,transparent 6px 12px)}
.lic-now{position:absolute;top:0;bottom:0;width:0;border-left:2px solid #c62828;z-index:2;pointer-events:none}
.lic-now-label{position:absolute;top:-2px;left:4px;background:#c62828;color:#fff;font-size:.68rem;padding:0 4px;border-radius:3px;white-space:nowrap}
.lic-legend .lic-sw{display:inline-block;width:12px;height:12px;border-radius:2px;vertical-align:-2px;margin:0 3px 0 10px}
.lic-legend .lic-now-sw{width:3px;background:#c62828}
@media (max-width:767.98px){.lic-label{flex-basis:170px;max-width:170px}}
/* Istanza non di produzione (APP_INSTANCE_LABEL nel .env, es. SVILUPPO) */
.instance-strip { background: #fdecea; color: #b3261e; border: 1px solid currentColor; border-radius: .6rem; padding: .45rem .8rem; font-size: .85rem; margin-bottom: 1rem; }
