/* =====================================================================
   Gestionale MyTico - Foglio di stile principale
   Palette costruita sull'identita' MyTico: arancione #EB6E1C su
   antracite #1D1D1B. Nessuna risorsa esterna, nessun CDN.
   ===================================================================== */

/* ----- 1. Token di design -------------------------------------------- */
:root {
    color-scheme: light;

    --brand:            #EB6E1C;
    --brand-strong:     #CE5B10;
    --brand-soft:       #FEF1E7;
    --brand-border:     #F7C9A6;
    --ink:              #1D1D1B;

    --bg:               #F5F6F8;
    --surface:          #FFFFFF;
    --surface-2:        #FAFBFC;
    --surface-hover:    #F3F5F7;
    --border:           #E3E6EA;
    --border-strong:    #CFD4DA;

    --text:             #1D1D1B;
    --text-soft:        #4A4F57;
    --text-muted:       #767C86;
    --text-faint:       #9AA0A8;

    --success:          #12805C;
    --success-soft:     #E4F5EE;
    --success-border:   #A9DEC9;
    --danger:           #C0392B;
    --danger-soft:      #FDECEA;
    --danger-border:    #F3B7B0;
    --warning:          #B4690E;
    --warning-soft:     #FDF3E3;
    --warning-border:   #F0CE94;
    --info:             #1B6FA8;
    --info-soft:        #E8F2FA;
    --info-border:      #A9CDE8;

    --sidebar-bg:       #1D1D1B;
    --sidebar-bg-2:     #262623;
    --sidebar-text:     #C9C9C4;
    --sidebar-text-dim: #8A8A83;
    --sidebar-active:   #FFFFFF;
    --sidebar-border:   #33332F;

    --radius-sm:  6px;
    --radius:     10px;
    --radius-lg:  14px;
    --radius-xl:  20px;

    --shadow-xs: 0 1px 2px rgba(16, 20, 26, .06);
    --shadow-sm: 0 1px 3px rgba(16, 20, 26, .08), 0 1px 2px rgba(16, 20, 26, .04);
    --shadow:    0 4px 12px rgba(16, 20, 26, .08), 0 1px 3px rgba(16, 20, 26, .05);
    --shadow-lg: 0 12px 32px rgba(16, 20, 26, .14), 0 4px 8px rgba(16, 20, 26, .06);

    /* Dimensione dell'interfaccia: 1 = 100%. La scrive il layout come
       stile in linea su <html>, letta da Impostazioni -> Account.
       Tutto cio' che deve ingrandirsi e' espresso in rem, cosi' basta
       spostare la base per scalare l'intera pagina. I bordi, i raggi e
       le ombre restano in pixel: devono restare sottili a ogni misura.
       Le soglie @media restano in pixel e continuano a guardare la
       larghezza vera della finestra: l'impaginazione ridotta scatta
       quando serve, indipendentemente dallo zoom scelto. */
    --ui-scale: 1;

    --sidebar-w: 15.875rem;
    --topbar-h: 3.75rem;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --ease: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --brand-soft:     #3A2414;
        --brand-border:   #6B4020;
        --bg:             #141416;
        --surface:        #1D1D20;
        --surface-2:      #232327;
        --surface-hover:  #2A2A2F;
        --border:         #2F2F35;
        --border-strong:  #43434B;
        --text:           #ECECEE;
        --text-soft:      #C2C2C8;
        --text-muted:     #9195A0;
        --text-faint:     #6E727C;
        --success-soft:   #10281F;
        --success-border: #235C46;
        --danger-soft:    #2E1614;
        --danger-border:  #6E312A;
        --warning-soft:   #2B1F0D;
        --warning-border: #6A4C18;
        --info-soft:      #10222F;
        --info-border:    #21506F;
        --success:        #4ECFA0;
        --danger:         #F08479;
        --warning:        #E0A64D;
        --info:           #6FB4E4;
        --sidebar-bg:     #0F0F11;
        --sidebar-bg-2:   #17171A;
        --sidebar-border: #26262B;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
        --shadow:    0 4px 14px rgba(0, 0, 0, .5);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --brand-soft:     #3A2414;
    --brand-border:   #6B4020;
    --bg:             #141416;
    --surface:        #1D1D20;
    --surface-2:      #232327;
    --surface-hover:  #2A2A2F;
    --border:         #2F2F35;
    --border-strong:  #43434B;
    --text:           #ECECEE;
    --text-soft:      #C2C2C8;
    --text-muted:     #9195A0;
    --text-faint:     #6E727C;
    --success-soft:   #10281F;
    --success-border: #235C46;
    --danger-soft:    #2E1614;
    --danger-border:  #6E312A;
    --warning-soft:   #2B1F0D;
    --warning-border: #6A4C18;
    --info-soft:      #10222F;
    --info-border:    #21506F;
    --success:        #4ECFA0;
    --danger:         #F08479;
    --warning:        #E0A64D;
    --info:           #6FB4E4;
    --sidebar-bg:     #0F0F11;
    --sidebar-bg-2:   #17171A;
    --sidebar-border: #26262B;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow:    0 4px 14px rgba(0, 0, 0, .5);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
}

/* ----- 2. Reset ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

/* L'attributo hidden deve vincere sempre: qualunque regola che imposti
   display (per esempio flex su un pannello a comparsa) sovrascriverebbe
   la regola del browser, lasciando visibile cio' che il codice crede
   nascosto. E' successo con le tendine: restavano tutte aperte. */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    font-size: calc(16px * var(--ui-scale));
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: .906rem;   /* i 14.5px di prima, ora agganciati alla scala */
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.3; color: var(--text); }
h1 { font-size: 1.5rem; letter-spacing: -.015em; }
h2 { font-size: 1.2rem; letter-spacing: -.01em; }
h3 { font-size: 1.02rem; }
h4 { font-size: .94rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 3px;
}

