/* ============================================================
   crm_components.css — DESIGN SYSTEM CANONICO Nova CRM
   ----------------------------------------------------------------
   Single source of truth per i componenti UI riutilizzabili:
   - Bottoni (.crm-btn family)
   - Bottoni speciali: Guida (?), Aggiorna (↻)
   - Tabelle (.crm-table)
   - Status pills (.crm-pill family)
   - Modali (.crm-modal family)
   - Icone (dimensioni canoniche)
   - Filtri (.cl-filter-* già esistenti, qui completati)

   USO: includere DOPO dash.css. Le pagine del CRM possono usare
   queste classi al posto dei loro prefissi locali (jag-*, tta-*, ecc.).

   ⚠ Non duplicare regole già in filter_bar.css (.cl-tab-filter-bar,
     .cl-status-pills, .cl-status-pill) — qui le riusiamo.
   ============================================================ */


/* ── BOTTONI ─────────────────────────────────────────────── */
/* Pattern Apple/macOS: bordi soft, hover sottile, focus visibile */
.crm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.crm-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cfd9e6;
}
.crm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.crm-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Variante primary (azione principale) */
.crm-btn-primary {
  background: #007aff;
  color: #fff;
  border-color: #007aff;
  font-weight: 600;
}
.crm-btn-primary:hover:not(:disabled) {
  background: #005bb5;
  border-color: #005bb5;
}

/* Variante danger (azione distruttiva) */
.crm-btn-danger {
  background: #fff;
  color: #dc2626;
  border-color: #fecaca;
}
.crm-btn-danger:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
}

/* Variante ghost (azione secondaria) */
.crm-btn-ghost {
  background: transparent;
  color: #475569;
  border-color: transparent;
}
.crm-btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  color: #0f172a;
}

/* Misure */
.crm-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.crm-btn-lg { height: 38px; padding: 0 18px; font-size: 14px; }


/* ── TOOLBAR VERCEL-STYLE (Linear/Vercel/Stripe veri) ──────── */
/* DNA Vercel: tab underline (NON pillola/segmented), bottoni
   con chrome minimo (border zinc-200, hover bg zinc-50),
   bordo bottom della toolbar (non card chiusa).
   Tipografia tight, lettering -0.01em, Inter/Geist feel. */
.crm-toolbar-vc {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 38px;
  padding: 0 14px;
  background: #ffffff;
  border-bottom: 1px solid #eaeaea;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Geist", "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

/* Tab Vercel — underline pattern */
.crm-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-right: 12px;
}
.crm-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: #71717a;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  user-select: none;
}
.crm-tab:hover:not(.active):not(:disabled) {
  color: #18181b;
}
.crm-tab.active {
  color: #18181b;
  border-bottom-color: #18181b;
  font-weight: 600;
}
.crm-tab:focus { outline: none; }
.crm-tab:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: -2px;
  border-radius: 4px;
}

/* Badge contatore inline nel tab (Tutti 45, Alia 30, CRM 15) */
.crm-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #71717a;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.crm-tab.active .crm-tab-count {
  background: rgba(24,24,27,0.10);
  color: #18181b;
}
.crm-tab-count[data-count="0"] { opacity: 0.4; }

/* Bottoni Vercel — chrome minimo, border zinc-200 */
.crm-vbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  align-self: center;
  height: 30px;
  padding: 0 10px;
  background: #ffffff;
  border: 1px solid #eaeaea;
  border-radius: 6px;
  color: #18181b;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
  user-select: none;
  letter-spacing: -0.01em;
}
.crm-vbtn:hover:not(:disabled) {
  background: #fafafa;
  border-color: #d4d4d8;
}
.crm-vbtn:active:not(:disabled) {
  background: #f4f4f5;
}
.crm-vbtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.crm-vbtn:focus { outline: none; }
.crm-vbtn:focus-visible {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #18181b;
}
.crm-vbtn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.crm-vbtn.icon-only {
  width: 30px;
  padding: 0;
}
.crm-vbtn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
}

