/* Pannello inquilino */

@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url("../fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215;
}

:root {
  color-scheme: light;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --inchiostro: #16424f;
  --inchiostro-scuro: #0f2f39;
  --sfondo: #eef3f4;
  --carta: #ffffff;
  --carta-tenue: #f4f7f8;
  --testo: #14262c;
  --testo-tenue: #5c6f75;
  --linea: #dfe7e9;
  --linea-forte: #cdd8db;
  --collegamento: #1f5c6e;
  --ambra: #f1c453;
  --credito: #2f7d5c;
  --credito-bg: #e1f1e9;
  --debito: #b4432f;
  --debito-bg: #f9e3de;
  --attenzione: #8a5d00;
  --attenzione-bg: #fbf0d3;
  --info: #1f5c6e;
  --info-bg: #dfecef;
  --neutro: #55676d;
  --neutro-bg: #e6edef;
  --testata-bg: #16424f;
  --testata-testo: #ffffff;
  --testata-tenue: #b9d0d6;
  --raggio: 14px;
  --ombra: 0 1px 2px rgba(22, 66, 79, 0.06), 0 10px 28px -18px rgba(22, 66, 79, 0.4);
}
/* Tema scuro: quando è scelto dal menu «Tema», oppure in automatico se lo usa il dispositivo */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --inchiostro: #8fd0e2;
    --inchiostro-scuro: #c3e9f3;
    --sfondo: #0f1c20;
    --carta: #16252a;
    --carta-tenue: #1c2f35;
    --testo: #e4ecee;
    --testo-tenue: #9fb2b8;
    --linea: #24373d;
    --linea-forte: #34494f;
    --collegamento: #8fd0e2;
    --credito: #6fcea3;
    --credito-bg: #173f31;
    --debito: #f08a76;
    --debito-bg: #4d241c;
    --attenzione: #f1c453;
    --attenzione-bg: #4a3a12;
    --info: #8fd0e2;
    --info-bg: #1a3a44;
    --neutro: #b3c3c8;
    --neutro-bg: #263a40;
    --testata-bg: #0c1d23;
    --ombra: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --inchiostro: #8fd0e2;
  --inchiostro-scuro: #c3e9f3;
  --sfondo: #0f1c20;
  --carta: #16252a;
  --carta-tenue: #1c2f35;
  --testo: #e4ecee;
  --testo-tenue: #9fb2b8;
  --linea: #24373d;
  --linea-forte: #34494f;
  --collegamento: #8fd0e2;
  --credito: #6fcea3;
  --credito-bg: #173f31;
  --debito: #f08a76;
  --debito-bg: #4d241c;
  --attenzione: #f1c453;
  --attenzione-bg: #4a3a12;
  --info: #8fd0e2;
  --info-bg: #1a3a44;
  --neutro: #b3c3c8;
  --neutro-bg: #263a40;
  --testata-bg: #0c1d23;
  --ombra: 0 1px 2px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--testo);
  background: var(--sfondo);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--collegamento); text-underline-offset: 3px; }
