/* Stile grafico ispirato a thecolorsofmotion.com (componenti in stile shadcn/ui):
   font Geist, bordi sottili, raggi 8/12 px, pulsanti alti 36 px, pillole con
   ombra leggera, menu con ombra morbida, barre di scorrimento discrete.
   Caricato per ultimo: rifinisce i componenti di base.css, componenti.css,
   mobile.css e sezioni.css usando solo le variabili di colore (chiaro e scuro). */

@font-face {
  font-family: 'Geist';
  src: url('../fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

body { letter-spacing: -0.006em; }
button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }
h1, h2, h3, .page-title, .modal-header h2 { letter-spacing: -0.02em; }
td, .stat-value, .kpi-value, .amount-pos, .amount-neg, .smc-amount, .emc-amount { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-light); color: var(--text); }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--primary); }

/* Barre di scorrimento sottili e arrotondate in tutta l'app. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); border: 3px solid transparent; background-clip: content-box; }
.table-wrap { scrollbar-color: var(--scroll) transparent; }
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb:hover { border-radius: 999px; }

/* Fuoco da tastiera: anello sottile del colore del testo. */
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* --- PULSANTI --- */
.btn { min-height: 36px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; line-height: 1.25; white-space: nowrap; transition: background-color .15s cubic-bezier(.4,0,.2,1), border-color .15s cubic-bezier(.4,0,.2,1), color .15s cubic-bezier(.4,0,.2,1), opacity .15s, box-shadow .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); border: 1px solid var(--primary); box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary); opacity: .88; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger, .btn-success { box-shadow: var(--shadow); }
.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn:active { transform: translateY(.5px); }

/* --- CAMPI E MENU A TENDINA --- */
.field label { color: var(--text); font-weight: 500; font-size: 13.5px; }
.field input, .field select, .field textarea, .search-bar input, .split-table input[type=number] {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.field input, .field select { min-height: 38px; padding: 8px 12px; }
.field input::placeholder, .field textarea::placeholder, .search-bar input::placeholder { color: var(--text2); opacity: .8; }
.field input:focus, .field select:focus, .field textarea:focus, .search-bar input:focus, .split-table input[type=number]:focus {
  border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft);
}
/* Freccia doppia su/giù come i selettori del sito di riferimento. */
select, .spese-filter-sel, .ruolo-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 24 24' stroke='%23858585' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E"); background-position: right 10px center; cursor: pointer; }
select option { background: var(--surface); color: var(--text); }

.spese-filter-sel, .spese-filter-search, .ruolo-select { box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.spese-filter-sel { padding-right: 30px; }
/* Tutti gli altri campi di testo, data e numero dell'app: stesso fuoco. */
:is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select, textarea):focus { border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft); outline: none; }

/* --- SCHEDE E TABELLE --- */
.card, .stat-card, .condomino-card, .spesa-mobile-card, .entrata-mobile-card, .edificio-card { border-radius: var(--radius); border-color: var(--border); box-shadow: var(--shadow); }
.card-header { padding: .9rem 1.25rem; }
.card-header h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
th { background: transparent; color: var(--text2); font-weight: 500; font-size: 12.5px; text-transform: none; letter-spacing: 0; height: 40px; }
.split-table th { background: transparent; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; }
tr:hover td { background: color-mix(in srgb, var(--surface2) 70%, transparent); }
.th-sort:hover { color: var(--text); background: var(--surface2); }
.th-sort.active, .th-sort.active .sort-icon { color: var(--text); }

