@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Schibsted"; src: url("../fonts/schibsted-grotesk-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --specchio: #EDEFF3;      /* sfondo: grigio-azzurro dello specchio di sala */
  --foglio: #FFFFFF;
  --inchiostro: #2A1B35;    /* testo: melanzana scuro */
  --fumo: #6B6277;          /* testo secondario */
  --linea: #D9D5E0;
  --rosa: #B03A6C;          /* azioni principali */
  --rosa-tenue: #F5E2EA;
  --pagato: #2B7353; --pagato-tenue: #DFF0E7;
  --manca: #9E4A16;  --manca-tenue: #F7E6D9;
  --credito: #2D5A97; --credito-tenue: #E1E9F5;
  --ombra: 0 1px 0 rgba(42, 27, 53, .06);
  --r: 14px;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --specchio: #17111C; --foglio: #221A29; --inchiostro: #F1ECF4; --fumo: #ABA2B5; --linea: #3A3042;
    --rosa: #E57BA7; --rosa-tenue: #3C2232;
    --pagato: #7FCFA7; --pagato-tenue: #1D3329; --manca: #F0A673; --manca-tenue: #3A271A;
    --credito: #93B6EA; --credito-tenue: #1E2A3D; --ombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--specchio); color: var(--inchiostro);
  font-family: "Schibsted", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--rosa); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.app {
  max-width: 680px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(var(--tab-h) + 32px + env(safe-area-inset-bottom));
}

