/* ==========================================================
   Mailing Commerciali — foglio di stile
   Stessa base di KPI Chiamate; le aggiunte di questo portale sono in fondo.
   Palette istituzionale Credit System (#375d96).
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Marchio */
  --brand:       #375d96;
  --brand-700:   #2a4875;
  --brand-300:   #8fb0d9;
  --brand-50:    #f1f5fa;

  /* Testo */
  --ink:         #1b1d21;
  --ink-2:       #5c6470;
  --ink-3:       #8d949f;

  /* Superfici */
  --bg:          #f6f7f9;
  --card:        #ffffff;
  --line:        #e7eaee;      /* divisori, bordi delle card: non deve gridare */
  --line-soft:   #f0f2f5;
  --line-strong: #c7ccd4;      /* bordo di input, select, pulsanti, pannelli: deve leggersi bene */

  /* Semantici */
  --pos:         #2f7d4f;
  --pos-bg:      #edf6f1;
  --neg:         #b42318;
  --neg-bg:      #fdf0ee;
  --warn-bg:     #fff6e8;
  --warn:        #8a5a12;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --sh-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --sh:    0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 8px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Cifre a larghezza fissa: le colonne di numeri restano allineate */
.num, table td, .stat-value, .kpi-value, .vol-value { font-variant-numeric: tabular-nums; }

h1 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 10px; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 650; letter-spacing: -.01em; margin: 0; }

p { margin: 0 0 12px; }
code {
  background: var(--brand-50);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hidden { display: none !important; }
.muted { color: var(--ink-2); font-size: 13px; }

/* Etichetta minuscola maiuscoletta, usata per i titoli di sezione */
.eyebrow {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
}

/* ==========================================================
   Struttura
   ========================================================== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--sh-sm);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-head p { margin: 2px 0 0; }

.content { max-width: 1560px; margin: 0 auto; padding: 24px 22px 72px; }

/* ---------------- Barra superiore ---------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  height: 60px;
}
.topbar-brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.topbar-brand img { height: 19px; width: auto; display: block; }
.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  padding-left: 13px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-name { font-weight: 600; font-size: 13.5px; }

.badge {
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-soft { background: var(--line-soft); color: var(--ink-2); }

/* ---------------- Schede ---------------- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  background: none;
  border: none;
  padding: 13px 14px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}
.tab::after {
  content: '';
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: transparent;
  border-radius: 2px 2px 0 0;
  transition: background .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); font-weight: 650; }
.tab.active::after { background: var(--brand); }

.panel { display: none; }
.panel.active { display: block; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ==========================================================
   Campi
   ========================================================== */
.field { display: block; margin-bottom: 15px; }
.field > .field-label,
label > .field-label { display: block; margin-bottom: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -.005em;
}
.field-hint { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }

/* Nota "campi bloccati" in Correzioni: leggibile ma senza il peso di un
   alert vero e proprio, che qui sarebbe già occupato da #ctrl-state. */
#ctrl-locked-note {
  background: var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

input[type="text"], input[type="password"], input[type="number"], select, .input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"] { font-variant-numeric: tabular-nums; }

/* Le frecce native dei campi numerici appesantiscono la griglia */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

input:focus, select:focus, .input:focus, .btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13);
}
input:disabled, select:disabled, input[readonly] {
  background: var(--line-soft);
  color: var(--ink-3);
  cursor: not-allowed;
}
input::placeholder { color: var(--ink-3); }

/* Menu a tendina con indicatore disegnato, non quello di sistema */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c6470' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
select::-ms-expand { display: none; }

/* ==========================================================
   Menu a tendina disegnato
   Un CSS può ridecorare la casella chiusa di un <select>, ma la lista che
   si apre al click resta disegnata dal sistema operativo. Questo componente
   nasconde il <select> nativo (che resta la fonte di verità per valore ed
   eventi — il resto del codice continua a leggerlo/ascoltarlo invariato) e
   lo sostituisce con un pulsante e un pannello coerenti col resto dell'app.
   ========================================================== */
.xselect { position: relative; display: block; }
.xselect select { display: none; }

