/* ═══════════════════════════════════════════════════════════════════════
   DESIGN_SCOPE: CRM_UI_ONLY
   This is the authoritative product UI system for the browser-based CRM.
   Never import or imitate PDF/PPTX/report styling here. The Lab26 website-
   aligned editorial system is restricted to exported reports/documents.

   REDESIGN — blank canvas (wipe 2026-07-10, ripartenza da shadcn reale).
   Riferimento visivo: shadcn-dashboard-ref/dashboard-app (preset
   b2Bnxu2cq, font Work Sans) — leggere sempre il codice sorgente reale
   lì dentro (components/ui/*.tsx) prima di scrivere qualunque regola
   qui. Nessuna dichiarazione qui deve provenire dal vecchio style.css.
   Caricato DOPO style.css.
   ═══════════════════════════════════════════════════════════════════════ */

/* shadcn reale assume sempre il default browser (16px), mai un root
   font-size custom — il vecchio style.css impone html{font-size:15px},
   che rimpicciolisce silenziosamente ogni misura in rem del 6.7%. */
html { font-size: 16px; }

/* Font unico: Work Sans ovunque (caricato in base.html). */
body, h1, h2, h3, h4, h5, h6 {
  font-family: 'Work Sans', sans-serif;
}
/* button/input/select/textarea NON ereditano il font-family del body per
   default nei browser (usano il font di sistema — su macOS legge come
   Arial/Helvetica) — bug classico, causa reale del font sbagliato su
   bottoni/select/tab segnalato esplicitamente. */
button, input, select, textarea {
  font-family: inherit;
}

/* Segnale affidabile per intercettare l'autofill WebKit/Chromium. Il listener
   globale in base.html ripristina il valore reale del CRM. La login è esclusa
   perché non riceve data-autofill-guard. */
@keyframes crm-autofill-detected { from { opacity: .999; } to { opacity: 1; } }
[data-autofill-guard]:-webkit-autofill {
  animation-name: crm-autofill-detected;
  animation-duration: .01s;
  animation-iteration-count: 1;
}

:root {
  /* Scala radius reale (letta da app/globals.css nel progetto Next.js di
     riferimento, blocco @theme inline) — il vecchio style.css aveva una
     formula sottrattiva inventata e nessun --radius-md. */
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);
  --radius-2xl: calc(var(--radius) * 1.8);
  --radius-4xl: calc(var(--radius) * 2.6);

  --sidebar-width: 16rem;      /* 256px — reale SIDEBAR_WIDTH */
  --sidebar-width-icon: 3rem;  /* 48px  — reale SIDEBAR_WIDTH_ICON */

  /* Topbar: non è un componente shadcn a sé (non esiste "Topbar" in
     shadcn/ui) — composizione osservata negli esempi dashboard block
     ufficiali. Altezza coerente con h-14 (56px). */
  --navbar-height: 3.5rem;
  /* Gap unico usato ovunque: stacco dai bordi del viewport E fra
     navbar/sidebar/area operativa — deve essere lo stesso valore in
     tutti i casi per una geometria coerente (regola esplicita: "spacing
     dai bordi e fra l'un l'altro identici"). */
  --content-gap: 1rem; /* 16px */

  /* Gerarchia globale dei layer. I numeri locali non devono decidere se
     un modal finisca accidentalmente sotto navbar/sidebar:
     screen < chrome < modal < modal secondario < popover del modal. */
  --layer-screen: 100;
  --layer-mobile-scrim: 350;
  --layer-sidebar: 400;
  --layer-navbar: 500;
  --layer-dropdown-backdrop: 590;
  --layer-dropdown: 600;
  --layer-modal-root: 2000;
  --layer-modal: 1000;
  --layer-modal-content: 1010;
  --layer-modal-secondary: 1100;
  --layer-modal-popover: 1200;
  --layer-toast: 3000;
  --layer-critical: 4000;

  /* Larghezza sidebar collassata in variante floating: icon-width + due
     volte il gap (padding sx/dx del contenitore) + 2px — formula reale
     da sidebar.tsx (lì è spacing(4)=1rem fisso perché usa il vero p-2;
     qui il padding non è più p-2 ma --content-gap, quindi la formula usa
     2*--content-gap per restare corretta anche se il gap cambia). */
  --sidebar-width-icon-floating: calc(var(--sidebar-width-icon) + 2 * var(--content-gap) + 2px);

  /* Ombra condivisa da navbar/sidebar-inner/area operativa: ring 1px +
     shadow-xs reale (0 1px 2px, opacità .05) — NON lo shadow-sm (due
     layer, opacità .1) che sidebar.tsx usa per la variante floating:
     provato, risultava troppo marcato specialmente in dark mode contro
     uno sfondo quasi nero. shadow-xs è il riferimento corretto per
     Card, che è la vera fonte per pannelli come questi. */
  --panel-shadow: 0 0 0 1px var(--border), 0 1px 2px 0 rgba(0,0,0,.05);

  /* Ombra di CONTENUTO — card/bottoni/input/hero (distinta da
     --panel-shadow, che è solo per il chrome navbar/sidebar/area
     operativa). Regola fissata dopo un tuning esplicito richiesto
     dall'utente ("un po' di shadow" → "un po' di più" → "un po' di
     più" ancora): partita da shadow-xs reale (0 1px 2px, opacità .05),
     alzata di due step fino a 0 1px 3px, opacità .12. Preferenza salvata
     come regola permanente — usare SEMPRE questo valore per qualunque
     nuovo componente con shadow di contenuto, non un valore diverso "a
     occhio". */
  --content-shadow: 0 1px 3px 0 rgba(0,0,0,.12);
}
/* Il ring "0 0 0 1px" senza blur è geometricamente identico a quello
   reale (ring-foreground/10), ma un bordo a spigolo vivo senza sfumatura
   legge sempre più "acceso" a schermo di quanto suggerisca il solo
   valore di opacità — specialmente su angoli molto arrotondati
   (--radius-xl) dove il ring curva con l'anti-aliasing del browser.
   Segnalato esplicitamente come troppo marcato in dark mode: qui si
   dimezza l'opacità reale solo per il dark mode (dal 10% reale al 5%),
   pur restando la stessa tecnica (ring via box-shadow, mai border). */
body.dark-mode {
  --panel-shadow: 0 0 0 1px color-mix(in oklch, var(--border) 50%, transparent),
                  0 1px 2px 0 rgba(0,0,0,.05);
}

/* Sfondo di pagina: i tre token (--background/--card/--muted) NON hanno
   la stessa relazione di luminosità nelle due modalità, quindi non può
   essere lo stesso token ovunque:
   - Light: --muted (0.97) è più SCURO di --card/--background (1.0) →
     pagina grigio chiaro, pannelli bianchi che risaltano sopra. Corretto.
   - Dark: --muted (0.269) è il PIÙ CHIARO dei tre token (più chiaro
     anche di --card, 0.205) → usarlo per la pagina renderebbe i
     pannelli (--card) più SCURI della pagina, invertendo la relazione
     "elevata" (bug corretto in un giro precedente). In dark mode va
     usato --background (0.145, il più scuro) per la pagina, cosicché
     --card (0.205) resti più chiaro e quindi elevato sopra di essa. */
body:has(.sidebar) {
  background: var(--muted);
}
body.dark-mode:has(.sidebar) {
  background: var(--background);
}

/* I viewer hanno una sola destinazione: la dashboard di brand. Il loro
   shell non riserva quindi spazio a una navigazione laterale inesistente,
   ma mantiene la stessa geometria floating e lo stesso canvas fisso del
   resto del CRM. */
body.viewer-shell {
  background: var(--muted);
}
body.dark-mode.viewer-shell {
  background: var(--background);
}

/* ═══════════════════════════════════════════════════════════════════════
   TOPBAR — fixed, floating (inset di --content-gap su top/left/right,
   non flush contro il viewport), sopra sidebar E area operativa. Non
   più offset da margin-left: logo sempre in alto a sinistra del
   viewport, mai "dentro" alla colonna di contenuto.
   ═══════════════════════════════════════════════════════════════════════ */
.navbar {
  position: fixed;
  top: var(--content-gap); left: var(--content-gap); right: var(--content-gap);
  width: auto;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px 0 32px;
  gap: 12px;
  background: var(--card);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow);
  z-index: var(--layer-navbar);
}
.navbar-admin,
.navbar-client {
  margin-left: 0 !important; /* la topbar non è più offset dalla sidebar */
}

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR — letta da components/ui/sidebar.tsx (shadcn reale, appena
   riletto in shadcn-dashboard-ref). Variante: floating, collapsible=icon.
   Nel vero componente il contenitore fixed ha solo padding (p-2), il box
   visibile è un div INTERNO (data-slot="sidebar-inner") con rounded-lg +
   shadow-sm + ring-1 ring-sidebar-border. Qui: .sidebar = contenitore
   fixed (padding, trasparente), .sidebar-inner = il box floating vero e
   proprio — stesso colore/rotondità/ombra della navbar (regola di
   coerenza geometrica esplicita), non il bg-sidebar/rounded-lg reali.
   ═══════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0;
  z-index: var(--layer-sidebar);
  width: var(--sidebar-width);
  background: transparent;
  border: none;
  box-shadow: none !important; /* annulla la regola "light mode drop shadow" del vecchio sistema */
  /* Padding = --content-gap: deve essere lo STESSO valore del margine
     di .main-content, altrimenti lo stacco bordo-sinistro↔sidebar e
     sidebar↔area-operativa non sono uguali. */
  padding: var(--content-gap);
  /* Con box-sizing:border-box globale (style.css), il padding di questo
     contenitore viene SOTTRATTO dall'altezza dichiarata — quindi per far
     sì che .sidebar-inner (il box visibile, height:100% del content-box
     di questo contenitore) risulti allineato esattamente come
     .main-content (stesso top, stessa altezza), qui vanno usati UN solo
     gap in top/height, non due/tre: il gap "in più" verso la topbar e
     verso il bordo inferiore è già il padding stesso di questo
     contenitore, non va sommato di nuovo. (Bug corretto: prima usava
     2/3 gap, la sidebar-inner risultava più bassa e iniziava più in
     basso dell'area operativa.) */
  top: calc(var(--navbar-height) + var(--content-gap));
  height: calc(100vh - var(--navbar-height) - var(--content-gap));
  transition: width 0.2s ease;
}
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-icon-floating);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: var(--card);
  color: var(--sidebar-foreground);
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  flex-shrink: 0;
}

.sidebar-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: min(var(--radius-md), 10px); /* reale Button variant="ghost" size="icon-sm" */
  background: none;
  border: none;
  color: var(--sidebar-foreground);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.sidebar-trigger:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.sidebar-trigger svg { width: 16px; height: 16px; }

.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}
.sidebar-content::-webkit-scrollbar { width: 0; }

/* ── Menu (ul > li > a/button) ─────────────────────────────────────── */
.sidebar-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar-menu-item { position: relative; }

.sidebar-menu-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md); /* reale: SidebarMenuButton usa "rounded-md" */
  padding: 7px 8px;
  height: 2.25rem;
  max-height: 2.25rem; /* difensivo — vedi nota sotto */
  box-sizing: border-box;
  text-align: left;
  font-size: 1.0625rem; /* 17px — via di mezzo fra 0.875rem reale (14px) e 1.25rem provato (troppo grande) */
  font-weight: 400;
  line-height: 1.25; /* include correttamente ascendenti e discendenti (g, p, q, y) senza cambiare l'altezza della voce */
  text-transform: none;
  letter-spacing: normal;
  color: var(--sidebar-foreground);
  background: none;
  border: none;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
/* Colore icona disaccoppiato dal testo (che resta var(--sidebar-foreground))
   per far combaciare le icone sidebar con quelle della navbar
   (.navbar-icon-btn usa var(--muted-foreground) a riposo) — richiesta
   esplicita "cambia colore sidebar icons per matchare navbar icons". */
.sidebar-menu-button svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted-foreground); }
.sidebar-menu-button:hover svg { color: var(--sidebar-accent-foreground); }
/* Icona in verde primary quando il tool (o un suo subtool) è attivo —
   stesso verde di CTA/title icons in tutta la piattaforma. Richiesta
   esplicita: solo l'icona, la label resta nel colore neutro sotto. */
.sidebar-menu-button.active svg { color: var(--primary); }
.sidebar-menu-button:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.sidebar-menu-button.active {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 500;
}
/* Il vecchio style.css ha ".sidebar-group-toggle.active { color: var(--primary)
   !important; }" — il verde sui toggle ADV/CRO/Fatturazione quando il
   gruppo è aperto (nessun !important nel resto di questo file lo può
   battere per ordine di cascata). Richiesta esplicita: solo bg
   highlight come gli altri item, niente colore verde sul testo. Serve
   un altro !important per annullarlo. */
.sidebar-group-toggle.active {
  color: var(--sidebar-accent-foreground) !important;
}
.sidebar-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.sidebar-chevron { width: 16px; height: 16px; flex-shrink: 0; color: var(--sidebar-foreground); opacity: .6; transition: transform .2s ease; }
.sidebar-group.open .sidebar-group-toggle .sidebar-chevron { transform: rotate(180deg); }

.sidebar-notif-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--destructive); flex-shrink: 0;
}
/* reale SidebarMenuBadge: h-5 min-w-5 (20px/20px) rounded-md text-xs (12px) */
.sidebar-lead-badge {
  min-width: 1.25rem; height: 1.25rem; padding: 0 4px;
  background: var(--primary); color: var(--primary-foreground);
  font-size: 0.75rem; font-weight: 500; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 1;
}

/* ── Sub-menu (indentato, bordo sinistro sottile, niente sfondo pieno,
   niente icone — solo il testo, per scelta esplicita) ── */
.sidebar-menu-sub {
  overflow: hidden;
  max-height: 0;
  margin: 0 0.875rem; /* reale: mx-3.5 (14px) */
  /* Padding/bordo a ZERO finché il gruppo è chiuso — max-height:0 da
     solo non basta: il padding verticale (2px top+bottom) e il
     border-left restavano comunque renderizzati come un piccolo
     "trattino" sotto l'icona di ogni voce con dropdown, presente anche
     a gruppo chiuso. Essendo assente nelle voci semplici (senza
     dropdown), creava un'altezza incoerente fra i due tipi di voce —
     la causa reale del "pivot verticale" segnalato. */
  padding: 0 10px;
  border-left: 1px solid transparent;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: max-height .2s ease;
}
.sidebar-group.open .sidebar-menu-sub {
  max-height: 400px;
  padding: 2px 10px 2px 10px; /* reale: py-0.5 px-2.5, applicato solo a gruppo aperto */
  border-left-color: var(--sidebar-border);
}
.sidebar-menu-sub-item { position: relative; }

.sidebar-menu-sub-button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 1.75rem;
  border-radius: var(--radius-md);
  padding: 0 8px;
  font-size: 0.875rem; /* 14px — reale */
  font-weight: 300; /* ridotto di uno step (400→300) per le voci non selezionate, richiesta esplicita */
  color: var(--sidebar-foreground);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: color .15s;
}
/* Niente highlight (background) su hover/attivo, richiesta esplicita —
   la voce selezionata si distingue solo per peso (bold), non per sfondo. */
.sidebar-menu-sub-button:hover { background: none; color: var(--sidebar-accent-foreground); }
.sidebar-menu-sub-button.active {
  background: none;
  color: var(--sidebar-accent-foreground);
  font-weight: 700;
}

/* ── Stato collassato (solo icone) — le icone restano ANCORATE: mai
   ridimensionare/ricentrare i bottoni al toggle (bug corretto in un
   giro precedente, valido anche qui). L'unica differenza fra i due
   stati è la visibilità di label/chevron/badge/sotto-menu — padding,
   width, justify-content e align-items restano sempre gli stessi, così
   l'icona non si muove mai in nessuna direzione. ── */
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-chevron,
body.sidebar-collapsed .sidebar-notif-dot,
body.sidebar-collapsed .sidebar-lead-badge,
body.sidebar-collapsed .sidebar-menu-sub {
  display: none;
}

/* ── Icona sole/luna nel bottone tema ── */
.navbar-theme-btn .icon-dark { display: none; }
body.dark-mode .navbar-theme-btn .icon-light { display: none; }
body.dark-mode .navbar-theme-btn .icon-dark { display: block; }

/* ═══════════════════════════════════════════════════════════════════════
   NAVBAR — azioni utente (tema/impostazioni/profilo/notifiche/esci) in
   alto a destra. Bottoni icona ghost coerenti col reale Button
   variant="ghost" size="icon-sm" (size-8, rounded-[min(var(--radius-md),10px)]).
   ═══════════════════════════════════════════════════════════════════════ */
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.navbar-actions-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}
.navbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: min(var(--radius-md), 10px);
  background: none;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.navbar-icon-btn svg { width: 18px; height: 18px; }
.navbar-icon-btn:hover { background: var(--accent); color: var(--foreground); }
.navbar-icon-btn.active { color: var(--foreground); background: var(--accent); }
.navbar-logout:hover { color: var(--destructive); background: color-mix(in oklch, var(--destructive) 10%, transparent); }

/* ═══════════════════════════════════════════════════════════════════════
   AREA OPERATIVA — stesso colore/rotondità/ombra di navbar/sidebar-inner
   (regola di coerenza geometrica esplicita). Margine sinistro = SOLO
   larghezza sidebar (il gap verso la sidebar è già nel padding destro
   del contenitore .sidebar, sommarne un altro raddoppierebbe lo
   stacco); margine superiore = altezza topbar + due gap, stesso punto
   di partenza verticale della sidebar-inner.
   ═══════════════════════════════════════════════════════════════════════ */
body:has(.sidebar) .main-content {
  position: fixed;
  top: calc(var(--navbar-height) + 2 * var(--content-gap));
  left: var(--sidebar-width);
  right: var(--content-gap);
  bottom: var(--content-gap);
  width: auto;
  margin: 0;
  background: var(--card);
  border-radius: var(--radius-xl);
  border: none;
  box-shadow: var(--panel-shadow);
  transition: left .2s ease;
  /* Altezza FISSA (non più min-height): l'area operativa ha sempre le
     stesse dimensioni della sidebar, non cresce con la lunghezza del
     contenuto — richiesta esplicita. Il contenuto che eccede scorre
     dentro .sc-page-scroll (vedi sotto), mai l'intero .main-content. */
  height: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--layer-screen);
}

body.viewer-shell .main-content {
  position: fixed;
  top: calc(var(--navbar-height) + 2 * var(--content-gap));
  left: var(--content-gap);
  right: var(--content-gap);
  bottom: var(--content-gap);
  width: auto;
  height: auto;
  margin: 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow);
  z-index: var(--layer-screen);
}

/* Authenticated tool-only windows reuse the same page and APIs while removing
   the CRM navigation shell. The workspace becomes the viewport itself. */
body.crm-standalone { overflow: hidden; background: var(--card); }
body.crm-standalone .main-content {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: var(--layer-screen);
}

/* Un position:fixed crea uno stacking context: senza elevare questo root,
   qualunque modal renderizzato dentro .main-content resta prigioniero sotto
   navbar e sidebar anche con z-index enormi. Quando un overlay interno è
   visibile, l'intero stacking root passa sopra il chrome; il backdrop del
   modal oscura quindi correttamente TUTTO il viewport. */
body:has(.sidebar) .main-content:has(
  .sc-dialog-overlay.open,
  .ld-modal-overlay.open,
  .modal-overlay.open,
  .report-modal-overlay.open,
  .adv-modal-overlay.open,
  .rm2-overlay[style*="display: flex"],
  .rm2-overlay[style*="display:flex"],
  .modal-overlay[style*="display: flex"],
  .modal-overlay[style*="display:flex"],
  .report-modal-overlay[style*="display: flex"],
  .report-modal-overlay[style*="display:flex"]
) {
  z-index: var(--layer-modal-root);
}

body.viewer-shell .main-content:has(
  .sc-dialog-overlay.open,
  .ld-modal-overlay.open,
  .modal-overlay.open,
  .report-modal-overlay.open,
  .adv-modal-overlay.open,
  .rm2-overlay[style*="display: flex"],
  .rm2-overlay[style*="display:flex"],
  .modal-overlay[style*="display: flex"],
  .modal-overlay[style*="display:flex"],
  .report-modal-overlay[style*="display: flex"],
  .report-modal-overlay[style*="display:flex"]
) {
  z-index: var(--layer-modal-root);
}

/* ── Page shell: header/filtri/CTA/card importanti fissi in alto, SOLO
   il contenuto sotto scorre in un riquadro di altezza vincolata, con un
   micro-gradiente in fondo che sfuma l'ultima riga invece di tagliarla
   di netto quando il contenuto è più lungo dello spazio disponibile.
   Pattern site-wide, non solo ADV: ogni pagina compone .sc-page-fixed
   (tutto ciò che deve restare visibile) + .sc-page-body > .sc-page-scroll
   (+ .sc-page-fade). Niente riga separatrice — richiesta esplicita di
   interfaccia pulita, nessuna linea orizzontale superflua da nessuna
   parte: lo spacing da solo basta a distinguere fixed da scrollabile. ── */
.sc-page-fixed { flex-shrink: 0; margin-bottom: 1rem; }
.sc-page-body { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
/* overflow-y:auto rende .sc-page-scroll un clip-box su TUTTI i lati
   (non solo in verticale): qualunque box-shadow/ring di una card che
   sfiora il bordo del contenitore — sinistro/destro MA ANCHE quello
   superiore della primissima riga di card (bug reale verificato: KPI
   "Spesa/Impressioni" senza bordo in alto) — viene tagliato di netto.
   padding+margine negativo uguale e opposto su tutti i lati = gutter
   per il bleed dell'ombra, senza spostare visivamente il contenuto. */
.sc-page-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
  margin: -4px;
}
/* Le card impilate devono conservare la propria altezza naturale e far
   scorrere il contenitore. Senza questo vincolo il flexbox le comprime per
   farle stare tutte nel viewport: canvas e tabelle restano nel DOM, ma la
   card viene ridotta al solo header con overflow nascosto. */
.sc-page-scroll > * { flex-shrink: 0; }
/* Variante per una .sc-card che contiene una tabella: l'header della
   card (titolo+contatore) resta fisso, solo le righe scorrono — il
   thead sticky sopra fa il resto. La card stessa diventa il contenitore
   flex:1 dentro .sc-page-body, .adv-table-wrap è l'unico che scrolla. */
.sc-page-scroll-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sc-page-scroll-card > .sc-card-header { flex-shrink: 0; }
.sc-page-scroll-card > .adv-table-wrap { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* .sc-page-fade: SOLO per .sc-page-scroll (più card impilate, es.
   leads.html/users.html/client_detail.html) — un overlay rettangolare
   va bene lì perché sfuma lo sfondo della pagina dietro alle card, non
   la card stessa. MAI dentro .sc-page-scroll-card: quel div, essendo
   un rettangolo pieno sovrapposto, taglierebbe l'angolo arrotondato
   della card sotto (bug reale verificato: "Clienti attivi"). Per
   .sc-page-scroll-card la sfumatura usa invece una mask-image sulla
   .adv-table-wrap stessa (poco sotto), che rispetta sempre il bordo
   della card perché sta DENTRO al suo overflow:hidden. ── */
.sc-page-fade {
  /* bottom:-4px allinea il bordo del gradiente al vero bottom di
     .sc-page-scroll, che grazie a padding:4px/margin:-4px (bleed per
     lo shadow, vedi sopra) sporge di 4px oltre .sc-page-body — senza
     questo offset il gradiente finiva 4px più in alto del punto reale
     in cui il contenuto viene tagliato (bug reale verificato). */
  position: absolute; left: 0; right: 0; bottom: -4px; height: 40px;
  background: linear-gradient(to bottom, transparent, var(--card));
  pointer-events: none;
}
/* Nascosto via JS (base.html) quando .sc-page-scroll è arrivato in fondo o
   non ha overflow: altrimenti l'ultima riga resta sempre sfumata anche
   senza altro contenuto sotto. */
.sc-page-fade.sc-page-fade-hidden { opacity: 0; }
/* ── Fade top/bottom per .sc-page-scroll-card > .adv-table-wrap: mask
   sul contenuto vero (righe tabella), mai un div overlay — clippata
   dall'overflow:hidden della card, quindi non tocca mai il suo bordo
   arrotondato. Classi .fade-top/.fade-bottom aggiunte via JS (vedi
   base.html) solo quando c'è davvero altro contenuto sopra/sotto. ── */
.sc-page-scroll-card > .adv-table-wrap {
  -webkit-mask-image: none;
  mask-image: none;
  /* .adv-table-wrap ha di suo padding-bottom:1.5rem (per uso standalone
     fuori da .sc-card), ma qui la card fornisce già 1.5rem top/bottom
     (padding:1.5rem 0, stesso pattern di .set-form) — sommarli lasciava
     48px di spazio morto sotto l'ultima riga invece di 24px, la tabella
     non arrivava mai davvero in fondo alla card. */
  padding-bottom: 0;
}
.sc-page-scroll-card > .adv-table-wrap.fade-bottom:not(.fade-top) {
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}
.sc-page-scroll-card > .adv-table-wrap.fade-top:not(.fade-bottom) {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 40px);
  mask-image: linear-gradient(to bottom, transparent 0, black 40px);
}
.sc-page-scroll-card > .adv-table-wrap.fade-top.fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 40px, black calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, black 40px, black calc(100% - 40px), transparent 100%);
}
body.sidebar-collapsed:has(.sidebar) .main-content {
  left: var(--sidebar-width-icon-floating);
  /* Difesa esplicita contro le vecchie regole margin-based di style.css:
     il guscio desktop ha una sola sorgente di offset, la proprietà left. */
  margin-left: 0;
}

