/* =========================================================================
   Magazzino Noleggio — Quadro — il quadro comandi (scuro) e il suo chiaro
   ========================================================================= */

/* ── Quadro (scuro, predefinito) — acciaio e spie da semaforo ────────── */
:root {
  /* Scala di spaziatura del sito: ogni distanza è multiplo di 4 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px;
  --radius:    10px;
  --radius-sm: 8px;   /* era 9px: fuori dalla scala da 4 */
  --tap:       44px;
  --nav-h:     64px;
  --ease:      220ms cubic-bezier(.4,0,.2,1);

  --bg:        #0a0c0e;
  --bg-2:      #0e1113;
  --surface:   #131719;
  --surface-2: #1a1f22;
  --border:    #212729;
  --border-2:  #2c3437;
  --text:      #e8edef;
  --text-2:    #889599;
  --text-3:    #7c8a8f;

  /* L'acciaio e' il colore dei comandi e non vuole dire niente: cosi'
     quando in pagina compare un colore, e' per forza un'informazione. */
  --accent:     #d7dde0;
  --accent-ink: #0a0c0e;
  --accent-rgb: 215,221,224;

  /* Le tre spie. Verde, ambra e rosso da semaforo vero: si leggono senza
     leggerle, e non li usa nient'altro. */
  --green:      #22c55e;
  --green-rgb:  34,197,94;
  --green-text: #4ade80;
  --green-ink:  #04210f;
  --red:        #ef4444;
  --red-rgb:    239,68,68;
  --red-text:   #f87171;
  --red-ink:    #240606;
  --amber:      #f59e0b;
  --amber-rgb:  245,158,11;
  --amber-text: #fbbf24;
  --amber-ink:  #1a1102;

  --muted-rgb:      136,149,153;
  --doc-rgb:        148,163,184;
  --tag-ddt-color:  #94a3b8;

  --nav-bg:              rgba(10,12,14,.94);
  --toast-err-bg:        #1b0d0d;
  --toast-ok-bg:         #08210f;
  --btn-primary-bg:      #d7dde0;
  --btn-primary-color:   #0a0c0e;
  --btn-primary-border:  #c3cbcf;

  /* Il bisello: una riga di luce sul bordo alto dei pannelli, come una
     lamiera. E l'alone delle spie, che le fa sembrare accese davvero. */
  --bisello:   inset 0 1px 0 rgba(255,255,255,.055);
  --spia:      0 0 0 3px rgba(var(--c), .16), 0 0 14px rgba(var(--c), .45);

  --shadow:    0 6px 20px rgba(0,0,0,.55);
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

/* ── Quadro chiaro ─────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #eef1f2;
  --bg-2:      #e6eaeb;
  --surface:   #fff;
  --surface-2: #f2f5f6;
  --border:    #dde3e5;
  --border-2:  #c8d1d4;
  --text:      #0f1416;
  --text-2:    #5a6669;
  --text-3:    #5b6568;

  --accent:     #1b2427;
  --accent-ink: #fff;
  --accent-rgb: 27,36,39;

  /* Sul chiaro il pieno resta acceso ma il testo scende: un ambra brillante
     scritto su bianco non si legge, riempito invece si', ed e' per questo
     che pieno e testo sono due token diversi. */
  --green:      #16a34a;
  --green-rgb:  22,163,74;
  --green-text: #036e2b;
  --green-ink:  #fff;
  --red:        #dc2626;
  --red-rgb:    220,38,38;
  --red-text:   #b91c1c;
  --red-ink:    #fff;
  --amber:      #f59e0b;
  --amber-rgb:  245,158,11;
  --amber-text: #a24100;
  --amber-ink:  #231604;

  --muted-rgb:      15,20,22;
  --doc-rgb:        71,85,105;
  --tag-ddt-color:  #475569;

  --nav-bg:              rgba(255,255,255,.94);
  --toast-err-bg:        #fef2f2;
  --toast-ok-bg:         #f0fdf4;
  --btn-primary-bg:      #1b2427;
  --btn-primary-color:   #fff;
  --btn-primary-border:  #39474b;

  --bisello:   none;
  --spia:      0 0 0 3px rgba(var(--c), .18), 0 0 10px rgba(var(--c), .3);

  --shadow:    0 4px 16px rgba(15,20,22,.08);
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* L'attributo `hidden` deve sempre nascondere l'elemento: senza questa regola
   un `display:flex/inline-flex` author (es. .sheet-backdrop, .btn) lo annulla e
   lascia overlay invisibili che intercettano i tap. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* Le cifre hanno tutte la stessa larghezza: km, minuti, giorni e quantita'
     si incolonnano da soli, in tabella e fuori. */
  font-variant-numeric: tabular-nums;
}

/* Un codice di pratica, una targa, un numero d'ordine: non sono parole, e
   non devono sembrarlo. */
.cod, .mono { font-family: var(--font-mono); letter-spacing: -.2px; }
body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }
h3 { font-size: 1rem; font-weight: 700; margin: 0 0 4px; }
.muted { color: var(--text-2); }
.code { font-family: ui-monospace, 'Courier New', monospace; font-size: .85em; color: var(--text-2); letter-spacing: .3px; }
.dot-sep { color: var(--text-3); margin: 0 2px; }

/* ---------- Layout ---------- */
.layout { display: block; }
.sidebar { display: none; }
.content {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 0;
  min-height: 100vh;
}
.bottom-spacer { height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px); }

.page-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0 20px;
}
.page-head h1 { flex: 1; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.btn-icon { display: inline-flex; align-items: center; gap: var(--sp-1, 4px); }
.btn-icon svg { flex-shrink: 0; }
.btn-icon-only { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: 32px; padding: 0; }
.section-title { margin: 28px 0 14px; }
.intro, .hint { margin: -4px 0 16px; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Le colonne le conta il template: al massimo cinque, perche' oltre i
     bersagli diventano piu' stretti del polpastrello. Le voci in piu'
     stanno sotto «Altro»: prima andavano a capo e la barra raddoppiava
     di altezza, mangiando schermo su ogni pagina. */
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); font-size: 11px; font-weight: 600;
  transition: color var(--ease);
  /* «Altro» e' un <button>: senza questo si porterebbe dietro sfondo,
     bordo e font del browser, e sarebbe l'unica voce diversa da tutte. */
  background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab .ic svg { width: 22px; height: 22px; }
.tab-label {
  max-width: 100%; padding: 0 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Sotto i 400px cinque etichette ci stanno solo respirando un po' meno. */
@media (max-width: 400px) { .tab { font-size: 10px; gap: 2px; } }
.tab.active { color: var(--accent); }
.tab:active { transform: scale(.94); }
.tab-label { line-height: 1; }

/* Le voci che non stanno in barra, nel pannello «Altro»: righe piene,
   non icone microscopiche — qui lo spazio c'e' e il nome si legge tutto. */
.nav-altro-voci { display: flex; flex-direction: column; gap: 2px; }
.nav-altro-voce {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 12px; border-radius: 12px;
  font-size: 16px; font-weight: 600; color: var(--text);
  min-height: 52px;
}
.nav-altro-voce .ic { display: flex; color: var(--text-3); }
.nav-altro-voce .ic svg { width: 22px; height: 22px; }
.nav-altro-voce:active { background: var(--bg-2); }
.nav-altro-voce.active { background: rgba(var(--accent-rgb), .12); color: var(--accent); }
.nav-altro-voce.active .ic { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2, 8px); min-height: var(--tap); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--text);
  transition: transform var(--ease), background var(--ease), border-color var(--ease), opacity var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-color); border-color: var(--btn-primary-border); }
