/* ==========================================================================
   Cassa Fiera — stylesheet centralizzato (mobile-first, no build).
   Tutto il colore/spaziatura via custom properties: cambiare qui propaga.
   ========================================================================== */
:root {
  --c-bg: #f1f5f9;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-border: #e2e8f0;
  --c-border-strong: #cbd5e1;
  --c-text: #2b2b2b;             /* grigio scuro del profilo nel logo */
  --c-muted: #5f6b62;
  --c-subtle: #9aa39c;

  /* ---- Palette derivata dall'ICONA (verde/giallo/rosso tricolore + grigio) ---- */
  --c-primary: #007830;          /* verde del cerchio (istituzionale) */
  --c-primary-hover: #006028;
  --c-primary-soft: #d7f0df;     /* verde chiarissimo per sfondi/badge */
  --c-accent: #f0a818;           /* ambra/oro dell'aereo (evidenze/sconto) */
  --c-danger: #c00000;           /* rosso del tricolore */
  --c-danger-hover: #990000;
  --c-ok: #007830;               /* verde = ok, coerente col primario */
  --c-ok-soft: #d7f0df;
  --c-warn-soft: #fdf0d2;        /* ambra chiara */
  --c-warn-text: #8a5a00;
  --c-err-soft: #fbe0e0;
  --c-err-text: #990000;
  --c-info-soft: #e6efe9;
  --c-info-text: #006028;

  --fede: #2563eb;               /* FedeModel */
  --padova: #db2777;             /* PadovaModellismo */

  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.18);

  --text-sm: 14px; --text-base: 16px; --text-lg: 19px; --text-h2: 22px; --text-h1: 28px;
  --tap: 48px;
  --gap-1: 8px; --gap-2: 14px; --gap-3: 22px; --gap-4: 32px;
  --maxw: 1240px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--c-text); background: var(--c-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--text-base); line-height: 1.5;
}
h1 { font-size: var(--text-h1); line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: var(--text-h2); line-height: 1.25; margin: 0 0 .6rem; }
h3 { font-size: var(--text-lg); margin: 0 0 .4rem; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--c-muted); }
.subtle { color: var(--c-subtle); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--c-primary); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------- Icone SVG ---------- */
.ico { display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.ico-inline { display: inline-block; vertical-align: -2px; }   /* allineata al testo */
.navlink-ico { width: 18px; height: 18px; margin-right: .5rem; vertical-align: -3px; }
.quick-ico { color: var(--c-primary); }
.quick--primary .quick-ico { color: #fff; }

/* ---------- Brand mark (logo immagine) ---------- */
.brand-mark {
  width: 34px; height: 34px; object-fit: contain; display: inline-block;
  border-radius: var(--r-sm); flex: 0 0 auto;
}
.brand-mark--lg { width: 72px; height: 72px; border-radius: var(--r-md); margin: 0 auto 1rem; display: block; }

/* ========================== AUTH (login/offline) ========================== */
.body-auth { background: linear-gradient(160deg, #007830 0%, #024d22 55%, #1c1c1c 100%); }
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  background: var(--c-surface); width: 100%; max-width: 380px; padding: 2rem 1.75rem;
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); text-align: center;
}
.auth-card h1 { margin: 0 0 .25rem; }
.auth-sub { margin: 0 0 1.5rem; font-size: var(--text-sm); }
.auth-card .field { text-align: left; }

/* ========================== TOPBAR / NAV ========================== */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--gap-2); padding: 0 1rem;
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--c-text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: var(--text-lg); }
.mainnav { display: flex; gap: 2px; margin-left: .5rem; flex: 1; overflow-x: auto; }
.navlink {
  padding: .5rem .85rem; border-radius: var(--r-sm); color: var(--c-muted);
  font-weight: 600; white-space: nowrap; min-height: var(--tap); display: inline-flex; align-items: center;
}
.navlink:hover { background: var(--c-surface-2); text-decoration: none; color: var(--c-text); }
.navlink.is-active { background: var(--c-primary-soft); color: var(--c-primary-hover); }
.topbar-user { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.user-chip { display: flex; flex-direction: column; line-height: 1.15; text-align: right; color: var(--c-text); padding: .35rem .5rem; border-radius: var(--r-sm); }
a.user-chip:hover { background: var(--c-surface-2); text-decoration: none; }
.user-name { font-weight: 600; font-size: var(--text-sm); }
.user-role { font-size: 12px; color: var(--c-subtle); }
.mainnav--desktop .navlink--logout { color: var(--c-danger); margin-left: .25rem; }
.iconbtn {
  width: var(--tap); height: var(--tap); display: grid; place-items: center;
  border-radius: var(--r-sm); color: var(--c-muted); font-size: 20px;
}
.iconbtn:hover { background: var(--c-surface-2); text-decoration: none; }

.fiera-banner {
  background: var(--c-primary-soft); color: var(--c-primary-hover);
  padding: .4rem 1rem; font-size: var(--text-sm); text-align: center;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.fiera-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c-ok); box-shadow: 0 0 0 3px rgba(4,120,87,.2); }