/* Variante ghost (no chrome in idle, hover sottile) */
.crm-vbtn.ghost {
  background: transparent;
  border-color: transparent;
  color: #52525b;
}
.crm-vbtn.ghost:hover:not(:disabled) {
  background: #f4f4f5;
  border-color: transparent;
  color: #18181b;
}


/* ── TOOLBAR MAC SONOMA (barra translucida + segmented + tools) ── */
/* Ricostruzione fedele del chrome di una finestra macOS:
   barra translucida con vibrancy, hairline grigia in basso,
   segmented control a sinistra, tool buttons a destra.
   Pattern Finder, Mail, Notes (2024-2025). */
.crm-mac-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  padding: 0 12px;
  background: rgba(246, 246, 246, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 10px 10px 0 0;
}

/* Segmented control (Tutti/Alia/CRM come unico controllo) */
.crm-mac-segmented {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 7px;
  padding: 2px;
  height: 28px;
  gap: 0;
}
.crm-mac-segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
  user-select: none;
}
.crm-mac-segment:hover:not(.active):not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
}
.crm-mac-segment.active {
  background: #ffffff;
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.10);
  font-weight: 600;
}

/* Tool buttons (Rinfresca, Sistema scarsi, ↻, ?) — niente chrome */
.crm-mac-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease;
  white-space: nowrap;
  user-select: none;
}
.crm-mac-tool:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
}
.crm-mac-tool:active:not(:disabled) {
  background: rgba(0, 0, 0, 0.10);
}
.crm-mac-tool:focus { outline: none; }
.crm-mac-tool:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: 1px;
}
.crm-mac-tool:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.crm-mac-segment:focus { outline: none; }
.crm-mac-segment:focus-visible {
  outline: 2px solid #007aff;
  outline-offset: 1px;
}
.crm-mac-tool svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.crm-mac-tool.icon-only {
  width: 28px;
  padding: 0;
}


/* ── BOTTONE TOOLBAR MAC (canonico Finder/Mail/Notes 2024) ─── */
/* Pattern macOS toolbar: nessun bordo, nessuno sfondo in idle.
   Hover = sfondo grigio chiaro 6% nero. Pressed = 10%.
   Tutti uguali (Rinfresca, Sistema scarsi, qualsiasi azione).
   Niente tinte rosse/blu — il chrome è uniforme.
   Distinguere le azioni via: posizione, icona, label. */
.crm-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #1d1d1f;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s ease;
  white-space: nowrap;
  user-select: none;
}
.crm-toolbar-btn:hover:not(:disabled) {
  background: rgba(0,0,0,0.06);
}
.crm-toolbar-btn:active:not(:disabled) {
  background: rgba(0,0,0,0.10);
}
.crm-toolbar-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.crm-toolbar-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.crm-toolbar-btn.icon-only {
  width: 28px;
  padding: 0;
}


/* ── ICONE BOTTONE STILE MAC (sobrie, solo simbolo) ──────── */
/* Pattern macOS Finder/Mail toolbar: cerchio sottile, sfondo
   trasparente che si schiarisce in hover, simbolo grigio scuro.
   Usate per Guida (?), Aggiorna (↻), Aggiungi (+). */
.crm-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  color: #334155;
  border: 1px solid rgba(0,0,0,0.14);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}
.crm-btn-icon:hover:not(:disabled) {
  background: rgba(0,0,0,0.05);
  color: #0f172a;
}
.crm-btn-icon:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
.crm-btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

/* Guida — solo "?" stile macOS */
.crm-btn-help { /* alias semantico */ }
.crm-btn-help::before { content: "?"; }

/* Guida pipeline — apre la guida step-by-step della generazione */
.crm-btn-guide-book::before { content: "📖"; font-size: 14px; }

/* Aggiorna — ↻ stile macOS (SVG inline come pseudo-element) */
.crm-btn-refresh::before {
  content: "";
  width: 14px;
  height: 14px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23334155" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
}
.crm-btn-refresh:hover::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%230f172a" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"/></svg>');
}
.crm-btn-refresh.loading::before { animation: crm-spin 0.8s linear infinite; }
@keyframes crm-spin { to { transform: rotate(360deg); } }