/* Desktop: il canvas dell'app non deve avere alcuno scroll o rubber-band.
   Navbar, sidebar e area operativa sono tre pannelli fixed; soltanto i
   contenitori interni esplicitamente scrollabili possono muoversi. */
@media (min-width: 769px) {
  html:has(.sidebar),
  body:has(.sidebar),
  html:has(body.viewer-shell),
  body.viewer-shell {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
}
/* Sotto i 768px il vecchio style.css nasconde la sidebar completamente
   fuori schermo (transform:translateX(-100%), nessuno stato "solo
   icone" su mobile — è binario: sidebar intera o niente). Riservare
   qui lo spazio di una sidebar collassata (--sidebar-width-icon-floating)
   creava un vuoto a sinistra dove la sidebar non c'è più (bug segnalato
   esplicitamente: "overflow sulla sinistra dell'area operativa").
   Stesso breakpoint del vecchio sistema (768px) e margin-left:content-gap
   (simmetrico col margine destro), non icon-floating. Il vecchio
   style.css ha ".main-content { margin-left:0 !important }" sullo stesso
   breakpoint/selettore — serve lo stesso !important per vincere, un
   valore normale verrebbe ignorato indipendentemente da specificità e
   ordine. */
@media (max-width: 768px) {

  body.crm-standalone .main-content {
    position: fixed;
    inset: 0;
    width: auto;
    height: 100dvh;
    margin: 0 !important;
    padding: 1rem;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* MOBILE APP SHELL — un solo controllo di navigazione. La sidebar è un
     drawer comandato dal burger della topbar: il trigger desktop interno
     sarebbe un secondo burger con la stessa azione e viene quindi rimosso.
     Quando il drawer è aperto, il burger diventa una X esplicita. */
  .sidebar-header { display: none; }
  .navbar-menu-close-icon { display: none; }
  body.sidebar-mobile-open .navbar-menu-open-icon { display: none; }
  body.sidebar-mobile-open .navbar-menu-close-icon { display: block; }
  body.sidebar-mobile-open .navbar-mobile-burger {
    background: var(--accent);
    box-shadow: inset 0 0 0 1px var(--border);
  }

  /* Le barre browser iOS/Android cambiano altezza durante lo scroll: dvh
     evita contenuti e footer nascosti sotto la chrome del browser. */
  body:has(.sidebar) .main-content,
  body.sidebar-collapsed:has(.sidebar) .main-content,
  body.viewer-shell .main-content {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    width: auto;
    margin-top: calc(var(--navbar-height) + 2 * var(--content-gap));
    margin-right: var(--content-gap);
    margin-bottom: var(--content-gap);
    margin-left: var(--content-gap) !important;
    height: calc(100dvh - var(--navbar-height) - 3 * var(--content-gap));
    padding: 1.25rem;
    /* Su mobile l'intera area operativa è l'unico scroll verticale. Il
       modello desktop (header fisso + body/table con scroll separati)
       produceva tre gesture target concorrenti e, con KPI/header alti,
       poteva comprimere la tabella a 0px pur avendo righe caricate. */
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar { height: calc(100dvh - var(--navbar-height) - var(--content-gap)) !important; }

  /* Appiattisce tutti gli scroll verticali annidati: header, KPI, card,
     tabelle e footer scorrono come una pagina unica. Le tabelle conservano
     soltanto lo scroll orizzontale, senza altezza artificiale o maschere. */
  .sc-page-fixed { flex: none; }
  .sc-page-body { display: block; flex: none; min-height: 0; }
  .sc-page-scroll {
    display: block;
    flex: none;
    min-height: 0;
    overflow: visible;
  }
  .sc-page-scroll-card {
    display: block;
    flex: none;
    min-height: 0;
    height: auto;
  }
  .sc-page-scroll-card > .adv-table-wrap {
    display: block;
    flex: none;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }
  .sc-page-fade { display: none; }

  /* Target touch: 44px per azioni vere; chip, tab e badge restano compatti.
     Icone navbar a 36px per non sacrificare il layout sui 320px. */
  .sc-btn:not(.sc-btn-sm),
  .btn-primary, .btn-secondary, .btn-ghost,
  .sidebar-menu-button { min-height: 44px; }
  .sidebar-menu-sub-button { min-height: 40px; }
  .navbar-icon-btn { width: 36px; height: 36px; }

  /* Drawer leggibile e senza elementi tagliati; tap su una voce occupa tutta
     la riga. Il contenuto parte subito sotto la topbar, senza header vuoto. */
  .sidebar-content { padding: 12px; }
  .sidebar-menu-button, .sidebar-menu-sub-button { border-radius: 10px; }

  /* Scroll orizzontale intenzionale: contenitore con overscroll isolato e
     scrollbar sottile visibile, utile anche per scoprire le colonne extra. */
  .adv-table-wrap {
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .adv-table-wrap::-webkit-scrollbar { height: 4px; }
  .adv-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

  /* Dialog e form devono restare utilizzabili con tastiera aperta. */
  .sc-dialog-content, .modal, .profile-modal, .settings-modal {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }
  .sc-dialog-body, .modal-body, .profile-modal-form, .settings-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-fields-row, .sc-form-row { flex-direction: column; }
  .modal-field, .sc-form-row > * { min-width: 0 !important; width: 100%; }
  .ld-shell { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  .ld-modal { height: auto; min-height: 0; max-height: calc(100dvh - 96px); }
  /* Dashboard attività: 4 card contatori troppo strette su mobile
     (repeat(4,1fr) su 375px comprime label come "In scadenza (48h)"
     illeggibili) → 2×2. Toolbar filtri+ricerca: nowrap forzava tab+
     ricerca sulla stessa riga causando overflow orizzontale reale
     (5 tab + input 220px fisso non ci stanno in nessun viewport
     mobile) → wrap, tab scrollabili in orizzontale, ricerca full-width
     quando va a capo. */
  .dsh-counts { grid-template-columns: repeat(2, 1fr); }
  .dsh-toolbar { flex-wrap: wrap; }
  .sc-tabs-track { max-width: 100%; overflow-x: auto; }
  .dsh-search { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════
   COMPONENTI BASE — namespace "sc-" (shadcn-compose). Da qui in avanti
   OGNI classe nuova (componenti riusabili + pagine) usa un prefisso
   (sc- per i primitivi, dsh- per la Dashboard) invece di nomi "naturali"
   come .card/.badge/.feed-entry — verificato con grep che quei nomi sono
   TUTTI già occupati nel vecchio style.css (fonte di ogni bug di bleed
   avuto finora: ombre, gradient, border, colori che riapparivano senza
   una ragione visibile). Con un prefisso dedicato la collisione è
   strutturalmente impossibile, non serve più neutralizzare nulla.
   Verificato leggendo button.tsx/badge.tsx/card.tsx/dialog.tsx/
   textarea.tsx/select.tsx/input.tsx reali in shadcn-dashboard-ref
   (2026-07-10, lettura fresca per la ricostruzione Dashboard).
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  /* shadcn non ha un token "warning" nativo in questo preset — valore
     amber standard (oklch equivalente amber-500), usato solo per il
     badge priorità "alta". Sfondo sempre soft via color-mix, mai pieno. */
  --warning: oklch(0.769 0.188 70.08);
  --warning-foreground: oklch(0.279 0.077 45.635);
  /* "Verde acceso" — token di stato SALVATO COME REGOLA PERMANENTE su
     richiesta esplicita dell'utente. Questo preset non ha token
     --chart-1/--chart-2 configurati (verificato: assenti in style.css,
     causa reale del colore mancante segnalato la prima volta). Verde
     vero (hue ~152, non giallo-verde come --primary/Lime) per restare
     distinguibile dal brand pur restando nella stessa famiglia
     "successo". Usare SEMPRE --success (mai --chart-1/2, mai un verde
     inventato lì per lì) per qualunque stato "completato/fatto/ok" in
     futuri componenti — sfondo sempre soft via color-mix (come
     --destructive/--warning), mai pieno, coerente con le altre regole
     di stato semantico. */
  --success: oklch(0.72 0.19 152);
}

/* ── Page chrome (titolo pagina + sottotitolo, sopra il contenuto).
   Riferimento di posizione/spaziatura = admin/dashboard_activity.html:
   titolo sempre a (24px, 24px) dal bordo alto/sinistro dell'area
   operativa (= solo il padding di .main-content, NIENTE sopra il
   titolo su nessuna pagina — vedi .sc-page-back-icon più sotto per le
   pagine di dettaglio); 24px di stacco tra sottotitolo e il primo
   elemento sotto (questo margin-bottom); 16px tra ogni elemento
   successivo (.sc-page-fixed, .adv-tabs, i selettori periodo/confronto
   ecc. — mai un valore diverso). ── */
.sc-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
/* Pagine dove .sc-page-header è l'UNICO figlio di .sc-page-fixed (niente
   filtri/selettori sotto): il suo margin-bottom resterebbe intrappolato
   dentro il flex item (niente collapse verso l'esterno) e si sommerebbe
   al margin-bottom del wrapper, 24+16=40px invece dei 24px di riferimento
   (stesso bug di .adv-tabs/.adv-kpi-grid/.ls-toolbar). Spostiamo i 24px
   sul wrapper stesso e azzeriamo quello dell'header, così il totale
   resta 24px anche qui. */
.sc-page-fixed:has(> .sc-page-header:only-child) { margin-bottom: 24px; }
.sc-page-fixed > .sc-page-header:only-child { margin-bottom: 0; }
/* Icona a sinistra su OGNI titolo di pagina, richiesta esplicita — flex
   di default perché questa regola vale sempre, non solo quando c'è
   un'icona (l'icona va sempre messa nel markup, non è opzionale). */
.sc-page-title { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 700; margin: 0; }
.sc-page-title > svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--primary); }
.sc-page-subtitle { font-size: 0.875rem; color: var(--muted-foreground); margin: 2px 0 0; }
/* ── Badge piattaforma a destra del titolo invece che su una riga sotto
   (provato su client_detail.html): centrati verticalmente col testo del
   titolo, stesso gap:10px degli altri figli flex di .sc-page-title. ── */
.cd-title-badges { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Back-link come icona inline nella riga del titolo (non più sopra,
   come testo, su una riga propria): con quella versione il titolo delle
   pagine di dettaglio scendeva più in basso di 24px dal bordo alto,
   rompendo l'allineamento con Dashboard/le pagine lista. Qui il titolo
   resta sempre a 24px dall'alto; solo la sua X di partenza cambia (dopo
   l'icona back) sulle pagine che ne hanno una — richiesta esplicita,
   scelta consapevole rispetto a tenere il titolo anche a X fissa. ── */
.sc-page-back-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; flex-shrink: 0;
  color: var(--muted-foreground); border-radius: var(--radius-md);
  transition: color .15s, background .15s;
}
.sc-page-back-icon:hover { color: var(--foreground); background: var(--muted); }
.sc-page-back-icon svg { width: 18px; height: 18px; color: inherit; }

/* ── Titolo di sezione (header di card/blocco) — icona a sinistra ── */
.sc-section-title { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 1rem; }
.sc-section-title svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted-foreground); }

/* ── Button (reale: button.tsx) ── */
.sc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  height: 2.25rem; /* h-9 = 36px, default reale */
  padding: 0 10px; /* px-2.5 */
}
.sc-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sc-btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
/* Prova: shadow-xs anche su default/secondary/destructive (nel vero
   button.tsx ce l'ha solo "outline") — sperimentale, su richiesta
   esplicita "aggiungiamo un po' di shadow, proviamo". */
.sc-btn-default { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--content-shadow); }
.sc-btn-default:hover { background: color-mix(in oklch, var(--primary) 80%, transparent); }
.sc-btn-secondary { background: var(--secondary); color: var(--secondary-foreground); box-shadow: var(--content-shadow); }
.sc-btn-secondary:hover { background: color-mix(in oklch, var(--secondary), var(--foreground) 5%); }
.sc-btn-outline { background: var(--background); color: var(--foreground); border-color: var(--border); box-shadow: var(--content-shadow); }
.sc-btn-outline:hover { background: var(--muted); }
.sc-btn-ghost { background: none; color: var(--foreground); }
.sc-btn-ghost:hover { background: var(--muted); }
.sc-btn-destructive { background: color-mix(in oklch, var(--destructive) 10%, transparent); color: var(--destructive); box-shadow: var(--content-shadow); }
.sc-btn-destructive:hover { background: color-mix(in oklch, var(--destructive) 20%, transparent); }
.sc-btn-sm { height: 2rem; padding: 0 10px; border-radius: min(var(--radius-md), 10px); }
.sc-btn-xs { height: 1.5rem; padding: 0 8px; font-size: 0.75rem; border-radius: min(var(--radius-md), 8px); }
.sc-btn-lg { height: 2.5rem; padding: 0 10px; }
.sc-btn-icon, .sc-btn-icon-sm, .sc-btn-icon-xs, .sc-btn-icon-lg { padding: 0; gap: 0; }
.sc-btn-icon { width: 2.25rem; height: 2.25rem; }
.sc-btn-icon-sm { width: 2rem; height: 2rem; border-radius: min(var(--radius-md), 10px); }
.sc-btn-icon-xs { width: 1.5rem; height: 1.5rem; border-radius: min(var(--radius-md), 8px); }
.sc-btn-icon-lg { width: 2.5rem; height: 2.5rem; }

/* ── Badge (reale: badge.tsx — h-5 rounded-4xl px-2 py-0.5 text-xs font-medium) ── */
.sc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 1.25rem; /* h-5 = 20px */
  padding: 2px 8px; /* py-0.5 px-2 */
  border-radius: var(--radius-4xl);
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
  flex-shrink: 0;
}
.sc-badge svg { width: 12px; height: 12px; }
.sc-badge-default { background: var(--primary); color: var(--primary-foreground); }
.sc-badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.sc-badge-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.sc-badge-destructive { background: color-mix(in oklch, var(--destructive) 10%, transparent); color: var(--destructive); }
.sc-badge-warning { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning-foreground); }

/* ── Flash message (banner successo/errore/warning) ── */
.sc-flash { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px; font-size: 0.9rem; overflow-wrap: break-word; word-break: break-word; }
.sc-flash.success { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.sc-flash.error { background: color-mix(in oklch, var(--destructive) 12%, transparent); color: var(--destructive); }
.sc-flash.warning { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning-foreground); }

/* ── Card (reale: card.tsx — rounded-xl, ring-1 ring-foreground/10,
   shadow-xs, gap/padding 24px via --card-spacing, 16px per size="sm") ── */
.sc-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem; /* --card-spacing default = spacing(6) = 24px */
  background: var(--card);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent),
              var(--content-shadow); /* ring-foreground/10 + shadow-xs */
  padding: 1.5rem 0;
  overflow: hidden;
}
.sc-card-sm { gap: 1rem; padding: 1rem 0; } /* size="sm" reale = spacing(4) = 16px */
.sc-card-muted { background: var(--muted); }
/* Navigation rails contain 32px controls. An 8px block inset makes their
   visible icon/text edge land on the same 16px rhythm as the inline inset. */
.sc-card-rail { padding-block: .5rem; }
.sc-card-header { display: flex; flex-direction: column; gap: 4px; padding: 0 1.5rem; }
.sc-card-sm .sc-card-header { padding: 0 1rem; }
.sc-card-title { font-size: 1rem; font-weight: 500; line-height: 1.4; }
.sc-card-sm .sc-card-title { font-size: 0.875rem; }
.sc-card-description { font-size: 0.875rem; color: var(--muted-foreground); }
.sc-card-content { padding: 0 1.5rem; }
.sc-card-sm .sc-card-content { padding: 0 1rem; }
.sc-card-footer { display: flex; align-items: center; padding: 0 1.5rem; }
.sc-card-sm .sc-card-footer { padding: 0 1rem; }

/* ── Input / Textarea di form (reali: input.tsx/textarea.tsx —
   border-input, rounded-md, bg-transparent, shadow-xs) ── */
.sc-input, .sc-textarea, .sc-select {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  box-shadow: var(--content-shadow); /* shadow-xs, allineata a card/bottoni */
  padding: 4px 10px; /* px-2.5 py-1 reale (input) */
  height: 2.25rem; /* h-9 */
  font-size: 0.875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sc-textarea { height: auto; min-height: 4rem; padding: 8px 10px; resize: vertical; }
.sc-select { padding-right: 28px; }
.sc-input:focus, .sc-textarea:focus, .sc-select:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
.sc-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--foreground); margin-bottom: 4px; }

/* Campo "Formato indirizzo": un unico controllo (come .sc-input) frazionato in segmenti interni */
.ld-addr-box {
  display: flex; align-items: stretch; width: 100%;
  height: 2.25rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  box-shadow: var(--content-shadow);
  background: transparent;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.ld-addr-box:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent);
}
.ld-addr-seg {
  border: none; background: transparent; color: var(--foreground);
  font-size: 0.875rem; padding: 4px 10px; outline: none; min-width: 0;
}
.ld-addr-seg + .ld-addr-seg { border-left: 1px solid var(--border); }
.ld-addr-seg::placeholder { color: var(--muted-foreground); }

/* ── Hero input (barra comando NL, ricerca in toolbar): stessa idea del
   Card (ring+shadow-xs) ma senza bordo interno sull'input contenuto —
   non è un componente shadcn a sé, è una composizione per input "grandi"
   fuori da un form strutturato. ── */
.sc-hero {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent),
              var(--content-shadow);
  transition: box-shadow .15s;
}

/* ── Tabs / segmented control (pattern osservato, non un componente
   .tsx a sé per i filtri) ── */
.sc-tabs-track { display: inline-flex; align-items: center; height: 2rem; gap: 2px; background: var(--muted); border-radius: var(--radius-lg); padding: 3px; box-sizing: border-box; }
.sc-tabs-item {
  display: inline-flex; align-items: center; justify-content: center; height: 100%; box-sizing: border-box;
  background: transparent; border: none; border-radius: var(--radius-md);
  color: var(--muted-foreground); padding: 0 14px;
  font-size: 0.85rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.sc-tabs-item:hover { color: var(--foreground); }
.sc-tabs-item.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px 0 rgba(0,0,0,.06); }

/* ── Dialog (reale: dialog.tsx — overlay bg-black/10, content rounded-xl
   ring-1 ring-foreground/10 bg-popover p-6 gap-6) ── */
.sc-dialog-overlay {
  display: none;
  position: fixed; inset: 0; z-index: var(--layer-modal);
  background: rgba(0,0,0,.1);
  backdrop-filter: blur(2px);
}
.sc-dialog-overlay.open { display: block; }
/* Tutti gli overlay standard usano il layer primario, anche se una pagina
   legacy porta ancora un vecchio z-index inline. Per un modal sopra un
   altro modal si usa esclusivamente .sc-modal-secondary. */
:is(.sc-dialog-overlay, .rm2-overlay, .ld-modal-overlay, .modal-overlay,
    .report-modal-overlay, .adv-modal-overlay) {
  z-index: var(--layer-modal) !important;
}
.sc-modal-secondary { z-index: var(--layer-modal-secondary) !important; }
.sc-modal-popover { z-index: var(--layer-modal-popover) !important; }
.sc-dialog-content {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: var(--layer-modal-content);
  width: calc(100% - 2rem);
  max-width: 28rem; /* sm:max-w-md reale */
  display: flex; flex-direction: column; gap: 1.5rem; /* gap-6 */
  background: var(--popover);
  color: var(--popover-foreground);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent),
              0 12px 32px -4px rgba(0,0,0,.18);
  padding: 1.5rem; /* p-6 */
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}
.sc-dialog-header { display: flex; flex-direction: column; gap: 4px; }
.sc-dialog-title { font-weight: 500; font-size: 1rem; line-height: 1.2; }
.sc-dialog-body { display: flex; flex-direction: column; gap: 12px; }
.sc-dialog-close { position: absolute; top: 1rem; right: 1rem; }
.sc-dialog-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* Dense editor layout: header and footer remain fixed while only the body
   scrolls. */
.sc-dialog-content.sc-dialog-layout { gap: 1rem; overflow: hidden; }
.sc-dialog-content.sc-dialog-layout > .sc-dialog-header,
.sc-dialog-content.sc-dialog-layout > .sc-dialog-footer,
.sc-dialog-content.sc-dialog-layout > form > .sc-dialog-footer { flex: none; }
.sc-dialog-content.sc-dialog-layout > form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}
.sc-dialog-content.sc-dialog-layout > .sc-dialog-body,
.sc-dialog-content.sc-dialog-layout > form > .sc-dialog-body {
  flex: 1;
  min-height: 0;
  /* Keep focus rings and shadows inside the scroll clip without changing the
     visible field alignment. */
  margin: -.5rem;
  padding: .5rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

/* ═══════════════════════════════════════════════════════════════════════
   DASHBOARD (dashboard_bp, /admin/dashboard) — namespace "dsh-".
   Markup: admin/dashboard_activity.html. Business logic in
   dashboard.js: stessi endpoint (parse/save/entry PATCH-DELETE), stesso
   payload, invariata — solo l'HTML generato lì dentro usa queste classi
   + Hugeicons, niente inline-style/emoji/Lucide.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Barra input NL ── */
.dsh-inputbar { padding: 10px 10px 10px 16px; margin-bottom: 16px; }
.dsh-inputbar:focus-within { box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow); } /* niente ring di focus — deve restare "una grossa casella di testo" */
.dsh-inputbar textarea {
  flex: 1; min-width: 0; resize: none; border: none; background: transparent;
  outline: none; font-size: 0.9375rem;
  color: var(--foreground); line-height: 1.5; max-height: 160px; padding: 4px 0;
}
.dsh-inputbar textarea::placeholder { color: var(--muted-foreground); }
.dsh-inputbar textarea:focus { border: none; box-shadow: none; outline: none; } /* annulla "textarea:focus{box-shadow:...}" globale del vecchio style.css */
.dsh-inputbar-submit.sc-btn-icon-sm { background: var(--primary); color: var(--primary-foreground); flex-shrink: 0; }
.dsh-inputbar-submit.sc-btn-icon-sm:hover { background: color-mix(in oklch, var(--primary) 80%, transparent); }
.dsh-inputbar-submit.loading svg { animation: dsh-spin 1s linear infinite; }
@keyframes dsh-spin { to { transform: rotate(360deg); } }

/* ── Preview inline ── */
.dsh-preview { display: none; margin-bottom: 16px; }
.dsh-preview.visible { display: flex; }
.dsh-preview-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 1.5rem; }
.dsh-preview-title { font-weight: 600; font-size: 0.9375rem; }
.dsh-preview-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.dsh-preview-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 1.5rem; }
.dsh-preview-meta-item { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--muted-foreground); }
.dsh-preview-meta-item svg { width: 13px; height: 13px; }
.dsh-preview-edit { display: none; padding: 16px 1.5rem 0; border-top: 1px solid var(--border); margin: 0 1.5rem; }
.dsh-preview-edit.visible { display: block; }
.dsh-preview-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dsh-preview-edit-grid .span-2 { grid-column: 1 / -1; }

/* ── 4 card contatori ── */
.dsh-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 16px; }
.dsh-count-card { padding: 1rem !important; cursor: pointer; text-align: left; transition: box-shadow .15s; gap: 4px !important; }
.dsh-count-card.active { box-shadow: 0 0 0 1px var(--primary), var(--content-shadow); }
.dsh-count-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.dsh-count-label { font-size: 0.8125rem; color: var(--muted-foreground); }

/* ── Toolbar filtri + ricerca ── */
.dsh-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: nowrap; }
.dsh-search { padding: 0 10px; height: 2rem; width: 220px; }
.dsh-search svg { width: 15px; height: 15px; color: var(--muted-foreground); flex-shrink: 0; }
.dsh-search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-size: 0.8125rem; color: var(--foreground); }
.dsh-search input::placeholder { color: var(--muted-foreground); }
.dsh-search input:focus { border: none; box-shadow: none; outline: none; }