.btn-success { background: var(--green); color: var(--accent-ink); }
.btn-danger  { background: var(--red);   color: var(--red-ink); }
.btn-ghost   { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-doc     { background: #4f46e5; color: #fff; border-color: #6366f1; }
.btn-doc:active { background: #4338ca; }
.btn-orange { background: #f97316; color: #fff; border-color: #fb923c; }
.btn-orange:active { background: #ea580c; }
.btn-whatsapp-send { background: #16a34a; color: #fff; border-color: #22c55e; }
.btn-whatsapp-send:active { background: #15803d; }
.btn-config { display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(var(--green-rgb), .12); color: var(--green-text); border: 1px solid rgba(var(--green-rgb), .25); margin: 12px 0 0; min-height: 36px; font-size: 13px; }
.btn-config:active { background: rgba(var(--green-rgb), .2); }
.btn-config svg { width: 16px; height: 16px; }
.inv-divider { height: 1px; background: var(--border); margin: 14px 0 12px; }
.btn-sm  { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-xs  { min-height: 28px; padding: 0 8px; font-size: 12px; }
.btn-lg  { min-height: 56px; font-size: 16px; flex: 1; }
.btn-block { width: 100%; }

.action-row {
  display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0;
}
.action-row > .btn,
.action-row > form {
  flex: 1 1 calc(50% - 5px); min-width: calc(50% - 5px);
}
.action-row > form { display: flex; }
.action-row > form > .btn { width: 100%; }
/* Dentro action-row tutti i bottoni sono uniformi */
.action-row .btn {
  min-height: var(--tap); font-size: 15px; padding: 0 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  /* Una riga di luce sul bordo alto: e' quello che fa sembrare un pannello
     una lamiera invece che un rettangolo colorato. Sul chiaro e' spenta. */
  box-shadow: var(--bisello);
}
.card + .card { margin-top: 14px; }

/* ---------- Search + chips ---------- */
.search-bar {
  position: relative; display: flex; align-items: center;
  margin-bottom: 12px;
}
.search-bar input {
  width: 100%; height: 42px; padding: 0 14px 0 44px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 16px;
  transition: border-color var(--ease);
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-ic {
  position: absolute; left: 14px; color: var(--text-3);
  display: flex; pointer-events: none;
}
.search-ic svg { width: 20px; height: 20px; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 16px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Category grid (inventory) ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.cat-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 4px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-2); text-decoration: none;
  transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease);
}
.cat-btn:active { transform: scale(.96); }
.cat-btn.active {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.cat-btn.active .cat-icon svg { stroke: var(--accent-ink); }
.cat-icon svg { width: 20px; height: 20px; }
.cat-label {
  font-size: 10px; font-weight: 600; line-height: 1.1;
  text-align: center; word-break: break-word;
}

/* ---------- Item list ---------- */
.item-list, .check-list, .doc-list, .timeline { list-style: none; margin: 0; padding: 0; }
.item-list li { margin-bottom: 8px; display: flex; align-items: stretch; gap: 6px; }
.item-list li .item-card { flex: 1; min-width: 0; }
.item-edit-btn {
  display: flex; align-items: center; justify-content: center;
  width: 38px; flex-shrink: 0; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-3); text-decoration: none;
  transition: background var(--ease), color var(--ease);
}
.item-edit-btn:active { background: var(--bg-2); color: var(--text); }
.item-edit-btn svg { width: 16px; height: 16px; }
.item-card {
  display: flex; align-items: center; gap: 14px;
  transition: transform var(--ease), border-color var(--ease);
}
.item-card:active { transform: scale(.99); border-color: var(--border-2); }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 16px; }
.item-meta { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-size: 13px; }

.qty-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 62px; padding: 8px 6px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.qty-num { font-size: 22px; font-weight: 800; line-height: 1; }
.qty-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; margin-top: 3px; }
.qty-ok   { background: rgba(var(--green-rgb),.10); color: var(--green-text); border-color: rgba(var(--green-rgb),.22); }
.qty-warn { background: rgba(var(--amber-rgb),.10); color: var(--amber-text); border-color: rgba(var(--amber-rgb),.25); }

/* ---------- Item detail ---------- */
.back-link {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-left: -8px; border-radius: 10px;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
}
.back-link svg { width: 22px; height: 22px; }

.info-card { padding: 6px 16px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; }
.info-grid > div { padding: 12px 0; border-bottom: 1px solid var(--border); }
.info-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.info-grid dt { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.info-grid dd { margin: 3px 0 0; font-weight: 600; }

.qr-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-img { width: 180px; height: 180px; border-radius: 10px; background: #fff; padding: 8px; }
.qr-code-label { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 1px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 8px; text-align: center;
}
.stat-num { display: block; font-size: 26px; font-weight: 800; line-height: 1; }
.stat-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-top: 6px; }
.stat-ok  .stat-num { color: var(--green-text); }
.stat-out .stat-num { color: var(--red-text); }
.stat-tot .stat-num { color: var(--text); }

/* ---------- Timeline (storico) ---------- */
.timeline { margin-top: 6px; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-badge {
  flex: 0 0 auto; min-width: 46px; height: 34px; padding: 0 8px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-weight: 800; font-size: 14px;
}
.tl-uscita   .tl-badge { background: rgba(var(--red-rgb),.12); color: var(--red-text); }
.tl-rientro  .tl-badge { background: rgba(var(--green-rgb),.12); color: var(--green-text); }
.tl-rettifica .tl-badge { background: rgba(var(--accent-rgb),.10); color: var(--accent); }
.tl-body { flex: 1; min-width: 0; }
.tl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tl-type { font-weight: 600; }
.tl-date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.tl-dest { font-size: 14px; margin-top: 2px; }
.tl-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; }

.tag { display: inline-flex; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-buono { background: rgba(var(--green-rgb),.12); color: var(--green-text); }
.tag-danneggiato { background: rgba(var(--red-rgb),.12); color: var(--red-text); }
.tag-out { background: rgba(var(--red-rgb),.12); color: var(--red-text); }
.tag-ddt { background: rgba(var(--doc-rgb),.15); color: var(--tag-ddt-color); }
.tag-ddr { background: rgba(var(--green-rgb),.15); color: var(--green-text); }
.tag-cal { background: rgba(var(--accent-rgb),.15); color: var(--accent); font-size: 11px; margin-left: 6px; }

/* ── Booking OdU link ── */
.booking-odu-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-card { display: flex; flex-direction: column; gap: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); color: var(--text); font-size: 16px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.15);
}
.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa2b5' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.field.has-error input, .field.has-error select { border-color: var(--red); }
.field .err { color: var(--red-text); font-size: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.check-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.file-field input { padding: 10px; }

.code-block, pre.code-block {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-family: ui-monospace, monospace; font-size: 12.5px;
  overflow-x: auto; color: var(--text-2); margin: 8px 0;
}

/* ---------- Alerts / toast ---------- */
.alert { padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: rgba(var(--red-rgb),.10); color: var(--red-text); border-color: rgba(var(--red-rgb),.25); }
.alert-warn  { background: rgba(var(--amber-rgb),.10); color: var(--amber-text); border-color: rgba(var(--amber-rgb),.25); }
.alert-success { background: rgba(var(--green-rgb),.10); color: var(--green-text); border-color: rgba(var(--green-rgb),.25); }

#toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 60; width: min(92%, 460px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 13px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); border: 1px solid var(--border-2);
  background: var(--surface); color: var(--text);
  animation: toast-in var(--ease);
}
.toast::before { content: "✓ "; }
.toast-error { background: var(--toast-err-bg); color: var(--red-text); border-color: rgba(var(--red-rgb),.35); }
.toast-error::before { content: "! "; }
.toast-success { background: var(--toast-ok-bg); color: var(--green-text); border-color: rgba(var(--green-rgb),.35); }
.toast-hide { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.5); opacity: 0;
  display: flex; align-items: flex-end; justify-content: center;
  transition: opacity var(--ease);
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 680px;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform 260ms cubic-bezier(.4,0,.2,1);
  max-height: 90vh; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-2); margin: 4px auto 14px; }
.sheet h3 { margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 12px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Scanner ---------- */
.scanner { text-align: center; }
.reader {
  position: relative; width: 100%; max-width: 340px; margin: 0 auto;
  aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: #000; border: 1px solid var(--border);
}
.reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.reader-frame { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.corner { position: absolute; width: 30px; height: 30px; border: 3px solid var(--accent); }
.corner.tl { top: 18px; left: 18px; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.corner.tr { top: 18px; right: 18px; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.corner.bl { bottom: 18px; left: 18px; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.corner.br { bottom: 18px; right: 18px; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }
.scan-line {
  position: absolute; left: 22px; right: 22px; top: 22px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 10px var(--accent);
  animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 22px; } 50% { top: calc(100% - 22px); } }
.scan-status { margin: 12px 0 4px; }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Documents ---------- */
.doc-card { margin-bottom: 16px; display: flex; align-items: center; gap: 12px; }
.doc-dest { font-weight: 700; font-size: 16px; }
.doc-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; }
.doc-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.doc-actions form { flex: 1 1 auto; min-width: 0; }
.doc-actions .btn { width: 100%; }

/* ---------- Import ---------- */
.import-summary { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.chip-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 13px; color: var(--text-2); }
.chip-stat strong { color: var(--text); font-size: 15px; }
.chip-stat.ok strong { color: var(--green-text); }
.chip-stat.warn strong { color: var(--amber-text); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { background: var(--bg-2); color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; }
.data-table td:nth-child(3) { white-space: normal; }
.row-bad { background: rgba(var(--red-rgb),.06); }

/* ---------- Labels select ---------- */
.select-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.check-list li { margin-bottom: 8px; }
.check-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; min-height: var(--tap);
}
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.check-main { display: flex; flex-direction: column; }

/* ---------- Sticky actions ---------- */
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + 8px); z-index: 20;
  background: linear-gradient(transparent, var(--bg) 30%);
  padding-top: 12px;
}

/* ---------- Settings ---------- */
.settings-section { margin-bottom: 32px; }
.account-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px 22px;
  box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 1.3rem; margin-top: 10px; }
.login-brand .muted { font-size: 14px; }
.brand-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, #e2231a, #f5b301);
  font: 800 13px/1 var(--font-mono); color: #14100a;
}
.brand-dot::before { content: 'Z'; }
/* La firma della macchina. E' l'unico rosso e l'unico oro dell'app, e sta
   in un punto dove non deve significare niente. */
.brand-barra { height: 3px; margin: -1px -1px 0; border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, #e2231a 0 38%, #f5b301 38% 100%); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 20px; }
.empty p { color: var(--text-2); margin-bottom: 16px; }
.empty-small { padding: 20px 0; }

/* =========================================================================
   Desktop (>= 768px): sidebar a sinistra, contenuto centrato
   ========================================================================= */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .layout { display: flex; min-height: 100vh; }
  .sidebar {
    display: flex; flex-direction: column; gap: 6px;
    width: 250px; flex: 0 0 250px; padding: 22px 16px;
    background: var(--bg-2); border-right: 1px solid var(--border);
    position: sticky; top: 0; height: 100vh;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
  .brand-name { font-weight: 700; font-size: 15px; }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px;
    border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 15px;
    transition: background var(--ease), color var(--ease);
  }
  .side-link .ic svg { width: 20px; height: 20px; }
  .side-link:hover { background: var(--surface); color: var(--text); }
  .side-link.active { background: rgba(var(--accent-rgb),.10); color: var(--accent); }
  .side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 0; border-top: 1px solid var(--border); }
  .side-user { font-size: 13px; color: var(--text-2); }
  .side-logout { font-size: 13px; color: var(--text-2); }
  .side-logout:hover { color: var(--red-text); }

  .content { flex: 1; max-width: 860px; padding: 28px 36px; }
  .bottom-spacer { height: 20px; }
  #toast-wrap { bottom: 24px; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; max-width: 500px; }
  .sticky-actions { bottom: 8px; }
  .stats { gap: 14px; }
  .info-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .info-grid > div { border-bottom: 0; }
}

@media (min-width: 768px) and (max-width: 900px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================================
   Nuove funzionalita: dashboard, programma uscita, eliminazione
   ========================================================================= */
.head-actions { display: flex; gap: 8px; }
.side-sep { height: 1px; background: var(--border); margin: 8px 6px; }

/* ---- Dashboard ---- */

/* Shortcuts (top of dashboard) — 2×2 grid */
.dash-shortcuts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.shortcut-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
.shortcut-btn:active { transform: scale(.97); }
.shortcut-icon {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-2); color: var(--text-2);
}
.shortcut-icon svg { width: 20px; height: 20px; }
.shortcut-icon.shortcut-primary { background: rgba(var(--accent-rgb),.12); color: var(--accent); }
.shortcut-label { font-size: 14px; font-weight: 600; line-height: 1.2; }

/* 4-stat row */
.dash-row-4 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px;
}
.dash-mini {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.dash-mini-num { font-size: 22px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.dash-mini-lbl { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.dash-mini.ok   .dash-mini-num { color: var(--green-text); }
.dash-mini.out  .dash-mini-num { color: var(--red-text); }
.dash-mini.warn .dash-mini-num { color: var(--amber-text); }

/* 2-col grid for ordini + DDT */
.dash-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.dash-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 3px; color: var(--text); text-decoration: none;
}
.dash-num { font-size: 26px; font-weight: 800; line-height: 1; }
.dash-lbl { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .3px; }
.dash-stat.ok   .dash-num { color: var(--green-text); }
.dash-stat.out  .dash-num { color: var(--red-text); }
.dash-stat.warn .dash-num { color: var(--amber-text); }
.dash-stat.is-link { position: relative; }
.dash-stat.is-link::after { content: "›"; position: absolute; top: 10px; right: 12px; color: var(--text-3); font-size: 20px; line-height: 1; }

/* ---- Dashboard charts ---- */
.dash-chart-row {
  display: flex; align-items: flex-start; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 16px;
}
.dash-donut-wrap { flex: 0 0 auto; }
.dash-donut { width: 100px; height: 100px; }
.dash-donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-label { flex: 1; color: var(--text-2); }
.legend-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.legend-sub { font-weight: 400; color: var(--text-3); font-size: 11px; }
.legend-sep { margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--border); }
.legend-cat { opacity: .85; }
.legend-cat .legend-dot { width: 6px; height: 6px; }

/* Category mini-donuts row */
.cat-donuts-row {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 16px;
  margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border);
}
.cat-donut-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}
.cat-donut-svg { width: 56px; height: 56px; }
.cat-donut-label { font-size: 11px; font-weight: 600; color: var(--text-2); }
.cat-donut-val { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Line chart (ordini giornalieri) */
.dash-linechart {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 10px; margin-bottom: 16px;
}
.linechart-svg { width: 100%; height: auto; display: block; }

.alert-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 16px;
  border-radius: var(--radius); background: rgba(var(--amber-rgb),.10);
  border: 1px solid rgba(var(--amber-rgb),.25); color: var(--amber-text); text-decoration: none;
}
.ab-ic { display: flex; } .ab-ic svg { width: 22px; height: 22px; }
.ab-text { flex: 1; font-size: 14px; } .ab-text strong { font-size: 16px; }
.ab-arrow { font-size: 22px; opacity: .7; }
.fuori-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- Stepper ---- */
.stepper { display: flex; gap: 8px; margin-bottom: 20px; }
.step {
  flex: 1; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3);
  padding: 8px 4px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
}
.step.active { color: var(--accent); border-color: var(--accent); background: rgba(var(--accent-rgb),.10); }
.step.done { color: var(--green-text); }

