/* =====================================================================
   PropertyCheck — foglio di stile unico
   Palette di sempre (blu #1a4fd6 su grigi freddi), forme morbide (angoli 4-8px,
   ombre leggere), font Inter ospitato in locale, spaziature su griglia di 4px.
   Tema: chiaro su :root; scuro dalla preferenza di sistema oppure con
   data-theme="dark" su <html> (switch nel menu laterale).
   Nessuno stile inline: la CSP è style-src 'self'.

   Indice: 1 token · 2 base · 3 layout (barra, menu, pagina) · 4 componenti
           (bottoni, card, avvisi, toast, moduli, badge, tabelle, menu, modali,
           stati vuoti, ricerca globale) · 5 pagine (home, elenco, dettaglio,
           nuova, manuale, accesso, aiuto) · 6 telefono · 7 meno animazioni
   ===================================================================== */

/* ===================================================================== 1. TOKEN */
@font-face {
    font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
    src: url("../fonts/inter-latin.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+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.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
                   U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* colori — tema chiaro: superfici bianche su grigio freddo, testo secondario sopra 7:1 */
    --bg: #e8ebf0;
    --surface: #ffffff;
    --surface-2: #f6f8fb;       /* zone rientrate dentro una card (intestazioni, piè) */
    --text: #101828;
    --muted: #475467;
    --border: #d5dae2;
    --line: #8a94a3;            /* bordi dei campi: 3:1 sul bianco */
    --primary: #1a4fd6;         /* link e accenti */
    --primary-solid: #1a4fd6;   /* riempimento di bottoni e selezioni (testo bianco sopra) */
    --primary-hover: #1641b3;
    --primary-text: #ffffff;
    --primary-soft: #dbe6ff;
    --ok-bg: #dcf2e4; --ok-fg: #0f5130; --ok-dot: #1f9d57;
    --err-bg: #fbe1e0; --err-fg: #8f1d1a; --err-dot: #d92d20;
    --warn-bg: #ffecc7; --warn-fg: #6e4200; --warn-dot: #dc8b05;
    --info-bg: #dde7ff; --info-fg: #173a9e; --info-dot: #1a4fd6;
    --neutral-bg: #e9ecf1; --neutral-fg: #1d2939; --neutral-dot: #8a94a3;
    --selected: #fffbe6;
    --table-head: #dfe4ec;
    --table-head-fg: #344054;
    --seg-bg: #dbe0e8;         /* binario degli interruttori a segmenti */
    --btn-bg: #f7f9fc;
    --btn-hover: #e9edf3;
    --btn-border: #a9b3c1;
    --overlay: rgba(16, 24, 40, .5);

    /* tipografia */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --fs-xs: .75rem;   /* 12px: etichette, badge */
    --fs-sm: .8125rem; /* 13px: testo secondario, tabelle dense */
    --fs-md: .875rem;  /* 14px: tabelle, menu */
    --fs-base: .9375rem; /* 15px: corpo */
    --fs-lg: 1.0625rem;  /* 17px: titoli di card */
    --fs-xl: 1.375rem;   /* 22px: titoli di sezione grandi */
    --fs-2xl: 1.75rem;   /* 28px: titolo di pagina, numeri KPI */
    --fw-normal: 400; --fw-medium: 500; --fw-semi: 600; --fw-bold: 700;

    /* forme */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;
    --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-2: 0 4px 8px -2px rgba(16, 24, 40, .10), 0 2px 4px -2px rgba(16, 24, 40, .06);
    --shadow-3: 0 20px 24px -4px rgba(16, 24, 40, .12), 0 8px 8px -4px rgba(16, 24, 40, .05);
    --ring: 0 0 0 3px rgba(26, 79, 214, .45);

    /* misure */
    --ctl: 38px;                /* altezza unica di bottoni, campi e menu a tendina */
    --ctl-sm: 32px;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
    --topbar-h: 56px;
    --sidebar: 240px;
    --sidebar-mini: 64px;
    --side-w: var(--sidebar);
    --z-menu: 60; --z-topbar: 30; --z-sidebar: 20; --z-toast: 90; --z-tip: 95;
    --speed: 120ms;
    --side-speed: 150ms;
    color-scheme: light;
}

/* Tema scuro: UNA sola definizione dei valori, ripetuta per i due selettori
   (preferenza di sistema senza scelta esplicita / scelta esplicita "scuro").
   Se cambi un valore, cambialo in entrambi i blocchi: sono identici. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #101318; --surface: #191d24; --surface-2: #1f242c; --text: #e6e8ec; --muted: #9aa4b5;
        --border: #2c323d; --line: #4a5261;
        --primary: #7ea2ff; --primary-solid: #3866e8; --primary-hover: #2f58cf; --primary-soft: #22325e;
        --ok-bg: #12301f; --ok-fg: #6fd39a; --ok-dot: #3fbf77;
        --err-bg: #3a1716; --err-fg: #ff8f8a; --err-dot: #f2554b;
        --warn-bg: #3a2a0c; --warn-fg: #f5c26b; --warn-dot: #f0a420;
        --info-bg: #17254a; --info-fg: #a9c0ff; --info-dot: #6b93ff;
        --neutral-bg: #262b35; --neutral-fg: #c7cdd7; --neutral-dot: #7d8796;
        --selected: #2e2a14; --table-head: #2a313d; --table-head-fg: #c7cdd7; --seg-bg: #0c0f13;
        --btn-bg: #252c37; --btn-hover: #303846; --btn-border: #56606f;
        --overlay: rgba(0, 0, 0, .6);
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 10px rgba(0, 0, 0, .45); --shadow-3: 0 20px 32px rgba(0, 0, 0, .55);
        --ring: 0 0 0 3px rgba(126, 162, 255, .55);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #101318; --surface: #191d24; --surface-2: #1f242c; --text: #e6e8ec; --muted: #9aa4b5;
    --border: #2c323d; --line: #4a5261;
    --primary: #7ea2ff; --primary-solid: #3866e8; --primary-hover: #2f58cf; --primary-soft: #22325e;
    --ok-bg: #12301f; --ok-fg: #6fd39a; --ok-dot: #3fbf77;
    --err-bg: #3a1716; --err-fg: #ff8f8a; --err-dot: #f2554b;
    --warn-bg: #3a2a0c; --warn-fg: #f5c26b; --warn-dot: #f0a420;
    --info-bg: #17254a; --info-fg: #a9c0ff; --info-dot: #6b93ff;
    --neutral-bg: #262b35; --neutral-fg: #c7cdd7; --neutral-dot: #7d8796;
    --selected: #2e2a14; --table-head: #2a313d; --table-head-fg: #c7cdd7; --seg-bg: #0c0f13;
    --btn-bg: #252c37; --btn-hover: #303846; --btn-border: #56606f;
    --overlay: rgba(0, 0, 0, .6);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 10px rgba(0, 0, 0, .45); --shadow-3: 0 20px 32px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(126, 162, 255, .55);
    color-scheme: dark;
}
:root.side-mini { --side-w: var(--sidebar-mini); }

/* ===================================================================== 2. BASE */
*, *::before, *::after { box-sizing: border-box; }
/* spazio della barra di scorrimento sempre riservato: la pagina non cambia larghezza quando il contenuto si accorcia */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
    margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden;
    font-family: var(--font); font-size: var(--fs-base); line-height: 1.5;
    font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }
h1 { font-size: var(--fs-2xl); line-height: 1.2; font-weight: var(--fw-bold); letter-spacing: -.02em; margin: 0 0 var(--s3); }
h2 { font-size: var(--fs-lg); line-height: 1.3; font-weight: var(--fw-semi); letter-spacing: -.01em; margin: var(--s6) 0 var(--s3); }
h3 { font-size: var(--fs-base); font-weight: var(--fw-semi); margin: var(--s4) 0 var(--s2); }
p { margin: 0 0 var(--s3); }
strong { font-weight: var(--fw-semi); }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); font-size: .92em; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.upper { text-transform: uppercase; }
.small { font-size: var(--fs-sm); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
kbd, .kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
    font: var(--fw-semi) 11px/1 var(--font); color: var(--muted); background: var(--surface-2);
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-sm); }