.fiera-banner--none { background: var(--c-warn-soft); color: var(--c-warn-text); }

/* ---------- Hamburger (solo mobile) ---------- */
.navtoggle {
  display: none;                 /* nascosto su desktop, mostrato a <=768px */
  width: var(--tap); height: var(--tap); flex: 0 0 auto;
  border: 1px solid var(--c-border); background: var(--c-surface);
  border-radius: var(--r-sm); cursor: pointer; padding: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.navtoggle-bar {
  width: 22px; height: 2.5px; background: var(--c-text); border-radius: 2px;
  transition: transform .22s ease, opacity .18s ease;
}
/* trasforma in "X" quando il menu è aperto */
body.nav-open .navtoggle-bar:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
body.nav-open .navtoggle-bar:nth-child(2) { opacity: 0; }
body.nav-open .navtoggle-bar:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Backdrop e drawer sono figli del <body> (NON dentro la topbar sticky), così
   non restano intrappolati nel suo stacking context: stanno sopra a tutto. */
.nav-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 998;
  opacity: 0; transition: opacity .2s ease;
}
body.nav-open .nav-backdrop { opacity: 1; }

/* Drawer laterale — visibile solo quando aperto (su mobile). */
.navdrawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 999;
  width: 80%; max-width: 310px;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
  background: var(--c-surface); box-shadow: var(--shadow-lg);
  padding: .75rem .75rem 1rem;
  transform: translateX(-100%); transition: transform .25s ease;
}
body.nav-open .navdrawer { transform: none; }
.navdrawer-head { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem 1rem; border-bottom: 1px solid var(--c-border); margin-bottom: .5rem; }
.navdrawer-user { font-weight: 700; }
.navdrawer .navlink {
  width: 100%; font-size: var(--text-lg); padding: .8rem 1rem;
  border-radius: var(--r-sm); color: var(--c-text);
}
.navdrawer .navlink:hover { background: var(--c-surface-2); text-decoration: none; }
.navdrawer .navlink.is-active { background: var(--c-primary-soft); color: var(--c-primary-hover); }
.navdrawer .navlink--logout { color: var(--c-danger); margin-top: auto; }

@media (max-width: 768px) {
  .navtoggle { display: flex; }
  .mainnav--desktop { display: none; }   /* su mobile usiamo il drawer */
  .brand-name { font-size: var(--text-base); }
  .user-role { display: none; }
}
@media (min-width: 769px) {
  /* su desktop il drawer e il suo toggle non esistono proprio */
  .navdrawer, .nav-backdrop, .navtoggle { display: none !important; }
}

/* ========================== LAYOUT ========================== */
.main-wrap { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.main-full { min-height: calc(100dvh - var(--topbar-h)); }
.page-head { display: flex; align-items: center; gap: var(--gap-2); flex-wrap: wrap; margin-bottom: var(--gap-3); }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }

.grid { display: grid; gap: var(--gap-3); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm);
}
.card h2, .card h3 { margin-top: 0; }
.card-pad-0 { padding: 0; overflow: hidden; }

/* KPI / stat cards */
.kpi { display: flex; flex-direction: column; gap: .25rem; }
.kpi-label { font-size: var(--text-sm); color: var(--c-muted); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi--fede { border-left: 4px solid var(--fede); }
.kpi--padova { border-left: 4px solid var(--padova); }
.kpi--total { border-left: 4px solid var(--c-primary); }

/* ========================== BUTTONS ========================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--tap); padding: 0 1.05rem; border: 1px solid var(--c-border-strong);
  background: var(--c-surface); color: var(--c-text); border-radius: var(--r-sm);
  font-size: var(--text-base); font-weight: 600; cursor: pointer; line-height: 1;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--c-surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { background: var(--c-danger-hover); border-color: var(--c-danger-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-lg { min-height: 56px; font-size: var(--text-lg); padding: 0 1.5rem; }
.btn-sm { min-height: 38px; padding: 0 .7rem; font-size: var(--text-sm); }
.btn-block { width: 100%; }

/* ========================== FORMS ========================== */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: var(--gap-2); }
.field-label { font-size: var(--text-sm); font-weight: 600; color: var(--c-muted); }
input, select, textarea {
  font: inherit; color: var(--c-text); background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm);
  padding: 0 .8rem; min-height: var(--tap); width: 100%;
}
textarea { padding: .6rem .8rem; min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft);
}
.form-row { display: flex; gap: var(--gap-2); flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 140px; margin-bottom: 0; }

.filterbar { display: flex; gap: var(--gap-2); flex-wrap: wrap; align-items: flex-end; }
.filterbar .field { margin-bottom: 0; }