/* --- PILLOLE: badge, filtri, anni --- */
.badge { border-radius: var(--radius-xs); padding: 2px 8px; font-size: 12px; font-weight: 500; border: 1px solid transparent; }
.badge-gray { border-color: var(--border); background: var(--surface); }
.chip, .chip-anno { border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); font-weight: 500; transition: background-color .15s, border-color .15s, color .15s; }
.chip:hover, .chip-anno:hover { background: var(--surface2); border-color: var(--border); }
.chip.active, .chip-anno.attivo { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.split-mode-btns { border-radius: var(--radius-sm); padding: 3px; gap: 2px; background: var(--surface2); border-color: var(--border); }
.split-mode-btn { border-radius: var(--radius-xs); background: transparent; }
.split-mode-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.wstep.active .wstep-circle { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Linguette: sottolineatura sottile del colore del testo. */
.tab-bar { border-bottom: 1px solid var(--border); }
.tab { margin-bottom: -1px; border-bottom-width: 2px; }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

/* --- FINESTRE --- */
.modal-overlay { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.modal { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.modal-header { padding: 1.1rem 1.5rem .9rem; }
.modal-close { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); }
.alert { border-radius: var(--radius-sm); }
.mobile-profile-menu { border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; }
.mpm-item { border-radius: var(--radius-xs); padding: 8px 10px; }

/* --- STRUTTURA: barra laterale, intestazione, navigazione mobile --- */
.sidebar { background: var(--bg); }
nav a { margin: 1px .5rem; padding: 7px .75rem; border-radius: var(--radius-xs); font-weight: 500; color: var(--text2); }
nav a:hover { background: var(--surface2); color: var(--text); }
nav a.active { background: var(--surface2); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--border); }
nav .section-label { padding: .75rem 1.25rem .35rem; letter-spacing: .06em; }
.edificio-switcher { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius-sm); }
.edificio-switcher:hover { background: var(--surface2); }
.edificio-switcher .ed-nome { color: var(--text); }
.edificio-switcher .ed-label { color: var(--text2); }
.page-title { font-weight: 700; letter-spacing: -0.025em; }
.bottom-nav { box-shadow: 0 -1px 0 var(--border); }
.bnav-item { border-radius: var(--radius-sm); }
.bnav-item.active { color: var(--text); background: var(--surface2); }
.bnav-item .bnav-dot { background: var(--text); }
.fab { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg); }

/* Guida e interruttore del tema: pillole bianche con bordo e ombra leggera,
   come i pulsanti in alto del sito di riferimento. */
.btn-guida { color: var(--text); box-shadow: var(--shadow); padding: 3px 11px 3px 4px; }
.btn-guida:hover, .btn-guida.attivo { background: var(--surface2); border-color: var(--border); }
.btn-guida-icona { background: var(--primary); color: var(--on-primary); }
.tema-switch { box-shadow: var(--shadow); background: var(--surface); }
.tema-switch:hover { border-color: var(--scroll-hover); }
.tema-switch.scuro { background: var(--surface2); border-color: var(--border); }
.tema-switch.scuro .ts-luna { color: var(--text); }

/* Accesso */
.login-card { border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }

/* Tema scuro: testo degli avvisi chiaro su fondo appena tinto, il colore
   resta nella barra a sinistra e nel bordo (testo colorato su fondo colorato
   in scuro si legge male). */
:root[data-theme="dark"] .alert { color: var(--text); border-left-width: 3px; }
:root[data-theme="dark"] .alert-success { border-left-color: var(--green); }
:root[data-theme="dark"] .alert-warning { border-left-color: var(--amber); }
:root[data-theme="dark"] .alert-danger { border-left-color: var(--red); }
:root[data-theme="dark"] .alert-info { border-left-color: var(--accent); }

/* Note lunghe nelle liste: solo le prime due righe; il testo intero resta nel
   dettaglio (✏️) e nel suggerimento al passaggio del mouse. */
.testo-2-righe { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
:root[data-theme="dark"] .cf-zero-warn { color: var(--text); border-left-width: 3px; }
:root[data-theme="dark"] .cf-zero-warn.ok { border-left-color: var(--green); }
:root[data-theme="dark"] .cf-zero-warn.warn { border-left-color: var(--amber); }
:root[data-theme="dark"] .cf-zero-warn.critical { border-left-color: var(--red); }
.th-sort .sort-icon { opacity: .75; }

/* --- ICONE DEI PULSANTI (js/core/icone-pulsanti.js) --- */
.ico { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }
.btn .ico { vertical-align: 0; }
.btn-icona { padding: 0 !important; width: 32px; min-width: 32px; height: 32px; min-height: 32px; }
.btn:not(.btn-sm).btn-icona { width: 36px; min-width: 36px; height: 36px; }
.allegato-btn.btn-icona { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-xs); }
/* Eliminare: cestino rosso su pulsante neutro, fondo rosso tenue al passaggio. */
.btn-elimina, .btn-elimina.btn-danger, .allegato-btn.danger { color: var(--red); }
.btn-danger.btn-icona { background: var(--surface); border: 1px solid var(--border); }
.btn-danger.btn-icona:hover, .allegato-btn.danger:hover { background: var(--red-light); border-color: var(--red-border); color: var(--red); }
.btn-secondary.btn-icona { color: var(--text); }
.btn-secondary.btn-icona:hover { background: var(--surface2); }

