/* ==========================================================================
   IdeaImpresa Mobile — Design System
   Target: smartphone e palmari 5"–6" (360–430px logici)
   Mobile-first. Tap target minimo 48px. Safe-area per notch/gesture bar.
   ========================================================================== */

/* ---------- 1. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* niente bounce / pull-to-refresh nativo: la PWA gestisce il proprio scroll */
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  /* 100dvh: tiene conto della barra URL mobile che appare/scompare */
  min-height: 100dvh;
}

/* Il testo dei contenuti deve restare selezionabile (copia codici, indirizzi…) */
.selectable, input, textarea { -webkit-user-select: text; user-select: text; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- 2. TOKEN ---------- */
:root {
  /* Brand — cambiare solo questi per il re-branding cliente */
  --primary:        #1a73e8;
  --primary-dark:   #1558b0;
  --primary-light:  #e8f0fe;
  --accent:         #00897b;

  /* Semantici */
  --success:        #1e8e3e;
  --success-bg:     #e6f4ea;
  --warning:        #e37400;
  --warning-bg:     #fef3e2;
  --danger:         #d93025;
  --danger-bg:      #fce8e6;
  --info:           #1a73e8;
  --info-bg:        #e8f0fe;

  /* Superfici */
  --bg:             #f1f3f6;
  --surface:        #ffffff;
  --surface-2:      #f8f9fa;
  --border:         #dadce0;
  --border-light:   #eceff1;

  /* Testo */
  --text:           #1f1f1f;
  --text-muted:     #5f6368;
  --text-disabled:  #9aa0a6;
  --text-on-dark:   #ffffff;

  /* Misure — dimensionate per il pollice, non per il mouse */
  --tap:            48px;   /* tap target minimo (linea guida WCAG/Material) */
  --tap-lg:         56px;   /* azioni primarie e uso con guanti */
  --header-h:       56px;
  --bottomnav-h:    60px;
  --drawer-w:       282px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      20px;

  /* Safe area (notch iPhone, gesture bar Android) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  /* Elevazioni */
  --sh-1: 0 1px 3px rgba(60,64,67,.16);
  --sh-2: 0 2px 8px rgba(60,64,67,.18);
  --sh-3: 0 6px 20px rgba(60,64,67,.24);

  /* Tipografia */
  --fs-xs:  0.6875rem;  /* 11px — label, meta */
  --fs-sm:  0.8125rem;  /* 13px — testo secondario */
  --fs-md:  0.9375rem;  /* 15px — corpo */
  --fs-lg:  1.0625rem;  /* 17px — titoli sezione */
  --fs-xl:  1.375rem;   /* 22px — numeri KPI */
  --fs-2xl: 1.75rem;    /* 28px — numeri grandi */

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Tema scuro automatico — utile per magazzini e turni notturni */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #121316;
    --surface:       #1e1f22;
    --surface-2:     #26282c;
    --border:        #35373b;
    --border-light:  #2b2d31;
    --text:          #e8eaed;
    --text-muted:    #9aa0a6;
    --text-disabled: #5f6368;
    --primary-light: #1e3a5f;
    --success-bg:    #14311f;
    --warning-bg:    #3a2a10;
    --danger-bg:     #3a1a17;
    --info-bg:       #1e3a5f;
  }
}

/* ---------- 3. UTILITY ---------- */
.hidden { display: none !important; }
.mt-md  { margin-top: 16px; }
.mb-md  { margin-bottom: 16px; }
.center { text-align: center; }
.spacer { flex: 1; }

/* ==========================================================================
   4. SCHERMATA LOGIN
   ========================================================================== */
#screen-login {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--primary) 0%, #0b3d91 100%);
  padding: calc(var(--sat) + 32px) 20px calc(var(--sab) + 24px);
}

.login-brand {
  text-align: center;
  color: #fff;
  margin: auto 0 28px;
}

.login-brand .brand-mark {
  width: 76px; height: 76px;
  margin: 0 auto 16px;
  background: rgba(255,255,255,.16);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}

.login-brand .brand-mark svg { width: 40px; height: 40px; fill: #fff; }
.login-brand h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.3px; }
.login-brand p  { font-size: var(--fs-sm); opacity: .82; margin-top: 4px; }

.login-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 20px calc(20px + var(--sab));
  box-shadow: var(--sh-3);
  margin-bottom: auto;
}

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* font-size 16px obbligatorio: sotto i 16px iOS Safari zooma al focus */
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.18);
  background: var(--surface);
}

