/* Stile comune delle pagine per i tecnici (home, materiale, reso, sopralluogo, sospensioni): colori, caratteri, testata,
   pulsanti, schede dal basso, campi, avvisi, ingresso, ringraziamento, riquadri numerati, ricerca e invio.
   Stessa grafica dei PDF dei sopralluoghi: blu notte #0B2D45, filo ciano #12B2E0, titoli stretti in maiuscolo. */
:root {
  --bg: #F2F6F9;          /* grigio con un filo di azzurro */
  --surface: #FFFFFF;
  --fg: #10222F;
  --muted: #5A7385;
  --line: #D5E1EA;
  --brand: #0B2D45;       /* blu notte dei PDF */
  --brand-fg: #FFFFFF;
  --accent: #0E6BA0;      /* blu del logo («siat»): collegamenti e titoletti */
  --top: #0B2D45;         /* testata */
  --top-soft: #7CC9E8;
  --sky: #12B2E0;         /* azzurro del logo («installazioni») */
  --sky-soft: #E2F4FB;
  --ok: #1F7A4D;
  --photo-bg: #EEF2F5;
  --shadow: 0 1px 2px rgba(15, 37, 54, .06), 0 6px 18px rgba(15, 37, 54, .06);
  --f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-code: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1620; --surface: #12212E; --fg: #E5EEF5; --muted: #93A8B9; --line: #223646;
    --brand: #35C4EE; --brand-fg: #06131C; --accent: #7CC9E8; --top: #071D2D; --sky: #35C4EE; --sky-soft: #10303F; --ok: #52C58A;
    --photo-bg: #1A2C3B; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1620; --surface: #12212E; --fg: #E5EEF5; --muted: #93A8B9; --line: #223646;
  --brand: #35C4EE; --brand-fg: #06131C; --accent: #7CC9E8; --top: #071D2D; --sky: #35C4EE; --sky-soft: #10303F; --ok: #52C58A;
  --photo-bg: #1A2C3B; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); overflow-x: hidden;
  font: 16px/1.45 var(--f-body);
  padding-top: env(safe-area-inset-top, 0px);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--top); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.wrap {
  max-width: 980px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* testata: blu notte col filo ciano in cima, logo sul suo riquadro bianco (come nei PDF) */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--top); border-top: 3px solid var(--sky); color: #E6F1F7; }