/* ── Feed ── */
.dsh-feed { display: flex; flex-direction: column; gap: 8px; }
.dsh-entry { padding: 14px 16px !important; gap: 8px !important; }
.dsh-entry-header { display: flex; align-items: center; gap: 8px; }
.dsh-entry-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--muted-foreground); }
.dsh-entry-dot.in_progress { background: var(--primary); }
.dsh-entry-dot.done { background: var(--success); } /* verde acceso, coerente col nuovo highlight del bottone "Fatto" */
.dsh-entry-title { flex: 1; min-width: 0; font-size: 0.9375rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsh-entry-title.done { text-decoration: line-through; color: var(--muted-foreground); }
.dsh-entry-badges { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.dsh-entry-time { color: var(--muted-foreground); font-size: 0.78rem; margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.dsh-entry-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.dsh-entry-action-btn { width: 1.75rem; height: 1.75rem; border-radius: min(var(--radius-md), 8px); background: none; border: none; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, color .15s; }
.dsh-entry-action-btn svg { width: 14px; height: 14px; }
.dsh-entry-action-btn:hover { background: var(--muted); color: var(--foreground); }
.dsh-entry-action-btn.active { background: var(--accent); color: var(--foreground); }
/* Colore sull'HIGHLIGHT (sfondo) di sicuro/selezionato, non sull'icona a
   riposo — su richiesta esplicita ("coloriamo l'highlight invece
   dell'icona"). Icone a riposo restano tutte neutre; solo il bottone
   ATTIVO (stato corrente dell'entry) prende il colore, stesso schema dei
   pallini nel feed (todo=neutro, in_progress=lime, done=verde acceso).
   I primi 3 bottoni sono sempre nell'ordine todo/in_progress/done
   (vedi dashboard_activity.html). */
.dsh-entry-actions button:nth-child(2).active {
  background: color-mix(in oklch, var(--primary) 18%, transparent);
  color: var(--primary);
}
.dsh-entry-actions button:nth-child(3).active {
  background: color-mix(in oklch, var(--success) 22%, transparent); /* verde acceso — vedi --success in :root */
  color: var(--success);
}
.dsh-entry-action-btn.danger:hover { background: color-mix(in oklch, var(--destructive) 10%, transparent); color: var(--destructive); }
.dsh-entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-left: 15px; }
.dsh-entry-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--muted-foreground); }
.dsh-entry-chip svg { width: 12px; height: 12px; }
.dsh-entry-desc { padding-left: 15px; font-size: 0.85rem; color: var(--muted-foreground); line-height: 1.5; }

