/* KASSANDRA - interfaccia web. Mobile first: gli stili base sono per lo smartphone,
   i @media (min-width) aggiungono spazio e colonne su tablet e desktop. */
:root {
  --ink: #17324d; --ink-2: #33475b; --ink-3: #4c5c6e;
  --bg: #f5f7fa; --card: #fff; --line: #d5dde6; --campo: #5c6f82;
  --teal: #0066cc; --teal-2: #3d8fe0; --blue: #0066cc; --red: #b3261e; --amber: #8a4b00; --green: #1a6b36;
  --focus: #ff9900; --testata: #004d99;
  --raggio: 10px; --ombra: 0 10px 30px rgba(31, 41, 55, .08);
  --nav-h: 64px; --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e8eef6; --ink-2: #c3cfdd; --ink-3: #a3b2c4; --bg: #0c1522; --card: #142133; --line: #2b3d55; --campo: #8aa0b8;
    --teal: #6db3ff; --teal-2: #6db3ff; --blue: #8cc4ff; --red: #ff9a92; --amber: #ffbf66; --green: #7fd69a; --focus: #ffbf47; --testata: #0c1522; --ombra: none; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-width: 320px; color: var(--ink); background: var(--bg);
  font: 1rem/1.6 "Titillium Web", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; box-shadow: 0 0 0 5px rgba(0,0,0,.55); }
@media (prefers-color-scheme: dark) { :focus-visible { box-shadow: 0 0 0 5px rgba(255,255,255,.35); } }
.salta { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--card); color: var(--ink); padding: 12px 18px; border: 2px solid var(--teal); border-radius: 8px; font-weight: 700; }
.salta:focus { top: 8px; }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .btn, .segmenti a, .scelta, .card { border: 1px solid CanvasText; } }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; font-weight: 700; } h2 { font-size: 1.3rem; font-weight: 700; } h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-3); } .small { font-size: .9rem; } .num { font-variant-numeric: tabular-nums; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- intestazione --- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gutter); padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line); border-top: 4px solid var(--teal);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: .1em; font-size: 1.05rem; }
.brand, .brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.top .spazio { flex: 1; }
.top form { margin: 0; }
.utente { display: none; color: var(--ink-3); font-size: .85rem; }

/* --- navigazione: barra in basso su mobile, colonna a sinistra su desktop --- */
.nav {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); font-size: .8rem; font-weight: 700; min-height: 48px;
}
.nav a svg { width: 24px; height: 24px; }
.nav a svg .f { fill: transparent; transition: fill .15s; }
.nav a[aria-current="page"] svg .f { fill: currentColor; fill-opacity: .16; }
.nav a, .nav a:hover { text-decoration: none; }
.nav a:hover { color: var(--ink); background: rgba(0,102,204,.08); }
.nav a[aria-current="page"] { color: var(--teal); box-shadow: inset 0 3px 0 var(--teal); }

main { padding: var(--gutter); max-width: 1100px; margin: 0 auto; }
.intest { margin: .5rem 0 1.25rem; padding-bottom: .75rem; border-bottom: 2px solid var(--line); }
.intest .sopra { color: var(--teal); font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .25rem; }
.indietro { display: inline-block; margin-bottom: .5rem; font-size: .9rem; font-weight: 700; }