.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.18em; }
.icon-lg { width: 1.4em; height: 1.4em; }
.icon-xl { width: 2rem; height: 2rem; }

/* ----- 3. Struttura -------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    border-right: 1px solid var(--sidebar-border);
    transition: transform .25s var(--ease);
}

.sidebar__brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: 0 1.125rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex: none;
}

.sidebar__logo {
    width: 1.875rem; height: 1.875rem;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: .02em;
    flex: none;
}

.sidebar__title { font-size: .92rem; font-weight: 600; color: #fff; letter-spacing: -.01em; }
.sidebar__subtitle { font-size: .68rem; color: var(--sidebar-text-dim); letter-spacing: .04em; text-transform: uppercase; }

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: .875rem .625rem 1.25rem;
    scrollbar-width: thin;
}
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: #3A3A36; border-radius: 3px; }

.nav-group { margin-bottom: 1.05rem; }
.nav-group__label {
    font-size: .655rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--sidebar-text-dim);
    padding: 0 .625rem .4rem;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .625rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 1px;
    transition: background .13s var(--ease), color .13s var(--ease);
}
.nav-link:hover { background: var(--sidebar-bg-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-link.active:hover { background: var(--brand-strong); }
.nav-link .icon { opacity: .85; }
.nav-link.active .icon { opacity: 1; }
.nav-link__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-badge {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    min-width: 1.25rem;
    height: 1.1875rem;
    padding: 0 .375rem;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex: none;
}
.nav-link.active .nav-badge { background: rgba(255, 255, 255, .25); }
.nav-badge.is-alert { background: var(--danger); color: #fff; }

.sidebar__footer {
    flex: none;
    padding: .75rem .875rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: .72rem;
    color: var(--sidebar-text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

/* Scelta dei colori delle email, con anteprima */
.color-field { display: flex; align-items: center; gap: .5rem; }
.color-field input[type="color"] {
    width: 3rem;
    height: 2.2rem;
    padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}
.mail-preview {
    width: 100%;
    height: 32rem;
    margin-top: .8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f4f5f7;
}

/* Selezione multipla negli elenchi */
.check-col { width: 2.4rem; text-align: center; }
.check-col input { width: 1rem; height: 1rem; cursor: pointer; }
.check-col input:disabled { cursor: default; opacity: .35; }

.bulk-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    margin-bottom: .7rem;
    padding: .6rem .8rem;
    background: var(--brand-soft);
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
}
.bulk-bar__count { font-size: .82rem; }

/* Dimensione dell'interfaccia: due lettere A di misura diversa, come nei
   lettori di testo. La percentuale compare solo quando non e' 100%. */
.ui-scale {
    display: flex;
    align-items: center;
    gap: .1rem;
    margin-left: auto;
}
.ui-scale__value {
    font-size: .68rem;
    font-variant-numeric: tabular-nums;
    color: var(--sidebar-text-dim);
    min-width: 2.4em;
    text-align: center;
}
.ui-scale__letter {
    font-weight: 700;
    font-size: .95rem;
    line-height: 1;
}
.ui-scale__letter--small { font-size: .7rem; }
.ui-scale .btn:disabled { opacity: .35; cursor: default; }

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-h);
    flex: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar__title { font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.topbar__spacer { flex: 1; }

.topbar__toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 2.25rem; height: 2.25rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-soft);
}

.content { padding: 1.5rem 1.25rem 3rem; flex: 1; }
.container { max-width: 88.75rem; margin: 0 auto; }
.container-narrow { max-width: 56.25rem; margin: 0 auto; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.page-head__text { flex: 1; min-width: 13.75rem; }
.page-head__desc { color: var(--text-muted); font-size: .875rem; margin-top: .15rem; }
.page-head__actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ----- 4. Bottoni ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .48rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text);
    font-size: .862rem;
    font-weight: 550;
    line-height: 1.35;
    cursor: pointer;
    white-space: nowrap;
    transition: background .13s var(--ease), border-color .13s var(--ease), color .13s var(--ease), box-shadow .13s var(--ease);
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: .55; pointer-events: none; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--surface-hover); color: var(--text); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.92); color: #fff; }