/* ========================== TABLES ========================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.tbl th, .tbl td { padding: .65rem .7rem; text-align: left; border-bottom: 1px solid var(--c-border); }
.tbl th { background: var(--c-surface-2); font-weight: 700; color: var(--c-muted); position: sticky; top: 0; }
.tbl tbody tr:hover { background: var(--c-surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 2rem; text-align: center; color: var(--c-subtle); }

/* badge proprietario / stato */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; }
.badge--fede { background: #dbeafe; color: var(--fede); }
.badge--padova { background: #fce7f3; color: var(--padova); }
.badge--ok { background: var(--c-ok-soft); color: var(--c-ok); }
.badge--annull { background: var(--c-err-soft); color: var(--c-err-text); }
.badge--warn { background: var(--c-warn-soft); color: var(--c-warn-text); }
.stock-neg { color: var(--c-danger); font-weight: 700; }

/* ========================== ALERTS ========================== */
.alert { padding: .7rem 1rem; border-radius: var(--r-sm); margin-bottom: var(--gap-2); font-size: var(--text-sm); }
.alert-error { background: var(--c-err-soft); color: var(--c-err-text); }
.alert-ok { background: var(--c-ok-soft); color: var(--c-ok); }
.alert-warn { background: var(--c-warn-soft); color: var(--c-warn-text); }
.alert-info { background: var(--c-info-soft); color: var(--c-info-text); }

/* ========================== TOAST ========================== */
.toast-root { position: fixed; right: 1rem; bottom: 1rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; max-width: 90vw; }
.toast {
  background: #0f172a; color: #fff; padding: .7rem 1rem; border-radius: var(--r-sm);
  box-shadow: var(--shadow-md); opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s;
  font-size: var(--text-sm); max-width: 360px;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--ok { background: var(--c-ok); }
.toast--error { background: var(--c-danger); }
.toast--warn { background: var(--c-accent); color: #1f2937; }

/* ========================== MODAL ========================== */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 90;
  display: grid; place-items: center; padding: 1rem; opacity: 0; transition: opacity .2s;
}
.modal-back.is-in { opacity: 1; }
.modal { background: var(--c-surface); border-radius: var(--r-md); padding: 1.3rem; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); }
.modal-title { margin: 0 0 .6rem; }
.modal-body { margin-bottom: 1.1rem; color: var(--c-text); }
.modal-actions { display: flex; gap: var(--gap-2); justify-content: flex-end; }

/* ========================== CASSA ========================== */
/* La pagina cassa gestisce il proprio padding: azzera quello del main-wrap
   per non sommare due padding orizzontali (causa di sbordo su mobile). */
.body-cassa .main-wrap { padding: 0; max-width: none; }
.cassa { display: grid; grid-template-columns: 1fr 360px; gap: var(--gap-3); min-height: calc(100dvh - var(--topbar-h)); padding: 1rem; max-width: var(--maxw); margin: 0 auto; }
@media (max-width: 920px) { .cassa { grid-template-columns: 1fr; } }
.cassa-main { display: flex; flex-direction: column; gap: var(--gap-2); min-height: 0; }
.scan-box { background: var(--c-surface); border: 2px solid var(--c-primary); border-radius: var(--r-md); padding: 1rem; box-shadow: var(--shadow-sm); }
.scan-search { position: relative; }
.scan-row { display: flex; gap: var(--gap-2); align-items: stretch; }
.scan-input { font-size: 22px; min-height: 60px; font-weight: 600; letter-spacing: .5px; }

/* tendina risultati ricerca cassa */
.scan-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50;
  margin: 0; padding: 4px; list-style: none;
  background: var(--c-surface); border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto;
}
.scan-res {
  display: flex; align-items: center; gap: .6rem; justify-content: space-between;
  padding: .55rem .65rem; border-radius: var(--r-sm); cursor: pointer;
}
.scan-res:hover, .scan-res.is-active { background: var(--c-primary-soft); }
.scan-res-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scan-res-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-res-meta { font-size: 12px; color: var(--c-subtle); }
.scan-res-price { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart { flex: 1; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); overflow: hidden; display: flex; flex-direction: column; min-height: 200px; }
.cart-list { flex: 1; overflow-y: auto; }
.cart-row { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-bottom: 1px solid var(--c-border); }
.cart-row.is-new { animation: flash 1s ease; }
@keyframes flash { from { background: var(--c-primary-soft); } to { background: transparent; } }
.cart-row .desc { flex: 1; min-width: 0; }
.cart-row .desc .brand-line { font-weight: 600; }
.cart-row .desc .meta { font-size: 12px; color: var(--c-subtle); }
.qty { display: flex; align-items: center; gap: .25rem; }
.qty button { width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--c-border-strong); background: var(--c-surface); font-size: 20px; cursor: pointer; line-height: 1; }
.qty input { width: 52px; text-align: center; min-height: 38px; padding: 0; }
.cart-row .sub { width: 90px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-row .rm { color: var(--c-danger); background: none; border: none; cursor: pointer; font-size: 20px; width: 38px; height: 38px; }
.cart-empty { padding: 3rem 1rem; text-align: center; color: var(--c-subtle); }

.cassa-side { display: flex; flex-direction: column; gap: var(--gap-2); }
.totalbox { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 1.1rem; box-shadow: var(--shadow-sm); }
.total-teorico { font-size: 40px; font-weight: 800; letter-spacing: -1px; text-align: right; font-variant-numeric: tabular-nums; }
.total-label { font-size: var(--text-sm); color: var(--c-muted); }
.pay-field input { font-size: 26px; min-height: 58px; text-align: right; font-weight: 700; }
.sconto-info { font-size: var(--text-sm); color: var(--c-accent); font-weight: 700; min-height: 1.4em; text-align: right; }
.metodi { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }
.metodo {
  border: 2px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--c-surface);
  padding: .55rem .3rem; cursor: pointer; font-weight: 700; font-size: var(--text-sm); text-align: center; min-height: var(--tap);
}
.metodo.is-sel { border-color: var(--c-primary); background: var(--c-primary-soft); color: var(--c-primary-hover); }
.btn-incassa { min-height: 72px; font-size: 24px; }

