/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:       #d3af00;
  --gold-h:     #b89800;
  --gold-light: #fef9d7;
  --gold-mid:   #f5e680;
  --bg:         #f5f4f0;
  --surface:    #ffffff;
  --border:     #e8e4d8;
  --text:       #1a1a1a;
  --text-muted: #888880;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 20px rgba(0,0,0,.09);
  --danger:     #dc2626;
  --danger-h:   #b91c1c;

  /* progressione stati — dal neutro al completato */
  --c-nuovo:            #2563eb;
  --c-da_richiamare:    #dc2626;
  --c-perizia_da_fissare: #fbbf24;
  --c-perizia_fissata:  #86efac;
  --c-perizia_fatta:    #16a34a;
  --c-incarico_firmato: #14532d;
  --c-non_interessato:  #cbd5e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--gold-h); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  height: 70px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.navbar-brand {
  display: flex;
  align-items: center;
}
.navbar-logo {
  height: 64px;
  width: auto;
  display: block;
}
.navbar-nav {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .2rem;
}
.navbar-nav a {
  padding: .4rem .9rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.navbar-nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.navbar-nav a.active { color: var(--gold-h); background: var(--gold-light); font-weight: 600; }
.navbar-nav .btn-nav {
  background: var(--gold);
  color: #fff !important;
  padding: .4rem 1.1rem;
  font-weight: 600;
}
.navbar-nav .btn-nav:hover { background: var(--gold-h); }
.nav-user-info {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: 0 .5rem;
}
.nav-username {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.badge-admin {
  display: inline-block;
  background: #14532d;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .15rem .45rem;
  border-radius: 4px;
  text-transform: uppercase;
}
/* ── Container ── */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
}

/* ── Alerts ── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-info    { background: var(--gold-light); border: 1px solid var(--gold-mid); color: #6b5300; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .5rem 1.15rem;
  border-radius: 7px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-h); }
.btn-secondary{ background: #f0ece0; color: var(--text); }
.btn-secondary:hover { background: #e8e2d0; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-h); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm       { padding: .28rem .75rem; font-size: .8rem; }
.btn-full     { width: 100%; justify-content: center; }
.btn-icon-delete {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: .85rem; padding: .2rem .4rem;
  border-radius: 4px; transition: background .15s, color .15s; font-family: inherit;
}
.btn-icon-delete:hover { background: #fee2e2; color: var(--danger); }
.btn-icon-action {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .3rem .45rem; border-radius: 6px; line-height: 1;
}
.btn-icon-trash { color: var(--text-muted); background: transparent; border: 1px solid var(--border); }
.btn-icon-trash:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }
.inline-form { display: inline; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.header-actions { display: flex; gap: .5rem; }
.breadcrumb { font-size: .88rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--gold-h); }
.breadcrumb strong { color: var(--text); }
.count-badge {
  display: inline-block;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: .1rem .55rem;
  font-size: .75rem;
  font-weight: 600;
  vertical-align: middle;
}

/* ── Dashboard stats — forzate su una riga ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .75rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem .75rem 1rem;
  text-align: center;
  border-top: 4px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
  transition: box-shadow .15s, transform .15s;
  cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-total            { border-color: #1a1a1a; }
.stat-nuovo            { border-color: var(--c-nuovo); }
.stat-da_richiamare    { border-color: var(--c-da_richiamare); }
.stat-perizia_da_fissare { border-color: var(--c-perizia_da_fissare); }
.stat-perizia_fissata  { border-color: var(--c-perizia_fissata); }
.stat-perizia_fatta    { border-color: var(--c-perizia_fatta); }
.stat-incarico_firmato { border-color: var(--c-incarico_firmato); }
.stat-non_interessato  { border-color: var(--c-non_interessato); }
.stat-number { font-size: 2.1rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.stat-label  { font-size: .7rem; color: var(--text-muted); margin-top: .35rem; font-weight: 600; line-height: 1.3; text-transform: uppercase; letter-spacing: .04em; }

/* ── Section ── */
.section { background: var(--surface); border-radius: var(--radius); box-shadow: 0 2px 12px rgba(0,0,0,.07); overflow: hidden; border: 1px solid var(--border); }
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  background: #faf9f5;
}
.section-header h2 { font-size: .95rem; font-weight: 700; }
.link-secondary { font-size: .83rem; color: var(--text-muted); }
.link-secondary:hover { color: var(--gold-h); }