/* ---- Choice (tipo uscita) ---- */
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.choice-btn {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  padding: 18px 16px; min-height: 92px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border); color: var(--text); cursor: pointer;
  transition: border-color var(--ease), background var(--ease), transform var(--ease);
}
.choice-btn:active { transform: scale(.98); }
.choice-btn.active { border-color: var(--accent); background: rgba(var(--accent-rgb),.08); }
.choice-title { font-size: 17px; font-weight: 700; }
.choice-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.3; }
.tipo-form { margin-top: 4px; }
.draft-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 14px; flex-wrap: wrap; }

/* ---- Selezione articoli (step 2) ---- */
.usc-list .usc-item { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.usc-info { flex: 1; min-width: 0; }
.usc-ctrl { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: 0 0 auto; }
.qstep { display: flex; align-items: center; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.qbtn { width: 34px; height: 38px; border: 0; background: var(--bg-2); color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; }
.qbtn:active { background: var(--surface); }
.qinput {
  width: 46px; height: 38px; border: 0; border-left: 1px solid var(--border-2); border-right: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--text); text-align: center; font-size: 15px; -moz-appearance: textfield;
}
.qinput::-webkit-outer-spin-button, .qinput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.add-btn { min-width: 100px; }
.usc-item.in-cart { border-color: var(--accent); }
.disp-n { color: var(--green-text); font-weight: 600; }

.cart-bar {
  position: sticky; bottom: calc(var(--nav-h) + 8px); z-index: 20; margin-top: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.cart-info { font-size: 14px; color: var(--text-2); }
.cart-info strong { color: var(--text); font-size: 16px; }

.filter-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-sm);
  background: rgba(var(--amber-rgb),.08); border: 1px solid rgba(var(--amber-rgb),.22); color: var(--amber-text); font-size: 13px;
}
.filter-notice a { font-weight: 600; white-space: nowrap; }
.totale-row { text-align: right; font-size: 15px; color: var(--text-2); margin: 6px 2px 14px; }
.totale-row strong { color: var(--text); font-size: 18px; }

