/* Particella — mappa a tutto schermo con una "scheda di lavoro" flottante,
   come un foglio di mappa appoggiato sul tavolo del geometra. */
:root {
  --bg: #F2F5F3;
  --panel: rgba(250, 252, 251, .92);
  --panel-solid: #FAFCFB;
  --ink: #14211D;
  --muted: #5B6B65;
  --line: #D3DDD8;
  --field: #FFFFFF;
  --accent: #125E4C;
  --accent-ink: #F3FBF8;
  --accent-soft: #DCEDE6;
  --mark: #FFC21A;
  --mark-ink: #3B2A00;
  --danger: #B3261E;
  --shadow: 0 18px 50px -18px rgba(20, 40, 33, .35), 0 2px 6px rgba(20, 40, 33, .08);

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r: 14px;
  --gut: max(16px, env(safe-area-inset-left, 0px));
  --gut-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --panel: rgba(22, 30, 27, .9); --panel-solid: #161E1B;
    --ink: #E5EEEA; --muted: #95A7A0; --line: #2C3934; --field: #0F1614;
    --accent: #4FC6A3; --accent-ink: #062019; --accent-soft: #173A30;
    --mark: #FFC93D; --mark-ink: #2B1F00; --danger: #FF8A80;
    --shadow: 0 18px 50px -18px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --panel: rgba(22, 30, 27, .9); --panel-solid: #161E1B;
  --ink: #E5EEEA; --muted: #95A7A0; --line: #2C3934; --field: #0F1614;
  --accent: #4FC6A3; --accent-ink: #062019; --accent-soft: #173A30;
  --mark: #FFC93D; --mark-ink: #2B1F00; --danger: #FF8A80;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { font: 12px/1.4 var(--f-body); background: var(--bg); }
.base-none .leaflet-container,
#map.base-none {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}
.leaflet-control-attribution { background: var(--panel) !important; color: var(--muted); font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-bar a { background: var(--panel-solid); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--accent-soft); }
.leaflet-control-zoom { border: 1px solid var(--line) !important; box-shadow: var(--shadow) !important; }

/* ---------- Pannello ---------- */
.panel {
  position: fixed; z-index: 1000;
  top: calc(16px + env(safe-area-inset-top, 0px)); left: var(--gut);
  width: 420px; max-height: calc(100% - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel > * { padding: 16px 20px; }
.panel > * + * { border-top: 1px solid var(--line); }
.panel > .sheet-handle + * { border-top: 0; }
.sheet-handle, .sheet-peek { display: none; }

.brand { display: flex; gap: 12px; align-items: center; padding-block: 14px 12px; }
.brand-mark { width: 36px; height: 36px; color: var(--accent); flex: none; }
.brand h1 {
  margin: 0; font: 700 26px/1 var(--f-display); letter-spacing: -.025em;
  font-variation-settings: "opsz" 96;
}
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
/* slogan sotto il nome: un po' più grande, in corsivo leggero */
.brand p.slogan { margin-top: 5px; font: italic 400 15px/1.3 var(--f-body); color: color-mix(in srgb, var(--ink) 78%, var(--muted)); letter-spacing: .005em; }

.search { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; position: relative; min-width: 0; }
.field label, .field .label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.opt { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .8; }
.input-wrap { position: relative; }
.input-wrap .ico {
  position: absolute; left: 13px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; transition: color .15s;
}
.input-wrap:focus-within .ico { color: var(--accent); }
.field input {
  width: 100%; height: 46px; padding: 0 12px 0 38px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--field);
  font-size: 16px; transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input::placeholder { color: var(--muted); opacity: .6; }
#foglio, #particella { font-family: var(--f-mono); letter-spacing: .02em; }

.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 5; margin: 6px 0 0; padding: 5px;
  list-style: none; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 280px; overflow: auto; scrollbar-width: thin;
}
.suggest li {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--accent-soft); }
.suggest li small { font-family: var(--f-mono); color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.suggest li mark { background: none; color: var(--accent); font-weight: 600; }
.suggest li.warn small { color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  min-width: 42px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--field); font-family: var(--f-mono); font-size: 13px; cursor: pointer;
}
.chips button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Riferimento catastale: l'elemento firma */
.ref {
  margin: 0; padding: 12px 14px 10px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 35%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
}
.ref figcaption {
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.ref-code { display: flex; align-items: flex-start; gap: 3px; font-family: var(--f-mono); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.seg { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.seg b {
  font-weight: 500; font-size: 16px; line-height: 1.25; padding: 3px 6px; border-radius: 6px;
  background: var(--field); color: var(--muted); letter-spacing: .04em; transition: background .25s, color .25s;
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg.on b { color: var(--ink); }
.seg[data-k="par"].on b { background: var(--mark); color: var(--mark-ink); box-shadow: none; }
.seg i { font-style: normal; font-family: var(--f-body); font-size: 9px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.ref-code .dot { font-size: 16px; line-height: 1.7; color: var(--muted); padding: 0 1px; }
.seg.flash b { animation: flash .6s ease; }
@keyframes flash { 0% { background: var(--mark); color: var(--mark-ink); } 100% {} }

.go {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 16px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform .12s, filter .15s, box-shadow .15s;
}
.go svg { width: 18px; height: 18px; transition: transform .2s; }
.go:hover { filter: brightness(1.06); box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--accent) 90%, transparent); }
.go:hover svg { transform: translateX(3px); }
.go:active { transform: scale(.985); }
.go[disabled] { filter: saturate(.4) opacity(.7); cursor: progress; }

.status { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--field) 70%, transparent); border: 1px solid var(--line); }
.status p { margin: 0; font-size: 13px; color: var(--muted); }
.status.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.status.err p { color: var(--danger); }
.scan { display: grid; gap: 2px; flex: none; width: 36px; height: 36px; }
.scan span { background: var(--line); border-radius: 1.5px; transition: background .2s; }
.scan span.busy { background: var(--accent); animation: pulse .8s ease-in-out infinite alternate; }
.scan span.done { background: var(--accent-soft); }
.scan span.hit { background: var(--mark); }
@keyframes pulse { to { opacity: .35; } }

/* Risultato */
.result { display: flex; flex-direction: column; gap: 11px; }
.result-head { display: flex; flex-direction: column; gap: 3px; padding-top: 2px; }
.eyebrow { margin: 0; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.result h2 { margin: 0; font: 700 23px/1.1 var(--f-display); letter-spacing: -.02em; text-wrap: balance; }
.result .sub { margin: 0; color: var(--muted); font-size: 13.5px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metrics[data-n="3"] { grid-template-columns: 1.25fr 1fr 1fr; }
.metric { padding: 9px 11px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); min-width: 0; }
.metric span { display: block; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.metric b { display: block; margin-top: 2px; font: 700 19px/1.15 var(--f-display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric:first-child { background: color-mix(in srgb, var(--mark) 16%, var(--field)); border-color: color-mix(in srgb, var(--mark) 45%, var(--line)); }
.facts { display: flex; flex-direction: column; margin: 0; }
.facts div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.facts div:last-child { border-bottom: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); flex: none; }
.facts dd { margin: 0; font-family: var(--f-mono); font-size: 13.5px; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; min-width: 0; }
.note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.note:empty { display: none; }
.result .actions { margin-top: 1px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.act {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  height: 38px; padding: 0 8px; border-radius: 10px; white-space: nowrap; overflow: hidden; border: 1px solid var(--line); background: var(--field);
  font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none; color: var(--ink);
  transition: border-color .15s, color .15s, background .15s;
}
.act svg { width: 16px; height: 16px; flex: none; }
.act:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }


.credits { padding-block: 10px 12px; }
.credits p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.45; }
.credits .legal-links { margin-top: 4px; }
.credits .legal-links a { color: var(--muted); }
.credits .legal-links a:hover { color: var(--accent); }
.vdlg-privacy a { color: var(--muted); }

/* Velo sul satellite: tiene la mappa omogenea anche dove un tassello catastale
   sta ancora caricando. Intensità legata al cursore "Catasto". */
.veiled::after {
  content: ""; position: absolute; left: -50000px; top: -50000px; width: 100000px; height: 100000px;
  background: rgba(238, 242, 240, var(--veil-a, .3)); pointer-events: none;
}

/* ---------- Controlli mappa ---------- */
.mapctl {
  position: fixed; z-index: 1000; top: calc(16px + env(safe-area-inset-top, 0px)); right: var(--gut-r);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.seg-switch, .opacity, .round {
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.seg-switch { display: flex; padding: 3px; border-radius: 11px; }
.seg-switch button {
  border: 0; background: transparent; padding: 7px 11px; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--muted);
}
.seg-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.opacity { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 11px; font-size: 12px; color: var(--muted); }
.opacity input { width: 90px; accent-color: var(--accent); }
.round { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; cursor: pointer; }
.round svg { width: 20px; height: 20px; }

.leaflet-bottom.leaflet-right { margin-right: env(safe-area-inset-right, 0px); margin-bottom: env(safe-area-inset-bottom, 0px); }

.zoomhint {
  position: fixed; z-index: 900; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow); white-space: nowrap;
  transition: opacity .3s;
}
.zoomhint.off { opacity: 0; pointer-events: none; }
.toast {
  position: fixed; z-index: 1200; left: 50%; top: calc(18px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  padding: 9px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13.5px; box-shadow: var(--shadow);
}

/* Etichette particelle sulla mappa */
.plabel {
  background: none; border: 0; box-shadow: none; padding: 0;
  font: 500 11px/1 var(--f-mono); color: #fff;
  text-shadow: 0 0 3px #000, 0 0 2px #000, 0 0 1px #000;
}
.plabel::before { display: none; }
.plabel.sel { color: #2B1F00; text-shadow: 0 0 3px #FFC21A, 0 0 2px #FFC21A; font-weight: 700; font-size: 13px; }
.sheet-tag {
  background: #0E2A23; color: #fff; border: 0; border-radius: 6px; padding: 3px 7px;
  font: 600 12px/1.2 var(--f-mono); box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.sheet-tag::before { display: none; }
.scan-rect { pointer-events: none; }
.tap-pulse { animation: tap 1s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes tap { 50% { opacity: .35; } }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel-solid); color: var(--ink); }


/* Avviso essenziale: misure indicative + richiesta visura */
.visura {
  display: flex; gap: 10px; align-items: center;
  padding: 9px 10px 9px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--mark) 10%, var(--field));
  border: 1px solid color-mix(in srgb, var(--mark) 40%, var(--line));
}
.visura-ico { flex: none; width: 18px; height: 18px; color: var(--mark); }
.visura-body { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.visura-body p { margin: 0; flex: 1; min-width: 0; font-size: 12px; line-height: 1.35; color: var(--muted); }
.visura-body b { color: var(--ink); font-weight: 600; }
.visura-body a { color: var(--accent); white-space: nowrap; }
.visura-btn {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border: 0; border-radius: 10px; cursor: pointer; white-space: nowrap;
  background: var(--mark); color: var(--mark-ink); font-weight: 600; font-size: 13px;
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--mark) 90%, transparent);
  transition: transform .15s, filter .15s;
}
.visura-btn svg { width: 15px; height: 15px; transition: transform .2s; }
.visura-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.visura-btn:hover svg { transform: translateX(3px); }

/* ---------- Finestra "Richiedi la visura" ---------- */
.vdlg {
  width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible;
}
.vdlg::backdrop { background: rgba(5, 10, 8, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.vdlg[open] { animation: vdlg-in .35s cubic-bezier(.2, .8, .2, 1); }
.vdlg[open]::backdrop { animation: vdlg-fade .3s ease; }
@keyframes vdlg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes vdlg-fade { from { opacity: 0; } }
.vdlg-card {
  position: relative; margin: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding: 22px; border-radius: 22px;
  background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  background-image: radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--mark) 10%, transparent), transparent 60%);
}
.vdlg-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; border: 1px solid var(--line); background: var(--field); color: var(--muted); cursor: pointer;
}
.vdlg-close:hover { color: var(--ink); border-color: var(--accent); }
.vdlg-step { display: flex; flex-direction: column; gap: 16px; }
.vdlg-head { display: flex; gap: 13px; align-items: flex-start; padding-right: 40px; }
.vdlg-badge {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--mark); color: var(--mark-ink); box-shadow: 0 10px 22px -12px var(--mark);
}
.vdlg-head h2 { margin: 2px 0 0; font: 700 24px/1.1 var(--f-display); letter-spacing: -.02em; }
.vdlg-sub { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

.vdlg-ref {
  padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 35%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  display: flex; flex-direction: column; gap: 9px;
}
.vdlg-ref-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: 13.5px; font-weight: 600; }
.vdlg-area { font: 500 12px var(--f-mono); color: var(--muted); white-space: nowrap; }
.vdlg-ref .seg b { color: var(--ink); }

