/* ═══════════════════════════════════════════════════════════════════════
   Gestionale NCC — Design System MOBILE-FIRST
   Mobile → Larger mobile → Tablet → Desktop (progressive enhancement)
   Principi: record list (MAI tabelle), bottom nav, bottom sheets,
   touch target ≥ 44px, input ≥ 16px, safe areas, MOBILE WINS.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Design tokens — palette editoriale calda (light-first) ───────────────
   Ispirazione: estetica editoriale italiana. ~85% chiaro (crema/avorio),
   terracotta e oro con moderazione, scuro caldo per testo/CTA/footer.
   ─────────────────────────────────────────────────────────────────────── */
:root {
  /* Superfici: crema → avorio → bianco (in evidenza) */
  --app-bg: #f7f3ea;            /* crema — sfondo principale */
  --surface-2: #fcfaf4;         /* avorio — sezioni, topbar, bottom nav */
  --surface-3: #f4efe3;         /* avorio profondo — hover, thumb */
  --surface: #ffffff;           /* card e superfici in evidenza */

  /* Bordi e divisori beige */
  --border: #eae2d2;
  --border-strong: #ddd2be;

  /* Testo caldo (mai neri freddi) */
  --text: #2b2924;
  --text-2: #62605d;
  --text-3: #a39d92;

  /* Scuro caldo per CTA/footer/alto contrasto */
  --primary: #25231f;
  --primary-soft: #efede7;
  --primary-hover: #3a362f;

  /* Brand: terracotta + oro caldo (moderazione) */
  --accent: #b9573f;
  --accent-strong: #a14a33;
  --accent-soft: #f6e9e2;
  --gold: #d39a45;
  --gold-soft: #f8efdc;

  /* Stati semantici caldi, armonizzati con la palette */
  --success: #5f7a4e;           /* verde oliva caldo */
  --success-soft: #edf2e4;
  --warning: #b07d2e;           /* ocra / ambra */
  --warning-soft: #f9f0db;
  --danger: #b3452f;            /* rosso mattone caldo */
  --danger-soft: #f9e7e1;
  --info: #8a6d4f;              /* bronzo caldo */
  --info-soft: #f3ecdf;

  --radius-card: 14px;
  --radius-input: 10px;
  --radius-sheet: 18px;
  --radius-chip: 999px;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 40px;

  --topbar-h: 56px;
  --bottomnav-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --fs-page: 1.375rem;      /* 22px */
  --fs-section: 1.125rem;   /* 18px */
  --fs-record: 1rem;        /* 16px */
  --fs-body: 0.9375rem;     /* 15px */
  --fs-meta: 0.8125rem;     /* 13px */

  /* Ombre calde (mai blu-fredde) */
  --shadow-card: 0 1px 2px rgba(43, 41, 36, .05), 0 1px 3px rgba(43, 41, 36, .07);
  --shadow-pop: 0 8px 24px rgba(43, 41, 36, .16);
  --ring: rgba(185, 87, 63, .18);

  /* ══ Sincronizzazione Bootstrap 5.3 → palette calda ══ */
  --bs-primary: #b9573f;
  --bs-primary-rgb: 185, 87, 63;
  --bs-primary-bg-subtle: #f6e9e2;
  --bs-primary-border-subtle: #e6cfc3;
  --bs-primary-text-emphasis: #8f3a28;
  --bs-dark: #25231f;
  --bs-dark-rgb: 37, 35, 31;
  --bs-dark-bg-subtle: #efede7;
  --bs-dark-border-subtle: #d8d2c6;
  --bs-dark-text-emphasis: #25231f;
  --bs-body-color: #2b2924;
  --bs-body-bg: #f7f3ea;
  --bs-emphasis-color: #25231f;
  --bs-secondary-color: #62605d;
  --bs-secondary-color-rgb: 98, 96, 93;
  --bs-secondary-rgb: 98, 96, 93;
  --bs-secondary-bg: #fcfaf4;
  --bs-secondary-bg-rgb: 252, 250, 244;
  --bs-tertiary-bg: #f4efe3;
  --bs-tertiary-bg-rgb: 244, 239, 227;
  --bs-border-color: #eae2d2;
  --bs-border-color-translucent: rgba(221, 210, 190, .6);
  --bs-link-color: #b9573f;
  --bs-link-color-rgb: 185, 87, 63;
  --bs-link-hover-color: #a14a33;
  --bs-link-hover-color-rgb: 161, 74, 51;
  --bs-success: #5f7a4e;
  --bs-success-rgb: 95, 122, 78;
  --bs-success-bg-subtle: #edf2e4;
  --bs-success-border-subtle: #d3dfc2;
  --bs-success-text-emphasis: #44592f;
  --bs-warning: #b07d2e;
  --bs-warning-rgb: 176, 125, 46;
  --bs-warning-bg-subtle: #f9f0db;
  --bs-warning-border-subtle: #ecdcb0;
  --bs-warning-text-emphasis: #7d5716;
  --bs-danger: #b3452f;
  --bs-danger-rgb: 179, 69, 47;
  --bs-danger-bg-subtle: #f9e7e1;
  --bs-danger-border-subtle: #ecc8bd;
  --bs-danger-text-emphasis: #8f2f1d;
  --bs-info: #8a6d4f;
  --bs-info-rgb: 138, 109, 79;
  --bs-info-bg-subtle: #f3ecdf;
  --bs-info-border-subtle: #e0d2b8;
  --bs-info-text-emphasis: #5f4a33;
  --bs-light: #fcfaf4;
  --bs-light-rgb: 252, 250, 244;
  --bs-light-bg-subtle: #fcfaf4;
  --bs-light-border-subtle: #e8e0cf;
  --bs-light-text-emphasis: #62605d;
  --bs-white: #ffffff;
  --bs-white-rgb: 255, 255, 255;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--app-bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.45;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-strong); }

