/* PWA-cassa Contrada Crizzina — layout (Cassa 2a redesign, 2026-07-05).
   Token + font da brand/colors_and_type.css (Design Tokens v3, Gotham Rounded).
   Redesign dal mock "2a Cassa portatile": barra carrello persistente + sheet
   scontrino (la tab «Carrello» sparisce → Cassa · Report · Menu), card con
   barretta colore categoria + contatore in-cart, Report/Menu a card + badge
   pill (lo stesso linguaggio di stato del gestionale), conferma che racconta
   l'effetto fiscale. SOLO UI: la logica di emissione/scorporo/sconto in app.js
   è invariata. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

:root {
  /* Grigio secondario allineato al gestionale (quick-win Q2, 5,4:1) */
  --cassa-muted: #6E6357;
}

body {
  background: #d8d3c7;
  font-family: var(--font-sans);
  color: var(--cc-ink);
}

/* Contenitore app: colonna centrata (su desktop sembra un telefono). */
.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--cc-paper);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 40px rgba(30, 26, 22, 0.12);
}

/* ===== header oliva ===== */
header { background: var(--cc-olive); color: var(--cc-paper); padding: 12px 16px; }
.htop { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.htop img { height: 26px; width: auto; display: block; }
.hactions { display: flex; align-items: center; gap: 8px; }
.listino-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 11px; font-weight: 600; }
.listino-pill .ldot { width: 7px; height: 7px; border-radius: 50%; background: #A9C46B; }
.listino-pill.err { background: rgba(168,58,30,.30); }
.listino-pill.err .ldot { background: var(--cc-terracotta-300, #E5916F); }
.icobtn { background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 11px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icobtn svg { width: 20px; height: 20px; }
.searchwrap { display: none; margin-top: 10px; }
.searchwrap.on { display: block; }
.search { width: 100%; background: rgba(255,255,255,.16); border: none; color: #fff; border-radius: 11px; padding: 11px 12px; font-size: 15px; font-family: var(--font-sans); }
.search::placeholder { color: rgba(255,255,255,.7); }

/* banner stato listino (offline / vuoto) */
.banner { padding: 9px 14px; font-size: 12.5px; text-align: center; background: var(--cc-saffron); color: var(--cc-ink); }
.banner.err { background: var(--cc-terracotta-100); color: var(--cc-red-signal); }
.hidden { display: none !important; }

/* ===== viste ===== */
.view-cassa { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.view { flex: 1; min-height: 0; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view.scroll { padding: 18px 16px 22px; }        /* Report / Menu */
.view-cassa .scroll { padding: 14px 16px 18px; } /* griglia prodotti */

/* ===== Cassa: chip categorie + griglia ===== */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px; background: var(--cc-paper); border-bottom: 1px solid var(--cc-line); flex: 0 0 auto; }
.cats::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--cc-line); background: var(--cc-paper-soft); border-radius: 999px; padding: 8px 16px; font-size: 13.5px; font-weight: 500; color: var(--cassa-muted); cursor: pointer; white-space: nowrap; font-family: var(--font-sans); }
.chip.on { background: var(--cc-terracotta); color: #fff; border-color: var(--cc-terracotta); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.card { position: relative; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 14px; padding: 12px 12px 12px 16px; cursor: pointer; min-height: 104px; display: flex; flex-direction: column; box-shadow: var(--shadow-paper); overflow: hidden; text-align: left; }
.card:active { background: var(--cc-paper-deep); }
.card .cbar { position: absolute; top: 0; left: 0; bottom: 0; width: 4px; }
.card .qbadge { position: absolute; top: 9px; right: 9px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--cc-terracotta); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.card .nome { font-size: 13.5px; font-weight: 500; line-height: 1.28; color: var(--cc-ink); padding-right: 22px; }
.card .sub { font-size: 11px; color: var(--cassa-muted); margin-top: 3px; }
.card .riga2 { display: flex; justify-content: space-between; align-items: flex-end; margin-top: auto; padding-top: 10px; }
.card .prezzo { font-size: 17px; font-weight: 700; color: var(--cc-ink); }
.card .iva { font-size: 10px; color: var(--cassa-muted); background: var(--cc-paper); padding: 2px 6px; border-radius: 6px; border: 1px solid var(--cc-line); }

/* ===== barra carrello persistente (apre lo sheet) ===== */
.cartbar { flex: 0 0 auto; border-top: 1px solid var(--cc-line); background: var(--cc-paper-soft); }
.cartbar-hint { padding: 13px 18px calc(13px + env(safe-area-inset-bottom)); font-size: 12.5px; color: var(--cassa-muted); text-align: center; }
.cartbar-go { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)) 18px; border: none; background: transparent; cursor: pointer; font-family: var(--font-sans); text-align: left; }
.cb-info { display: flex; flex-direction: column; line-height: 1.15; }
.cb-count { font-size: 11px; color: var(--cassa-muted); font-weight: 600; }
.cb-tot { font-size: 24px; font-weight: 700; color: var(--cc-ink); }
.cb-cta { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 52px; padding: 0 22px; border-radius: 14px; background: var(--cc-terracotta); color: #fff; font-size: 16px; font-weight: 700; }
.cb-cta svg { width: 18px; height: 18px; }

/* ===== Report ===== */
.sec-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--cc-olive); }
.sec-label-mt { margin-top: 20px; }
.kpi-row { display: flex; gap: 12px; margin-top: 14px; }
.kpi-card { flex: 1; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 14px; padding: 16px; }
.kpi-lbl { font-size: 11px; color: var(--cassa-muted); font-weight: 600; }
.kpi-val { font-size: 27px; font-weight: 700; color: var(--cc-ink); margin-top: 2px; }
.metodo-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.metodo-row { display: flex; align-items: center; gap: 12px; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 12px; padding: 12px 14px; }
.mdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.mdot-cash { background: var(--cc-olive); }
.mdot-card { background: var(--cc-sky); }
.mdot-sumup { background: var(--cc-terracotta); }
.mname { flex: 1; font-size: 14px; }
.mval { font-weight: 700; }
.nota { font-size: 12px; color: var(--cassa-muted); margin-top: 16px; line-height: 1.5; }

/* ===== Menu ===== */
.menu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.menu-row { display: flex; align-items: center; gap: 12px; min-height: 60px; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 14px; padding: 12px 16px; }
.menu-ci { flex: 1; min-width: 0; }
.menu-nome { font-size: 14.5px; font-weight: 500; }
.menu-sub { font-size: 12px; color: var(--cassa-muted); margin-top: 1px; }
.menu-chev { width: 18px; height: 18px; color: var(--cassa-muted); flex: 0 0 auto; }

/* badge pill: stesso linguaggio di stato del gestionale */
.cc-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.cc-pill .pdot { width: 8px; height: 8px; border-radius: 50%; }
.pill-ok { background: #EBF0E0; color: #4A5C28; }
.pill-ok .pdot { background: #4A5C28; }
.pill-attesa { background: #F6EDDC; color: #7A5B1E; }
.pill-attesa .pdot { background: var(--cc-ochre); }

/* ===== tab bar (3) ===== */
.tabbar { display: flex; background: var(--cc-paper-soft); border-top: 1px solid var(--cc-line); padding-bottom: env(safe-area-inset-bottom); flex: 0 0 auto; }
.tab { flex: 1; text-align: center; padding: 9px 0 11px; font-size: 11px; color: var(--cassa-muted); cursor: pointer; font-weight: 500; border: none; background: none; font-family: var(--font-sans); }
.tab.on { color: var(--cc-terracotta); }
.tab .ico { display: flex; justify-content: center; margin-bottom: 3px; }
.tab .ico svg { width: 22px; height: 22px; }

/* ===== sheet scontrino (ex tab Carrello) ===== */
.sheet-ov { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; background: rgba(30,26,22,.5); }
.sheet-scrim { flex: 1; border: none; background: transparent; cursor: pointer; }
.sheet { background: var(--cc-paper); border-radius: 24px 24px 0 0; max-height: 88%; display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(30,26,22,.3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
.sh-spacer { width: 44px; }
.grabber { width: 42px; height: 5px; border-radius: 3px; background: var(--cc-line); }
.sh-close { width: 44px; text-align: right; border: none; background: transparent; color: var(--cassa-muted); font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font-sans); }
.sheet-title { font-size: 17px; font-weight: 700; padding: 0 20px 6px; color: var(--cc-ink); }
.sheet-list { padding: 6px 16px 2px; }
.sheet-foot { padding: 10px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--cc-line); background: var(--cc-paper); }
.sheet-tot { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.st-lbl { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cassa-muted); }
.st-val { font-size: 30px; font-weight: 700; color: var(--cc-ink); }
.payhint { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cc-olive); margin-bottom: 8px; }

/* carrello: righe (dentro lo sheet) */
.crow { background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 14px; padding: 10px 12px; margin-bottom: 9px; display: flex; align-items: center; gap: 10px; }
.crow .ci { flex: 1; min-width: 0; }
.crow .cn { font-size: 13.5px; font-weight: 500; color: var(--cc-ink); }
.crow .cp { font-size: 11.5px; color: var(--cassa-muted); margin-top: 2px; }
.crow .cp-old { text-decoration: line-through; opacity: .5; }
.stepper { display: flex; align-items: center; border: 1px solid var(--cc-line); border-radius: 11px; overflow: hidden; background: #fff; }
.stepper button { width: 40px; height: 40px; border: none; background: var(--cc-paper-deep); font-size: 20px; cursor: pointer; color: var(--cc-olive); font-family: var(--font-sans); }
.stepper span { width: 34px; text-align: center; font-size: 15px; font-weight: 700; }
.crow .imp { width: 62px; text-align: right; font-weight: 700; font-size: 14px; }
.cbtn-sc { border: none; background: none; color: var(--cc-olive); font-weight: 700; font-size: 15px; cursor: pointer; padding: 0 4px; }
.del { border: none; background: none; color: var(--cc-red-signal); cursor: pointer; padding: 0 2px; display: flex; align-items: center; }
.del svg { width: 18px; height: 18px; }
.vuoto { text-align: center; color: var(--cassa-muted); padding: 44px 20px; font-size: 14px; line-height: 1.6; }

/* opzioni scontrino */
.opts { display: flex; gap: 8px; padding: 4px 16px 8px; }
.opt { flex: 1; text-align: center; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 11px; padding: 11px 4px; font-size: 12px; font-weight: 600; color: var(--cc-olive); cursor: pointer; }

/* pagamento (dentro il sheet) */
.payrow { display: flex; gap: 9px; }
.btn { flex: 1; border: none; border-radius: 14px; height: 66px; font-size: 13px; font-weight: 700; cursor: pointer; color: #fff; font-family: var(--font-sans); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.btn svg { width: 21px; height: 21px; }
.btn.cash { background: var(--cc-olive); }
.btn.card { background: var(--cc-sky); color: var(--cc-ink); }
.btn.sumup { background: var(--cc-terracotta); }

/* ===== modale anteprima / emesso ===== */
.ov { position: absolute; inset: 0; background: rgba(30,26,22,.55); display: none; align-items: center; justify-content: center; padding: 22px; z-index: 30; }
.ov.show { display: flex; }
.modal { background: var(--cc-paper); border-radius: 20px; padding: 24px 22px; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 20px 50px rgba(30,26,22,.35); }
.modal .check { width: 58px; height: 58px; border-radius: 50%; background: var(--cc-olive); color: #fff; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; }
.modal .check.preview { background: var(--cc-saffron); }
.modal .check svg { width: 30px; height: 30px; }
.modal h3 { font-family: var(--font-sans); font-weight: 700; font-size: 18px; margin-bottom: 4px; color: var(--cc-ink); }
.modal .num { color: var(--cassa-muted); font-size: 12.5px; margin-bottom: 14px; line-height: 1.5; }
.modal .num b, .modal .num strong { color: var(--cc-ink); }
.modal .preview-note { background: var(--cc-terracotta-100); color: var(--cc-red-signal); border-radius: 12px; padding: 10px 12px; font-size: 11.5px; line-height: 1.45; margin-bottom: 14px; }
.modal .riepilogo { text-align: left; font-size: 12.5px; color: #4A4138; background: var(--cc-paper-soft); border: 1px solid var(--cc-line); border-radius: 12px; padding: 11px 13px; margin-bottom: 14px; }
.modal .riepilogo .rg { display: flex; justify-content: space-between; padding: 2px 0; }
.modal .riepilogo .rg.tot { font-weight: 700; color: var(--cc-ink); border-top: 1px solid var(--cc-line); margin-top: 4px; padding-top: 6px; }
.send { display: flex; gap: 8px; margin-bottom: 10px; }
.send button { flex: 1; border: 1px solid var(--cc-line); background: var(--cc-paper-soft); border-radius: 11px; padding: 11px 4px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--cc-olive); font-family: var(--font-sans); }
.closex { border: none; background: var(--cc-terracotta); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; border-radius: 13px; padding: 15px; width: 100%; font-family: var(--font-sans); }

/* toast */
.toast-ov { background: transparent; align-items: flex-end; padding-bottom: 92px; pointer-events: none; }
.toast { background: var(--cc-ink); color: var(--cc-paper); padding: 11px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
