/* Magazzino – stile. Layout "Etichetta" (C): riquadri grandi, codici come nastro.
   I colori sono variabili: tema (chiaro, scuro, officina) e accento si scelgono
   in Impostazioni e vengono applicati da js/ui/tema.js. */

:root {
  --sfondo: #FFFFFF;
  --superficie: #F4F6F9;
  --superficie-2: #E9EDF2;
  --linea: #DCE2EA;
  --linea-forte: #C5CFDB;
  --testo: #0F2A44;
  --testo-2: #556677;
  --inchiostro: #0F2A44;
  --su-inchiostro: #FFFFFF;
  --nastro: #111111;
  --su-nastro: #FFFFFF;
  --giallo: #FFD400;
  --su-giallo: #111111;
  --accento: #1D5FD1;
  --su-accento: #FFFFFF;
  --accento-testo: #1D5FD1;
  --accento-tenue: #E6EEFB;
  --ok: #1F7A4D;
  --basso: #B45309;
  --esaurito: #B91C1C;
  --pericolo: #B91C1C;
  --ombra: 0 6px 24px rgba(15, 42, 68, 0.14);
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --raggio: 16px;
  --menu: 0px;
  --alto: env(safe-area-inset-top, 0px);
  --basso-sicuro: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-tema="scuro"] {
  --sfondo: #0F1215;
  --superficie: #181D22;
  --superficie-2: #222931;
  --linea: #2C343D;
  --linea-forte: #3A434D;
  --testo: #EEF1F4;
  --testo-2: #9AA5B1;
  --inchiostro: #EEF1F4;
  --su-inchiostro: #0F1215;
  --nastro: #EEF1F4;
  --su-nastro: #0F1215;
  --ok: #5BC48A;
  --basso: #F2A65A;
  --esaurito: #FF8A7A;
  --pericolo: #FF8A7A;
  --ombra: 0 6px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

:root[data-tema="officina"] {
  --sfondo: #F3F1EC;
  --superficie: #FFFFFF;
  --superficie-2: #ECE8E1;
  --linea: #E2DED6;
  --linea-forte: #CFC9BE;
  --testo: #1F1D1A;
  --testo-2: #6B665E;
  --inchiostro: #1F1D1A;
  --su-inchiostro: #FFFFFF;
  --nastro: #1F1D1A;
  --su-nastro: #FFFFFF;
}

:root[data-testo="grande"] { font-size: 18px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sfondo);
  color: var(--testo);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: clip;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accento-testo); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.mono { font-family: var(--font-mono); }