button, a, [role="button"], select, input, textarea, label { -webkit-tap-highlight-color: rgba(185, 87, 63, .12); }

::selection { background: var(--gold-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 1.25rem);
}
.app-main .container-fluid { padding-left: var(--space-4); padding-right: var(--space-4); }
.app-main .container-fluid.py-4 { padding-top: var(--space-4); }

/* ── Top app bar (mobile-first, poi estesa a desktop) ──────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) calc(var(--space-3) + var(--safe-left)) 0 calc(var(--space-3) + var(--safe-left));
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.topbar__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-page);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__title small { display: block; font-size: var(--fs-meta); font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  text-decoration: none;
  transition: background-color .15s ease;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn--primary { color: var(--surface); background: var(--primary); }
.icon-btn--primary:active { background: var(--primary-hover); }
.icon-btn--accent { color: var(--surface); background: var(--accent); }
.icon-btn--accent:active { background: var(--accent-strong); }

.user-avatar {
  width: 38px; height: 38px; font-size: .9rem;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--surface); font-weight: 700;
}

/* ── Bottom navigation (mobile) ────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1040;
  display: flex;
  align-items: stretch;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  box-shadow: 0 -4px 16px rgba(43, 41, 36, .06);
}
.bottom-nav__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: calc(var(--bottomnav-h) - 4px);
  padding: 6px 2px 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: .6875rem;
  font-weight: 600;
  border: 0;
  background: none;
  position: relative;
}
.bottom-nav__item i { font-size: 1.25rem; line-height: 1; }
.bottom-nav__item:active { color: var(--accent); background: var(--accent-soft); }
.bottom-nav__item.active { color: var(--accent); }
.bottom-nav__item.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

/* ── Sticky action bar (sopra la bottom nav su mobile) ─────────────────── */
.sticky-actions {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  padding-left: calc(var(--space-4) + var(--safe-left));
  padding-right: calc(var(--space-4) + var(--safe-right));
  background: linear-gradient(to top, var(--surface-2) 82%, rgba(252, 250, 244, 0));
  border-top: 1px solid var(--border);
}
.sticky-actions .btn { min-height: 48px; }
.sticky-actions__total { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-actions__total small { display: block; font-weight: 500; font-size: var(--fs-meta); color: var(--text-2); }

/* Quando c'è una sticky CTA sopra la bottom nav, il contenuto deve liberare
   spazio per entrambe (bottom nav + barra sticky), altrimenti il fondo
   (es. il riepilogo) resta coperto dalla barra fissa. Solo < 1200px. */
@media (max-width: 1199.98px) {
  body.has-sticky-cta .app-main {
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 5.75rem);
  }
}