/* salta al contenuto: visibile solo col focus da tastiera */
.skip-link { position: fixed; left: var(--s3); top: -60px; z-index: 100; padding: var(--s2) var(--s4); background: var(--primary-solid);
    color: var(--primary-text); font-weight: var(--fw-semi); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.skip-link:focus { top: var(--s3); text-decoration: none; }

/* icone lineari (sprite nel layout) */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===================================================================== 3. LAYOUT */
.topbar {
    position: sticky; top: 0; z-index: var(--z-topbar); height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--s4); padding: 0 var(--s5);
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: var(--fw-bold); font-size: 1.05rem; letter-spacing: -.01em;
    color: var(--text); white-space: nowrap; min-width: 0; overflow: hidden; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 28px; height: 28px; }
.brand-sub { font-weight: var(--fw-medium); color: var(--muted); font-size: var(--fs-sm); }
.topbar .menu-btn { display: none; }

/* bottone della ricerca globale (Ctrl+K) */
.cerca-btn { display: flex; align-items: center; gap: var(--s2); flex: 0 1 360px; min-width: 0; height: 36px; margin-left: var(--s4);
    padding: 0 var(--s2) 0 var(--s3); background: var(--surface-2); color: var(--muted); border: 1px solid var(--btn-border);
    border-radius: var(--radius); font: inherit; font-size: var(--fs-md); cursor: pointer; text-align: left;
    transition: border-color var(--speed), background var(--speed); }
.cerca-btn:hover { border-color: var(--line); background: var(--surface); }
.cerca-btn .ico { width: 16px; height: 16px; }
.cerca-btn > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* menu utente */
.user { display: flex; align-items: center; gap: var(--s3); margin-left: auto; color: var(--muted); flex-shrink: 0; }
.user-menu > summary { display: flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s2) 0 4px; cursor: pointer;
    border-radius: var(--radius-pill); color: var(--text); font-weight: var(--fw-medium); list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--neutral-bg); }
.avatar { width: 28px; height: 28px; display: grid; place-items: center; flex: none; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary); font-weight: var(--fw-bold); font-size: var(--fs-xs); text-transform: uppercase; }
.user-menu .menu-lista { right: 0; left: auto; min-width: 15rem; }
.menu-intesta { padding: var(--s2) var(--s4) var(--s3); border-bottom: 1px solid var(--border); margin-bottom: var(--s1); }
.menu-intesta strong { display: block; color: var(--text); }

.sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: var(--z-sidebar); width: var(--side-w);
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border-right: 1px solid var(--border);
    transition: width var(--side-speed) ease-out;
}
.sidebar ~ main { margin-left: var(--side-w); transition: margin-left var(--side-speed) ease-out; }
.no-anim .sidebar, .no-anim .sidebar ~ main, .no-anim .lbl, .no-anim .collapse-ico { transition: none !important; }

.lbl { transition: opacity var(--side-speed); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) 0; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav .group { position: relative; padding: var(--s4) 0 var(--s2) 22px; white-space: nowrap;
    font-size: 11px; font-weight: var(--fw-semi); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.item {
    position: relative; flex: none; display: flex; align-items: center; gap: var(--s3); height: 38px;
    width: calc(100% - 2 * var(--s2)); margin: 0 var(--s2); padding: 0 var(--s3) 0 12px;
    border: 0; border-radius: var(--radius); background: none; color: var(--text); text-decoration: none; text-align: left;
    white-space: nowrap; font: inherit; font-size: var(--fs-md); font-weight: var(--fw-medium); cursor: pointer; transition: background var(--speed);
}
.item .ico { color: var(--muted); }
a.item:hover, button.item:hover { background: var(--neutral-bg); text-decoration: none; }
.item.active { background: var(--primary-soft); color: var(--primary); font-weight: var(--fw-semi); box-shadow: inset 3px 0 0 var(--primary-solid); }
.item.active .ico { color: var(--primary); }
.item .conta { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center;
    border-radius: var(--radius-pill); background: var(--warn-bg); color: var(--warn-fg); font-size: 11px; font-weight: var(--fw-bold); }
.side-mini .item .conta { position: absolute; top: 4px; left: 30px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; margin: 0; }
.side-foot { flex: none; border-top: 1px solid var(--border); padding: var(--s3) 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.collapse-ico { transition: transform var(--side-speed) ease-out; }

.theme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; margin: 0 var(--s2) var(--s2);
    background: var(--seg-bg); border: 1px solid var(--btn-border); border-radius: var(--radius); }
.theme button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; overflow: hidden; white-space: nowrap;
    border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-semi); cursor: pointer; }
.theme button .ico { width: 15px; height: 15px; }
.theme button:hover { color: var(--text); }
.theme button[aria-pressed="true"] { background: var(--primary-solid); color: var(--primary-text); box-shadow: var(--shadow-1); }

/* menu ridotto: solo icone, nella stessa posizione */
.side-mini .sidebar .lbl { opacity: 0; }
.side-mini .nav .group::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 12px; border-top: 1px solid var(--border); }
.side-mini .collapse-ico { transform: rotate(180deg); }
.side-mini .theme { grid-template-columns: 1fr; }
.side-mini .theme button[aria-pressed="false"], .side-mini .theme .lbl { display: none; }
.tip { position: fixed; z-index: var(--z-tip); pointer-events: none; padding: 6px 10px; white-space: nowrap; border-radius: var(--radius);
    background: #101828; color: #fff; font-size: var(--fs-sm); font-weight: var(--fw-medium); box-shadow: var(--shadow-2); }
.scrim { display: none; }

/* pagina a tutta larghezza */
.container { min-width: 0; padding: var(--s5) var(--s6) var(--s7); }
.container.narrow, .narrow { max-width: 760px; }
.container.wide { max-width: none; }
.container > h1 { margin-bottom: var(--s5); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head > div { min-width: 0; }
.page-head h1 { margin: 0; }
.page-head p.muted { margin: var(--s1) 0 0; }
.page-head .meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); color: var(--muted); }
.breadcrumb { display: flex; gap: var(--s2); align-items: center; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s2); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.aggiornato { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.aggiornato::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok-dot); animation: pulsa 2s ease-in-out infinite; }

/* ===================================================================== 4. COMPONENTI */

/* ---------- bottoni ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--ctl); padding: 0 var(--s4); line-height: 1.2;
    font: inherit; font-size: var(--fs-md); font-weight: var(--fw-semi); white-space: nowrap; cursor: pointer; text-decoration: none;
    border: 1px solid var(--btn-border); border-radius: var(--radius); background: var(--btn-bg); color: var(--text); box-shadow: var(--shadow-1);
    transition: background var(--speed), border-color var(--speed), color var(--speed), box-shadow var(--speed);
}
.btn:hover { text-decoration: none; background: var(--btn-hover); }
.btn:focus-visible { outline: 2px solid var(--primary-solid); outline-offset: 2px; box-shadow: var(--ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary-solid); border-color: var(--primary-solid); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { background: var(--btn-bg); color: var(--err-fg); border-color: var(--btn-border); }
.btn.danger:hover { background: var(--err-bg); border-color: var(--err-fg); }
.btn.danger.solid { background: var(--err-dot); border-color: var(--err-dot); color: #fff; }
.btn.danger.solid:hover { filter: brightness(.92); }
.btn.ghost { background: none; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--neutral-bg); }
.btn.small { min-height: var(--ctl-sm); padding: 0 var(--s3); font-size: var(--fs-sm); gap: 6px; }
.btn.full { width: 100%; margin-top: var(--s5); min-height: 44px; }
.btn .ico { width: 16px; height: 16px; display: block; margin-left: -2px; }
.btn.small .ico { width: 14px; height: 14px; }
.btn.modal-close .ico, .btn > .ico:only-child { margin: 0; }
.btn.icon { padding: 0; width: var(--ctl); }
.btn.small.icon { width: var(--ctl-sm); }
/* invio in corso: spinner al posto dell'icona, bottone disattivato (vedi app.js) */
.btn[aria-busy="true"] { pointer-events: none; opacity: .8; }
.btn[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: gira .8s linear infinite; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s3); }
.btn-row form { margin: 0; }
.page-head .btn-row { margin-top: 0; }
.actions { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s5); }

/* ---------- card ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
    padding: var(--s5); margin-bottom: var(--s4); min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card-title { margin: 0 0 var(--s1); font-size: var(--fs-lg); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.card-head .card-title { margin: 0; }
.card-head .conta-titolo { color: var(--muted); font-weight: var(--fw-medium); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin: var(--s6) 0 var(--s3); }
.section-title h2 { margin: 0; }

/* ---------- avvisi (nella pagina) ---------- */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); margin: 0 0 var(--s4);
    border: 1px solid transparent; border-radius: var(--radius); font-size: var(--fs-md); }