.piccolo { font-size: 0.8125rem; }
.meta { color: var(--testo-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ico { width: 1.375rem; height: 1.375rem; flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--accento); outline-offset: 2px; }

/* ---------- struttura ---------- */
#app { min-height: 100vh; }
.pagina {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(var(--alto) + 12px) 16px calc(var(--basso-sicuro) + 120px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pagina.senza-barra { padding-bottom: calc(var(--basso-sicuro) + 40px); }
.testata { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.testata h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; flex: 1; min-width: 0; }
.testata .sotto { font-size: 0.875rem; color: var(--testo-2); }
.testata .titoli { flex: 1; min-width: 0; }
.testata .titoli h1 { overflow: hidden; text-overflow: ellipsis; }
.btn-icona {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-icona:hover { background: var(--superficie); }
.btn-icona.indietro { margin-left: -10px; }
.etichetta-sezione {
  font-size: 0.75rem; font-weight: 600; color: var(--testo-2); text-transform: uppercase; letter-spacing: 0.1em;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.etichetta-sezione a { text-transform: none; letter-spacing: 0; font-size: 0.875rem; font-weight: 600; text-decoration: none; }

/* ---------- nastro (codici come etichette Dymo) ---------- */
.nastro {
  display: inline-block; font-family: var(--font-mono); font-weight: 700; letter-spacing: 0.04em;
  background: var(--nastro); color: var(--su-nastro); padding: 0.12em 0.5em; font-size: 0.8125rem;
  white-space: nowrap; line-height: 1.5; text-decoration: none;
}
.nastro.giallo { background: var(--giallo); color: var(--su-giallo); }
.nastro.grande { font-size: 1.125rem; padding: 0.2em 0.65em; }
.nastro.titolo { font-size: 0.9375rem; padding: 0.35em 0.75em; white-space: normal; text-transform: uppercase; }
.nastro.vuoto { background: transparent; color: var(--testo); border: 1px dashed var(--linea-forte); }

/* ---------- pulsanti ---------- */
.btn {
  min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--linea);
  background: var(--sfondo); font-weight: 600; font-size: 0.9375rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--testo);
}
.btn:hover { background: var(--superficie); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primario { background: var(--accento); color: var(--su-accento); border-color: transparent; }
.btn-primario:hover { background: var(--accento); filter: brightness(1.08); }
.btn-scuro { background: var(--inchiostro); color: var(--su-inchiostro); border-color: transparent; }
.btn-scuro:hover { background: var(--inchiostro); filter: brightness(1.15); }
.btn-pericolo { color: var(--pericolo); }
.btn-pericolo.pieno { background: var(--pericolo); color: #fff; border-color: transparent; }
.btn-grande { min-height: 58px; font-size: 1.0625rem; border-radius: 16px; }
.btn-tratteggio { border-style: dashed; border-color: var(--linea-forte); color: var(--accento-testo); background: transparent; }
.btn-testo { border: 0; background: transparent; color: var(--accento-testo); padding: 0 8px; min-height: 44px; }
.largo { width: 100%; }
.fila { display: flex; gap: 8px; }
.fila > * { flex: 1; }
.griglia-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* ---------- home ---------- */
.tessere { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tessera {
  min-height: 150px; border-radius: 20px; border: 1px solid var(--linea); background: var(--superficie);
  padding: 18px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  text-align: left; text-decoration: none; color: var(--testo);
}
.tessera svg.ico { width: 2rem; height: 2rem; }
.tessera b { display: block; font-size: 1.375rem; }
.tessera span.meta { font-size: 0.8125rem; }
.tessera.primaria { background: var(--accento); color: var(--su-accento); border-color: transparent; }
.tessera.scura { background: var(--inchiostro); color: var(--su-inchiostro); border-color: transparent; }
.tessera.primaria span.meta, .tessera.scura span.meta { color: inherit; opacity: 0.88; }
.banner {
  display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 16px;
  background: var(--giallo); color: var(--su-giallo); text-decoration: none;
  font-family: var(--font-mono); font-weight: 700; font-size: 0.9375rem; letter-spacing: 0.04em;
}
.banner.tranquillo { background: var(--superficie); color: var(--testo-2); }
.cerca-rapida {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px;
  border: 1px solid var(--linea); border-radius: 14px; background: var(--superficie); color: var(--testo-2);
  text-decoration: none;
}

/* ---------- barra in basso e pulsante assistente ---------- */
.barra-fondo {
  position: fixed; left: var(--menu); right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(var(--basso-sicuro) + 14px);
  background: var(--sfondo); border-top: 1px solid var(--linea);
  display: flex; gap: 10px; justify-content: center;
}
.barra-fondo > .contenuto { width: 100%; max-width: 728px; display: flex; gap: 10px; }
.barra-fondo .btn { flex: 1; }
.fab {
  position: fixed; right: 20px; bottom: calc(var(--basso-sicuro) + 104px); z-index: 21;
  width: 56px; height: 56px; border-radius: 28px; border: 1px solid var(--linea); background: var(--sfondo);
  box-shadow: var(--ombra); display: flex; align-items: center; justify-content: center; color: var(--accento-testo);
}

/* ---------- elenchi ---------- */
.elenco { display: flex; flex-direction: column; }
.riga {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linea);
  text-decoration: none; color: var(--testo); background: transparent; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; min-height: 56px;
}
.riga:last-child { border-bottom: 0; }
.riga .principale { flex: 1; min-width: 0; }
.riga .nome { font-weight: 600; font-size: 0.9375rem; display: block; }
.riga .sotto { font-size: 0.8125rem; color: var(--testo-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.riga .qta { font-family: var(--font-mono); font-weight: 700; text-align: right; white-space: nowrap; }
.riga .delta { font-family: var(--font-mono); font-weight: 700; width: 3.2rem; flex-shrink: 0; }
.scheda { border: 1px solid var(--linea); border-radius: var(--raggio); padding: 14px; background: var(--sfondo); }
.scheda.piena { background: var(--superficie); }
.scheda.evidenza { border: 2px solid var(--inchiostro); }
.scheda .elenco .riga:first-child { padding-top: 0; }
.scheda .elenco .riga:last-child { padding-bottom: 0; }
.vuoto { text-align: center; color: var(--testo-2); padding: 32px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.vuoto svg.ico { width: 2.5rem; height: 2.5rem; opacity: 0.6; }
.basso { color: var(--basso); }
.esaurito { color: var(--esaurito); }
.ok { color: var(--ok); }
.punto { width: 10px; height: 10px; border-radius: 5px; display: inline-block; flex-shrink: 0; background: var(--ok); }
.punto.basso { background: var(--basso); }
.punto.esaurito { background: var(--esaurito); }
.cartellino {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 6px;
  background: var(--superficie-2); color: var(--testo-2);
}
.cartellino.basso { background: color-mix(in srgb, var(--basso) 16%, transparent); color: var(--basso); }
.cartellino.esaurito { background: color-mix(in srgb, var(--esaurito) 16%, transparent); color: var(--esaurito); }

/* ---------- campi ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > span:first-child, .campo > legend { font-size: 0.8125rem; font-weight: 600; color: var(--testo-2); }
.input, select.input, textarea.input {
  min-height: 48px; padding: 10px 14px; border: 1px solid var(--linea-forte); border-radius: 12px;
  background: var(--sfondo); font-size: 1rem; width: 100%;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { outline: 2px solid var(--accento); outline-offset: 0; border-color: transparent; }
.input.mono { font-family: var(--font-mono); text-transform: uppercase; }
.input.mono::placeholder { text-transform: none; font-family: var(--font); }
.input-con-pulsanti { display: flex; gap: 8px; align-items: stretch; }
.input-con-pulsanti .input { flex: 1; min-width: 0; }
.input-con-pulsanti .btn { min-width: 52px; padding: 0 12px; }
.aiuto { font-size: 0.8125rem; color: var(--testo-2); margin: 0; }
.errore { color: var(--pericolo); font-size: 0.875rem; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.segmenti { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: var(--superficie-2); border-radius: 12px; }
.segmenti button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 500; font-size: 0.875rem; padding: 0 6px; color: var(--testo-2); }
.segmenti.a-capo { display: flex; flex-wrap: wrap; }
.segmenti.a-capo button { flex: 1 1 auto; }
.segmenti button[aria-pressed="true"] { background: var(--sfondo); color: var(--testo); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.interruttore { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.interruttore input { width: 48px; height: 28px; appearance: none; border-radius: 14px; background: var(--linea-forte); position: relative; cursor: pointer; flex-shrink: 0; margin: 0; }
.interruttore input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; transition: transform 0.15s; }
.interruttore input:checked { background: var(--accento); }
.interruttore input:checked::after { transform: translateX(20px); }
input[type="checkbox"].spunta { width: 24px; height: 24px; accent-color: var(--accento); margin: 0; flex-shrink: 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scorre { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chip {
  min-height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--linea); background: var(--sfondo);
  font-size: 0.875rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
}
.chips:not(.scorre) .chip { white-space: normal; text-align: left; padding-top: 6px; padding-bottom: 6px; }
.chip[aria-pressed="true"] { background: var(--inchiostro); color: var(--su-inchiostro); border-color: transparent; font-weight: 600; }
.scelte-posizione { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.scelta {
  min-height: 52px; border: 1px dashed var(--linea-forte); background: var(--sfondo); padding: 6px 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; border-radius: 0;
}
.scelta b { font-family: var(--font-mono); font-size: 0.9375rem; letter-spacing: 0.03em; }
.scelta span { font-size: 0.75rem; color: var(--testo-2); }
.scelta[aria-pressed="true"] { background: var(--nastro); color: var(--su-nastro); border: 1px solid var(--nastro); }
.scelta[aria-pressed="true"] span { color: inherit; opacity: 0.8; }
.suggerimenti { border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; background: var(--sfondo); box-shadow: var(--ombra); }
.suggerimenti button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; padding: 10px 14px; min-height: 48px; border: 0; border-bottom: 1px solid var(--linea); background: transparent; }
.suggerimenti button:last-child { border-bottom: 0; }
.suggerimenti button:hover, .suggerimenti button.attivo { background: var(--superficie); }

/* ---------- movimento ---------- */
.passo { display: flex; flex-direction: column; gap: 8px; }
.passo-titolo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.articolo-scelto { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; height: 64px; border: 2px solid var(--inchiostro);
  border-radius: 16px; overflow: hidden; flex: 1;
}
.stepper button { border: 0; background: var(--sfondo); font-size: 1.875rem; display: flex; align-items: center; justify-content: center; }
.stepper button:first-child { border-right: 2px solid var(--inchiostro); }
.stepper button:last-child { border-left: 2px solid var(--inchiostro); background: var(--inchiostro); color: var(--su-inchiostro); }
.stepper .valore { display: flex; flex-direction: column; align-items: center; justify-content: center; background: transparent; border: 0; font-family: var(--font-mono); font-size: 2rem; font-weight: 700; line-height: 1; }
.stepper .valore small { font-size: 0.6875rem; font-family: var(--font); font-weight: 500; color: var(--testo-2); margin-top: 2px; }
.livelli { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.livelli button { min-height: 56px; border: 1px solid var(--linea); border-radius: 12px; background: var(--sfondo); font-size: 0.75rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px; }
.livelli button .tacche { display: flex; gap: 2px; }
.livelli button .tacche i { width: 6px; height: 12px; border-radius: 2px; background: var(--linea-forte); }
.livelli button .tacche i.piena { background: currentColor; }
.livelli button[aria-pressed="true"] { background: var(--inchiostro); color: var(--su-inchiostro); border-color: transparent; }
.zone { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.zone button { height: 34px; border: 1px solid var(--linea-forte); background: var(--sfondo); border-radius: 4px; font-size: 0.6875rem; font-family: var(--font-mono); padding: 0; color: var(--testo-2); }
.zone button[aria-pressed="true"] { background: var(--accento); border-color: var(--accento); color: var(--su-accento); }

/* ---------- mappa dello scaffale ---------- */
.mappa { border: 1px solid var(--linea); border-radius: 16px; padding: 12px; background: var(--superficie); display: flex; flex-direction: column; gap: 6px; }
.mappa .titolo { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8125rem; font-weight: 600; }
.mappa .titolo span:last-child { color: var(--testo-2); font-weight: 500; text-align: right; }
.mappa .ripiano { display: flex; align-items: center; gap: 8px; }
.mappa .ripiano > b { font-family: var(--font-mono); font-size: 0.75rem; width: 18px; flex-shrink: 0; }
.mappa .barra { flex: 1; height: 20px; border-radius: 4px; background: var(--superficie-2); font-size: 0.6875rem; color: var(--testo-2); display: flex; align-items: center; padding-left: 8px; overflow: hidden; white-space: nowrap; }
.mappa .celle { flex: 1; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.mappa .celle i { height: 24px; border-radius: 3px; background: var(--sfondo); border: 1px solid var(--linea-forte); }
.mappa .celle i.qui { background: var(--accento); border-color: var(--accento); }
.mappa .celle.tutto i { background: color-mix(in srgb, var(--accento) 35%, var(--sfondo)); border-color: var(--accento); }
.mappa.mobile { flex-direction: row; align-items: center; gap: 12px; }

/* ---------- articolo ---------- */
.testa-articolo { background: var(--superficie); border-bottom: 1px solid var(--linea); margin: calc(-1 * (var(--alto) + 12px)) -16px 0; padding: calc(var(--alto) + 12px) 16px 0; }
.testa-articolo h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 14px; }
.cifre { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.cifre > div { background: var(--sfondo); border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; }
.cifre .meta { font-size: 0.75rem; }
.cifre b { display: block; font-family: var(--font-mono); font-size: 1.375rem; line-height: 1.3; }
.cifre b.parola { font-family: var(--font); font-size: 1rem; margin-top: 4px; }
.schede-tab { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.schede-tab button { min-height: 44px; border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 0; font-weight: 500; color: var(--testo-2); white-space: nowrap; }
.schede-tab button[aria-selected="true"] { border-bottom-color: var(--accento); color: var(--testo); font-weight: 700; }
.posto { display: flex; flex-direction: column; gap: 10px; }
.posto .alto { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.posto .quanti { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 700; }
.codice-barre { background: #fff; border-radius: 8px; padding: 8px; display: flex; justify-content: center; }
.codice-barre svg { width: 100%; max-width: 260px; height: auto; }

/* ---------- foglio (pannello dal basso) ---------- */
#foglio-sfondo {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 12, 20, 0.45);
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.15s;
}
#foglio-sfondo.aperto { opacity: 1; }
#foglio {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; overflow-x: hidden; background: var(--sfondo);
  border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--basso-sicuro) + 20px);
  display: flex; flex-direction: column; gap: 14px; transform: translateY(24px); transition: transform 0.18s;
}
#foglio-sfondo.aperto #foglio { transform: none; }
#foglio .maniglia { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--linea-forte); flex-shrink: 0; }
#foglio h2 { font-size: 1.25rem; }
.azioni-foglio { display: flex; gap: 8px; }
.azioni-foglio > * { flex: 1; }

/* ---------- avvisi ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--basso-sicuro) + 96px); z-index: 60;
  max-width: min(92vw, 520px); width: max-content; background: var(--inchiostro); color: var(--su-inchiostro);
  border-radius: 14px; padding: 12px 14px 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--ombra);
  font-size: 0.9375rem;
}
#toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; min-height: 36px; padding: 0 6px; }
#avviso-versione {
  position: fixed; top: calc(var(--alto) + 8px); left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--giallo); color: var(--su-giallo); padding: 8px 8px 8px 14px; display: flex; gap: 10px; align-items: center;
  font-weight: 600; font-size: 0.875rem; box-shadow: var(--ombra);
}
#avviso-versione button { min-height: 36px; border: 0; background: var(--nastro); color: var(--su-nastro); padding: 0 12px; font-weight: 700; }
.offline { position: fixed; top: calc(var(--alto) + 6px); right: 12px; z-index: 40; }

/* ---------- scanner ---------- */
#scanner { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; display: flex; flex-direction: column; }
#scanner .alto { position: absolute; top: 0; left: 0; right: 0; z-index: 2; padding: calc(var(--alto) + 10px) 12px 10px; display: flex; align-items: center; gap: 8px; background: linear-gradient(rgba(0,0,0,0.6), transparent); }
#scanner .alto h2 { flex: 1; font-size: 1.0625rem; }
#scanner .btn-icona { color: #fff; background: rgba(255,255,255,0.14); }
#scanner .mirino { position: relative; flex: 1; overflow: hidden; }
#scanner video { width: 100%; height: 100%; object-fit: cover; transform-origin: center; }
#scanner .cornice { position: absolute; left: 50%; top: 45%; width: min(76vw, 320px); height: min(44vw, 190px); transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,0.9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,0.35); }
#scanner .cornice::after { content: ''; position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; background: #FF8A5C; animation: scorri 1.8s ease-in-out infinite alternate; }
@keyframes scorri { from { transform: translateY(-60px); } to { transform: translateY(60px); } }
#scanner .basso { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 16px 16px calc(var(--basso-sicuro) + 18px); display: flex; flex-direction: column; gap: 12px; background: linear-gradient(transparent, rgba(0,0,0,0.75) 30%); }
#scanner .stato { text-align: center; font-size: 0.9375rem; min-height: 1.4em; }
#scanner .stato.errore { color: #FFB4A8; }
#scanner .comandi { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
#scanner .zoom { display: flex; gap: 4px; background: rgba(255,255,255,0.14); border-radius: 22px; padding: 4px; }
#scanner .zoom button { min-width: 44px; height: 36px; border-radius: 18px; border: 0; background: transparent; color: #fff; font-weight: 600; }
#scanner .zoom button[aria-pressed="true"] { background: #fff; color: #000; }
#scanner .btn { background: rgba(255,255,255,0.14); color: #fff; border: 0; }
#scanner .fuoco { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 2px solid #FFD400; border-radius: 50%; opacity: 0; pointer-events: none; }
#scanner .fuoco.visibile { animation: fuoco 0.8s ease-out; }
@keyframes fuoco { from { opacity: 1; transform: scale(1.4); } to { opacity: 0; transform: scale(1); } }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg-io { align-self: flex-end; max-width: 86%; background: var(--superficie); border: 1px solid var(--linea); padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg-ia { align-self: flex-start; max-width: 100%; white-space: pre-wrap; line-height: 1.5; }
.msg-ia.errore { color: var(--pericolo); }
.proposta { border: 2px solid var(--inchiostro); border-radius: 16px; overflow: hidden; }
.proposta .capo { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--inchiostro); color: var(--su-inchiostro); font-weight: 600; font-size: 0.875rem; }
.proposta label { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--linea); }
.proposta label .principale { flex: 1; }
.proposta .scartata { padding: 10px 14px; color: var(--testo-2); font-size: 0.8125rem; border-bottom: 1px solid var(--linea); }
.proposta .azioni-foglio { padding: 10px 14px; }
.proposta.fatta { opacity: 0.6; }
.digita { display: flex; gap: 8px; align-items: flex-end; }
.digita textarea { flex: 1; min-height: 50px; max-height: 140px; border: 2px solid var(--inchiostro); border-radius: 14px; padding: 12px 14px; resize: none; background: var(--sfondo); }
.digita .btn { flex: 0 0 50px; min-width: 50px; min-height: 50px; padding: 0; }
.attesa { display: inline-flex; gap: 4px; }
.attesa i { width: 7px; height: 7px; border-radius: 4px; background: var(--testo-2); animation: lampeggia 1s infinite; }
.attesa i:nth-child(2) { animation-delay: 0.15s; }
.attesa i:nth-child(3) { animation-delay: 0.3s; }
@keyframes lampeggia { 50% { opacity: 0.2; } }

/* ---------- posizioni ---------- */
.albero details { border: 1px solid var(--linea); border-radius: var(--raggio); background: var(--sfondo); }
.albero details + details { margin-top: 10px; }
.albero summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; min-height: 56px; }
.albero summary::-webkit-details-marker { display: none; }
.albero summary .principale { flex: 1; min-width: 0; }
.albero summary .freccia { transition: transform 0.15s; color: var(--testo-2); }
.albero details[open] > summary .freccia { transform: rotate(90deg); }
.albero .figli { padding: 0 14px 10px; }
.albero .figli .riga { padding: 10px 0; min-height: 48px; }

/* ---------- accesso ---------- */
.porta { max-width: 420px; margin: 0 auto; padding: calc(var(--alto) + 48px) 24px 40px; display: flex; flex-direction: column; gap: 18px; min-height: 100vh; justify-content: center; }
.porta h1 { font-size: 2.25rem; letter-spacing: -0.03em; }
.porta .logo { width: 72px; height: 72px; }
.porta ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; color: var(--testo-2); }
.porta li { display: flex; gap: 10px; align-items: flex-start; }
.caricamento { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: var(--testo-2); }

/* ---------- menu laterale (PC) ---------- */
#menu-laterale { display: none; }
@media (min-width: 1000px) {
  :root { --menu: 248px; }
  #menu-laterale {
    display: flex; flex-direction: column; gap: 2px; position: fixed; left: 0; top: 0; bottom: 0; width: var(--menu);
    border-right: 1px solid var(--linea); background: var(--superficie); padding: 20px 12px; overflow-y: auto; z-index: 30;
  }
  #menu-laterale .marchio { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 1.25rem; }
  #menu-laterale a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--testo); text-decoration: none; font-weight: 500; }
  #menu-laterale a:hover { background: var(--superficie-2); }
  #menu-laterale a[aria-current="page"] { background: var(--inchiostro); color: var(--su-inchiostro); font-weight: 600; }
  #menu-laterale .separa { height: 1px; background: var(--linea); margin: 10px 4px; }
  #menu-laterale .conteggio { margin-left: auto; font-family: var(--font-mono); font-size: 0.75rem; background: var(--giallo); color: var(--su-giallo); padding: 0 6px; }
  #app { padding-left: var(--menu); }
  .solo-telefono { display: none !important; }
  .fab { right: 32px; }
  #foglio-sfondo { align-items: center; }
  #foglio { border-radius: 20px; max-height: 86vh; padding-bottom: 20px; }
  .tessera { min-height: 120px; }
  .tessere { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 999px) { .solo-pc { display: none !important; } }

/* ---------- stampa etichette ---------- */
#stampa { display: none; }
.anteprima-etichette { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; background: var(--superficie-2); border-radius: 12px; overflow-x: auto; }
.etichetta {
  background: #fff; color: #000; display: flex; align-items: center; gap: 2.5mm; padding: 2mm 2.5mm; overflow: hidden;
  font-family: var(--font); box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.etichetta .qr { flex-shrink: 0; display: flex; }
.etichetta .qr svg { width: 100%; height: 100%; display: block; }
.etichetta .testi { min-width: 0; display: flex; flex-direction: column; gap: 0.6mm; }
.etichetta .cod { font-family: var(--font-mono); font-weight: 700; line-height: 1; letter-spacing: 0.02em; }
.etichetta .nome { line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.etichetta .tipo { font-size: 6pt; text-transform: uppercase; letter-spacing: 0.08em; }
.fmt-57x32 { width: 57mm; height: 32mm; } .fmt-57x32 .qr { width: 24mm; height: 24mm; } .fmt-57x32 .cod { font-size: 18pt; } .fmt-57x32 .nome { font-size: 7.5pt; }
.fmt-89x36 { width: 89mm; height: 36mm; } .fmt-89x36 .qr { width: 29mm; height: 29mm; } .fmt-89x36 .cod { font-size: 26pt; } .fmt-89x36 .nome { font-size: 9pt; }
.fmt-54x25 { width: 54mm; height: 25mm; } .fmt-54x25 .qr { width: 19mm; height: 19mm; } .fmt-54x25 .cod { font-size: 16pt; } .fmt-54x25 .nome { font-size: 7pt; }
.fmt-51x19 { width: 51mm; height: 19mm; } .fmt-51x19 .qr { width: 15mm; height: 15mm; } .fmt-51x19 .cod { font-size: 15pt; } .fmt-51x19 .nome { font-size: 6.5pt; -webkit-line-clamp: 1; }
.fmt-a4 { width: 70mm; height: 37mm; } .fmt-a4 .qr { width: 27mm; height: 27mm; } .fmt-a4 .cod { font-size: 22pt; } .fmt-a4 .nome { font-size: 8.5pt; }
.lista-brother { font-family: var(--font-mono); }

@media print {
  body { background: #fff; }
  #app, #menu-laterale, #toast, #foglio-sfondo, #scanner, #avviso-versione, .barra-fondo, .fab { display: none !important; }
  #stampa { display: block; }
  #stampa .etichetta { box-shadow: none; break-after: page; page-break-after: always; }
  #stampa.foglio-a4 { display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37mm; }
  #stampa.foglio-a4 .etichetta { break-after: auto; page-break-after: auto; outline: 0.1mm dashed #bbb; }
  #stampa.testo { font-family: monospace; font-size: 11pt; color: #000; }
}