/* ── Stato vuoto ── */
.dsh-empty { text-align: center; padding: 56px 24px; color: var(--muted-foreground); }
.dsh-empty svg { width: 32px; height: 32px; margin-bottom: 10px; opacity: .5; }
.dsh-empty-title { font-weight: 500; color: var(--foreground); }
.dsh-empty-sub { font-size: 0.85rem; margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════════════
   ADV / Performance (admin.dashboard, route "/admin/") — ricostruita da
   zero riusando le regole sc-/dsh- già stabilite per la Dashboard.
   Markup: admin/dashboard.html. Business logic invariata (stessa query,
   stesso switchScope/JS) — solo rinominate le classi toccate
   (.scope-tab→.adv-tab, .scope-panel→.adv-scope-panel) aggiornando i
   riferimenti nello script inline della stessa pagina.
   Il modal di invio report (#reportModal) e lo storico (#reportHistoryModal)
   restano con lo stile vecchio per ora, su scelta esplicita — troppo
   complessi per questo giro, si ricostruiscono a parte quando richiesto.
   ═══════════════════════════════════════════════════════════════════════ */

.adv-page-header { align-items: flex-start; flex-wrap: wrap; }

/* ── Tab Clienti/Agenzia — underline style (reale pattern Tabs shadcn,
   distinto dal segmented-control pillola di .sc-tabs-track/.sc-tabs-item
   usato per i filtri della Dashboard: qui è un cambio di sezione, non un
   filtro, quindi lo stile underline è quello corretto). ── */
/* niente margin-bottom qui: .adv-tabs è sempre l'ultimo figlio di
   .sc-page-fixed, che fornisce già lui i 16px di distacco dal contenuto
   sotto — un margin-bottom qui si sommerebbe (flex item, niente collapse
   verso l'esterno) raddoppiando lo spazio a 32px. */
.adv-tabs { display: flex; align-items: center; gap: 4px; }
.adv-tab {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  padding: 10px 4px; margin-right: 20px;
  font-size: 0.9375rem; font-weight: 500; color: var(--muted-foreground);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.adv-tab:hover { color: var(--foreground); }
.adv-tab.active { color: var(--foreground); border-bottom-color: var(--primary); font-weight: 600; }
.adv-tab-count { pointer-events: none; }

/* auto-fit invece di un conteggio fisso di colonne: il pannello Clienti
   ha 5 card (aggiunta "Vendite"), il pannello Agenzia ne ha 4 — così
   nessuna delle due resta con una colonna vuota.
   Niente margin-bottom: come .adv-tabs, è sempre l'ultimo figlio di un
   .sc-page-fixed che fornisce già lui i 16px verso il contenuto sotto —
   altrimenti raddoppia a 32px (flex item, margin non collassa). */
.adv-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.adv-kpi-card { padding: 16px; }
.adv-kpi-label { font-size: 0.8125rem; color: var(--muted-foreground); }
.adv-kpi-value { font-size: 1.5rem; font-weight: 700; font-family: 'Work Sans', sans-serif; margin-top: 4px; }
.adv-kpi-value.accent { color: var(--primary); }

.adv-table-card-header { flex-direction: row; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

.adv-table-wrap { overflow-x: auto; padding: 0 1.5rem 1.5rem; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.pizza-performance-body { margin-top: 0; }
.pizza-performance-card { margin: 0; }
.pizza-performance-note { color: var(--muted-foreground); font-size: .78rem; font-weight: 500; }
.pizza-performance-intro { color: var(--muted-foreground); font-size: .8rem; line-height: 1.45; padding: 0 1.5rem 1rem; }
.pizza-performance-tables { display: grid; gap: 1.25rem; }
.pizza-performance-section + .pizza-performance-section { border-top: 1px solid var(--border); padding-top: 1.25rem; }
.pizza-performance-section > .sc-section-title { display: flex; align-items: center; min-height: 2rem; padding: 0 1.5rem .75rem; font-size: .9rem; }
.pizza-performance-table { min-width: max-content; }
.pizza-performance-table th { white-space: normal; line-height: 1.2; min-width: 86px; }
.pizza-performance-table th:first-child { min-width: 112px; }
.pizza-performance-table td { white-space: nowrap; }
.pizza-performance-table .pizza-week { font-weight: 650; }
@media (max-width: 720px) {
  .pizza-performance-intro, .pizza-performance-section > .sc-section-title { padding-left: 1rem; padding-right: 1rem; }
  .pizza-performance-note { display: none; }
}
.adv-table-wrap::-webkit-scrollbar { height: 6px; }
.adv-table-wrap::-webkit-scrollbar-track { background: transparent; }
.adv-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.adv-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); }
.adv-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.adv-table th {
  text-align: left; font-weight: 500; font-size: 0.78rem; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .03em;
  padding: 0 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
  /* sticky ovunque: se .adv-table-wrap non è un contenitore con scroll
     verticale vincolato (pagine non ancora sul page-shell) non ha alcun
     effetto — sticky senza un antenato overflow si comporta da static. */
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.adv-table th.num, .adv-table td.num { text-align: right; }
.adv-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.adv-table tbody tr:last-child td { border-bottom: none; }

/* Dense spreadsheet variant. */
.sc-card.adv-grid-card { gap: 0; }
.sc-card.adv-grid-card > .adv-table-card-header { margin-bottom: 0; }
.sc-card-sm.adv-grid-card > .adv-table-wrap { padding-inline: 1rem; }
.sc-card.adv-grid-card > .sc-card-footer { min-height: 1.5rem; }
.adv-table.adv-table-grid th,
.adv-table.adv-table-grid td {
  height: 32px;
  padding: 0 8px;
  border-inline-end: 1px solid var(--border);
  vertical-align: middle;
}
.adv-table.adv-table-grid th { line-height: 1.2; }
.adv-row-clickable { cursor: pointer; transition: background .1s; }
.adv-row-clickable:hover td { background: var(--muted); }
.adv-client-name { font-weight: 500; }
.adv-accent-val { font-weight: 600; color: var(--primary); }
.adv-badge-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ── Badge piattaforma — colori brand preservati (stessi valori del
   vecchio style.css, verificati: sono associazioni cromatiche reali dei
   brand, non un vezzo estetico, corretto tenerle), forma allineata al
   vero Badge shadcn (rounded-4xl, h-5, text-xs) invece della vecchia
   pillola con radius/padding arbitrari. ── */
.adv-platform-badge.meta    { background: rgba(24,119,242,0.12); color: #1877f2; }
.adv-platform-badge.google  { background: rgba(52,168,83,0.12);  color: #34a853; }
.adv-platform-badge.tiktok  { background: rgba(245,158,11,0.12); color: #b45309; }
.adv-platform-badge.klaviyo { background: rgba(26,107,60,0.12);  color: #1a6b3c; }
.adv-platform-badge.ga4     { background: rgba(249,171,0,0.12);  color: #e37400; }
.adv-platform-badge.instagram { background: rgba(225,48,108,0.11); color: #c13584; }
body.dark-mode .adv-platform-badge.meta    { background: rgba(24,119,242,0.18); color: #5b9ef7; }
body.dark-mode .adv-platform-badge.google  { background: rgba(52,168,83,0.18);  color: #5ec97a; }
body.dark-mode .adv-platform-badge.tiktok  { background: rgba(245,158,11,0.18); color: #fbbf24; }
body.dark-mode .adv-platform-badge.klaviyo { background: var(--muted); color: var(--muted-foreground); }
body.dark-mode .adv-platform-badge.ga4     { background: rgba(249,171,0,0.18); color: #f5c842; }
body.dark-mode .adv-platform-badge.instagram { background: rgba(225,48,108,0.18); color: #f38bb0; }
.adv-platform-badge.whatsapp { background: rgba(37,211,102,0.12); color: #128c7e; }
.adv-platform-badge.email    { background: var(--muted); color: var(--muted-foreground); }
body.dark-mode .adv-platform-badge.whatsapp { background: rgba(37,211,102,0.18); color: #4ce08a; }

.adv-type-badge.leadgen    { background: rgba(41,128,185,0.12); color: #2980b9; }
.adv-type-badge.ecommerce  { background: rgba(30,132,73,0.12);  color: #1e8449; }
body.dark-mode .adv-type-badge.leadgen   { background: rgba(41,128,185,0.2); color: #5dade2; }
body.dark-mode .adv-type-badge.ecommerce { background: rgba(30,132,73,0.2);  color: #58d68d; }

/* Campaign picker: gli switch controllano quali campagne alimentano le
   rispettive sezioni Performance, senza interferire con l'espansione riga. */
.cd-scope-col { text-align: center !important; width: 5.75rem; }
.cd-scope-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  vertical-align: middle;
}
.cd-scope-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.cd-scope-toggle span {
  width: 2rem;
  height: 1.125rem;
  padding: 2px;
  border-radius: 999px;
  background: var(--sc-surface-muted, #e8e8e8);
  box-shadow: inset 0 0 0 1px var(--sc-border, #dedede);
  transition: background .16s ease, box-shadow .16s ease;
}
.cd-scope-toggle span::after {
  content: "";
  display: block;
  width: .875rem;
  height: .875rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
  transition: transform .16s ease;
}
.cd-scope-toggle input:checked + span { background: var(--lime, #a8db20); box-shadow: none; }
.cd-scope-toggle input:checked + span::after { transform: translateX(.875rem); }
.cd-scope-toggle input:focus-visible + span { outline: 2px solid #111; outline-offset: 2px; }
.cd-scope-toggle input:disabled + span { opacity: .55; cursor: wait; }

.adv-recipient { font-size: 0.8125rem; color: var(--muted-foreground); }
.adv-recipient-email { color: var(--foreground); }
.adv-recipient-cc { color: var(--muted-foreground); font-size: 0.75rem; }
.adv-recipient-empty { color: var(--muted-foreground); font-style: italic; }

/* ── Stato report — stessi token semantici già in uso altrove (--success
   per "inviato", --warning per "salvato/in attesa", neutro per bozza/
   non generato) invece dei vecchi valori hardcoded. ── */
.adv-report-status.sent  { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.adv-report-status.ready { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning-foreground); }
.adv-report-status.none  { background: var(--muted); color: var(--muted-foreground); }
.adv-report-status-date { font-size: 0.72rem; color: var(--muted-foreground); margin-top: 2px; }
.adv-report-count { font-size: 0.8rem; color: var(--muted-foreground); }
.adv-report-count.empty { color: var(--muted-foreground); }

.adv-empty-inline { padding: 48px 24px; text-align: center; }
.adv-empty-inline-title { font-size: 1rem; margin: 0; color: var(--foreground); }
.adv-empty-inline-sub { font-size: 0.83rem; margin: 8px 0 0; color: var(--muted-foreground); }

.adv-month-label {
  min-width: 11.5rem;
  justify-content: center;
  pointer-events: none;
}

.monthly-report-tables { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.monthly-report-card-title { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }

.men-clients-dialog { max-width: 36rem; }
.men-clients-list { gap: 0; max-height: min(56vh, 32rem); overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.men-client-toggle { display: flex; align-items: center; gap: 1rem; min-height: 4rem; padding: 0.75rem 1rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.men-client-toggle:last-child { border-bottom: 0; }
.men-client-toggle:hover { background: var(--muted); }
.men-client-toggle-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.men-client-toggle-copy strong { font-size: 0.86rem; }
.men-client-toggle-copy small { color: var(--muted-foreground); font-size: 0.73rem; }
.men-client-toggle .sc-switch { flex: 0 0 auto; }

/* ── Report mensile cliente ─────────────────────────────── */
.mrc-page-header { align-items: center; }
.mrc-page-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.55rem; flex-wrap: wrap; }
.mrc-month-nav { display: flex; align-items: center; gap: 0.45rem; }
.mrc-month-label { min-width: 11rem; justify-content: center; pointer-events: none; }
.mrc-month-nav .disabled { opacity: 0.38; pointer-events: none; }
.mrc-page-body { gap: 1rem; }
.mrc-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.mrc-summary-card { min-height: 7.25rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.45rem; text-align: center; }
.mrc-summary-card strong { font-size: 1.08rem; }
.mrc-summary-card small { color: var(--muted-foreground); }
.mrc-eyebrow { color: var(--muted-foreground); font-size: 0.69rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.mrc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; min-height: 0; }
.mrc-layout-social { grid-template-columns: minmax(0, 1.75fr) minmax(17rem, 0.65fr); }
.mrc-main-column, .mrc-side-column { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.mrc-current-card, .mrc-archive-card, .mrc-config-card { overflow: hidden; }
.mrc-current-card { gap: 1.25rem; }
.mrc-card-header { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; text-align: center; }
.mrc-current-card .mrc-card-header { flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
.mrc-archive-card .mrc-card-header { align-items: flex-start; text-align: left; }
.mrc-card-header h2, .mrc-config-card h2 { margin: 0.25rem 0 0; font-size: 1rem; }
.mrc-report-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.55rem; }
.mrc-current-card .mrc-report-actions { justify-content: flex-end; }
.mrc-report-actions form { margin: 0; }
.mrc-pdf-viewer { border-top: 1px solid var(--border); background: var(--muted); }
.mrc-pdf-stage { position: relative; display: grid; min-height: min(61vh, 46rem); place-items: center; padding: 1.25rem; overflow: hidden; background: color-mix(in srgb, var(--muted) 74%, #c9c9c4); }
.mrc-pdf-page-image { display: block; max-width: 100%; max-height: calc(min(61vh, 46rem) - 2.5rem); border-radius: 0.18rem; background: white; box-shadow: 0 1rem 2.2rem rgba(20, 20, 20, 0.16); }
.mrc-pdf-loading { position: absolute; z-index: 1; display: inline-flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: .6rem; background: var(--card); color: var(--muted-foreground); font-size: .78rem; box-shadow: 0 .35rem 1.1rem rgba(20,20,20,.08); }
.mrc-pdf-loading[hidden] { display: none; }
.mrc-pdf-loading i { width: 1rem; height: 1rem; color: var(--primary); }
.mrc-pdf-controls { display: flex; align-items: center; justify-content: center; gap: .8rem; min-height: 3.4rem; padding: .55rem 1rem; border-top: 1px solid var(--border); background: var(--card); }
.mrc-pdf-page { display: inline-flex; align-items: baseline; gap: .3rem; min-width: 6.6rem; justify-content: center; font-size: .76rem; color: var(--muted-foreground); }
.mrc-pdf-page strong { color: var(--foreground); font-weight: 700; }
.mrc-pdf-controls .sc-btn:disabled { opacity: .4; cursor: not-allowed; }
.mrc-inline-state { display: flex; align-items: center; justify-content: center; gap: 0.7rem; padding: 1.15rem 1.5rem; border-top: 1px solid var(--border); text-align: left; }
.mrc-inline-state > i { color: var(--muted-foreground); font-size: 1.25rem; }
.mrc-inline-state span { display: flex; flex-direction: column; gap: 0.15rem; }
.mrc-inline-state small { color: var(--muted-foreground); }
.mrc-empty-state { min-height: 23rem; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; text-align: center; }
.mrc-empty-state p { margin: 0.45rem 0 0; max-width: 30rem; color: var(--muted-foreground); }
.mrc-empty-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: 0.85rem; border-radius: 0.85rem; background: var(--muted); color: var(--muted-foreground); }
.mrc-config-card { text-align: center; }
.mrc-source-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; margin-top: 1rem; }
.mrc-section-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; justify-items: center; gap: 0.65rem; }
.mrc-section-list li { display: flex; align-items: center; gap: 0.65rem; font-size: 0.82rem; }
.mrc-section-list li span { flex: 0 0 1.5rem; height: 1.5rem; display: grid; place-items: center; border-radius: 0.45rem; background: var(--muted); color: var(--muted-foreground); font-size: 0.7rem; font-weight: 700; }
.mrc-rule-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; justify-items: center; gap: 0.7rem; }
.mrc-rule-list li { display: flex; align-items: flex-start; gap: 0.55rem; color: var(--muted-foreground); font-size: 0.8rem; line-height: 1.35; }
.mrc-rule-list i { color: var(--primary); flex: 0 0 auto; }
.mrc-table-action { text-align: right; }
.adv-client-link { color: inherit; text-decoration: none; }
.adv-client-link:hover { color: var(--primary); }

/* ── Collegamento Meta Insights ─────────────────────────── */
.meta-social-connection-card { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; }
.meta-social-connection-card > h2 { margin: 0; }
.meta-social-connection-heading { display: flex; align-items: flex-start; justify-content: center; gap: 0.7rem; min-width: 0; text-align: left; }
.meta-social-connection-heading h2 { margin: 0; overflow-wrap: anywhere; }
.meta-social-connection-heading small { display: block; margin-top: 0.25rem; color: var(--muted-foreground); }
.meta-social-status-dot { flex: 0 0 0.65rem; width: 0.65rem; height: 0.65rem; margin-top: 0.3rem; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0.22rem rgba(34,197,94,0.14); }
.meta-social-sync-status { margin: 0; color: var(--muted-foreground); font-size: 0.8rem; line-height: 1.45; }
.meta-social-error { width: 100%; margin: 0; padding: 0.7rem 0.8rem; border: 1px solid rgba(220,38,38,0.2); border-radius: var(--radius-sm); background: rgba(220,38,38,0.06); color: #b91c1c; font-size: 0.77rem; line-height: 1.4; overflow-wrap: anywhere; }
.meta-social-card-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; }
.meta-social-card-actions form { margin: 0; }
.mrc-meta-dialog { width: min(32rem, calc(100vw - 2rem)); }
.mrc-meta-dialog-intro { margin: 0.35rem 0 0; color: var(--muted-foreground); font-size: 0.84rem; line-height: 1.45; }
.mrc-meta-account { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.9rem; border-radius: var(--radius-lg); background: var(--muted); }
.mrc-meta-account > div { display: flex; min-width: 0; flex-direction: column; gap: 0.2rem; }
.mrc-meta-account strong { overflow-wrap: anywhere; font-size: 0.92rem; }
.mrc-meta-account small { color: var(--muted-foreground); font-size: 0.8rem; }
.mrc-meta-dialog .meta-social-sync-status { margin: 0.9rem 0 0; }
.mrc-meta-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; margin-top: 1.1rem; }
.mrc-meta-dialog-actions form { margin: 0; }

.meta-social-select-page { display: flex; justify-content: center; }
.meta-social-select-card { width: min(54rem, 100%); }
.meta-social-assets { display: grid; gap: 0.75rem; padding: 0 1.25rem 1.25rem; }
.meta-social-asset { position: relative; display: flex; align-items: flex-start; gap: 0.85rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.meta-social-asset:hover { border-color: color-mix(in srgb, var(--primary) 60%, var(--border)); background: var(--muted); }
.meta-social-asset:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 0.18rem color-mix(in srgb, var(--primary) 22%, transparent); }
.meta-social-asset input { flex: 0 0 auto; margin-top: 0.2rem; accent-color: var(--primary); }
.meta-social-asset-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.meta-social-asset-copy strong { overflow-wrap: anywhere; }
.meta-social-asset-copy small { color: var(--muted-foreground); }
.meta-social-select-actions { display: flex; justify-content: flex-end; padding: 0 1.25rem 1.25rem; }

@media (max-width: 640px) {
  .meta-social-card-actions .sc-btn,
  .meta-social-card-actions form { width: 100%; }
  .meta-social-card-actions form .sc-btn { width: 100%; justify-content: center; }
  .meta-social-select-actions .sc-btn { width: 100%; justify-content: center; }
}

@media (max-width: 1050px) {
  .mrc-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mrc-layout, .mrc-layout-social { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .mrc-page-header { align-items: flex-start; }
  .mrc-page-header-actions { width: 100%; justify-content: flex-start; }
  .mrc-current-card .mrc-card-header { flex-direction: column; align-items: flex-start; }
  .mrc-current-card .mrc-report-actions { justify-content: flex-start; }
  .mrc-month-nav { width: 100%; }
  .mrc-month-label { flex: 1; min-width: 0; }
  .mrc-summary-grid { grid-template-columns: 1fr; }
  .mrc-summary-card { min-height: auto; }
  .mrc-pdf-stage { min-height: 16rem; padding: .65rem; }
  .mrc-pdf-page-image { max-height: calc(16rem - 1.3rem); }
  .mrc-meta-dialog-actions .sc-btn, .mrc-meta-dialog-actions form { width: 100%; }
  .mrc-meta-dialog-actions form .sc-btn { width: 100%; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════════════
   LEAD (leads.list_leads, route "/admin/leads/") — ricostruita da zero
   riusando le regole sc-/adv- già stabilite (tabs, tabella, dialog,
   badge). Markup: admin/leads.html, JS interamente inline (nessun file
   dedicato) — business logic invariata (stessi endpoint fetch/polling),
   solo le stringhe HTML generate lato client sono state riscritte per
   usare queste classi al posto di quelle del vecchio sistema
   (.card/.data-table/.platform-badge/.sidebar-lead-badge — tutte
   condivise/rischiose altrove, vedi nota in PROGRESS). Nota: le card
   client usano il prefisso sc-lead-card (non lead-client-card) per non
   collidere con le regole :nth-child gradient del vecchio style.css.
   ═══════════════════════════════════════════════════════════════════════ */

.lead-cards-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 1rem; }
.sc-lead-card {
  flex: 1; min-width: 160px; max-width: 220px; padding: 16px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  transition: box-shadow .15s; position: relative;
}
.sc-lead-card:hover { box-shadow: 0 0 0 1px var(--primary), var(--content-shadow); }
.sc-lead-card-internal { border-color: color-mix(in srgb, var(--primary) 42%, var(--border)); }
.sc-lead-card-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sc-lead-card-name { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-lead-card-internal-badge { flex-shrink: 0; font-size: .68rem; }
.sc-lead-card-count { font-size: 1.75rem; font-weight: 700; color: var(--foreground); align-self: flex-end; line-height: 1; font-family: 'Work Sans', sans-serif; }
.sc-lead-card-notif {
  position: absolute; top: 10px; right: 10px; min-width: 1.35rem; height: 1.35rem;
  padding: 0 5px; border-radius: 999px; background: var(--destructive); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; line-height: 1;
}
.sc-lead-card:has(.sc-lead-card-notif) .sc-lead-card-heading { padding-right: 30px; }

.lead-loading-cell { text-align: center; color: var(--muted-foreground); padding: 30px; }
.lead-cell-muted { white-space: nowrap; color: var(--muted-foreground); font-size: 0.8rem; }
.lead-cell-name { font-weight: 500; }
.lead-cell-sub { font-size: 0.85rem; color: var(--muted-foreground); }
.lead-client-tag { font-weight: 600; }

/* Riga nuova nel feed "Ultimi lead" — stessa idea del vecchio
   .lead-fade-in ma ridichiarata qui per non dipendere dal vecchio
   style.css. */
@keyframes lead-fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.lead-fade-in { animation: lead-fade-in .5s ease; }

/* ═══════════════════════════════════════════════════════════════════════
   STATO SYNC (admin.sync_monitor, route "/admin/sync-monitor") —
   ricostruita da zero. Prima non aveva NESSUNA classe CSS propria (tutto
   inline-style con colori hex hardcoded: #2D8A3E/#D93025/#B7D63C/#22c55e/
   ecc.) — nessun rischio di collisione col vecchio sistema, foglio
   bianco reale. Colori di stato mappati sui token semantici già
   stabiliti (--success/--warning/--destructive/--primary) invece dei hex
   sparsi. Business logic invariata (stessi endpoint fetch/poll) — solo
   le stringhe HTML generate da renderSyncModal() riscritte per usare
   queste classi + Hugeicons al posto di emoji/simboli unicode (✓/✗/⟳/✅/⛔).
   ═══════════════════════════════════════════════════════════════════════ */

.sync-modal-content { text-align: left; }
.sync-modal-head { margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sync-modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 2px; }
.sync-modal-sub { font-size: 0.8rem; color: var(--muted-foreground); }
.sync-modal-timing { text-align: right; font-size: 0.75rem; color: var(--muted-foreground); line-height: 1.6; flex-shrink: 0; white-space: nowrap; }

.sync-progress-track { background: var(--muted); border-radius: 999px; height: 5px; margin-bottom: 12px; overflow: hidden; }
.sync-progress-fill { background: var(--primary); height: 100%; border-radius: 999px; transition: width .5s ease; }

.sync-step-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.sync-step-row:last-of-type { border-bottom: none; }
.sync-step-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted-foreground); }
.sync-step-icon.done  { color: var(--success); }
.sync-step-icon.error { color: var(--destructive); }
.sync-step-icon.active { color: var(--primary); animation: dsh-spin 1s linear infinite; }
.sync-step-text { flex: 1; min-width: 0; }
.sync-step-label { font-weight: 600; font-size: 0.88rem; }
.sync-step-desc { font-size: 0.75rem; color: var(--muted-foreground); }
.sync-step-sub { font-size: 0.75rem; color: var(--muted-foreground); flex-shrink: 0; white-space: nowrap; }
.sync-step-sub.done  { color: var(--success); }
.sync-step-sub.error { color: var(--destructive); }

.sync-modal-footer { margin-top: 18px; display: flex; justify-content: flex-end; }
.sync-modal-footer.two { gap: 10px; }
.sync-modal-footer.two .sc-btn { flex: 1; }

.sync-result { text-align: center; padding: 12px 0; }
.sync-result-icon { width: 44px; height: 44px; margin-bottom: 10px; }
.sync-result-icon.done  { color: var(--success); }
.sync-result-icon.error { color: var(--destructive); }
.sync-result-meta { margin-top: 6px; font-size: 0.78rem; color: var(--muted-foreground); }
.sync-result-note { margin-top: 8px; font-size: 0.75rem; color: var(--muted-foreground); opacity: .7; }

.sync-error-item { background: color-mix(in oklch, var(--destructive) 8%, transparent); border-radius: var(--radius-md); padding: 10px 14px; margin-top: 8px; font-size: 0.82rem; }
.sync-error-item strong { color: var(--destructive); }
.sync-error-msg { color: var(--muted-foreground); margin-top: 2px; }

.sync-client-link { color: var(--foreground); text-decoration: none; }
.sync-client-link:hover { text-decoration: underline; }
.sync-status-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.sync-status-value { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; font-size: 0.85rem; }
.sync-status-value.ok    { color: var(--success); }
.sync-status-value.warn  { color: var(--warning-foreground); }
.sync-status-value.error { color: var(--destructive); }
.sync-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.sync-status-dot.ok    { background: var(--success); }
.sync-status-dot.warn  { background: var(--warning); }
.sync-status-dot.error { background: var(--destructive); }
.sync-status-rel { font-size: 0.73rem; color: var(--muted-foreground); }
.sync-status-empty { color: var(--muted-foreground); font-size: 0.8rem; }

.sync-legend { margin-top: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 20px; font-size: 0.8rem; color: var(--muted-foreground); }
.sync-legend .sync-status-dot { margin-right: 5px; }
.sync-legend-note { margin-left: auto; }

/* ═══════════════════════════════════════════════════════════════════════
   SWITCH — reale da switch.tsx (letto in shadcn-dashboard-ref, appena
   aggiunto): h-[18.4px] w-[32px], thumb size-4(16px) rounded-full,
   bg-primary quando checked / bg-input quando unchecked, shadow-xs.
   Qui: input nativo nascosto + <span class="sc-switch-track"> come
   traccia, thumb via ::after sulla traccia (checkbox reale per la
   business logic, nessun listener JS aggiuntivo necessario).
   ═══════════════════════════════════════════════════════════════════════ */
.sc-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.sc-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sc-switch-track {
  display: inline-block; width: 32px; height: 18.4px; border-radius: 999px;
  background: var(--input); box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
  position: relative; transition: background .15s;
}
.sc-switch-track::after {
  content: ''; position: absolute; top: 1.2px; left: 1.2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--background); transition: transform .15s;
}
.sc-switch input:checked + .sc-switch-track { background: var(--primary); }
.sc-switch input:checked + .sc-switch-track::after { transform: translateX(calc(100% - 2px)); }
.sc-switch input:focus-visible + .sc-switch-track { box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent); }
/* sc-toggle-wrap / sc-toggle = alias di sc-switch / sc-switch-track */
.sc-toggle-wrap { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.sc-toggle-wrap input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sc-toggle { display: inline-block; width: 32px; height: 18.4px; border-radius: 999px; background: var(--input); box-shadow: 0 1px 2px 0 rgba(0,0,0,.05); position: relative; transition: background .15s; }
.sc-toggle::after { content: ''; position: absolute; top: 1.2px; left: 1.2px; width: 16px; height: 16px; border-radius: 50%; background: var(--background); transition: transform .15s; }
.sc-toggle-wrap input:checked + .sc-toggle { background: var(--primary); }
.sc-toggle-wrap input:checked + .sc-toggle::after { transform: translateX(calc(100% - 2px)); }
.sc-toggle-wrap input:focus-visible + .sc-toggle { box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 50%, transparent); }

/* ═══════════════════════════════════════════════════════════════════════
   UTENTI (users.list_users, route "/admin/users/") — ricostruita da
   zero riusando sc-/adv-. Markup: admin/users.html, JS interamente
   inline invariato (nessun fetch — ogni azione è un form POST classico,
   solo i selettori .scope-tab/.scope-panel/.filter-pill sono stati
   rinominati per usare le nuove classi, coerente col resto della
   sessione). Due modal (crea/modifica utente) multi-colonna: dialog
   generico esteso con .usr-dialog-wide per il layout più largo.
   ═══════════════════════════════════════════════════════════════════════ */

.usr-dialog-wide { max-width: 44rem; }
.usr-dialog-subtitle { font-size: 0.8125rem; color: var(--muted-foreground); margin: 2px 0 0; }

.usr-filter-bar { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.usr-filter-pill {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-4xl);
  padding: 3px 10px; font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.usr-filter-pill:hover { color: var(--foreground); }
.usr-filter-pill.active { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }

.usr-empty { color: var(--muted-foreground); font-size: 0.8rem; }
.usr-action-row { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.usr-inline-form { display: inline-flex; }
.usr-action-warn:hover  { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning-foreground); }
.usr-action-danger:hover { background: color-mix(in oklch, var(--destructive) 10%, transparent); color: var(--destructive); }
.usr-action-ok:hover     { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }

.usr-collapsible-header { cursor: pointer; }
.usr-muted-title { color: var(--muted-foreground); }
.usr-collapsible-chevron { width: 16px; height: 16px; color: var(--muted-foreground); transition: transform .2s ease; }
.usr-muted-row td { color: var(--muted-foreground); opacity: .7; }

.usr-modal-cols { display: flex; flex-direction: column; gap: 20px; margin-top: 8px; }
.usr-modal-col { flex: 1; min-width: 0; }
.usr-modal-col-pair { display: flex; gap: 20px; }
.usr-modal-col-pair .usr-modal-col { flex: 1; }
.usr-modal-col-title { font-size: 0.8125rem; font-weight: 600; color: var(--foreground); margin: 0 0 10px; }
.usr-field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.usr-field { flex: 1; min-width: 160px; }
.usr-field-hint { font-size: 0.75rem; color: var(--muted-foreground); margin: 4px 0 0; }
.usr-mono { font-family: monospace; font-size: 0.82rem; }

.usr-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.usr-toggle-label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; cursor: pointer; }

.usr-type-pills { display: flex; flex-direction: column; gap: 8px; }
.usr-type-pill {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 0.875rem; cursor: pointer; transition: background .15s, border-color .15s;
}
.usr-type-pill input { width: 16px; height: 16px; accent-color: var(--primary); }
.usr-type-pill:has(input:checked) { background: color-mix(in oklch, var(--primary) 10%, transparent); border-color: var(--primary); }

.usr-internal-block { padding: 12px; background: var(--muted); border-radius: var(--radius-md); }
.usr-reports-grid { display: flex; gap: 32px; flex-wrap: wrap; }
.usr-reports-toggles { min-width: 200px; }
.usr-reports-fields { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.usr-viewer-scope { color: var(--muted-foreground); font-size: .75rem; }
.usr-viewer-config { padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--muted); }
.usr-campaign-scope-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.usr-campaign-search { margin: .65rem 0; background: var(--card); }
.usr-campaign-scope {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .45rem;
  max-height: 15rem;
  overflow-y: auto;
  padding: .2rem;
}
.usr-campaign-option {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  min-width: 0;
  padding: .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
}
.usr-campaign-option:has(input:checked) { border-color: var(--primary); background: color-mix(in oklch, var(--primary) 8%, var(--card)); }
.usr-campaign-option input { flex: 0 0 auto; margin-top: .15rem; accent-color: var(--primary); }
.usr-campaign-option span { min-width: 0; }
.usr-campaign-option strong,
.usr-campaign-option small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usr-campaign-option strong { font-size: .78rem; }
.usr-campaign-option small { margin-top: .2rem; color: var(--muted-foreground); font-size: .67rem; }
@media (max-width: 760px) {
  .usr-campaign-scope { grid-template-columns: 1fr; }
  .usr-campaign-scope-head { align-items: stretch; flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════════════════
   REPORT SETTIMANALE — modal fullscreen di invio report (rimandato nel
   primo giro di ADV Performance, ricostruito ora). JS business logic
   invariata (stessi fetch verso /admin/report/preview|ai|ai-rewrite|send,
   stessa gestione coda) — riscritte solo le stringhe HTML generate
   (mkKpiCard/buildAdvCard/buildKlaviyoCard/success screen) per usare
   queste classi invece di rm-*, inline-style, colori hex hardcoded
   (#B7D63C/#141414/#e55/ecc.) e Hugeicons al posto delle emoji ✓/✗/●.
   Non è un <dialog> centrato piccolo come sc-dialog-content (troppo
   contenuto: KPI + piattaforme + AI + considerazioni + preview email) —
   resta un pannello fullscreen a due colonne, stile/token coerenti col
   resto del sistema (--content-shadow, --radius-xl, --success/--warning/
   --destructive per gli stati). ── */
.rm2-overlay { display: none; position: fixed; inset: 0; z-index: var(--layer-modal); background: rgba(0,0,0,.5); align-items: center; justify-content: center; }
.rm2-wrap { background: var(--card); border-radius: var(--radius-xl); box-shadow: var(--content-shadow); width: min(1400px, 94vw); height: 90vh; display: flex; flex-direction: column; overflow: hidden; }

.rm2-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rm2-header-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rm2-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm2-dates { font-size: 0.85rem; color: var(--muted-foreground); white-space: nowrap; }
.rm2-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Date picker "Data di riferimento" — versione minima a data singola
   dello stesso pattern visivo di _period_selector.html (ps-day/ps-month),
   ma classi indipendenti (rm2-dp-*): quel file è condiviso con
   client_detail.html, un rename lì romperebbe quella pagina, e qui serve
   comunque una versione senza preset/range, solo Annulla/Applica. ── */
.rm2-dp-wrap { position: relative; flex-shrink: 0; }
.rm2-dp-panel {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow);
  padding: 14px 16px 12px;
  z-index: var(--layer-modal-popover);
  width: 260px;
}
.rm2-dp-panel.open { display: block; }
.rm2-dp-cal-title { text-align: center; font-weight: 600; font-size: 0.875rem; margin-bottom: 8px; color: var(--foreground); display: flex; align-items: center; justify-content: space-between; }
.rm2-dp-nav { background: none; border: none; color: var(--muted-foreground); cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 1rem; }
.rm2-dp-nav:hover { color: var(--foreground); }
.rm2-dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.rm2-dp-dow { text-align: center; font-size: 0.7rem; color: var(--muted-foreground); padding: 2px 0 5px; text-transform: uppercase; }
.rm2-dp-day { text-align: center; padding: 5px 2px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; transition: background .1s, color .1s; border: none; background: none; color: var(--foreground); width: 100%; }
.rm2-dp-day:hover:not(:disabled) { background: var(--accent); }
.rm2-dp-day:disabled { cursor: default; color: var(--muted-foreground); opacity: .5; }
.rm2-dp-day.selected { background: var(--primary) !important; color: var(--primary-foreground) !important; font-weight: 600; }
.rm2-dp-day.today { font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--primary); }
.rm2-dp-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; margin-top: 8px; border-top: 1px solid var(--border); }

.rm2-loading { display: flex; align-items: center; justify-content: center; flex: 1; gap: 12px; color: var(--muted-foreground); }

.rm2-body { display: none; flex: 1; flex-direction: column; min-height: 0; }
/* Colonna destra (destinatari + anteprima email) rimossa: l'invio del
   report da questo modal non esiste più (solo "Salva" — l'email si invia
   altrove nel sistema). .rm2-left resta l'unico contenuto, ora a piena
   larghezza e in colonna così l'ultimo blocco (Considerazioni) può
   riempire lo spazio verticale residuo fino al fondo del modal. */
.rm2-left { flex: 1; min-width: 0; width: 100%; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; }

.rm2-section-label { font-size: 0.78rem; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .03em; }
.rm2-section-label.rm2-inline { text-transform: none; letter-spacing: normal; font-size: 0.8125rem; color: var(--foreground); }
.rm2-mt { margin-top: 20px; }
.rm2-optional { font-size: 0.72rem; color: var(--muted-foreground); }

.rm2-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.rm2-kpi-card { background: var(--muted); border-radius: var(--radius-md); padding: 12px; }
.rm2-kpi-card-label { font-size: 0.72rem; color: var(--muted-foreground); }
.rm2-kpi-card-val { font-size: 1.25rem; font-weight: 700; font-family: 'Work Sans', sans-serif; margin-top: 2px; }
.rm2-kpi-card-val.accent { color: var(--primary); }
.rm2-kpi-card-sub { font-size: 0.7rem; color: var(--muted-foreground); margin-top: 2px; }

/* Piattaforme: solo card reali (nessun placeholder invisibile), il
   numero effettivo (1-4, via data-count impostato dal JS) decide il
   grid — su una riga a piena larghezza fino a 3, 2×2 solo con 4, così
   il blocco occupa sempre la stessa larghezza del resto dei contenuti
   (come le card di Riepilogo) invece di lasciare metà riga vuota. */
.rm2-plat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.rm2-plat-grid[data-count="1"] { grid-template-columns: 1fr; }
.rm2-plat-grid[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.rm2-plat-card { background: var(--muted); border-radius: var(--radius-md); padding: 12px; }
.rm2-plat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rm2-plat-camp { font-size: 0.72rem; color: var(--muted-foreground); }
.rm2-plat-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rm2-plat-metric { display: flex; flex-direction: column; gap: 1px; }
.rm2-plat-label { font-size: 0.7rem; color: var(--muted-foreground); }
.rm2-plat-val { font-size: 0.9rem; font-weight: 600; }
.rm2-plat-val.accent { color: var(--primary); }
.rm2-plat-val.muted { color: var(--muted-foreground); font-weight: 400; }
.rm2-roas-green  { color: var(--success); }
.rm2-roas-yellow { color: var(--warning-foreground); }
.rm2-roas-red    { color: var(--destructive); }

.rm2-block { margin-top: 20px; }
.rm2-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rm2-block-head-left { display: flex; align-items: center; gap: 8px; }
/* Ultimo blocco della colonna (Considerazioni & Next Steps): riempie
   tutto lo spazio verticale residuo fino al fondo del modal invece di
   restare alla sua altezza minima — richiesta esplicita. flex:1 sul
   blocco + sulla textarea, min-height:0 necessario perché altrimenti
   un figlio flex non si restringe mai sotto il proprio content-size,
   impedendo lo scroll/overflow corretto del contenitore padre. */
.rm2-block.rm2-considerations-block { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.rm2-considerations { flex: 1; min-height: 100px; resize: none; }

.rm2-history-body { max-height: 50vh; overflow-y: auto; }

@media (max-width: 900px) {
  /* Le regole [data-count] hanno specificità maggiore di .rm2-plat-grid
     da sola (classe+attributo > classe) e vincerebbero anche qui sotto
     900px se non replicato lo stesso selettore — serve lo stesso identico
     attribute selector per riportare a 1 colonna su mobile a qualunque
     conteggio di card. */
  .rm2-plat-grid,
  .rm2-plat-grid[data-count="1"],
  .rm2-plat-grid[data-count="2"],
  .rm2-plat-grid[data-count="3"],
  .rm2-plat-grid[data-count="4"] { grid-template-columns: 1fr; }
  /* Header del modal invio report: titolo + fino a 3 bottoni (Annulla/
     Salva/Salva e invia) + stato invio non ci stanno su una riga sotto
     900px — flex-shrink:0 sui bottoni impediva qualunque restringimento,
     causando overflow orizzontale reale. Va a capo su due righe. */
  .rm2-header { flex-wrap: wrap; }
  .rm2-header-actions { flex-wrap: wrap; width: 100%; justify-content: flex-end; }
}

/* ═══════════════════════════════════════════════════════════════════════
   CLIENT DETAIL (Performance → dettaglio cliente) — namespace "cd-".
   Riusa dove possibile i primitivi già esistenti (sc-card, adv-table,
   adv-table-wrap, adv-empty-inline, sc-badge, adv-platform-badge,
   sc-tabs-track/item): qui solo ciò che è genuinamente specifico di
   questa pagina (KPI con breakdown+delta, card comprimibili, drill-down
   ad-set, filtri campagne).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── KPI con pillole di breakdown + delta vs confronto ── */
.cd-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cd-kpi-card { position: relative; }
.cd-kpi-conv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cd-kpi-conv-breakdown { display: flex; gap: 6px; flex-wrap: wrap; }
.cd-kpi-pill { font-size: 0.68rem; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-4xl); background: var(--muted); color: var(--muted-foreground); white-space: nowrap; }
.cd-kpi-pill.forms { background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); }
.cd-kpi-pill.whatsapp { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.cd-kpi-delta { position: absolute; top: 12px; right: 14px; font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: var(--radius-4xl); background: var(--muted); color: var(--muted-foreground); }
.cd-kpi-delta.up { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.cd-kpi-delta.dn { background: color-mix(in oklch, var(--destructive) 12%, transparent); color: var(--destructive); }

/* ── Card comprimibile (grafico, tabelle settimanali, klaviyo, campagne) ── */
.cd-card { margin-bottom: 1rem; }
/* flex-direction:row esplicito: .sc-card-header (da cui eredita) è column,
   e senza override align-items:center centra i figli in orizzontale invece
   di allinearli verticalmente su una riga — bug reale, titoli tipo
   "Suggerimenti AI" apparivano centrati invece che a sinistra. */
.cd-card-header { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; user-select: none; }
.cd-card-header.static { cursor: default; }
.cd-card-title { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; }
.cd-collapse-arrow { color: var(--muted-foreground); font-size: 0.75rem; transition: transform .15s; display: inline-block; }
.cd-collapse-arrow.collapsed { transform: rotate(-90deg); }
.cd-card-body { overflow: hidden; }
.cd-card-body.collapsed { display: none; }
.cd-expand-btn { flex-shrink: 0; }

/* ── Tabelle settimanali: righe/celle specifiche non coperte da .adv-table ── */
.cd-week-label { white-space: nowrap; }
.cd-current-tag { margin-left: 6px; font-size: 0.68rem; font-weight: 600; padding: 1px 7px; border-radius: var(--radius-4xl); background: color-mix(in oklch, var(--primary) 15%, transparent); color: var(--primary); }
.cd-table tr.current-week { background: color-mix(in oklch, var(--primary) 6%, transparent); }
.cd-table tr.row-expandable { cursor: pointer; }
.cd-table tr.row-expandable:hover { background: var(--accent); }
.cd-table td.conv-val { font-weight: 600; color: var(--primary); }
.cd-delta { font-size: 0.68rem; margin-left: 4px; }
.cd-delta.up { color: var(--success); }
.cd-delta.dn { color: var(--destructive); }
.cd-delta.n  { color: var(--muted-foreground); }
.cd-lm-th, .cd-lm-cell { color: var(--muted-foreground); }

/* ── Badge stato campagna/ad set (attiva / in pausa) ── */
.cd-status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 500; padding: 2px 9px; border-radius: var(--radius-4xl); }
.cd-status-badge.active { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.cd-status-badge.paused { background: var(--muted); color: var(--muted-foreground); }

/* ── Filtri campagne (segmented pill, stesso pattern di sc-tabs-*) ── */
.cd-filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 1rem; }
#campFilters { box-sizing: border-box; padding-inline: 1.5rem; }
@media (max-width: 768px) { #campFilters { padding-inline: 1rem; } }
.cd-filter-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
/* In lead_sheet_page.html .cd-filter-bar è l'ultimo figlio di
   .sc-page-fixed (qui, non in client_detail.html dove sta nel body
   scrollabile): il suo margin-bottom si sommerebbe a quello del wrapper
   (stesso bug di .adv-tabs/.adv-kpi-grid/.ls-toolbar) — azzerato solo in
   questo caso specifico. */
.sc-page-fixed > .cd-filter-bar:last-child { margin-bottom: 0; }
.cd-filter-pill { display: inline-flex; align-items: center; gap: 6px; height: 1.75rem; padding: 0 12px; border-radius: var(--radius-4xl); background: var(--muted); color: var(--muted-foreground); font-size: 0.8rem; font-weight: 500; border: none; cursor: pointer; transition: background .12s, color .12s; }
.cd-filter-pill:hover { color: var(--foreground); }
.cd-filter-pill.active { background: var(--primary); color: var(--primary-foreground); }
.cd-platform-dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: var(--muted-foreground); }
.cd-platform-dot.meta { background: #1877f2; }
.cd-platform-dot.google { background: #34a853; }
.cd-platform-dot.tiktok { background: #111; }
.cd-filter-pill.active .cd-platform-dot { background: currentColor; }
.cd-campaign-filter { gap: 6px; }
.cd-campaign-filter.active .cd-platform-dot { background: currentColor; }

/* ── Riga campagna cliccabile + drill-down ad set ── */
.cd-camp-row { cursor: pointer; }
.cd-camp-row.muted-row { opacity: .55; }
.cd-campaign-name { display: flex; align-items: center; gap: 6px; }
.cd-camp-chevron { display: inline-block; font-size: 0.65rem; color: var(--muted-foreground); transition: transform .15s; }
.cd-camp-chevron.open { transform: rotate(90deg); }
.cd-adsets-cell { padding: 0 !important; border-bottom: 1px solid var(--border); }
.cd-adsets-inner { padding: 10px 20px; background: var(--muted); }
.cd-adsets-loading, .cd-adsets-empty { padding: 12px 0; color: var(--muted-foreground); font-size: 0.82rem; }
.cd-adset-name { padding-left: 18px; }
.cd-ad-name { padding-left: 34px; color: var(--muted-foreground); font-size: 0.78rem; }
.cd-ads-list-row td { padding: 0 !important; border-top: none !important; }

/* ── Sezioni (Lead Gen / E-Commerce) ── */
.cd-section { margin-bottom: 0; }
.cd-section-header { margin-bottom: 0.75rem; }
.cd-section-title { font-size: 0.95rem; font-weight: 700; }

/* ── Modal fullscreen storico tabella (riusa il pattern rm2-overlay) ── */
.cd-modal-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; }
.cd-modal-loading { padding: 40px; text-align: center; color: var(--muted-foreground); }

@media (max-width: 900px) {
  .cd-kpi-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .cd-kpi-grid { grid-template-columns: 1fr; }
}

/* ── Verifica fatture saldate: confronto FIC → Airtable ── */
.sync-empty-icon.is-loading svg,
#paid-check-btn.is-loading svg,
#paid-sync-btn.is-loading svg { animation: spin 1s linear infinite; transform-origin: center; }
.paid-results-card .sc-select { width: 125px; height: 32px; font-size: .75rem; }
.paid-table { min-width: 900px; table-layout: fixed; }
.paid-table th { top: 0; }
.paid-table th:nth-child(1), .paid-table td:nth-child(1) { width: 46px; text-align: center; }
.paid-table th:nth-child(2), .paid-table td:nth-child(2) { width: 130px; }
.paid-table th:nth-child(3), .paid-table td:nth-child(3) { width: 120px; }
.paid-table th:nth-child(4), .paid-table td:nth-child(4) { width: auto; }
.paid-table th:nth-child(5), .paid-table td:nth-child(5) { width: 130px; }
.paid-table th:nth-child(6), .paid-table td:nth-child(6) { width: 120px; text-align: right; white-space: nowrap; }
.paid-table th:nth-child(7), .paid-table td:nth-child(7) { width: 145px; text-align: center; }
.paid-row-check { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.paid-invoice-number { font-weight: 650; font-variant-numeric: tabular-nums; }
.paid-client-name { font-weight: 500; }
.paid-no-filter-results { height: 180px !important; color: var(--muted-foreground); text-align: center !important; }
@media (max-width: 760px) {
  .paid-results-card .sc-select { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════
   LEAD SHEET (admin/lead_sheet_page.html, client-facing variant incluso)
   — namespace "ls-" per la pagina/tabella, "ld-" per il modal di dettaglio
   lead, "pb-" per il pipeline builder. Riusa sc-/adv-/cd- dove il pattern
   è identico (badge stage → cd-status-badge/cd-filter-pill, modal grandi
   → rm2-overlay/rm2-wrap/cd-modal-scroll, modal medi → sc-dialog).
   ═══════════════════════════════════════════════════════════════════════ */

.ls-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.ls-toolbar .sc-input { flex: 1; min-width: 0; }

.ls-table-card { flex: 1; min-height: 0; }
.ls-table-card .adv-table-wrap { max-width: 100%; }
#lsTable th, #lsTable td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
#lsTable td:first-child, #lsTable th:first-child { max-width: 34px; }
.ls-sort-header { cursor: pointer; user-select: none; }
.ls-row-new { background: color-mix(in oklch, var(--primary) 8%, transparent); }
.ls-row-highlight { animation: ls-highlight-fade 2.5s ease-out forwards; }
@keyframes ls-highlight-fade { 0%,20% { background: color-mix(in oklch, #f59e0b 22%, transparent); } 100% { background: transparent; } }

/* pill di stato riga (stessa forma di cd-status-badge, colore data-driven inline) */
.ls-stage-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-4xl); }
.ls-stage-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ls-stage-pill.closed { background: color-mix(in oklch, var(--destructive) 15%, transparent); color: var(--destructive); }

.ls-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.ls-footer-total { color: var(--muted-foreground); font-size: 0.85rem; }
.ls-pagination { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ls-pagination .sc-btn { padding: 0 10px; font-size: 0.8rem; height: 1.9rem; }
.ls-page-info { font-size: 0.82rem; color: var(--muted-foreground); white-space: nowrap; }
.ls-perpage-select { padding: 4px 6px; font-size: 0.8rem; width: auto; height: 1.9rem; }
.ls-bulk-bar { display: none; gap: 8px; align-items: center; flex-shrink: 0; }
.ls-bulk-bar.visible { display: flex; }
.ls-bulk-count { color: var(--foreground); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* ── Modal dettaglio lead (rm2 pattern + card note laterale) ── */
/* .ld-shell non ha posizionamento proprio: dipende dal display:flex del genitore
   per centrarsi (larghezza fino a 960px, non adatta al pattern sc-dialog-content
   che è pensato per dialog piccoli centrati con transform). Classe dedicata invece
   di riusare .modal-overlay (style.css): stesso comportamento di centering/backdrop,
   ma senza dipendere dal sistema di design legacy. */
.ld-modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: var(--layer-modal);
  background: rgba(0,0,0,.1);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 20px;
}
.ld-modal-overlay.open { display: flex; }
.ld-shell { display: flex; flex-direction: column; gap: 12px; width: min(96vw, 960px); }
.ld-close-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #fff;
  font-size: 0.82rem; font-weight: 500; cursor: pointer; backdrop-filter: blur(4px); transition: background .15s;
}
.ld-close-btn:hover { background: rgba(255,255,255,.18); }
.ld-modal { width: 100%; height: min(80vh, 700px); display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--card); border-radius: var(--radius-xl); box-shadow: var(--content-shadow); }
.ld-pipeline-wrap { padding: 16px 24px 0; flex-shrink: 0; }
.ld-header { padding: 16px 24px 0; flex-shrink: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ld-name { font-size: 1.15rem; font-weight: 700; color: var(--foreground); line-height: 1.2; }
.ld-meta { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 3px; }
.ld-tabbar { padding: 12px 24px 0; flex-shrink: 0; display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.ld-tab { padding: 8px 16px; font-size: 0.85rem; font-weight: 500; background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted-foreground); cursor: pointer; white-space: nowrap; margin-bottom: -1px; transition: color .12s, border-color .12s; }
.ld-tab.active { font-weight: 600; border-bottom-color: var(--primary); color: var(--primary); }
.ld-tab.locked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  opacity: .48;
  cursor: not-allowed;
}
.ld-tab.locked .ld-tab-label { filter: blur(.55px); }
.ld-tab.locked > svg { width: 12px; height: 12px; filter: none; }
.ld-tabcontent { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 24px; }
.ld-footer { flex-shrink: 0; padding: 12px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-start; }

.ld-notes-card { width: 100%; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; max-height: 280px; background: var(--card); border-radius: var(--radius-xl); box-shadow: var(--content-shadow); }
.ld-notes-title { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); }
.ld-note-row { display: flex; gap: 8px; align-items: flex-end; }
.ld-note-input { flex: 1; resize: none; }
.ld-notes-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.ld-note-item { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--secondary); }
.ld-note-body { flex: 1; min-width: 0; }
.ld-note-text { font-size: 0.8rem; color: var(--foreground); white-space: pre-wrap; word-break: break-word; }
.ld-note-meta { font-size: 0.72rem; color: var(--muted-foreground); margin-top: 3px; }
.ld-note-del { flex-shrink: 0; background: none; border: none; cursor: pointer; color: var(--muted-foreground); padding: 2px 4px; border-radius: 4px; line-height: 1; }
.ld-note-del:hover { color: var(--destructive); }
.ld-notes-empty { font-size: 0.8rem; color: var(--muted-foreground); padding: 4px 0; }

/* ── Campi form nel tab dettaglio (grid 1 colonna, label uppercase) ── */
.ld-section { margin-bottom: 20px; }
.ld-section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-foreground); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ld-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ld-field-wrap { display: flex; flex-direction: column; gap: 2px; }
.ld-field-wrap.full { grid-column: 1 / -1; }
.ld-field-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); display: block; margin-bottom: 4px; }
.ld-field-input { font-family: inherit; }
.ld-field-input.readonly { background: var(--muted); color: var(--muted-foreground); border-color: transparent; }
.ld-field-checkbox-row { display: flex; align-items: center; gap: 8px; padding: 8px 2px; cursor: pointer; font-size: 0.88rem; }
.ld-empty-hint { color: var(--muted-foreground); font-size: 0.85rem; }
.ld-phone-row { display: flex; align-items: center; gap: 6px; }
.ld-phone-call-btn { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--muted); color: var(--muted-foreground); text-decoration: none; transition: color .15s, border-color .15s, background .15s; }
.ld-phone-call-btn:hover { color: var(--success); border-color: var(--success); background: color-mix(in oklch, var(--success) 8%, transparent); }
.ld-readonly-id { background: var(--muted); border: 1px solid transparent; border-radius: 6px; padding: 8px 10px; color: var(--muted-foreground); font-family: monospace; font-size: 0.82rem; }

/* ── Card di campi nel modal lead ──────────────────────────────────────── */
/* I gruppi sono una sola regola visuale riutilizzabile: non cambiano tab,
   dati o permessi del campo. Titolo e icona seguono il pattern delle tabelle
   CRM, senza kicker/ellipsis decorativi. */
.ld-field-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.ld-field-card { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.ld-field-card-title { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-bottom: 14px; font-size: .9rem; font-weight: 650; color: var(--foreground); }
.ld-field-card-title svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--primary); }
.ld-field-card .ld-grid { gap: 14px; }

/* Nei modal desktop ogni card usa lo spazio disponibile senza dilatare
   inutilmente i campi brevi: Nome/Cognome e coppie data/stato restano
   affiancati; indirizzi (classe .full) mantengono tutta la riga. */
@media (min-width: 720px) {
  .ld-field-card .ld-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; row-gap: 12px; }
}

/* ── Lab26 admin: contesto pubblicitario nel tab Acquisizione ── */
.ld-acq-loading, .ld-acq-empty { padding: 18px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted-foreground); font-size: .82rem; margin-bottom: 18px; }
.ld-acq-spinner { display: inline-block; width: 13px; height: 13px; margin-right: 7px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; vertical-align: -2px; animation: ldAcqSpin .8s linear infinite; }
@keyframes ldAcqSpin { to { transform: rotate(360deg); } }
.ld-acq-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--muted); margin-bottom: 14px; }
.ld-acq-kicker { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-foreground); margin-bottom: 4px; }
.ld-acq-title { font-size: 1rem; font-weight: 750; color: var(--foreground); }
.ld-acq-sub { font-size: .76rem; color: var(--muted-foreground); margin-top: 3px; }
.ld-acq-badge { flex-shrink: 0; border-radius: 999px; padding: 4px 9px; font-size: .68rem; font-weight: 700; }
.ld-acq-badge.exact { color: var(--success); background: color-mix(in oklch, var(--success) 12%, transparent); border: 1px solid color-mix(in oklch, var(--success) 25%, transparent); }
.ld-acq-badge.probable { color: var(--warning-foreground); background: color-mix(in oklch, var(--warning) 12%, transparent); border: 1px solid color-mix(in oklch, var(--warning) 25%, transparent); }
.ld-acq-main { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 18px; margin-bottom: 14px; }
.ld-acq-visual { min-height: 220px; border-radius: 10px; overflow: hidden; background: #080808; border: 1px solid var(--border); }
.ld-acq-creative-link { position: relative; display: block; height: 100%; min-height: 220px; color: #fff; text-decoration: none; }
.ld-acq-creative-img { display: block; width: 100%; height: 300px; object-fit: cover; object-position: center; }
.ld-acq-creative-link span { position: absolute; left: 8px; bottom: 8px; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,.72); font-size: .68rem; font-weight: 650; }
.ld-acq-image-missing { min-height: 220px; display: grid; place-items: center; padding: 14px; color: #aaa; font-size: .76rem; }
.ld-acq-context { min-width: 0; padding: 4px 0; }
.ld-acq-headline { font-size: 1.15rem; font-weight: 780; line-height: 1.25; margin-bottom: 8px; }
.ld-acq-dynamic { font-size: .72rem; line-height: 1.4; color: var(--muted-foreground); padding: 7px 9px; border-radius: 7px; background: var(--muted); margin-bottom: 10px; }
.ld-acq-landing { display: block; color: var(--primary); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 16px; }
.ld-acq-path { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
.ld-acq-path div { min-width: 0; padding: 10px 11px; border: 1px solid var(--border); border-radius: 8px; }
.ld-acq-path span { display: block; color: var(--muted-foreground); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
.ld-acq-path strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.ld-acq-details { border-top: 1px solid var(--border); padding: 11px 0 4px; margin-bottom: 20px; }
.ld-acq-details summary { cursor: pointer; color: var(--muted-foreground); font-size: .76rem; font-weight: 650; }
.ld-acq-copy { display: grid; grid-template-columns: 60px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .76rem; line-height: 1.45; }
.ld-acq-copy strong { color: var(--muted-foreground); }
.ld-acq-copy span { white-space: pre-wrap; }
.ld-acq-technical { margin-top: 10px; color: var(--muted-foreground); font-family: monospace; font-size: .68rem; word-break: break-all; }
.ld-google-preview { padding: 18px 20px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.ld-google-sponsored { color: var(--foreground); font-size: .72rem; margin-bottom: 7px; }
.ld-google-title { color: #1a0dab; font-size: 1.18rem; font-weight: 500; line-height: 1.3; margin-bottom: 6px; }
body.dark-mode .ld-google-title { color: #8ab4f8; }
.ld-google-description { color: var(--foreground); font-size: .82rem; line-height: 1.5; margin-bottom: 10px; }
.ld-google-preview .ld-acq-dynamic { margin: 12px 0 10px; }
.ld-google-preview .ld-acq-landing { margin-bottom: 0; }
@media (max-width: 700px) {
  .ld-acq-main { grid-template-columns: 1fr; }
  .ld-acq-visual, .ld-acq-creative-link { min-height: 180px; }
  .ld-acq-creative-img { height: 260px; }
  .ld-acq-path { grid-template-columns: 1fr; }
}

/* ── Pipeline bar (dentro il modal dettaglio) ── */
.ld-pipe-empty { border: 2px dashed var(--border); border-radius: 10px; padding: 12px 18px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted-foreground); font-size: 0.82rem; font-weight: 500; cursor: pointer; transition: border-color .15s; user-select: none; }
.ld-pipe-empty:hover { border-color: var(--primary); }
.ld-pipe-empty-dots { display: flex; align-items: center; gap: 5px; margin-left: 8px; opacity: .35; }
.ld-pipe-empty-dot { width: 22px; height: 22px; border: 2px dashed currentColor; border-radius: 50%; display: inline-flex; }
.ld-pipe-empty-line { width: 18px; height: 0; border-top: 2px dashed currentColor; }
.ld-pipe-closed { display: flex; align-items: center; gap: 10px; }
.ld-pipe-closed-hint { font-size: 0.75rem; color: var(--muted-foreground); }
.ld-pipe-track { display: flex; align-items: stretch; gap: 0; width: 100%; }
.ld-pipe-step-wrap { display: flex; align-items: center; cursor: pointer; flex: 1; min-width: 0; gap: 0; }
.ld-pipe-step { flex: 1; min-width: 0; padding: 8px 6px; font-size: 0.73rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; border-radius: 20px; transition: all .15s; user-select: none; }
.ld-pipe-connector { flex: 0 0 12px; height: 2px; align-self: center; }

/* ── Pipeline builder (sc-dialog, larghezza custom) ── */
.pb-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.pb-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; background: var(--muted); border-radius: 8px; padding: 8px 10px; }
.pb-row.locked { opacity: .7; }
.pb-drag-handle { cursor: grab; color: var(--muted-foreground); font-size: 1.1rem; user-select: none; flex-shrink: 0; }
.pb-swatch-wrap { display: flex; align-items: center; flex-shrink: 0; cursor: pointer; position: relative; }
.pb-swatch { width: 20px; height: 20px; border-radius: 50%; display: inline-block; border: 2px solid var(--border); }
.pb-color-input { position: absolute; opacity: 0; width: 0; height: 0; }
.pb-name-input { flex: 1; min-width: 0; }
.pb-lock-icon { flex-shrink: 0; color: var(--muted-foreground); display: inline-flex; }
.pb-label-muted { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--muted-foreground); }
.pb-hint { font-size: 0.75rem; color: var(--muted-foreground); flex-shrink: 0; }
.pb-required { width: 100%; margin-left: 28px; padding: 8px 10px; border-top: 1px solid var(--border); }
.pb-required summary { cursor: pointer; font-size: .78rem; font-weight: 650; color: var(--muted-foreground); }
.pb-required-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px 12px; padding-top: 10px; }
.pb-required-option { display: flex; align-items: center; gap: 7px; font-size: .78rem; cursor: pointer; }
.pb-required-option input { width: 14px; height: 14px; }
.pb-add-link { display: inline-block; margin-top: 12px; color: var(--primary); font-size: 0.85rem; font-weight: 600; flex-shrink: 0; }
.pb-intro { color: var(--muted-foreground); font-size: 0.83rem; margin: 0 0 16px; flex-shrink: 0; }

/* ── Modal grandi (CSV import / gestisci colonne): riuso rm2-overlay +
   rm2-wrap + cd-modal-scroll, solo bit specifici qui ── */
.ls-modal-footer { margin-top: 0; flex-shrink: 0; display: flex; justify-content: flex-end; gap: 8px; align-items: center; padding: 12px 24px; border-top: 1px solid var(--border); }
.ls-csv-summary { color: var(--muted-foreground); font-size: 0.85rem; margin: 0 0 14px; flex-shrink: 0; }
.ls-csv-preview-wrap { max-height: 140px; overflow: auto; margin-bottom: 14px; }
.ls-csv-bulk-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ls-csv-sep { color: var(--border); }
.ls-csv-bulk-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 4px 10px; font-size: 0.75rem; color: var(--muted-foreground); cursor: pointer; transition: color .12s, border-color .12s; }
.ls-csv-bulk-btn:hover { color: var(--foreground); border-color: var(--primary); }
.ls-csv-new-badge { font-size: 0.68rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: color-mix(in oklch, var(--primary) 15%, transparent); color: var(--primary); white-space: nowrap; margin-left: 6px; }
.ls-csv-existing-badge { font-size: 0.68rem; padding: 1px 6px; border-radius: 4px; background: var(--muted); color: var(--muted-foreground); white-space: nowrap; margin-left: 6px; }
.ls-cols-drag { cursor: grab; color: var(--muted-foreground); text-align: center; user-select: none; }

/* ── Preferenze colonne account cliente ── */
.ls-client-cols-dialog {
  width: min(760px, calc(100vw - 2rem));
  max-width: 760px;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.ls-client-cols-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.ls-client-cols-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--foreground);
  font-size: 1.05rem;
  font-weight: 700;
}
.ls-client-cols-title svg { width: 18px; height: 18px; }
.ls-client-cols-header p {
  margin: 5px 0 0;
  color: var(--muted-foreground);
  font-size: .8rem;
}
.ls-client-cols-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 18px 22px;
  min-height: 300px;
  overflow-y: auto;
}
.ls-client-cols-panel {
  display: flex;
  min-width: 0;
  min-height: 260px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
}
.ls-client-cols-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
  font-size: .8rem;
  font-weight: 650;
}
.ls-client-cols-count {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-4xl);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: .7rem;
}
.ls-client-cols-list {
  flex: 1;
  min-height: 210px;
  padding: 8px;
  overflow-y: auto;
  background: color-mix(in oklch, var(--muted) 35%, transparent);
  transition: background .12s, box-shadow .12s;
}
.ls-client-cols-list:empty::after {
  content: "Trascina qui";
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted-foreground);
  font-size: .76rem;
}
.ls-client-cols-list.drag-over {
  background: color-mix(in oklch, var(--primary) 8%, transparent);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.ls-client-col-item {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  padding: 9px 9px 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  cursor: grab;
  user-select: none;
}
.ls-client-col-item:last-child { margin-bottom: 0; }
.ls-client-col-item.dragging { opacity: .45; }
.ls-client-col-grip {
  flex-shrink: 0;
  color: var(--muted-foreground);
  font-size: 1rem;
  line-height: 1;
}
.ls-client-col-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: .8rem;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ls-client-col-move {
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.ls-client-col-move:hover {
  background: var(--muted);
  color: var(--foreground);
}
.ls-client-col-move svg { width: 15px; height: 15px; }
.ls-client-cols-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 22px;
  border-top: 1px solid var(--border);
}
@media (max-width: 680px) {
  .ls-client-cols-dialog { max-height: calc(100vh - 2rem); }
  .ls-client-cols-grid { grid-template-columns: 1fr; min-height: 0; }
  .ls-client-cols-panel { min-height: 190px; }
  .ls-client-cols-list { min-height: 140px; }
}

/* ── Formula column builder (inline) ── */
.cm-formula-preview { font-size: .78rem; color: var(--muted-foreground); font-family: monospace; display: block; padding: 2px 0; }

/* ── Formula Builder Modal ── */
.formula-modal-wrap { width: min(860px, calc(100vw - 3rem)); max-height: calc(100vh - 6rem); display: flex; flex-direction: column; }
.formula-modal-body { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; min-height: 0; }
.fm-section { display: flex; flex-direction: column; gap: 6px; }
.fm-input-wrap { display: flex; align-items: flex-start; gap: 0; }
.fm-eq { font-family: monospace; font-size: 1.1rem; font-weight: 700; color: var(--primary); padding: 6px 6px 6px 10px; background: var(--muted); border: 1px solid var(--border); border-right: none; border-radius: var(--radius) 0 0 var(--radius); line-height: 1.5rem; flex-shrink: 0; }
.fm-expr { flex: 1; border-radius: 0 var(--radius) var(--radius) 0; font-family: monospace; font-size: .88rem; resize: vertical; min-height: 4rem; }
.fm-preview { font-size: .8rem; padding: 6px 10px; border-radius: var(--radius); background: color-mix(in oklch, var(--success) 10%, transparent); color: var(--success); border: 1px solid color-mix(in oklch, var(--success) 25%, transparent); font-family: monospace; }
.fm-two-col { display: grid; grid-template-columns: 1fr 1.6fr; gap: 1rem; }
@media (max-width: 640px) { .fm-two-col { grid-template-columns: 1fr; } }
.fm-panel { display: flex; flex-direction: column; gap: 6px; }
.fm-panel-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.fm-fn-groups { display: flex; flex-direction: column; gap: 4px; }
.fm-fn-group-label { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); opacity: .7; margin-top: 4px; }
.fm-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.fm-chip { display: inline-flex; align-items: center; height: 1.625rem; padding: 0 9px; border-radius: var(--radius-4xl); font-size: .75rem; font-weight: 600; border: none; cursor: pointer; transition: background .1s, color .1s; white-space: nowrap; }
.fm-col  { background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); }
.fm-col:hover  { background: color-mix(in oklch, var(--primary) 22%, transparent); }
.fm-fn   { background: var(--muted); color: var(--foreground); font-family: monospace; }
.fm-fn:hover   { background: color-mix(in oklch, var(--foreground) 12%, transparent); }
.fm-op   { background: color-mix(in oklch, var(--warning) 12%, transparent); color: var(--warning); font-family: monospace; font-size: .82rem; }
.fm-op:hover   { background: color-mix(in oklch, var(--warning) 22%, transparent); }
.fm-str  { font-family: monospace; }
.fm-op-chips { gap: 5px; }
.fm-trigger-wrap { display: flex; flex-direction: column; gap: 8px; }
.fm-radio-row { display: flex; align-items: center; gap: 8px; font-size: .85rem; cursor: pointer; }
.fm-radio-row input[type="radio"] { flex-shrink: 0; }
.fm-inline-num { width: 4.5rem !important; height: 1.75rem; padding: 0 6px; text-align: center; font-size: .85rem; }
.fm-inline-select { height: 1.75rem; font-size: .82rem; padding: 0 6px; }
.fm-tooltip-bar { font-size: .78rem; color: var(--muted-foreground); padding: 4px 8px; background: var(--muted); border-radius: var(--radius); font-family: monospace; }

/* ── Inserisci lead manuale (sc-dialog) ── */
.ml-field-wrap { display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 640px) {
  .ld-shell { width: 96vw; }
  /* Le tab del modal lead possono superare la larghezza di uno smartphone:
     devono restare raggiungibili con uno swipe, non tagliate dal modal. */
  .ld-tabbar { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .ld-tabbar::-webkit-scrollbar { display: none; }
  .ld-modal { height: 88vh; }
  .ld-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════
   IMPOSTAZIONI (admin/settings.html) — namespace "set-". Riusa sc-/adv-/
   usr- dove il pattern è identico (tabella CRUD utenti CRM → adv-table +
   usr-action-row, modal modifica → sc-dialog, campi form → usr-field +
   sc-label/sc-input/sc-select): qui solo avatar iniziali e wrapper form
   dei pannelli Profilo/Sistema, non coperti altrove.
   ═══════════════════════════════════════════════════════════════════════ */
.set-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; color: #1a1a1a; flex-shrink: 0;
}
/* padding orizzontale only: .sc-card fornisce già 1.5rem top/bottom
   (padding: 1.5rem 0), coerente con sc-card-content/sc-card-header. */
.set-form { display: flex; flex-direction: column; gap: 16px; padding: 0 1.5rem; }
.set-save-msg { font-size: 0.82rem; }

/* ═══════════════════════════════════════════════════════════════════════
   CALL RECAP (admin/calls_list.html, call_detail.html, calls_settings.html)
   — namespace "cl-". Riusa sc-/adv-/usr- dove il pattern è identico
   (lista → adv-table, form connessione → usr-field/sc-input, badge stato
   → sc-badge): qui solo i pezzi specifici (meta grid dettaglio call,
   partecipanti, recap AI markdown, checklist step, transcript, stato
   connessione Fathom).
   ═══════════════════════════════════════════════════════════════════════ */
.cl-list-count { font-size: 0.8rem; color: var(--muted-foreground); font-weight: 400; margin-left: 8px; }
.cl-th-ai { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cl-th-ai svg { width: 12px; height: 12px; color: var(--primary); flex-shrink: 0; }
.cl-title-cell { font-weight: 500; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cl-import-status { color: var(--muted-foreground); font-size: 0.9rem; }
.cl-progress-track { background: var(--muted); border-radius: 999px; height: 8px; overflow: hidden; margin-top: 12px; }
.cl-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.cl-progress-label { font-size: 0.85rem; color: var(--muted-foreground); text-align: right; margin-top: 8px; }

.cl-detail-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cl-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; padding: 0 1rem; }
.cl-meta-label { color: var(--muted-foreground); font-size: 0.8125rem; margin-bottom: 4px; }
.cl-meta-value { font-weight: 600; }

.cl-participants { display: flex; flex-direction: column; padding: 0 1rem; }
.cl-participant-row { padding: 10px 0; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.cl-participant-row:last-child { border-bottom: none; }
.cl-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.85rem; flex-shrink: 0; }
.cl-participant-name { font-weight: 500; }
.cl-participant-email { font-size: 0.85rem; color: var(--muted-foreground); }

.cl-summary-source { font-size: 0.8rem; color: var(--muted-foreground); flex-shrink: 0; }
.cl-summary { padding: 0 1rem; line-height: 1.7; color: var(--muted-foreground); }
.cl-summary h2 { font-size: 1rem; font-weight: 700; margin: 16px 0 6px; color: var(--foreground); }
.cl-summary h3 { font-size: 0.95rem; font-weight: 600; margin: 14px 0 4px; color: var(--foreground); }
.cl-summary ul { padding-left: 20px; margin: 6px 0; }
.cl-summary li { margin-bottom: 4px; }
.cl-summary p { margin: 6px 0; }
.cl-summary strong { color: var(--foreground); font-weight: 600; }
.cl-summary a { color: var(--primary); text-decoration: none; font-size: 0.8rem; }
.cl-summary a:hover { text-decoration: underline; }

.cl-steps-counter { color: var(--muted-foreground); font-size: 0.85rem; flex-shrink: 0; }
.cl-steps-wrap { padding: 0 1rem; }
.cl-steps-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-step-item {
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 12px; cursor: pointer; transition: opacity .15s, background .15s;
}
.cl-step-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; accent-color: var(--primary); }
.cl-step-text { flex: 1; font-weight: 500; }
.cl-step-item.done { opacity: .55; background: var(--muted); }
.cl-step-item.done .cl-step-text { text-decoration: line-through; }

.cl-transcript { border-radius: var(--radius-lg); overflow: hidden; }
.cl-transcript-summary {
  padding: 14px 1rem; background: var(--card); cursor: pointer; font-weight: 600; user-select: none;
  display: flex; align-items: center; gap: 8px;
}
.cl-transcript-summary svg { width: 16px; height: 16px; color: var(--muted-foreground); }
.cl-transcript-body { padding: 16px 1rem; background: var(--muted); overflow-x: auto; }
.cl-transcript-body pre { margin: 0; font-family: monospace; font-size: 0.85rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }

.cl-connected-tag { font-size: 0.85rem; color: var(--success); display: inline-flex; align-items: center; gap: 5px; }
.cl-connected-tag svg { width: 14px; height: 14px; }


.cl-status-row { padding: 0 1rem; display: flex; align-items: center; gap: 16px; }
.cl-status-icon { width: 32px; height: 32px; color: var(--muted-foreground); flex-shrink: 0; }
.cl-status-icon.ok { color: var(--success); }
.cl-status-title { font-weight: 600; margin-bottom: 4px; }
.cl-status-sub { color: var(--muted-foreground); font-size: 0.9rem; }
.cl-status-sub code { background: var(--muted); padding: 2px 6px; border-radius: 4px; }

.cl-instructions { padding: 0 1rem; color: var(--muted-foreground); line-height: 1.8; }
.cl-instructions p { margin: 0 0 12px; }
.cl-instructions ol { margin: 0; padding-left: 20px; }
.cl-instructions code { background: var(--muted); padding: 2px 6px; border-radius: 4px; color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════════════
   FATTURAZIONE (admin/fatturazione*.html + static/js/fatturazione.js) —
   namespace "ftr-". Riusa sc-/adv- dove il pattern è identico (sezioni →
   sc-card, tabelle → adv-table/adv-table-wrap, form → usr-field/sc-input,
   messaggi → sc-flash, modal → sc-dialog): qui solo dropzone upload,
   summary contatori preview, celle editabili FIC, conflitto nome
   anagrafica, barra filtri+bulk-edit, badge doppioni, e il modal di
   conferma sync Airtable (condiviso in base.html).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Dropzone upload PDF ── */
.ftr-dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 28px 20px; text-align: center; cursor: pointer;
  color: var(--muted-foreground); transition: border-color .15s, background .15s;
}
.ftr-dropzone:hover, .ftr-dropzone.drag-over { border-color: var(--primary); background: color-mix(in oklch, var(--primary) 5%, transparent); }
.ftr-dropzone svg { width: 28px; height: 28px; margin: 0 auto 8px; opacity: .5; display: block; }
.ftr-dropzone-label { font-size: 0.85rem; }
.ftr-dropzone-hint { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 4px; }

.ftr-file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ftr-file-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: var(--muted); border-radius: var(--radius-md); font-size: 0.85rem;
}
.ftr-file-item svg { width: 14px; height: 14px; vertical-align: middle; margin-right: 6px; color: var(--muted-foreground); }
.ftr-file-size { font-size: 0.75rem; color: var(--muted-foreground); flex-shrink: 0; }

/* ── Summary contatori preview (nuovi/aggiorna/identici) ── */
.ftr-summary { display: flex; gap: 12px; font-size: 0.82rem; color: var(--muted-foreground); margin-bottom: 12px; }
.ftr-preview-header { display: none; align-items: center; justify-content: space-between; margin-top: 20px; margin-bottom: 8px; gap: 12px; }
.ftr-preview-header.visible { display: flex; }
.ftr-preview-header .ftr-summary { margin-bottom: 0; }

/* ── Importi ── */
.ftr-amount.positive { color: var(--foreground); }
.ftr-amount.negative { color: var(--destructive); }

/* ── Celle editabili (contenteditable) ── */
.ftr-editable { cursor: text; transition: background .1s; border-radius: 4px; }
.ftr-editable:hover { background: var(--muted); }
.ftr-editable:focus { outline: 2px solid var(--ring); outline-offset: -2px; background: var(--muted); }
.ftr-field-mismatch { background: color-mix(in oklch, var(--warning) 15%, transparent); }
.ftr-field-mismatch:hover,
.ftr-field-mismatch:focus { background: color-mix(in oklch, var(--warning) 22%, transparent); }

/* ── Celle nome cliente/fornitore: tronca invece di andare a capo (evita righe di altezza diversa) ── */
.ftr-name-cell { max-width: 160px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Conflitto nome (nessun match esatto in anagrafica) ── */
.ftr-name-conflict {
  display: block; padding: 10px; cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: color-mix(in oklch, var(--destructive) 8%, transparent); color: var(--destructive);
  transition: background .12s;
}
.ftr-name-conflict:hover { background: color-mix(in oklch, var(--destructive) 14%, transparent); }
.ftr-name-managed { background: color-mix(in oklch, var(--success) 12%, transparent); color: var(--success); }
.ftr-platform-heading { display: flex; align-items: center; justify-content: flex-start; width: 100%; height: 18px; line-height: 0; }
.ftr-platform-heading img { display: block; width: 18px; height: 18px; object-fit: contain; }
.ftr-airtable-state { justify-content: flex-start; }
.ftr-table input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.ftr-table .ftr-doc-cell { text-align: left; }

/* ── Controlli tabella FIC: filtro + bulk edit ── */
.ftr-controls { display: flex; flex-direction: column; gap: 10px; }
.ftr-filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ftr-filter-row .sc-select, .ftr-filter-row .sc-input { width: auto; height: 2rem; font-size: 0.82rem; }
.ftr-filter-count { font-size: 0.78rem; color: var(--muted-foreground); }
/* ── Header colonna ordinabile (tabella FIC) ── */
.ftr-th-sortable { cursor: pointer; user-select: none; }
.ftr-th-sortable.active { color: var(--primary); }
.ftr-sort-icon { font-size: 0.7em; opacity: .35; }
.ftr-sort-icon.active { opacity: 1; }

/* ── Badge doppioni (pill di warning, cliccabile) ── */
.ftr-warn-badge {
  display: none; align-items: center; gap: 4px; font-size: 0.75rem; padding: 3px 10px;
  border-radius: var(--radius-4xl); background: color-mix(in oklch, var(--destructive) 12%, transparent);
  color: var(--destructive); border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  cursor: pointer; white-space: nowrap;
}
.ftr-warn-badge.visible { display: inline-flex; }
.ftr-doppioni-note {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--destructive) 6%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 20%, transparent); font-size: 0.82rem;
}
.ftr-doppioni-note strong { color: var(--destructive); }
.ftr-doppioni-note ul { margin: 6px 0 0 16px; color: var(--foreground); }
.ftr-row-flag { color: var(--destructive); font-size: 0.9rem; margin-left: 4px; }
.ftr-row-dup td { background: color-mix(in oklch, var(--destructive) 4%, transparent); }

/* ── Modal doppioni (lista gruppi + ignora) ── */
.ftr-doppioni-list { display: flex; flex-direction: column; gap: 10px; }
.ftr-doppioni-group {
  padding: 10px 14px; border-radius: var(--radius-md); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  background: color-mix(in oklch, var(--destructive) 4%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 25%, transparent);
}
.ftr-doppioni-group-body { flex: 1; min-width: 0; }
.ftr-doppioni-group-label { font-size: 0.72rem; color: var(--muted-foreground); margin-bottom: 6px; }
.ftr-doppioni-group-name { font-size: 0.85rem; font-weight: 500; padding: 3px 0; border-bottom: 1px solid var(--border); }
.ftr-doppioni-group-name:last-child { border-bottom: none; }
.ftr-doppioni-ignore { flex-shrink: 0; }

/* ── Log sincronizzazioni FIC ── */
.ftr-log-dialog {
  width: min(1120px, calc(100vw - 48px)); max-width: 1120px; height: min(760px, calc(100vh - 48px)); max-height: none;
  gap: 0; padding: 0; overflow: hidden;
}
.ftr-log-dialog .sc-dialog-header {
  display: flex; flex: 0 0 auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 68px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--card);
}
.ftr-log-heading { min-width: 0; }
.ftr-log-dialog .sc-dialog-title { display: block; font-size: .96rem; font-weight: 700; }
.ftr-log-summary { display: block; margin-top: 4px; color: var(--muted-foreground); font-size: .71rem; line-height: 1.2; }
.ftr-log-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.ftr-log-close { color: var(--muted-foreground); }
.ftr-log-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0; background: var(--card); }
.ftr-log-dialog-body > .adv-table-wrap { min-width: 940px; overflow: visible; padding: 0; }
.ftr-log-dialog-body .adv-table { table-layout: fixed; font-size: .77rem; }
.ftr-log-dialog-body .adv-table th {
  top: 0; z-index: 3; height: 42px; padding: 0 10px; background: var(--muted); white-space: nowrap;
  box-shadow: 0 1px 0 var(--border);
}
.ftr-log-dialog-body .adv-table td { height: 48px; padding: 7px 10px; }
.ftr-log-dialog-body .adv-table th:nth-child(1) { width: 116px; }
.ftr-log-dialog-body .adv-table th:nth-child(2) { width: 68px; }
.ftr-log-dialog-body .adv-table th:nth-child(3) { width: 118px; }
.ftr-log-dialog-body .adv-table th:nth-child(4) { width: 112px; }
.ftr-log-dialog-body .adv-table th:nth-child(5) { width: 230px; }
.ftr-log-dialog-body .adv-table th:nth-child(6) { width: 88px; }
.ftr-log-dialog-body .adv-table th:nth-child(7),
.ftr-log-dialog-body .adv-table th:nth-child(8) { width: 88px; text-align: right; }
.ftr-log-dialog-body .adv-table th:nth-child(9) { width: 170px; }
.ftr-log-sync-date { color: var(--foreground); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ftr-log-sync-date span, .ftr-log-sync-date small { display: block; }
.ftr-log-sync-date small { margin-top: 2px; color: var(--muted-foreground); font-size: .67rem; }
.ftr-log-number { overflow: hidden; font-family: monospace; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.ftr-log-invoice-date { color: var(--muted-foreground); white-space: nowrap; }
.ftr-log-counterparty { overflow: hidden; font-weight: 550; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.ftr-log-tipo { display: inline-flex; align-items: center; font-size: .72rem; color: var(--muted-foreground); white-space: nowrap; }
.ftr-log-amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ftr-log-error { overflow: hidden; color: var(--destructive); font-size: .7rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  .ftr-log-dialog { width: calc(100vw - 20px); height: calc(100vh - 20px); }
  .ftr-log-dialog .sc-dialog-header { min-height: 62px; padding: 11px 12px; }
  .ftr-log-actions .sc-btn:not(.ftr-log-close) { width: 34px; padding: 0; font-size: 0; }
  .ftr-log-actions .sc-btn:not(.ftr-log-close) svg { margin: 0; }
}

/* ── Modal verifica nome (conflitto Clienti/Fornitori vs Airtable) ── */
.ftr-nm-block { margin-bottom: 18px; }
.ftr-nm-block:last-child { margin-bottom: 0; }
.ftr-nm-block-label {
  font-size: 0.75rem; font-weight: 600; color: var(--muted-foreground); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 8px;
}
.ftr-nm-fic-name {
  background: color-mix(in oklch, var(--destructive) 8%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  border-radius: var(--radius-md); padding: 10px 14px; font-weight: 600; color: var(--destructive); font-size: 0.93rem;
}
.ftr-nm-list { display: flex; flex-direction: column; gap: 6px; }
.ftr-nm-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; transition: background .15s;
}
.ftr-nm-option:hover { background: var(--muted); }
.ftr-nm-option.dashed { border-style: dashed; }
.ftr-nm-option input[type="radio"] { flex-shrink: 0; accent-color: var(--primary); }
.ftr-nm-option-body { flex: 1; min-width: 0; }
.ftr-nm-option-name { font-weight: 500; font-size: 0.88rem; margin-bottom: 3px; }
.ftr-nm-option-extra { font-size: 0.74rem; color: var(--muted-foreground); }
.ftr-nm-option-score { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.ftr-nm-option-pct { font-size: 0.75rem; font-weight: 600; }
.ftr-nm-option-bar { height: 3px; border-radius: 2px; opacity: .7; }
.ftr-nm-empty { color: var(--muted-foreground); font-size: 0.85rem; font-style: italic; padding: 8px 0; }
.ftr-nm-overwrite-box {
  display: none; margin-top: 16px; background: color-mix(in oklch, var(--warning) 8%, transparent);
  border: 1px solid color-mix(in oklch, var(--warning) 35%, transparent); border-radius: var(--radius-md); padding: 12px 14px;
}
.ftr-nm-overwrite-box.visible { display: block; }
.ftr-nm-overwrite-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.ftr-nm-overwrite-label input { margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }
.ftr-nm-overwrite-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 3px; }
.ftr-nm-overwrite-desc { font-size: 0.78rem; color: var(--muted-foreground); }

/* ── Workspace di sincronizzazione condiviso (FIC + Budget ADV) ── */
.sync-workspace {
  display: flex; flex-direction: column; gap: 16px; min-height: 100%;
}
.sync-workspace .sc-card { margin: 0; }
.sync-page-scroll { padding-bottom: 88px; }
.sync-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sync-source-status {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: var(--radius-4xl); background: var(--card);
  color: var(--muted-foreground); font-size: .78rem; font-weight: 600;
}
.sync-source-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-foreground); }
.sync-source-status.connected::before { background: var(--success); }
.sync-source-status.warning::before { background: var(--warning); }

.sync-config-card { gap: 0; padding: 0; overflow: hidden; }
.sync-card-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
/* Il divisore appartiene al rapporto header/body. Se l'header è l'unico
   contenuto della card non separa nulla e non deve essere disegnato. */
.sync-config-card > .sync-card-heading:last-child { border-bottom: 0; }
.sync-card-eyebrow {
  color: var(--muted-foreground); font-size: .68rem; font-weight: 700;
  letter-spacing: .08em; line-height: 1.2; text-transform: uppercase; margin-bottom: 5px;
}
.sync-card-title { margin: 0; color: var(--foreground); font-size: .96rem; font-weight: 700; line-height: 1.25; }
.sync-card-description { margin: 4px 0 0; color: var(--muted-foreground); font-size: .79rem; line-height: 1.45; }
.sync-config-body {
  display: grid; grid-template-columns: minmax(260px, .9fr) minmax(340px, 1.15fr) 158px;
  align-items: end; gap: 20px; padding: 18px 20px 20px;
}
.sync-config-body-compact { grid-template-columns: minmax(260px, 420px) 158px; justify-content: space-between; }
.sync-field-group { min-width: 0; }
.sync-field-label { display: block; min-height: 16px; margin: 0 0 7px; color: var(--muted-foreground); font-size: .72rem; font-weight: 650; line-height: 16px; }
.sync-period-fields { display: grid; grid-template-columns: minmax(130px, 1fr) 100px; gap: 8px; }
.sync-period-fields .sc-select { width: 100% !important; height: 38px; }
.sync-mode-group {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  height: 38px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted);
}
.sync-mode-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; height: 30px; padding: 0 11px;
  border: 0; border-radius: calc(var(--radius-md) - 3px); background: transparent; color: var(--muted-foreground);
  font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.sync-mode-btn:hover { background: color-mix(in oklch, var(--card) 72%, transparent); color: var(--foreground); }
.sync-mode-btn.active {
  background: color-mix(in srgb, var(--primary) 16%, var(--card)); color: var(--foreground);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 42%, transparent), 0 1px 2px rgba(0,0,0,.06);
}
.sync-mode-btn.active svg { color: var(--primary); }
.sync-mode-btn svg { width: 14px; height: 14px; }
.sync-config-action { display: flex; align-items: flex-end; }
.sync-primary-action { width: 100%; min-width: 0; height: 38px; justify-content: center; }
.sync-secondary-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px;
  border-top: 1px solid var(--border); background: color-mix(in oklch, var(--muted) 42%, transparent);
}
.sync-secondary-label { margin-right: 2px; color: var(--muted-foreground); font-size: .71rem; font-weight: 650; }

.sync-empty-state {
  display: grid; place-items: center; min-height: 300px; padding: 36px 24px; text-align: center;
}
.sync-empty-inner { width: min(560px, 100%); }
.sync-empty-icon {
  display: grid; place-items: center; width: 46px; height: 46px; margin: 0 auto 14px;
  border-radius: 14px; background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary);
}
.sync-empty-icon svg { width: 22px; height: 22px; }
.sync-empty-title { margin: 0; font-size: .94rem; font-weight: 700; }
.sync-empty-copy { margin: 6px auto 0; max-width: 470px; color: var(--muted-foreground); font-size: .79rem; line-height: 1.5; }
.sync-empty-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 20px; text-align: left;
}
.sync-empty-step { display: flex; align-items: flex-start; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.sync-empty-step-num {
  display: grid; place-items: center; width: 21px; height: 21px; flex: 0 0 21px; border-radius: 50%;
  margin: 0; background: var(--muted); color: var(--muted-foreground); font-size: .68rem; font-weight: 750; line-height: 1;
}
.sync-empty-step strong { display: block; font-size: .73rem; line-height: 1.2; }
.sync-empty-step > div > span { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: .66rem; line-height: 1.3; }

.sync-results-card { display: none; flex-direction: column; min-height: 430px; gap: 0; padding: 0; overflow: hidden; }
.sync-results-card.visible { display: flex; }
.sync-metric-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--border);
}
.sync-metric {
  min-width: 0; padding: 15px 18px; border-right: 1px solid var(--border); background: var(--card);
}
.sync-metric:last-child { border-right: 0; }
.sync-metric-label { color: var(--muted-foreground); font-size: .68rem; font-weight: 650; line-height: 1.2; }
.sync-metric-value { margin-top: 5px; color: var(--foreground); font-size: 1.08rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sync-metric-meta { margin-top: 3px; color: var(--muted-foreground); font-size: .66rem; line-height: 1.25; }
.sync-metric.issue .sync-metric-value { color: var(--destructive); }
.sync-results-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: color-mix(in oklch, var(--muted) 34%, transparent);
}
.sync-filter-tabs { display: flex; align-items: center; gap: 5px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.sync-filter-tabs::-webkit-scrollbar { display: none; }
.sync-filter-tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--radius-4xl); background: transparent; color: var(--muted-foreground);
  font: inherit; font-size: .72rem; font-weight: 650; cursor: pointer;
}
.sync-filter-tab:hover { color: var(--foreground); background: var(--muted); }
.sync-filter-tab.active { border-color: var(--border); background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.sync-filter-count { color: var(--muted-foreground); font-size: .65rem; }
.sync-toolbar-tools { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.sync-search { position: relative; width: min(230px, 24vw); margin: 0; }
.sync-search svg { position: absolute; left: 9px; top: 50%; width: 14px; height: 14px; color: var(--muted-foreground); transform: translateY(-50%); pointer-events: none; }
.sync-search .sc-input { height: 32px; padding-left: 30px; font-size: .75rem; }
.sync-table-shell { flex: 1; min-height: 0; overflow: auto; }
.sync-table-shell .adv-table-wrap { border: 0; border-radius: 0; box-shadow: none; }
.sync-table-shell .adv-table th { padding: 10px; }
.sync-action-bar {
  position: sticky; z-index: 5; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--card);
}
.sync-action-summary { color: var(--muted-foreground); font-size: .77rem; }
.sync-action-summary strong { color: var(--foreground); }
.sync-action-buttons { display: flex; align-items: center; gap: 8px; }
.sync-issue-dot { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--destructive); vertical-align: 1px; }

/* Budget ADV: variante compatta dello stesso workspace. */
.budget-table { min-width: 1120px; table-layout: fixed; font-variant-numeric: tabular-nums; }
.budget-table th:nth-child(1), .budget-table td:nth-child(1) { width: 42px; text-align: center; }
.budget-table th:nth-child(2), .budget-table td:nth-child(2) { width: 23%; }
.budget-table th:nth-child(3), .budget-table td:nth-child(3) { width: 23%; }
.budget-table th:nth-child(4), .budget-table td:nth-child(4),
.budget-table th:nth-child(5), .budget-table td:nth-child(5),
.budget-table th:nth-child(6), .budget-table td:nth-child(6),
.budget-table th:nth-child(7), .budget-table td:nth-child(7) { width: 10%; text-align: right; white-space: nowrap; }
.budget-table th:nth-child(8), .budget-table td:nth-child(8) { width: 12%; text-align: center; white-space: nowrap; }
.budget-account { font-weight: 650; line-height: 1.25; }
.budget-account-sub { color: var(--muted-foreground); font-size: .7rem; margin-top: 3px; }
.budget-api-error { color: var(--destructive); font-size: .7rem; font-weight: 650; cursor: help; }
.budget-source-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.budget-source-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: var(--radius-4xl); background: var(--muted); color: var(--muted-foreground); font-size: .68rem; font-weight: 650; }
.budget-source-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.budget-error-details { margin-top: 6px; max-width: 260px; color: var(--destructive); font-size: .67rem; line-height: 1.35; white-space: normal; }

/* FIC: densità progressiva; la vista essenziale nasconde i campi avanzati senza rimuoverli dal DOM. */
.ftr-table.ftr-table-essential .ftr-col-secondary { display: none; }
.ftr-view-toggle { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); }
.ftr-view-toggle button { height: 25px; padding: 0 8px; border: 0; border-radius: calc(var(--radius-md) - 3px); background: transparent; color: var(--muted-foreground); font: inherit; font-size: .68rem; font-weight: 650; cursor: pointer; }
.ftr-view-toggle button.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

@media (max-width: 900px) {
  .sync-config-body { grid-template-columns: 1fr 1fr; }
  .sync-config-body-compact { grid-template-columns: minmax(0, 1fr) 158px; }
  .sync-config-action { grid-column: 1 / -1; }
  .sync-config-body-compact .sync-config-action { grid-column: auto; }
  .sync-primary-action { width: 100%; }
  .sync-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sync-metric:nth-child(2) { border-right: 0; }
  .sync-metric:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .sync-results-toolbar { align-items: stretch; flex-direction: column; }
  .sync-toolbar-tools { justify-content: space-between; }
  .sync-search { width: min(100%, 320px); }
}
@media (max-width: 600px) {
  .sync-header-actions { width: 100%; justify-content: flex-start; }
  .sync-card-heading, .sync-config-body, .sync-secondary-actions { padding-left: 14px; padding-right: 14px; }
  .sync-config-body { grid-template-columns: 1fr; gap: 14px; }
  .sync-config-body-compact { grid-template-columns: 1fr; }
  .sync-config-action { grid-column: auto; }
  .sync-empty-steps { grid-template-columns: 1fr; }
  .sync-action-bar { align-items: stretch; flex-direction: column; }
  .sync-action-buttons, .sync-action-buttons .sc-btn { width: 100%; justify-content: center; }
}

/* ── Modal conferma sync Airtable (base.html, condiviso ADV+FIC) ── */
.ftr-sync-brand { display: flex; align-items: center; gap: 12px; }
.ftr-sync-brand-label { font-size: 0.7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 2px; }
.ftr-sync-brand-value { font-size: 1rem; font-weight: 600; color: var(--foreground); }
.ftr-sync-target { background: var(--muted); border-radius: var(--radius-md); padding: 14px 16px; }
.ftr-sync-target-row { display: flex; align-items: center; gap: 8px; }
.ftr-sync-target-row svg { width: 14px; height: 14px; color: var(--muted-foreground); flex-shrink: 0; }
.ftr-sync-target-label { font-size: 0.75rem; color: var(--muted-foreground); font-weight: 500; }
.ftr-sync-target-value { font-size: 0.85rem; font-weight: 600; color: var(--foreground); margin-left: auto; }
.ftr-sync-target-sep { height: 1px; background: var(--border); margin: 10px 0; }
.ftr-sync-count { font-size: 0.83rem; color: var(--muted-foreground); }

/* ═══════════════════════════════════════════════════════════════════════
   CRO (admin/cro_dashboard.html, cro_client.html, cro_leads.html,
   cro_lead_detail.html, cro_report.html) — namespace "cro-". Riusa sc-/
   adv- dove il pattern è identico (sezioni → sc-card, tabelle → adv-table,
   modal → sc-dialog, badge di stato semplici → sc-badge): qui i widget
   genuinamente specifici del modulo (score ring, timeline lead, KPI
   strip, benchmark bar, insight/quick-win card, status pill data-driven).
   .cro-score-ring, .cro-score-text, .cro-loader-*, .cro-preset-btn restano
   quelli già in style.css (nessuna collisione, nomi già ben namespaced).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Dashboard CRO: griglia client + card cliccabile con score ring ── */
.cro-client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.cro-client-card { padding: 20px; cursor: pointer; transition: box-shadow .15s; }
.cro-client-card:hover { box-shadow: 0 0 0 1px var(--primary), var(--content-shadow); }
.cro-client-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cro-client-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cro-client-shop { font-size: 0.78rem; color: var(--muted-foreground); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cro-client-foot { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cro-client-report-date { font-size: 0.75rem; color: var(--muted-foreground); }
.cro-connected-badge { background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); border-color: color-mix(in oklch, var(--primary) 30%, transparent); }
.cro-empty-state { text-align: center; padding: 56px 24px; }
.cro-empty-state svg { width: 40px; height: 40px; color: var(--muted-foreground); margin: 0 auto 16px; display: block; }
.cro-empty-title { font-weight: 600; font-size: 1rem; margin-bottom: 8px; }
.cro-empty-sub { font-size: 0.875rem; color: var(--muted-foreground); max-width: 360px; margin: 0 auto; }

/* ── Client: header con azioni ── */
.cro-shop-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cro-shop-domain { font-size: 0.78rem; color: var(--muted-foreground); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Score card (ring + summary testuale) ── */
.cro-score-card { padding: 20px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.cro-score-summary { flex: 1; min-width: 180px; }
.cro-score-summary-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); margin-bottom: 6px; }
.cro-score-summary-text { font-size: 0.9rem; color: var(--foreground); line-height: 1.6; margin: 0; }
.cro-score-rationale { font-size: 0.8rem; color: var(--muted-foreground); margin: 6px 0 0; font-style: italic; }
.cro-score-period { margin-top: 8px; font-size: 0.75rem; color: var(--muted-foreground); }
.cro-score-period strong { color: var(--warning); }

/* ── Diagnosi funnel ── */
.cro-funnel-card { border-left: 3px solid var(--destructive); }
.cro-funnel-body { padding: 16px 1.5rem; }
.cro-funnel-loss {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
  background: color-mix(in oklch, var(--destructive) 8%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 20%, transparent);
  border-radius: var(--radius-md); padding: 8px 14px;
}
.cro-funnel-loss svg { width: 14px; height: 14px; color: var(--destructive); }
.cro-funnel-loss span { font-size: 0.85rem; font-weight: 600; color: var(--destructive); }

/* ── Breakdown fatturato ── */
.cro-revenue-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.cro-revenue-row.total { border-bottom: none; border-top: 2px solid var(--border); margin-top: 4px; padding-top: 10px; font-weight: 700; }
.cro-revenue-row.negative .cro-revenue-val { color: var(--destructive); }
.cro-revenue-note { margin-top: 14px; padding: 10px 12px; background: var(--muted); border-radius: var(--radius-md); border-left: 3px solid var(--muted-foreground); }
.cro-revenue-note p { margin: 0; font-size: 0.76rem; color: var(--muted-foreground); line-height: 1.5; }
.cro-revenue-note strong { color: var(--foreground); }

/* ── Benchmark di settore ── */
.cro-bench-row { margin-bottom: 18px; }
.cro-bench-row:last-child { margin-bottom: 0; }
.cro-bench-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cro-bench-label { font-size: 0.85rem; font-weight: 500; }
.cro-bench-value { font-weight: 700; font-size: 0.9rem; }
.cro-bench-value .sub { font-weight: 400; color: var(--muted-foreground); font-size: 0.8rem; }
.cro-bench-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; }
.cro-bench-track { background: var(--secondary); border-radius: 4px; height: 6px; position: relative; }
.cro-bench-fill { height: 100%; border-radius: 4px; transition: width .3s; }
.cro-bench-marker { position: absolute; right: 0; top: -3px; width: 2px; height: 12px; background: var(--muted-foreground); }

/* ── Insights CRO ── */
.cro-ins-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 16px; }
.cro-ins-card:last-child { margin-bottom: 0; }
.cro-ins-card.first { border-left: 3px solid var(--primary); }
.cro-ins-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cro-ins-icon { font-size: 1.2rem; }
.cro-ins-title { font-weight: 700; font-size: 0.9rem; flex: 1; min-width: 0; }
.cro-ins-pie { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); border: 1px solid color-mix(in oklch, var(--primary) 30%, transparent); }
.cro-ins-context { font-size: 0.82rem; color: var(--muted-foreground); margin: 0 0 8px; font-style: italic; }
.cro-ins-bullets { margin: 0; padding-left: 18px; }
.cro-ins-bullets li { font-size: 0.85rem; line-height: 1.6; margin-bottom: 4px; }

/* ── Quick Wins ── */
.cro-qw-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.cro-qw-card:last-child { margin-bottom: 0; }
.cro-qw-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.cro-qw-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); font-weight: 700; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cro-qw-body { flex: 1; min-width: 0; }
.cro-qw-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.cro-qw-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cro-qw-tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 4px; background: var(--secondary); display: inline-flex; align-items: center; gap: 4px; }
.cro-qw-tag svg { width: 11px; height: 11px; }
.cro-qw-tag.lift { background: color-mix(in oklch, var(--primary) 10%, transparent); color: var(--primary); border: 1px solid color-mix(in oklch, var(--primary) 20%, transparent); }
.cro-qw-howto { font-size: 0.83rem; color: var(--muted-foreground); line-height: 1.5; background: var(--secondary); border-radius: var(--radius-md); padding: 8px 12px; }