.alert > .ico { width: 18px; height: 18px; margin-top: 1px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: color-mix(in srgb, var(--ok-fg) 20%, transparent); }
.alert.err { background: var(--err-bg); color: var(--err-fg); border-color: color-mix(in srgb, var(--err-fg) 20%, transparent); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: color-mix(in srgb, var(--warn-fg) 20%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info-fg); border-color: color-mix(in srgb, var(--info-fg) 20%, transparent); }
p.alert { display: block; }
ul.errori { margin: var(--s2) 0 0; padding-left: var(--s5); max-height: 260px; overflow: auto; }

/* ---------- notifiche a comparsa (toast) ---------- */
.toasts { position: fixed; top: calc(var(--topbar-h) + var(--s3)); right: var(--s4); z-index: var(--z-toast);
    display: grid; gap: var(--s2); width: min(420px, calc(100vw - 2 * var(--s4))); pointer-events: none; }
.toast { pointer-events: auto; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: var(--s3); align-items: start;
    padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-left: 4px solid var(--tono, var(--info-dot)); border-radius: var(--radius);
    box-shadow: var(--shadow-3); font-size: var(--fs-md); animation: entra .2s ease-out; }
.toast .ico { width: 20px; height: 20px; color: var(--tono, var(--info-dot)); }
.toast.ok { --tono: var(--ok-dot); }
.toast.err { --tono: var(--err-dot); }
.toast-testo { overflow-wrap: anywhere; padding-top: 1px; }
.toast-chiudi { width: 28px; height: 28px; display: grid; place-items: center; margin: -4px -4px 0 0; padding: 0;
    border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; }
.toast-chiudi:hover { background: var(--neutral-bg); color: var(--text); }
.toast-chiudi .ico { width: 16px; height: 16px; color: inherit; }
.toast.esce { animation: esce .18s ease-in forwards; }
@keyframes entra { from { opacity: 0; transform: translateY(-6px); } }
@keyframes esce { to { opacity: 0; transform: translateX(16px); } }

/* ---------- moduli: etichetta sopra, campi allineati in alto ---------- */
form { margin: 0; }
label { display: block; font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: 20px; margin: var(--s3) 0 6px; }
label .muted { font-weight: var(--fw-normal); }
input, select, textarea {
    width: 100%; min-height: var(--ctl); padding: 0 var(--s3); font: inherit; font-size: var(--fs-base); color: var(--text);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    transition: border-color var(--speed), box-shadow var(--speed);
}
textarea { padding: var(--s2) var(--s3); min-height: 90px; }
input:not([type=checkbox]):not([type=radio]), select { height: var(--ctl); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-solid); box-shadow: 0 0 0 1px var(--primary-solid), var(--ring); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err-dot); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--err-dot) 25%, transparent); }
.hint { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.field-error { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; font-size: var(--fs-sm); color: var(--err-fg); font-weight: var(--fw-medium); }
.field-ok { display: flex; gap: 6px; align-items: center; margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ok-fg); font-weight: var(--fw-medium); }
.field-error .ico, .field-ok .ico { width: 16px; height: 16px; flex: none; }
input[type=file] { padding: 0 var(--s3) 0 0; font-size: var(--fs-md); line-height: calc(var(--ctl) - 2px); overflow: hidden; }
input[type=file]::file-selector-button { font: inherit; font-weight: var(--fw-semi); height: 100%; padding: 0 var(--s3); margin: 0 var(--s3) 0 0;
    border: 0; border-right: 1px solid var(--btn-border); background: var(--surface-2); color: var(--text); cursor: pointer; vertical-align: top; }
input[type=file]:hover::file-selector-button { background: var(--btn-hover); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--primary-solid); }
input[readonly] { background: var(--surface-2); }
/* password con bottone "occhio" (aggiunto da app.js) */
.pwd { position: relative; display: block; }
.pwd input { padding-right: 44px; }
.pwd-toggle { position: absolute; top: 1px; right: 1px; bottom: 1px; width: 40px; display: flex; align-items: center; justify-content: center;
    padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0; }
.pwd-toggle:hover, .pwd-toggle[aria-pressed="true"] { color: var(--text); }
.pwd-toggle .ico { width: 18px; height: 18px; }
input::-ms-reveal, input::-ms-clear { display: none; }

/* interruttore (checkbox con aspetto a levetta) */
.switch { display: flex; gap: var(--s3); align-items: flex-start; font-weight: var(--fw-normal); margin: var(--s4) 0 0; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; position: relative; width: 36px; height: 20px; margin-top: 1px; flex: none;
    border-radius: var(--radius-pill); background: var(--line); cursor: pointer; transition: background var(--speed); border: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-1); transition: transform var(--speed); }
.switch input:checked { background: var(--primary-solid); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--ring); }
.switch strong { display: block; }
.switch .muted { font-size: var(--fs-sm); }

.row { display: flex; gap: var(--s3); align-items: flex-start; }
.row > div { flex: 1; min-width: 0; }
.row > .grow { flex: 3; }
.row > .w-s { flex: 1; max-width: 110px; }
form.inline { display: inline-flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: 0; }
form.inline input, form.inline select { width: auto; min-width: 0; }
form.inline.wrap { display: flex; margin-top: var(--s4); }
form.stack { display: flex; flex-direction: column; gap: var(--s1); min-width: 220px; }
label.radio { display: flex; gap: var(--s2); align-items: flex-start; font-weight: var(--fw-normal); margin: var(--s2) 0; cursor: pointer; }
label.radio input { margin-top: 2px; }
.manuale-check { margin-top: var(--s4); }

/* zona di rilascio dei file (input file con stile; il trascinamento lo gestisce app.js) */
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 84px;
    margin: 0; padding: var(--s3) var(--s4); text-align: center; cursor: pointer; font-weight: var(--fw-normal);
    border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted);
    transition: border-color var(--speed), background var(--speed); }
.dropzone:hover, .dropzone.sopra { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.dropzone:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-titolo { font-weight: var(--fw-semi); color: var(--text); }
.dropzone .dz-tipo { font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .05em; color: var(--primary); }
.dropzone .dz-file { font-size: var(--fs-sm); color: var(--ok-fg); font-weight: var(--fw-semi); overflow-wrap: anywhere; }
.dropzone.scelto { border-style: solid; border-color: var(--ok-dot); background: var(--ok-bg); }
.dropzone.errato { border-color: var(--err-dot); background: var(--err-bg); }
.dropzone.errato .dz-file { color: var(--err-fg); }
.dropzones { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: var(--s3); }

/* ---------- interruttore a segmenti (viste, tipo verifica, densità) ---------- */
.viste, .segmenti { display: inline-flex; gap: 2px; padding: 3px; background: var(--seg-bg); border: 1px solid var(--btn-border); border-radius: var(--radius); }
.viste a, .segmenti a, .segmenti button { display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--s4); border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--muted); font: inherit; font-size: var(--fs-md); font-weight: var(--fw-semi); cursor: pointer; white-space: nowrap; }
.viste a:hover, .segmenti a:hover, .segmenti button:hover { color: var(--text); text-decoration: none; background: var(--btn-hover); }
.viste a.active:hover, .segmenti a.active:hover, .segmenti [aria-pressed="true"]:hover { color: var(--primary-text); background: var(--primary-hover); }
.viste a.active, .segmenti a.active, .segmenti [aria-pressed="true"] { background: var(--primary-solid); color: var(--primary-text); box-shadow: var(--shadow-1); }
.segmenti .ico { width: 16px; height: 16px; }
.segmenti.grande { display: flex; width: 100%; padding: 4px; }
.segmenti.grande a { flex: 1; justify-content: center; padding: var(--s2) var(--s3); font-size: var(--fs-base); }

