/* ===================== APP PREPOSTO ===================== */
:root {
  --tab-h: 64px;
  --c-near: #7c4dff; --c-cond: #e08a00; --c-inos: #d1453b; --c-viol: #3d6fb6; --c-peri: #c62828;
  --c-ok: #1e7a46; --c-pers: #c75000; --c-na: #6b7684;
}
body.app {
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  background: var(--sfondo);
}
.ico { width: 22px; height: 22px; flex: none; }

/* barra in alto */
.app-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  background: var(--primario); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; min-height: 56px;
}
.app-bar-logo { width: 32px; height: 32px; border-radius: 22%; box-shadow: 0 0 0 1.5px rgba(255,255,255,.6); }
.app-bar-titolo { font-size: 1.1rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-bar-btn { color: #fff; display: flex; padding: 4px; margin-left: -6px; }
.app-bar-btn .ico { width: 26px; height: 26px; }
.coda-badge { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 99px; font-size: .85rem; }
.coda-badge .ico { width: 18px; height: 18px; }
.app-main { max-width: 640px; margin: 0 auto; padding: 14px; }

/* barra in basso */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: var(--superficie); border-top: 1px solid var(--bordo);
  padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
}
.tabbar a.attivo { color: var(--primario); }
.tabbar .tab-nuova .tab-ico {
  background: var(--primario); color: #fff; width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: -22px;
  box-shadow: 0 4px 12px rgba(31,78,121,.35); border: 3px solid var(--superficie);
}
.tabbar .tab-nuova .ico { width: 26px; height: 26px; }

/* home */
.saluto { margin: 4px 2px 14px; }
.saluto p { margin: 0; font-size: 1.15rem; }
.saluto .muted { font-size: .9rem; }
.tile-nuova {
  display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 14px; text-decoration: none;
  background: linear-gradient(135deg, var(--primario), #2f6aa3); color: #fff; margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(31,78,121,.25);
}
.tile-nuova strong { display: block; font-size: 1.1rem; }
.tile-nuova small { opacity: .85; }
.tile-nuova .tile-ico { background: rgba(255,255,255,.2); border-radius: 12px; padding: 10px; display: flex; }
.tile-nuova .tile-ico .ico { width: 28px; height: 28px; }
.tile-nuova .freccia { margin-left: auto; opacity: .8; }
.contatori { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.contatore {
  background: var(--superficie); border: 1px solid var(--bordo); border-radius: 12px; padding: 12px 8px;
  text-align: center; text-decoration: none; color: var(--muted); font-size: .8rem; font-weight: 600;
  border-top: 4px solid var(--bordo);
}
.contatore b { display: block; font-size: 1.6rem; color: var(--testo); }
.c-aperta { border-top-color: #e08a00; } .c-in_gestione { border-top-color: #3d6fb6; } .c-chiusa { border-top-color: #1e7a46; }
.sezione { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 2px 8px; }
.vuoto { text-align: center; color: var(--muted); }
.coda .coda-testa { display: flex; align-items: center; gap: 8px; color: var(--avviso); }
.coda ul { margin: 8px 0; padding-left: 20px; font-size: .9rem; }
.coda small { color: var(--errore); }

/* elenchi */
.elenco { background: var(--superficie); border: 1px solid var(--bordo); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.voce {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--testo); text-decoration: none;
  border-bottom: 1px solid var(--bordo);
}
.voce:last-child { border-bottom: 0; }
.voce:active { background: var(--sfondo); }
.voce-testo { flex: 1; min-width: 0; }
.voce-testo strong { display: block; }
.voce-testo small { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voce .freccia { color: var(--muted); }
.voce-ico { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; color: #fff; }
.voce-ico.grande { width: 56px; height: 56px; border-radius: 14px; }
.voce-ico.grande .ico { width: 30px; height: 30px; }
.t-near_miss { --c: var(--c-near); } .t-condizione_pericolosa { --c: var(--c-cond); } .t-inosservanza { --c: var(--c-inos); }
.t-violazione_regolamento { --c: var(--c-viol); } .t-pericolo { --c: var(--c-peri); }
.e-comportamento_corretto { --c: var(--c-ok); } .e-inosservanza_persistente { --c: var(--c-pers); } .e-non_applicabile { --c: var(--c-na); }
.voce-ico[class*="t-"] { background: var(--c); }

.stato { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.stato-aperta { background: #fff3d6; color: #8a5a00; }
.stato-in_gestione { background: #e3ecf8; color: #2c5a94; }
.stato-chiusa { background: #e5f4ea; color: #1e7a46; }
.prio { font-size: .75rem; font-weight: 700; }
.prio-alta, .prio-urgente { color: var(--errore) !important; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip { white-space: nowrap; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--bordo); background: var(--superficie); color: var(--testo); text-decoration: none; font-size: .9rem; }
.chip.attivo { background: var(--primario); border-color: var(--primario); color: #fff; }

/* dettaglio */
.testa-pratica { display: flex; gap: 14px; align-items: center; }
.testa-pratica h2 { margin: 0 0 6px; }
.card h3 { font-size: 1rem; margin: 0 0 10px; }
.dati { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px; }
.dati dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 10px; }
.dati dt:first-child { margin-top: 0; }
.dati dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 30px; color: var(--muted); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bordo); background: var(--superficie); }
.timeline li::after { content: ""; position: absolute; left: 12px; top: 20px; bottom: 0; width: 2px; background: var(--bordo); }
.timeline li:last-child::after { display: none; }
.timeline li.fatto { color: var(--testo); font-weight: 600; }
.timeline li.fatto::before { background: var(--ok); border-color: var(--ok); }
.timeline small { display: block; font-weight: 400; color: var(--muted); }
.galleria { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 12px; }
.galleria img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }

/* modulo guidato */
.progresso { height: 6px; background: var(--bordo); border-radius: 99px; overflow: hidden; }
.progresso-barra { height: 100%; width: 0; background: var(--primario); transition: width .25s; }
.passo-info { font-size: .85rem; color: var(--muted); margin: 8px 2px 12px; font-weight: 600; }
.passo { display: none; }
.passo.attivo { display: block; animation: entra .2s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.campo-fisso { margin-bottom: 12px; }
.etichetta { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.etichetta small { font-weight: 400; color: var(--muted); }
textarea { resize: vertical; }
input, select, textarea { font-size: 16px; } /* evita lo zoom automatico su iPhone */

.scelte { border: 0; padding: 0; margin: 0 0 14px; }
.scelte legend { font-weight: 700; margin: 0 2px 8px; padding: 0; }
.scelta {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 8px; font-weight: 400;
  background: var(--superficie); border: 2px solid var(--bordo); border-radius: 12px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.scelta input { position: absolute; opacity: 0; pointer-events: none; }
.scelta-ico { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--c); color: #fff; flex: none; }
.scelta-testo strong { display: block; }
.scelta-testo small { color: var(--muted); font-size: .82rem; }
.scelta:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--superficie)); }
.scelta:has(input:focus-visible) { outline: 2px solid var(--primario); outline-offset: 2px; }

.foto-pulsanti { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-foto { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; flex: 1 1 140px; justify-content: center; }
.btn-foto.disabilitato { opacity: .4; pointer-events: none; }
.anteprime { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 12px; }
.anteprima { position: relative; }
.anteprima img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.anteprima .rimuovi {
  position: absolute; top: -6px; right: -6px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--superficie);
  background: var(--errore); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
}
.pulsanti-passo {
  position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px;
  padding: 12px 0; background: var(--sfondo);
}
.pulsanti-passo .btn { flex: 1; padding: 13px; font-weight: 600; }
.pulsanti-passo .btn:disabled { opacity: .6; }

/* profilo */
.profilo { text-align: center; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--primario); color: #fff; font-size: 1.6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.profilo h2 { margin: 0; }
.esci { margin-top: 10px; }

/* ---------------- notifiche ---------------- */
.notifiche-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.notifiche-box .nb-testo { flex: 1 1 220px; min-width: 0; }
.notifiche-box .nb-testo strong { display: block; }
.notifiche-box .nb-testo span { font-size: .9rem; }
.notifiche-box .nb-azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.notifiche-box.attive .nb-testo strong::after { content: " ✓"; color: var(--ok, #1e7a46); }
.notifiche-box.compatto { background: var(--superficie); border: 1px solid var(--bordo); border-left: 4px solid #f5b800; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
