/* App cliente – mobile first. Su tablet occupa tutto lo schermo con contenuti più larghi,
   su PC (da 1024px) la barra in basso diventa un menu laterale. Le regole sono in fondo al file. */
body.cliente { min-height: 100vh; min-height: 100dvh; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--bg); position: relative; display: flex; flex-direction: column; }
.wide-only { display: none !important; }

.topbar { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: rgba(16, 14, 12, .92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; min-height: 58px; padding-top: calc(.8rem + env(safe-area-inset-top)); }
.topbar .back { background: none; border: 0; color: var(--text); font-size: 1.5rem; cursor: pointer; padding: 0 .4rem 0 0; line-height: 1; }
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .logo { width: 34px; height: 34px; object-fit: contain; }
.brand-mini { font: 600 .68rem var(--sans); letter-spacing: .14em; color: var(--accent-2); text-transform: uppercase; }

.view { flex: 1; padding: 1rem 1rem 96px; }
.view.no-tabs { padding-bottom: 1.5rem; }
/* Benvenuto: contenuto centrato in verticale e staccato dalla barra di stato (app installata su iPhone). */
.view.benv { display: flex; flex-direction: column; justify-content: center; min-height: 100vh; min-height: 100dvh;
  padding-top: calc(1rem + env(safe-area-inset-top)); padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.benv > .hero { padding-top: 0; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(26, 23, 20, .97); border-top: 1px solid var(--line); padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom)); z-index: 30; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; padding: .3rem 0; position: relative; }
.tabbar a .ic { font-size: 1.3rem; line-height: 1.2; filter: grayscale(1); opacity: .75; }
.tabbar a.on { color: var(--accent-2); }
.tabbar a.on .ic { filter: none; opacity: 1; }
.tabbar .count { position: absolute; top: 0; left: 55%; background: var(--wa); color: #08361b; font-size: .62rem; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Benvenuto */
.hero { text-align: center; padding: 2rem 1rem 1rem; }
.hero .logo-big { width: 220px; max-width: 70%; height: auto; object-fit: contain; margin-bottom: 1rem; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .45)); }
.hero h1 { font-size: 2rem; letter-spacing: .02em; }
.hero .tag { color: var(--accent-2); font-family: var(--serif); font-style: italic; font-size: 1.05rem; }
.features { display: grid; gap: .6rem; margin: 1.2rem 0; }
.feature { display: flex; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; text-align: left; }
.feature .ic { font-size: 1.5rem; }
.feature b { display: block; font-size: .95rem; }
.feature span { font-size: .82rem; color: var(--text-2); }