/* ── Page header (compatta) ────────────────────────────────────────────── */
.page-head { padding-bottom: var(--space-4); }
.page-head__title { font-size: var(--fs-page); font-weight: 700; letter-spacing: -.02em; margin-bottom: 2px; }
.page-head__sub { color: var(--text-2); font-size: var(--fs-body); margin: 0; }
.page-head__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* ── Ricerca mobile-first ──────────────────────────────────────────────── */
.search-wrap { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.search-wrap .form-control {
  min-height: 48px;
  border-radius: var(--radius-input);
  font-size: 1rem;
  padding-left: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%23a39d92' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
}
.search-wrap .form-control:focus { box-shadow: 0 0 0 3px var(--ring); border-color: var(--accent); }

/* ── Filter chips (scorrimento orizzontale NATURALE per chip) ──────────── */
.chip-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: 2px 1px var(--space-3);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 40px;
  padding: .45rem .9rem;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}
.chip:active { background: var(--surface-3); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.chip.active:active { background: var(--primary-hover); }
.chip .bi-x-lg { font-size: .7rem; }
.chip__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin: -5px -7px -5px 2px;
  border-radius: 50%;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}
.chip__clear:hover { color: inherit; }
.chip__clear:active { background: rgba(255, 255, 255, .22); }
.chip.active .chip__clear { background: rgba(255, 255, 255, .16); }

/* ── RECORD LIST: il pattern principale (niente tabelle) ───────────────── */
.record-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.record-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  transition: background-color .12s ease;
}
.record-row:last-child { border-bottom: 0; }
.record-row:active, .record-row.is-active { background: var(--surface-2); }

/* Corpo: gerarchia verticale — mai sovrapposizioni tra le righe */
.record-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 2px 0;
}

/* Riga 1: identità + badge (title si restringe, badge resta visibile) */
.record-row__title-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}
.record-row__title {
  min-width: 0;
  font-size: var(--fs-record);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  overflow-wrap: anywhere;
}
.record-row__badge { flex-shrink: 0; padding-top: 2px; }

/* Riga 2: informazioni secondarie */
.record-row__sub {
  font-size: var(--fs-meta);
  color: var(--text-2);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* Riga 2b: esecutore assegnato (Autista - Nome / Partner - Nome) */
.record-row__sub2 {
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--accent-strong);
  line-height: 1.45;
  overflow-wrap: anywhere;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: .3rem .6rem;
  align-self: flex-start;
  max-width: 100%;
}
.record-row__sub2 i { color: var(--accent); }

/* Riga 3: metadata a sinistra + metrica decisionale a destra */
.record-row__meta-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}
.record-row__meta {
  min-width: 0;
  flex: 1 1 auto;
  font-size: var(--fs-meta);
  color: var(--text-3);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.record-row__value {
  flex-shrink: 0;
  text-align: right;
  font-weight: 700;
  font-size: .9375rem;
  color: var(--text);
  white-space: nowrap;
}
.record-row__value small { display: block; font-weight: 500; font-size: var(--fs-meta); color: var(--text-3); white-space: nowrap; text-align: right; }

/* Valore con sotto-elemento (valueSub / valueDot): colonna allineata a destra */
.record-row__value--col {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.record-row__value-dot { display: inline-flex; align-items: center; line-height: 0; }

/* Chevron: centrato verticalmente, non comprime il contenuto */
.record-row__chevron {
  flex-shrink: 0;
  align-self: center;
  color: var(--text-3);
  font-size: 1rem;
  display: flex;
  align-items: center;
  padding-left: 2px;
}

/* ── RIDE-LINES: dettaglio corse espanso — SOLO righe di testo divise da
   una linea (codice corsa a sinistra, importo a destra). Nessuna card,
   nessuna lista annidata: separatori sottili e massima leggibilità. ──── */
.ride-lines {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0 var(--space-4);
}
.ride-lines__empty { padding: var(--space-4); text-align: center; font-size: var(--fs-meta); color: var(--text-3); }

.ride-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 46px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}
.ride-line:last-child { border-bottom: 0; }
.ride-line:active { opacity: .6; }

.ride-line__code { font-size: var(--fs-body); font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.ride-line__amount { flex-shrink: 0; font-size: var(--fs-body); font-weight: 700; color: var(--text); white-space: nowrap; }

/* ── SALDO: selezione corse da saldare ─────────────────────────────────── */
.settle-select-all {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-card);
}
.settle-select-all__label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  width: 100%;
}
.settle-select-all__label .form-check-input { width: 1.35em; height: 1.35em; margin: 0; flex-shrink: 0; }