/* --- FINESTRE DI CONFERMA (js/core/dialoghi.js) --- */
.dialogo { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); padding: 0; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); margin: auto; }
.dialogo::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
.dialogo-form { padding: 1.25rem 1.25rem 1rem; display: flex; flex-direction: column; gap: .75rem; }
.dialogo-testa { display: flex; align-items: center; gap: .6rem; }
.dialogo-testa h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.dialogo-icona { display: inline-flex; width: 32px; height: 32px; border-radius: 999px; align-items: center; justify-content: center; flex-shrink: 0; }
.dialogo-icona .ico { width: 18px; height: 18px; vertical-align: 0; }
.dialogo-info { background: var(--accent-light); color: var(--accent); }
.dialogo-ok { background: var(--green-light); color: var(--green); }
.dialogo-attenzione { background: var(--amber-light); color: var(--amber); }
.dialogo-pericolo .dialogo-icona, .dialogo-errore { background: var(--red-light); color: var(--red); }
.dialogo-testo { font-size: 14px; line-height: 1.55; color: var(--text2); white-space: pre-line; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; }
.dialogo-campo { width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 15px; }
.dialogo-piede { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.dialogo-piede .btn { width: auto; }
.btn-pericolo { background: var(--red); color: #fff; border: 1px solid var(--red); box-shadow: var(--shadow); }
:root[data-theme="dark"] .btn-pericolo { color: #1A0F0E; }
.btn-pericolo:hover { opacity: .9; }
@media (max-width: 480px) { .dialogo-piede .btn { flex: 1; } }

/* --- AVVISI IN BASSO (js/core/dialoghi.js) --- */
.avvisi { position: fixed; z-index: 3000; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.avviso { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.45; animation: avviso-entra .18s ease-out; }
.avviso.uscita { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.avviso-testo { flex: 1; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.avviso-icona { display: inline-flex; margin-top: 1px; }
.avviso-icona .ico { width: 18px; height: 18px; vertical-align: 0; }
.avviso-ok .avviso-icona { color: var(--green); }
.avviso-errore .avviso-icona { color: var(--red); }
.avviso-attenzione .avviso-icona { color: var(--amber); }
.avviso-info .avviso-icona { color: var(--accent); }
.avviso-errore { border-left: 3px solid var(--red); }
.avviso-attenzione { border-left: 3px solid var(--amber); }
.avviso-chiudi { background: none; border: none; color: var(--text2); cursor: pointer; padding: 2px; border-radius: var(--radius-xs); display: inline-flex; }
.avviso-chiudi:hover { background: var(--surface2); color: var(--text); }
@keyframes avviso-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .avviso { animation: none; } .avviso.uscita { transition: none; } }
/* Telefono: sopra la barra di navigazione in basso. */
@media (max-width: 768px) { .avvisi { left: 16px; right: 16px; width: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

/* Casella "Avvisa i condomini per email" / "Riceve le email" */
.casella-email { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: .25rem 0 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface2); font-size: 14px; cursor: pointer; }
.casella-email input { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.casella-email input:disabled + span { opacity: .7; }

/* --- ELENCO DESTINATARI DELLE EMAIL (js/sezioni/email.js) --- */
.casella-email-box { margin: .25rem 0 1rem; }
.casella-email-box .casella-email { margin-bottom: .5rem; }
.scelta-dest { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.scelta-dest-testa { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.scelta-dest-conta { font-size: 13px; font-weight: 600; }
.scelta-dest-azioni { display: flex; gap: 6px; }
.scelta-dest-lista { list-style: none; margin: 0; padding: 4px; max-height: 260px; overflow-y: auto; }
.scelta-dest-lista li label { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; padding: 7px 8px; border-radius: var(--radius-xs); cursor: pointer; font-size: 14px; }
.scelta-dest-lista li label:hover { background: var(--surface2); }
.scelta-dest-lista input { width: 16px; height: 16px; grid-row: span 2; }
.scelta-dest-lista .sd-nome { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.scelta-dest-lista .sd-apt { color: var(--text2); font-weight: 400; font-size: 12.5px; margin-left: 4px; }
.scelta-dest-lista .sd-dett { grid-column: 2; font-size: 12.5px; color: var(--text2); min-width: 0; overflow-wrap: anywhere; }
.scelta-dest-lista li.escluso label { cursor: not-allowed; opacity: .75; }
.scelta-dest-lista li.escluso { padding: 0; }
/* WhatsApp ai condomini (js/sezioni/whatsapp.js) */
.wa-anteprima { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface2); max-height: 200px; overflow-y: auto; }
.wa-lista { list-style: none; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 280px; overflow-y: auto; }
.wa-lista li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px; border-radius: var(--radius-xs); font-size: 14px; }
.wa-lista li + li { border-top: 1px solid var(--border); }
.wa-lista .wa-chi { display: flex; flex-direction: column; min-width: 0; }
.wa-lista .sd-nome { font-weight: 500; overflow-wrap: anywhere; }
.wa-lista .sd-apt { color: var(--text2); font-weight: 400; font-size: 12.5px; margin-left: 4px; }
.wa-lista .sd-dett { font-size: 12.5px; color: var(--text2); overflow-wrap: anywhere; }
.wa-lista li.escluso .sd-nome { font-weight: 400; }
.wa-lista li.aperto .sd-nome::after { content: ' ✓'; color: var(--green, #15803d); }
.wa-lista .btn { flex-shrink: 0; }
.wa-altri { margin-top: .5rem; font-size: 13px; }
.wa-altri summary { cursor: pointer; color: var(--accent); margin-bottom: .4rem; }
.wa-evento { padding-bottom: .75rem; margin-bottom: .75rem; border-bottom: 1px solid var(--border); }
/* Storico delle email in Impostazioni */
.storico-email { list-style: none; margin: 0; padding: 0; }
.storico-email li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.storico-email li:last-child { border-bottom: none; }
.storico-email .se-riga { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.storico-email .se-dett { font-size: 12.5px; color: var(--text2); margin-top: 3px; }
.storico-email details { margin-top: 4px; font-size: 13px; }
.storico-email summary { cursor: pointer; color: var(--accent); }

/* Pallini e caselle dentro un campo: dimensione propria, mai a tutta larghezza
   (la regola dei campi di testo li allargava, es. Sintetico/Dettagliato del rendiconto). */
.field input[type=radio], .field input[type=checkbox] { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 2px 0 0; box-shadow: none; border: none; flex-shrink: 0; }

/* --- TABELLE MILLESIMALI (js/sezioni/millesimi.js) --- */
.mill-tab { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; margin-bottom: .75rem; background: var(--surface); }
.mill-tab-testa { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.mill-nome { flex: 1 1 180px; min-height: 34px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 600; }
.mill-righe { width: 100%; border-collapse: collapse; font-size: 14px; }
.mill-righe td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.mill-righe tr:last-child td { border-bottom: none; }
.mill-righe td:last-child { width: 130px; }
.mill-val { width: 100%; min-height: 34px; padding: 6px 8px; text-align: right; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.mill-categorie { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }
.mill-categorie label { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: 13px; }
.mill-categorie select { max-width: 140px; }

/* --- APPARTAMENTI IN AFFITTO (js/sezioni/affitti.js) --- */
.affitti-lista { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.affitti-lista label { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.affitti-lista label:hover { background: var(--surface2); }
.affitti-lista input { width: 16px; height: 16px; flex-shrink: 0; }

/* "Mostra altre" in fondo agli elenchi lunghi (Spese, Entrate) */
.altre-righe { display: flex; gap: .75rem; align-items: center; justify-content: center; padding: .75rem 1rem; border-top: 1px solid var(--border); }