/* ── Report completo / note metodologiche ── */
/* Altezza fissa esplicita: Chart.js con maintainAspectRatio:false richiede
   un contenitore a altezza vincolata (non deducibile dal solo attributo
   height del canvas), altrimenti dentro un .sc-card flex il canvas può
   crescere ben oltre l'altezza prevista (bug reale verificato: 640px
   invece di ~140px, canvas che eredita l'aspect ratio dal proprio
   width/height HTML di default anziché dal contenitore). */
.cro-chart-wrap { height: 180px; padding: 0 1rem; }
.cro-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.cro-report-pre { white-space: pre-wrap; font-size: 0.85rem; line-height: 1.7; font-family: inherit; margin: 0; }
.cro-method-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--border); }
.cro-method-row:last-child { border-bottom: none; }
.cro-method-row svg { width: 13px; height: 13px; color: var(--muted-foreground); flex-shrink: 0; margin-top: 2px; }
.cro-method-row span { font-size: 0.82rem; color: var(--muted-foreground); line-height: 1.5; }
.cro-data-notes { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.cro-data-notes div { font-size: 0.8rem; color: var(--muted-foreground); padding: 3px 0; }

/* ── Modal avvio report (croStartModal → sc-dialog) ── */
.cro-modal-intro { font-size: 0.82rem; color: var(--muted-foreground); margin-bottom: 20px; }
.cro-modal-label { font-size: 0.82rem; font-weight: 600; margin-bottom: 8px; }
.cro-custom-dates { display: none; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.cro-custom-dates.visible { display: grid; }

/* ── Modal bulk quick-win → dashboard task ── */
.cro-qw-modal-sub { font-size: 0.78rem; color: var(--muted-foreground); margin-top: 2px; }
.cro-qw-modal-section-label { font-size: 0.75rem; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.cro-qw-modal-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cro-qw-task-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; transition: background .15s; }
.cro-qw-task-row input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--primary); }
.cro-qw-task-body { flex: 1; min-width: 0; }
.cro-qw-task-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cro-qw-task-num { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cro-qw-task-desc { font-size: 0.78rem; color: var(--muted-foreground); background: var(--secondary); border-radius: 5px; padding: 5px 8px; line-height: 1.45; }
.cro-qw-task-meta { margin-top: 5px; font-size: 0.74rem; color: var(--muted-foreground); }
.cro-toast {
  position: fixed; bottom: 24px; right: 24px; z-index: var(--layer-toast);
  background: var(--card); border-radius: var(--radius-lg); padding: 12px 18px; font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 340px;
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow);
}
.cro-toast.error { color: var(--destructive); }