/* ---------- badge di stato: pallino + etichetta (colore, forma e testo) ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: var(--radius-pill);
    font-size: var(--fs-xs); font-weight: var(--fw-semi); line-height: 18px; white-space: nowrap;
    background: var(--neutral-bg); color: var(--neutral-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--neutral-dot)); flex: none; }
.badge.nodot { padding: 2px 10px; }
.badge.nodot::before { display: none; }
.badge.big { font-size: var(--fs-md); padding: 4px 14px 4px 12px; }
.badge.big::before { width: 8px; height: 8px; }
.t-ok   { background: var(--ok-bg);   color: var(--ok-fg);   --dot: var(--ok-dot); }
.t-err  { background: var(--err-bg);  color: var(--err-fg);  --dot: var(--err-dot); }
.t-warn { background: var(--warn-bg); color: var(--warn-fg); --dot: var(--warn-dot); }
.t-info { background: var(--info-bg); color: var(--info-fg); --dot: var(--info-dot); }
.t-neutral { background: var(--neutral-bg); color: var(--neutral-fg); --dot: var(--neutral-dot); }
.badge.t-info.vivo::before { animation: pulsa 1.6s ease-in-out infinite; }
/* classi storiche per stato (badge s-<stato>, n-<statoNota>): stessi toni */
.s-completata, .n-completata { background: var(--ok-bg); color: var(--ok-fg); --dot: var(--ok-dot); }
.s-errore, .n-errore, .s-esito_negativo { background: var(--err-bg); color: var(--err-fg); --dot: var(--err-dot); }
.s-timeout, .n-timeout, .s-bloccata, .s-attesa_catasto, .s-attesa_conservatoria { background: var(--warn-bg); color: var(--warn-fg); --dot: var(--warn-dot); }
.s-in_coda, .s-catasto_in_corso, .s-elenco_note_in_corso, .s-note_in_corso, .n-in_corso, .n-da_richiedere { background: var(--info-bg); color: var(--info-fg); --dot: var(--info-dot); }
.n-elencata, .n-scartata { background: var(--neutral-bg); color: var(--neutral-fg); }

.tag { display: inline-flex; align-items: center; height: 20px; font-size: 11px; font-weight: var(--fw-semi); letter-spacing: .02em;
    color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 6px; margin-right: var(--s1); }
.tag-manuale { color: var(--warn-fg); background: var(--warn-bg); border-color: transparent; }

/* ---------- conteggi per stato (filtro) ---------- */
/* riquadri a larghezza fissa: non si ridimensionano quando cambiano filtro, numeri o larghezza della pagina */
.stats { display: grid; grid-template-columns: repeat(auto-fill, 168px); gap: var(--s3); margin-bottom: var(--s4); }
.stat { position: relative; display: grid; align-content: start; gap: 2px; padding: var(--s3) var(--s4); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.stat-num { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); font-weight: var(--fw-medium); }
.stat-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--neutral-dot)); flex: none; }
.stat-sub { font-size: var(--fs-xs); color: var(--muted); }
a.stat { color: var(--text); text-decoration: none; transition: border-color var(--speed), box-shadow var(--speed); }
a.stat:hover { border-color: var(--line); box-shadow: var(--shadow-2); text-decoration: none; }
a.stat.active { background: var(--primary-soft); border-color: var(--primary-solid); box-shadow: 0 0 0 2px var(--primary-solid), var(--shadow-1); }
a.stat.active .stat-label { color: var(--primary); font-weight: var(--fw-semi); }
a.stat.zero .stat-num { color: var(--muted); }
.stat.t-ok, .stat.t-err, .stat.t-warn, .stat.t-info, .stat.t-neutral { background: var(--surface); color: var(--text); }

/* ---------- schede, barra filtri, ricerca ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin: 0 0 var(--s4); overflow-x: auto; }
.tabs a { padding: var(--s2) var(--s3); color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: var(--fw-semi); font-size: var(--fs-md); white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs { border-bottom-color: var(--line); }
.tabs a { border-bottom-width: 3px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary-solid); }
.barra-vista { display: flex; align-items: center; justify-content: space-between; gap: var(--s3) var(--s4); flex-wrap: wrap; margin: 0 0 var(--s3); }
.barra-vista .sinistra, .barra-vista .destra { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
form.ricerca { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3) var(--s4); align-items: start; padding: var(--s4); margin-bottom: var(--s2); }
form.ricerca > div { min-width: 0; }
form.ricerca > div.grow { grid-column: span 2; }
form.ricerca label { margin: 0 0 6px; }
form.ricerca .ricerca-azioni { display: flex; gap: var(--s3); align-items: center; padding-top: 26px; }
form.ricerca-rapida { display: flex; gap: var(--s2); align-items: center; flex: 1 1 320px; max-width: 520px; }
.campo-ico { position: relative; flex: 1; min-width: 0; }
.campo-ico > .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.campo-ico > input { padding-left: 34px; }
select.filtro { width: auto; min-width: 11rem; }

/* ---------- tabelle ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
    overflow-x: auto; max-width: 100%; margin-bottom: var(--s4); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
:not(.table-wrap) > .table { border: 1px solid var(--border); border-radius: var(--radius); }
.table th, .table td { padding: 10px var(--s3); text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; font-size: var(--fs-md); }
.table th { background: var(--table-head); color: var(--table-head-fg); border-bottom: 1px solid var(--line); font-weight: var(--fw-semi); font-size: var(--fs-xs); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: var(--s4); }
.table th:last-child, .table td:last-child { padding-right: var(--s4); }
.table-wrap > .table thead tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
.table-wrap > .table thead tr:first-child th:last-child { border-top-right-radius: var(--radius-lg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.selected td, .table tbody tr.selected:hover td { background: var(--selected); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.data { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table th a.ordina { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a.ordina:hover { color: var(--text); text-decoration: none; }
.table th a.ordina .ico { width: 12px; height: 12px; }
.table th[aria-sort] { color: var(--text); }
/* densità compatta (scelta ricordata nel browser) */
.compatta .table th, .compatta .table td { padding-top: 5px; padding-bottom: 5px; }
.compatta .table td { font-size: var(--fs-sm); }
.esito { color: var(--muted); max-width: 360px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s3) var(--s4); flex-wrap: wrap; margin-top: var(--s4); font-size: var(--fs-md); }
.pagine { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pagine a, .pagine strong, .pagine span.puntini { min-width: 32px; height: 32px; padding: 0 var(--s2); display: inline-grid; place-items: center;
    border-radius: var(--radius); font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; color: var(--text); }
.pagine a { border: 1px solid var(--border); background: var(--surface); }
.pagine a:hover { border-color: var(--line); text-decoration: none; }
.pagine strong { background: var(--primary-solid); color: var(--primary-text); }
.pagine span.puntini { color: var(--muted); min-width: 16px; }
.per-pagina { display: inline-flex; align-items: center; gap: 4px; }
.per-pagina a, .per-pagina strong { min-width: 36px; height: 28px; padding: 0 var(--s2); display: inline-grid; place-items: center; border-radius: var(--radius-sm); }
.per-pagina strong { background: var(--neutral-bg); color: var(--text); }
.actions-cell { white-space: nowrap; }
.actions-cell form { margin: 0 0 var(--s1); }

/* tabella verifiche (elenco e avanzamento) */
.verifiche td { vertical-align: middle; }
.verifiche td.id a { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.verifiche td.soggetto { min-width: 12rem; }
.verifiche td.stato .err-text, .verifiche td.stato .warn-text { max-width: 15rem; }
.verifiche .nome { font-weight: var(--fw-semi); }
.oggetto-tag { margin-bottom: 4px; }
.verifiche th.azioni-th { text-align: right; }
.verifiche td.actions-cell { width: 1%; }
.verifiche tbody tr { cursor: default; }

/* azioni di riga: Apri, un'azione principale, menu "Altro" */
.azioni-riga { display: flex; gap: var(--s2); align-items: center; justify-content: flex-end; }
.azioni-riga form, .actions-cell .azioni-riga form { margin: 0; }
.azioni-riga form.inline.genera { gap: 0; flex-wrap: nowrap; }
.azioni-riga form.inline.genera select { max-width: 11rem; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0; }
.azioni-riga form.inline.genera .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.monitor .azioni-riga { flex-direction: column; align-items: stretch; width: 9.5rem; margin-left: auto; }
.monitor .azioni-riga > .btn, .monitor .azioni-riga > form > .btn, .monitor details.menu > summary { width: 100%; }
.monitor .azioni-riga form.inline.genera { display: grid; gap: var(--s1); }
.monitor .azioni-riga form.inline.genera select { max-width: none; width: 100%; border-right: 1px solid var(--line); border-radius: var(--radius); }
.monitor .azioni-riga form.inline.genera .btn { border-radius: var(--radius); }

/* ---------- menu a tendina ("Altro", menu utente) ---------- */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary.btn { background: var(--primary-soft); border-color: var(--primary-solid); color: var(--primary); }
details.menu .caret { width: 14px; height: 14px; transition: transform var(--speed); }
details.menu[open] .caret { transform: rotate(180deg); }
.menu-lista { position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-menu); min-width: 13rem; display: grid;
    padding: var(--s1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3); text-align: left; }
.menu-lista form { margin: 0; }
.menu-voce { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: var(--s2) var(--s3); background: none; border: 0; border-radius: var(--radius-sm);
    font: inherit; font-size: var(--fs-md); text-align: left; color: var(--text); text-decoration: none; white-space: nowrap; cursor: pointer; }
.menu-voce .ico { width: 16px; height: 16px; color: var(--muted); }
.menu-voce:hover, .menu-voce:focus-visible { background: var(--neutral-bg); text-decoration: none; outline: none; }
.menu-sep { height: 1px; margin: var(--s1) 0; background: var(--border); }
.menu-voce.pericolo { color: var(--err-fg); }
.menu-voce.pericolo .ico { color: var(--err-fg); }
.menu-lista > .menu-voce.pericolo:not(:first-child), .menu-lista > form + .menu-voce.pericolo { border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: var(--s1); }
.menu-voce.pericolo:hover { background: var(--err-bg); }

dl.grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s2) var(--s5); margin: 0 0 var(--s3); font-size: var(--fs-md); }
dl.grid dt { color: var(--muted); }
dl.grid dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- passi (vista avanzamento): mini-stepper a segmenti ---------- */
.p-fatto { --passo: var(--ok-dot); }
.p-in_attesa { --passo: var(--info-dot); }
.p-azione, .p-bloccato { --passo: var(--warn-dot); }
.p-errore, .p-negativo { --passo: var(--err-dot); }
.p-manuale { --passo: var(--neutral-dot); }
.p-non_necessario, .p-da_fare { --passo: var(--line); --vuoto: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0 0 var(--s3); font-size: var(--fs-sm); color: var(--muted); }
.step { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.step::before, ol.passi li::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--passo, var(--line)); background: var(--passo, var(--line)); }
.p-non_necessario::before, .p-da_fare::before { background: transparent !important; }
.p-in_attesa::before { animation: pulsa 1.6s ease-in-out infinite; }
@keyframes pulsa { 50% { opacity: .35; } }
/* barra a 4 segmenti sopra l'elenco dei passi */
.segmenti-passi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-bottom: 6px; max-width: 15rem; }
.segmenti-passi span { height: 4px; border-radius: var(--radius-pill); background: var(--passo, var(--border)); }
.segmenti-passi .p-non_necessario, .segmenti-passi .p-da_fare { background: var(--border); }
.segmenti-passi .p-in_attesa { animation: pulsa 1.6s ease-in-out infinite; }
ol.passi { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; min-width: 15rem; }
ol.passi li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s2); align-items: center; font-size: var(--fs-sm); }
.passo-stato { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.p-errore .passo-stato, .p-negativo .passo-stato, .p-azione .passo-stato, .p-bloccato .passo-stato { color: var(--passo); font-weight: var(--fw-semi); }
.p-azione .passo-stato, .p-bloccato .passo-stato { color: var(--warn-fg); }
.p-errore .passo-stato, .p-negativo .passo-stato { color: var(--err-fg); }
.p-non_necessario .passo-nome, .p-da_fare .passo-nome { color: var(--muted); }
.err-text { color: var(--err-fg); font-size: var(--fs-sm); margin-top: var(--s1); max-width: 280px; white-space: normal; }
.warn-text { color: var(--warn-fg); }

/* documenti scaricabili: formato + nome leggibile, uno per riga */
.docs { display: grid; gap: 4px; min-width: 10rem; }
.doc { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--text); text-decoration: none; }
.doc:hover { text-decoration: none; }
.doc:hover .doc-nome { color: var(--primary); text-decoration: underline; }
.doc-ext { flex: none; width: 2.6rem; padding: 1px 0; text-align: center; font-size: 10px; font-weight: var(--fw-bold); letter-spacing: .03em;
    border-radius: var(--radius-sm); color: var(--neutral-fg); background: var(--neutral-bg); }