/* --- componenti --- */
.card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: var(--raggio); padding: 14px; box-shadow: var(--ombra); margin-bottom: 14px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.griglia { display: grid; gap: 12px; grid-template-columns: 1fr; }
.scelta { display: block; color: var(--ink); padding: 18px; border-radius: var(--raggio); border: 1px solid var(--line); background: var(--card); box-shadow: var(--ombra); min-height: 96px; }
.scelta, .scelta:hover, .btn, .btn:hover, .segmenti a, .segmenti a:hover, .elenco a.riga, .elenco a.riga:hover, .utente { text-decoration: none; }
.scelta:hover { border-color: var(--teal); box-shadow: 0 6px 22px rgba(0,77,153,.16); transform: translateY(-2px); }
.scelta { transition: transform .15s, box-shadow .15s, border-color .15s; }
.scelta strong { display: block; font-size: 1.15rem; margin-bottom: 4px; }
.scelta span { color: var(--ink-3); font-size: .9rem; }
.dati { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.dato { background: var(--card); border: 1px solid var(--line); border-radius: var(--raggio); padding: 12px; }
.dato b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; } .dato span { color: var(--ink-3); font-size: .8rem; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; background: rgba(0,102,204,.1); border: 1px solid var(--teal); color: var(--teal); font-size: .8rem; font-weight: 700; }
.chip.rosso { background: rgba(179,38,30,.1); color: var(--red); border-color: var(--red); } .chip.ambra { background: rgba(138,75,0,.1); color: var(--amber); border-color: var(--amber); }
.pallino { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.avviso { padding: 12px 14px 12px 44px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; border: 2px solid; position: relative; background-repeat: no-repeat; background-position: 12px 12px; background-size: 22px; }
.avviso::before { content: ""; position: absolute; left: 12px; top: 13px; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico) center/contain no-repeat; mask: var(--ico) center/contain no-repeat; }
.avviso.ok { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/%3E%3C/svg%3E"); }
.avviso.errore { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2L1 21h22zm1 15h-2v-2h2zm0-4h-2V9h2z'/%3E%3C/svg%3E"); }
.avviso.ok { background: rgba(26,107,54,.1); color: var(--green); border-color: var(--green); }
.avviso.errore { background: rgba(179,38,30,.08); color: var(--red); border-color: var(--red); }

/* --- liste: su mobile ogni riga e' una scheda --- */
.elenco { list-style: none; margin: 0; padding: 0; }
.elenco li { border-top: 1px solid var(--line); }
.elenco li:first-child { border-top: 0; }
.elenco a.riga, .elenco .riga { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 12px 0; color: var(--ink); min-height: 48px; }
.elenco a.riga:hover { text-decoration: none; }
.elenco .t { min-width: 0; } .elenco .t b { display: block; overflow-wrap: anywhere; } .elenco .t span { color: var(--ink-3); font-size: .85rem; }
.tabella-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
tbody tr:hover { background: rgba(0,102,204,.05); }
.tabella-scroll:focus-visible { outline-offset: -3px; }
th, td { text-align: left; padding: 8px 10px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-top: 0; white-space: nowrap; }
td.num, th.num { text-align: right; }

/* --- moduli: campi a 16px per evitare lo zoom di iOS, bersagli da 44px --- */
label { display: block; font-weight: 700; font-size: .95rem; margin: 14px 0 4px; }
.req { color: var(--red); font-weight: 700; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--card); border: 2px solid var(--campo); border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px;
  font: inherit; font-weight: 700; color: #fff; background: var(--teal); border: 2px solid var(--teal); border-radius: 6px; cursor: pointer; text-align: center; transition: background .15s;
}
@media (prefers-color-scheme: dark) { .btn { color: #00264d; } .btn.secondario, .btn.pericolo { color: var(--ink); } .segmenti a[aria-current="true"] { color: #00264d; } }
.btn:hover { background: var(--testata); border-color: var(--testata); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondario { color: var(--teal); background: transparent; border: 2px solid var(--teal); }
.btn.secondario:hover { background: rgba(0,102,204,.1); color: var(--teal); border-color: var(--teal); }
.btn.pericolo { color: var(--red); background: transparent; border: 2px solid var(--red); }
.btn.pericolo:hover { background: rgba(179,38,30,.1); color: var(--red); border-color: var(--red); }
.btn.piccolo { min-height: 36px; padding: 4px 10px; font-size: .85rem; }
.btn.pieno { width: 100%; }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.riga-campi { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.riga-campi .largo { grid-column: 1 / -1; }
.segmenti { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.segmenti a { padding: 8px 16px; border-radius: 99px; border: 2px solid var(--teal); background: var(--card); color: var(--teal); font-weight: 700; font-size: .95rem; min-height: 40px; display: inline-flex; align-items: center; }
.segmenti a[aria-current="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.segmenti a[aria-current="true"]::before { content: "\2713\00a0"; }
.segmenti a:hover { text-decoration: none; }
.paginazione { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
details > summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
pre.verbale { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; max-height: 60vh; overflow: auto; background: var(--bg); border-radius: 8px; padding: 10px; }
.barra { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; margin: 6px 0 2px; }
.barra i { display: block; height: 100%; }
.vuoto { text-align: center; color: var(--ink-3); padding: 28px 8px; }

/* --- login --- */
.accesso { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.accesso .card { width: min(440px, 100%); padding: 24px; }
.accesso img { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 12px; }
.accesso h1 { font-size: 2rem; letter-spacing: -.04em; }
body.senza-nav { padding-bottom: 0; }

/* --- tablet --- */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  h1 { font-size: 2rem; }
  .griglia { grid-template-columns: repeat(2, 1fr); }
  .dati { grid-template-columns: repeat(5, 1fr); }
  .utente { display: inline; }
  .card { padding: 18px; }
}
/* --- desktop: navigazione laterale --- */
@media (min-width: 960px) {
  body { padding-bottom: 0; padding-left: 220px; }
body.senza-nav { padding-left: 0; }
  .piede { margin-left: 0; }
  .nav {
    inset: 0 auto 0 0; width: 220px; height: auto; grid-auto-flow: row; grid-auto-columns: auto; align-content: start; gap: 4px;
    padding: 76px 12px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 8px; font-size: .95rem; }
  .nav a[aria-current="page"] { background: rgba(0,102,204,.12); box-shadow: inset 4px 0 0 var(--teal); }
  .top { margin-left: -220px; padding-left: calc(220px + var(--gutter)); }
  .griglia.tre { grid-template-columns: repeat(3, 1fr); }
  .riga-campi.quattro { grid-template-columns: repeat(4, 1fr); }
}
@media print { .nav, .top, .btn, form { display: none !important; } body { padding: 0; } }

/* --- amministrazione utenti --- */
.utente-scheda { border-top: 1px solid var(--line); padding: 12px 0; }
.utente-scheda:first-child { border-top: 0; }
.utente-scheda h3, .utente-scheda h2 { font-size: 1.1rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 4px; overflow-wrap: anywhere; }
.utente-scheda dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0; font-size: .85rem; }
.utente-scheda dt { color: var(--ink-3); } .utente-scheda dd { margin: 0; }
.azioni form { margin: 0; }
.avviso.ok { overflow-wrap: anywhere; user-select: all; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 14px 0 0; min-height: 44px; }
.check input { width: 22px; min-height: 22px; height: 22px; flex: none; }

.colore-input { padding: 4px; height: 48px; width: 100%; max-width: 160px; cursor: pointer; }
.logo-partito { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.vuoto-logo { display: grid; place-items: center; font-weight: 900; font-size: .8rem; color: var(--ink-3); background: var(--bg); }

/* Editor scenario Politiche */
.lista-quota { border-top: 1px solid var(--line); padding: 12px 0; }
.lista-quota:first-of-type { border-top: 0; }
.lista-quota .check { margin-bottom: 6px; }

/* --- piede di pagina e pagina accessibilita' --- */
.piede { max-width: 1100px; margin: 8px auto 0; padding: 18px var(--gutter) 28px; border-top: 2px solid var(--line); color: var(--ink-2); font-size: .9rem; }
.piede a { font-weight: 700; }
.piede ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; }
.testo-lungo { max-width: 70ch; } .testo-lungo h2 { margin-top: 1.5rem; }
.scelta .ico { width: 36px; height: 36px; color: var(--teal); margin-bottom: 8px; display: block; }
.scelta strong { color: var(--ink); }
.scelta span:not(.ico) { color: var(--ink-2); }
.dato b { color: var(--teal); }
.dato span { color: var(--ink-2); font-size: .9rem; }
.elenco .t span { color: var(--ink-2); font-size: .9rem; }
@media (prefers-color-scheme: dark) {
  .segmenti a[aria-current="true"], .btn:hover { color: #00264d; }
  .btn:hover { background: #a8d3ff; border-color: #a8d3ff; }
}

/* Liste: griglia di composizione e rilievi di controllo */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
table.grid input, table.grid select { width: 100%; min-width: 7rem; }
table.grid td.controllo { min-width: 14rem; font-size: .85rem; }
table.grid th.sezione { text-align: left; background: var(--bg); }
.viol { display: block; margin: 2px 0; padding: 4px 8px; border-left: 4px solid var(--amber); background: rgba(138,75,0,.08); }
.viol.bloccante { border-left-color: var(--red); background: rgba(179,38,30,.08); }
.viol-gen { margin: 8px 0; }
.chip.rosso { background: var(--red); color: #fff; }
.chip.verde { background: var(--green); color: #fff; }
details.incolla { margin: 8px 0; }
details.incolla textarea { width: 100%; }

/* Form rapido «Nuova simulazione» in home */
.rapido-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 18px; margin: 10px 0; }
.rapido-riga { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.rapido-riga .rapido-nome { flex: 1 1 auto; margin: 0; font-weight: 600; }
.rapido-riga input.quota { width: 5.5em; text-align: right; margin: 0; }
.rapido-riga input.on { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }

/* Schede della home: icona in una tessera colorata, testo accanto */
.scelta { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 0; }
.scelta .testo { display: block; min-width: 0; }
.scelta .testo strong { margin-bottom: 2px; font-size: 1.05rem; }
.scelta .testo > span { display: block; font-size: .88rem; line-height: 1.35; }
.ico-tile { --t: #0066cc; flex: 0 0 auto; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  color: var(--t); background: rgba(0,102,204,.1); background: color-mix(in srgb, var(--t) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--t) 22%, transparent); transition: transform .15s; }
.ico-tile svg { width: 24px; height: 24px; }
.scelta:hover .ico-tile { transform: scale(1.06); }
.t-blu { --t: #0066cc; } .t-verde { --t: #0f7a4d; } .t-viola { --t: #6d3fd0; } .t-ambra { --t: #b45f06; }
@media (prefers-color-scheme: dark) { .t-blu { --t: #6db3ff; } .t-verde { --t: #6fd6a0; } .t-viola { --t: #b79bff; } .t-ambra { --t: #ffbf66; } }
@media (prefers-reduced-motion: reduce) { .ico-tile, .scelta { transition: none; } .scelta:hover .ico-tile { transform: none; } }
.scelta .ico-tile { color: var(--t); }
@media (max-width: 640px) { .nav a { font-size: .68rem; padding: 0 1px; min-width: 0; } .nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
.scelta span.ico-tile:not(.ico) { color: var(--t); }

.rapido-riga .rapido-logo { width: 28px; height: 28px; flex: 0 0 auto; object-fit: contain; border-radius: 6px; }
.rapido-riga .pallino { margin: 0 10px; flex: 0 0 auto; }