.executor-row {
  display: flex;
  align-items: stretch;
}
.executor-row__check {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 52px;
  cursor: pointer;
}
.executor-row__check .form-check-input { width: 1.3em; height: 1.3em; margin: 0; cursor: pointer; }
.executor-row__check .status-dot { box-shadow: 0 0 0 2px var(--surface); }
.executor-row__main { flex: 1 1 auto; min-width: 0; }
.executor-row__main .record-row { border-bottom: 0; }

/* Riga corsa selezionabile: checkbox + codice + importo + badge saldato */
.ride-line--select { cursor: pointer; }
.ride-line--select .ride-line__code { flex: 1 1 auto; min-width: 0; padding-right: var(--space-2); }
.ride-line--select .form-check-input {
  width: 1.3em; height: 1.3em;
  margin: 0 var(--space-3) 0 0;
  flex-shrink: 0;
  cursor: pointer;
}
.ride-line__settled {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}
.ride-line__settled i { font-size: .95rem; }

/* Thumb: allineato in alto, non deforma la riga */
.record-row__thumb {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  background: var(--surface-3);
  color: var(--text-2);
  margin-top: 2px;
}

.record-row--compact { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.record-row--compact .record-row__title { font-size: .9375rem; }
/* Retro-compat: markup manuale senza title-line/meta-line (settlements) */
.record-row__body > .record-row__title { display: block; }
.record-row > .record-row__value { align-self: center; }

.record-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--text);
}
.record-card:active { background: var(--surface-2); }

/* ── Status badge ──────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .24rem .65rem;
  border-radius: var(--radius-chip);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

.status--success { background: var(--success-soft); color: var(--success); }
.status--warning { background: var(--warning-soft); color: var(--warning); }
.status--danger  { background: var(--danger-soft);  color: var(--danger); }
.status--info    { background: var(--info-soft);    color: var(--info); }
.status--neutral { background: var(--surface-2);    color: var(--text-2); }
.status--dark    { background: var(--primary);      color: var(--surface); }

/* Indicatore a pallina (Saldo): verde = da incassare, rosso = da pagare */
.status-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0;
  box-shadow: 0 0 0 2px var(--surface);
}
.status-dot--green { background: #3d9a57; }
.status-dot--red   { background: #cf4436; }

/* Badge stato saldo accanto alla pallina: verde = tutte saldate,
   ambra (warning) = solo alcune saldate */
.badge-settled,
.badge-partial {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  padding: .34rem .55rem;
  border-radius: 6px;
  white-space: nowrap;
  vertical-align: middle;
}
.badge-settled { background: var(--success-soft); color: var(--success); }
.badge-partial { background: var(--warning-soft); color: var(--warning); }
.badge-settled i, .badge-partial i { font-size: .85rem; }

/* ── Metriche: feed verticale su mobile, griglia su desktop ────────────── */
.metric-list { display: grid; grid-template-columns: 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow-card); }
.metric {
  background: var(--surface);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
}
.metric__icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  background: var(--surface-3);
  color: var(--accent);
}
.metric__label { font-size: var(--fs-meta); color: var(--text-2); font-weight: 500; }
.metric__value { font-size: 1.25rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.metric__value small { font-size: var(--fs-meta); font-weight: 600; }
.metric__delta { font-size: var(--fs-meta); font-weight: 600; }
.metric__delta--up { color: var(--success); }
.metric__delta--down { color: var(--danger); }
.metric__right { margin-left: auto; text-align: right; }

/* ── Cards / sezioni ───────────────────────────────────────────────────── */
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.app-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.app-card__header h2, .app-card__header h3, .app-card__header h4, .app-card__header .h5 { margin: 0; font-size: var(--fs-section); font-weight: 700; }
.app-card__body { padding: var(--space-4); }

.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-4); margin-bottom: var(--space-4); }
.form-section__title { font-size: var(--fs-section); font-weight: 700; margin-bottom: 2px; display: flex; align-items: center; gap: var(--space-2); }
.form-section__sub { font-size: var(--fs-meta); color: var(--text-2); margin-bottom: var(--space-4); }