/* ── Table ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .73rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em;
  padding: .65rem 1.25rem; background: #faf9f5; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--border);
  font-size: .9rem; vertical-align: middle; white-space: nowrap;
}
.table-actions { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.col-miogest { min-width: 110px; }
.col-agente { min-width: 130px; }
.col-zona { width: 180px; }
.td-zona { max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-miogest {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .72rem; font-weight: 700; white-space: nowrap; cursor: pointer;
  border: none; font-family: inherit; transition: opacity .15s;
  line-height: 1.3; text-align: center;
}
.badge-miogest:hover { opacity: .8; }
.badge-miogest::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: .35rem;
  vertical-align: middle;
}
.miogest-si  { background: #dcfce7; color: #166534; }
.miogest-si::before  { background: #16a34a; }
.miogest-no  { background: #f1f5f9; color: #94a3b8; }
.miogest-no::before  { background: #cbd5e1; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: #faf9f5; }
.text-muted { color: var(--text-muted); font-size: .85rem; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: .25rem .75rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; white-space: nowrap; letter-spacing: .02em;
}
.badge-lg { padding: .35rem .95rem; font-size: .82rem; }
.badge-nuovo            { background: #dbeafe; color: #1d4ed8; }
.badge-da_richiamare    { background: #fee2e2; color: #b91c1c; }
.badge-perizia_da_fissare { background: #fef3c7; color: #92400e; }
.badge-perizia_fissata  { background: #dcfce7; color: #15803d; }
.badge-perizia_fatta    { background: #bbf7d0; color: #166534; }
.badge-incarico_firmato { background: #16a34a; color: #fff; }
.badge-non_interessato  { background: #f1f5f9; color: #64748b; }

/* ── Filters bar ── */
.filters-bar { margin-bottom: 1.25rem; }
.filters-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.input-search {
  flex: 1; min-width: 180px; padding: .5rem .9rem;
  border: 1px solid var(--border); border-radius: 7px; font-size: .9rem;
  background: var(--surface); outline: none; transition: border-color .15s;
  font-family: inherit;
}
.input-search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(211,175,0,.12); }
.select-filter {
  padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 7px;
  font-size: .9rem; background: var(--surface); cursor: pointer;
  outline: none; min-width: 145px; font-family: inherit;
}
.select-filter:focus { border-color: var(--gold); }