.vdlg-kind { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vdlg-kind legend { padding: 0; margin-bottom: 7px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.vdlg-kind label { position: relative; cursor: pointer; }
.vdlg-kind input { position: absolute; opacity: 0; pointer-events: none; }
.vdlg-kind span {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--field);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.vdlg-kind b { font-size: 14px; }
.vdlg-kind small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.vdlg-kind input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: color-mix(in srgb, var(--accent-soft) 40%, var(--field)); }
.vdlg-kind input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.vdlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vdlg-grid .field:first-child, .vdlg-wide { grid-column: 1 / -1; }
.vdlg-grid input, .vdlg-grid textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--field);
  font: inherit; font-size: 15px; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.vdlg-grid input { height: 44px; padding-left: 12px; }
.vdlg-grid textarea { resize: vertical; min-height: 64px; }
.vdlg-grid input:focus, .vdlg-grid textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.vdlg-grid .invalid { border-color: var(--danger); }
.vdlg-err { margin: -4px 0 0; font-size: 13px; color: var(--danger); }
.vdlg-hint { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.vdlg-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.vdlg-id { font: 12.5px var(--f-mono) !important; }
.vdlg-done .go { width: 100%; }
.vdlg-send[disabled] { cursor: progress; }
.vdlg-send .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }

.vdlg-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.vdlg-send { width: 100%; }
.vdlg-mail, .vdlg-privacy { margin: 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.vdlg-privacy { font-size: 11.5px; opacity: .8; }
.vdlg-copy {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer;
  text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px;
}

.vdlg-done { align-items: center; text-align: center; padding: 10px 4px 2px; }
.vdlg-done h2 { margin: 0; font: 700 24px/1.15 var(--f-display); letter-spacing: -.02em; }
.vdlg-done p { margin: 0; font-size: 14px; color: var(--muted); max-width: 36ch; line-height: 1.5; }
.vdlg-done b { color: var(--ink); }
.vdlg-done .vdlg-fallback { font-size: 12.5px; }
.vdlg-check {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 8px var(--accent-soft);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.vdlg-actions-row { flex-direction: row; flex-wrap: wrap; justify-content: center; width: 100%; }
.vdlg-actions-row .act { flex: 1 1 120px; }
@media (max-width: 480px) {
  .vdlg-card { padding: 18px 16px; }
  .vdlg-step { gap: 13px; }
  .vdlg-grid { grid-template-columns: 1fr; }
  .vdlg-kind small { display: none; }
  .vdlg-head h2 { font-size: 21px; }
}

/* ---------- Scheda di caricamento al centro della mappa ---------- */
.loader {
  position: fixed; z-index: 1100; top: 50%;
  left: calc(var(--gut) + 420px + (100% - var(--gut) - 420px) / 2);
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 32px));
  display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  padding: 18px 18px 14px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  animation: loader-in .35s cubic-bezier(.2, .8, .2, 1);
}
@keyframes loader-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
.loader-art { width: 100%; height: auto; max-width: 100%; border-radius: 12px; background: var(--field); }
.la-sheet { fill: none; stroke: var(--line); stroke-width: 1.5; stroke-dasharray: 5 5; }
.la-grid { fill: none; stroke: var(--line); stroke-width: 1; opacity: .6; }
.la-parcel {
  fill: color-mix(in srgb, var(--mark) 22%, transparent); stroke: var(--mark); stroke-width: 2.5; stroke-linejoin: round;
  stroke-dasharray: 210; stroke-dashoffset: 210; animation: la-draw 2.4s ease-in-out infinite;
}
@keyframes la-draw {
  0% { stroke-dashoffset: 210; fill-opacity: 0; }
  55% { stroke-dashoffset: 0; fill-opacity: 0; }
  75%, 90% { stroke-dashoffset: 0; fill-opacity: 1; }
  100% { stroke-dashoffset: 0; fill-opacity: 0; opacity: 0; }
}
.la-dot { fill: var(--accent); animation: la-dot 2.4s ease-in-out infinite; transform-origin: 88px 54px; }
@keyframes la-dot { 0%, 50% { opacity: 0; transform: scale(.4); } 70% { opacity: 1; transform: scale(1.3); } 85% { transform: scale(1); } 100% { opacity: 0; } }
.la-scan { fill: var(--accent); opacity: .55; animation: la-scan 1.8s ease-in-out infinite alternate; }
@keyframes la-scan { from { transform: translateX(0); } to { transform: translateX(141px); } }