.field-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  font-size: var(--fs-sm);
}

.field-inline label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted);
  min-height: var(--tap);   /* la checkbox deve essere colpibile col pollice */
  cursor: pointer;
}

.field-inline input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.field-inline a { color: var(--primary); text-decoration: none; padding: 12px 0; }

/* ---------- Bottoni ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap-lg);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 600;
  transition: background .15s, transform .08s, opacity .15s;
}

.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn svg { width: 20px; height: 20px; fill: currentColor; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--sh-2); }
.btn-primary:active { background: var(--primary-dark); }

.btn-ghost { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }

.btn-sm {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

/* ---------- Alert ---------- */
.alert {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  margin-top: 14px;
  line-height: 1.4;
}

.alert.show    { display: flex; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; margin-top: 1px; }

.login-meta {
  text-align: center;
  color: rgba(255,255,255,.7);
  font-size: var(--fs-xs);
  margin-top: 20px;
}

/* ==========================================================================
   5. APP SHELL
   ========================================================================== */
#screen-app { display: none; min-height: 100dvh; }

/* ---------- 5.1 Header ---------- */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--header-h) + var(--sat));
  padding: var(--sat) 4px 0;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 60;
  box-shadow: var(--sh-1);
}

.header-btn {
  width: var(--tap);
  height: var(--tap);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  position: relative;
  flex-shrink: 0;
  transition: background .15s;
}

.header-btn:active { background: rgba(255,255,255,.18); }
.header-btn svg { width: 24px; height: 24px; fill: currentColor; }

#header-title {
  flex: 1;
  font-size: var(--fs-lg);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 4px;
}

.badge-dot {
  position: absolute;
  top: 9px; right: 9px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--primary);
  border-radius: 9px;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Icona sync in rotazione durante il ciclo di sincronizzazione */
#btn-sync.attivo svg { animation: ruota 1s linear infinite; }
@keyframes ruota { to { transform: rotate(-360deg); } }

/* Badge del pulsante sync: conta le modifiche non ancora inviate */
#sync-badge { background: var(--warning); }

/* Riga di stato sincronizzazione, in cima alle viste elenco */
.sync-stato {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  padding: 0 2px 10px;
}

.sync-stato .pallino {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.sync-stato.in-sospeso .pallino { background: var(--warning); }
.sync-stato.offline    .pallino { background: var(--danger); }

/* Barra offline: compare sotto l'header quando manca la rete */
#offline-bar {
  position: fixed;
  top: calc(var(--header-h) + var(--sat));
  left: 0; right: 0;
  background: var(--warning);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  padding: 5px;
  z-index: 59;
  transform: translateY(-100%);
  transition: transform .25s var(--ease);
}

#offline-bar.show { transform: translateY(0); }

/* ---------- 5.2 Drawer laterale ---------- */
#scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}

#scrim.show { opacity: 1; pointer-events: auto; }

#drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: var(--drawer-w);
  max-width: 86vw;
  background: var(--surface);
  z-index: 100;
  transform: translateX(-102%);
  transition: transform .28s var(--ease);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-3);
  padding-left: var(--sal);
}

#drawer.open { transform: translateX(0); }

.drawer-head {
  background: var(--primary);
  color: #fff;
  padding: calc(var(--sat) + 20px) 18px 18px;
}

.drawer-head .avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  border: 2px solid rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: 12px;
}

.drawer-head .d-name  { font-size: var(--fs-md); font-weight: 600; }
.drawer-head .d-mail  { font-size: var(--fs-sm); opacity: .8; margin-top: 2px; }
.drawer-head .d-org   { font-size: var(--fs-xs); opacity: .7; margin-top: 6px; text-transform: uppercase; letter-spacing: .6px; }

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

.nav-group-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-disabled);
  padding: 14px 18px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: var(--tap);
  padding: 0 18px;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  position: relative;
  transition: background .12s;
}

.nav-link:active { background: var(--surface-2); }
.nav-link svg { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 4px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}

.drawer-foot {
  border-top: 1px solid var(--border-light);
  padding: 12px 14px calc(12px + var(--sab));
}

.drawer-version {
  font-size: var(--fs-xs);
  color: var(--text-disabled);
  text-align: center;
  margin-top: 10px;
}