.xselect-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.xselect-btn:hover { border-color: #d8dce2; }
.xselect-btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13);
}
.xselect-btn:disabled { background: var(--line-soft); color: var(--ink-3); cursor: not-allowed; }
.xselect-btn svg { flex: none; color: var(--ink-3); transition: transform .15s; }
.xselect-btn.is-open svg { transform: rotate(180deg); }
.xselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Compatta nella barra dei filtri, allineata al pulsante del calendario */
.toolbar .xselect-btn { height: 36px; font-size: 13px; }
.toolbar .xselect { width: auto; min-width: 165px; }
/* Ogni pulsante della barra filtri (es. "Esporta") alla stessa altezza di
   select, data e segmented control li' accanto: 36px, non un pixel diverso. */
.toolbar .btn { height: 36px; }

/* Ancora più compatta nelle righe di tabella (modifica ruolo in linea) */
.table-wrap .xselect-btn { height: 32px; padding: 0 8px; font-size: 12.5px; border-radius: 7px; }
.table-wrap .xselect { width: auto; min-width: 138px; }

/* position:fixed e coordinate in pixel calcolate da JS (positionPop()):
   il pannello è agganciato a <body>, mai a un antenato che potrebbe
   tagliarlo con un overflow impostato per lo scorrimento orizzontale. */
.xselect-pop {
  position: fixed;
  z-index: 300;   /* sopra anche alle finestre di dialogo (.dialog, 200) */
  max-height: 280px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 6px;
  animation: rise .16s ease both;
}
.xselect-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  white-space: normal;   /* va a capo solo oltre la larghezza massima del menu */
}
.xselect-item:hover, .xselect-item:focus-visible { background: var(--brand-50); outline: none; }
.xselect-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

fieldset { border: none; padding: 0; margin: 0 0 22px; }
fieldset legend { padding: 0; margin-bottom: 12px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.narrow { max-width: 260px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  margin-bottom: 15px;
}
.checkbox-label input { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); cursor: pointer; }

/* ==========================================================
   Pulsanti
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;            /* vale anche quando .btn è su un link */
  box-shadow: var(--sh-sm);
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { background: #fbfcfd; border-color: #b7bdc7; }
.btn:active { transform: translateY(.5px); }
.btn svg { flex: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 1px 2px rgba(55, 93, 150, .25);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-primary:disabled { background: var(--brand-300); border-color: var(--brand-300); cursor: not-allowed; transform: none; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }
.btn-danger { color: var(--neg); }
.btn-danger:hover { background: var(--neg-bg); border-color: #f3d3ce; }

/* Gruppo di scelta compatto (periodo, metrica) */
.seg {
  display: inline-flex;
  align-items: center;
  background: var(--line-soft);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
/* Altezza esplicita (non affidata a padding+line-height): con i 3px di
   respiro di .seg, il gruppo risulta alto 36px come select, data e pulsanti
   della stessa barra — non un pixel in più o in meno. */
.seg button {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 0 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.active {
  background: var(--card);
  color: var(--brand);
  box-shadow: var(--sh-sm);
}

/* ==========================================================
   Messaggi
   ========================================================== */
/* Blocco, non flex: così un avviso che mescola testo e <code> resta
   un normale paragrafo e va a capo correttamente. */
.alert {
  border-radius: var(--r);
  padding: 12px 14px;
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.55;
}
.alert svg { vertical-align: -3px; margin-right: 8px; }
.alert code { background: rgba(27, 29, 33, .07); }
.alert-ok    { background: var(--pos-bg);  color: #1f5c39; }
.alert-error { background: var(--neg-bg);  color: #8c1c14; }
.alert-info  { background: var(--brand-50); color: var(--brand-700); }
.alert-warn  { background: var(--warn-bg); color: var(--warn); }

.form-msg { font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.form-msg:not(:empty) { margin: 0 0 14px; }
.form-msg.ok { color: var(--pos); }
.form-msg.error { color: var(--neg); }

/* ==========================================================
   KPI — gerarchia a tre livelli
   ========================================================== */

/* Livello 1: indicatori principali */
.kpi-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.kpi-cell { background: var(--card); padding: 18px 20px 16px; }
.kpi-cell .kpi-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
}
/* Pallino dello stesso colore della linea nel grafico: il numero e la sua
   traccia si riconoscono a colpo d'occhio, senza dover leggere le etichette. */
.kpi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--ink-3)); flex: none; }
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.15;
  margin-top: 7px;
  color: var(--dot, var(--ink));
}
.kpi-cell.is-missing .kpi-value { color: var(--ink-3); font-weight: 500; }
.kpi-cell.is-missing .kpi-dot { background: var(--ink-3); }
.kpi-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; }
.trend.up   { color: var(--pos); }
.trend.down { color: var(--neg); }
.trend.flat { color: var(--ink-3); }

/* Livello 2: indicatori secondari, riga sottile */
.kpi-secondary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fcfdfe;
}
.stat-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); font-weight: 550; }
.stat-value { font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: var(--dot, var(--ink)); }
.stat.is-missing .stat-value { color: var(--ink-3); font-weight: 500; }
.stat.is-missing .kpi-dot { background: var(--ink-3); }