/* Aggiungi — "+" stile macOS, accent BLU (azione primaria) */
.crm-btn-add {
  color: #007aff;
  border-color: rgba(0, 122, 255, 0.30);
}
.crm-btn-add:hover:not(:disabled) {
  background: rgba(0, 122, 255, 0.10);
  color: #005bb5;
  border-color: rgba(0, 122, 255, 0.50);
}
.crm-btn-add::before { content: "+"; font-size: 18px; font-weight: 400; }

/* Sync — refresh stilizzato accent BLU (azione di sync da rete/API) */
.crm-btn-sync {
  color: #007aff;
  border-color: rgba(0, 122, 255, 0.30);
}
.crm-btn-sync:hover:not(:disabled) {
  background: rgba(0, 122, 255, 0.10);
  border-color: rgba(0, 122, 255, 0.50);
}
.crm-btn-sync::before {
  content: "";
  width: 14px;
  height: 14px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23007aff" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
}
.crm-btn-sync:hover::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23005bb5" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"/></svg>');
}
.crm-btn-sync.loading::before { animation: crm-spin 0.8s linear infinite; }

/* Sync GDrive — icona cloud sync nel bottone circolare */
.crm-btn-gdrive {
  color: #334155;
  border: 1px solid rgba(0,0,0,0.14);
  background: rgba(91, 141, 239, 0.08);
  border-radius: 50%;
  width: 28px;
  height: 28px;
}
.crm-btn-gdrive:hover:not(:disabled) {
  background: rgba(91, 141, 239, 0.14);
  color: #0f172a;
  border-color: rgba(91, 141, 239, 0.28);
}
.crm-btn-gdrive::before {
  content: "";
  width: 18px;
  height: 18px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23334155" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 18a4.5 4.5 0 1 1 .88-8.913A5.25 5.25 0 0 1 18.75 10.5 3.75 3.75 0 1 1 18 18H7.5Z"/><path d="M9 14.25 12 11.5l3 2.75"/><path d="M12 11.5v6"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.crm-btn-gdrive:hover::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%230f172a" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M7.5 18a4.5 4.5 0 1 1 .88-8.913A5.25 5.25 0 0 1 18.75 10.5 3.75 3.75 0 1 1 18 18H7.5Z"/><path d="M9 14.25 12 11.5l3 2.75"/><path d="M12 11.5v6"/></svg>');
}

/* Upload PDF — stesso linguaggio visivo di GDrive (icona-only) */
.crm-btn-pdf-upload {
  color: #0a84ff;
  border: 1px solid rgba(10, 132, 255, 0.30);
  background: transparent;
  border-radius: 50%;
  width: 28px;
  height: 28px;
}
.crm-btn-pdf-upload:hover:not(:disabled) {
  background: rgba(10, 132, 255, 0.10);
  color: #005bb5;
  border-color: rgba(10, 132, 255, 0.50);
}
.crm-btn-pdf-upload::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%230a84ff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: none;
  transition: transform 0.15s ease;
}
.crm-btn-pdf-upload:hover::before {
  transform: translateY(-0.5px) scale(1.03);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23005bb5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>');
}

/* Importa da Windoc — icona download accent BLU (toolbar) */
.crm-btn-windoc {
  color: #0a84ff;
  border-color: rgba(10, 132, 255, 0.30);
}
.crm-btn-windoc:hover:not(:disabled) {
  background: rgba(10, 132, 255, 0.10);
  color: #005bb5;
  border-color: rgba(10, 132, 255, 0.50);
}
.crm-btn-windoc::before {
  content: "";
  width: 14px;
  height: 14px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%230a84ff" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
}
.crm-btn-windoc:hover::before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23005bb5" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>');
}

/* ── Set esteso icone toolbar Mac-style ──────────────────── */
/* Pattern: tutti uguali (28px cerchio, bordo grigio sottile),
   solo l'icona SVG cambia. Hover scurisce. */