/* ---------- 5.3 Contenuto ---------- */
#content {
  padding-top: calc(var(--header-h) + var(--sat));
  /* lo spazio in fondo evita che la bottom nav copra l'ultimo elemento */
  padding-bottom: calc(var(--bottomnav-h) + var(--sab) + 16px);
  padding-left: var(--sal);
  padding-right: var(--sar);
  min-height: 100dvh;
}

.view { display: none; padding: 14px 14px 0; }
.view.active { display: block; animation: viewIn .22s var(--ease); }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 5.4 Bottom navigation ---------- */
#bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottomnav-h) + var(--sab));
  padding-bottom: var(--sab);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  display: flex;
  z-index: 70;
  box-shadow: 0 -2px 10px rgba(0,0,0,.07);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--bottomnav-h);
  color: var(--text-disabled);
  font-size: 10px;
  font-weight: 600;
  position: relative;
  transition: color .15s;
}

.tab svg { width: 24px; height: 24px; fill: currentColor; }
.tab.active { color: var(--primary); }

.tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  width: 32px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

.tab-count {
  position: absolute;
  top: 6px;
  margin-left: 20px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- 5.5 FAB ---------- */
.fab {
  position: fixed;
  right: calc(16px + var(--sar));
  bottom: calc(var(--bottomnav-h) + var(--sab) + 16px);
  width: var(--tap-lg);
  height: var(--tap-lg);
  border-radius: 18px;
  background: var(--primary);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sh-3);
  z-index: 65;
  transition: transform .1s;
}

.fab.show  { display: flex; }
.fab:active { transform: scale(.92); }
.fab svg   { width: 26px; height: 26px; fill: currentColor; }

/* ==========================================================================
   6. COMPONENTI CONTENUTO
   ========================================================================== */

/* ---------- 6.1 Ricerca / scanner ---------- */
.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 6px 0 12px;
  margin-bottom: 14px;
  min-height: var(--tap);
}

.searchbar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.searchbar > svg { width: 20px; height: 20px; fill: var(--text-muted); flex-shrink: 0; }

.searchbar input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 16px;
  color: var(--text);
  min-height: var(--tap);
}

.searchbar .scan-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.searchbar .scan-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* Riquadro scansione: pensato per lettori laser dei palmari (keyboard wedge) */
.scan-panel {
  background: var(--surface);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  margin-bottom: 14px;
}

.scan-panel svg { width: 44px; height: 44px; fill: var(--primary); opacity: .8; }
.scan-panel h3  { font-size: var(--fs-md); font-weight: 600; margin: 10px 0 4px; }
.scan-panel p   { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.45; }

.scan-panel input {
  width: 100%;
  margin-top: 14px;
  min-height: var(--tap-lg);
  padding: 0 14px;
  font-size: 18px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  letter-spacing: 1px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.scan-panel input:focus { border-color: var(--primary); background: var(--surface); }

/* ---------- 6.2 KPI ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.kpi {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--sh-1);
  border-left: 3px solid var(--primary);
}

.kpi.ok   { border-left-color: var(--success); }
.kpi.warn { border-left-color: var(--warning); }
.kpi.bad  { border-left-color: var(--danger); }

.kpi-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi-value { font-size: var(--fs-xl); font-weight: 800; margin: 4px 0 2px; letter-spacing: -.5px; }
.kpi-meta  { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- 6.3 Sezioni e liste ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 10px;
}

.section-title { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.section-link  { font-size: var(--fs-sm); font-weight: 600; color: var(--primary); padding: 6px; }

/* La lista sostituisce la tabella: su 5" le tabelle non sono leggibili */
.list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--sh-1);
  overflow: hidden;
  margin-bottom: 16px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  transition: background .12s;
}

.list-row:last-child { border-bottom: none; }
.list-row:active     { background: var(--surface-2); }

.row-icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.row-icon svg { width: 22px; height: 22px; fill: currentColor; }
.row-icon.ok   { background: var(--success-bg); color: var(--success); }
.row-icon.warn { background: var(--warning-bg); color: var(--warning); }
.row-icon.bad  { background: var(--danger-bg);  color: var(--danger); }

.row-body { flex: 1; min-width: 0; }