/* Dettaglio: raggruppamenti informativi */
.detail-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; margin-bottom: var(--space-4); }
.detail-group__head { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--fs-section); font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.detail-group__body { padding: var(--space-3) var(--space-4); }
.detail-field { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; }
.detail-field + .detail-field { border-top: 1px dashed var(--border); }
.detail-field__label { color: var(--text-2); font-size: var(--fs-meta); flex-shrink: 0; padding-top: 1px; }
.detail-field__value { font-weight: 600; text-align: right; word-break: break-word; min-width: 0; }

/* ── Bottom sheet / Action sheet ───────────────────────────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 41, 36, .45);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1060;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  background: var(--surface);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  transform: translateY(105%);
  transition: transform .28s cubic-bezier(.32, .72, .3, 1);
  padding-bottom: var(--safe-bottom);
  box-shadow: var(--shadow-pop);
}
.sheet.show { transform: translateY(0); }
.sheet__handle { flex-shrink: 0; width: 38px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: var(--space-2) auto var(--space-1); }
.sheet__header { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 2px var(--space-4) var(--space-2); }
.sheet__title { font-size: 1.0625rem; font-weight: 700; margin: 0; }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--space-2) var(--space-4) var(--space-4); }
.sheet__body--flush { padding: var(--space-2) 0 var(--space-3); }

.sheet-actions { display: flex; flex-direction: column; }
.sheet-action {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  width: 100%;
  text-align: left;
}
.sheet-action:first-child { border-top: 0; }
.sheet-action:active { background: var(--surface-3); }
.sheet-action i { font-size: 1.15rem; color: var(--text-2); width: 24px; text-align: center; flex-shrink: 0; }
.sheet-action--danger { color: var(--danger); }
.sheet-action--danger i { color: var(--danger); }
.sheet-action__hint { margin-left: auto; font-size: var(--fs-meta); font-weight: 500; color: var(--text-3); }

.sheet-option { display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; font-size: 1rem; color: var(--text); font-weight: 500; }
.sheet-option:last-child { border-bottom: 0; }
.sheet-option .form-check-input { width: 1.25em; height: 1.25em; margin: 0; }

/* ── Pagination mobile-friendly ────────────────────────────────────────── */
.pagination-wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) 0 var(--space-2); }
.pagination-wrap .btn { min-height: 44px; }
.pagination-info { font-size: var(--fs-meta); color: var(--text-2); white-space: nowrap; }

/* ── CTA sticky dentro i bottom sheet ──────────────────────────────────── */
.sticky-sheet-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: calc(-1 * var(--space-4) + var(--safe-bottom));
  background: var(--surface);
}
.sticky-sheet-actions .btn { min-height: 48px; }

/* Chevron espandibile nelle record-row (accordion) */
.record-row__chevron i { transition: transform .2s ease; }
.record-row[aria-expanded="true"] .record-row__chevron i.bi-chevron-down { transform: rotate(180deg); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  padding: 2.5rem var(--space-5);
  color: var(--text-2);
}
.empty-state__icon {
  width: 60px; height: 60px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  color: var(--text-3);
  margin-bottom: var(--space-1);
}
.empty-state__title { font-size: 1.0625rem; font-weight: 700; color: var(--text); }
.empty-state__text { font-size: var(--fs-meta); max-width: 34ch; margin: 0; }

/* ── Skeleton ──────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, #f7f2e7 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Forms mobile-first ────────────────────────────────────────────────── */
.form-control, .form-select {
  min-height: 48px;
  font-size: 1rem;
  border-radius: var(--radius-input);
  border-color: var(--border-strong);
  padding: .65rem .8rem;
  color: var(--text);
  background-color: var(--surface);
}
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.form-control::placeholder { color: var(--text-3); }
.form-label { font-size: .875rem; font-weight: 600; color: var(--text); margin-bottom: .375rem; }
.form-text { font-size: var(--fs-meta); color: var(--text-2); }
.form-check-input { width: 1.25em; height: 1.25em; margin-top: .1em; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

.btn { border-radius: var(--radius-input); font-weight: 600; }
.btn-lg { min-height: 52px; font-size: 1rem; }
.btn-sm { min-height: 38px; }
.btn:active { transform: scale(.98); }
.btn-dark { background: var(--primary); border-color: var(--primary); color: var(--surface); }
.btn-dark:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--surface); }
.btn-dark:disabled { background: var(--primary); border-color: var(--primary); opacity: .55; }
.btn-outline-dark { color: var(--primary); border-color: var(--border-strong); }
.btn-outline-dark:hover { background: var(--surface-3); color: var(--primary); border-color: var(--border-strong); }