/* ── Lead CRO: KPI strip + status pill ── */
.cro-lead-kpi-strip { display: flex; gap: 12px; margin-bottom: 1rem; flex-wrap: wrap; }
.cro-lead-kpi-tile { background: var(--card); border-radius: var(--radius-lg); padding: 14px 20px; min-width: 160px; box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow); }
.cro-lead-kpi-label { font-size: 0.75rem; color: var(--muted-foreground); margin-bottom: 4px; }
.cro-lead-kpi-value { font-size: 1.5rem; font-weight: 700; }
.cro-status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; font-weight: 500; }
.cro-status-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cro-status-pill.badge { padding: 4px 12px; border-radius: 20px; }
.cro-status-sub { font-size: 0.72rem; color: var(--muted-foreground); margin-top: 1px; }

/* ── Lead detail ── */
.cro-detail-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.cro-status-row { margin-top: 8px; margin-bottom: 1rem; display: flex; gap: 8px; flex-wrap: wrap; }
.cro-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cro-info-card { padding: 20px; }
.cro-info-title { font-size: 0.7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 14px; }
.cro-info-title svg { width: 13px; height: 13px; color: var(--primary); }
.cro-info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.cro-info-row:last-child { border-bottom: none; }
.cro-info-row .label { color: var(--muted-foreground); flex-shrink: 0; }
.cro-info-row .value { font-weight: 500; text-align: right; max-width: 60%; }
.cro-info-row .value a { color: var(--primary); }