.row-title {
  font-size: var(--fs-md);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-end {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.row-amount { font-size: var(--fs-md); font-weight: 700; white-space: nowrap; }
.row-meta   { font-size: var(--fs-xs); color: var(--text-muted); }

.row-chevron { width: 20px; height: 20px; fill: var(--text-disabled); flex-shrink: 0; }

/* ---------- 6.4 Chip di stato ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.chip-ok   { background: var(--success-bg); color: var(--success); }
.chip-warn { background: var(--warning-bg); color: var(--warning); }
.chip-bad  { background: var(--danger-bg);  color: var(--danger); }
.chip-info { background: var(--info-bg);    color: var(--info); }
.chip-gray { background: var(--surface-2);  color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- 6.5 Filtri scorrevoli ---------- */
.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin: 0 -14px 4px;
  padding-left: 14px;
  padding-right: 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filter-scroll::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 19px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  display: flex; align-items: center;
  transition: background .12s, color .12s, border-color .12s;
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- 6.6 Azioni rapide a griglia ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.quick-tile {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--sh-1);
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
  transition: transform .08s;
}

.quick-tile:active { transform: scale(.96); }

.quick-tile .qt-icon {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}

.quick-tile .qt-icon svg { width: 21px; height: 21px; fill: currentColor; }
.quick-tile.g .qt-icon { background: var(--success-bg); color: var(--success); }
.quick-tile.o .qt-icon { background: var(--warning-bg); color: var(--warning); }
.quick-tile.r .qt-icon { background: var(--danger-bg);  color: var(--danger); }

/* ---------- 6.7 Stato vuoto ---------- */
.empty {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--sh-1);
  padding: 48px 24px;
  text-align: center;
}

.empty svg { width: 54px; height: 54px; fill: var(--text-disabled); opacity: .5; }
.empty h3  { font-size: var(--fs-md); font-weight: 600; margin: 14px 0 6px; }
.empty p   { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }

/* ---------- 6.8 Card impostazioni ---------- */
.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.setting-row:last-child { border-bottom: none; }
.setting-row > svg:first-child { width: 22px; height: 22px; fill: var(--text-muted); flex-shrink: 0; }
.setting-label { flex: 1; font-size: var(--fs-md); }
.setting-value { font-size: var(--fs-sm); color: var(--text-muted); }

/* Interruttore touch-friendly */
.switch {
  position: relative;
  width: 46px; height: 26px;
  background: var(--border);
  border-radius: 13px;
  flex-shrink: 0;
  transition: background .2s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--sh-1);
  transition: transform .2s var(--ease);
}

.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

/* ---------- 6.9 Bottom sheet ---------- */
#sheet-scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
}

#sheet-scrim.show { opacity: 1; pointer-events: auto; }

#sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 120;
  transform: translateY(102%);
  transition: transform .28s var(--ease);
  padding-bottom: var(--sab);
  max-height: 82dvh;
  overflow-y: auto;
  box-shadow: var(--sh-3);
}

#sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 38px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 4px;
}

.sheet-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  padding: 10px 18px 6px;
}

.sheet-body { padding: 6px 18px 20px; }

/* ---------- 6.10 Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + var(--sab) + 18px);
  transform: translate(-50%, 24px);
  background: #303134;
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 12px 18px;
  border-radius: 24px;
  box-shadow: var(--sh-3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s var(--ease);
  max-width: 88vw;
  text-align: center;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok   { background: var(--success); }
#toast.bad  { background: var(--danger); }

/* ==========================================================================
   7. ADATTAMENTI DISPOSITIVO
   ========================================================================== */

/* Palmari compatti (es. Zebra TC21, 4.7"–5") */
@media (max-width: 360px) {
  :root { --fs-md: 0.875rem; --drawer-w: 260px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .tab { font-size: 9px; }
}

/* Schermi alti 6"+ : due colonne per i KPI restano ottimali, più respiro */
@media (min-width: 400px) {
  .view { padding: 16px 16px 0; }
}

/* Landscape su palmare: header ridotto per non mangiare lo schermo */
@media (orientation: landscape) and (max-height: 480px) {
  :root { --header-h: 48px; --bottomnav-h: 52px; }
  .kpi-row { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet / desktop: il template resta usabile, drawer fisso */
@media (min-width: 840px) {
  #drawer  { transform: translateX(0); box-shadow: none; border-right: 1px solid var(--border); }
  #scrim   { display: none; }
  #header  { left: var(--drawer-w); }
  #content { margin-left: var(--drawer-w); max-width: 720px; }
  #bottomnav, .fab { left: var(--drawer-w); }
  #drawer-toggle { display: none; }
}

/* Rispetta la preferenza di sistema per il movimento ridotto */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