/* Auto */
.car-card { background: linear-gradient(135deg, #2b2621, #1a1714); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: block; color: inherit; text-decoration: none; position: relative; overflow: hidden; }
.car-card::after { content: none; position: absolute; right: -10px; bottom: -18px; font-size: 5rem; opacity: .06; }
.car-card:hover { border-color: var(--accent); }
.car-card .nome { font: 700 1.15rem var(--serif); margin: .1rem 0 .5rem; }
.car-card .meta { font-size: .82rem; color: var(--text-2); display: flex; gap: .8rem; flex-wrap: wrap; margin-top: .6rem; }
.cars { display: grid; gap: .7rem; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.quick a, .quick button { display: flex; flex-direction: column; align-items: center; gap: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .2rem; color: var(--text); text-decoration: none; font: 600 .72rem var(--sans); cursor: pointer; }
.quick .ic { font-size: 1.35rem; }

.deadline { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-left: 4px solid var(--ok); }
.deadline.warn { border-left-color: var(--warn); } .deadline.bad { border-left-color: var(--bad); }
.deadline + .deadline { margin-top: .5rem; }

.stepper { display: flex; gap: .3rem; margin-bottom: 1rem; }
.stepper span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.stepper span.on { background: var(--accent); }

.choice { display: grid; gap: .5rem; }
.choice label { display: flex; gap: .7rem; align-items: center; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.choice input { width: auto; accent-color: var(--accent); }
.choice label:has(input:checked) { border-color: var(--accent); background: rgba(200, 100, 30, .1); }

.summary { background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 1rem; }
.sticky-cta { position: sticky; bottom: 76px; padding-top: .8rem; background: linear-gradient(transparent, var(--bg) 35%); }

.voce { display: flex; justify-content: space-between; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.voce:last-child { border-bottom: 0; }
.voce .spec { font-size: .8rem; color: var(--text-2); }
.success-ic { font-size: 3.5rem; text-align: center; margin: 1rem 0 .5rem; }

/* Scheda auto in stile "storico tagliandi" */
.verified { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--ok); font-weight: 700; background: var(--surface); }
.hero-car { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 10; background: radial-gradient(circle at 50% 30%, #3a2410, #0d0d0d 70%); border: 1px solid var(--line); }
.hero-car img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 8% 10% 22%; background: linear-gradient(180deg, rgba(255,255,255,.04) 0 55%, transparent 55%), repeating-linear-gradient(90deg, transparent 0 46px, rgba(255,255,255,.03) 46px 48px); }
.hero-ph svg { width: 100%; height: auto; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.82)); }
.hero-txt { position: absolute; left: 1rem; right: 1rem; bottom: .8rem; }
.hero-plate { font: 700 1.9rem/1 'Courier New', ui-monospace, monospace; letter-spacing: .14em; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.hero-model { color: #e8e1d6; font-size: .9rem; margin-top: .3rem; }
.hero-photo { position: absolute; top: .6rem; right: .6rem; width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; }
.info-card { background: var(--surface); border: 1px solid var(--line); border-radius: 0 0 18px 18px; margin: -6px 6px 0; padding: .9rem 1rem .3rem; }
.info-owner { color: var(--text-2); font-size: .9rem; padding-bottom: .5rem; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: .85rem 0; border-top: 1px solid var(--line); font-size: .9rem; color: var(--text-2); }
.info-row b { font-size: 1.15rem; color: var(--text); }
.info-row b.accent { color: var(--accent-2); }
.stato.ok { color: var(--ok) !important; } .stato.warn { color: var(--warn) !important; } .stato.bad { color: var(--bad) !important; } .stato.muted { color: var(--muted) !important; }
.tiles { display: grid; gap: .6rem; margin-top: .9rem; }
.tile { display: flex; align-items: center; gap: .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem; color: inherit; text-decoration: none; }
.tile > div { flex: 1; min-width: 0; }
.tile small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.tile b { font-size: .95rem; }
.tile-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex: none; }
.tile.hl-bad { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.tile.hl-warn { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.tile .chev { color: var(--muted); }
/* Pulsanti Messaggio/Chiama nella home, subito sotto l'indirizzo dell'officina. */
/* Fissati in fondo allo schermo, sopra la barra di navigazione: non scorrono con la pagina. */
.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h, 66px) + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; padding: .6rem 1rem; background: linear-gradient(transparent, var(--bg) 30%); z-index: 25; }
.view:has(.cta-row) { padding-bottom: calc(var(--tabbar-h, 66px) + 96px + env(safe-area-inset-bottom)); }
.cta-wa { background: linear-gradient(135deg, #2ee6a6, #1fb6a0); border: 0; color: #05261c; border-radius: 14px; padding: .9rem; }
.cta-call { background: linear-gradient(135deg, #c0392b, #8e1d14); border: 0; color: #fff; border-radius: 14px; padding: .9rem; }
.car-card .thumb { position: absolute; right: 0; top: 0; bottom: 0; width: 45%; object-fit: cover; -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%); mask-image: linear-gradient(90deg, transparent, #000 40%); opacity: .9; }
.car-card .thumb-svg { position: absolute; right: -6px; bottom: 6px; width: 46%; opacity: .55; }
.car-card > *:not(.thumb):not(.thumb-svg) { position: relative; }

/* Profilo in alto a destra (la barra in basso ha Home, Prenota, Documenti, Fatture) */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); display: flex; align-items: center; justify-content: center; font: 700 .8rem var(--sans); text-decoration: none; text-transform: uppercase; flex: none; }
.avatar.on { border-color: var(--accent); color: var(--accent-2); }
.quick a.has-count { position: relative; }
.quick .count { position: absolute; top: 6px; right: 14%; background: var(--wa); color: #08361b; font-size: .62rem; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Caricamento file e foto */
.upload { display: flex; align-items: center; justify-content: center; min-height: 56px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg-2); color: var(--text-2); font-size: .9rem; cursor: pointer; padding: .6rem; text-align: center; }
.upload:hover { border-color: var(--accent); color: var(--text); }
.lib-prev { width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radius-sm); background: #000; margin-top: .4rem; }
.lib-thumb { width: 64px; height: 48px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; flex: none; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.help-box summary { cursor: pointer; list-style: none; }
.help-box summary::-webkit-details-marker { display: none; }
.libretto-demo { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem; margin-top: .7rem; padding: .6rem; border-radius: 8px; background: #e9e4d8; color: #2a2a2a; font: .78rem 'Courier New', monospace; }
.libretto-demo div { padding: .25rem .4rem; border: 1px solid #c9c1b0; border-radius: 4px; }
.libretto-demo span { font-weight: 700; margin-right: .35rem; }
.libretto-demo .hl { background: #ffd89a; border-color: var(--accent); outline: 2px solid var(--accent); }
.res-grid { grid-template-columns: 1fr 2fr .8fr; }
@media (max-width: 640px) { .res-grid { grid-template-columns: 1fr 2fr .8fr; } }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .4rem; }
.gallery:empty { display: none; }
.g-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: #000; cursor: pointer; }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; }

/* Documenti e fatture */
.doc .doc-ic { font-size: 1.6rem; }
.doc-amount { font-family: var(--serif); white-space: nowrap; }

/* Sabato su appuntamento */
.cal-day.appt { cursor: pointer; opacity: .85; border-style: dashed; }
.hero-ph.fa-ok { padding: 0; background: none; }
.hero-ph .fa-credit { z-index: 3; top: auto; left: auto; right: .5rem; bottom: .5rem; max-width: 42%; border-radius: 6px; }
.car-card .thumb-svg.fa-ok { right: 0; top: 0; bottom: 0; width: 45%; opacity: .9; -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%); mask-image: linear-gradient(90deg, transparent, #000 40%); }
.prof-car .thumb, .prof-car .thumb-svg { width: 76px; height: 50px; flex: none; border-radius: 8px; overflow: hidden; object-fit: cover; display: grid; place-items: center; }
.prof-car .thumb-svg svg { width: 100%; height: auto; }

/* Assicurazione e sinistri: scelta tra foto e file, anteprima dei PDF. */
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.g-pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; background: var(--bg-2); color: var(--text-2); padding: .3rem; }
.g-pdf .g-ic { font-size: 1.6rem; }
.g-pdf small { font-size: .65rem; line-height: 1.1; word-break: break-all; text-align: center; max-height: 2.2em; overflow: hidden; }
.sinistro-btn { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); font-weight: 700; }
.danger-text { color: var(--bad) !important; }

/* ---------- Tablet (da 700px) ---------- */
@media (min-width: 700px) {
  .app { max-width: none; }
  .topbar { padding-left: max(1.2rem, calc((100% - 860px) / 2 + 1.5rem)); padding-right: max(1.2rem, calc((100% - 860px) / 2 + 1.5rem)); }
  .view { width: 100%; max-width: 860px; margin: 0 auto; padding: 1.4rem 1.5rem 110px; }
  .view.no-tabs { max-width: 620px; padding-bottom: 2.5rem; }
  .tabbar { max-width: none; grid-template-columns: repeat(4, minmax(0, 150px)); justify-content: center; }
  .tabbar a { font-size: .78rem; }
  .quick a, .quick button { padding: 1rem .4rem; font-size: .85rem; }
  .quick .ic { font-size: 1.6rem; }
  .cars, .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-car { aspect-ratio: 2 / 1; }
  .hero-plate { font-size: 2.4rem; }
  .info-card { margin: -6px 10px 0; }
  .choice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery { grid-template-columns: repeat(4, 1fr); }
  .lib-prev { max-height: 320px; }
  .features { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .feature { flex-direction: column; text-align: center; align-items: center; }
  .feature span { display: block; margin-top: .2rem; }
  #toasts { bottom: 90px; }
  .cta-row { max-width: 860px; padding-left: 1.5rem; padding-right: 1.5rem; --tabbar-h: 68px; }
  .view:has(.cta-row) { --tabbar-h: 68px; }
}

/* ---------- PC e tablet orizzontale (da 1024px): menu laterale ---------- */
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "banner banner" "side top" "side main"; }
  .app:not(:has(.tabbar)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "banner" "top" "main"; }
  .demo-banner { grid-area: banner; }
  .topbar { grid-area: top; padding: .9rem 2rem; min-height: 66px; }
  .topbar h1 { font-size: 1.35rem; }
  .view { grid-area: main; max-width: 1100px; padding: 1.8rem 2rem 3rem; }
  .view.no-tabs { max-width: 640px; }
  .tabbar { grid-area: side; position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 1.1rem .8rem; border-top: 0; border-right: 1px solid var(--line); background: var(--bg-2); }
  .tabbar a { flex-direction: row; gap: .75rem; font-size: .95rem; font-weight: 500; padding: .65rem .8rem; border-radius: var(--radius-sm); color: var(--text-2); }
  .tabbar a:hover { background: var(--surface); color: var(--text); }
  .tabbar a .ic { font-size: 1.15rem; width: 1.5rem; text-align: center; }
  .tabbar a.on { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
  .tabbar .count { position: static; margin-left: auto; }
  .wide-only { display: flex !important; }
  .tab-brand { align-items: center; gap: .7rem; padding: .2rem .4rem 1rem !important; margin-bottom: .6rem; border-bottom: 1px solid var(--line); border-radius: 0 !important; background: none !important; box-shadow: none !important; }
  .tab-brand img { width: 46px; height: 46px; object-fit: contain; }
  .tab-brand b { display: block; font: 700 1rem var(--serif); letter-spacing: .04em; color: var(--text); }
  .tab-brand small { display: block; color: var(--muted); font-size: .75rem; font-weight: 400; }
  .tab-sep { margin-top: auto !important; }
  .sticky-cta { bottom: 0; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-car { aspect-ratio: 21 / 8; }
  .choice { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery { grid-template-columns: repeat(6, 1fr); }
  #toasts { bottom: 24px; }
  .cta-row { left: 250px; bottom: 0; max-width: 1100px; padding: .8rem 2rem 1rem; }
  .view:has(.cta-row) { padding-bottom: 110px; }
  /* Benvenuto: logo a sinistra, presentazione e pulsanti a destra */
  .view.benv { max-width: 1100px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 3rem; align-content: center; min-height: 100vh; }
  .benv > .hero { grid-column: 1; grid-row: 1 / span 5; align-self: center; }
  .benv > :not(.hero) { grid-column: 2; }
  .benv .features { grid-template-columns: minmax(0, 1fr); }
  .benv .feature { flex-direction: row; text-align: left; }
  .benv .hero .logo-big { width: 300px; }
}
.card .logo { width: 40px; height: 40px; object-fit: contain; flex: none; }
.card .row > div { min-width: 0; }
@media (min-width: 1024px) { .app:has(.tabbar) .topbar .logo { display: none; } }
