/* =====================================================================
   FRIGNANO LIVE GUARD — stile app cittadino
   Font di sistema: veloci, nativi su iPhone/Android, nessun dato a terzi
   ===================================================================== */
:root {
  --navy: #0e3a5b;
  --navy-2: #15507c;
  --navy-ink: #0a2a42;
  --amber: #f2a541;
  --amber-ink: #8a5300;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #13212e;
  --ink-2: #4a5866;
  --ink-3: #7b8794;
  --line: #e4e0d6;
  --line-2: #d6d1c4;
  --ok: #16a34a;
  --ko: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(10, 42, 66, .06), 0 6px 20px rgba(10, 42, 66, .07);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--navy-2); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; background: var(--bg); position: relative; }
@media (min-width: 600px) { body { background: #e9e5db; } #app { box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,.08); } }

/* ---------- banner demo ---------- */
.demo { background: repeating-linear-gradient(45deg, #fff4dc, #fff4dc 10px, #ffecc4 10px, #ffecc4 20px);
  color: var(--amber-ink); font-size: 13px; padding: 7px 14px; text-align: center; border-bottom: 1px solid #f1d49a; }
.demo b { font-weight: 700; }
.demo button { background: none; border: 0; text-decoration: underline; color: inherit; font-size: 13px; cursor: pointer; padding: 0 0 0 6px; }

/* ---------- logo / topbar ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand-t { font-weight: 800; letter-spacing: -.01em; font-size: 17px; line-height: 1.1; }
.brand-s { font-size: 12px; color: var(--ink-3); }
.topbar { position: sticky; top: 0; z-index: 500; background: rgba(246, 244, 239, .92); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar .saluto { font-size: 13px; color: var(--ink-2); text-align: right; line-height: 1.2; }
.topbar .saluto b { color: var(--ink); display: block; font-size: 14px; }

/* ---------- auth ---------- */
.auth { padding: calc(28px + var(--safe-t)) 20px 40px; }
.auth-hero { text-align: center; margin: 8px 0 26px; }
.auth-hero img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-hero h1 { font-size: 26px; letter-spacing: -.02em; margin: 14px 0 4px; }
.auth-hero p { margin: 0; color: var(--ink-2); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #ebe7dd; border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.pitch { display: grid; gap: 10px; margin: 26px 0 0; padding: 0; list-style: none; }
.pitch li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.pitch li span { flex: 0 0 30px; height: 30px; border-radius: 9px; background: #fff; display: grid; place-items: center; box-shadow: var(--shadow); }

/* ---------- card e form ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 5px; }
.input, textarea.input, select.input {
  width: 100%; border: 1.5px solid var(--line-2); background: #fff; border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 4px rgba(21, 80, 124, .14); }
textarea.input { min-height: 110px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pw { position: relative; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--ink-3); font-size: 13px; padding: 8px; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); margin: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; flex: 0 0 20px; margin: 1px 0 0; accent-color: var(--navy); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: transform .08s, filter .15s, background .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-p { background: var(--navy); color: #fff; }
.btn-p:hover { filter: brightness(1.1); }
.btn-a { background: var(--amber); color: #3d2600; }
.btn-g { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn-d { background: #fff; color: var(--ko); box-shadow: inset 0 0 0 1.5px #f3c4c4; }
.btn-w { width: 100%; }
.btn-s { padding: 9px 13px; font-size: 14px; border-radius: 10px; }
.link { background: none; border: 0; color: var(--navy-2); font-weight: 600; cursor: pointer; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }
.err { background: #fdecec; color: #8f1d1d; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 0 0 14px; }
.ok-box { background: #e9f7ee; color: #14532d; border-radius: 10px; padding: 12px; font-size: 14px; margin: 0 0 14px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: g .7s linear infinite; }
@keyframes g { to { transform: rotate(360deg); } }

/* ---------- tab e tabbar ---------- */
main { padding-bottom: calc(var(--tabbar) + var(--safe-b) + 16px); }
.tab { display: none; }
.tab.on { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 900;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar) + var(--safe-b));
  padding-bottom: var(--safe-b); }
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--navy); }
.tabbar .plus { position: relative; }
.tabbar .plus i { width: 54px; height: 54px; border-radius: 18px; background: var(--amber); color: #3d2600; display: grid; place-items: center;
  margin-top: -22px; box-shadow: 0 6px 16px rgba(242, 165, 65, .45), 0 0 0 4px var(--bg); }
.tabbar .plus i svg { width: 28px; height: 28px; }

/* ---------- sezioni ---------- */
.pad { padding: 16px; }
.h2 { font-size: 22px; letter-spacing: -.02em; margin: 4px 0 4px; }
.sub { color: var(--ink-2); margin: 0 0 16px; font-size: 14.5px; }

/* ---------- mappa ---------- */
.mappa-wrap { position: relative; }
#mappa { height: 46vh; min-height: 280px; background: #e7e3d8; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1.5px solid var(--line-2); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 16px 4px; }
.stat { background: #fff; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--ink-3); }
.pin { width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.3); border: 2.5px solid #fff; }
.pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }
.leaflet-container { font: inherit; }

/* ---------- elenco segnalazioni ---------- */
.lista { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px 16px; }
.item { display: flex; gap: 12px; background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; text-align: left; border: 0; width: 100%; }
.item .ico { flex: 0 0 48px; height: 48px; border-radius: 12px; background: #f1eee6; display: grid; place-items: center; font-size: 22px; overflow: hidden; }
.item .ico img { width: 100%; height: 100%; object-fit: cover; }
.item .tx { flex: 1; min-width: 0; }
.item .t1 { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.item .t2 { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t3 { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.vuoto { text-align: center; color: var(--ink-3); padding: 36px 20px; }
.vuoto div { font-size: 40px; margin-bottom: 6px; }

/* ---------- form segnalazione ---------- */
.step { margin-bottom: 14px; }
.step-h { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; margin-bottom: 12px; }
.step-h i { font-style: normal; width: 26px; height: 26px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 13px; }
.step-h small { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cat { border: 1.5px solid var(--line-2); background: #fff; border-radius: 12px; padding: 11px 10px; display: flex; gap: 9px; align-items: center;
  cursor: pointer; text-align: left; font-size: 14px; font-weight: 600; line-height: 1.2; min-height: 54px; }
.cat em { font-style: normal; font-size: 22px; }
.cat[aria-pressed="true"] { border-color: var(--navy); background: #eaf1f7; box-shadow: inset 0 0 0 1px var(--navy); }
.foto-box { border: 2px dashed var(--line-2); border-radius: 14px; padding: 18px; text-align: center; background: #fbfaf7; }
.foto-box .bt { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.foto-prev { position: relative; border-radius: 14px; overflow: hidden; }
.foto-prev img { display: block; width: 100%; max-height: 300px; object-fit: cover; }
.foto-prev button { position: absolute; top: 8px; right: 8px; }
#mini-mappa { height: 230px; border-radius: 14px; overflow: hidden; background: #e7e3d8; margin-bottom: 10px; }
.warn { background: #fff6e5; color: var(--amber-ink); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 8px; }
.scelta { display: grid; gap: 8px; }
.opz { display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 13px; background: #fff; cursor: pointer; }
.opz input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--navy); flex: 0 0 20px; }
.opz b { display: block; font-size: 15px; }
.opz span { font-size: 13.5px; color: var(--ink-2); }
.opz:has(input:checked) { border-color: var(--navy); background: #eaf1f7; }
.sos { display: flex; gap: 10px; align-items: center; background: #fdecec; color: #7f1d1d; border-radius: 14px; padding: 12px 14px; font-size: 14px; margin: 4px 0 14px; }
.sos b { font-size: 18px; }
.contatore { text-align: right; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.successo { text-align: center; padding: 30px 10px; }
.successo .big { width: 84px; height: 84px; border-radius: 50%; background: #e9f7ee; color: var(--ok); display: grid; place-items: center; margin: 0 auto 14px; font-size: 42px; }
.codice { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; background: #fff; padding: 8px 14px; border-radius: 10px;
  box-shadow: var(--shadow); letter-spacing: .04em; margin: 8px 0 18px; font-size: 18px; }

/* ---------- timeline stato ---------- */
.tl { display: grid; gap: 0; margin: 12px 0 4px; }
.tl div { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--ink-3); position: relative; padding-bottom: 12px; }
.tl div::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #d8d3c6; flex: 0 0 12px; margin-top: 4px; position: relative; z-index: 1; }
.tl div:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: #e4e0d6; }
.tl div.si { color: var(--ink); }
.tl div.si::before { background: var(--c, var(--navy)); }
.tl b { display: block; }

/* ---------- sheet dettaglio ---------- */
.velo { position: fixed; inset: 0; background: rgba(10, 25, 40, .45); z-index: 1500; opacity: 0; pointer-events: none; transition: opacity .2s; }
.velo.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 560px; z-index: 1600; background: var(--bg);
  border-radius: 22px 22px 0 0; max-height: 88vh; overflow-y: auto; transform: translate(-50%, 105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  padding: 8px 18px calc(24px + var(--safe-b)); box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.sheet.on { transform: translate(-50%, 0); }
.sheet .maniglia { width: 42px; height: 5px; border-radius: 3px; background: #cfc9bb; margin: 4px auto 12px; }
.sheet img.foto { width: 100%; border-radius: 14px; max-height: 340px; object-fit: cover; display: block; margin-bottom: 12px; background: #e7e3d8; }
.sheet .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.sheet h3 { margin: 4px 0 6px; font-size: 20px; letter-spacing: -.01em; }
.sheet p { margin: 0 0 10px; }
.risposta { background: #fff; border-left: 4px solid var(--navy); padding: 10px 12px; border-radius: 0 10px 10px 0; font-size: 14px; margin: 10px 0; }

/* ---------- profilo ---------- */
.menu { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.menu > * { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border: 0; background: none; width: 100%;
  text-align: left; font-size: 15px; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: var(--ink); }
.menu > *:last-child { border-bottom: 0; }
.menu .k { color: var(--ink-3); font-size: 13px; }
.menu .v { font-weight: 600; text-align: right; word-break: break-word; }
.menu .rosso { color: var(--ko); font-weight: 600; }
.lbl { font-size: 13px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 18px 4px 8px; }

/* ---------- installazione ---------- */
.install { margin: 12px 16px 0; background: var(--navy); color: #fff; border-radius: 16px; padding: 14px; display: flex; gap: 12px; align-items: center; }
.install img { width: 42px; height: 42px; border-radius: 10px; }
.install div { flex: 1; font-size: 14px; line-height: 1.3; }
.install b { display: block; font-size: 15px; }
.install .x { background: none; border: 0; color: #fff; opacity: .7; font-size: 22px; cursor: pointer; padding: 0 4px; }
.passi { counter-reset: p; list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.passi li { counter-increment: p; display: flex; gap: 12px; align-items: flex-start; background: #fff; border-radius: 12px; padding: 12px; box-shadow: var(--shadow); font-size: 15px; }
.passi li::before { content: counter(p); flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--amber); color: #3d2600; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.ios-share { display: inline-block; vertical-align: -4px; width: 20px; height: 20px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 18px); transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 3000; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; font-size: 12px; color: var(--ink-3); padding: 18px; }
.foot a { color: inherit; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- territorio e crediti ---------- */
.terr { display: flex; gap: 10px; align-items: center; background: #eaf1f7; color: var(--navy-ink); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin: -4px 0 14px; }
.terr b:first-child { font-size: 18px; }
.warn.ko { background: #fdecec; color: #7f1d1d; }
.cred { display: flex; gap: 14px; align-items: center; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.cred img { width: 52px; height: 52px; border-radius: 14px; }
.cred-t { font-size: 12.5px; color: var(--ink-3); }
.cred-n { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.cred-r { font-size: 13.5px; color: var(--ink-2); }
.cred-a { font-size: 13.5px; font-weight: 700; color: var(--navy-2); }
.pitch-comuni { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.pitch-comuni b { font-size: 16px; }
.pitch-comuni p { margin: 6px 0 12px; font-size: 14.5px; opacity: .92; }
.pitch-comuni a:not(.btn) { color: #fff; font-weight: 700; }
.pitch-comuni .pc-bt { display: flex; gap: 8px; flex-wrap: wrap; }
.pitch-comuni .btn-p { background: var(--amber); color: #3d2600; }