.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn-accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--surface); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--surface); }
.btn-gold:hover { background: #b9842f; border-color: #b9842f; color: var(--surface); }

.input-group .form-control { min-height: 48px; }
.input-group .btn { min-height: 48px; }

/* ── Modali: full-screen su mobile ─────────────────────────────────────── */
@media (max-width: 575.98px) {
  .modal-dialog { margin: 0; min-height: 100vh; }
  .modal-dialog .modal-content { border: 0; border-radius: 0; min-height: 100vh; }
  .modal-dialog.modal-dialog-centered { align-items: stretch; display: flex; }
  .modal-footer { padding-bottom: calc(.75rem + var(--safe-bottom)); }
}

/* Tutti i modali: sfondo bianco pieno + bordo scuro sottile.
   Bootstrap di default usa --bs-body-bg (crema) e bordo beige chiaro,
   che sul backdrop scuro appare come un alone bianco intorno al dialog. */
.modal .modal-content {
  background-color: var(--surface) !important;
  border: 1px solid rgba(43, 41, 36, .12) !important;
}

/* Su mobile i modali a schermo intero (es. Modifica servizio) NON devono
   avere bordo: il bordo sottile va bene solo sui dialog compatti centrati. */
@media (max-width: 575.98px) {
  .modal .modal-content { border: 0 !important; }
}

/* Modal di conferma (Elimina / Annulla assegnazione): dialog compatto
   centrato — si adatta alle dimensioni mobile, niente full-screen */
@media (max-width: 575.98px) {
  .modal#modalDeleteService.show,
  .modal#modalClearAssignment.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
  }
  .modal#modalDeleteService .modal-dialog,
  .modal#modalClearAssignment .modal-dialog {
    margin: 0 auto !important;
    min-height: 0 !important;
    width: 100%;
    max-width: 380px;
    display: block;
  }
        .modal#modalDeleteService .modal-content,
  .modal#modalClearAssignment .modal-content {
    border: 1px solid rgba(43, 41, 36, .12) !important;
    border-radius: var(--radius-card);
    min-height: 0 !important;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
  }
  .modal#modalDeleteService .modal-body,
  .modal#modalClearAssignment .modal-body { padding: var(--space-4); }
  .modal#modalDeleteService .modal-footer,
  .modal#modalClearAssignment .modal-footer { gap: var(--space-2); }
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
  background:
    radial-gradient(1100px 500px at 85% -10%, var(--gold-soft) 0%, rgba(248, 239, 220, 0) 55%),
    radial-gradient(900px 480px at -10% 110%, var(--accent-soft) 0%, rgba(246, 233, 226, 0) 50%),
    var(--app-bg);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: var(--space-6) var(--space-5);
}
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.login-card h1::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--accent);
  display: inline-block;
}

