:root {
  --bg: #fbfaf8;
  --fg: #1d1d1b;
  --muted: #66655f;
  --line: #ddd9d1;
  --hover: #f3f1ec;
  --field: #ffffff;
  --accent: #1d1d1b;
  --accent-fg: #fbfaf8;
  --ok-bg: #e6f3ec;
  --ok-fg: #1e5c3b;
  --err-bg: #fbe9e7;
  --err-fg: #8a1f14;
  --focus: #2b5fd9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --fg: #ece9e2;
    --muted: #a09d94;
    --line: #34332f;
    --hover: #1d1d1b;
    --field: #1c1c1a;
    --accent: #ece9e2;
    --accent-fg: #151514;
    --ok-bg: #16281f;
    --ok-fg: #8fd3ad;
    --err-bg: #2e1815;
    --err-fg: #f0a79d;
    --focus: #8fb0ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
a { color: inherit; text-underline-offset: 0.18em; }
code { font-size: 0.9em; background: var(--hover); padding: 0.05rem 0.3rem; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muto, .nota, .aiuto { color: var(--muted); }
.nota { font-size: 0.9rem; margin: 0 0 1.25rem; }

/* barra in alto */
.barra {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--line); max-width: none;
}
.barra nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.95rem; }
.barra a { text-decoration: none; }
.barra a:hover { text-decoration: underline; }
.barra form { margin: 0; }
button.link { font: inherit; font-size: 0.95rem; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
button.link:hover { color: var(--fg); }

/* messaggi */
.avviso { padding: 0.7rem 0.9rem; border-radius: 8px; margin: 0 0 1.25rem; }
.avviso.ok { background: var(--ok-bg); color: var(--ok-fg); }
.avviso.errore { background: var(--err-bg); color: var(--err-fg); }
.avviso ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

/* testata e tabella */
.testata { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; }
.azioni { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.azioni form { margin: 0; }
.tabella-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.6rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tbody th { font-weight: 600; }
tbody tr:hover { background: var(--hover); }
.pill { display: inline-block; padding: 0.05rem 0.55rem; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line); white-space: nowrap; }
.pill.si { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.pill.no { color: var(--muted); }

/* bottoni */
.bottone, button.bottone {
  display: inline-block; font: inherit; font-size: 0.95rem; padding: 0.5rem 0.95rem; cursor: pointer;
  border: 1px solid var(--fg); border-radius: 8px; background: transparent; color: var(--fg); text-decoration: none;
}
.bottone:hover { background: var(--hover); }
.bottone.primario, button.primario { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.bottone.primario:hover, button.primario:hover { opacity: 0.88; background: var(--accent); }
.bottone.pericolo { color: var(--err-fg); border-color: var(--err-fg); }
button.primario { font: inherit; font-size: 0.95rem; padding: 0.55rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent); cursor: pointer; }

/* moduli */
.modulo { display: grid; gap: 1rem; max-width: 24rem; }
.modulo.largo { max-width: none; gap: 1.5rem; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem 1.1rem; margin: 0; display: grid; gap: 1rem; min-width: 0; }
legend { padding: 0 0.4rem; font-weight: 600; }
label { display: grid; align-content: start; gap: 0.3rem; font-size: 0.95rem; font-weight: 500; min-width: 0; }
label.spunta { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
input[type="text"], input[type="password"], input[type="url"], input[type="search"], select, textarea {
  font: inherit; font-weight: 400; width: 100%; padding: 0.5rem 0.65rem; color: var(--fg);
  background: var(--field); border: 1px solid var(--line); border-radius: 8px;
}
input[type="file"] { font: inherit; font-weight: 400; font-size: 0.9rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }
textarea { resize: vertical; line-height: 1.5; }
.aiuto { font-size: 0.82rem; font-weight: 400; }
.griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; }
.anteprima-icona img { border-radius: 12px; display: block; background: var(--hover); }
.righes-link, .righe-link { display: grid; gap: 0.5rem; }
.righe-link { gap: 0.6rem; }
.riga-link { display: grid; grid-template-columns: 11rem 1fr 1.6fr; gap: 0.5rem; }
.riga-link.senza-tipo { grid-template-columns: 1fr 1.6fr; }
.barra-azioni { display: flex; gap: 1rem; align-items: center; }
.elimina { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.indietro { margin: 0; font-size: 0.9rem; }
.indietro a { color: var(--muted); text-decoration: none; }
.indietro a:hover { color: var(--fg); text-decoration: underline; }
.accesso { max-width: 24rem; margin: 3rem auto 0; }

@media (max-width: 40rem) {
  .riga-link, .riga-link.senza-tipo { grid-template-columns: 1fr; padding-bottom: 0.6rem; border-bottom: 1px dashed var(--line); }
}