.cro-timeline { display: flex; flex-direction: column; gap: 14px; }
.cro-timeline-item { display: flex; align-items: center; gap: 12px; }
.cro-timeline-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.75rem; }
.cro-timeline-title { font-size: 0.82rem; font-weight: 500; color: var(--muted-foreground); }
.cro-timeline-title.active { color: var(--foreground); }
.cro-timeline-sub { font-size: 0.75rem; color: var(--muted-foreground); }

.cro-payment-card { margin-top: 1rem; padding: 20px; }
.cro-payment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.cro-payment-tile { background: var(--muted); border-radius: var(--radius-md); padding: 12px; }
.cro-payment-tile-label { font-size: 0.72rem; color: var(--muted-foreground); margin-bottom: 4px; }
.cro-payment-tile-value { font-size: 0.9rem; font-weight: 600; word-break: break-all; }
.cro-payment-tile-value.mono { font-family: monospace; }

.cro-data-card { margin-top: 1rem; padding: 20px; }
.cro-data-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.cro-data-tile { background: var(--muted); border-radius: var(--radius-md); padding: 12px; }
.cro-data-tile-label { font-size: 0.72rem; color: var(--muted-foreground); margin-bottom: 4px; }
.cro-data-tile-value { font-size: 1.1rem; font-weight: 600; }

.cro-detail-cols { margin-top: 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cro-note-quote { margin-top: 12px; padding: 10px; background: var(--muted); border-radius: var(--radius-md); font-size: 0.82rem; color: var(--muted-foreground); font-style: italic; }

.cro-strategy-card { margin-top: 1rem; padding: 20px; }
.cro-strategy-title { font-size: 0.7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.cro-strategy-title svg { width: 13px; height: 13px; color: var(--primary); }
.cro-strategy-loading { text-align: center; padding: 32px; color: var(--muted-foreground); }
.cro-strategy-locked { text-align: center; padding: 28px 20px; color: var(--muted-foreground); }
.cro-strategy-locked svg { width: 24px; height: 24px; opacity: .4; margin: 0 auto 10px; display: block; }
.cro-strategy-locked-title { font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }
.cro-strategy-locked-sub { font-size: 0.8rem; }
.cro-strategy-tags { display: flex; flex-wrap: wrap; margin-bottom: 14px; }
.cro-strategy-tag { display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 500; padding: 3px 10px; border-radius: 20px; margin: 0 6px 6px 0; }
.cro-strategy-hook { background: color-mix(in oklch, var(--success) 8%, transparent); border: 1px solid color-mix(in oklch, var(--success) 20%, transparent); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 18px; }
.cro-strategy-hook-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--success); margin-bottom: 6px; }
.cro-strategy-hook-text { font-size: 0.88rem; line-height: 1.6; font-style: italic; }
.cro-strategy-section-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-foreground); margin-bottom: 12px; }
.cro-strategy-section-label.spaced { margin: 16px 0 10px; }
.cro-strategy-step { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.cro-strategy-step-num { width: 22px; height: 22px; border-radius: 50%; background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); font-size: 0.7rem; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.cro-strategy-step-title { font-size: 0.85rem; font-weight: 500; margin-bottom: 2px; }
.cro-strategy-step-desc { font-size: 0.82rem; color: var(--muted-foreground); line-height: 1.5; }
.cro-strategy-objection { background: var(--muted); border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 8px; }
.cro-strategy-objection-q { font-size: 0.72rem; font-weight: 500; color: var(--muted-foreground); margin-bottom: 4px; }
.cro-strategy-objection-a { font-size: 0.83rem; line-height: 1.5; }
.cro-strategy-error { color: var(--muted-foreground); font-size: 0.83rem; padding: 8px 0; }

.cro-notes-card { margin-top: 1rem; padding: 20px; }
.cro-notes-form { display: flex; gap: 8px; align-items: center; margin-bottom: 20px; }
.cro-note-list { display: flex; flex-direction: column; gap: 10px; }
.cro-note { background: var(--muted); border-radius: var(--radius-md); padding: 14px 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cro-note-body { flex: 1; }
.cro-note-meta { font-size: 0.75rem; color: var(--muted-foreground); margin-bottom: 6px; }
.cro-note-meta strong { color: var(--foreground); }
.cro-note-text { font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; }
.cro-note-del { background: transparent; border: none; color: var(--muted-foreground); cursor: pointer; font-size: 0.8rem; padding: 2px 6px; flex-shrink: 0; }
.cro-note-del:hover { color: var(--destructive); }
.cro-notes-empty { text-align: center; padding: 24px; color: var(--muted-foreground); font-size: 0.85rem; }

.cro-waiting-block { margin-top: 1rem; padding: 32px; text-align: center; color: var(--muted-foreground); }
.cro-waiting-icon { font-size: 1.5rem; margin-bottom: 8px; }
.cro-waiting-title { font-weight: 500; }
.cro-waiting-sub { font-size: 0.83rem; margin-top: 4px; }

@media (max-width: 900px) {
  .cro-info-grid, .cro-detail-cols { grid-template-columns: 1fr; }
  .cro-qw-modal-fields { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════════
   PIPELINE / ONBOARDING (admin/pipeline_index.html, pipeline_nuovo.html,
   pipeline_scheda.html) — namespace "pl-". Riusa sc-/adv-/usr- dove il
   pattern è identico (form → usr-field/sc-input, sezioni → sc-card,
   modal storico versioni → dropdown posizionato, badge → sc-badge): qui
   il kanban, lo stepper a 6 fasi, il layout a due colonne, la tabella
   economics editabile inline, il gantt SVG e il pannello listino, tutti
   genuinamente specifici di questo modulo.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Kanban board ── */
.pl-kanban { display: grid; grid-template-columns: repeat(5, minmax(170px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding: 3px; }
.pl-column { background: var(--card); border-radius: var(--radius-lg); box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow); min-width: 170px; }
.pl-column-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.pl-column-header span:first-child { font-size: 0.78rem; font-weight: 600; }
.pl-column-count { font-size: 0.72rem; background: var(--muted); border-radius: 10px; padding: 1px 7px; font-weight: 600; color: var(--muted-foreground); }
.pl-column-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.pl-column-empty { font-size: 0.78rem; color: var(--muted-foreground); text-align: center; padding: 12px 0; }
.pl-card { display: block; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.pl-card:hover { border-color: var(--primary); box-shadow: var(--content-shadow); }
.pl-card-title { font-size: 0.83rem; font-weight: 600; margin-bottom: 4px; }
.pl-card-meta { font-size: 0.72rem; color: var(--muted-foreground); display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.pl-card-meta svg { width: 11px; height: 11px; }
.pl-card-date { font-size: 0.68rem; color: var(--muted-foreground); margin-top: 6px; }
@media (max-width: 1100px) { .pl-kanban { grid-template-columns: repeat(3, minmax(170px, 1fr)); } }

/* ── Stepper 6 fasi ── */
.pl-stepper { position: relative; display: flex; align-items: flex-start; margin-bottom: 1rem; overflow-x: auto; padding: 4px 0 8px; }
.pl-stepper::before { content: ''; position: absolute; top: 20px; left: calc(100% / 12); right: calc(100% / 12); height: 2px; background: var(--border); z-index: 0; }
.pl-step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; z-index: 1; }
.pl-step-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; background: var(--muted); color: var(--muted-foreground); border: 2px solid var(--border); transition: background .2s, border-color .2s, color .2s; position: relative; z-index: 2; }
.pl-step.active .pl-step-circle { background: var(--primary); color: var(--primary-foreground); border-color: var(--primary); }
.pl-step.done .pl-step-circle { background: var(--success); color: #fff; border-color: var(--success); }
.pl-step-label { font-size: 0.68rem; font-weight: 500; color: var(--muted-foreground); white-space: nowrap; }
.pl-step.active .pl-step-label { color: var(--foreground); font-weight: 700; }
.pl-step.done .pl-step-label { color: var(--success); }

/* ── Layout scheda (2 colonne) ── */
.pl-scheda-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.25rem; align-items: start; }
.pl-scheda-layout--full { grid-template-columns: minmax(0, 1fr); }
.pl-scheda-layout--full > div:last-child { display: none; }
@media (max-width: 900px) { .pl-scheda-layout { grid-template-columns: 1fr; } }

/* ── Doc grid (analisi + strategia affiancate) ── */
.pl-doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .pl-doc-grid { grid-template-columns: 1fr; } }
.pl-doc-empty { color: var(--muted-foreground); font-style: italic; }
.pl-doc-viewer-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 8px; }
.pl-doc-nav { display: flex; align-items: center; gap: 6px; }
.pl-doc-nav-btn { padding: 4px 8px; font-size: 13px; line-height: 1; }
.pl-doc-slide-info { font-size: 0.78rem; color: var(--muted-foreground); min-width: 48px; text-align: center; }
.pl-doc-links { display: flex; gap: 8px; flex-wrap: wrap; }

.pl-versione-badge { position: relative; display: inline-block; }
.pl-versione-badge-btn { font-size: 0.72rem; background: color-mix(in oklch, var(--primary) 12%, transparent); color: var(--primary); border-radius: 10px; padding: 2px 8px; font-weight: 600; cursor: pointer; border: none; }
.pl-vers-dropdown { position: absolute; top: calc(100% + 4px); left: 0; z-index: var(--layer-dropdown); background: var(--card); border-radius: var(--radius-md); box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), 0 8px 24px rgba(0,0,0,.15); min-width: 190px; padding: 4px 0; font-size: 0.8rem; display: none; }
.pl-vers-dropdown.open { display: block; }
.pl-vers-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; color: var(--foreground); text-decoration: none; white-space: nowrap; }
.pl-vers-item:hover { background: var(--muted); }
.pl-vers-item .badge { font-size: 0.72rem; font-weight: 700; background: var(--primary); color: var(--primary-foreground); padding: 1px 6px; border-radius: 3px; flex-shrink: 0; }
.pl-vers-item .date { color: var(--muted-foreground); font-size: 0.75rem; }
.pl-vers-item .current { font-size: 0.7rem; color: var(--primary); font-weight: 600; }
.pl-vers-empty { padding: 8px 12px; color: var(--muted-foreground); font-size: 0.8rem; }

/* ── Economics table ── */
.pl-econ-wrap { overflow-x: auto; }
.pl-econ-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; min-width: 700px; }
.pl-econ-table th { background: var(--muted); padding: 8px; border-bottom: 2px solid var(--border); text-align: left; font-size: 0.7rem; font-weight: 600; color: var(--muted-foreground); white-space: nowrap; }
.pl-econ-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.pl-input-sm { padding: 4px 8px !important; font-size: 0.75rem !important; height: 1.75rem !important; }
.pl-totali { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.pl-totale-item { font-size: 0.875rem; font-weight: 700; padding: 6px 12px; background: var(--muted); border-radius: var(--radius-md); }
.pl-gantt-label { font-size: 0.8rem; font-weight: 600; color: var(--muted-foreground); margin-bottom: 8px; letter-spacing: .04em; text-transform: uppercase; }
.pl-gantt-svg { background: var(--muted); border-radius: var(--radius-md); display: block; }

/* ── Pannello listino ── */
.pl-listino-panel { display: none; margin-bottom: 1rem; }
.pl-listino-panel.open { display: block; }
.pl-listino-results { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.pl-listino-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .1s; font-size: 0.78rem; }
.pl-listino-item:hover { background: var(--muted); }
.pl-listino-item strong { flex: 1; }
.pl-listino-item span { color: var(--muted-foreground); }
.pl-listino-empty { color: var(--muted-foreground); font-size: 0.85rem; }

/* ── Files list ── */
.pl-files-list { display: flex; flex-direction: column; gap: 6px; }
.pl-file-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; padding: 6px 8px; background: var(--muted); border-radius: var(--radius-sm); }
.pl-file-item svg { width: 14px; height: 14px; color: var(--muted-foreground); flex-shrink: 0; }
.pl-file-meta { margin-left: auto; color: var(--muted-foreground); font-size: 0.72rem; }

/* ── Log attività (sidebar dx) ── */
.pl-log { display: flex; flex-direction: column; }
.pl-log-item { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.pl-log-item:last-child { border-bottom: none; }
.pl-log-text { font-size: 0.78rem; line-height: 1.5; }
.pl-log-date { font-size: 0.68rem; color: var(--muted-foreground); margin-top: 3px; }
.pl-log-avanzamento .pl-log-text { color: var(--success); font-weight: 600; }
.pl-log-generazione .pl-log-text { color: #4a90e2; }
.pl-log-sistema .pl-log-text { color: var(--muted-foreground); }

/* ── Note interne ── */
.pl-note-bar { display: flex; align-items: center; gap: 8px; padding: 12px 1.5rem; }
.pl-note-input { flex: 1; resize: none; height: 2.25rem; min-height: 2.25rem; }
.pl-note-log { max-height: 260px; overflow-y: auto; border-top: 1px solid var(--border); }
.pl-nota-item { padding: 10px 1.5rem; border-bottom: 1px solid var(--border); }
.pl-nota-item:last-child { border-bottom: none; }
.pl-nota-testo { font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; }
.pl-nota-meta { display: flex; align-items: center; gap: 12px; margin-top: 4px; font-size: 0.78rem; color: var(--muted-foreground); }
.pl-nota-meta .del-btn { margin-left: auto; }

/* ── Cliente acquisito ── */
.pl-cliente-badge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 32px 0; gap: 12px; }
.pl-cliente-badge svg { width: 48px; height: 48px; color: var(--primary); }
.pl-cliente-badge h2 { font-size: 1.5rem; font-weight: 700; }
.pl-doc-link-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--muted); border-radius: var(--radius-sm); font-size: 0.85rem; }
.pl-doc-link-item svg { width: 16px; height: 16px; color: var(--muted-foreground); }
.pl-doc-link-date { margin-left: auto; color: var(--muted-foreground); font-size: 0.8rem; }