/* ---------- Testi ---------- */
h1, h2, h3 { margin: 0; line-height: 1.15; }
.titolo { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.sottotitolo { color: var(--fumo); margin: 4px 0 0; font-size: 15px; }
.sezione { font-size: 19px; font-weight: 700; margin: 32px 0 10px; }
.muto { color: var(--fumo); }
.piccolo { font-size: 14px; }
.euro { white-space: nowrap; }

/* La frase del trimestre: l'unico elemento "forte" dell'app */
.frase {
  font-size: clamp(26px, 7.4vw, 40px); font-weight: 500; line-height: 1.18; letter-spacing: -.015em;
  margin: 18px 0 6px; text-wrap: balance;
}
.frase b { font-weight: 800; }
.frase .quota { display: block; font-weight: 800; color: var(--rosa); font-size: 1.32em; letter-spacing: -.025em; margin-top: 6px; }
.frase-nota { color: var(--fumo); font-size: 15px; margin: 0 0 8px; }

/* ---------- Selettore trimestre ---------- */
.trimestri { display: flex; gap: 6px; margin-top: 16px; overflow-x: auto; }
.trimestri button {
  border: 1.5px solid var(--linea); background: var(--foglio); border-radius: 999px;
  padding: 7px 14px; font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.trimestri button[aria-pressed="true"] { background: var(--inchiostro); border-color: var(--inchiostro); color: var(--specchio); }

/* ---------- Riquadri e righe ---------- */
.foglio { background: var(--foglio); border-radius: var(--r); box-shadow: var(--ombra); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li + li { border-top: 1px solid var(--linea); }
.riga {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 14px 16px; text-decoration: none; min-height: 56px;
}
a.riga:active { background: var(--specchio); }
.riga .nome { font-weight: 500; }
.riga .dettaglio { grid-column: 1; color: var(--fumo); font-size: 14px; }
.riga .valore { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-weight: 700; }
.riga .valore small { display: block; font-weight: 400; color: var(--fumo); font-size: 13px; }

/* Barra di avanzamento di un corso: come una sbarra della sala */
.sbarra { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--manca-tenue); overflow: hidden; margin-top: 8px; }
.sbarra i { display: block; height: 100%; background: var(--pagato); border-radius: 3px; }

/* ---------- Stato pagamento ---------- */
.stato { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.stato.ok { background: var(--pagato-tenue); color: var(--pagato); }
.stato.manca { background: var(--manca-tenue); color: var(--manca); }
.stato.credito { background: var(--credito-tenue); color: var(--credito); }
.stato.attesa { background: var(--specchio); color: var(--fumo); }

/* ---------- Totali ---------- */
.conti { display: grid; grid-template-columns: 1fr auto; padding: 6px 16px; }
.conti dt, .conti dd { padding: 10px 0; margin: 0; border-top: 1px solid var(--linea); }
.conti dt:first-of-type, .conti dd:first-of-type { border-top: 0; }
.conti dd { text-align: right; font-weight: 700; }
.conti .forte { font-weight: 800; color: var(--rosa); }

/* ---------- Pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 700; cursor: pointer;
  background: var(--rosa); color: #fff; text-decoration: none; min-height: 48px;
}
.btn.secondario { background: var(--foglio); color: var(--inchiostro); border: 1.5px solid var(--linea); }
.btn.pericolo { background: transparent; color: var(--manca); border: 1.5px solid var(--manca-tenue); }
.btn.piccolo { padding: 8px 12px; min-height: 38px; font-size: 15px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.largo { width: 100%; }
.azioni { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.indietro { display: inline-flex; align-items: center; gap: 4px; color: var(--fumo); text-decoration: none; font-weight: 500; margin-bottom: 10px; padding: 6px 0; }
.testata { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- Moduli ---------- */
.campi { display: grid; gap: 14px; padding: 16px; }
.campo { display: grid; gap: 5px; }
.campo label, .campo .etichetta { font-size: 14px; font-weight: 500; color: var(--fumo); }
.campo input, .campo select, .campo textarea {
  width: 100%; border: 1.5px solid var(--linea); background: var(--foglio); border-radius: 10px;
  padding: 11px 12px; min-height: 46px; font-size: 17px;
}
.campo textarea { min-height: 72px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--rosa); }
.campo input[readonly], .campo select:disabled, .campo textarea[readonly] { background: transparent; border-color: transparent; padding-left: 0; }
.due { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spunta { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.spunta input { width: 22px; height: 22px; accent-color: var(--rosa); }
.aiuto { font-size: 14px; color: var(--fumo); margin: 0; }

/* Scheda pagamento di un trimestre */
.trimestre-card { margin-top: 12px; }
.trimestre-card summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; cursor: pointer; list-style: none; min-height: 52px; }
.trimestre-card summary::-webkit-details-marker { display: none; }
.trimestre-card summary h3::before { content: ""; display: inline-block; width: 7px; height: 7px; margin: 0 10px 2px 2px; border-right: 2px solid var(--fumo); border-bottom: 2px solid var(--fumo); transform: rotate(-45deg); transition: transform .15s; }
.trimestre-card[open] summary h3::before { transform: rotate(45deg); }
.trimestre-card[open] summary { padding-bottom: 0; }
.trimestre-card h3 { font-size: 17px; }
.avviso { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; font-size: 15px; background: var(--credito-tenue); color: var(--credito); }
.avviso.manca { background: var(--manca-tenue); color: var(--manca); }

/* ---------- Cerca ---------- */
.cerca { position: relative; margin: 16px 0 4px; }
.cerca input { width: 100%; border: 1.5px solid var(--linea); background: var(--foglio); border-radius: 12px; padding: 12px 14px 12px 42px; font-size: 17px; }
.cerca svg { position: absolute; left: 13px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); stroke: var(--fumo); fill: none; stroke-width: 2; }

/* ---------- Confronto ---------- */
.carica {
  display: grid; place-items: center; gap: 6px; text-align: center; padding: 28px 16px;
  border: 2px dashed var(--linea); border-radius: var(--r); background: var(--foglio); cursor: pointer;
}
.carica strong { font-size: 18px; }
.carica input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.esito { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.esito div { background: var(--foglio); border-radius: 12px; padding: 12px 14px; }
.esito b { display: block; font-size: 24px; font-weight: 800; }
.diff { font-size: 14px; color: var(--fumo); }
.diff s { color: var(--manca); text-decoration-thickness: 1.5px; }

/* ---------- Accesso ---------- */
.accesso { min-height: 80vh; display: grid; align-content: center; gap: 24px; }
.marchio { width: 64px; height: 64px; border-radius: 18px; }
.errore { color: var(--manca); font-weight: 500; margin: 0; }

/* ---------- Barra in basso ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--foglio); border-top: 1px solid var(--linea);
}
.tabbar a { display: grid; place-items: center; align-content: center; gap: 3px; text-decoration: none; color: var(--fumo); font-size: 12px; font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar svg circle[r="1.6"] { fill: currentColor; stroke: none; }
.tabbar a[aria-current="page"] { color: var(--rosa); }

.offline { position: sticky; top: 0; z-index: 20; background: var(--manca); color: #fff; font-size: 14px; padding: 8px 16px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--inchiostro); color: var(--specchio); padding: 11px 18px; border-radius: 12px; font-weight: 500; z-index: 30;
  max-width: calc(100% - 32px);
}
.etichetta-ruolo { font-size: 13px; font-weight: 700; color: var(--credito); background: var(--credito-tenue); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.vuoto { padding: 24px 16px; text-align: center; color: var(--fumo); }
.caricamento { padding: 40px 0; color: var(--fumo); text-align: center; }

@media (min-width: 720px) {
  .app { padding-top: 40px; }
}
@media (prefers-reduced-motion: no-preference) {
  .sbarra i { transition: width .5s ease-out; }
}