.doc-ext.pdf { background: var(--err-bg); color: var(--err-fg); }
.doc-ext.xml { background: var(--info-bg); color: var(--info-fg); }
.doc-zip { white-space: nowrap; margin-top: var(--s1); padding-top: var(--s1); border-top: 1px dashed var(--border); color: var(--primary); font-weight: var(--fw-semi); }
.doc-zip .ico { flex: none; width: 2.6rem; height: 14px; }

/* barra di avanzamento (<progress>): niente stili inline, il valore è un attributo */
progress.barra { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: var(--radius-pill);
    background: var(--neutral-bg); overflow: hidden; color: var(--primary-solid); }
progress.barra::-webkit-progress-bar { background: var(--neutral-bg); border-radius: var(--radius-pill); }
progress.barra::-webkit-progress-value { background: var(--primary-solid); border-radius: var(--radius-pill); transition: width .3s ease; }
progress.barra::-moz-progress-bar { background: var(--primary-solid); border-radius: var(--radius-pill); }
progress.barra.alta::-webkit-progress-value { background: var(--warn-dot); }
progress.barra.alta::-moz-progress-bar { background: var(--warn-dot); }

/* spinner: anello che gira; con meno animazioni diventa un anello fermo tratteggiato */
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- finestre modali ---------- */
dialog.modal { width: min(560px, calc(100vw - 2 * var(--s4))); max-height: calc(100dvh - 2 * var(--s5)); margin: auto; padding: 0;
    border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); }
dialog.modal.large { width: min(960px, calc(100vw - 2 * var(--s4))); height: calc(100dvh - 2 * var(--s5)); }
dialog.modal[open] { display: flex; flex-direction: column; animation: apri .16s ease-out; }
dialog.modal::backdrop { background: var(--overlay); }
@keyframes apri { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s4);
    padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-head form { margin: 0; }
.modal-close { min-width: 32px; justify-content: center; box-shadow: none; border-color: transparent; background: none; }
.modal-close:hover { background: var(--neutral-bg); }
.modal-body { flex: 1; overflow-y: auto; padding: var(--s4) var(--s5) var(--s5); display: flex; flex-direction: column; }
.modal-body > .actions { margin-top: auto; padding-top: var(--s5); }
.modal-body.flush { padding: 0; }
.modal-body iframe { flex: 1; width: 100%; border: 0; background: #525659; }
body.modal-aperto { overflow: hidden; }
/* conferma di un'azione (Rilancia, Blocca, Elimina…): finestra piccola con icona */
dialog.conferma { width: min(440px, calc(100vw - 2 * var(--s4))); }
.conferma-corpo { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s4); padding: var(--s5) var(--s5) var(--s2); }
.conferma-icona { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--warn-bg); color: var(--warn-fg); }
.conferma.pericolo .conferma-icona { background: var(--err-bg); color: var(--err-fg); }
.conferma-icona .ico { width: 20px; height: 20px; }
.conferma-corpo h2 { margin: 0 0 var(--s1); font-size: var(--fs-lg); }
.conferma-corpo p { margin: 0; color: var(--muted); font-size: var(--fs-md); }
.conferma .actions { margin: 0; padding: var(--s4) var(--s5) var(--s5); }

/* ---------- stati vuoti ---------- */
.empty { color: var(--muted); padding: var(--s6) var(--s4); text-align: center; background: var(--surface);
    border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.vuoto { display: grid; justify-items: center; gap: var(--s2); padding: var(--s7) var(--s4); text-align: center;
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.vuoto-icona { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); margin-bottom: var(--s2); }
.vuoto-icona .ico { width: 24px; height: 24px; }
.vuoto h2, .vuoto h3 { margin: 0; font-size: var(--fs-lg); }
.vuoto p { margin: 0 0 var(--s2); color: var(--muted); max-width: 46ch; }

/* ---------- ricerca globale (Ctrl+K) ---------- */
dialog.cmdk { width: min(640px, calc(100vw - 2 * var(--s4))); margin: 12vh auto auto; padding: 0; max-height: 70vh;
    border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3); }