/* scanner camera overlay */
.scanview { position: relative; background: #000; border-radius: var(--r-sm); overflow: hidden; aspect-ratio: 4/3; margin-top: .6rem; }
.scanview video { width: 100%; height: 100%; object-fit: cover; }
.scanview .reticle { position: absolute; inset: 18% 12%; border: 3px solid rgba(255,255,255,.8); border-radius: 8px; }
/* bottone camera mentre carica la libreria scan fallback (ZXing, BLK-002) */
#camBtn.is-loading { opacity: .6; cursor: progress; }
/* controlli camera (zoom/torcia) sovrapposti al video — solo se supportati */
.scan-ctrls { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 8px; z-index: 4; }
.scan-ctrls .scan-zoom { width: 120px; accent-color: var(--c-primary); }
.scan-ctrls .scan-torch { width: 40px; height: 40px; border-radius: 999px; border: none; font-size: 18px; line-height: 1; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; }
.scan-ctrls .scan-torch.is-on { background: var(--c-accent, #f0a818); }
/* modale "scansiona ancora" (dopo scan camera valido) — qta live + 3 azioni */
.scan-again .sa-name { font-size: 1.05rem; margin: 0 0 .8rem; }
.scan-again .sa-qty { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; }
.scan-again .sa-qty-ctrl { display: flex; align-items: center; gap: .6rem; }
.scan-again .sa-qty-ctrl .btn { min-width: 44px; min-height: 44px; font-size: 1.4rem; line-height: 1; padding: 0; }
.scan-again .sa-qval { min-width: 2ch; text-align: center; font-size: 1.3rem; font-weight: 700; }
.scan-again .sa-actions { flex-wrap: wrap; gap: .5rem; }
.scan-again .sa-actions .btn { flex: 1 1 auto; }
.scan-again .sa-actions [data-x="redo"] { flex-basis: 100%; }   /* riga propria su mobile */

/* ---------- CASSA su MOBILE (altezza fissa, scroll solo nel carrello) ---------- */
@media (max-width: 920px) {
  /* La pagina cassa NON scrolla: occupa esattamente lo schermo sotto la topbar.
     Scrolla solo la lista del carrello. INCASSA sempre visibile in basso. */
  body.body-cassa { overflow: hidden; }
  .body-cassa .main-wrap { height: auto; }
  .cassa {
    display: flex; flex-direction: column;
    height: calc(100dvh - var(--topbar-h) - var(--fiera-banner-h, 34px));
    min-height: 0; padding: .6rem; gap: var(--gap-2);
  }
  .cassa, .cassa-main, .cassa-side { min-width: 0; }

  /* scan-box e blocco pagamento: dimensione fissa (non si comprimono) */
  .cassa-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--gap-2); }
  .scan-box { flex: 0 0 auto; padding: .55rem; }
  .cassa-side { flex: 0 0 auto; gap: .5rem; }

  /* IL carrello prende tutto lo spazio rimasto e scrolla SOLO la lista */
  .cart { flex: 1 1 auto; min-height: 64px; }
  .cart-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }

  /* scan box compatto, input più piccolo, niente sbordo */
  .scan-input { font-size: 17px; min-height: 50px; letter-spacing: 0; }
  .scan-row #camBtn { min-width: 50px; padding: 0; flex: 0 0 auto; }
  /* su mobile, a schermo fisso, l'hint occupa spazio prezioso: nascondilo */
  #scanHint { display: none; }
  /* totale + pagato affiancabili per risparmiare altezza */
  .total-label { display: inline; }

  /* riga carrello: tutto su UNA riga, testo troncato, controlli mini */
  .cart-row { gap: .4rem; padding: .45rem .55rem; }
  .cart-row .desc { min-width: 0; flex: 1 1 auto; }
  .cart-row .desc .brand-line {
    font-size: 14px; line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .cart-row .desc .meta {
    font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .qty { flex: 0 0 auto; gap: 2px; }
  .qty button { width: 32px; height: 32px; font-size: 18px; }
  .qty input { width: 34px; min-height: 32px; font-size: 14px; }
  .cart-row .sub { width: auto; min-width: 62px; font-size: 14px; flex: 0 0 auto; }
  .cart-row .rm { width: 30px; height: 30px; font-size: 18px; flex: 0 0 auto; }

  /* totale e pagamento compatti per lasciare spazio al carrello */
  .totalbox { padding: .5rem .7rem; }
  /* "Totale" e la cifra sulla stessa riga */
  .cassa-side .totalbox:first-child { display: flex; align-items: baseline; justify-content: space-between; }
  .total-teorico { font-size: 26px; }
  .pay-field input { font-size: 20px; min-height: 48px; }
  .metodo { font-size: 13px; padding: .45rem .2rem; min-height: 42px; }
  .btn-incassa { min-height: 56px; font-size: 20px; }
  /* "Svuota carrello" più piccolo: non deve mangiare altezza */
  #svuotaBtn { min-height: 38px; font-size: 13px; }
  .field-label { font-size: 12px; }
}
/* schermi molto stretti: comprimi ancora un filo */
@media (max-width: 380px) {
  .qty input { width: 28px; }
  .cart-row .sub { min-width: 54px; font-size: 13px; }
  .total-teorico { font-size: 26px; }
}

/* ========================== DASHBOARD ========================== */
.dash-h { font-size: var(--text-lg); margin: var(--gap-3) 0 .6rem; }
.dash-fiera { font-size: var(--text-sm); color: var(--c-muted); }
.dash-live { margin-left: .4rem; }
.kpi-sub { font-size: var(--text-sm); color: var(--c-muted); font-weight: 600; }
.dash-note { font-size: 13px; margin: .6rem 0 0; }
.row-warn { background: var(--c-warn-soft); }

/* griglia azioni rapide */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap-2); }
.quick {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md);
  padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); cursor: pointer; color: var(--c-text);
  min-height: 96px; justify-content: center; font: inherit; width: 100%;
  transition: transform .06s, box-shadow .12s, border-color .12s;
}
.quick:hover { text-decoration: none; box-shadow: var(--shadow-md); border-color: var(--c-border-strong); }
.quick:active { transform: translateY(1px); }
.quick-ico { font-size: 26px; line-height: 1; }
.quick-lbl { font-weight: 700; font-size: var(--text-lg); }
.quick-sub { font-size: 13px; color: var(--c-muted); }
.quick--primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.quick--primary .quick-sub { color: rgba(255,255,255,.85); }
.quick--primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }

