/* ---- Font Roboto (file locali: nessuna richiesta a Google) ---- */
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/roboto-400.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/roboto-500.woff2") format("woff2"); }
@font-face { font-family: "Roboto"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/roboto-700.woff2") format("woff2"); }

:root {
  --sfondo: #eeeeee;
  --menu: #242021;             /* area menu a sinistra */
  --riquadro: #77bb21;         /* colore dei riquadri */
  --bottone: #242021;          /* sfondo dei bottoni */
  --bottone-hover: #433d3f;
  --bottone-testo: #ffffff;    /* testo dei bottoni */
  --ink: #242021;
  --surface: #ffffff;
  --rule: #d9d9d9;
  --muted: #5f5a5b;
  --link: #3d6a0c;
  --ok-bg: #e3f1cc;
  --ok-testo: #2f5707;
  --warn: #8a5600;
  --warn-bg: #f5ead2;
  --bad: #a3302b;
  --bad-bg: #f6dfdc;
  --font: "Roboto", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; font-family: var(--font); font-size: 1rem; color: var(--ink); background: var(--sfondo);
  line-height: 1.5; font-variant-numeric: tabular-nums;
}
h1 { font-size: 1.7rem; font-weight: 500; letter-spacing: -0.01em; margin: 0 0 1.25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; font-weight: 500; margin: 2rem 0 .75rem; }
p { margin: 0 0 .9rem; max-width: 70ch; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 4px var(--riquadro); }

/* ---- Struttura admin ---- */
body.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.barra {
  background: var(--menu); color: #d9d6d7; padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1.5rem; position: sticky; top: 0; height: 100vh;
}
.barra :focus-visible { outline-color: #fff; box-shadow: none; }
.logo { display: block; text-decoration: none; background: #fff; border-bottom: 4px solid var(--riquadro); padding: .6rem .75rem .4rem; text-align: center; }
.logo img { display: block; width: 100%; max-width: 150px; height: auto; margin: 0 auto; }
.logo-nome { display: block; font-size: .85rem; color: var(--muted); padding-top: .15rem; }
.barra nav { display: flex; flex-direction: column; gap: 2px; }
.voce { color: #e9e7e8; text-decoration: none; padding: .5rem .75rem; border-left: 3px solid transparent; }
.voce:hover { background: rgba(255,255,255,.08); }
.voce-attiva { border-left-color: var(--riquadro); background: rgba(255,255,255,.12); color: #fff; font-weight: 500; }
.utente { margin-top: auto; border-top: 1px solid #4a4446; padding-top: .9rem; font-size: .93rem; }
.utente-nome { display: block; margin-bottom: .25rem; }
.contenuto { padding: 2rem 2.5rem 4rem; max-width: 1100px; width: 100%; }

/* ---- Pagine pubbliche ---- */
body.pubblica { display: flex; justify-content: center; padding: 3rem 1rem; }
.scheda { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--riquadro); border-top-width: 4px; padding: 2rem; align-self: flex-start; }
.scheda .logo { background: none; border: 0; padding: 0 0 1.25rem; }
.scheda .logo img { max-width: 170px; }

/* ---- Form ---- */
label { display: block; font-weight: 500; margin: 0 0 .25rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid #8f8a8b; background: #fff; color: var(--ink); border-radius: 2px;
}
textarea { min-height: 5rem; resize: vertical; }
input[type=file] { font: inherit; width: 100%; padding: .5rem; border: 1px dashed #8f8a8b; background: #fff; }
.campo { margin-bottom: 1rem; }
.campo-breve { max-width: 12rem; }
.riga-campi { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.riga-campi .campo { margin-bottom: 0; }
.aiuto { color: var(--muted); font-size: .9rem; margin-top: .25rem; }

/* ---- Bottoni ---- */
button, .bottone {
  font: inherit; font-weight: 500; cursor: pointer; border: 1px solid var(--bottone); background: var(--bottone); color: var(--bottone-testo);
  padding: .55rem 1.1rem; border-radius: 2px; text-decoration: none; display: inline-block;
}
button:hover, .bottone:hover { background: var(--bottone-hover); border-color: var(--bottone-hover); }
button.secondario { background: #fff; color: var(--bottone); }
button.secondario:hover { background: #e6e6e6; }
button.pericolo { background: #fff; color: var(--bad); border-color: var(--bad); }
button.pericolo:hover { background: var(--bad-bg); }
button.link { background: none; border: 0; padding: 0; color: #b9e07a; text-decoration: underline; font-weight: 400; }
button.link:hover { background: none; color: #fff; }
.azioni { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.azioni form { margin: 0; }
.spaziato { margin-top: 1rem; }

/* ---- Tabelle ---- */
.tabella-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--riquadro); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 500; font-size: .9rem; color: var(--muted); background: #f6f6f6; white-space: nowrap; border-bottom: 2px solid var(--riquadro); }
tr:last-child td { border-bottom: 0; }
td.vuoto { color: var(--muted); padding: 1.5rem .85rem; }
.num { text-align: right; }
.nome-doc { word-break: break-word; }
.hash { font-family: Consolas, "Courier New", monospace; font-size: .85rem; color: var(--muted); }

/* ---- Pannelli e dettagli ---- */
.pannello { background: var(--surface); border: 1px solid var(--riquadro); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; max-width: 640px; }
.pannello h2 { margin-top: 0; }
.dati { display: grid; grid-template-columns: 11rem 1fr; gap: .35rem 1rem; margin: 0; }
.dati dt { color: var(--muted); }
.dati dd { margin: 0; }
.riepilogo { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.riepilogo > div { background: var(--surface); border: 1px solid var(--riquadro); border-top-width: 4px; padding: .7rem 1.1rem; min-width: 9.5rem; }
.riepilogo b { display: block; font-size: 1.9rem; line-height: 1.1; font-weight: 500; }
.riepilogo span { color: var(--muted); font-size: .9rem; }

/* ---- Stati e avvisi ---- */
.stato { display: inline-block; padding: .08rem .55rem; border: 1px solid currentColor; font-size: .88rem; border-radius: 2px; white-space: nowrap; }
.stato-attivo { color: var(--ok-testo); background: var(--ok-bg); }
.stato-attesa { color: var(--warn); background: var(--warn-bg); }
.stato-sospeso { color: #4d4748; background: #e3e1e1; }
.stato-bloccato { color: var(--bad); background: var(--bad-bg); }
.avviso { padding: .7rem 1rem; margin-bottom: 1.1rem; border-left: 4px solid; max-width: 70ch; background: #fff; }
.avviso-ok { background: var(--ok-bg); border-color: var(--riquadro); }
.avviso-errore { background: var(--bad-bg); border-color: var(--bad); }
.avviso-avviso { background: var(--warn-bg); border-color: #c98a00; }
.ko { color: var(--bad); font-weight: 500; }
.ok { color: var(--ok-testo); font-weight: 500; }
.ricerca { display: flex; gap: .6rem; margin-bottom: 1rem; max-width: 460px; }
.ricerca input { flex: 1; }

@media (max-width: 800px) {
  body.admin { grid-template-columns: 1fr; }
  .barra { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; }
  .logo { padding: .35rem .6rem; }
  .logo img { max-width: 70px; }
  .logo-nome { display: none; }
  .barra nav { flex-direction: row; flex-wrap: wrap; }
  .utente { margin: 0 0 0 auto; border: 0; padding: 0; }
  .contenuto { padding: 1.25rem 1rem 3rem; }
  .dati { grid-template-columns: 1fr; }
  .dati dt { margin-top: .5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