/* Livello 3: volumi, striscia compatta senza riquadri */
.vol-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.vol-item { padding: 0 20px; border-left: 1px solid var(--line-soft); flex: 0 0 auto; }
.vol-item:first-child { padding-left: 0; border-left: none; }
.vol-label {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
}
.vol-value { font-size: 18px; font-weight: 650; letter-spacing: -.025em; margin-top: 2px; }
.vol-item.is-missing .vol-value { color: var(--ink-3); font-weight: 500; }

/* ==========================================================
   Grafici
   ========================================================== */
.chart-wrap { position: relative; height: 330px; margin-top: 4px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 330px; color: var(--ink-3); font-size: 13.5px;
}

/* ==========================================================
   Tabelle
   ========================================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
  padding: 11px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th.text, td.text { text-align: left; }
thead th {
  background: #fbfcfd;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fcfdfe; }
td.na { color: var(--ink-3); }

/* Riga "Totale complessivo" del Report giornaliero: stessa evidenziazione
   gialla usata nel foglio che si compilava a mano, per restare riconoscibile
   a chi legge l'email. */
tfoot .report-total td { background: #fff8b0; font-weight: 700; border-top: 2px solid var(--line-strong); }
td.strong { font-weight: 650; }
.empty-state {
  text-align: center;
  color: var(--ink-3);
  padding: 44px 20px;
  font-size: 13.5px;
}

/* ==========================================================
   Filtri
   ========================================================== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .field { margin-bottom: 0; }
.toolbar-sep { width: 1px; height: 24px; background: var(--line); }

/* ==========================================================
   Selettore periodo con calendario disegnato
   ========================================================== */
.daterange { position: relative; }
.daterange-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 13px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--sh-sm);
  font-variant-numeric: tabular-nums;
}
/* Compatto nella barra dei filtri, alla stessa altezza del select e della
   segmented control li' accanto — stesso schema di .toolbar .xselect-btn. */