.btn--danger-soft { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.btn--danger-soft:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(.94); color: #fff; }

.btn--sm { padding: .3rem .55rem; font-size: .8rem; gap: .3rem; }
.btn--lg { padding: .62rem 1.15rem; font-size: .93rem; }
.btn--block { display: flex; width: 100%; }
.btn--icon { padding: .4rem; width: 2rem; height: 2rem; }
.btn--icon.btn--sm { width: 1.75rem; height: 1.75rem; padding: .25rem; }

.btn-group { display: inline-flex; gap: .3rem; align-items: center; }

/* ----- 5. Superfici -------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    margin-bottom: 1.15rem;
}
.card:last-child { margin-bottom: 0; }

.card__head {
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.card__title { font-size: .95rem; font-weight: 600; flex: 1; min-width: 8.75rem; }
.card__desc { font-size: .8rem; color: var(--text-muted); font-weight: 400; margin-top: .1rem; }
.card__body { padding: 1.1rem; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: .8rem 1.1rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ----- 6. Griglie ---------------------------------------------------- */
/* Il margine sotto la griglia la stacca dal blocco successivo; dentro la
   griglia la distanza la da' il gap, quindi le card non aggiungono il loro. */
.grid { display: grid; gap: 1.15rem; margin-bottom: 1.15rem; }
.grid > .card { margin-bottom: 0; }
.grid:last-child { margin-bottom: 0; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(17.5rem, 1fr); }
.grid--tight { gap: .75rem; }

.row { display: flex; gap: .9rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12.5rem; min-width: 0; }
.row--tight { gap: .6rem; }
.col-full { flex-basis: 100% !important; }
.col-2 { flex: 2 1 20rem; }

/* ----- 7. Riquadri statistica ---------------------------------------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .95rem 1.05rem;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: .3rem;
    min-width: 0;
}
.stat__label {
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .055em;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.stat__value {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.stat__meta { font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.stat__delta { font-weight: 600; display: inline-flex; align-items: center; gap: .15rem; }
.stat__delta.is-up { color: var(--success); }
.stat__delta.is-down { color: var(--danger); }
.stat--accent { border-left: 3px solid var(--brand); }
.stat--success { border-left: 3px solid var(--success); }
.stat--danger { border-left: 3px solid var(--danger); }
.stat--warning { border-left: 3px solid var(--warning); }

/* ----- 8. Tabelle ---------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .862rem; }
.table th, .table td { padding: .62rem .8rem; text-align: left; vertical-align: middle; }
.table thead th {
    background: var(--surface-2);
    font-size: .715rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 650;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr.is-muted { opacity: .58; }
/* Riga da guardare prima di agire (doppione, periodo che non torna) */
.table tbody tr.is-warning { background: var(--warning-soft); }
.table tbody tr.is-warning:hover { background: var(--warning-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.actions, .table th.actions { text-align: right; white-space: nowrap; width: 1%; }
.table td.tight { width: 1%; white-space: nowrap; }
.table__primary { font-weight: 600; color: var(--text); }
.table__sub { font-size: .78rem; color: var(--text-muted); }
.table--compact th, .table--compact td { padding: .45rem .65rem; }

.table thead th a { color: inherit; display: inline-flex; align-items: center; gap: .2rem; }
.table thead th a:hover { color: var(--text); text-decoration: none; }
.sort-arrow { opacity: .45; width: .85em; height: .85em; }
.sort-arrow.is-active { opacity: 1; color: var(--brand); }

.row-actions { display: inline-flex; gap: .2rem; justify-content: flex-end; }

/* ----- 9. Etichette di stato ----------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .28rem;
    padding: .14rem .48rem;
    border-radius: 20px;
    font-size: .735rem;
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge.is-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge.is-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.badge.is-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge.is-info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.badge.is-brand   { background: var(--brand-soft);   color: var(--brand-strong); border-color: var(--brand-border); }
.badge.is-muted   { background: var(--surface-2);    color: var(--text-muted); border-color: var(--border); }

.dot { width: .4375rem; height: .4375rem; border-radius: 50%; background: currentColor; flex: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .18rem .5rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .77rem;
    color: var(--text-soft);
}
.chip__swatch { width: 0.5625rem; height: 0.5625rem; border-radius: 2px; flex: none; }

/* ----- 10. Form ------------------------------------------------------ */
.field { margin-bottom: .95rem; }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    font-size: .805rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: .3rem;
}
.label .req { color: var(--danger); font-weight: 400; }
.hint { font-size: .765rem; color: var(--text-muted); margin-top: .28rem; }

.input, .select, .textarea {
    width: 100%;
    padding: .48rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: .875rem;
    transition: border-color .13s var(--ease), box-shadow .13s var(--ease);
    appearance: none;
    -webkit-appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(235, 110, 28, .16);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }

.textarea { min-height: 5.5rem; resize: vertical; line-height: 1.55; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23767C86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .5rem center;
    background-size: 1.05em;
    padding-right: 2rem;
}

.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { font-size: .765rem; color: var(--danger); margin-top: .25rem; display: flex; align-items: center; gap: .25rem; }

/*
 * Campo con etichetta attaccata (€, %, giorni, ore...).
 *
 * Fino alla 1.1.12 la forma dipendeva da dove stava l'etichetta: il CSS
 * dava per scontato che fosse a destra, e per metterla a sinistra serviva
 * la classe --prefix, che quasi nessuna vista usava. Il risultato era un
 * "€" staccato dal campo, con gli angoli arrotondati dalla parte sbagliata
 * e il bordo doppio. Ora la forma la decide la posizione: ogni pezzo e'
 * squadrato, il primo arrotonda a sinistra, l'ultimo a destra, e i bordi
 * vicini si sovrappongono invece di sommarsi. Vale per €, per "all'ora",
 * per tutt'e due insieme e per il pulsante "Copia".
 */
.input-group { display: flex; align-items: stretch; }
.input-group > * { border-radius: 0; }
.input-group > * + * { margin-left: -1px; }
.input-group > :first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.input-group > :last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.input-group > .input { flex: 1 1 auto; min-width: 0; width: 1%; position: relative; }
.input-group > .input:focus { z-index: 1; }
.input-group__addon {
    display: flex;
    align-items: center;
    padding: 0 .6rem;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: .84rem;
    white-space: nowrap;
    flex: 0 0 auto;
}
/* Un numero di giorni da solo su una riga non deve occupare tutta la card */
.input-group--short { max-width: 18rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; font-size: .87rem; }
.check input[type="checkbox"], .check input[type="radio"] {
    width: 1rem; height: 1rem;
    margin: .17rem 0 0;
    accent-color: var(--brand);
    flex: none;
    cursor: pointer;
}
.check__text { flex: 1; }
.check__hint { display: block; font-size: .765rem; color: var(--text-muted); margin-top: .1rem; }
.check-list { display: flex; flex-direction: column; gap: .55rem; }
/* Casella dentro una cella di tabella o accanto a un pulsante:
   deve restare sulla riga, non occupare tutta la larghezza. */
.check--inline { display: inline-flex; align-items: center; }
.check--inline .check__text { flex: none; }

.switch-card {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .7rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
}
.switch-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.switch-card__title { font-weight: 600; font-size: .87rem; }
.switch-card__desc { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }

.form-section { padding: 1.1rem; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section__title { font-size: .88rem; font-weight: 650; margin-bottom: .2rem; }
.form-section__desc { font-size: .8rem; color: var(--text-muted); margin-bottom: .9rem; }

/* ----- 11. Avvisi ---------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .72rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: .862rem;
    margin-bottom: 1rem;
}
.alert .icon { margin-top: .12rem; flex: none; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 650; margin-bottom: .1rem; }
.alert--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert--danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.alert--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.alert--info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info); }
.alert__close { background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.alert__close:hover { opacity: 1; }

.toasts {
    position: fixed;
    top: calc(var(--topbar-h) + 12px);
    right: 16px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: min(23.75rem, calc(100vw - 2rem));
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-muted);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .7rem .85rem;
    display: flex;
    gap: .55rem;
    align-items: flex-start;
    font-size: .862rem;
    animation: toast-in .22s var(--ease);
}
.toast--success { border-left-color: var(--success); }
.toast--success .icon { color: var(--success); }
.toast--danger { border-left-color: var(--danger); }
.toast--danger .icon { color: var(--danger); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .icon { color: var(--warning); }
.toast--info { border-left-color: var(--info); }
.toast--info .icon { color: var(--info); }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(14px); } }

/* ----- 12. Stato vuoto ----------------------------------------------- */
.empty { padding: 2.75rem 1.5rem; text-align: center; }
.empty__icon {
    width: 2.875rem; height: 2.875rem;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: grid; place-items: center;
    margin: 0 auto .8rem;
    color: var(--text-faint);
}
.empty__title { font-weight: 650; margin-bottom: .25rem; }
.empty__text { color: var(--text-muted); font-size: .862rem; max-width: 26.25rem; margin: 0 auto 1rem; }

/* ----- 13. Filtri e paginazione -------------------------------------- */
.toolbar {
    display: flex;
    gap: .55rem;
    align-items: center;
    flex-wrap: wrap;
    padding: .8rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--radius) var(--radius) 0 0;
}
.toolbar__search { flex: 1 1 14.375rem; min-width: 10.625rem; position: relative; }
.toolbar__search .input { padding-left: 2.05rem; }
.toolbar__search .icon {
    position: absolute;
    left: .62rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
}
.toolbar .select { width: auto; min-width: 8rem; }
.toolbar__spacer { flex: 1; }

.pagination {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 1.1rem;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.pagination__pages { display: flex; gap: .2rem; margin-left: auto; }
.pagination__link {
    min-width: 1.875rem; height: 1.875rem;
    padding: 0 .45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: grid; place-items: center;
    color: var(--text-soft);
    font-size: .82rem;
    font-weight: 550;
    background: var(--surface);
}
.pagination__link:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.pagination__link.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination__link.is-disabled { opacity: .4; pointer-events: none; }
.pagination__gap { display: grid; place-items: center; min-width: 1.375rem; color: var(--text-faint); }

/* ----- 14. Schede a linguette ---------------------------------------- */
.tabs {
    display: flex;
    gap: .15rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.15rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: .55rem .8rem;
    font-size: .862rem;
    font-weight: 550;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }

/* ----- 15. Finestre modali ------------------------------------------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 20, 26, .55);
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 1rem;
    animation: fade-in .15s var(--ease);
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(32.5rem, 100%);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    animation: modal-in .18s var(--ease);
}
.modal--wide { width: min(53.75rem, 100%); }
.modal__head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.modal__title { font-size: 1rem; font-weight: 650; flex: 1; }
.modal__body { padding: 1.15rem; overflow-y: auto; }
.modal__foot { padding: .85rem 1.15rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

/* ----- 16. Menu a discesa -------------------------------------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 11.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .3rem;
    z-index: 50;
    display: none;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .42rem .55rem;
    border-radius: var(--radius-sm);
    font-size: .855rem;
    color: var(--text-soft);
    width: 100%;
    background: none;
    border: 0;
    cursor: pointer;
    text-align: left;
}
.dropdown__item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.dropdown__item.is-danger { color: var(--danger); }
.dropdown__item.is-danger:hover { background: var(--danger-soft); }
.dropdown__sep { height: 1px; background: var(--border); margin: .3rem 0; }

/* ----- 17. Righe documento ------------------------------------------- */
.items-table { width: 100%; border-collapse: collapse; font-size: .855rem; }
.items-table th {
    font-size: .715rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 650;
    text-align: left;
    padding: .45rem .5rem;
    border-bottom: 1px solid var(--border);
}
.items-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.items-table .input, .items-table .select, .items-table .textarea { padding: .35rem .5rem; font-size: .83rem; }
.items-table td.num { text-align: right; }
.items-table tfoot td { border-bottom: 0; padding-top: .7rem; }

.totals { margin-left: auto; width: min(20rem, 100%); }
.totals__row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; font-size: .87rem; }
.totals__row.is-total {
    border-top: 1px solid var(--border);
    margin-top: .3rem;
    padding-top: .55rem;
    font-size: 1.05rem;
    font-weight: 650;
}
.totals__label { color: var(--text-muted); }
.totals__value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ----- 18. Elenchi di dettaglio -------------------------------------- */
.detail-list { display: grid; gap: .05rem; }
.detail-row {
    display: flex;
    gap: 1rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .862rem;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row__label { color: var(--text-muted); flex: 0 0 40%; max-width: 11.875rem; }
.detail-row__value { flex: 1; min-width: 0; font-weight: 500; word-break: break-word; }

.timeline { position: relative; padding-left: 1.2rem; }
.timeline::before { content: ''; position: absolute; left: 4px; top: .4rem; bottom: .4rem; width: 1px; background: var(--border); }
.timeline__item { position: relative; padding: .35rem 0 .55rem; font-size: .84rem; }
.timeline__item::before {
    content: '';
    position: absolute;
    left: -1.2rem; top: .72rem;
    width: 0.5625rem; height: 0.5625rem;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
}
.timeline__item.is-brand::before { border-color: var(--brand); }
.timeline__time { color: var(--text-muted); font-size: .77rem; }

/* ----- 19. Grafici --------------------------------------------------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart-wrap { position: relative; width: 100%; }
.chart-legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-muted); margin-top: .6rem; }
.chart-legend__item { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend__swatch { width: 0.625rem; height: 0.625rem; border-radius: 2px; flex: none; }
/* Compare solo sullo schermo stretto, dove le colonne a destra spariscono. */
.show-sm { display: none; }
/* Barre, punti e fette che portano all'elenco di quello che contengono.
   Il collegamento e' un <a> dentro l'SVG: il cursore lo deve dire, e il
   contorno del fuoco deve restare visibile per chi naviga da tastiera. */
a.chart-legend__item { color: inherit; text-decoration: none; }
a.chart-legend__item:hover { color: var(--text); text-decoration: underline; }
.chart__link { cursor: pointer; }
.chart__link:hover > rect,
.chart__link:hover > path,
.chart__link:hover > circle { filter: brightness(1.12); }
.chart__link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.chart-tip {
    position: absolute;
    pointer-events: none;
    background: var(--ink);
    color: #fff;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .78rem;
    box-shadow: var(--shadow);
    white-space: nowrap;
    opacity: 0;
    transition: opacity .12s var(--ease);
    z-index: 10;
}
.chart-tip.is-visible { opacity: 1; }
.chart-tip__label { color: rgba(255, 255, 255, .7); font-size: .72rem; }

/* ----- 20. Utilita' -------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: .8rem; }
.tiny { font-size: .73rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: .82em; }
.tnum { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-brand { color: var(--brand); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: .35rem; } .mt-2 { margin-top: .7rem; } .mt-3 { margin-top: 1.1rem; } .mt-4 { margin-top: 1.6rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .35rem; } .mb-2 { margin-bottom: .7rem; } .mb-3 { margin-bottom: 1.1rem; } .mb-4 { margin-bottom: 1.6rem; }
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .7rem; } .gap-3 { gap: 1.1rem; }
.wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.avatar {
    width: 2rem; height: 2rem;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    display: grid; place-items: center;
    font-size: .76rem;
    font-weight: 650;
    flex: none;
    border: 1px solid var(--brand-border);
}
.avatar--sm { width: 1.625rem; height: 1.625rem; font-size: .68rem; }

.progress { height: 6px; background: var(--surface-hover); border-radius: 3px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s var(--ease); }
.progress__bar.is-success { background: var(--success); }
.progress__bar.is-danger { background: var(--danger); }

.spinner {
    width: 0.9375rem; height: 0.9375rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.is-loading { position: relative; pointer-events: none; opacity: .65; }

/* ----- 21. Pagina di accesso ----------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1000px 500px at 15% -10%, rgba(235, 110, 28, .13), transparent 60%),
        radial-gradient(800px 420px at 100% 110%, rgba(235, 110, 28, .07), transparent 60%),
        var(--bg);
}
.auth__box { width: min(25rem, 100%); }
.auth__brand { text-align: center; margin-bottom: 1.4rem; }
.auth__logo {
    width: 3.25rem; height: 3.25rem;
    border-radius: 14px;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0 auto .7rem;
    box-shadow: 0 6px 20px rgba(235, 110, 28, .3);
}
.auth__title { font-size: 1.22rem; }
.auth__subtitle { color: var(--text-muted); font-size: .862rem; margin-top: .15rem; }
.auth__foot { text-align: center; margin-top: 1.1rem; font-size: .78rem; color: var(--text-faint); }

/* ----- 22. Pagine pubbliche (cliente) -------------------------------- */
.pub { min-height: 100vh; background: var(--bg); }
.pub__bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 30;
}
.pub__wrap { max-width: 55rem; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.pub__hero {
    background: var(--ink);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 2.25rem 1.75rem;
    margin-bottom: 1.5rem;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
}
.pub__hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(29, 29, 27, .88), rgba(29, 29, 27, .55));
}
.pub__hero > * { position: relative; z-index: 1; }
.pub__hero h1 { color: #fff; font-size: clamp(1.5rem, 4vw, 2.15rem); }
.pub__hero p { color: rgba(255, 255, 255, .78); margin-top: .4rem; }
.pub__eyebrow { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--brand); font-weight: 650; }

/* ----- 23. Adattamento ai piccoli schermi ---------------------------- */
@media (max-width: 1180px) {
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .main { margin-left: 0; }
    .topbar__toggle { display: inline-flex; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(16, 20, 26, .5);
        z-index: 55;
        animation: fade-in .15s var(--ease);
    }
    .content { padding: 1.15rem .9rem 3rem; }
    .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
    .page-head__actions { width: 100%; }
    .detail-row { flex-direction: column; gap: .1rem; }
    .detail-row__label { flex-basis: auto; max-width: none; }
    .toasts { left: 12px; right: 12px; max-width: none; }
}

@media (max-width: 620px) {
    body { font-size: 0.875rem; }
    .topbar { padding: 0 .9rem; }
    .card__head, .card__body, .toolbar { padding-left: .9rem; padding-right: .9rem; }
    .stat__value { font-size: 1.32rem; }
    .btn { padding: .45rem .7rem; }
    .table th, .table td { padding: .55rem .6rem; }
    .hide-sm { display: none !important; }
    .show-sm { display: block; }
    .modal__foot { flex-direction: column-reverse; }
    .modal__foot .btn { width: 100%; }
}

/* ----- 24. Stampa ---------------------------------------------------- */
@media print {
    .sidebar, .topbar, .page-head__actions, .toolbar, .pagination,
    .row-actions, .btn, .toasts, .no-print { display: none !important; }
    .main { margin-left: 0; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; margin-bottom: 1rem; }
    body { background: #fff; font-size: 11pt; }
    a { color: inherit; text-decoration: none; }
    .table thead th { position: static; background: #f2f2f2; }
}

/* ----- 25. Movimento ridotto ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ----- 26. Calendario delle scadenze --------------------------------- */
.cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.cal__weekday {
    background: var(--surface-2);
    padding: .4rem .5rem;
    font-size: .7rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    text-align: center;
}

.cal__day {
    background: var(--surface);
    min-height: 6rem;
    padding: .35rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.cal__day--empty { background: var(--surface-2); }
.cal__day.is-quiet .cal__daynum { opacity: .5; }
.cal__day.is-today { background: var(--brand-soft); }
.cal__day.is-today .cal__daynum span:first-child {
    background: var(--brand);
    color: #fff;
    border-radius: 50%;
    width: 1.25rem; height: 1.25rem;
    display: inline-grid;
    place-items: center;
}

.cal__daynum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .25rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: .1rem;
}
.cal__daytotal { font-size: .68rem; color: var(--text-muted); font-weight: 500; }

.cal__item {
    display: flex;
    align-items: center;
    gap: .25rem;
    padding: .18rem .3rem;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .72rem;
    color: var(--text-soft);
    text-decoration: none;
    line-height: 1.3;
}
.cal__item:hover { background: var(--surface-hover); text-decoration: none; color: var(--text); }
.cal__item.is-paid { opacity: .55; }
.cal__item.is-overdue { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.cal__dot { width: .4375rem; height: .4375rem; border-radius: 50%; flex: none; }
.cal__itemtext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal__itemamount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* Sotto i 700px la griglia non è più leggibile: si passa a un elenco
   dei soli giorni che hanno scadenze. */
@media (max-width: 700px) {
    .cal { display: block; background: transparent; border: 0; }
    .cal__weekday { display: none; }
    .cal__day { min-height: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
    .cal__day--empty, .cal__day.is-quiet { display: none; }
    .cal__day.is-today { border-radius: var(--radius-sm); }
    .cal__daynum { font-size: .85rem; }
    .cal__item { font-size: .8rem; padding: .3rem .4rem; }
}

/* ---------------------------------------------------------------------
   Logo dell'azienda
   Lo sfondo a scacchi rende evidente la trasparenza del PNG caricato.
   --------------------------------------------------------------------- */
.logo-preview {
    display: grid;
    place-items: center;
    min-height: 5.75rem;
    padding: .8rem;
    margin-bottom: .6rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-2);
    background-image:
        linear-gradient(45deg, rgba(128, 128, 128, .12) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(128, 128, 128, .12) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(128, 128, 128, .12) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(128, 128, 128, .12) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.logo-preview img { max-width: 100%; max-height: 4.75rem; object-fit: contain; }
.logo-preview--square img { max-height: 5.75rem; }

/* Il logo sostituisce il monogramma quando e' stato caricato: niente
   riquadro colorato ne' alone, che appartengono solo al monogramma. */
.sidebar__logo--image, .auth__logo--image {
    background: transparent;
    border-radius: 0;
    width: auto;
    box-shadow: none;
    padding: 0;
}
.sidebar__logo--image { max-width: 8.25rem; height: 2rem; }
.sidebar__logo--image img { max-width: 100%; max-height: 2rem; object-fit: contain; }
/* inline-flex: la cornice segue l'immagine invece di occupare tutta la
   larghezza della colonna (il centraggio arriva da .auth__brand). */
.auth__logo--image {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 3.5rem;
    margin: 0 auto .8rem;
}
.auth__logo--image img { max-width: 15rem; max-height: 3.5rem; object-fit: contain; }

/* ---------------------------------------------------------------------
   Editor di testo formattato
   --------------------------------------------------------------------- */
.editor {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}
.editor:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.editor__bar {
    display: flex;
    align-items: center;
    gap: .15rem;
    flex-wrap: wrap;
    padding: .3rem .35rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.editor__btn {
    min-width: 1.75rem;
    height: 1.625rem;
    padding: 0 .4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-soft);
    font-size: .82rem;
    line-height: 1;
    cursor: pointer;
}
.editor__btn:hover { background: var(--surface-hover); border-color: var(--border); color: var(--text); }
.editor__btn:active { background: var(--brand-soft); border-color: var(--brand-border); }

.editor__sep { width: 1px; height: 1rem; margin: 0 .25rem; background: var(--border); }

.editor__area {
    min-height: 6.5rem;
    max-height: 26rem;
    overflow-y: auto;
    padding: .6rem .7rem;
    font-size: .9rem;
    line-height: 1.55;
    color: var(--text);
    outline: none;
}
.editor__area:empty::before {
    content: attr(data-placeholder);
    color: var(--text-faint);
}
.editor__area p { margin: 0 0 .5rem; }
.editor__area p:last-child { margin-bottom: 0; }
.editor__area ul, .editor__area ol { margin: .3rem 0 .5rem; padding-left: 1.4rem; }
.editor__area li { margin-bottom: .2rem; }
.editor__area a { color: var(--brand); text-decoration: underline; }

/* La textarea resta nel form per l'invio, ma non si vede */
.editor__source {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Testo formattato mostrato in sola lettura (schede e anteprime) */
.rich { font-size: .9rem; line-height: 1.55; color: var(--text-soft); }
.rich p { margin: 0 0 .5rem; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: .3rem 0 .5rem; padding-left: 1.3rem; }
.rich li { margin-bottom: .15rem; }
.rich--tight { font-size: .84rem; }

/* ---------------------------------------------------------------------
   Tendine con ricerca (select.js)
   Il pulsante riprende esattamente i bordi e le spaziature di .input,
   cosi' un campo e una tendina affiancati restano allineati.
   --------------------------------------------------------------------- */
.combo { position: relative; width: 100%; }

.combo__button {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .48rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: .875rem;
    text-align: left;
    cursor: pointer;
    transition: border-color .13s var(--ease), box-shadow .13s var(--ease);
}
.combo__button:hover { border-color: var(--text-faint); }
.combo.is-open .combo__button,
.combo__button:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(235, 110, 28, .16);
}
.combo__button:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

.combo__label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__label.is-placeholder { color: var(--text-muted); }

.combo__caret {
    flex: none;
    width: 1.05em; height: 1.05em;
    background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23767C86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    transition: transform .13s var(--ease);
}
.combo.is-open .combo__caret { transform: rotate(180deg); }

.combo__panel {
    position: absolute;
    z-index: 70;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 11.875rem;
    max-height: 17rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* Campo in fondo alla finestra: le voci si aprono verso l'alto, altrimenti
   finirebbero sotto il bordo dello schermo. La sceglie select.js. */
.combo__panel--up {
    top: auto;
    bottom: calc(100% + 4px);
}

.combo__search {
    flex: none;
    margin: .35rem;
    padding: .38rem .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: .84rem;
}
.combo__search:focus { outline: none; border-color: var(--brand); }

.combo__list { flex: 1; margin: 0; padding: .2rem; list-style: none; overflow-y: auto; }

.combo__option {
    padding: .38rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .865rem;
    line-height: 1.35;
    cursor: pointer;
}
.combo__option:hover, .combo__option.is-active { background: var(--surface-hover); }
.combo__option.is-selected { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.combo__option.is-disabled { color: var(--text-faint); cursor: not-allowed; }

.combo__group {
    padding: .45rem .5rem .2rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}

.combo__empty { padding: .6rem; font-size: .82rem; color: var(--text-muted); text-align: center; }

/* La select nativa resta nel form ma non si vede.
   Il selettore e' `.combo .combo__source` e non `.combo__source` per
   una ragione precisa: dentro la barra dei filtri vale anche
   `.toolbar .select { width: auto }`, che ha la stessa specificita' di
   una classe sola e vinceva. La select nascosta tornava larga quanto la
   sua opzione piu' lunga (con 69 clienti in elenco: mezzo schermo) e,
   pur essendo invisibile, allargava l'area scorrevole della pagina. */
.combo .combo__source {
    position: absolute;
    width: 1px; height: 1px;
    min-width: 0;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
}

/* Nella barra dei filtri le tendine non devono occupare tutta la riga */
.toolbar .combo { width: auto; min-width: 9.375rem; }

/* ---------------------------------------------------------------------
   Cronologia dei documenti
   --------------------------------------------------------------------- */
.timeline__item.is-success::before { border-color: var(--success); }
.timeline__item.is-danger::before  { border-color: var(--danger); }
.timeline__item.is-info::before    { border-color: var(--info); }

/* La cronologia apre la colonna laterale: il filo colorato le da' peso
   senza rubare spazio al riepilogo economico. */
.card--accent { border-left: 3px solid var(--brand); }
/* Riquadro di un conto che non si vuole vedere: sanzioni, ritardi. */
.card--danger { border-left: 3px solid var(--danger); }
.card--danger .card__title { display: flex; align-items: center; gap: .4rem; }
.card--accent .card__title { display: flex; align-items: center; gap: .4rem; }
.card__body--tight {
    padding: .6rem 1.1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

/* Barra dei filtri usata fuori da una card (pagina degli abbinamenti) */
.toolbar--standalone {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.15rem;
}

/* Avviso dei contratti in rinnovo: e' la cosa da fare, non una nota a
   margine, quindi porta il colore del marchio invece dell'azzurro
   informativo che si usa per il resto. */
.alert--accent {
    background: var(--brand-soft);
    border-color: var(--brand-border);
    color: var(--text);
}
/* L'icona porta il colore, il testo no: l'arancione del marchio sul
   fondo velato sta a 3,6:1, sotto la soglia di leggibilita' per un testo
   di quella dimensione. Il titolo resta del colore del testo. */
.alert--accent .icon { color: var(--brand); }

/* ---------------------------------------------------------------------
   Clienti che non pagano nemmeno dopo i solleciti (1.1.13)
   --------------------------------------------------------------------- */
/* L'elenco dentro l'avviso resta del colore del testo: una lista intera
   in rosso si legge male, e il rosso lo portano gia' icona e titolo. */
.alert__list { margin: .35rem 0 .2rem; padding-left: 1.1rem; }
.alert__list li { margin: .2rem 0; }
.alert--danger .alert__list { color: var(--text); }

/* ---------------------------------------------------------------------
   Piè di pagina delle email (1.1.13)
   --------------------------------------------------------------------- */
.textarea--short { min-height: 3.6rem; }
.var-legend { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.chip--button { cursor: pointer; font: inherit; font-size: .77rem; }
.chip--button:hover { border-color: var(--brand-border); color: var(--text); }
.chip--button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------------------------------------------------------------------
   Statistiche: prospetto del compenso e calendario dei versamenti (1.1.13)
   --------------------------------------------------------------------- */
/* Prospetto: un socio per colonna, le voci si leggono dall'alto in basso
   come un conto. Prima ogni socio era una riga, e quando uno aveva i
   contributi registrati e l'altro no le colonne non combaciavano piu'. */
.table--statement .table__sub,
.table--calendar .table__sub { display: block; }
.table--statement thead th {
    text-transform: none;
    letter-spacing: 0;
    font-size: .84rem;
    color: var(--text);
}
.table--statement thead th .table__sub { font-weight: 400; }
.table--statement thead th:first-child {
    text-transform: uppercase;
    letter-spacing: .05em;
    font-size: .715rem;
    color: var(--text-muted);
}
.table--statement tbody th { font-weight: 500; color: var(--text); min-width: 12rem; }
.table--statement tbody th .table__sub { font-weight: 400; }
.table--statement td.num { min-width: 9.5rem; }
.table--statement tbody tr.is-subtotal { border-top: 1px solid var(--border-strong); }
.table--statement tr.is-subtotal th,
.table--statement tr.is-subtotal td { font-weight: 600; }
.table--statement tbody tr.is-total,
.table--statement tbody tr.is-total:hover { background: var(--surface-2); }
.table--statement tr.is-total th,
.table--statement tr.is-total td { font-weight: 700; font-size: .95rem; }

/* Calendario: un gruppo per mese, con il totale sulla riga del mese.
   Niente celle unite: con la data a cavallo di piu' righe, il passaggio
   del mouse accendeva la data insieme alla sola prima riga del gruppo. */
.table--calendar tr.cal-month th {
    background: var(--surface-2);
    color: var(--text);
    font-size: .84rem;
    font-weight: 650;
    text-transform: none;
    letter-spacing: 0;
    border-top: 1px solid var(--border-strong);
}
.table--calendar tbody tr.cal-month:hover { background: transparent; }
.table--calendar tr.cal-month th .table__sub { font-weight: 400; }
.table--calendar tr.cal-month--overdue th { background: var(--danger-soft); color: var(--danger); }
.table--calendar td.is-estimate { color: var(--text-muted); font-style: italic; }
.table--calendar td:first-child { width: 1%; }

.cal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: .75rem;
}
.cal-summary__item {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .7rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-width: 0;
}
.cal-summary__item--total { border-left: 3px solid var(--brand); }
.cal-summary__who {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 600;
}
.cal-summary__value { font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cal-summary__meta { font-size: .76rem; color: var(--text-muted); }

/* Elenco con spiegazioni lunghe (base del compenso): l'etichetta prende
   lo spazio che serve e l'importo sta a destra, allineato come in un
   conto. Con l'elenco normale la spiegazione andava a capo ogni tre
   parole in una colonna stretta e l'importo le stava appiccicato. */
.detail-list--wide .detail-row__label { flex: 1 1 auto; max-width: none; }
.detail-list--wide .detail-row__value {
    flex: 0 0 auto;
    min-width: 8rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Sul telefono il prospetto scorre di lato: la colonna delle voci resta
   ferma, altrimenti scorrendo si vedono numeri senza sapere di che cosa. */
.table--statement tbody th,
.table--statement thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
}
.table--statement thead th:first-child { background: var(--surface-2); z-index: 3; }
.table--statement tbody tr:hover th { background: var(--surface-hover); }
.table--statement tbody tr.is-total th { background: var(--surface-2); }
@media (max-width: 640px) {
    .table--statement tbody th { min-width: 8.5rem; }
    .table--statement td.num { min-width: 7.5rem; }
}

/* Tabella delle categorie: il nome non si deve stringere per far posto
   alla tendina del tipo (e' successo allungando le etichette dei tipi). */
.cat-name { min-width: 10rem; }
.select.cat-kind { max-width: 14rem; }

/* ---------------------------------------------------------------------
   Conto corrente (1.2.0)
   --------------------------------------------------------------------- */
/* Un avviso che porta dei pulsanti e' una riga flessibile: finche' non
   vanno a capo, su uno schermo stretto spingono la pagina fuori dalla
   finestra. Il cruscotto a 360 px scorreva di lato ogni volta che
   c'erano rinnovi da preparare. La base di 14rem del testo e' il punto
   in cui conviene mandare i pulsanti sotto invece di stringere ancora. */
.alert { flex-wrap: wrap; }
.alert__body { flex: 1 1 14rem; }