/* ---- Conferma / esito uscita ---- */
.success-hero { text-align: center; padding: 20px 0 8px; }
.success-ic {
  display: inline-flex; align-items: center; justify-content: center; width: 64px; height: 64px;
  border-radius: 50%; background: rgba(var(--green-rgb),.12); color: var(--green-text); margin-bottom: 10px;
}
.success-ic svg { width: 34px; height: 34px; }
.ddt-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- Eliminazione articolo ---- */
.danger-zone { margin: 32px 0 8px; padding-top: 22px; border-top: 1px solid var(--border); }
.btn-danger-outline { background: transparent; color: var(--red-text); border: 1px solid rgba(var(--red-rgb),.45); }
.btn-danger-outline:active { background: rgba(var(--red-rgb),.08); }

@media (min-width: 768px) {
  /* Shortcuts: 4 in riga su desktop */
  .dash-shortcuts { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .shortcut-btn { padding: 18px 12px; gap: 10px; }
  .shortcut-icon { width: 46px; height: 46px; }
  .shortcut-icon svg { width: 24px; height: 24px; }
  .shortcut-label { font-size: 14px; }

  /* Dashboard stat cards: più grandi */
  .dash-row-4 { gap: 12px; margin-bottom: 16px; }
  .dash-mini { padding: 14px 8px; gap: 4px; }
  .dash-mini-num { font-size: 28px; }
  .dash-mini-lbl { font-size: 10px; letter-spacing: .4px; }

  /* Donut chart: più grande e spazioso */
  .dash-chart-row { padding: 20px; gap: 24px; }
  .dash-donut { width: 130px; height: 130px; }
  .dash-donut-legend { gap: 8px; }
  .legend-item { font-size: 14px; gap: 8px; }
  .legend-dot { width: 10px; height: 10px; }
  .legend-val { font-size: 15px; }
  .legend-sub { font-size: 12px; }

  /* Mini category donuts: più grandi */
  .cat-donuts-row { gap: 20px 28px; padding-top: 16px; margin-top: 14px; }
  .cat-donut-svg { width: 72px; height: 72px; }
  .cat-donut-label { font-size: 13px; }
  .cat-donut-val { font-size: 12px; }

  /* Line chart: altezza proporzionata */
  .dash-linechart { padding: 20px 16px; }

  /* 2-col grid: più grande */
  .dash-grid-2 { gap: 14px; margin-bottom: 20px; }
  .dash-stat { padding: 18px; gap: 4px; }

  /* Item edit button: più grande su desktop con hover */
  .item-edit-btn { width: 44px; }
  .item-edit-btn:hover { background: var(--bg-2); color: var(--accent); }
  .item-edit-btn svg { width: 18px; height: 18px; }

  .choice-btn { min-height: 110px; }
  .cart-bar { bottom: 8px; }
}

/* =========================================================================
   Ordini di Uscita (OdU) + evasione
   ========================================================================= */
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.link-more { font-size: 13px; color: var(--accent); font-weight: 600; }

.odu-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.odu-main { flex: 1; min-width: 0; }
.odu-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.odu-id { font-weight: 700; font-size: 14px; }
.odu-dest { font-weight: 600; margin-top: 4px; }
.odu-sub { font-size: 12.5px; margin-top: 3px; }

.state-pill {
  display: inline-flex; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; white-space: nowrap;
}
.state-da_evadere { background: rgba(var(--muted-rgb),.15); color: var(--text); }
.state-in_evasione { background: rgba(var(--amber-rgb),.14); color: var(--amber-text); }
.state-evaso { background: rgba(var(--green-rgb),.14); color: var(--green-text); }
.state-parzialmente_evaso { background: rgba(var(--amber-rgb),.14); color: var(--amber-text); }

/* Barra di progresso */
.progress-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.progress-nums { font-weight: 700; color: var(--text); }
.progress-track { height: 10px; border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 6px; transition: width .3s ease; }

/* Input manuale evasione */
.manual-bar { display: flex; gap: 8px; margin: 8px 0 4px; }
.manual-bar input {
  flex: 1; height: var(--tap); padding: 0 14px; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); color: var(--text);
  font-size: 16px; text-transform: uppercase;
}
.manual-bar input:focus { outline: none; border-color: var(--accent); }

/* Checklist evasione */
.evasione-list { display: flex; flex-direction: column; gap: 10px; }
.evasione-line {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: background .3s, border-color .3s;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.ev-check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); color: var(--text-3); border: 1px solid var(--border-2);
}
.ev-check svg { width: 16px; height: 16px; }
.ev-info { flex: 1; min-width: 0; }
.ev-nums { text-align: right; flex: 0 0 auto; }
.ev-count { font-size: 16px; font-weight: 700; }
.ev-count .ev-evasa { color: var(--accent); }
.ev-res { display: block; font-size: 12px; margin-top: 2px; }
.evasione-line:active:not(.row-done) { background: rgba(var(--accent-rgb),.10); }
.evasione-line.row-done { border-color: rgba(var(--green-rgb),.35); background: rgba(var(--green-rgb),.06); cursor: default; }
.evasione-line.row-done .ev-check { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.evasione-line.row-done .ev-count .ev-evasa { color: var(--green-text); }
.evasione-line.row-flash { animation: evflash .7s ease; }
@keyframes evflash { 0% { background: rgba(var(--green-rgb),.22); } 100% { } }
.evasione-line.row-extra { border-style: dashed; }

.data-table tr.row-done td { color: var(--green-text); }

/* =========================================================================
   Immagine oggetto, note, rientro, lista OdU
   ========================================================================= */
.item-thumb {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-thumb svg { width: 24px; height: 24px; }

.image-card { display: flex; flex-direction: column; gap: 10px; }
.item-image {
  width: 100%; border-radius: 10px; overflow: hidden; background: var(--bg-2);
  aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center;
}
.item-image img { width: 100%; height: 100%; object-fit: cover; }
.image-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-3); }
.image-placeholder svg { width: 42px; height: 42px; }
.image-placeholder span { font-size: 13px; }

.note-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.note-card .field { width: 100%; margin-bottom: 4px; }
.op-tag { font-size: 12px; }
.review-top { margin-bottom: 12px; }
.progress-fill.fill-green { background: var(--green); }