.loader-body { display: flex; flex-direction: column; gap: 6px; }
.loader-title { margin: 0; font: 700 18px/1.2 var(--f-display); letter-spacing: -.015em; text-wrap: balance; }
.loader-text { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.loader-steps { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.loader-steps li { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); transition: color .2s; }
.loader-steps li::before {
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--line); box-sizing: border-box; transition: all .25s;
}
.loader-steps li.active { color: var(--ink); font-weight: 500; }
.loader-steps li.active::before { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.loader-steps li.done { color: var(--ink); }
.loader-steps li.done::before {
  border-color: var(--accent); background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2 7 10.5l4.5-5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-bar { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 8px; }
.loader-bar span { display: block; height: 100%; width: 6%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--mark)); transition: width .5s ease; }
.loader-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.loader-time { font: 12px var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.loader-cancel {
  border: 0; background: none; color: var(--muted); font-size: 12.5px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.loader-cancel:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.loader-hint { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ---------- Pulsante Google Maps in evidenza ---------- */
.act.gmaps {
  grid-column: 1 / -1; order: -1; justify-content: flex-start; gap: 12px;
  height: 46px; padding: 0 14px 0 7px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, #1A73E8, #0B57D0); color: #fff;
  box-shadow: 0 10px 22px -12px rgba(11, 87, 208, .9);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.act.gmaps:hover { color: #fff; background: linear-gradient(135deg, #1A73E8, #0B57D0); filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 14px 26px -12px rgba(11, 87, 208, 1); }
.gm-ico { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: #fff; color: #EA4335; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.gm-ico svg { width: 20px; height: 20px; }
.gm-txt { display: flex; align-items: baseline; gap: 8px; min-width: 0; text-align: left; }
.gm-txt b { font-size: 14.5px; font-weight: 600; }
.gm-txt small { font-size: 11.5px; opacity: .85; }
.gm-arrow { margin-left: auto; flex: none; opacity: .9; transition: transform .2s; }
.act.gmaps:hover .gm-arrow { transform: translate(2px, -2px); }

@media (min-width: 721px) and (max-height: 880px) {
  .panel.has-result .ref { display: none; }
  .panel.has-result .brand p { display: none; }
  .panel.has-result .brand { padding-block: 12px 10px; }
}
@media (min-width: 721px) and (max-height: 720px) {
  .panel.has-result .brand, .panel.has-result .credits, .panel.has-result .seo { display: none; }
  .panel.has-result .search { padding-top: 14px; }
}


/* Pagine per comune: titolo del comune e riquadro informativo nella barra laterale */
.brand .brand-name { margin: 0; font: 700 26px/1 var(--f-display); letter-spacing: -.025em; color: var(--ink); font-variation-settings: "opsz" 96; }
.brand h1.brand-sub { margin: 4px 0 0; font: 500 13.5px/1.3 var(--f-body); letter-spacing: 0; color: var(--accent); }
.seo { padding-block: 12px 4px; }
/* con un risultato aperto c'è già "Richiedi la visura" nella scheda: il riquadro del comune si nasconde */
.panel.has-result .seo { display: none; }
.seo-cta { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--mark) 10%, var(--field)); border: 1px solid color-mix(in srgb, var(--mark) 40%, var(--line)); }
.seo-cta div { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.seo-cta b { font-size: 13.5px; }
.seo-cta span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.seo-cta-btn { flex: none; height: 34px; padding: 0 12px; border: 0; border-radius: 10px; cursor: pointer; white-space: nowrap;
  background: var(--mark); color: var(--mark-ink); font-weight: 600; font-size: 13px; }
.seo-cta-btn:hover { filter: brightness(1.05); }
.seo-box > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; font-size: 13px; font-weight: 600; color: var(--ink);
}
.seo-box > summary::-webkit-details-marker { display: none; }
.seo-box > summary::after { content: "+"; font: 400 18px/1 var(--f-mono); color: var(--accent); }
.seo-box[open] > summary::after { content: "–"; }
.seo-box p, .seo-box li { font-size: 13px; line-height: 1.55; color: var(--muted); }
.seo-box p { margin: 0 0 10px; }
.seo-box b, .seo-box code { color: var(--ink); }
.seo-box code { font-family: var(--f-mono); font-size: 12px; background: var(--field); padding: 1px 5px; border-radius: 4px; }
.seo-box h3 { margin: 14px 0 6px; font: 700 14px/1.3 var(--f-display); color: var(--ink); }
.seo-box ol { margin: 0 0 10px; padding-left: 18px; }
.seo-warn { padding: 9px 11px; border-radius: 10px; background: color-mix(in srgb, var(--mark) 10%, var(--field)); border: 1px solid color-mix(in srgb, var(--mark) 40%, var(--line)); color: var(--ink) !important; }
.faq { border-top: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 8px 0; font-size: 13px; color: var(--ink); }
.faq p { margin: 0 0 8px !important; }
.near { list-style: none; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.near li { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; min-width: 0; }
.near a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.near a:hover { color: var(--accent); }
.near span { color: var(--muted); font: 11px var(--f-mono); white-space: nowrap; }
.seo-nav { font-size: 12.5px !important; }
.seo-nav a { color: var(--accent); }

/* ---------- Telefono: il pannello diventa un foglio dal basso ---------- */
@media (max-width: 720px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 62%; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: max-height .3s ease, transform .25s ease;
  }
  .panel.dragging { transition: none; }
  .panel > * { padding-left: var(--gut); padding-right: var(--gut-r); }
  .panel > .sheet-handle { padding: 0; touch-action: none; }
  /* chiuso: resta solo la maniglia con il riepilogo */
  .panel.collapsed { max-height: calc(76px + env(safe-area-inset-bottom, 0px)); overflow: hidden; }
  .panel.collapsed .sheet-peek {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
    padding-block: 2px 12px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; touch-action: none;
  }
  .peek-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  .peek-text b { font: 700 16px/1.2 var(--f-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .peek-text small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-peek svg { flex: none; color: var(--accent); }
  .sheet-handle {
    display: grid; place-items: center; height: 26px; border: 0; cursor: pointer; flex: none;
    /* resta sempre in cima al pannello, anche quando il contenuto scorre */
    position: sticky; top: 0; z-index: 4; background: var(--panel-solid); width: 100%;
  }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 3px; background: var(--line); }
  .brand { display: none; }
  .mapctl { gap: 6px; }
  .opacity { display: none; }
  .seg-switch button { padding: 6px 8px; font-size: 12px; }
  .zoomhint { bottom: auto; top: calc(66px + env(safe-area-inset-top, 0px)); font-size: 11.5px; white-space: normal; text-align: center; width: max-content; max-width: calc(100% - 32px); }
  .leaflet-top.leaflet-left { display: none; }
  /* zoom e crediti della mappa sopra la striscia del pannello chiuso */
  .leaflet-bottom.leaflet-right { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .loader {
    left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
    width: min(300px, calc(100% - 32px)); padding: 12px 14px 10px; gap: 10px; border-radius: 18px;
    animation: loader-in-m .3s ease;
  }
  @keyframes loader-in-m { from { opacity: 0; transform: translate(-50%, -8px); } }
  .loader-art { height: 64px; }
  .loader-title { font-size: 16px; }
  .loader-steps { margin-top: 2px; gap: 4px; }
  .loader-hint { display: none; }
  .ref-code { gap: 2px; }
  .seg b { font-size: 15px; padding: 2px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .la-parcel { stroke-dashoffset: 0; }
  .la-scan { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Logo testuale: Catasto (bianco) mappe (verde) . (giallo, come la particella) com (discreto) */
.wordmark { white-space: nowrap; letter-spacing: -.025em; }
.wordmark .wm-b { color: var(--accent); }
.wordmark .wm-dot { color: var(--mark); }
.wordmark .wm-tld { color: var(--muted); font-weight: 500; font-size: .72em; letter-spacing: 0; }