a:hover { color: var(--inchiostro-scuro); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--ambra); outline-offset: 2px; border-radius: 4px; }
.solo-lettori { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Testata ---------- */
.testata { background: var(--testata-bg); color: var(--testata-testo); }
.testata-riga {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.marca { display: inline-flex; align-items: center; gap: 10px; color: var(--testata-testo); text-decoration: none; font-weight: 650; min-width: 0; }
.marca:hover { color: var(--testata-testo); }
.marca-simbolo { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--ambra); color: #16424f; display: inline-grid; place-items: center; }
.marca-simbolo svg { width: 18px; height: 18px; }
.marca-testi { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.marca-testi small { font-weight: 400; font-size: 0.82rem; color: var(--testata-tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-utente { position: relative; flex: none; }
.menu-utente summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.93rem;
  font-weight: 550;
}
.menu-utente summary::-webkit-details-marker { display: none; }
.menu-utente summary:hover { background: rgba(255, 255, 255, 0.1); }
.iniziali { width: 26px; height: 26px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 700; }
.menu-utente-voci {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 220px;
  background: var(--carta);
  color: var(--testo);
  border: 1px solid var(--linea);
  border-radius: 12px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.5);
  padding: 6px;
}
.menu-utente-voci a, .menu-utente-voci button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--testo);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.menu-utente-voci a:hover, .menu-utente-voci button:hover { background: var(--carta-tenue); }
.menu-utente-voci .titolo-gruppo { padding: 8px 12px 4px; font-size: 0.8rem; color: var(--testo-tenue); }
.menu-utente-voci hr { border: 0; border-top: 1px solid var(--linea); margin: 6px 0; }
.menu-utente-voci a[aria-current="true"] { font-weight: 650; }

.schede { max-width: 1080px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.schede::-webkit-scrollbar { display: none; }
.schede a {
  flex: none;
  padding: 10px 12px 12px;
  color: var(--testata-tenue);
  text-decoration: none;
  font-weight: 550;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
}
.schede a:hover { color: var(--testata-testo); }
.schede a[aria-current="page"] { color: var(--testata-testo); border-bottom-color: var(--ambra); }

/* ---------- Struttura ---------- */
.pagina { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }
.titolo-pagina { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.titolo-pagina h1 { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
.titolo-pagina p { color: var(--testo-tenue); margin-top: 4px; max-width: 62ch; }
.ritorno { display: inline-block; margin-bottom: 12px; font-weight: 550; text-decoration: none; }
.ritorno:hover { text-decoration: underline; }

.due-colonne { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.pila { display: grid; gap: 20px; }

.riquadro { background: var(--carta); border: 1px solid var(--linea); border-radius: var(--raggio); box-shadow: var(--ombra); overflow: hidden; }
.riquadro-testa { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.riquadro-testa h2 { font-size: 1.05rem; font-weight: 650; }
.riquadro-testa a { font-size: 0.93rem; font-weight: 550; white-space: nowrap; }
.riquadro-corpo { padding: 16px 20px 20px; }
.vuoto { padding: 18px 20px 22px; color: var(--testo-tenue); }

/* ---------- Saldo (elemento principale del riepilogo) ---------- */
.saldo-grande { padding: 26px 24px 24px; }
.saldo-grande .sopra { color: var(--testo-tenue); }
.saldo-grande .cifra {
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
}
.saldo-grande.debito .cifra { color: var(--debito); }
.saldo-grande.credito .cifra { color: var(--credito); }
.saldo-grande .sotto { max-width: 52ch; }
.bilancia { margin-top: 22px; }
.bilancia-barra { height: 10px; border-radius: 5px; background: var(--neutro-bg); overflow: hidden; }
.bilancia-barra span { display: block; height: 100%; border-radius: 5px; background: var(--credito); }
.bilancia-legenda { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; font-size: 0.93rem; color: var(--testo-tenue); }
.bilancia-legenda b { display: block; color: var(--testo); font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.bilancia-legenda > div:last-child { text-align: right; }

/* ---------- Schede descrittive ---------- */
.voci { display: grid; gap: 0; }
.voci > div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--linea); }
.voci > div:last-child { border-bottom: 0; padding-bottom: 0; }
.voci > div:first-child { padding-top: 0; }
.voci dt { color: var(--testo-tenue); }
.voci dd { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.voci dd small { display: block; font-weight: 400; color: var(--testo-tenue); font-size: 0.85rem; }

/* ---------- Bollette ---------- */
.bollette li { border-top: 1px solid var(--linea); }
.bollette li:first-child { border-top: 0; }
.bolletta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 16px 20px;
  color: inherit;
  text-decoration: none;
}
a.bolletta:hover { background: var(--carta-tenue); color: inherit; }
.bolletta-nome { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.bolletta-nome i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.bolletta-quota { text-align: right; font-weight: 650; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bolletta-dettagli { color: var(--testo-tenue); font-size: 0.93rem; }
.bolletta-etichetta { text-align: right; color: var(--testo-tenue); font-size: 0.85rem; }
.bolletta .divisione { grid-column: 1 / -1; margin-top: 8px; }

/* La bolletta divisa: un segmento per inquilino, largo quanto la sua quota */
.divisione { display: flex; gap: 2px; height: 8px; }
.divisione span { min-width: 4px; border-radius: 2px; background: var(--neutro-bg); }
.divisione span:first-child { border-radius: 4px 2px 2px 4px; }
.divisione span:last-child { border-radius: 2px 4px 4px 2px; }
.divisione span:only-child { border-radius: 4px; }
.divisione.alta { height: 14px; }

.filtri { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filtri label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--testo-tenue); }

/* ---------- Tabelle ---------- */
.tabella-scorri { overflow-x: auto; }
table.dati { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.dati th, table.dati td { padding: 12px 20px; text-align: left; border-top: 1px solid var(--linea); vertical-align: middle; }
table.dati thead th { border-top: 0; color: var(--testo-tenue); font-weight: 600; font-size: 0.85rem; background: var(--carta-tenue); white-space: nowrap; }
table.dati .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.dati tfoot td { font-weight: 650; background: var(--carta-tenue); }
table.dati tr.io td { background: color-mix(in srgb, var(--ambra) 14%, transparent); }
table.dati td small { display: block; color: var(--testo-tenue); }

/* ---------- Etichette ---------- */
.pillola { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.pillola-ok { background: var(--credito-bg); color: var(--credito); }
.pillola-errore { background: var(--debito-bg); color: var(--debito); }
.pillola-attenzione { background: var(--attenzione-bg); color: var(--attenzione); }
.pillola-info { background: var(--info-bg); color: var(--info); }
.pillola-neutro { background: var(--neutro-bg); color: var(--neutro); }

/* ---------- Pulsanti e campi ---------- */
.pulsante {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--linea-forte);
  background: var(--carta);
  color: var(--testo);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.pulsante:hover { border-color: var(--collegamento); color: var(--collegamento); }
.pulsante.principale { background: #16424f; border-color: #16424f; color: #ffffff; }
.pulsante.principale:hover { background: #0f2f39; border-color: #0f2f39; color: #ffffff; }
.pulsante.piccolo { padding: 5px 11px; font-size: 0.87rem; border-radius: 8px; }
.pulsante.largo { width: 100%; padding: 12px 16px; }

.campo { display: grid; gap: 6px; margin-bottom: 16px; }
.campo label { font-weight: 600; }
.campo input[type="text"], .campo input[type="password"], .campo input[type="email"], .campo textarea, .campo select, .filtri select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--linea-forte);
  border-radius: 10px;
  background: var(--carta);
  color: var(--testo);
  font: inherit;
}
.filtri select { width: auto; min-width: 150px; padding: 8px 10px; }
.campo input:focus, .campo textarea:focus, .campo select:focus, .filtri select:focus {
  outline: 0;
  border-color: var(--collegamento);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--collegamento) 24%, transparent);
}
.campo .aiuto, .campo .aiuto ul { color: var(--testo-tenue); font-size: 0.87rem; }
.campo .aiuto ul { padding-left: 18px; list-style: disc; }
.campo .errore, .errori-modulo { color: var(--debito); font-size: 0.9rem; font-weight: 550; }
.errori-modulo { background: var(--debito-bg); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; }
.campo.con-errore input, .campo.con-errore textarea { border-color: var(--debito); }

.messaggi { display: grid; gap: 8px; margin-bottom: 20px; }
.messaggi li { padding: 12px 16px; border-radius: 10px; background: var(--info-bg); color: var(--testo); border: 1px solid var(--linea); }
.messaggi li.success { background: var(--credito-bg); }
.messaggi li.error { background: var(--debito-bg); }
.messaggi li.warning { background: var(--attenzione-bg); }

/* ---------- Varie ---------- */
.grafico { position: relative; height: 260px; }
.grafico.basso { height: 200px; }
.anteprima-pdf { width: 100%; height: 72vh; min-height: 420px; border: 0; display: block; background: var(--carta-tenue); }
.elenco-righe li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--linea); }
.elenco-righe li:first-child { border-top: 0; }
.elenco-righe .principale-testo { font-weight: 600; }
.elenco-righe small { display: block; color: var(--testo-tenue); font-size: 0.87rem; font-weight: 400; }
.elenco-righe .a-destra { text-align: right; flex: none; }
.elenco-righe a.riga-link { color: inherit; text-decoration: none; }
.elenco-righe a.riga-link:hover .principale-testo { color: var(--collegamento); text-decoration: underline; }
.importo { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.testo-lungo { white-space: pre-line; max-width: 68ch; }
.risposta { background: var(--carta-tenue); border-left: 3px solid var(--collegamento); border-radius: 0 10px 10px 0; padding: 14px 16px; margin-top: 16px; }
.risposta h3 { font-size: 0.9rem; color: var(--testo-tenue); font-weight: 600; margin-bottom: 4px; }
.foto-segnalazione { margin-top: 16px; border-radius: 12px; border: 1px solid var(--linea); max-height: 480px; }

/* ---------- Pagine di accesso ---------- */
.accesso { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.accesso-scheda { width: min(420px, 100%); }
.accesso-marca { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; font-weight: 650; font-size: 1.1rem; color: var(--testo); }
.accesso-marca .marca-simbolo { background: #16424f; color: #f1c453; width: 38px; height: 38px; border-radius: 11px; }
.accesso-marca .marca-simbolo svg { width: 22px; height: 22px; }
.accesso-scheda .riquadro { padding: 26px 24px; }
.accesso-scheda h1 { font-size: 1.45rem; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 6px; }
.accesso-scheda .introduzione { color: var(--testo-tenue); margin-bottom: 20px; }
.accesso-piede { margin-top: 16px; text-align: center; font-size: 0.93rem; }

@media (max-width: 820px) {
  .due-colonne { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .pagina { padding: 20px 14px 48px; }
  .testata-riga { padding: 12px 14px; }
  .schede { padding: 0 4px; }
  .titolo-pagina h1 { font-size: 1.4rem; }
  .saldo-grande { padding: 22px 18px 20px; }
  .riquadro-testa { padding: 14px 16px 0; }
  .riquadro-corpo { padding: 14px 16px 18px; }
  .bolletta, .elenco-righe li { padding-left: 16px; padding-right: 16px; }
  table.dati th, table.dati td { padding: 10px 14px; }
  .nascondi-stretto { display: none; }
  .menu-utente .nome-utente { display: none; }
  .menu-utente summary { padding: 4px; border: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.bolletta-periodo { font-weight: 400; color: var(--testo-tenue); }
table.dati td:first-child { white-space: nowrap; }

/* ---------- Affitto e bollette nel riepilogo ---------- */
.conti-due { display: grid; gap: 20px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--linea); }
.conto-testa { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.conto-testa h2 { font-size: 1.05rem; font-weight: 650; }
.conto-saldo { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--testo-tenue); white-space: nowrap; }
.conto-saldo.debito { color: var(--debito); }
.conto-saldo.credito { color: var(--credito); }
.conto .bilancia-barra span { background: var(--credito); }
.conto .bilancia-barra.parziale span { background: var(--ambra); }
.conto-nota { margin-top: 8px; color: var(--testo-tenue); font-size: 0.93rem; max-width: 62ch; }
.conto-nota strong { color: var(--debito); font-weight: 600; }

/* giorni senza inquilini: parte della bolletta che resta al proprietario */
.divisione span.senza-inquilini {
  background: repeating-linear-gradient(135deg, var(--linea-forte) 0 3px, transparent 3px 6px);
}
.nota-divisione { margin-top: 10px; color: var(--testo-tenue); font-size: 0.9rem; }
table.dati tr.riga-vuoto td { color: var(--testo-tenue); }

/* ---------- Menu a tendina della testata: tema e utente ---------- */
.testata-azioni { display: flex; align-items: center; gap: 8px; flex: none; }
.menu-tema { position: relative; }
.menu-tema summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--testata-testo);
  font-size: 0.93rem;
  font-weight: 550;
}
.menu-tema summary::-webkit-details-marker { display: none; }
.menu-tema summary:hover { background: rgba(255, 255, 255, 0.1); }
.menu-tema summary svg { width: 17px; height: 17px; flex: none; }
.menu-tema-voci {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 230px;
  background: var(--carta);
  color: var(--testo);
  border: 1px solid var(--linea);
  border-radius: 12px;
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.5);
  padding: 6px;
}
.menu-tema-voci button {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 12px 9px 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--testo);
  font: inherit;
  cursor: pointer;
  position: relative;
}
.menu-tema-voci button:hover { background: var(--carta-tenue); }
.menu-tema-voci button small { color: var(--testo-tenue); font-size: 0.85rem; }
.menu-tema-voci button[aria-pressed="true"] { font-weight: 650; }
.menu-tema-voci button[aria-pressed="true"]::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 11px;
  height: 6px;
  border-left: 2px solid var(--collegamento);
  border-bottom: 2px solid var(--collegamento);
  transform: translateY(-70%) rotate(-45deg);
}
/* nelle pagine di accesso il menu sta nell'angolo, su sfondo chiaro o scuro */
.accesso-tema { position: fixed; top: 14px; right: 16px; }
.accesso-tema .menu-tema summary { color: var(--testo); border-color: var(--linea-forte); background: var(--carta); }
.accesso-tema .menu-tema summary:hover { border-color: var(--collegamento); background: var(--carta); }
@media (max-width: 560px) {
  .menu-tema .menu-tema-testo { display: none; }
  .menu-tema summary { padding: 7px; }
}
.menu-tema-voci button { white-space: nowrap; }
.menu-tema-voci { min-width: 250px; }
.stato-pagata { color: var(--credito); font-weight: 600; }
.stato-ritardo { color: var(--debito); font-weight: 600; }
.voci dd .pillola + small { margin-top: 4px; }