dialog.cmdk[open] { display: flex; flex-direction: column; animation: apri .14s ease-out; }
dialog.cmdk::backdrop { background: var(--overlay); }
.cmdk-campo { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s4); border-bottom: 1px solid var(--border); }
.cmdk-campo .ico { color: var(--muted); }
.cmdk-campo input { border: 0; box-shadow: none !important; height: 54px; padding: 0; font-size: var(--fs-lg); background: none; }
.cmdk-risultati { overflow-y: auto; padding: var(--s2); min-height: 0; }
.cmdk-gruppo { padding: var(--s2) var(--s3) var(--s1); font-size: 11px; font-weight: var(--fw-semi); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cmdk-voce { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2) var(--s3);
    border-radius: var(--radius); color: var(--text); text-decoration: none; }
.cmdk-voce:hover, .cmdk-voce[aria-selected="true"] { background: var(--primary-soft); text-decoration: none; }
.cmdk-voce .cmdk-id { font-weight: var(--fw-bold); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3ch; }
.cmdk-voce .cmdk-testo { min-width: 0; }
.cmdk-voce .cmdk-testo > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-voce .ico { color: var(--muted); width: 18px; height: 18px; }
.cmdk-vuoto { padding: var(--s5) var(--s4); text-align: center; color: var(--muted); font-size: var(--fs-md); }
.cmdk-piede { display: flex; gap: var(--s4); flex-wrap: wrap; padding: var(--s2) var(--s4); border-top: 1px solid var(--border);
    background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cmdk-piede span { display: inline-flex; gap: 6px; align-items: center; }
dl.scorciatoie { display: grid; grid-template-columns: max-content 1fr; gap: var(--s3) var(--s5); margin: 0; align-items: center; }
dl.scorciatoie dt { display: flex; gap: 4px; }
dl.scorciatoie dd { margin: 0; }

/* ===================================================================== 5. PAGINE */

/* ---------- home ---------- */
.saluto { margin-bottom: var(--s5); }
.saluto h1 { margin: 0; }
.saluto p { margin: var(--s1) 0 0; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi { display: grid; gap: var(--s1); padding: var(--s4) var(--s5); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); text-decoration: none;
    transition: border-color var(--speed), box-shadow var(--speed); }
a.kpi:hover { text-decoration: none; border-color: var(--line); box-shadow: var(--shadow-2); }
.kpi-testa { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--muted); }
.kpi-icona { width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius); background: var(--neutral-bg); color: var(--neutral-fg); }
.kpi-icona .ico { width: 18px; height: 18px; }
.kpi.t-ok .kpi-icona { background: var(--ok-bg); color: var(--ok-fg); }
.kpi.t-warn .kpi-icona { background: var(--warn-bg); color: var(--warn-fg); }
.kpi.t-err .kpi-icona { background: var(--err-bg); color: var(--err-fg); }
.kpi.t-info .kpi-icona { background: var(--info-bg); color: var(--info-fg); }
.kpi.t-ok, .kpi.t-warn, .kpi.t-err, .kpi.t-info { background: var(--surface); color: var(--text); }
.kpi.evidenza { border-color: var(--warn-dot); box-shadow: 0 0 0 1px var(--warn-dot), var(--shadow-1); }
.kpi-num { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-nota { font-size: var(--fs-sm); color: var(--muted); }
.home-griglia { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s4); align-items: start; }
.home-griglia > .card { margin-bottom: 0; }
ul.lista { list-style: none; margin: 0; padding: 0; }
ul.lista > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3) 0; border-top: 1px solid var(--border); }
ul.lista > li:first-child { border-top: 0; padding-top: 0; }
ul.lista > li:last-child { padding-bottom: 0; }
.lista-titolo { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-weight: var(--fw-semi); }
.lista-titolo a { color: var(--text); }
.lista-titolo a:hover { color: var(--primary); }
.lista-sotto { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.card-piede { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); font-size: var(--fs-md); }
ol.checklist { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s2); counter-reset: passo; }
ol.checklist li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s3); align-items: start; counter-increment: passo; }
ol.checklist li::before { content: counter(passo); width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
    border: 1.5px solid var(--line); color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
ol.checklist li.fatto::before { content: "✓"; border-color: var(--ok-dot); background: var(--ok-dot); color: #fff; }
ol.checklist li.fatto .cl-titolo { color: var(--muted); text-decoration: line-through; }
.cl-titolo { font-weight: var(--fw-semi); }
.cl-testo { font-size: var(--fs-sm); color: var(--muted); }
.avanzamento-setup { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s2); font-size: var(--fs-sm); color: var(--muted); }
.avanzamento-setup progress { flex: 1; }

/* ---------- dettaglio: riepilogo dell'esito (rischio) ---------- */
.rischio { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: var(--s4); align-items: start; padding: var(--s5);
    margin-bottom: var(--s4); border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-1);
    border-left: 5px solid var(--dot, var(--neutral-dot)); }
.rischio.t-ok, .rischio.t-err, .rischio.t-warn { background: var(--surface); color: var(--text); }
.rischio-icona { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-bg); color: var(--neutral-fg); }
.rischio.t-ok .rischio-icona { background: var(--ok-bg); color: var(--ok-fg); }
.rischio.t-err .rischio-icona { background: var(--err-bg); color: var(--err-fg); }
.rischio.t-warn .rischio-icona { background: var(--warn-bg); color: var(--warn-fg); }
.rischio-icona .ico { width: 24px; height: 24px; stroke-width: 2.2; }
.rischio-etichetta { margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rischio.t-ok .rischio-etichetta { color: var(--ok-fg); }
.rischio.t-err .rischio-etichetta { color: var(--err-fg); }
.rischio.t-warn .rischio-etichetta { color: var(--warn-fg); }
.rischio-titolo { margin: 2px 0 var(--s1); font-size: var(--fs-xl); line-height: 1.25; letter-spacing: -.01em; }
.rischio-testo { margin: 0; color: var(--muted); }
ul.rischio-voci { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s2); }
ul.rischio-voci li a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
    padding: var(--s2) var(--s3); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
ul.rischio-voci li a:hover { border-color: var(--err-dot); text-decoration: none; }
.rv-tipo { font-weight: var(--fw-semi); }
.rv-dett { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-importo { font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rischio-fatti { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s3); font-size: var(--fs-sm); color: var(--muted); }
.rischio-fatti strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- dettaglio: "adesso" + fasi in un'unica card ---------- */
.stato-card { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 2fr); gap: 0; padding: 0; overflow: hidden; }
.stato-card > .ora { padding: var(--s5); }
.stato-card > .fasi { padding: var(--s5); background: var(--surface-2); border-left: 1px solid var(--border); }
.fasi .card-title { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: var(--fw-semi); }
.ora { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: var(--s4); align-items: start; }
.ora-lavoro   { --accento: var(--primary);  --accento-bg: var(--info-bg); }
.ora-azione   { --accento: var(--warn-fg);  --accento-bg: var(--warn-bg); }
.ora-sospesa  { --accento: var(--warn-fg);  --accento-bg: var(--warn-bg); }
.ora-errore   { --accento: var(--err-fg);   --accento-bg: var(--err-bg); }
.ora-conclusa { --accento: var(--ok-fg);    --accento-bg: var(--ok-bg); }
.stato-card.ora-lavoro { border-top: 3px solid var(--info-dot); }
.stato-card.ora-azione, .stato-card.ora-sospesa { border-top: 3px solid var(--warn-dot); }
.stato-card.ora-errore { border-top: 3px solid var(--err-dot); }
.stato-card.ora-conclusa { border-top: 3px solid var(--ok-dot); }
.ora-icona { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
    background: var(--accento-bg); color: var(--accento); }
.ora-icona .ico { width: 24px; height: 24px; stroke-width: 2.2; }
.ora-icona .spin { width: 24px; height: 24px; border-width: 3px; }
.ora-etichetta { margin: 0; font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .06em; text-transform: uppercase; color: var(--accento); }
.ora-titolo { margin: 2px 0 var(--s1); font-size: var(--fs-xl); line-height: 1.3; letter-spacing: -.01em; }
.ora-dettaglio { margin: 0 0 var(--s2); color: var(--text); overflow-wrap: anywhere; }
.ora-errore .ora-dettaglio { color: var(--err-fg); }
.ora-prossimo { margin: 0; color: var(--muted); }
.ora-prossimo strong { color: var(--text); }
.ora .btn-row { margin-top: var(--s4); }
.ora .manuale { margin-top: var(--s4); }
.tentativi { margin-top: var(--s4); max-width: 560px; }
.tentativi-riga { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.tentativi p { margin: 6px 0 0; }

.dettaglio-griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--s4); align-items: start; margin-bottom: var(--s4); }
.dettaglio-griglia > .card { margin-bottom: 0; }