.top .wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-block: 12px 14px; }
.brandrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { height: 34px; width: auto; background: #fff; padding: 5px 9px; border-radius: 8px; }
.eyebrow { font: 600 12px/1 var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.top .eyebrow { color: var(--top-soft); text-align: right; }
h1, h2 { font-family: var(--f-display); font-weight: 700; margin: 0; letter-spacing: .01em; text-wrap: balance; }
h1 { text-transform: uppercase; letter-spacing: .03em; }
h2 { font-size: 22px; }
.btn {
  height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-fg); font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--fg); border: 1.5px solid var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
/* schede che salgono dal basso (prodotto e richiesta) */
dialog {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh;
  background: var(--surface); color: var(--fg); border-radius: 20px 20px 0 0; overflow: auto;
}
@media (min-width: 700px) { dialog { margin: auto; border-radius: 20px; } }
dialog::backdrop { background: rgba(6, 19, 28, .5); }
.sheet { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }
.sheet-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.x { width: 40px; height: 40px; flex: none; border: 0; border-radius: 10px; background: var(--bg); cursor: pointer; font-size: 22px; line-height: 1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1 1 160px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
label small { font-weight: 400; color: var(--muted); }
.field { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); padding: 12px; font-size: 16px; }
textarea.field { min-height: 92px; resize: vertical; }
.preview { margin: 0; padding: 12px; background: var(--bg); border-radius: 12px; font: 500 13px/1.5 var(--f-code); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
/* ringraziamento dopo l'invio: entra il logo, si disegna la spunta, «Grazie», poi sparisce da solo */
.thanks { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; background: var(--surface); animation: th-in .25s ease-out both; }
.thanks.via { animation: th-out .35s ease-in both; }
.thanks img { width: 200px; height: auto; background: #fff; padding: 10px 14px; border-radius: 14px; animation: th-logo .7s cubic-bezier(.2, 1.4, .4, 1) .1s both; }
.thanks svg { width: 64px; height: 64px; color: var(--ok); }
.thanks svg circle, .thanks svg path { fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.thanks svg circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: th-draw .5s ease-out .6s forwards; }
.thanks svg path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: th-draw .3s ease-out 1s forwards; }
.thanks h2 { font: 700 26px/1.2 var(--f-display); margin: 0; animation: th-up .4s ease-out 1.1s both; }
.thanks p { margin: 0; color: var(--muted); animation: th-up .4s ease-out 1.25s both; }
@keyframes th-in { from { opacity: 0; } }
@keyframes th-out { to { opacity: 0; } }
@keyframes th-logo { from { opacity: 0; transform: scale(.6) translateY(10px); } }
@keyframes th-draw { to { stroke-dashoffset: 0; } }
@keyframes th-up { from { opacity: 0; transform: translateY(12px); } }
/* ingresso: logo, «Richiesta materiale» e barra che si riempie; sparisce da sola anche senza script */
.intro { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; background: var(--surface); animation: intro-out .4s ease-in 1.8s forwards; }
.intro img { width: 220px; height: auto; background: #fff; padding: 10px 14px; border-radius: 14px; animation: th-logo .7s cubic-bezier(.2, 1.4, .4, 1) both; }
.intro .eyebrow { animation: th-up .4s ease-out .45s both; }
.intro .load { width: 140px; height: 4px; border-radius: 2px; background: var(--sky-soft); overflow: hidden; animation: th-up .4s ease-out .55s both; }
.intro .load i { display: block; width: 100%; height: 100%; background: var(--sky); animation: intro-load 1.1s ease-in-out .6s both; }
.intro .credits { position: absolute; left: 0; right: 0; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); animation: th-up .4s ease-out .8s both; }
@keyframes intro-out { to { opacity: 0; visibility: hidden; } }
@keyframes intro-load { from { width: 0; } }
/* crediti dell'idea */
.credits { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.credits svg { width: 14px; height: 14px; color: var(--sky); flex: none; }
.credits b { color: var(--fg); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .thanks, .thanks *, .intro, .intro * { animation-duration: .01s !important; animation-delay: 0s !important; } }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* elenco «voce: valore» nelle schede */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd.mono { font-family: var(--f-code); }
/* freccia «torna alla home» accanto al logo */
.home { display: flex; align-items: center; gap: 2px; margin-left: -8px; padding: 4px; border-radius: 10px; color: var(--top-soft); text-decoration: none; }
.home svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* barra fissa in basso (riepilogo + pulsante) */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(15, 37, 54, .08); }
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.bar .sum { min-width: 0; }
.bar .sum b { font: 700 18px/1.1 var(--f-display); display: block; font-variant-numeric: tabular-nums; }
.bar .sum span { color: var(--muted); font-size: 13px; }
/* riquadri numerati (sopralluogo, reso): il numero diventa ✓ quando il passo è fatto */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.box h2 { display: flex; align-items: center; gap: 10px; font-size: 21px; }
.box h2::before { counter-increment: passo; content: counter(passo); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-fg); font: 700 15px/1 var(--f-body); }
.box.fatto h2::before { content: "✓"; background: var(--ok); }
.box.guarda { animation: guarda .9s ease 2; }
@keyframes guarda { 50% { box-shadow: 0 0 0 4px var(--sky); } }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg button { text-align: left; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--bg); cursor: pointer; display: grid; gap: 2px; align-content: start; }
.seg button b { font: 700 18px/1.15 var(--f-display); }
.seg button small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.seg button[aria-checked="true"] { border-color: var(--brand); background: var(--sky-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.due { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.field.mono { font-family: var(--f-code); text-transform: uppercase; letter-spacing: .02em; }
.esito { font-size: 14px; margin: -4px 0 0; color: var(--muted); }
.esito.ok { color: var(--ok); font-weight: 600; }
.esito.no { color: #B45309; font-weight: 600; }
.avvisi { margin: 0; padding-left: 18px; color: #B45309; font-weight: 600; font-size: 14px; }
/* ricerca nel catalogo (materiale, reso) */
.search { position: relative; }
.search input {
  width: 100%; height: 52px; padding: 0 48px 0 46px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg);
  font-size: 17px;
}
.search input:focus { border-color: var(--sky); outline: none; box-shadow: 0 0 0 4px var(--sky-soft); }
.search svg { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; color: var(--muted); pointer-events: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search .clear { position: absolute; right: 6px; top: 6px; width: 40px; height: 40px; border: 0; background: none; border-radius: 8px; color: var(--muted); font-size: 22px; cursor: pointer; }
/* invio (comune.js): chi sei, pulsante, come si manda */
.invio { display: grid; gap: 12px; }
.chi-campi { display: grid; gap: 12px; }
.chi-ok { margin: 0; padding: 12px; border-radius: 12px; background: var(--bg); }
.link { border: 0; background: none; padding: 0 0 0 6px; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
.nega { margin: 0; color: #B91C1C; font-weight: 700; font-size: 14px; }
.invia { width: 100%; height: 54px; font-size: 17px; }
.progresso { height: 8px; border-radius: 4px; background: var(--sky-soft); overflow: hidden; }
.progresso i { display: block; height: 100%; width: 0; background: var(--sky); transition: width .2s ease; }
/* tastiera aperta (comune.js): la barra in basso sparisce, le schede stanno nello spazio sopra la tastiera */
html.tastiera .bar { display: none; }
html.tastiera dialog:not(.full) { max-height: calc(var(--alto, 100dvh) - 8px); }
/* «Cancella tutto» in fondo alle pagine: il secondo tocco conferma */
.cancella { justify-self: center; border: 0; background: none; color: #B91C1C; font-weight: 600; font-size: 15px; padding: 10px 14px; border-radius: 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cancella.sicuro { background: #B91C1C; color: #fff; text-decoration: none; }