.toolbar .daterange-btn { height: 36px; font-size: 13px; }
.daterange-btn:hover { border-color: #b7bdc7; }
.daterange-btn svg { color: var(--ink-3); flex: none; }

.cal {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: 0;
  width: 290px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 14px;
  animation: rise .16s ease both;
}
.cal.align-right { left: auto; right: 0; }
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title { font-size: 13.5px; font-weight: 650; }
.cal-nav {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}
.cal-nav:hover { background: var(--line-soft); }
.cal-nav:disabled { opacity: .35; cursor: not-allowed; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center;
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-3);
  padding-bottom: 6px;
}
.cal-day {
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.cal-day:hover:not(:disabled) { background: var(--brand-50); }
.cal-day.muted-day { color: var(--ink-3); opacity: .45; }
.cal-day:disabled { color: var(--ink-3); opacity: .3; cursor: not-allowed; }
.cal-day.in-range { background: var(--brand-50); border-radius: 0; }
.cal-day.edge { background: var(--brand); color: #fff; font-weight: 650; }
.cal-day.edge.start { border-radius: 7px 0 0 7px; }
.cal-day.edge.end   { border-radius: 0 7px 7px 0; }
.cal-day.edge.only  { border-radius: 7px; }
.cal-foot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.cal-preset {
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.cal-preset:hover { background: var(--brand-50); color: var(--brand); border-color: var(--brand-300); }
.cal-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; }

/* ==========================================================
   Accesso e installazione
   ========================================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, #eaeff7 0%, rgba(234, 239, 247, 0) 62%),
    var(--bg);
}
.login-card, .setup-card {
  width: 100%;
  max-width: 394px;
  margin: 0 auto;
  padding: 32px;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
}
.setup-card { max-width: 520px; }
.login-logo { height: 30px; width: auto; display: block; margin: 0 auto 26px; }
.login-card h1 { font-size: 19px; margin-bottom: 5px; }
.login-card .muted { margin-bottom: 24px; }
.auth-foot { margin: 22px 0 0; text-align: center; font-size: 11.5px; color: var(--ink-3); }

/* ==========================================================
   Finestra modale
   ========================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 26, 31, .5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade .15s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal.dialog-out { animation: fade-out .15s ease both; }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
.modal-box {
  max-width: 400px;
  width: 100%;
  margin: 0;
  box-shadow: var(--sh-lg);
  animation: rise .2s ease both;
}
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* Finestre modali create da JS (notifiche, conferme, richieste di un
   valore, domande in sequenza): stessa base visiva di .modal/.modal-box,
   sopra z-index più alto perché possono aprirsi da dentro un modale
   già presente (es. "Nuovo account"). Niente alert/confirm/prompt nativi
   del browser né notifiche a scomparsa automatica in tutto il progetto:
   ogni riscontro resta a schermo finché la persona non lo chiude lei. */
.dialog { z-index: 200; }
.dialog-title { font-size: 15.5px; font-weight: 700; margin-bottom: 10px; }
.dialog-body { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.dialog-body p { margin: 0 0 10px; }
.dialog-body p:last-child { margin-bottom: 0; }
.dialog-notify { display: flex; align-items: flex-start; gap: 10px; }
.dialog-notify svg { flex: none; margin-top: 2px; }
.dialog-notify-ok svg { color: var(--pos, #2f7d4f); }
.dialog-notify-error svg { color: var(--neg); }
.dialog-progress { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .03em; margin: -4px 0 12px; }
.dialog-subject { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.dialog-error { margin-top: 8px; font-size: 12.5px; color: var(--neg); }
.dialog-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
}
.dialog-input:focus { outline: 2px solid var(--brand-300); outline-offset: 1px; }

/* ==========================================================
   Selettore di file custom (niente <input type=file> a vista)
   ========================================================== */
.filepick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filepick-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.filepick-name { font-size: 13px; color: var(--ink-3); }
.filepick-name.has-file { color: var(--ink); font-weight: 600; }

/* ==========================================================
   Adattamento a schermi stretti
   ========================================================== */
@media (max-width: 860px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 60px; }
  .card { padding: 18px; border-radius: var(--r); }
  .toolbar { align-items: stretch; }
  .toolbar-sep { display: none; }
  .vol-item { padding: 8px 16px 8px 0; border-left: none; }
  .chart-wrap { height: 270px; }
}
@media (max-width: 560px) {
  .topbar { height: auto; padding: 12px 16px; }
  .topbar-title { display: none; }
  .tabs { padding: 0 10px; }
  .kpi-value { font-size: 26px; }
  .cal { width: calc(100vw - 44px); left: 0; }
  .login-card, .setup-card { padding: 24px; }
}

/* ==========================================================
   Mailing Commerciali — aggiunte
   ========================================================== */

/* Colori dei gruppi di esito: gli stessi su badge, tabella Esiti e grafici */
:root {
  --o-open:     #1791c4;   /* in corso: solleciti attivi */
  --o-todo:     #8d949f;   /* da contattare */
  --o-noreply:  #8d949f;
  --o-neg:      #b42318;
  --o-wait:     #c2743a;
  --o-appt:     #375d96;
  --o-prop:     #6b5ca5;
  --o-proprej:  #a8324a;
  --o-contract: #2f7d4f;
}

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
.span-2 { grid-column: span 2; }
.grid-split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-split > .card { min-width: 0; }

/* La barra filtri sta sotto la riga delle sezioni */
.toolbar.filters { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.toolbar.filters .toolbar-group { width: 100%; }
.toolbar.filters .xselect { min-width: 190px; }
.search-input {
  height: 36px;
  font-size: 13px;
  flex: 1 1 260px;
  width: auto;
  max-width: 420px;
}
input[type="search"] { -webkit-appearance: none; appearance: none; }

.textarea { height: auto; padding: 9px 12px; resize: vertical; min-height: 70px; line-height: 1.5; }
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13); }

/* Finestra della scheda azienda: più larga delle altre, scorre se serve */
/* Finestra più alta dello schermo: scorre tutta la finestra come una
   pagina (barra al bordo dello schermo), non il riquadro dall'interno con
   una barra schiacciata contro gli angoli arrotondati. */
.modal:has(.modal-wide) { align-items: flex-start; overflow-y: auto; }
.modal-wide { max-width: 860px; margin: 0 auto; }
.modal-wide .daterange-btn { width: 100%; }

/* Data vuota nel selettore */
.daterange-btn.is-empty span { color: var(--ink-3); font-weight: 500; }

/* ---------------- Elenco anagrafiche ---------------- */
.table-contacts tbody tr { cursor: pointer; }
.table-contacts td.cell-check, .table-contacts th.cell-check { width: 38px; padding-right: 0; }
.table-contacts input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
.table-contacts tr.is-selected td { background: var(--brand-50); }
.table-contacts td.wrap { white-space: normal; min-width: 180px; max-width: 280px; }
.cell-sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.cell-date { font-variant-numeric: tabular-nums; }
.auto-mark {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 650;
  color: var(--o-open);
  vertical-align: 1px;
}

/* Sollecito programmato per un giorno futuro: data in corsivo con un
   piccolo calendario accanto (stretto: la colonna non si allarga). */
.cell-date.is-planned { color: var(--brand); font-style: italic; }
.plan-mark { display: inline-block; margin-left: 5px; vertical-align: -1px; color: var(--brand); }

/* Elenco anagrafiche a colonne fisse: cambiando filtro, pagina o
   ordinamento le colonne restano dove sono, invece di allargarsi e
   restringersi secondo le righe mostrate. Le larghezze stanno nel
   <colgroup> scritto da renderContacts(); azienda, referente e mail si
   dividono lo spazio che resta e vanno a capo dentro la loro colonna. */
.table-contacts { table-layout: fixed; min-width: 1150px; }
.table-contacts col.col-check { width: 46px; }
.table-contacts col.col-date { width: 136px; }     /* "05/11/2026 AUTO" su una riga */
.table-contacts col.col-status { width: 180px; }
.table-contacts col.col-phone { width: 168px; }
.table-contacts td.cell-phone { white-space: normal; overflow-wrap: break-word; font-variant-numeric: tabular-nums; }
.table-contacts td.wrap, .table-contacts td.cell-mail { min-width: 0; max-width: none; overflow-wrap: break-word; }
.table-contacts td.wrap, .table-contacts td.cell-mail, .table-contacts td:last-child { white-space: normal; }
.table-contacts .status-pill { white-space: normal; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable.sorted { color: var(--brand); }
th.sortable svg { vertical-align: -2px; margin-left: 3px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: color-mix(in srgb, var(--pill) 11%, #fff);
  color: var(--pill);
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--pill);
  flex: none;
}
.status-pill.is-plain { background: var(--line-soft); color: var(--ink-2); }

.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bulk-count { font-size: 13px; font-weight: 650; color: var(--brand-700); margin-right: 4px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-2);
}
.pager-buttons { display: flex; gap: 6px; align-items: center; }

/* Promemoria dei solleciti da mandare oggi */
#due-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
#due-banner .btn { height: 32px; }

/* ---------------- Scheda azienda ---------------- */
.sibling-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.sibling {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fcfdfe;
  font-size: 13px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  width: 100%;
}
.sibling:hover { border-color: var(--brand-300); background: var(--brand-50); }

.log-wrap { margin: 4px 0 16px; font-size: 13px; }
.log-wrap summary { cursor: pointer; font-weight: 600; color: var(--ink-2); padding: 4px 0; }
.log-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.log-list li { padding: 7px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
.log-list li:last-child { border-bottom: none; }
.log-when { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------------- Analisi ---------------- */
.bar-cell { width: 34%; min-width: 120px; }
.bar {
  height: 8px;
  border-radius: 4px;
  background: var(--pill, var(--brand));
  opacity: .85;
  min-width: 2px;
}
tfoot td { font-weight: 700; border-top: 1px solid var(--line); background: #fbfcfd; }

/* ---------------- Impostazioni ---------------- */
.input-inline {
  height: 32px;
  font-size: 13px;
  padding: 0 9px;
  border-radius: 7px;
}
/* Campo numerico con l'unità dentro il bordo: "7 giorni" su una riga sola */
.input-suffix {
  display: inline-flex;
  /* Allineati sulla linea di base del testo, non al centro delle scatole:
     il campo centra il numero a modo suo, e con "center" il numero
     finiva un paio di pixel più in basso di "giorni". */
  align-items: baseline;
  height: 34px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.input-suffix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3.5px rgba(55, 93, 150, .13); }
.input-suffix input[type="number"] {
  display: inline-block;
  width: 52px;
  height: 100%;
  border: none;
  border-radius: 0;
  padding: 0 4px 0 10px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: none;
  background: transparent;
}
.input-suffix input[type="number"]:focus { box-shadow: none; }
.input-suffix span { padding: 0 11px 0 4px; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.input-suffix.is-off span { color: var(--ink-3); font-style: italic; }

/* Spostamento su/giù degli stati */
.move-btns { display: inline-flex; gap: 4px; }
.move-btns .btn { width: 30px; padding: 0; }
.move-btns .btn:disabled { opacity: .35; cursor: default; }

/* ==========================================================
   Barre di scorrimento sottili, nei colori dell'app (al posto di quelle
   grigie e spesse di Windows): tabelle, menu, storico, finestre.
   ========================================================== */
* { scrollbar-width: thin; scrollbar-color: #cdd2d9 transparent; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: #cdd2d9;
    border-radius: 10px;
    border: 3px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background-color: #b7bdc7; }
}

/* Anteprima import: le intestazioni vanno a capo invece di far scorrere la tabella */
#table-import-preview th { white-space: normal; vertical-align: bottom; }

@media (max-width: 860px) {
  .grid-4, .grid-split { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .search-input { max-width: none; }
}

/* Mail lunghe (o due mail nella stessa cella, come in alcune righe
   dell'Excel) vanno a capo invece di spingere fuori la colonna Stato. */
.table-contacts td.cell-mail { white-space: normal; min-width: 160px; max-width: 260px; }

/* Mail cliccabili nell'elenco: colore del marchio, non il blu del browser */
.table-contacts a[data-mail] { color: var(--brand); text-decoration: none; }
.table-contacts a[data-mail]:hover { text-decoration: underline; }

.table-more { margin-top: 12px; }

/* ---------------- Campagna aperta ---------------- */
.campaign-pick { gap: 10px; }
.campaign-pick > .field-label { margin: 0; }
.campaign-pick .field { margin: 0; }
.campaign-pick .xselect { min-width: 260px; }
.campaign-rules { font-size: 12.5px; }

/* Pulsante con l'aspetto di un link, dentro frasi e avvisi */
.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--brand-700); }

/* "Seleziona tutte le N anagrafiche del filtro" */
.select-all-note {
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin: 0 0 12px;
  font-size: 13px;
}

/* Avvisi sotto un campo della scheda (azienda già presente, mail doppia) */
.field-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 7px 0 0;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.45;
}
.field-note svg { flex: none; margin-top: 2px; }
.field-note.note-info  { background: var(--brand-50); color: var(--brand-700); }
.field-note.note-warn  { background: var(--warn-bg); color: var(--warn); }
.field-note.note-error { background: var(--neg-bg); color: #8c1c14; }
#email-note { margin: -6px 0 15px; }

/* Suggerimenti del campo Azienda */
.suggest-pop { padding: 4px; max-height: 340px; }
.suggest-head { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); padding: 8px 11px 4px; }
.suggest-item { display: flex; flex-direction: column; gap: 2px; }
.suggest-name { font-weight: 600; }
.suggest-name .badge { margin-left: 6px; vertical-align: 1px; }
.suggest-sub { font-size: 12px; color: var(--ink-3); font-weight: 400; }

/* ---------------- Import a passi ---------------- */
.steps {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  counter-reset: step;
  flex-wrap: wrap;
}
.steps li {
  counter-increment: step;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--line-soft);
}
.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  font-size: 11px;
}
.steps li.active { background: var(--brand-50); color: var(--brand-700); }
.steps li.active::before { background: var(--brand); color: #fff; }
.steps li.done { color: var(--ink-2); }
.import-step { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.import-step > .eyebrow { margin: 0 0 6px; }
.import-step > .muted { margin: 0 0 14px; font-size: 13px; }
.import-step > .btn { margin-top: 14px; }
#table-import-sheets td { vertical-align: middle; }
#table-import-sheets th { white-space: normal; vertical-align: bottom; }
#table-import-sheets td.wrap { white-space: normal; min-width: 200px; }
#table-import-sheets .xselect { min-width: 180px; }
#table-import-sheets .input-inline[name="name"] { width: 100%; min-width: 170px; }
tr.is-off td { color: var(--ink-3); }
tr.is-off td strong { color: var(--ink-2); }
.input-num { width: 76px; }

details.details-note summary { display: flex; gap: 0; cursor: pointer; list-style: none; }
details.details-note summary::-webkit-details-marker { display: none; }
details.details-note summary svg { flex: none; margin-top: 3px; }
details.details-note ul { margin: 10px 0 0 24px; padding: 0; columns: 2; column-gap: 28px; font-size: 12.5px; }

/* Nomi delle aziende da verificare */
.names-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 22px 0 12px;
}
.names-head h3 { margin: 0 0 4px; font-size: 15px; }
.names-head p { margin: 0; max-width: 720px; font-size: 13px; }
.name-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.name-group {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px 8px;
  background: var(--card);
}
.name-group.is-separate { background: #fcfdfe; }
.name-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.name-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 6px 4px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
}
.name-option:hover { background: var(--line-soft); }
.name-option input { margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.name-option-separate { color: var(--ink-2); border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 8px; }

/* Barra delle pagine: righe per pagina e salto diretto a una pagina */
.pager-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager-size { margin: 0; }
.pager-size .xselect { min-width: 150px; }
.pager-buttons { flex-wrap: wrap; }
.pager-buttons .btn svg + svg { margin-left: -9px; }
.pager-jump { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.pager-jump input { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
/* Stessa altezza dei pulsanti piccoli della barra */
.pager .xselect-btn, .pager-jump .input-inline { height: 32px; min-height: 32px; font-size: 13px; padding-top: 0; padding-bottom: 0; }

/* Menu e pulsante affiancati nell'intestazione di una card (Stati) */
.card-head .toolbar-group .field { margin: 0; }
.card-head .toolbar-group { align-items: center; }

/* ---------------- Impostazioni: campagne ---------------- */
.actions-cell { white-space: nowrap; text-align: right; }
.gap-list { display: flex; flex-direction: column; gap: 8px; }
.gap-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-2); }
.gaps-empty { margin: 0; font-size: 13px; }

@media (max-width: 560px) {
  .campaign-pick .xselect, .toolbar.filters .xselect { width: 100%; min-width: 0; }
  .name-groups { grid-template-columns: 1fr; }
  details.details-note ul { columns: 1; }
}

/* ==========================================================
   Novembre 2026: filtri, azioni in blocco, statistiche personali
   ========================================================== */

/* "Altri filtri": pannello a griglia sotto la barra principale */
.more-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.more-filters .field { margin-bottom: 12px; }
.more-filters .xselect, .more-filters .input, .more-filters .daterange-btn { width: 100%; }
.more-filters .input { height: 40px; font-size: 13.5px; }
#f-more.is-open { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Azioni sulle righe spuntate: barra fissa in basso al centro, sempre a
   portata anche a metà di una lista lunga. */
.bulk-bar {
  position: fixed;
  /* Centrata con i margini, non con transform: l'animazione di comparsa
     usa transform e la sposterebbe di lato. */
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  bottom: 22px;
  z-index: 90;
  max-width: calc(100vw - 32px);
  flex-wrap: nowrap;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--sh-lg);
  justify-content: center;
  animation: rise .16s ease both;
}
/* Spazio in fondo alla pagina perché la barra non copra le ultime righe */
.panel[data-panel="aziende"] { padding-bottom: 76px; }

.btn-ghost-danger { color: var(--neg); }
.btn-ghost-danger:hover { background: var(--neg-bg); color: var(--neg); }

/* Analisi: filtri e nota sul periodo */
.kpi-note { margin: 10px 0 0; font-size: 12.5px; }
.kpi-note:empty { display: none; }

/* Statistiche personali */
.stats-list { display: flex; flex-direction: column; gap: 14px; }
.stat-card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.stat-head h3 { margin: 0; font-size: 14.5px; }
.stat-head p { margin: 2px 0 0; font-size: 12.5px; }
.stat-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-actions .btn[data-stat-act="up"], .stat-actions .btn[data-stat-act="down"] { width: 30px; padding: 0; }
.stat-actions .btn:disabled { opacity: .35; cursor: default; }
.stat-chart { position: relative; margin-bottom: 12px; }
.stats-empty p { margin: 0 0 10px; color: var(--ink-2); font-size: 13.5px; }
.stats-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 14px; }
.metric-grid .checkbox-label { margin: 0; padding: 4px 0; font-size: 13px; }
.modal-box.dialog-wide { max-width: 560px; }

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .bulk-bar { bottom: 10px; flex-wrap: wrap; width: auto; }
}

/* ---------------- Analisi: il percorso ---------------- */
.funnel { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.funnel-row {
  display: grid;
  grid-template-columns: minmax(170px, 230px) 1fr 76px 150px;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.funnel-label strong { display: block; font-weight: 650; color: var(--ink); }
.funnel-label span { display: block; font-size: 11.5px; color: var(--ink-3); }
.funnel-track { height: 14px; background: var(--line-soft); border-radius: 7px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--brand); border-radius: 7px; }
.funnel-row:last-child .funnel-bar { background: var(--pos); }
.funnel-n { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.funnel-step { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.funnel-step span { font-size: 11.5px; color: var(--ink-3); }

tr.is-link { cursor: pointer; }
tr.is-link:hover td { background: var(--brand-50); }
.pipeline-note { margin: 10px 0 0; font-size: 12.5px; }

@media (max-width: 700px) {
  .funnel-row { grid-template-columns: 1fr 70px; gap: 4px 10px; }
  .funnel-track { grid-column: 1 / -1; grid-row: 2; }
  .funnel-step { grid-column: 1 / -1; }
}

/* Sotto-schede dell'Analisi */
.atabs { display: flex; width: fit-content; max-width: 100%; margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.atabs button { white-space: nowrap; }

/* Finestre lunghe (nuova statistica): restano dentro lo schermo, il
   contenuto scorre e i pulsanti restano sempre visibili in fondo. */
.modal-box.dialog-wide { max-width: 640px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-box.dialog-wide .dialog-body { overflow-y: auto; min-height: 0; padding-right: 4px; }
.modal-box.dialog-wide .modal-actions { flex: none; }
.metric-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
}

/* "Tutte le campagne": la campagna di ogni riga, sotto il nome dell'azienda. */
.cell-sub.cell-campaign { color: var(--brand); font-weight: 600; }

/* Menu a scelta multipla (province, regioni, settori): voci con la spunta. */
.xselect-btn.is-filled { border-color: var(--brand); color: var(--brand-700); font-weight: 600; }
.xselect-check { display: flex; align-items: center; gap: 9px; }
.xselect-box {
  flex: none; width: 16px; height: 16px; border: 1.5px solid var(--line-strong); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center; color: transparent; background: var(--card);
}
.xselect-check.checked .xselect-box { background: var(--brand); border-color: var(--brand); color: #fff; }
.xselect-check.checked { font-weight: 600; color: var(--ink); }
.xselect-clear { color: var(--ink-3); border-bottom: 1px solid var(--line-soft); border-radius: 7px 7px 0 0; margin-bottom: 2px; }

/* Opzioni del grafico "Mail inviate", sopra il grafico */
.chart-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -4px 0 14px; }
.chart-tools .field { margin: 0; }
.chart-tools .xselect { min-width: 200px; }
.chart-tools .xselect-btn { height: 36px; font-size: 13px; }

/* Telefoni: "+2" in elenco per gli altri numeri, link sotto il campo nella scheda */
.more-mark { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 5px; background: var(--line-soft);
  color: var(--ink-2); font-size: 11px; font-weight: 650; cursor: help; }
/* Scheda: un numero per riga */
.phone-rows { display: flex; flex-direction: column; gap: 4px; }
.phone-row { display: flex; gap: 2px; align-items: center; }
.phone-row .phone-input { flex: 1; min-width: 0; height: 34px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.phone-btn { flex: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 7px; background: transparent; color: var(--ink-3); cursor: pointer; }
.phone-btn:hover { background: var(--line-soft); color: var(--ink); }
.phone-btn.is-done { color: #2f7d4f; }
.phone-actions { display: flex; gap: 16px; margin-top: 6px; }
.phones-doubts { margin: 6px 0 0; padding-left: 18px; max-height: 200px; overflow: auto; }
.import-card + .import-card { margin-top: 20px; }