/* richieste annullo */
.req-item { padding: .5rem .1rem; border-bottom: 1px solid var(--c-border); }
.req-item:last-child { border-bottom: none; }
.req-main { display: block; font-weight: 600; }
.req-sub { display: block; font-size: 12px; color: var(--c-subtle); }

/* ========================== HEATMAP ========================== */
.heatmap { overflow-x: auto; }
.heatmap table { border-collapse: collapse; }
.heatmap th, .heatmap td { padding: 4px; text-align: center; font-size: 12px; }
.heatmap th { color: var(--c-muted); font-weight: 600; }
.heat-cell { width: 40px; height: 34px; border-radius: var(--r-sm); color: #0f172a; font-variant-numeric: tabular-nums; }

/* ========================== UTIL ========================== */
.flex { display: flex; gap: var(--gap-2); align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.mt-2 { margin-top: var(--gap-2); } .mt-3 { margin-top: var(--gap-3); }
.mb-2 { margin-bottom: var(--gap-2); } .mb-3 { margin-bottom: var(--gap-3); }
.hidden { display: none !important; }
.tag-toggle { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: var(--r-pill); overflow: hidden; }
.tag-toggle button { border: none; background: var(--c-surface); padding: .4rem .9rem; cursor: pointer; font-weight: 600; min-height: 40px; }
.tag-toggle button.is-sel { background: var(--c-primary); color: #fff; }

/* input di editing inline nelle tabelle (inventario) */
.edit-inp { min-height: 38px; padding: 0 .45rem; max-width: 120px; }
td .edit-inp { width: 100%; }