/* ── Lead cards grid ── */
.leads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 1rem;
}
.lead-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: box-shadow .15s, transform .15s;
}
.lead-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.lead-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1rem 1rem .6rem;
  border-bottom: 1px solid var(--border);
}
.lead-name  { font-weight: 700; font-size: .97rem; }
.lead-phone { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }
.lead-phone a { color: var(--text-muted); }
.lead-card-body { padding: .6rem 1rem; flex: 1; }
.lead-meta { font-size: .82rem; color: var(--text-muted); margin-bottom: .25rem; }
.meta-icon { font-size: .85rem; }
.lead-card-footer {
  padding: .65rem 1rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.lead-card-actions {
  padding: .5rem .75rem;
  border-top: 1px solid var(--border);
  background: #faf9f5;
  display: flex;
  gap: .35rem;
  align-items: center;
}
.inline-stato-form {
  display: flex;
  gap: .3rem;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.select-inline-stato {
  flex: 1;
  min-width: 0;
  padding: .22rem .45rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .75rem;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
.select-inline-stato:focus { border-color: var(--gold); }
.inline-agente-form {
  display: flex;
  gap: .3rem;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.select-inline-agente {
  flex: 1;
  min-width: 0;
  padding: .22rem .45rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .75rem;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
.select-inline-agente:focus { border-color: var(--gold); }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  background: #faf9f5;
}
.card-header h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.card-header h3 { font-size: .93rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-sticky { position: sticky; top: 74px; }

/* ── Page header esteso ── */
.page-header-left { display: flex; flex-direction: column; gap: .2rem; }
.page-title-row { display: flex; align-items: center; gap: .75rem; }
.page-subtitle { font-size: .83rem; color: var(--text-muted); margin-top: .1rem; }

/* ── Data su due righe ── */
.date-main { display: block; font-size: .87rem; font-weight: 600; color: var(--text); }
.date-time { display: block; font-size: .76rem; color: var(--text-muted); margin-top: .08rem; }

/* ── Nome lead ── */
.lead-name-text { font-weight: 700; font-size: .92rem; line-height: 1.3; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Phone link ── */
.phone-link { color: var(--text-muted); font-size: .87rem; letter-spacing: .01em; }
.phone-link:hover { color: var(--gold-h); }

/* ── Tag sede variante small ── */
.tag-sede-sm { font-size: .65rem; padding: .1rem .5rem; margin-top: .25rem; display: inline-block; }

/* ── Tag sede ── */
.card-header-left { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tag-sede {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

/* ── Detail layout ── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 800px) {
  .detail-layout { grid-template-columns: 1fr; }
  .card-sticky { position: static; }
}

/* ── Info grid ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: .75rem 1.5rem;
  margin-bottom: 1rem;
}
.info-item { display: flex; flex-direction: column; gap: .15rem; }
.info-item-full { grid-column: 1 / -1; }
.info-label { font-size: .71rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; }
.info-value { font-size: .95rem; }
.notes-box {
  margin-top: 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: .85rem 1rem;
}
.notes-label { font-size: .71rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; margin-bottom: .4rem; }
.notes-text  { font-size: .92rem; white-space: pre-wrap; line-height: 1.6; }

/* ── Stato rapido ── */
.stato-form { display: flex; flex-wrap: wrap; gap: .45rem; }
.btn-stato {
  padding: .35rem .9rem; border-radius: 6px; font-size: .8rem; font-weight: 600;
  cursor: pointer; border: 2px solid transparent; background: var(--bg);
  color: var(--text-muted); transition: all .15s; font-family: inherit;
}
.btn-stato:hover { background: var(--border); color: var(--text); }
.btn-stato.active { border-color: currentColor; background: var(--surface); }

.btn-stato.stato-nuovo             { color: #4b5563; }
.btn-stato.stato-nuovo.active      { background: #f3f4f6; }
.btn-stato.stato-da_richiamare     { color: #92400e; }
.btn-stato.stato-da_richiamare.active { background: #fef3c7; }
.btn-stato.stato-perizia_da_fissare { color: #92400e; }
.btn-stato.stato-perizia_da_fissare.active { background: #fef3c7; }
.btn-stato.stato-perizia_fissata   { color: #6b5300; }
.btn-stato.stato-perizia_fissata.active { background: var(--gold-light); }
.btn-stato.stato-perizia_fatta     { color: #166534; }
.btn-stato.stato-perizia_fatta.active { background: #bbf7d0; }
.btn-stato.stato-incarico_firmato  { color: #14532d; }
.btn-stato.stato-incarico_firmato.active { background: #16a34a; color: #fff; }
.btn-stato.stato-non_interessato   { color: #64748b; }
.btn-stato.stato-non_interessato.active { background: #f1f5f9; }

/* ── Chiamate ── */
.chiamate-list { display: flex; flex-direction: column; gap: .75rem; }
.chiamata-item {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: .75rem 1rem;
}
.chiamata-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.chiamata-actions { display: flex; gap: .25rem; align-items: center; flex-shrink: 0; }
.chiamata-info   { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.chiamata-data    { font-size: .84rem; font-weight: 700; }
.chiamata-agente  { font-size: .82rem; color: var(--text); margin-left: .5rem; }
.chiamata-tel     { font-size: .78rem; color: var(--text-muted); margin-left: .4rem; }
.chiamata-durata { font-size: .8rem; color: var(--text-muted); }
.chiamata-note   { font-size: .87rem; color: var(--text-muted); margin-top: .3rem; white-space: pre-wrap; }

/* Attività — risposta */
.attivita-risposto     { border-left: 3px solid #2563eb; background: #f0f7ff; }
.attivita-non-risposto { border-left: 3px solid #dc2626; background: #fff5f5; }
.risposta-badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}
.risposta-badge-risposto     { background: #dbeafe; color: #1d4ed8; }
.risposta-badge-non_risposto { background: #fee2e2; color: #b91c1c; }

/* Toggle ha risposto / non ha risposto */
.risposta-toggle { display: flex; gap: .5rem; }
.risposta-option { display: flex; align-items: center; gap: .4rem; cursor: pointer; flex: 1; }
.risposta-option input[type="radio"] { display: none; }
.risposta-option span {
  flex: 1; text-align: center; padding: .45rem .5rem;
  border-radius: 7px; border: 2px solid var(--border);
  font-size: .83rem; font-weight: 600; transition: all .15s; background: var(--surface);
  color: var(--text-muted);
}
.risposta-si input:checked + span   { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; }
.risposta-no input:checked + span   { background: #fee2e2; border-color: #dc2626; color: #b91c1c; }
.risposta-option span:hover { border-color: var(--gold); color: var(--text); }
.badge-esito {
  display: inline-block; padding: .15rem .65rem; border-radius: 20px;
  font-size: .71rem; font-weight: 700;
}
.esito-interessato    { background: #dcfce7; color: #166534; }
.esito-non_risponde   { background: #f3f4f6; color: #4b5563; }
.esito-richiamata     { background: #fef3c7; color: #92400e; }
.esito-non_interessato{ background: #f1f5f9; color: #64748b; }
.esito-appuntamento   { background: var(--gold-light); color: #6b5300; }

/* ── Forms ── */
.form-page { max-width: 720px; }
.form-section-title {
  font-size: .71rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 700; margin: 1.25rem 0 .75rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem 1rem;
}
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.form-group label { font-size: .8rem; font-weight: 700; color: var(--text); }
.form-group-full { grid-column: 1 / -1; }
.form-control {
  padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 7px;
  font-size: .92rem; font-family: inherit; background: var(--surface);
  outline: none; transition: border-color .15s; width: 100%; color: var(--text);
}
.form-control:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(211,175,0,.12); }
textarea.form-control { resize: vertical; }
.required { color: var(--danger); }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted); font-size: .95rem;
}

/* ── Logout button ── */
.btn-logout {
  padding: .38rem .85rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  font-family: inherit;
}
.btn-logout:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* ── Login page ── */
.login-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 2.5rem 2rem;
}
.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo {
  height: 140px;
  width: auto;
  margin: 0 auto 1.25rem;
  display: block;
}
.login-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: .3rem;
  letter-spacing: -.01em;
}
.login-header p { font-size: .87rem; color: var(--text-muted); }
.login-form .btn-full { margin-top: .5rem; padding: .65rem; font-size: .97rem; }

/* ── Pagina Statistiche — KPI cards ── */
.stat-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}
.stat-kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 4px solid var(--border);
  padding: 1.2rem 1.3rem 1rem;
  transition: box-shadow .15s, transform .15s;
}
.stat-kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-kpi-perizie  { border-top-color: var(--c-perizia_fissata); }
.stat-kpi-fatta    { border-top-color: var(--c-perizia_fatta); }
.stat-kpi-incarico { border-top-color: var(--c-incarico_firmato); }
.stat-kpi-chiusura {
  border-top-color: #14532d;
  background: linear-gradient(145deg, #14532d, #166534);
  color: #fff;
}
.stat-kpi-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
}
.stat-kpi-chiusura .stat-kpi-label { color: rgba(255,255,255,.7); }
.stat-kpi-sub {
  font-size: .7rem; color: var(--text-muted); margin-bottom: .7rem;
}
.stat-kpi-chiusura .stat-kpi-sub { color: rgba(255,255,255,.6); }
.stat-kpi-pct {
  font-size: 2.5rem; font-weight: 800; line-height: 1;
  letter-spacing: -.04em; margin-bottom: .65rem;
}
.stat-kpi-perizie  .stat-kpi-pct { color: #15803d; }
.stat-kpi-fatta    .stat-kpi-pct { color: #166534; }
.stat-kpi-incarico .stat-kpi-pct { color: #14532d; }
.stat-kpi-pct-chiusura { color: #fff; }
.stat-kpi-sign {
  font-size: 1.3rem; font-weight: 700; opacity: .65; margin-left: .04em;
}
.stat-kpi-bar-wrap {
  height: 7px; background: var(--border);
  border-radius: 99px; overflow: hidden; margin-bottom: .5rem;
}
.stat-kpi-chiusura .stat-kpi-bar-wrap { background: rgba(255,255,255,.25); }
.stat-kpi-bar {
  height: 100%; border-radius: 99px; max-width: 100%;
  transition: width .6s ease;
}
/* barra segmentata (fissate + fatte) */
.stat-kpi-bar-split {
  display: flex; width: 100%;
  background: transparent; border-radius: 99px;
}
.stat-kpi-bar-seg {
  height: 7px; transition: width .6s ease; max-width: 100%;
}
.stat-kpi-seg-fissata { background: var(--c-perizia_fissata); border-radius: 99px 0 0 99px; }
.stat-kpi-seg-fatta   { background: var(--c-perizia_fatta);   border-radius: 0 99px 99px 0; }

/* ── Selettore periodo grafico ── */
.period-selector {
  display: flex; gap: 2px;
  background: var(--bg); border-radius: 7px;
  padding: 3px; border: 1px solid var(--border);
}
.period-btn {
  padding: .28rem .85rem;
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  color: var(--text-muted); border-radius: 5px;
  transition: background .15s, color .15s;
}
.period-btn:hover  { color: var(--text); background: var(--border); }
.period-btn.active { background: var(--surface); color: var(--gold-h); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Header grafico con filtro date ── */
.chart-card-header-col { flex-direction: column; align-items: stretch; gap: .6rem; padding: .9rem 1.25rem .75rem; }
.chart-card-header-top { display: flex; align-items: center; justify-content: space-between; }
.chart-body-line { height: 260px; }

/* ── Filtro date range ── */
.date-range-form { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.date-presets    { display: flex; gap: 4px; }
.date-preset-btn {
  padding: .22rem .65rem; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface);
  font-family: inherit; font-size: .75rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.date-preset-btn:hover  { background: var(--bg); color: var(--text); border-color: #ccc; }
.date-preset-btn.active { background: var(--gold-light); color: var(--gold-h); border-color: var(--gold); }
.date-inputs { display: flex; align-items: center; gap: .4rem; }
.date-input  {
  padding: .28rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: .8rem; font-family: inherit;
  background: var(--surface); outline: none; color: var(--text);
  transition: border-color .15s;
}
.date-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(211,175,0,.12); }
.date-sep { font-size: .8rem; color: var(--text-muted); }

/* ── Bottone Statistiche (dashboard) ── */
.btn-statistiche {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .15s;
}
.btn-statistiche:hover {
  background: var(--gold-light);
  color: var(--gold-h);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(211,175,0,.15), var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}
.stat-kpi-count { font-size: .78rem; color: var(--text-muted); }
.stat-kpi-chiusura .stat-kpi-count { color: rgba(255,255,255,.65); }

/* ── Grafici ── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: .75rem;
  margin-bottom: .75rem;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.chart-card-header {
  display: flex; align-items: baseline; gap: .75rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #faf9f5;
}
.chart-card-title { font-size: .88rem; font-weight: 700; }
.chart-card-sub   { font-size: .75rem; color: var(--text-muted); }
.chart-body       { padding: 1.25rem; height: 240px; }
.chart-body-doughnut { height: 190px; }
.chart-legend {
  padding: .5rem 1.25rem 1rem;
  display: flex; flex-direction: column; gap: .3rem;
}
.chart-legend-item {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem;
}
.chart-legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}
.chart-legend-label { flex: 1; color: var(--text); }
.chart-legend-val   { font-weight: 700; color: var(--text-muted); }

/* ── Funnel di conversione ── */
.funnel-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: .75rem;
}
.funnel-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; gap: .85rem; }
.funnel-row  { display: flex; align-items: center; gap: 1rem; }
.funnel-label {
  width: 145px; flex-shrink: 0;
  font-size: .82rem; font-weight: 600; color: var(--text);
}
.funnel-bar-wrap {
  flex: 1; height: 10px; background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.funnel-bar {
  height: 100%; border-radius: 99px; max-width: 100%;
  transition: width .6s ease;
}
.funnel-right { display: flex; align-items: center; gap: .75rem; width: 90px; justify-content: flex-end; }
.funnel-pct { font-size: .85rem; font-weight: 700; color: var(--text); min-width: 40px; text-align: right; }
.funnel-n   { font-size: .8rem; color: var(--text-muted); min-width: 20px; text-align: right; }

/* ── Sezione chiamate (statistiche per-sede) ── */
.chiamate-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.5rem; overflow: hidden;
}
.chiamate-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
}
.chiamate-kpi-row {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border);
}
.chiamate-kpi-card {
  padding: 1.2rem 1.5rem; border-right: 1px solid var(--border);
}
.chiamate-kpi-card:last-child { border-right: none; }
.chiamate-kpi-tempo { background: var(--gold-light); }
.chiamate-kpi-val {
  font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--text);
}
.chiamate-kpi-label {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); margin-top: .25rem;
}
.chiamate-kpi-sub { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }

.chiamate-fasce-wrap { padding: 1.25rem 1.5rem; }
.chiamate-fasce-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); margin-bottom: .8rem;
}
.chiamate-fascia-row {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem;
}
.chiamate-fascia-label {
  width: 90px; flex-shrink: 0; font-size: .82rem; font-weight: 600; color: var(--text);
}
.chiamate-fascia-bar-wrap {
  flex: 1; height: 10px; background: var(--border); border-radius: 99px; overflow: hidden;
}
.chiamate-fascia-bar {
  height: 100%; border-radius: 99px; max-width: 100%; transition: width .6s ease;
}
.chiamate-fascia-n {
  width: 28px; text-align: right; font-size: .82rem; font-weight: 700; color: var(--text);
}
.chiamate-fasce-note {
  font-size: .75rem; color: var(--text-muted); margin-top: .7rem;
}

/* ── KPI breakdown sedi (pagina admin) ── */
.kpi-sede-breakdown {
  display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .3rem;
  font-size: .75rem; color: var(--text-muted);
}
.kpi-sede-breakdown span { white-space: nowrap; }
.kpi-sede-nome { font-weight: 700; color: var(--text); margin-right: .15rem; }

/* ── Statistiche Admin ── */
.admin-compare-table {
  width: 100%; border-collapse: collapse; font-size: .88rem;
}
.admin-compare-table thead th {
  padding: .6rem 1.2rem; text-align: center; font-size: .8rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
}
.admin-compare-table thead th:first-child { text-align: left; }
.admin-compare-table tbody td {
  padding: .55rem 1.2rem; text-align: center; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.admin-compare-table tbody td:first-child { text-align: left; color: var(--text-muted); }
.admin-compare-table .row-primary td { font-weight: 700; font-size: .95rem; color: var(--text); }
.admin-compare-table .row-kpi td:not(:first-child) { font-weight: 600; }
.admin-compare-table .row-chiusura td { background: var(--gold-light); }
.admin-compare-table .row-separator td { height: 6px; border: none; background: var(--bg); }
.admin-compare-table .col-totale { background: rgba(211,175,0,.07); font-weight: 700 !important; }
.admin-compare-table .kpi-pct { font-weight: 400; color: var(--text-muted); font-size: .8rem; }
.sede-link { color: var(--gold-h); font-weight: 700; }
.stato-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }

.admin-sede-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.admin-sede-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .9rem;
}
.admin-sede-totale {
  border-color: var(--gold); background: linear-gradient(135deg, #fffbe6 0%, #fff 60%);
}
.admin-sede-header {
  display: flex; align-items: baseline; justify-content: space-between;
}
.admin-sede-nome { font-weight: 700; font-size: 1rem; }
.admin-sede-tot  { font-size: .82rem; color: var(--text-muted); }

.admin-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
}
.admin-kpi-item {
  text-align: center; padding: .5rem .25rem;
  background: var(--bg); border-radius: 6px;
}
.admin-kpi-chiusura { background: var(--gold-light); }
.admin-kpi-val  { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.admin-kpi-sign { font-size: .8rem; font-weight: 600; opacity: .7; }
.admin-kpi-label { font-size: .68rem; color: var(--text-muted); margin-top: .2rem; text-transform: uppercase; letter-spacing: .03em; }

.admin-funnel { display: flex; flex-direction: column; gap: .45rem; }
.admin-funnel-row { display: flex; align-items: center; gap: .6rem; }
.admin-funnel-label { font-size: .75rem; color: var(--text-muted); width: 90px; flex-shrink: 0; }
.admin-funnel-bar-wrap { flex: 1; height: 7px; background: var(--border); border-radius: 99px; overflow: hidden; }
.admin-funnel-bar { height: 100%; border-radius: 99px; background: var(--gold); max-width: 100%; transition: width .5s ease; }
.admin-funnel-n { font-size: .75rem; font-weight: 700; width: 26px; text-align: right; }
.admin-sede-link {
  font-size: .78rem; color: var(--gold-h); font-weight: 600;
  text-align: right; margin-top: auto;
}
.admin-sede-link:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .stat-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid    { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .navbar-nav .btn-nav { display: none; }
  .stats-grid    { grid-template-columns: repeat(2, 1fr); }
  .stat-kpi-grid { grid-template-columns: 1fr 1fr; }
  .leads-grid    { grid-template-columns: 1fr; }
  .form-row-3    { grid-template-columns: 1fr 1fr; }
  .funnel-label  { width: 100px; font-size: .75rem; }
}