.crm-btn-edit::before,
.crm-btn-delete::before,
.crm-btn-view::before,
.crm-btn-search::before,
.crm-btn-settings::before,
.crm-btn-download::before,
.crm-btn-upload::before,
.crm-btn-share::before,
.crm-btn-archive::before,
.crm-btn-copy::before {
  content: "";
  width: 14px;
  height: 14px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
/* Modifica (pencil) */
.crm-btn-edit::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487 18.549 2.799a2.121 2.121 0 1 1 3 3L19.862 7.487M16.862 4.487 6.408 14.94a4.5 4.5 0 0 0-1.13 1.897l-.9 2.7-.07.21.21-.07 2.7-.9a4.5 4.5 0 0 0 1.897-1.13l10.453-10.453M16.862 4.487 19.862 7.487"/></svg>'); }
/* Elimina (trash) — accent rosso sottile in hover */
.crm-btn-delete::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"/></svg>'); }
.crm-btn-delete { color: #dc2626; border-color: rgba(220,38,38,0.25); }
.crm-btn-delete:hover:not(:disabled) { background: rgba(220,38,38,0.08); color: #991b1b; border-color: rgba(220,38,38,0.40); }
.crm-btn-delete:hover::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23991b1b" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"/></svg>'); }
/* Visualizza (eye) */
.crm-btn-view::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/></svg>'); }
/* Cerca (magnifying glass) */
.crm-btn-search::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"/></svg>'); }
/* Impostazioni (gear) */
.crm-btn-settings::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a6.93 6.93 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/></svg>'); }
/* Download (arrow down to tray) */
.crm-btn-download::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3"/></svg>'); }
/* Upload (arrow up from tray) */
.crm-btn-upload::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 7.5 12 3m0 0L7.5 7.5M12 3v13.5"/></svg>'); }
/* Condividi (share arrow box) */
.crm-btn-share::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M7.217 10.907a2.25 2.25 0 1 0 0 2.186m0-2.186c.18.324.283.696.283 1.093s-.103.77-.283 1.093m0-2.186 9.566-5.314m-9.566 7.5 9.566 5.314m0 0a2.25 2.25 0 1 0 3.935 2.186 2.25 2.25 0 0 0-3.935-2.186Zm0-12.814a2.25 2.25 0 1 0 3.933-2.185 2.25 2.25 0 0 0-3.933 2.185Z"/></svg>'); }
/* Archivia/Lucchetto (lock-closed) */
.crm-btn-archive::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"/></svg>'); }
/* Copia (clipboard) */
.crm-btn-copy::before { background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="%23475569" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15.666 3.888A2.25 2.25 0 0 0 13.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 0 1-.75.75H9a.75.75 0 0 1-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 0 1-2.25 2.25H6.75A2.25 2.25 0 0 1 4.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 0 1 1.927-.184"/></svg>'); }


/* ── ICONE AZIONE NELLE RIGHE TABELLA (.crm-row-action) ─── */
/* Stile canonico identico a admin_invoices: emoji o SVG colorato
   tipo macOS app icon, NESSUN bordo/sfondo, hover con scale + opacity.
   24x24 contenitore, font-size 22px per emoji native iOS/macOS. */
.crm-row-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 22px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
  vertical-align: middle;
}
.crm-row-action:hover:not(:disabled) {
  opacity: 1;
  transform: scale(1.08);
  background: transparent;
}
.crm-row-action:disabled { opacity: 0.4; cursor: not-allowed; }
.crm-row-action svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Badge contatore (tipo "invii email = 2") sul corner top-right */
.crm-row-action .crm-row-action-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: #f59e0b;
  color: #fff;
  border-radius: 50%;
  font-size: 8px;
  font-weight: 900;
  min-width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 2px;
}

/* Container per gruppo di azioni a fine riga */
.crm-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}


/* ── ICONE CANONICHE ─────────────────────────────────────── */
.crm-icon-sm  { width: 14px; height: 14px; flex-shrink: 0; }
.crm-icon     { width: 16px; height: 16px; flex-shrink: 0; }
.crm-icon-lg  { width: 20px; height: 20px; flex-shrink: 0; }


/* ── TABELLE ─────────────────────────────────────────────── */
.crm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.crm-table th {
  padding: 8px 10px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
  font-size: 11px;
  color: #475569;
  text-transform: none !important;  /* override del global th { uppercase } di dash.css */
  letter-spacing: 0 !important;
  text-align: left;
  white-space: nowrap;
}
.crm-table thead tr:first-child th:first-child { border-top-left-radius: 12px; }
.crm-table thead tr:first-child th:last-child  { border-top-right-radius: 12px; }
.crm-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  vertical-align: middle;
}
.crm-table tbody tr { transition: background 0.12s; }
.crm-table tbody tr:hover { background: #f8fafc; cursor: pointer; }
.crm-table tbody tr:last-child td { border-bottom: none; }

/* Sort indicator sui th cliccabili */
.crm-table th .th-sort {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.crm-table th .th-sort:hover { color: #3b82f6; }
.crm-table th .th-sort .sort-arrow { font-size: 9px; opacity: 0.4; line-height: 1; }
.crm-table th .th-sort.sort-asc  .sort-arrow::before { content: "▲"; opacity: 1; color: #3b82f6; }
.crm-table th .th-sort.sort-desc .sort-arrow::before { content: "▼"; opacity: 1; color: #3b82f6; }
.crm-table th .th-sort:not(.sort-asc):not(.sort-desc) .sort-arrow::before { content: "⇅"; }


/* ── STATUS PILLS (badge stato) ──────────────────────────── */
.crm-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.crm-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
/* Varianti semantiche */
.crm-pill-success { background: rgba(16,185,129,0.10); color: #047857; }
.crm-pill-warning { background: rgba(245,158,11,0.10); color: #92400e; }
.crm-pill-danger  { background: rgba(239,68,68,0.10);  color: #b91c1c; }
.crm-pill-info    { background: rgba(59,130,246,0.10); color: #1e40af; }
.crm-pill-neutral { background: #f1f5f9;               color: #64748b; }
.crm-pill-purple  { background: rgba(139,92,246,0.10); color: #6d28d9; }
/* Performance health (per Storico TT) */
.crm-pill-burn { background: rgba(239,68,68,0.10); color: #991b1b; font-weight: 700; }
.crm-pill-slow { background: rgba(245,158,11,0.10); color: #92400e; font-weight: 700; }
.crm-pill-ok   { background: rgba(16,185,129,0.10); color: #047857; font-weight: 700; }
.crm-pill-new  { background: rgba(99,102,241,0.10); color: #3730a3; font-weight: 600; }


/* ── MODALI ──────────────────────────────────────────────── */
.crm-modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.crm-modal-bg.active { display: flex; }
.crm-modal-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}
.crm-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.crm-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}
.crm-modal-header .close-x {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.crm-modal-header .close-x:hover { background: #f1f5f9; color: #0f172a; }
.crm-modal-section { margin-bottom: 18px; }
.crm-modal-section h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.crm-modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  margin-top: 16px;
}


/* ── LOADER (spinner) ────────────────────────────────────── */
.crm-loader {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: crm-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.crm-loader-lg { width: 28px; height: 28px; border-width: 3px; }


/* ════════════════════════════════════════════════════════════
   NUOVI COMPONENTI (file upload, tag input, tooltip,
   checkbox/radio, date picker)
   ════════════════════════════════════════════════════════════ */


/* ── FILE UPLOAD (drop zone) ─────────────────────────────── */
.crm-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 20px;
  background: #fafafa;
  border: 2px dashed #d4d4d8;
  border-radius: 10px;
  color: #52525b;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
}
.crm-upload:hover,
.crm-upload.dragover {
  background: #f0f9ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}
.crm-upload-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #71717a;
}
.crm-upload-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.crm-upload-title { font-size: 14px; font-weight: 600; color: #18181b; }
.crm-upload-hint  { font-size: 12px; color: #71717a; }
.crm-upload-cta   { font-size: 13px; color: #2563eb; font-weight: 500; }
.crm-upload input[type="file"] { display: none; }


/* ── TAG / CHIP INPUT (multi-valore) ─────────────────────── */
.crm-tag-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 8px;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  cursor: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.crm-tag-field:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.10);
}
.crm-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 4px 0 10px;
  background: #f4f4f5;
  border: 1px solid #e4e4e7;
  border-radius: 999px;
  color: #18181b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.crm-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: 0;
  color: #71717a;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.crm-tag-remove:hover { background: #e4e4e7; color: #18181b; }
.crm-tag-input {
  flex: 1 1 80px;
  min-width: 80px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
  color: #18181b;
  padding: 4px 6px;
}


/* ── TOOLTIP (canonico, oltre title HTML) ────────────────── */
.crm-tooltip {
  position: relative;
  display: inline-flex;
}
.crm-tooltip[data-tip]::after,
.crm-tooltip[data-tip]::before {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
  z-index: 100;
}
.crm-tooltip[data-tip]::after {
  content: attr(data-tip);
  background: #18181b;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  letter-spacing: -0.01em;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.crm-tooltip[data-tip]::before {
  content: '';
  bottom: calc(100% + 1px);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #18181b;
}
.crm-tooltip[data-tip]:hover::after,
.crm-tooltip[data-tip]:hover::before,
.crm-tooltip[data-tip]:focus-visible::after,
.crm-tooltip[data-tip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}
/* Variante posizione bottom */
.crm-tooltip[data-tip-pos="bottom"]::after {
  bottom: auto;
  top: calc(100% + 6px);
}
.crm-tooltip[data-tip-pos="bottom"]::before {
  bottom: auto;
  top: calc(100% + 1px);
  border-top: 0;
  border-bottom: 5px solid #18181b;
}


/* ── CHECKBOX / RADIO (canonici, stile Mac/SaaS) ─────────── */
.crm-check,
.crm-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #18181b;
  user-select: none;
  line-height: 1.3;
}
.crm-check input[type="checkbox"],
.crm-radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid #d4d4d8;
  background: #ffffff;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  position: relative;
}
.crm-check input[type="checkbox"] { border-radius: 4px; }
.crm-radio input[type="radio"]    { border-radius: 50%; }
.crm-check input[type="checkbox"]:hover,
.crm-radio input[type="radio"]:hover {
  border-color: #a1a1aa;
}
.crm-check input[type="checkbox"]:checked,
.crm-radio input[type="radio"]:checked {
  background: #2563eb;
  border-color: #2563eb;
}
.crm-check input[type="checkbox"]:checked::after {
  content: '';
  width: 9px;
  height: 9px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5L6.5 12L13 4.5"/></svg>') no-repeat center / contain;
}
.crm-radio input[type="radio"]:checked::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #ffffff;
  border-radius: 50%;
}
.crm-check input:focus-visible,
.crm-radio input:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
.crm-check input:disabled,
.crm-radio input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.crm-check input:disabled ~ *,
.crm-radio input:disabled ~ * {
  opacity: 0.5;
}


/* ── DATE PICKER (input nativo styled) ───────────────────── */
.crm-date {
  height: 36px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  font-size: 13px;
  color: #18181b;
  font-family: inherit;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-variant-numeric: tabular-nums;
}
.crm-date:hover { border-color: #d4d4d8; }
.crm-date:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.10);
}
.crm-date:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #fafafa;
}
/* Icona calendario nativa più discreta */
.crm-date::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.crm-date:hover::-webkit-calendar-picker-indicator { opacity: 0.85; }

/* ── Pill filter (Workspace style) ─────────────────────────────
   Pillola filtro singola, rounded Apple-style. Single source of truth
   per tutte le tab del Generatore annunci, Setup TT/Alia, ecc.
   Usata come <span class="pill-filter [active]" data-*>...</span>. */
.pill-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 100px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #334155;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
  white-space: nowrap;
}
.pill-filter:hover { background: #f8fafc; }
.pill-filter.active {
  background: #007aff; color: #fff; border-color: #007aff;
}
.pill-filter .count {
  font-size: 11px; padding: 0 5px; border-radius: 8px;
  background: rgba(0,0,0,0.06); font-weight: 600;
}
.pill-filter.active .count { background: rgba(255,255,255,0.25); }
