:root {
  --sfondo: #f7f3ee;
  --carta: #ffffff;
  --testo: #2a211c;
  --tenue: #6f625a;
  --bordo: #e4dbd2;
  --accento: #9c2f1f;      /* rosso salsiccia */
  --accento-testo: #ffffff;
  --sabato: #c9773b;
  --domenica: #9c2f1f;
  --pioggia: #2f6fa8;
  --temperatura: #b8860b;
  --positivo: #2e7d4f;
  --negativo: #b3261e;
  --ombra: 0 1px 2px rgba(42, 33, 28, .06), 0 2px 8px rgba(42, 33, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #1b1714;
    --carta: #26201c;
    --testo: #efe7df;
    --tenue: #b3a69c;
    --bordo: #3a312b;
    --accento: #e0745f;
    --accento-testo: #1b1714;
    --sabato: #e3a06a;
    --domenica: #e0745f;
    --pioggia: #6aa8e0;
    --temperatura: #e0b84a;
    --positivo: #6fc493;
    --negativo: #f08a80;
    --ombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; margin-bottom: .25rem; }
.occhiello { margin: 0 0 .15rem; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accento); font-weight: 600; }
.nota { color: var(--tenue); font-size: .88rem; margin: .2rem 0 .6rem; }
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--accento); color: var(--accento-testo); border: 0; border-radius: 8px;
  padding: .5rem 1rem; cursor: pointer; font-weight: 600;
}
button.secondario { background: transparent; color: var(--testo); border: 1px solid var(--bordo); font-weight: 500; }
select, input[type=password] {
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 8px; padding: .35rem .5rem;
}

/* accesso */
body.accesso { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.scheda-accesso {
  width: 100%; max-width: 380px; background: var(--carta); border: 1px solid var(--bordo);
  border-radius: 14px; padding: 1.75rem; box-shadow: var(--ombra);
}
.scheda-accesso form { display: grid; gap: .5rem; margin-top: 1rem; }
.scheda-accesso input { width: 100%; padding: .6rem .7rem; }
.scheda-accesso button { margin-top: .5rem; padding: .65rem; }
.errore { color: var(--negativo); margin: 0; font-size: .9rem; }

/* testata e schede */
.testata {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  padding: 1.25rem 16px .75rem; max-width: 1200px; margin: 0 auto;
}
.testata-destra { display: flex; align-items: center; gap: .75rem; }
.testata-destra .nota { margin: 0; }
.schede {
  display: flex; gap: .25rem; overflow-x: auto; padding: 0 16px; max-width: 1200px; margin: 0 auto;
  border-bottom: 1px solid var(--bordo); scrollbar-width: none;
}
.schede button {
  background: none; color: var(--tenue); border-radius: 0; padding: .6rem .85rem; font-weight: 500;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.schede button[aria-selected=true] { color: var(--testo); border-bottom-color: var(--accento); font-weight: 600; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }
.vista { display: grid; gap: 1rem; }
.vista[hidden] { display: none; }

.riquadro { background: var(--carta); border: 1px solid var(--bordo); border-radius: 12px; padding: 1rem; box-shadow: var(--ombra); min-width: 0; }
.comandi { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin: .25rem 0; }
.comandi label { display: inline-flex; align-items: center; gap: .4rem; font-size: .92rem; }
.grafico { position: relative; height: 320px; }
.grafico.alto { height: 400px; }

/* edizioni */
.griglia-edizioni { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: .75rem; }
.edizione { background: var(--carta); border: 1px solid var(--bordo); border-radius: 12px; padding: .9rem 1rem; box-shadow: var(--ombra); }
.edizione .anno { font-size: .85rem; color: var(--tenue); font-weight: 600; }
.edizione .totale { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.edizione .sotto { font-size: .82rem; color: var(--tenue); }
.edizione ul { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; }
.edizione li { display: grid; grid-template-columns: 5.2em 5.5em 1fr; gap: .5rem; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.edizione li > :nth-child(2) { text-align: right; }
.edizione li .tempo { text-align: right; overflow: hidden; text-overflow: ellipsis; }
.tempo { white-space: nowrap; }
.tempo.piove { color: var(--pioggia); font-weight: 600; }

/* tabelle */
.tabella-scorre { overflow-x: auto; padding: 0; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .9rem; }
th, td { padding: .5rem .7rem; text-align: right; border-bottom: 1px solid var(--bordo); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--carta); }
thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tenue); font-weight: 600; }
tbody tr { cursor: default; }
#t-articoli tbody tr { cursor: pointer; }
#t-articoli tbody tr:hover td, #t-articoli tbody tr.scelto td { background: color-mix(in srgb, var(--accento) 8%, var(--carta)); }
tr.categoria td { font-weight: 700; color: var(--accento); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; background: var(--sfondo); }
td.su { color: var(--positivo); }
td.giu { color: var(--negativo); }
td.vuoto { color: var(--bordo); }
td.forte { font-weight: 700; }
td.piove { color: var(--pioggia); font-weight: 600; }

@media (max-width: 600px) {
  h1 { font-size: 1.2rem; }
  .grafico { height: 260px; }
  .grafico.alto { height: 320px; }
  th, td { padding: .45rem .5rem; }
}