/* Lista OdU: card con link principale + pulsante duplica */
.odu-link { flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.odu-act { flex: 0 0 auto; }
.odu-cancelled { opacity: .6; }
.odu-cancelled .odu-dest { text-decoration: line-through; }

/* =========================================================================
   Operatori, categorie, pulsanti warning (annullamento)
   ========================================================================= */
.btn-warn { background: var(--amber); color: var(--amber-ink); }
.btn-warn-outline { background: transparent; color: var(--amber-text); border: 1px solid rgba(var(--amber-rgb),.45); }
.btn-warn-outline:active { background: rgba(var(--amber-rgb),.08); }

.user-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-main { flex: 1; min-width: 0; }
.user-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.user-actions form { display: flex; }
.user-card.is-inactive { opacity: .6; }

.cat-new { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; padding: 12px 14px; }
.cat-new input {
  flex: 1; height: 42px; padding: 0 12px; background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); color: var(--text); font-size: 16px;
}
.cat-new input:focus { outline: none; border-color: var(--accent); }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.cat-order { display: flex; flex-direction: column; gap: 2px; }
.cat-order form { display: flex; }
.cat-order .qbtn {
  width: 32px; height: 22px; border: 1px solid var(--border-2); border-radius: 5px;
  background: var(--bg-2); color: var(--text-2); font-size: 10px; cursor: pointer;
}
.cat-order .qbtn:disabled { opacity: .3; cursor: default; }
.cat-name { flex: 1; font-weight: 600; min-width: 0; }
.cat-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* =========================================================================
   Inventario: griglia categorie (bottoni grandi) — fallback
   ========================================================================= */
.cat-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px; min-height: 72px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; text-align: center;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
  text-decoration: none; line-height: 1.25;
}
.cat-tile:active { transform: scale(.97); }
.cat-tile.active {
  background: rgba(var(--accent-rgb),.10); border-color: var(--accent); color: var(--accent);
}
.cat-tile-icon { display: flex; }
.cat-tile-icon svg { width: 22px; height: 22px; }
.cat-tile-label { word-break: break-word; }

.results-count { font-size: 13px; margin-bottom: 10px; }

@media (min-width: 480px) {
  .cat-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 768px) {
  .cat-grid { grid-template-columns: repeat(6, 1fr); }
}

/* =========================================================================
   Configurazioni: lista, dettaglio, tabella componenti
   ========================================================================= */
.config-list { list-style: none; margin: 0; padding: 0; }
.config-card { margin-bottom: 10px; padding: 0; }
.config-link {
  display: block; padding: 16px; color: inherit; text-decoration: none;
  transition: background var(--ease);
}
.config-link:active { background: rgba(var(--accent-rgb),.05); }
.config-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.config-nome { font-size: 16px; }
.config-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
  display: inline-flex; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.badge-neutral { background: rgba(var(--accent-rgb),.12); color: var(--accent); }

.tag-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-2); }

/* Tabella componenti */
.comp-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.comp-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.comp-table th, .comp-table td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border);
}
.comp-table th {
  background: var(--bg-2); color: var(--text-2); font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px; font-weight: 600;
  position: sticky; top: 0;
}
.comp-table tbody tr { transition: background var(--ease); }
.comp-table tbody tr:hover { background: rgba(var(--accent-rgb),.04); }
.comp-table tbody tr:last-child td { border-bottom: 0; }
.comp-optional { opacity: .7; }
.comp-optional td:first-child::before { content: ""; }
.comp-actions { display: flex; gap: 6px; justify-content: flex-end; }
.comp-actions .qbtn {
  width: 32px; height: 32px; border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--bg-2); color: var(--text-2); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--ease), border-color var(--ease);
}
.comp-actions .qbtn:hover { background: var(--surface); border-color: var(--border-2); }
.comp-actions .qbtn-danger:hover { color: var(--red-text); border-color: rgba(var(--red-rgb),.45); }

.empty-state { text-align: center; padding: 32px 20px; }
.empty-state p { margin-bottom: 14px; }

/* Configurazioni: griglia compatta (pagina inventario > Tende) */
.config-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
.config-tile {
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color var(--ease), transform var(--ease);
  text-decoration: none; color: inherit;
}
.config-tile:active { transform: scale(.99); border-color: var(--accent); }
.config-tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.config-tile-top strong { font-size: 15px; }
.config-tile-meta { display: flex; flex-wrap: wrap; gap: 6px; }

@media (min-width: 480px) {
  .config-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================================
   Wizard configuratore tenda
   ========================================================================= */
.wiz-progress {
  height: 4px; background: var(--border); border-radius: 2px;
  margin: 12px 0 6px; overflow: hidden;
}
.wiz-progress-bar {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .35s ease;
}
.wiz-step-label {
  font-size: 12px; color: var(--text-2); text-align: center; margin-bottom: 16px;
}

/* Container e passi */
.wiz-container { min-height: 200px; }
.wiz-step { display: none; }
.wiz-step.active { display: block; animation: wizFade .25s ease; }
@keyframes wizFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.wiz-title {
  font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--text);
}

/* Opzioni cliccabili (bottoni grandi) */
.wiz-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px;
}
.wiz-opt {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 12px 16px;
  background: var(--bg-2); border: 2px solid var(--border-2); border-radius: var(--radius);
  color: var(--text); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
  text-align: center; word-break: break-word;
}
.wiz-opt:active { transform: scale(.97); }
.wiz-opt.selected {
  border-color: var(--accent); background: rgba(var(--accent-rgb),.08);
  color: var(--accent);
}
.wiz-opt:hover:not(.selected) { border-color: var(--text-2); }

/* Opzione tenda (con nome + codice) */
.wiz-opt-tent {
  flex-direction: column; gap: 2px; text-align: center;
}
.wiz-tent-name { font-weight: 700; font-size: 15px; }
.wiz-tent-code { font-size: 12px; color: var(--text-2); font-weight: 400; }

/* Azioni wizard */
.wiz-actions {
  display: flex; gap: 10px; justify-content: space-between;
  margin-top: 20px; padding: 16px 0;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 60px; background: var(--bg);
  z-index: 10;
}
.wiz-actions .btn { flex: 1; }

/* Riepilogo configurazione */
.wiz-review { animation: wizFade .25s ease; }
.wiz-summary {
  display: grid; grid-template-columns: 1fr; gap: 0;
  margin: 0;
}
.wiz-sum-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.wiz-sum-row:last-child { border-bottom: none; }
.wiz-sum-row dt { color: var(--text-2); font-size: 13px; font-weight: 500; }
.wiz-sum-row dd { margin: 0; font-weight: 600; font-size: 14px; text-align: right; }