/* fasi: segno tondo collegato da una linea verticale */
ol.stepper { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.fase { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s3); padding-bottom: var(--s4); }
.fase:last-child { padding-bottom: 0; }
.fase:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--border); }
.fase.f-fatta:not(:last-child)::after, .fase.f-manuale:not(:last-child)::after { background: var(--ok-dot); }
.fase-segno { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
    border: 2px solid var(--segno, var(--line)); background: var(--segno-bg, var(--surface)); color: var(--segno, var(--muted)); }
.fase-segno .ico { width: 14px; height: 14px; stroke-width: 3; }
.fase-segno .spin { width: 14px; height: 14px; }
.f-fatta   { --segno: var(--ok-dot);   --segno-bg: var(--ok-bg); }
.f-manuale { --segno: var(--neutral-dot); --segno-bg: var(--neutral-bg); }
.f-in_corso { --segno: var(--primary); --segno-bg: var(--info-bg); }
.f-azione, .f-sospesa { --segno: var(--warn-dot); --segno-bg: var(--warn-bg); }
.f-errore  { --segno: var(--err-dot);  --segno-bg: var(--err-bg); }
.f-saltata .fase-segno { border-style: dashed; }
.fase-corpo { min-width: 0; padding-top: 3px; }
.fase-testa { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; align-items: baseline; }
.fase-titolo { font-weight: var(--fw-semi); font-size: var(--fs-md); }
.f-da_fare .fase-titolo, .f-saltata .fase-titolo { color: var(--muted); font-weight: var(--fw-medium); }
.fase-stato { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-in_corso .fase-stato { color: var(--primary); font-weight: var(--fw-semi); }
.f-azione .fase-stato, .f-sospesa .fase-stato { color: var(--warn-fg); font-weight: var(--fw-semi); }
.f-errore .fase-stato { color: var(--err-fg); font-weight: var(--fw-semi); }
.fase-nota { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }

/* formalità: le pregiudizievoli sono evidenziate e si possono mostrare da sole */
.table tr.pregiudizievole td:first-child { box-shadow: inset 4px 0 0 var(--err-dot); }
.table tr.pregiudizievole td { background: color-mix(in srgb, var(--err-bg) 35%, var(--surface)); }
.table tr.pregiudizievole:target td { background: var(--err-bg); }
.pregiud { display: inline-flex; align-items: center; gap: 4px; font-weight: var(--fw-semi); color: var(--err-fg); white-space: nowrap; }
.pregiud .ico { width: 14px; height: 14px; }
.solo-pregiud .table tr:not(.pregiudizievole) { display: none; }
.filtro-check { display: inline-flex; gap: var(--s2); align-items: center; margin: 0; font-weight: var(--fw-medium); font-size: var(--fs-md); cursor: pointer; }

/* ---------- nuova verifica ---------- */
.nuova { max-width: none; }
.nuova .segmenti.grande { margin-bottom: var(--s5); }
.nuova-intro { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: var(--s3); align-items: start; padding: var(--s4);
    margin-bottom: var(--s5); border-radius: var(--radius); background: var(--primary-soft); color: var(--text); font-size: var(--fs-md); }
.nuova-intro .ico { width: 24px; height: 24px; color: var(--primary); margin: 4px 0 0 4px; }
.nuova-intro strong { display: block; margin-bottom: 2px; }
.nuova-intro ol { margin: var(--s1) 0 0; padding-left: var(--s5); color: var(--muted); }
.riepilogo-invio { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap;
    margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--border); }
.riepilogo-invio p { margin: 0; font-size: var(--fs-sm); color: var(--muted); max-width: 52ch; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--s4); align-items: start; }
.two-col > .card { margin-bottom: 0; }
.import-excel { margin-top: var(--s4); }
.anteprima-sintesi { display: flex; gap: var(--s3); flex-wrap: wrap; margin: 0 0 var(--s4); }
ul.modelli { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
ul.modelli li { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.campi { margin-bottom: var(--s4); }
.campi h3 { margin: 0 0 var(--s1); }
.nuovo-token { border-color: var(--warn-dot); }
input.token { font-size: .95rem; }
.copia-riga { display: flex; gap: var(--s2); }
.copia-riga input { flex: 1; }
form.inline.genera { margin: 0 0 var(--s1); flex-wrap: nowrap; }
form.inline.genera select { width: auto; max-width: 14rem; min-height: var(--ctl-sm); height: var(--ctl-sm); padding: 0 var(--s2); font-size: var(--fs-sm); }
details.segnaposto { margin-top: var(--s6); }
details.segnaposto > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-lg); font-weight: var(--fw-semi); }
details.segnaposto > summary::-webkit-details-marker { display: none; }
details.segnaposto > summary::before { content: "+"; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); font-weight: var(--fw-bold); }
details.segnaposto[open] > summary::before { content: "\2212"; }
details.segnaposto > summary + * { margin-top: var(--s3); }

/* ---------- procedura manuale ---------- */
.manuale { border: 1px solid color-mix(in srgb, var(--warn-dot) 45%, transparent); background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface));
    border-radius: var(--radius-lg); padding: var(--s4); margin: var(--s1) 0 var(--s2); white-space: normal; }
.manuale-titolo { font-weight: var(--fw-semi); color: var(--text); margin-bottom: 2px; }
.manuale-testo { font-size: var(--fs-sm); color: var(--muted); margin: 0 0 var(--s3); }
.manuale-form { display: grid; gap: var(--s3); margin-bottom: var(--s3); }
.manuale .btn-row { margin-top: 0; }
.manuale .oppure { font-size: var(--fs-sm); color: var(--muted); }
.file-label { display: inline-flex; align-items: center; gap: var(--s1); font-weight: var(--fw-semi); font-size: var(--fs-sm); margin: 0; }

/* ---------- accesso, errori ---------- */
.login-page { display: flex; flex-direction: column; align-items: center; min-height: 100vh;
    padding: clamp(var(--s7), 12vh, 120px) var(--s4) var(--s6);
    background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent 70%), var(--bg); }
@supports (height: 100svh) { .login-page { padding-top: clamp(var(--s7), 12svh, 120px); } }
.login-box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3); padding: var(--s6); }
.logo-grande { display: block; width: 56px; height: 56px; margin: 0 auto var(--s3); }
.login-box h1 { text-align: center; font-size: var(--fs-xl); }
.login-box > p.muted:first-of-type { text-align: center; }
.login-piede { margin-top: var(--s5); font-size: var(--fs-xs); color: var(--muted); text-align: center; max-width: 400px; }
input.codice { font-size: 1.6rem; letter-spacing: .5rem; text-align: center; min-height: 52px; font-family: var(--font-mono); }
.login-extra { display: flex; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); font-size: var(--fs-md); }
.login-theme { position: fixed; top: var(--s3); right: var(--s3); }
.login-theme .theme { margin: 0; }
.login-theme .theme button { padding: 0 var(--s3); }
.errore-pagina { display: grid; justify-items: center; text-align: center; gap: var(--s2); padding: var(--s7) var(--s4); }
.errore-codice { font-size: 4rem; font-weight: var(--fw-bold); letter-spacing: -.04em; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.errore-pagina h1 { margin: var(--s2) 0 0; font-size: var(--fs-xl); }
.errore-pagina p { color: var(--muted); max-width: 52ch; }

/* ---------- aiuto ---------- */
.aiuto-griglia { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.aiuto .indice { position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.aiuto .indice ol { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: 2px; font-size: var(--fs-md); }
.aiuto .indice a { display: block; padding: 4px var(--s2); border-radius: var(--radius-sm); color: var(--muted); }
.aiuto .indice a:hover { background: var(--neutral-bg); color: var(--text); text-decoration: none; }
.aiuto section.card { scroll-margin-top: calc(var(--topbar-h) + var(--s4)); }
.aiuto h2 { margin-top: 0; }
.aiuto h3 { margin: var(--s4) 0 var(--s1); }
.aiuto p, .aiuto li { max-width: 95ch; }
.codice-esempio { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s2) var(--s3); overflow-x: auto; font-size: var(--fs-sm); }
dl.faq dt { font-weight: var(--fw-semi); margin-top: var(--s3); }
dl.faq dd { margin: var(--s1) 0 0; color: var(--muted); }
.aiuto-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--muted); }
.aiuto-link .ico { width: 16px; height: 16px; }

