:root {
  --fondo: #e9eeec;
  --carta: #fbfcfb;
  --inchiostro: #10272b;
  --tenue: #5b6f72;
  --linea: #cfd9d6;
  --luce: #e2a400;
  --gas: #2463d6;
  --verde: #0b7a52;
  --arancio: #b8430a;
  --display: #0d1f22;
  --display-cifre: #8ff0b8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0e1719; --carta: #152225; --inchiostro: #e3ecea; --tenue: #93a6a8;
    --linea: #28393c; --display: #050b0c; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fondo); color: var(--inchiostro);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-underline-offset: 3px; }
main { max-width: 900px; margin: 0 auto; padding: 16px 16px 64px; }
.barra { display: flex; justify-content: space-between; align-items: center; max-width: 900px; margin: 0 auto; padding: 16px; }
.marchio { font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.marchio span { font-weight: 400; color: var(--tenue); margin-left: .4em; }
button { font: inherit; background: var(--inchiostro); color: var(--carta); border: 0; border-radius: 8px; padding: .6em 1.1em; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--gas); outline-offset: 2px; }
button.link { background: none; color: var(--tenue); padding: 0; text-decoration: underline; }
button.pericolo { background: none; color: var(--arancio); border: 1px solid currentColor; }
section { background: var(--carta); border: 1px solid var(--linea); border-radius: 14px; padding: 20px; margin: 16px 0; }
h1, h2 { line-height: 1.2; margin: 0 0 .4em; }
h2 { font-size: 1.2rem; }
small { color: var(--tenue); font-size: .82rem; }

/* Il contatore: l'unico elemento che alza la voce. */
.contatore { background: var(--display); color: #cfe3de; border: 0; padding: 24px 24px 20px; }
.contatore .didascalia { margin: 0; font-size: .95rem; }
.contatore .cifre {
  margin: .1em 0; color: var(--display-cifre); font: 700 clamp(3.5rem, 14vw, 6.5rem)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .04em; text-shadow: 0 0 18px rgba(143, 240, 184, .35);
}
.contatore .cifre small { font-size: .28em; color: #cfe3de; letter-spacing: 0; margin-left: .5em; font-family: system-ui, sans-serif; font-weight: 500; }
.contatore .sotto { margin: .6em 0 0; font-size: .85rem; color: #9fb7b2; max-width: 60ch; }

.scadenze { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; background: none; border: 0; padding: 0; }
.scadenze div, .confronto div { background: var(--carta); border: 1px solid var(--linea); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; }
.scadenze span, .confronto span { color: var(--tenue); font-size: .85rem; }
.scadenze strong, .confronto strong { font-size: 1.5rem; }
.scadenze em, .confronto em { font-style: normal; font-size: .85rem; color: var(--tenue); }
.scadenze .urgente { border-color: var(--arancio); }
.scadenze .urgente em { color: var(--arancio); }

.fornitura { border-top: 6px solid var(--linea); }
.fornitura.luce { border-top-color: var(--luce); }
.fornitura.gas { border-top-color: var(--gas); }
.fornitura header p { margin: 0 0 12px; color: var(--tenue); }
.confronto { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.confronto .meglio { border-color: var(--verde); }
.confronto .meglio em { color: var(--verde); font-weight: 600; }
.nota { font-size: .85rem; color: var(--tenue); }

table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--linea); vertical-align: top; }
th { font-size: .8rem; color: var(--tenue); font-weight: 500; }
td small { display: block; }
.n { text-align: right; white-space: nowrap; }
tbody tr:first-child td:first-child a { font-weight: 700; }
details summary { cursor: pointer; color: var(--tenue); }
details p { font-size: .9rem; }

.ok { color: var(--verde); } .ko { color: var(--arancio); }
.controlli { list-style: none; padding: 0; }
.controlli .fallito { color: var(--arancio); } .controlli .ok { color: var(--verde); }
.avviso, .errore { background: #fff3e6; color: #7a2e06; border-radius: 8px; padding: .6em .9em; }
@media (prefers-color-scheme: dark) { .avviso, .errore { background: #3a220f; color: #ffd8b8; } }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dt { color: var(--tenue); }
dd { margin: 0; }

.carica { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 16px; }
.carica label, .accesso label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--tenue); }
input { font: inherit; padding: .5em .6em; border: 1px solid var(--linea); border-radius: 8px; background: var(--carta); color: var(--inchiostro); }
.accesso { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 14px; background: var(--carta); padding: 24px; border-radius: 14px; border: 1px solid var(--linea); }
.vuoto p { max-width: 60ch; }

@media (max-width: 600px) {
  .confronto { grid-template-columns: 1fr; }
  table:not(.voci) thead th:nth-child(3), table:not(.voci) tbody td:nth-child(3) { display: none; }
  dl { grid-template-columns: 1fr; } dt { margin-top: 6px; }
}

/* I codici offerta sono stringhe lunghe senza spazi: vanno a capo invece di allargare la pagina. */
td small { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  section { padding: 14px; }
  th, td { padding: 8px 4px; }
  td:first-child { width: 100%; }
  .archivio thead th:nth-child(3), .archivio tbody td:nth-child(3) { display: none; }
}

/* Scomposizione della spesa per voce ARERA */
.contatore .risparmio { color: var(--display-cifre); font-size: 1rem; }
table.voci { font-size: .9rem; }
table.voci tr.tot th, table.voci tr.tot td { font-weight: 700; border-top: 2px solid var(--inchiostro); }
table.voci caption { text-align: left; color: var(--tenue); font-size: .8rem; padding-bottom: 4px; }
table.voci th[scope=row] { font-weight: 600; color: var(--inchiostro); font-size: .9rem; }
.solo-stretto { display: none; }
@media (max-width: 600px) { .solo-largo { display: none; } .solo-stretto { display: inline; } }
@media (max-width: 600px) { table.voci { font-size: .82rem; } table.voci th, table.voci td { padding: 7px 3px; } }
table.voci small { display: inline; }
@media (max-width: 420px) { table.voci small.solo-largo-i { display: none; } }
table.voci thead th.n { white-space: normal; }
@media (max-width: 400px) { table.voci .diff { display: none; } }
input[type=file] { max-width: 100%; }
.carica label { max-width: 100%; }
@media (max-width: 400px) { .archivio thead th:nth-child(5), .archivio tbody td:nth-child(5) { display: none; } }
.fornitura.dual { border-top-color: var(--verde); } .fornitura.dual th small { display: block; font-weight: 400; }