/* Pulsante "Configura tenda" nella distinta */
.tent-wizard-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; margin-bottom: 16px;
  background: rgba(var(--accent-rgb),.08); border: 2px dashed var(--accent);
  border-radius: var(--radius); color: var(--accent);
  font-size: 15px; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: background .2s, transform .15s;
}
.tent-wizard-btn:active { transform: scale(.98); }
.tent-wizard-btn:hover { background: rgba(var(--accent-rgb),.15); }
.tent-wizard-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* Tende configurate nell'ordine */
.tent-config-card {
  margin-bottom: 14px; padding: 16px 18px;
}
.tent-config-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.tent-config-head strong { font-size: 15px; }
.tent-config-details {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.tent-config-actions {
  display: flex; gap: 8px; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
}

@media (min-width: 480px) {
  .wiz-options { grid-template-columns: 1fr 1fr 1fr; }
}

/* =========================================================================
   UX AUDIT — Desktop (ufficio) & Mobile (operativo) miglioramenti
   ========================================================================= */

/* ---------- General: focus & accessibility ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* Smooth scroll sitewide */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Contrasto alto per chi lavora fuori, col sole sullo schermo: qui il
   grigio tenue smette di esistere e diventa quasi testo normale. */
@media (prefers-contrast: more) {
  :root { --text-2: #b6c0c3; --text-3: #9aa6aa; }
  [data-theme="light"] { --text-2: #394245; --text-3: #4a5457; }
}

/* ---------- Mobile operative improvements (<768px) ---------- */
@media (max-width: 767px) {
  /* Sticky progress bar at top during operative scroll */
  .progress-wrap {
    position: sticky;
    top: 0;
    z-index: 12;
  }

  /* Bigger touch area for evasione lines on mobile */
  .evasione-line {
    padding: 14px 16px;
    min-height: 60px;
  }

  /* Scanner full-bleed on mobile */
  .reader {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  /* OdU card: slightly more touch area */
  .odu-card { padding: 14px 16px; min-height: 72px; }

  /* Item card: larger touch target */
  .item-card { padding: 12px 14px; min-height: 68px; }

  /* Dash shortcuts: bigger buttons on phone */
  .shortcut-btn { padding: 16px 8px; }
}

/* Scan flash animations (success/error feedback) */
@keyframes scanPulseOk {
  0%  { box-shadow: 0 0 0 0 rgba(var(--green-rgb),.40); }
  70% { box-shadow: 0 0 0 12px rgba(var(--green-rgb),0); }
  100%{ box-shadow: none; }
}
@keyframes scanPulseErr {
  0%  { box-shadow: 0 0 0 0 rgba(var(--red-rgb),.40); }
  70% { box-shadow: 0 0 0 12px rgba(var(--red-rgb),0); }
  100%{ box-shadow: none; }
}
.scan-flash-ok  { animation: scanPulseOk .6s ease; }
.scan-flash-err { animation: scanPulseErr .6s ease; }

/* ---------- Desktop office (≥768px) overrides ---------- */
@media (min-width: 768px) {
  /* Sidebar: slightly wider + better hierarchy */
  .sidebar { width: 260px; flex: 0 0 260px; }
  .side-link { font-size: 14px; padding: 10px 12px; }
  .side-link.active { font-weight: 700; }

  /* Scanner compact on desktop (not primary workflow) */
  .scanner { max-width: 320px; margin: 0 auto 12px; }
  .reader  { max-width: 260px; }

  /* Table row hover on desktop */
  .data-table tbody tr { transition: background var(--ease); }
  .data-table tbody tr:hover { background: rgba(var(--accent-rgb),.04); }
  .data-table th, .data-table td { padding: 12px 16px; }

  /* OdU card horizontal layout: better data density */
  .odu-card { padding: 14px 18px; }
  .odu-sub  { font-size: 13px; }
  .odu-id   { font-size: 15px; }
}

/* ---------- Large desktop / office monitor (≥1024px) ---------- */
@media (min-width: 1024px) {
  /* Wider content for office data density */
  .content { max-width: 960px; padding: 28px 40px; }

  /* Inventory: 2-column grid for quick scanning */
  .item-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .item-list li { margin-bottom: 0; }

  /* Evasione checklist: 2-column on large screens */
  .evasione-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  /* Dashboard: numeri prominenti */
  .dash-row-4 { gap: 14px; }
  .dash-mini { padding: 18px 10px; }
  .dash-mini-num { font-size: 34px; }
  .dash-mini-lbl { font-size: 11px; }

  .dash-grid-2 { gap: 16px; }
  .dash-stat { padding: 22px; }
  .dash-num  { font-size: 36px; }
  .dash-lbl  { font-size: 13px; letter-spacing: .5px; }

  /* Donut ancora più grande */
  .dash-donut { width: 150px; height: 150px; }
  .dash-chart-row { padding: 24px; gap: 32px; }
  .cat-donut-svg { width: 80px; height: 80px; }

  /* Stats grid: more prominent */
  .stats     { gap: 16px; }
  .stat      { padding: 20px 12px; }
  .stat-num  { font-size: 30px; }

  /* Info grid: always 4 columns */
  .info-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 20px; }

  /* Forms: constrained width for readability */
  .form-card { max-width: 640px; }

  /* OdU list: state & destination on one line, more info visible */
  .odu-top { gap: 10px; }
  .odu-dest { font-size: 15px; }

  /* Page headers: more spacious */
  .page-head { padding: 16px 0 28px; }
  .page-head h1 { font-size: 26px; }

  /* Dividers: more breathing room */
  .divider { margin: 24px 0 18px; font-size: 13px; }

  /* Cards: more padding */
  .card { padding: 16px; }
  .item-card { padding: 14px 18px; }
  .item-name { font-size: 16px; }

  /* Search bar: bigger */
  .search-bar input { height: 48px; font-size: 16px; }

  /* Better action buttons: not full-width on desktop */
  .action-row > .btn,
  .action-row > form {
    flex: 0 1 auto;
    min-width: auto;
  }
}

/* ---------- Extra large desktop / widescreen (≥1280px) ---------- */
@media (min-width: 1280px) {
  .content { max-width: 1100px; }

  /* Inventory: 3-column grid */
  .item-list { grid-template-columns: repeat(3, 1fr); }

  /* Dashboard shortcuts: stay 4-col, even bigger */
  .dash-shortcuts { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .shortcut-btn { padding: 20px 16px; }
  .shortcut-label { font-size: 15px; }

  /* Dashboard stats */
  .dash-mini-num { font-size: 38px; }
  .dash-num { font-size: 40px; }

  /* Evasione: 3-column checklist */
  .evasione-list { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Scroll-to-top button ---------- */
.scroll-top {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 30;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  display: none; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform var(--ease), opacity var(--ease);
}
.scroll-top svg { width: 20px; height: 20px; }
.scroll-top.visible { display: flex; }
.scroll-top:active { transform: scale(.9); }
@media (min-width: 768px) {
  .scroll-top { bottom: 28px; right: 32px; }
}

/* ---------- State rientrato + annullato ---------- */
.state-rientrato { background: rgba(var(--green-rgb),.12); color: var(--green-text); }
.state-annullato { background: rgba(var(--red-rgb),.12); color: var(--red-text); }

/* =========================================================================
   DDT list, filter chips, share buttons, compact inventory, spacing
   ========================================================================= */

/* Filter row (DDT list) */
.filter-row {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.filter-chip.active {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

/* DDT card actions (download + share) */
.doc-head { flex: 1; min-width: 0; }
.ddt-actions { display: flex; gap: 6px; flex: 0 0 auto; align-items: center; }

/* WhatsApp icon color */
.btn-whatsapp svg, .btn-whatsapp-detail svg { fill: #25d366; }

/* Better spacing between content blocks */
.card + .section-title { margin-top: 32px; }
.progress-wrap + .progress-wrap { margin-top: 12px; }
.info-card { margin-bottom: 18px; }
.table-wrap { margin-bottom: 18px; }
.search-bar { margin-bottom: 18px; }

/* Compact inventory items */
.item-card.compact { padding: 8px 12px; min-height: auto; }
.item-card.compact .item-name { font-size: 14px; }
.item-card.compact .item-meta { font-size: 12px; margin-top: 1px; }
.item-card.compact .qty-badge { min-width: 52px; padding: 5px 4px; }
.item-card.compact .qty-num { font-size: 18px; }
.item-card.compact .qty-lbl { font-size: 9px; margin-top: 2px; }
.item-card.compact .item-thumb { width: 36px; height: 36px; }

/* ---------- Booking detail / form ---------- */
.booking-status-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.inline-form {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}
.form-input-sm {
  height: 32px; font-size: 13px; padding: 4px 8px;
}
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px;
}
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); }
.detail-value { font-size: 14px; color: var(--text); }
.detail-full { grid-column: 1 / -1; }
@media (max-width: 480px) {
  .detail-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* State pills for bookings */
.state-pill.state-opzione {
  background: rgba(var(--amber-rgb), .15);
  color: var(--amber-text);
  border: 1px solid rgba(var(--amber-rgb), .3);
}
.state-pill.state-confermato {
  background: rgba(var(--green-rgb), .15);
  color: var(--green-text);
  border: 1px solid rgba(var(--green-rgb), .3);
}
.state-pill.state-annullato {
  background: rgba(var(--red-rgb), .15);
  color: var(--red-text);
  border: 1px solid rgba(var(--red-rgb), .25);
}

/* Material picker (form) */
.mat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.mat-row:last-child { border-bottom: none; }
.mat-name { flex: 1; font-size: 14px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* flex-basis fisso: senza questo, .form-input {width:100%} piu' in basso
   vinceva e la quantita' si prendeva tutta la riga, facendo collassare il
   nome della tenda a larghezza zero. */
.mat-qty { flex: 0 0 64px; width: 64px; text-align: center; }
.mat-remove { flex: 0 0 auto; font-size: 18px; line-height: 1; }
.mat-add-row { display: flex; gap: 8px; margin-top: 10px; }
.mat-add-row .form-input { flex: 1; }

/* Material list (detail view) */
.mat-list-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.mat-list-row:last-child { border-bottom: none; }
.mat-list-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mat-list-name { font-size: 14px; font-weight: 600; color: var(--text); }
.mat-list-qty { font-size: 14px; font-weight: 700; color: var(--text-2); white-space: nowrap; }

/* Calendar stat chips */
.chip-stat {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2);
}
.chip-stat.warn { color: var(--amber-text); border-color: rgba(var(--amber-rgb), .3); }
.chip-stat.ok   { color: var(--green-text); border-color: rgba(var(--green-rgb), .3); }

/* Form group (booking forms) */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-group > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-input {
  width: 100%; height: var(--tap); padding: 8px 12px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text); font-size: 14px;
  font-family: var(--font-body);
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), .15); }
textarea.form-input { min-height: 64px; resize: vertical; height: auto; }
select.form-input { cursor: pointer; }
input[type="color"].form-input { padding: 4px; cursor: pointer; }

/* Form row (two columns) */
.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Form actions */
.form-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* Btn extra-small */
.btn-xs {
  padding: 3px 10px; font-size: 11px; min-height: 26px;
}

/* ---------- Theme toggle ---------- */
.theme-switch {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  color: var(--text-2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--ease), border-color var(--ease);
  padding: 0; flex: 0 0 auto;
}
.theme-switch:hover { border-color: var(--accent); color: var(--accent); }
.theme-switch svg { width: 18px; height: 18px; }
.ts-sun { display: none; }
[data-theme="light"] .ts-moon { display: none; }
[data-theme="light"] .ts-sun { display: flex; }

/* Mobile floating toggle */
.theme-fab {
  display: flex; align-items: center; justify-content: center;
  position: fixed; top: 14px; right: 14px; z-index: 50;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-2);
  color: var(--text-2); cursor: pointer; padding: 0;
  box-shadow: var(--shadow);
  transition: color var(--ease), border-color var(--ease);
}
.theme-fab:active { transform: scale(.9); }
.theme-fab svg { width: 18px; height: 18px; }
@media (min-width: 768px) { .theme-fab { display: none; } }

/* ── Sub-tabs (Lavoro section toggle) ──────────────────────────────── */
.sub-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  padding: 4px; background: var(--bg-2); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.sub-tab {
  flex: 1; text-align: center; padding: 8px 12px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  border-radius: calc(var(--radius) - 3px);
  text-decoration: none; transition: all var(--ease);
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* ---------- Print styles ---------- */
@media print {
  .sidebar, .bottom-nav, #toast-wrap, .sheet-backdrop,
  .scroll-top, .scanner, .manual-bar, .action-row,
  .search-bar, .chips, .sticky-actions, .head-actions,
  .alert-banner, .dash-shortcuts { display: none !important; }
  body   { background: #fff; color: #111; font-size: 12pt; }
  .layout { display: block; }
  .content { max-width: 100%; padding: 0; margin: 0; }
  .card   { border: 1px solid #ccc; box-shadow: none; background: #fff; }
  .progress-fill { background: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .state-pill, .tag { border: 1px solid #999; background: transparent !important; color: #333 !important; }
  .dash-stat { border: 1px solid #ccc; background: #fff; }
  .dash-num  { color: #111 !important; }
  a { color: #111; }
  h1 { font-size: 18pt; }
  .data-table { min-width: auto; }
  .data-table th { background: #eee !important; color: #333 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ═══════════════════════════════════════════════
   FASI DEL LAVORO nella scheda prenotazione
   Le stesse tre intensità che si vedono sul calendario:
   viaggio appena accennato, montaggio e smontaggio a metà
   strada, evento pieno. Serve a leggere la barra senza legenda.
   ═══════════════════════════════════════════════ */
.fasi-elenco { display: flex; flex-wrap: wrap; gap: var(--sp-2, 8px) var(--sp-4, 16px); }
.fase-voce {
  display: inline-flex; align-items: center; gap: var(--sp-2, 8px);
  font-weight: 600;
}
.fase-voce em { font-style: normal; font-weight: 500; color: var(--text-3); }
.fase-sw {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
  border: 1px solid rgba(var(--accent-rgb), .9);
}
.fase-margine .fase-sw {
  background-image: repeating-linear-gradient(45deg,
    transparent 0 2px, rgba(var(--accent-rgb), .55) 2px 3px);
}
/* Su un campione di 12-14 pixel le tre intensita' del calendario si
   confondono: qui le distanzio di piu' per farle restare leggibili. */
/* Stesse tinte dell'anteprima e della barra: il viaggio resta giallo,
   le altre tre sono intensita' crescenti della stessa tinta. */
.fase-sw { --sw-rgb: 79, 157, 255; }
.fase-viaggio    .fase-sw { background: rgba(232, 198, 106, .55); border-color: rgba(232, 198, 106, .9); }
.fase-smontaggio .fase-sw { background: rgba(var(--sw-rgb), .22); border-color: rgba(var(--sw-rgb), .9); }
.fase-montaggio  .fase-sw { background: rgba(var(--sw-rgb), .45); border-color: rgba(var(--sw-rgb), .9); }
.fase-evento     .fase-sw { background: rgba(var(--sw-rgb), .85); border-color: rgba(var(--sw-rgb), .9); }

/* ═══════════════════════════════════════════════
   CONFERMA — le fasi si compilano in fila, nell'ordine
   in cui accadono. A destra di ogni riga il sistema scrive
   quando cade quella fase, così il conto lo vedi mentre
   digiti invece di scoprirlo dopo aver premuto Conferma.
   ═══════════════════════════════════════════════ */
.fasi-form { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.fase-riga {
  display: grid;
  grid-template-columns: 16px minmax(200px, 1fr) minmax(120px, auto);
  align-items: center; gap: var(--sp-3, 12px);
  padding: var(--sp-3, 12px) 0;
  border-bottom: 1px solid var(--border);
}
.fase-riga:last-child { border-bottom: none; }
.fase-riga .fase-sw { width: 14px; height: 14px; }
/* Griglia e non flex: cosi' i campi numerici si incolonnano invece di
   scivolare dietro a etichette di lunghezza diversa. */
.fase-campo {
  display: grid; grid-template-columns: minmax(110px, 1fr) 72px 44px;
  align-items: center; gap: var(--sp-2, 8px);
}
.fase-campo-date { grid-template-columns: minmax(110px, 1fr) auto; }
.fase-campo > span {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.fase-campo .req { color: var(--red-text); }
.fase-campo input[type="number"] {
  width: 100%; text-align: center;
  height: 40px; padding: 0 var(--sp-2, 8px);
  border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--bg-2); color: var(--text); font-size: 15px; font-weight: 600;
}
.fase-campo em { font-style: normal; font-size: 13px; color: var(--text-3); }
.fase-campo-date { align-items: flex-start; }
.fase-date { display: flex; align-items: center; gap: var(--sp-2, 8px); flex-wrap: wrap; }
.fase-date input[type="date"] {
  height: 40px; padding: 0 var(--sp-2, 8px);
  border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--bg-2); color: var(--text); font-size: 14px;
}
.fase-freccia { color: var(--text-3); }
.fase-campo input:focus, .fase-date input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .15);
}
.fase-quando { font-size: 13px; color: var(--text-3); text-align: right; }
.fase-quando-ko { color: var(--red-text); font-weight: 600; }
.fase-riga.fase-evento .fase-quando { color: var(--text-2); font-weight: 600; }

.fasi-bilancio {
  margin: var(--sp-3, 12px) 0 0;
  padding: var(--sp-3, 12px);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-2);
}
.fasi-bilancio-ko {
  background: rgba(var(--red-rgb), .10);
  border-color: rgba(var(--red-rgb), .45);
  color: var(--red-text); font-weight: 600;
}
.btn[disabled] { opacity: .45; pointer-events: none; }

@media (max-width: 640px) {
  .fase-riga { grid-template-columns: 16px 1fr; row-gap: var(--sp-1, 4px); }
  .fase-quando { grid-column: 2; text-align: left; }
}

/* Le note che chi conferma lascia a chi prepara il materiale.
   Stanno in evidenza sull'OdU: se si perdono fra le altre note
   nessuno le legge e il camion parte senza il pezzo giusto. */
.nota-magazzino {
  margin: var(--sp-3, 12px) 0;
  padding: var(--sp-3, 12px) var(--sp-4, 16px);
  border: 1px solid rgba(var(--accent-rgb), .45);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius, 12px);
  background: rgba(var(--accent-rgb), .07);
}
.nm-titolo {
  display: block; margin-bottom: var(--sp-1, 4px);
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .6px; color: var(--accent);
}
.nota-magazzino p { margin: 0; color: var(--text); white-space: pre-wrap; }

/* Barra di stato della prenotazione */
.stato-card { padding: var(--sp-4, 16px); }
.stato-riga {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4, 16px); flex-wrap: wrap;
}
.stato-attuale { display: flex; align-items: center; gap: var(--sp-3, 12px); flex-wrap: wrap; }
.stato-nota { font-size: 13px; color: var(--text-3); }
.stato-azioni { display: flex; align-items: center; gap: var(--sp-2, 8px); flex-wrap: wrap; }
.stato-azioni form { margin: 0; }
@media (max-width: 640px) {
  .stato-riga { flex-direction: column; align-items: stretch; }
  .stato-azioni { justify-content: flex-start; }
  .stato-azioni .btn { flex: 1 1 auto; }
}

/* Anteprima del blocco: com'è fatta la prenotazione vista dal calendario.
   Un quadratino per giorno, stessi colori della barra vera, così quello
   che scegli qui lo riconosci là senza doverci pensare. */
.anteprima {
  margin-top: var(--sp-4, 16px);
  padding: var(--sp-3, 12px);
  border: 1px solid var(--border); border-radius: var(--radius-sm, 8px);
  background: var(--bg-2);
}
.ant-titolo {
  display: block; margin-bottom: var(--sp-2, 8px);
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-3);
}
.ant-barra, .ant-giorni {
  display: grid; grid-template-columns: repeat(var(--ant-cols, 7), minmax(0, 1fr));
  gap: 2px;
}
.ant-cella {
  height: 26px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: var(--text);
  border: 1px solid transparent; position: relative;
}
.ant-data { font-size: 10px; color: var(--text-3); text-align: center; margin-top: 3px; }
/* Le stesse quattro tinte della barra, ma su accento invece che commessa:
   qui la commessa non c'è ancora, conta far vedere le intensità. */
/* Il blu e' la prima tinta della tavolozza commesse: uso quello invece
   dell'accento perche' l'accento e' oro e si confonderebbe con il giallo
   del viaggio, che qui deve restare l'unica cosa fuori scala. */
.anteprima { --ant-rgb: 79, 157, 255; --ant-viaggio: 232, 198, 106; }
[data-theme="light"] .anteprima { --ant-viaggio: 214, 168, 46; }
.ant-margine {
  background-image: repeating-linear-gradient(45deg,
    transparent 0 3px, rgba(var(--ant-rgb), .30) 3px 4px);
  border-color: var(--border);
}
.ant-viaggio    { background: rgba(var(--ant-viaggio), .42); }
.ant-smontaggio { background: rgba(var(--ant-rgb), .16); }
.ant-montaggio  { background: rgba(var(--ant-rgb), .30); }
.ant-evento     { background: rgba(var(--ant-rgb), .58); }
/* Sotto una certa larghezza il nome non ci sta e resta solo il colore */
.ant-stretta .ant-cella { font-size: 0; }
/* Angolo piegato sui giorni con piu' di una attivita': stesso segno che
   compare sulla barra del calendario, cosi' li riconosci subito. */
.ant-doppia::after {
  content: ''; position: absolute; top: 0; right: 0;
  border-top: 7px solid rgba(255, 255, 255, .75); border-left: 7px solid transparent;
}
[data-theme="light"] .ant-doppia::after { border-top-color: rgba(0, 0, 0, .5); }
.fasi-bilancio-nota {
  background: rgba(var(--accent-rgb), .08);
  border-color: rgba(var(--accent-rgb), .4);
  color: var(--text-2);
}
.facolt {
  font-style: normal; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-3); margin-left: var(--sp-2, 8px);
}

/* Caselle di scelta a pillola (patenti, opzioni brevi) */
.scelte { display: flex; flex-wrap: wrap; gap: var(--sp-2, 8px); }
.scelta {
  display: inline-flex; align-items: center; gap: var(--sp-2, 8px);
  padding: 8px 14px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-2); cursor: pointer; font-size: 14px;
}
.scelta:has(input:checked) {
  border-color: var(--accent); background: rgba(var(--accent-rgb), .12);
  color: var(--text); font-weight: 600;
}
.scelta input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Contatore dei lavori in attesa di autorizzazione */
.ops-conta { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4, 16px); flex-wrap: wrap; }
.ops-num { font-size: 32px; font-weight: 800; line-height: 1; color: var(--text); }
.ops-attesa { font-size: 13px; color: var(--text-3); }
.ops-vecchio { color: var(--amber-text); font-weight: 600; }

/* Avviso in dashboard: lavori fermi in attesa di autorizzazione */
.avviso-ops {
  display: flex; align-items: center; gap: var(--sp-3, 12px);
  padding: var(--sp-3, 12px) var(--sp-4, 16px); margin-bottom: var(--sp-4, 16px);
  border: 1px solid rgba(var(--amber-rgb), .45);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius, 12px);
  background: rgba(var(--amber-rgb), .08);
  text-decoration: none; color: var(--text);
}
.avviso-num { font-size: 24px; font-weight: 800; color: var(--amber-text); line-height: 1; }
.avviso-ops strong { display: block; font-size: 14px; font-weight: 600; }
.avviso-nota { font-size: 13px; color: var(--text-3); }
.avviso-freccia { margin-left: auto; font-size: 22px; color: var(--text-3); }


/* ═══════════════════════════════════════════════════════════════════
   LE SPIE
   Un pallino che si accende davvero: colore pieno piu' un alone. Serve
   perche' una cosa arancione in mezzo a una pagina d'acciaio si veda
   dall'altra parte della stanza, che e' tutto quello che chiediamo a
   un semaforo.
   ═══════════════════════════════════════════════════════════════════ */
.spia-led {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--border-2); flex-shrink: 0;
}
.spia-led.verde  { --c: var(--green-rgb); background: var(--green); box-shadow: var(--spia); }
.spia-led.ambra  { --c: var(--amber-rgb); background: var(--amber); box-shadow: var(--spia); }
.spia-led.rossa  { --c: var(--red-rgb);   background: var(--red);   box-shadow: var(--spia); }