/* ===================================================================== 6. TELEFONO (sotto i 768px) */
@media (max-width: 1100px) {
    .home-griglia { grid-template-columns: minmax(0, 1fr); }
    .stato-card { grid-template-columns: minmax(0, 1fr); }
    .stato-card > .fasi { border-left: 0; border-top: 1px solid var(--border); }
    .aiuto-griglia { grid-template-columns: minmax(0, 1fr); }
    .aiuto .indice { position: static; }
}
@media (max-width: 767px) {
    dialog.modal { width: calc(100vw - 2 * var(--s3)); }
    dialog.modal.large { height: calc(100dvh - 2 * var(--s3)); }
    :root, :root.side-mini { --side-w: min(280px, 85vw); }
    .side-mini .sidebar .lbl { opacity: 1; }
    .side-mini .nav .group::after { display: none; }
    .side-mini .theme { grid-template-columns: repeat(3, 1fr); }
    .side-mini .theme button[aria-pressed="false"] { display: flex; }
    .side-mini .theme .lbl { display: inline; }
    .side-mini .item .conta { position: static; margin-left: auto; }
    .collapse-btn { display: none !important; }

    .topbar { padding: 0 max(var(--s3), env(safe-area-inset-right, 0px)) 0 max(var(--s3), env(safe-area-inset-left, 0px)); gap: var(--s2); }
    .topbar .menu-btn { display: inline-flex; min-height: 40px; padding: 0 var(--s3); }
    .brand { font-size: .95rem; }
    .brand .brand-nome { display: none; }
    .cerca-btn { flex: 1 1 auto; margin-left: 0; }
    .cerca-btn kbd, .user-menu .nome-utente { display: none; }
    .sidebar { transform: translateX(-105%); transition: transform var(--side-speed) ease-out; }
    .menu-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
    .menu-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 15; background: var(--overlay); }
    .sidebar ~ main { margin-left: 0; }
    .item { height: 44px; }

    .container { padding: var(--s4) max(var(--s4), env(safe-area-inset-right, 0px)) var(--s7) max(var(--s4), env(safe-area-inset-left, 0px)); }
    h1 { font-size: 1.45rem; }
    .card { padding: var(--s4); }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head > .btn { min-height: 44px; }
    .page-head > .badge { align-self: flex-start; }
    .stato-card > .ora, .stato-card > .fasi { padding: var(--s4); }
    .ora, .rischio { grid-template-columns: minmax(0, 1fr); }
    .ora-icona, .rischio-icona { width: 40px; height: 40px; }

    .row { flex-direction: column; gap: 0; }
    .row > .w-s { max-width: none; }
    input, select, .btn { min-height: 44px; }
    input, select, textarea { font-size: 16px; }
    .btn.small, form.inline.genera select { min-height: 40px; }
    .actions .btn { flex: 1; }
    form.inline:not(.genera) { display: flex; width: 100%; }
    form.inline:not(.genera) input, form.inline:not(.genera) select { flex: 1 1 160px; }
    form.ricerca { grid-template-columns: minmax(0, 1fr); }
    form.ricerca > div.grow { grid-column: auto; }
    form.ricerca .ricerca-azioni { padding-top: 0; }
    form.ricerca .ricerca-azioni .btn { flex: 1; }
    form.ricerca-rapida { max-width: none; }
    form.stack { min-width: 0; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
    .kpi { padding: var(--s3) var(--s4); }
    .kpi-num { font-size: var(--fs-xl); }
    dl.grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
    dl.grid dt { margin-top: var(--s2); font-size: var(--fs-sm); }
    .login-box { padding: var(--s5) var(--s4); }
    .segmenti.grande a { padding: var(--s2); font-size: var(--fs-md); }
    .pager { justify-content: center; }
    .toasts { left: var(--s3); right: var(--s3); width: auto; }

    /* tabelle "a schede": ogni riga è un blocco, ogni cella mostra la sua etichetta */
    .table-wrap.cards { border: 0; background: none; overflow: visible; box-shadow: none; border-radius: 0; }
    .cards .table, .cards .table tbody, .cards .table tr, .cards .table td { display: block; }
    .cards .table { background: none; border: 0; }
    .cards .table thead { display: none; }
    .cards .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
        margin-bottom: var(--s3); padding: var(--s3) var(--s4); }
    .cards .table tr.pregiudizievole { border-left: 4px solid var(--err-dot); }
    .cards .table tbody tr td, .cards .table tbody tr:hover td { background: none; box-shadow: none; }
    .cards .table td { border: 0; padding: var(--s1) 0 !important; max-width: none; white-space: normal; }
    .cards .table td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: var(--fw-semi); color: var(--muted); }
    .cards .table td:empty { display: none; }
    .cards .table td.actions-cell { border-top: 1px solid var(--border); margin-top: var(--s2); padding-top: var(--s3) !important; display: flex; flex-wrap: wrap; gap: var(--s2); }
    .cards .table td.actions-cell:not(:has(a, button, select)) { display: none; }
    .cards .actions-cell form { margin: 0; }
    .cards form.inline { display: flex; width: 100%; }
    .cards form.inline.genera select { flex: 1 1 auto; min-width: 0; max-width: none; }
    .cards .actions-cell > .btn, .cards .actions-cell > form:not(.genera) { flex: 1 1 auto; }
    .cards .actions-cell > form:not(.genera) .btn { width: 100%; }

    .cards .verifiche tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s1) var(--s3); align-items: center; }
    .cards .verifiche td { grid-column: 1 / -1; }
    .cards .verifiche td.id { grid-column: 1; grid-row: 1; font-weight: var(--fw-bold); }
    .cards .verifiche td.stato { grid-column: 2 / -1; grid-row: 1; justify-self: end; text-align: right; }
    .cards .verifiche td.actions-cell { width: auto; }
    .cards .azioni-riga, .cards .monitor .azioni-riga { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
    .cards .azioni-riga > :last-child:nth-child(odd), .cards .azioni-riga > form.genera { grid-column: 1 / -1; }
    .cards .azioni-riga > .btn:first-child:has(+ form.genera) { grid-column: 1 / -1; }
    .cards .azioni-riga > .btn, .cards .azioni-riga > form > .btn, .cards details.menu > summary { width: 100%; }
    .cards .azioni-riga form.inline.genera { display: flex; width: 100%; }
    .cards .azioni-riga form.inline.genera select { flex: 1 1 auto; max-width: none; }
    ol.passi, .docs { min-width: 0; }
}

/* ===================================================================== 7. MENO ANIMAZIONI */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
    /* lo spinner resta visibile come anello tratteggiato fermo: indica comunque "in corso" */
    .spin, .btn[aria-busy="true"]::after { border-style: dotted; border-right-color: currentColor; }
}

/* stampa: solo il contenuto */
@media print {
    .topbar, .sidebar, .scrim, .toasts, .btn-row, .actions, .azioni-riga, .skip-link, form.ricerca { display: none !important; }
    .sidebar ~ main { margin: 0; }
    body { background: #fff; }
    .card, .table-wrap { box-shadow: none; }
}

/* link-bottone disattivato (es. "Genera" prima della fine della verifica) */
a.btn[aria-disabled="true"] { pointer-events: none; opacity: .55; box-shadow: none; }
.muted.small > .ico, p.small > .ico { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.filtro-stato .menu-lista { min-width: 16rem; }
.filtro-stato .menu-voce { justify-content: space-between; }
.filtro-stato .menu-voce[aria-current="true"] { background: var(--primary-soft); }
.page-head .saluto { margin-bottom: 0; }
.piede-pagina { margin-top: var(--s6); }
details.segnaposto { margin-bottom: var(--s4); }

/* voci del riepilogo rischio: il testo va a capo invece di uscire dal riquadro */
ul.rischio-voci li a > span:nth-child(2) { min-width: 0; }
@media (max-width: 767px) {
    .card.stato-card { padding: 0; }
    ul.rischio-voci li a { grid-template-columns: auto minmax(0, 1fr); }
    ul.rischio-voci .rv-importo { grid-column: 2; }
    .rv-dett { white-space: normal; }
    .rischio { padding: var(--s4); }
}