/* ── AI progress bar ── */
.pl-ai-progress { display: none; padding: 16px 1.5rem; }
.pl-ai-progress-wrap { padding: 14px 0 8px; }
.pl-ai-progress-track { height: 6px; background: var(--muted); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.pl-ai-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .6s ease; width: 0%; }
.pl-ai-progress-steps { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.pl-ai-progress-step { font-size: 0.85rem; color: var(--muted-foreground); white-space: nowrap; }
.pl-ai-progress-step.active { color: var(--foreground); font-weight: 600; }
.pl-ai-progress-step.done { color: var(--success); }
.pl-spin { animation: dsh-spin 1s linear infinite; display: inline-block; }

/* ═══════════════════════════════════════════════════════════════════════
   CLIENT DASHBOARD (client/dashboard.html) — riusa quasi tutto sc-/adv-/
   cd- già definiti (KPI, breakdown settimanale via _weekly_table.html,
   già migrato). Qui solo il titolo di sezione Lead Gen/E-Commerce e il
   fix del modal "Storico completo": _weekly_table.html ora genera
   .sc-card/.cd-card-header/.adv-table-wrap (non più .card/.card-header/
   .table-wrapper), le regole in style.css che spogliano il chrome della
   card dentro il modal puntavano ancora ai nomi vecchi — qui i nomi
   corretti, redesign.css carica dopo quindi vince.
   ═══════════════════════════════════════════════════════════════════════ */
.dsh-kpi-note { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 4px; }
.cld-section { margin-bottom: 1.5rem; }
.cld-section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1rem; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
.cld-section-title { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.cld-trend-legend { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 0 1rem; }
.cld-chart-wrap { height: 240px; padding: 0 1rem 4px; }
.cld-chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Storico completo ADV: la shell e il titolo restano fissi; il partial
   condiviso espone una sola card ad altezza vincolata e soltanto le righe
   della tabella scorrono. Vale per Meta, Google, TikTok, GA4 e Totale. */
.adv-history-modal-dialog { height: 90vh; max-height: 90vh; }
.adv-history-modal-body {
  flex: 1;
  min-height: 0;
  padding: 20px 24px;
  overflow: hidden;
}
.adv-history-table-card {
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  gap: 0;
}
.adv-history-table-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.adv-history-table-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.adv-history-table-scroll .adv-table thead th {
  top: 0;
  z-index: 2;
  padding-top: 12px;
  background: var(--card);
  box-shadow: 0 1px 0 var(--border);
}
.adv-history-table-scroll .adv-table th:first-child,
.adv-history-table-scroll .adv-table td:first-child { padding-left: 24px; }
.adv-history-table-scroll .adv-table th:last-child,
.adv-history-table-scroll .adv-table td:last-child { padding-right: 24px; }

/* ── Meta Alerts / Suggerimenti AI ─────────────────────────────────────── */
.meta-alerts-list { display: flex; flex-direction: column; gap: 0; padding: 0.25rem 0; }
.meta-alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 0.875rem 1rem; border-bottom: 1px solid var(--border);
}
.meta-alert:last-child { border-bottom: none; }
.meta-alert-icon {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 16px; margin-top: 1px;
}
.meta-alert-error .meta-alert-icon { background: #fee2e2; color: #dc2626; }
.meta-alert-warn .meta-alert-icon  { background: #fef3c7; color: #d97706; }
.meta-alert-info .meta-alert-icon  { background: #dbeafe; color: #2563eb; }
@media (prefers-color-scheme: dark) {
  .meta-alert-error .meta-alert-icon { background: rgba(220,38,38,.18); color: #f87171; }
  .meta-alert-warn .meta-alert-icon  { background: rgba(217,119,6,.18);  color: #fbbf24; }
  .meta-alert-info .meta-alert-icon  { background: rgba(37,99,235,.18);  color: #60a5fa; }
}
:root[data-theme="dark"] .meta-alert-error .meta-alert-icon { background: rgba(220,38,38,.18); color: #f87171; }
:root[data-theme="dark"] .meta-alert-warn .meta-alert-icon  { background: rgba(217,119,6,.18);  color: #fbbf24; }
:root[data-theme="dark"] .meta-alert-info .meta-alert-icon  { background: rgba(37,99,235,.18);  color: #60a5fa; }
:root[data-theme="light"] .meta-alert-error .meta-alert-icon { background: #fee2e2; color: #dc2626; }
:root[data-theme="light"] .meta-alert-warn .meta-alert-icon  { background: #fef3c7; color: #d97706; }
:root[data-theme="light"] .meta-alert-info .meta-alert-icon  { background: #dbeafe; color: #2563eb; }
.meta-alert-body { flex: 1; min-width: 0; }
.meta-alert-title { font-size: 0.875rem; font-weight: 600; line-height: 1.35; }
.meta-alert-desc  { font-size: 0.8rem; color: var(--muted-foreground); margin-top: 3px; line-height: 1.4; }
.meta-alert-dismiss { flex-shrink: 0; align-self: center; }
.meta-alert-btns { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }
.meta-alert-approve { white-space: nowrap; }
.meta-alert-action-desc {
  font-size: 0.78rem; color: var(--muted-foreground); margin-top: 5px;
  display: flex; align-items: center; gap: 5px;
}
.ma-confirm-box {
  background: var(--muted); border-radius: 8px; padding: .75rem 1rem;
  font-size: .875rem; font-weight: 500;
}
.meta-alerts-loading, .meta-alerts-empty {
  display: flex; align-items: center; gap: 8px;
  padding: 1rem; font-size: 0.875rem; color: var(--muted-foreground);
}
.meta-alerts-empty i { font-size: 18px; color: #16a34a; flex-shrink: 0; }
@media (prefers-color-scheme: dark) { .meta-alerts-empty i { color: #4ade80; } }
:root[data-theme="dark"] .meta-alerts-empty i { color: #4ade80; }
:root[data-theme="light"] .meta-alerts-empty i { color: #16a34a; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE (≤768px) — design ridisegnato (classi sc-/adv-/pl-/cro-).
   Il blocco mobile in style.css copre solo le classi legacy
   (.page-header/.data-table/.kpi-grid): tutte le pagine ricostruite usano
   sc-/adv-/pl-/cro- e restavano SCOPERTE su mobile → header con bottoni
   tagliati, tabelle mozzate, board kanban clippata, valori troncati.
   Sweep completo 2026-07-20: fix unico raggruppato per causa-radice.
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* 1. NAVBAR — il logo admin usa il wordmark completo "Lab26 | SIAMMESSI?"
     (SVG viewBox 0 0 2433, ~160px a 18px d'altezza) che spingeva fuori le
     icone azione a destra: l'icona logout finiva off-screen, irraggiungibile.
     Croppa il logo alla sola parte "Lab26" (che occupa i primi ~740/2433 del
     viewBox, = ~50px a questa altezza): libera >100px e nasconde anche
     "SIAMMESSI" (coerente con la regola di brand). Il logo client (viewBox
     740) è già compatto, non serve toccarlo. Icone leggermente più strette. */
  .navbar-admin .navbar-logo-link { max-width: 50px; overflow: hidden; }
  .navbar-actions { gap: 1px; }
  .navbar-icon-btn { width: 32px; height: 32px; }
  .navbar-actions-sep { margin: 0 2px; }

  /* 2. HEADER PAGINA — .sc-page-header è nowrap: titolo + gruppo bottoni CTA
     sulla stessa riga → bottoni tagliati a destra (lead sheet 5 btn, board
     "Nuova Scheda", scheda "Avanza", CRO "Genera e invia report", ...).
     Titolo su riga intera, gruppo azioni a capo sotto full-width e libero di
     andare a più righe (il !important batte l'inline flex-wrap:nowrap dei
     template). */
  .sc-page-header { flex-wrap: wrap; gap: 12px; }
  .sc-page-header > :first-child { flex: 1 1 100%; min-width: 0; }
  .sc-page-header > :last-child { width: 100%; flex-wrap: wrap !important; }

  /* 3. TABELLE DATI — strategia scelta: prima colonna sticky + scroll pulito.
     La 1ª colonna (Data/ora nei lead, Cliente nelle altre) resta ancorata
     mentre il resto scorre in orizzontale, così non si perde il contesto.
     Celle nowrap per evitare wrapping brutto mid-scroll; scroll touch fluido.
     .adv-table th ha già position:sticky top:0 (header verticale): aggiungere
     left:0 lo rende sticky anche in orizzontale, angolo compreso. */
  /* padding orizzontale a 0: la colonna sticky pinna a left:0 del padding-box,
     con padding sinistro > 0 il contenuto scrollato filtrava in quel gap a
     sinistra della colonna fissa. A filo card = niente bleed. */
  .adv-table-wrap { -webkit-overflow-scrolling: touch; padding-left: 0; padding-right: 0; }
  .adv-table td, .adv-table th { white-space: nowrap; }
  .adv-table th:first-child, .adv-table td:first-child,
  #lsTable th:nth-child(2), #lsTable td:nth-child(2) { padding-left: 16px; }
  .adv-table th:first-child { left: 0; z-index: 4; box-shadow: 1px 0 0 var(--border); }
  .adv-table td:first-child {
    position: sticky; left: 0; z-index: 3;
    background: var(--card); box-shadow: 1px 0 0 var(--border);
  }
  /* Tabella lead: la 1ª colonna è la checkbox di selezione (non un dato) —
     su mobile va nascosta (bulk-select non serve) e l'ancora sticky diventa
     la 2ª colonna, Data/ora, che è il vero riferimento della riga. Override
     mirato: le altre tabelle non hanno checkbox e usano la regola generica. */
  #lsTable th:first-child, #lsTable td:first-child { display: none; }
  #lsTable th:first-child { box-shadow: none; }
  #lsTable th:nth-child(2), #lsTable td:nth-child(2) {
    position: sticky; left: 0; z-index: 3;
    background: var(--card); box-shadow: 1px 0 0 var(--border);
  }
  #lsTable thead th:nth-child(2) { z-index: 4; }

  /* Tabelle mobile completamente scorrevoli in orizzontale: nessuna colonna
     resta ancorata, così anche sui viewport stretti l'area utile non viene
     occupata permanentemente dalla prima colonna. Il thead conserva solo lo
     sticky verticale già previsto dal componente tabella. */
  .adv-table th:first-child,
  #lsTable th:nth-child(2) {
    left: auto;
    box-shadow: none;
  }
  .adv-table td:first-child,
  #lsTable td:nth-child(2) {
    position: static;
    left: auto;
    box-shadow: none;
  }

  /* 4. RIGHE ETICHETTA/VALORE — .cro-info-row era flex space-between: valori
     lunghi a destra (email, URL) tagliati fuori dalla card. Impila
     etichetta sopra + valore sotto full-width che va a capo. */
  .cro-info-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .cro-info-row .value { text-align: left; max-width: 100%; word-break: break-word; }

  /* 5. BOARD ONBOARDING — da 5 colonne kanban affiancate (mozzate, card
     clippate) a stack verticale: ogni stage full-width, uno sotto l'altro. */
  .pl-kanban { grid-template-columns: 1fr; overflow-x: visible; }
  .pl-column { min-width: 0; }

  /* 6. STEPPER ONBOARDING — 5 step con flex:1 si comprimevano e le label si
     sovrapponevano. Larghezza fissa + scroll orizzontale (già overflow-x:auto
     sul .pl-stepper), label leggibili. */
  .pl-stepper { gap: 6px; }
  .pl-step { flex: 0 0 auto; min-width: 68px; }
}

@media (max-width: 360px) {
  /* 320px è il caso limite ancora comune (iPhone SE / split view). */
  .navbar { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .navbar-mobile-burger { margin-right: 2px; }
  .navbar-actions { margin-left: auto; }
  .navbar-icon-btn { width: 32px; height: 32px; }
  .navbar-actions-sep { display: none; }
  body:has(.sidebar) .main-content { padding: 1rem; }
  .sc-page-title { font-size: 1.35rem; }
  .sc-page-subtitle { line-height: 1.4; }
}

/* ══════════════════════════════════════════════════════
   SETTINGS MODAL
   ══════════════════════════════════════════════════════ */
.settings-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.settings-nav {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.settings-nav-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted-foreground);
  padding: 4px 10px 6px;
  margin-top: 4px;
}
.settings-nav-group-label:first-child { margin-top: 0; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  text-align: left;
  font-size: .845rem;
  font-weight: 600;
  color: var(--muted-foreground);
  cursor: pointer;
  width: 100%;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.settings-nav-item i { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted-foreground); transition: color .12s; }
.settings-nav-item:hover { background: var(--accent); color: var(--foreground); }
.settings-nav-item:hover i { color: var(--foreground); }
.settings-nav-item.active { background: var(--accent); color: var(--primary); }
.settings-nav-item.active i { color: var(--primary); }
.settings-nav-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.settings-panel { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.settings-panel.active { display: flex; }
/* settings-nav usata come colonna interna (automation, feedback) */
.settings-panel > div > .settings-nav {
  border-right: 1px solid var(--border);
  border-radius: 0;
  overflow-y: auto;
  align-self: stretch;
}
.settings-panel-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; min-height: 0; }
.settings-panel-footer {
  flex-shrink: 0;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ── Builder card nel modal lead ───────────────────────────────────────── */
.modal-layout-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-layout-head .sc-section-title { margin: 0 0 4px; }
.modal-layout-head .sc-page-subtitle { max-width: 640px; margin: 0; }
.modal-layout-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.modal-layout-actions .sc-select { width: auto; min-width: 146px; }
.modal-layout-groups { display: grid; gap: 12px; }
.modal-layout-group, .modal-layout-unassigned { border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.modal-layout-group-head, .modal-layout-unassigned-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--muted); }
.modal-layout-group-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.modal-layout-group-title > svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--primary); }
.modal-layout-group-label { width: min(100%, 360px); height: 2rem; padding: 0 8px; font-size: .9rem; font-weight: 650; border-color: transparent; background: transparent; }
.modal-layout-group-label:hover { border-color: var(--border); background: var(--card); }
.modal-layout-group-label:focus { border-color: var(--primary); background: var(--card); }
.modal-layout-group-controls { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }
.modal-layout-group-controls .sc-btn:disabled { opacity: .35; cursor: default; }
.modal-layout-arrow-up { transform: rotate(90deg); }
.modal-layout-arrow-down { transform: rotate(-90deg); }
.modal-layout-remove { color: var(--destructive); }
.modal-layout-field-list { display: grid; gap: 6px; min-height: 52px; padding: 12px 14px; transition: background .12s, box-shadow .12s; }
.modal-layout-field-list.is-drop-target { background: color-mix(in oklch, var(--primary) 8%, transparent); box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary) 40%, transparent); }
.modal-layout-field { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 34px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground); font: inherit; text-align: left; cursor: grab; }
.modal-layout-field:hover { border-color: color-mix(in oklch, var(--primary) 40%, var(--border)); background: var(--accent); }
.modal-layout-field:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.modal-layout-field.is-dragging { opacity: .42; }
.modal-layout-field.is-drop-target { border-top: 2px solid var(--primary); }
.modal-layout-field-drag { color: var(--muted-foreground); line-height: 1; letter-spacing: -2px; }
.modal-layout-field-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; font-weight: 550; }
.modal-layout-field-type { margin-left: auto; padding: 2px 7px; border-radius: var(--radius-4xl); background: var(--muted); color: var(--muted-foreground); font-size: .68rem; line-height: 1.2; white-space: nowrap; }
.modal-layout-empty, .modal-layout-empty-state { margin: 0; color: var(--muted-foreground); font-size: .82rem; }
.modal-layout-empty { padding: 3px 0; }
.modal-layout-empty-state { padding: 18px; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }
.modal-layout-unassigned { margin-top: 14px; }
.modal-layout-unassigned-head { align-items: flex-start; }
.modal-layout-unassigned-head .sc-section-title { display: block; margin: 0 0 3px; font-size: .88rem; }
.modal-layout-unassigned-head p { margin: 0; color: var(--muted-foreground); font-size: .78rem; }

@media (max-width: 760px) {
  .modal-layout-head { flex-direction: column; }
  .modal-layout-actions { width: 100%; justify-content: space-between; }
}

.feedback-stage-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  padding: 4px 12px;
}
/* Le metriche non usano varianti decorative per posizione: niente
   gradienti o bordi colorati diversi fra prima, seconda, terza card. */
.kpi-card,.db-count-card,.rm-kpi-card,.cro-kpi-card,
body.dark-mode .kpi-card,body.dark-mode .db-count-card,
body.dark-mode .rm-kpi-card,body.dark-mode .cro-kpi-card{
  background:var(--card)!important;
  border-top:1px solid var(--border)!important;
}
.client-preview-navbar{position:absolute;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:.5rem;max-width:min(42vw,520px);padding:.38rem .65rem;border:1px solid #edc77f;border-radius:999px;background:#fff4df;color:#734b13;font-size:.72rem;white-space:nowrap}.client-preview-navbar>svg{width:.9rem;height:.9rem;flex:0 0 auto}.client-preview-navbar>span:not(.client-preview-readonly){overflow:hidden;text-overflow:ellipsis}.client-preview-readonly{border-radius:999px;background:#f0cc86;padding:.18rem .42rem;font-size:.58rem;font-weight:800;text-transform:uppercase;letter-spacing:.04em}.client-preview-mode form button[type="submit"],.client-preview-mode [data-save],.client-preview-mode .usr-action-danger{opacity:.45!important;cursor:not-allowed!important}
.set-preview-card{max-width:620px}.set-preview-copy h3{margin:0 0 .35rem;font-size:1rem}.set-preview-copy p{margin:0;color:var(--muted-foreground);font-size:.8rem;line-height:1.55}.set-preview-safety{display:flex;gap:.75rem;align-items:flex-start;padding:.85rem;border:1px solid color-mix(in srgb,var(--primary) 38%,var(--border));background:color-mix(in srgb,var(--primary) 8%,var(--card));border-radius:.75rem}.set-preview-safety>svg{width:1.1rem;height:1.1rem;color:var(--primary);flex:0 0 auto}.set-preview-safety span{display:grid;gap:.2rem}.set-preview-safety b{font-size:.75rem}.set-preview-safety small{font-size:.67rem;color:var(--muted-foreground);line-height:1.4}
@media(max-width:768px){.client-preview-navbar{position:static;transform:none;margin-left:auto;max-width:44vw}.client-preview-navbar>svg,.client-preview-readonly{display:none}.client-preview-navbar>span:not(.client-preview-readonly){max-width:100%}}
.lo-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.lo-item-row {
  display: grid;
  grid-template-columns: minmax(10rem, 1.4fr) minmax(7rem, 1fr) minmax(4.5rem, .55fr) minmax(5.5rem, .7fr) auto;
  gap: 6px;
  margin-bottom: 6px;
}

.lo-summary {
  display: flex;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.lo-summary-item {
  display: flex;
  min-width: 0;
  flex: 1 1 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 16px;
  border-right: 1px solid var(--border);
}

.lo-summary-item:first-child {
  padding-left: 0;
}

.lo-summary-item:last-child {
  padding-right: 0;
  border-right: 0;
}

.lo-summary-item span {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: .76rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lo-summary-item strong {
  flex: 0 0 auto;
  color: var(--foreground);
  font-size: .9rem;
}

.lo-order-card {
  gap: 9px;
  margin-bottom: 10px;
  padding: 14px 16px;
}

.lo-order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lo-order-identity {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.lo-order-identity strong {
  font-size: .92rem;
}

.lo-order-identity span,
.lo-order-meta,
.lo-order-items {
  color: var(--muted-foreground);
  font-size: .78rem;
}

.lo-order-value {
  flex: 0 0 auto;
  font-size: .95rem;
}

.lo-order-meta,
.lo-order-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
}

.lo-order-meta-item,
.lo-order-item {
  position: relative;
  white-space: nowrap;
}

.lo-order-meta-item:not(:last-child)::after,
.lo-order-item:not(:last-child)::after {
  position: absolute;
  right: -9px;
  color: var(--border-strong, var(--border));
  content: "·";
}

.lo-order-items {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.lo-order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: -2px;
}

.intg-code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--muted);
  font-family: monospace;
  font-size: .82rem;
}

.intg-pre {
  overflow-x: auto;
  margin: 6px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  font-size: .8rem;
  white-space: pre;
}

.intg-scope-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
}

.intg-scope-row input { margin-top: 3px; }
.intg-scope-row strong,
.intg-scope-row small { display: block; }
.intg-scope-row small { margin-top: 3px; color: var(--muted-foreground); }

.intg-keybox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
}

.intg-keybox code {
  flex: 1;
  min-width: 0;
  font-family: monospace;
  font-size: .82rem;
  word-break: break-all;
}

/* ── Chiavi API self-service cliente ─────────────────────────────── */
.client-api-dialog {
  width: min(48rem, calc(100vw - 32px));
  max-width: 48rem;
  max-height: min(42rem, calc(100vh - 32px));
  overflow: hidden;
}

.client-api-dialog [hidden] { display: none !important; }

.client-api-dialog-header {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.client-api-dialog-header .sc-page-subtitle {
  margin: 4px 0 0;
}

.client-api-dialog-body {
  overflow-y: auto;
  /* Il focus ring degli input sporge 3px: il body scrollabile lo ritagliava
     sui quattro lati. Il buffer con margine compensato lascia respirare il
     ring senza cambiare l'allineamento visivo dei contenuti. */
  margin: -3px;
  padding: 3px;
}

.client-api-view-stack {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 24px;
}

.client-api-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.client-api-toolbar p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: .84rem;
}

.client-api-loading {
  padding: 32px 16px;
  color: var(--muted-foreground);
  text-align: center;
  font-size: .86rem;
}

.client-api-empty {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted-foreground);
  text-align: center;
}

.client-api-empty svg {
  width: 26px;
  height: 26px;
  margin-bottom: 2px;
}

.client-api-empty strong {
  color: var(--foreground);
  font-size: .95rem;
}

.client-api-empty span {
  max-width: 24rem;
  font-size: .82rem;
}

.client-api-key-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 25rem;
  overflow-y: auto;
  padding: 1px;
}

.client-api-key-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, auto) auto;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.client-api-key-card:hover {
  border-color: color-mix(in oklch, var(--foreground) 18%, var(--border));
  box-shadow: 0 3px 12px color-mix(in oklch, var(--foreground) 6%, transparent);
}

.client-api-key-card.is-revoked {
  background: color-mix(in oklch, var(--muted) 45%, var(--card));
}

.client-api-key-primary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.client-api-key-icon {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: color-mix(in oklch, var(--primary) 13%, transparent);
  color: var(--primary);
}

.client-api-key-icon svg {
  width: 18px;
  height: 18px;
}

.client-api-key-card.is-revoked .client-api-key-icon {
  background: var(--muted);
  color: var(--muted-foreground);
}

.client-api-key-identity {
  min-width: 0;
}

.client-api-key-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.client-api-key-title strong {
  overflow: hidden;
  color: var(--foreground);
  font-size: .9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-api-key-meta {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.client-api-key-meta > div {
  display: grid;
  gap: 1px;
}

.client-api-key-meta span {
  color: var(--muted-foreground);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.client-api-key-meta strong {
  color: var(--foreground);
  font-size: .78rem;
  font-weight: 500;
}

.client-api-masked-key {
  display: block;
  max-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted-foreground);
  font-family: monospace;
  font-size: .74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-api-status-active {
  background: color-mix(in oklch, var(--success) 12%, transparent);
  color: var(--success);
}

.client-api-key-action {
  display: flex;
  justify-content: flex-end;
}

.client-api-revoke {
  color: var(--muted-foreground);
}

.client-api-revoke:hover {
  border-color: color-mix(in oklch, var(--destructive) 30%, var(--border));
  background: color-mix(in oklch, var(--destructive) 8%, transparent);
  color: var(--destructive);
}

.client-api-revoke svg { width: 14px; height: 14px; }

.client-api-error {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--destructive) 8%, transparent);
  color: var(--destructive);
  font-size: .82rem;
}

.client-api-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
}

.client-api-back:hover { color: var(--foreground); }
.client-api-back svg { width: 15px; height: 15px; }

.client-api-scope-block {
  margin-top: 18px;
}

.client-api-secret-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 0;
  padding: 12px;
  border: 1px solid color-mix(in oklch, var(--warning) 35%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--warning) 10%, transparent);
}

.client-api-secret-warning svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--warning);
}

.client-api-secret-warning strong,
.client-api-secret-warning span {
  display: block;
}

.client-api-secret-warning span {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: .82rem;
}

.client-api-keybox code {
  user-select: all;
}

.client-api-secret-hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: .8rem;
}

@media (max-width: 768px) {
  .client-api-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .client-api-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .client-api-toolbar .sc-btn {
    justify-content: center;
  }

  .client-api-keybox {
    align-items: stretch;
    flex-direction: column;
  }

  .client-api-key-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
  }

  .client-api-key-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }

  .client-api-key-action {
    grid-column: 1 / -1;
  }

  .client-api-key-action .sc-btn {
    width: 100%;
    justify-content: center;
  }

  .lo-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .lo-form-grid > [style*="grid-column"] {
    grid-column: 1 !important;
  }

  .lo-item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .lo-item-row > .lo-desc,
  .lo-item-row > .lo-format {
    grid-column: 1 / -1;
  }

  .lo-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 0;
  }

  .lo-summary-item {
    padding: 2px 10px;
  }

  .lo-summary-item:nth-child(2) {
    padding-right: 0;
    border-right: 0;
  }

  .lo-summary-item:nth-child(3) {
    padding-left: 0;
  }

  .lo-order-card {
    padding: 12px;
  }

  .lo-order-head {
    gap: 10px;
  }

  .lo-order-actions {
    justify-content: stretch;
  }

  .lo-order-actions .sc-btn {
    flex: 1 1 0;
  }
}

/* Filtro brand: stessa identità visiva del selettore di periodo (.pselector-trigger),
   così i due controlli affiancati sembrano lo stesso componente. */
.performance-period-left,
.stakeholder-period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.brand-filter-select.brand-filter-select {
  width: auto;
  min-width: 170px;
  height: auto;
  margin-bottom: 16px; /* pari a .pselector-wrap: mantiene le basi allineate */
  padding: 7px 30px 7px 13px; /* spazio a destra per la freccia nativa */
  background: var(--card);
  border: none;
  border-radius: var(--radius-md);
  color: var(--foreground);
  font-size: .875rem;
  cursor: pointer;
  white-space: nowrap;
  transition: box-shadow .15s;
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--foreground) 10%, transparent), var(--content-shadow);
}
.brand-filter-select.brand-filter-select:hover,
.brand-filter-select.brand-filter-select:focus,
.brand-filter-select.brand-filter-select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--primary), var(--content-shadow);
}