/* ── Calendario ────────────────────────────────────────────────────────── */
.booking-calendar { width: 100%; min-width: 0; }
.calendar-nav-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.calendar-months { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.calendar-month { min-width: 0; }
.calendar-month-title { margin: 0 0 10px; text-align: center; font-size: .9rem; font-weight: 700; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calendar-weekdays { margin-bottom: 5px; color: var(--text-2); font-size: .75rem; text-align: center; }
.calendar-weekdays span { display: flex; align-items: center; justify-content: center; min-height: 28px; }
.calendar-day {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1;
  border-radius: 50%;
  color: var(--text);
  font-size: .8rem;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease;
}
.calendar-day:hover { background: var(--surface-3); }
.calendar-day.bg-dark:hover { background: var(--primary) !important; color: var(--surface); }
.calendar-day.text-secondary { opacity: .45; }
.calendar-event-dot { position: absolute; bottom: 12%; left: 50%; width: 5px; height: 5px; border-radius: 50%; transform: translateX(-50%); background: var(--accent); }

/* ── Voucher ───────────────────────────────────────────────────────────── */
.voucher-card { max-width: 900px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; }

/* ── Alert ─────────────────────────────────────────────────────────────── */
.alert { border-radius: var(--radius-input); font-size: var(--fs-body); }

/* ── Utility ───────────────────────────────────────────────────────────── */
.tap-target { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.avatar-preview { width: 72px; height: 72px; }
.thumb-56 { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.clickable-row { cursor: pointer; }
.service-list-item { margin-left: 0; margin-right: 0; transition: background-color .15s ease; }
.service-list-item:hover, .service-list-item:focus { background: var(--surface-2); outline: 0; }
.min-width-0 { min-width: 0; }

/* ── Right panel mobile: sidebar 95% (offcanvas-end) ──────────────────── */
#rightPanel.offcanvas-end {
  width: 95vw !important;
  max-width: 95vw;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}
/* Bootstrap (navbar-expand .offcanvas .offcanvas-body) forza display:flex
   sull'offcanvas-body: il pannello laterale deve restare un blocco normale,
   con i figli (calendario ecc.) in colonna a larghezza piena. */
#rightPanel .offcanvas-body { display: block !important; }
#rightPanel .offcanvas-header { border-bottom: 1px solid var(--border); }

/* ── Offcanvas calendario (pulsante icona accanto a "Oggi") ───────────── */
#calendarOffcanvas {
  --bs-offcanvas-width: min(480px, 95vw);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}
#calendarOffcanvas.bg-white { background-color: var(--surface-2) !important; }
#calendarOffcanvas .offcanvas-header { border-bottom: 1px solid var(--border); }
#calendarOffcanvas .offcanvas-body { display: block !important; }
/* Nell'offcanvas i mesi restano impilati (1 sopra, 1 sotto) come su desktop,
   anche su viewport mobili dove di default sarebbero affiancati. */
#calendarOffcanvas .calendar-months { grid-template-columns: minmax(0, 1fr) !important; }

/* ── Offcanvas Modifica servizio (95% larghezza, apribile ovunque) ─────── */
#editServiceOffcanvas {
  --bs-offcanvas-width: min(95vw, 95%);
  width: 95% !important;
  max-width: 95%;
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
}
#editServiceOffcanvas .offcanvas-header { border-bottom: 1px solid var(--border); }
#editServiceOffcanvas .offcanvas-body { display: block !important; }
.icon-btn--light { color: var(--surface); }
.icon-btn--light:active { background: rgba(255, 255, 255, .15); }

/* ═══════════════════════════════════════════════════════════════════════
   PROGRESSIVE ENHANCEMENT — Larger mobile / tablet / desktop
   ═══════════════════════════════════════════════════════════════════════ */

/* Chrome desktop: navbar, sidebar e footer in avorio caldo (mai bianco dominante) */
header.navbar.bg-white,
#desktopSidebar.bg-white { background-color: var(--surface-2) !important; }
header.navbar { border-bottom-color: var(--border) !important; }
#desktopSidebar { border-right-color: var(--border) !important; }

/* Footer scuro caldo (editoriale) */
.app-footer { background: var(--primary); color: #cfc8ba; border-top: 1px solid var(--primary); }
.app-footer a { color: var(--gold); text-decoration: none; }
.app-footer a:hover { color: #e3b25e; }
.app-footer .small { color: #cfc8ba; }

/* Pannello laterale: avorio caldo */
#rightPanel.bg-white { background-color: var(--surface-2) !important; }
#rightPanel .offcanvas-header { border-bottom: 1px solid var(--border); }

/* Scrollbar calda (WebKit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--surface-2); }
::-webkit-scrollbar-thumb:hover { background: #c9bda2; }

/* Dropdown caldo (sfondo bianco, voce: nome a sinistra / telefono a destra) */
.dropdown-menu {
  border-color: var(--border);
  box-shadow: var(--shadow-card);
  background: var(--surface);
}
.dropdown-menu .dropdown-item {
  padding: var(--space-2) var(--space-3);
  gap: var(--space-3);
}
.dropdown-item:hover { background: var(--surface-3); color: var(--text); }
.dropdown-item:active { background: var(--accent); color: var(--surface); }
.dropdown-divider { border-color: var(--border); }

/* Alert caldi */
.alert { border-color: var(--border); background: var(--surface-2); color: var(--text); }

/* Badge bootstrap allineato */
.badge { border-radius: 6px; }

@media (min-width: 576px) {
  .metric-list { grid-template-columns: repeat(2, 1fr); gap: 1px; }
  .metric { min-height: 72px; }
  .page-head { padding-bottom: var(--space-5); }
}

@media (min-width: 768px) {
  .app-main .container-fluid { padding-left: 1.5rem; padding-right: 1.5rem; }
  .metric-list { grid-template-columns: repeat(4, 1fr); }
  .metric__value { font-size: 1.375rem; }
  .form-section { padding: var(--space-5); }
  .record-row { min-height: 64px; padding: var(--space-3) var(--space-5); }
  .modal-dialog { margin: 1.75rem auto; }
  .modal-dialog .modal-content { min-height: 0; border-radius: var(--radius-card); border: 1px solid var(--border); }
  .modal-dialog.modal-dialog-centered { align-items: center; display: flex; }
  .calendar-months { grid-template-columns: 1fr; }
}

@media (min-width: 992px) {
  .topbar { padding-left: calc(1rem + var(--safe-left)); padding-right: calc(1rem + var(--safe-right)); }
}

@media (min-width: 1200px) {
  .app-main { padding-bottom: 1.25rem; }
  .app-main .container-fluid { padding-left: 2rem; padding-right: 2rem; }
  .bottom-nav { display: none; }
  .sticky-actions { bottom: 0; }
  .navbar { min-height: 60px; }

  .record-row--grid { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(110px, 1fr) minmax(120px, 1fr) minmax(130px, 1fr) auto; align-items: center; column-gap: var(--space-4); }
  .record-row--grid .record-row__body { min-width: 0; }
  .record-row--grid .record-row__meta-line .record-row__value { text-align: right; }
  .record-row--grid .record-row__chevron { justify-self: end; }

  .record-row--grid-5 { grid-template-columns: minmax(220px, 2fr) minmax(130px, 1fr) minmax(110px, 1fr) minmax(140px, 1fr) auto; }
  .record-row--grid-6 { grid-template-columns: minmax(180px, 2fr) minmax(120px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr) minmax(120px, 1fr) auto; }
}

/* ── Sidebar desktop (layout esteso) ───────────────────────────────────── */
:root { --sb-width: 240px; }
.offcanvas-lg { --bs-offcanvas-width: var(--sb-width); }
@media (min-width: 992px) {
  .offcanvas-lg { position: relative !important; transform: none !important; visibility: visible !important; flex-shrink: 0; width: var(--sb-width) !important; border-right: 1px solid var(--border); background: var(--surface-2) !important; box-shadow: none !important; }
  .offcanvas-lg .offcanvas-header { display: none; }
  .offcanvas-lg .offcanvas-body { overflow-y: auto !important; }
  .offcanvas-backdrop { display: none !important; }
}

.sb-link { border-radius: 10px !important; transition: all .15s; color: var(--text); text-decoration: none; }
.sb-link:hover { background: var(--surface-3); color: var(--text); }
.sidebar-dropdown { border-radius: 10px !important; cursor: pointer; }
.sidebar-dropdown .bi-chevron-down { transition: transform .2s; }
.sidebar-dropdown[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* ── Right panel inline (≥768px) ───────────────────────────────────────── */
#rightPanel { min-width: 0; --bs-offcanvas-width: 95vw; }
@media (min-width: 768px) {
  #rightPanel.offcanvas-md {
    position: relative !important;
    transform: none !important;
    visibility: visible !important;
    flex-shrink: 0;
    width: 41.66666667% !important;
    border-left: 1px solid var(--border) !important;
    border-top: 0 !important;
    background: var(--surface-2) !important;
    box-shadow: none !important;
  }
  #rightPanel.offcanvas-md .offcanvas-header { display: none !important; }
  #rightPanel.offcanvas-md .offcanvas-body { overflow: visible !important; }
}


