:root {
  color-scheme: light;
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --primary: #0090df;
  --primary_hover: #0078c2;
  --secondary: #b3d9f5;
  --secondary_hover: #0078c2;
  --text: #5a6170;
  --text_light: #9aa0ab;
  --accent: #003d6c;
  --border: #dde3ea;
  --background: #FFFFFF;
  --background_light: #f0f4f8;
  --bg: var(--background_light);
  --surface: var(--background_light);
  --panel: var(--background);
  --line: var(--border);
  --muted: var(--text);
  --primary-dark: var(--primary_hover);
  --blue: var(--primary);
  --sky: #0090df;
  --orange: #e74f10;
  --lavender: var(--secondary);
  --success: #1a8c55;
  --warning: #b76507;
  --danger: #c0392b;
  --navy: #0f1923;
  --mint: #01D5CA;
  --brand-blue: #008EEB;
  --brand-grad: linear-gradient(-31deg, #01D5CA 0%, #008EEB 100%);
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background_light);
  color: var(--accent);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  overflow-wrap: anywhere;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #003d6c 0%, #005fa3 55%, #0090df 100%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-md);
}

.brand-mark {
  font-weight: 800;
  letter-spacing: 0;
  font-size: 22px;
}

.login-logo {
  width: 174px;
  height: auto;
}

.login-card h1,
.topbar h1 {
  margin: 12px 0 6px;
  font-family: "Bricolage Grotesque", "Radio Canada Big", "DM Sans", sans-serif;
  letter-spacing: -.02em;
  color: var(--navy);
}

.form-stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  color: var(--accent);
  min-width: 0;
  transition: border-color .15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 144, 223, .15);
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 42px;
  padding: 8px 16px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.btn:hover {
  border-color: #c5ced8;
  background: #f7fafc;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 144, 223, .28);
}

.btn.primary:hover {
  background: var(--primary_hover);
  border-color: var(--primary_hover);
  box-shadow: 0 4px 14px rgba(0, 144, 223, .38);
}

.btn.ghost {
  background: var(--background);
}

.btn.small {
  min-height: 24px !important;
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 6px;
  line-height: 1;
}

.btn.success {
  color: var(--success);
  border-color: rgba(26, 140, 85, .35);
  background: rgba(26, 140, 85, .06);
}

.btn.success:hover {
  background: rgba(26, 140, 85, .12);
}

.btn.muted-action {
  color: var(--danger);
  border-color: rgba(192, 57, 43, .3);
  background: rgba(192, 57, 43, .04);
}

.btn.muted-action:hover {
  background: rgba(192, 57, 43, .1);
}

.muted,
td span,
.pipeline-head span,
.agenda-item span {
  color: var(--muted);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0;
  background: #0f1923;
  color: rgba(255, 255, 255, .8);
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 1px 0 0 rgba(255,255,255,.06);
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 18px 18px;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-logo {
  height: auto;
  flex-shrink: 0;
}

.sidebar-logo-full {
  width: 142px;
  display: block;
}

.sidebar-logo-mark {
  display: none;
  width: 28px;
}

.sidebar-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-height: unset;
  padding: 0;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  color: rgba(255, 255, 255, .6);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, .14) !important;
  border-color: rgba(255, 255, 255, .25) !important;
  color: #fff !important;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, .07);
  margin: 0 18px;
  flex-shrink: 0;
}

.user-code {
  color: rgba(255, 255, 255, .3);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 18px 8px;
  flex-shrink: 0;
}

.sidebar nav {
  display: grid;
  gap: 2px;
  padding: 4px 10px;
  align-content: start;
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, .58);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  transition: background .15s, color .15s;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .9);
}

.sidebar a.active {
  background: linear-gradient(-31deg, rgba(1,213,202,.18) 0%, rgba(0,142,235,.18) 100%);
  color: #fff;
  border: 1px solid rgba(1, 213, 202, .22);
}

.sidebar a.active .nav-icon svg {
  color: #01D5CA;
}

.nav-icon {
  flex: 0 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .85;
}

.nav-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  margin: auto 10px 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255, 255, 255, .05) !important;
  border: 1px solid rgba(255, 255, 255, .1) !important;
  color: rgba(255, 255, 255, .5) !important;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  padding: 9px 10px;
  min-height: unset;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, .1) !important;
  border-color: rgba(255, 255, 255, .2) !important;
  color: rgba(255, 255, 255, .85) !important;
}

.main {
  min-width: 0;
  padding: 28px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.topbar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 22px;
  box-shadow: var(--shadow);
}

.topbar,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.topbar > div:first-child,
.section-head > div:first-child {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar p,
.section-head h2,
.card h2 {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  max-width: 780px;
}

.topbar h1,
.section-head h2,
.card h2 {
  font-family: "Bricolage Grotesque", "Radio Canada Big", "DM Sans", sans-serif;
  color: var(--navy);
  line-height: 1.12;
  overflow-wrap: anywhere;
  letter-spacing: -.02em;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.kpi,
.mini-kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow);
  min-width: 0;
  transition: box-shadow .15s;
}

.kpi:hover,
.mini-kpi:hover {
  box-shadow: var(--shadow-md);
}

.kpi span,
.mini-kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kpi strong {
  font-size: 30px;
  color: var(--navy);
  font-family: "Bricolage Grotesque", "Radio Canada Big", "DM Sans", sans-serif;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(170px, 210px)) auto auto;
  gap: 10px;
  align-items: center;
}

.toolbar input {
  min-width: 0;
}

.crm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  gap: 20px;
}

.app-section {
  display: none;
}

.app-section.active {
  display: block;
}

.crm-layout.app-section.active,
.profile-grid.app-section.active {
  display: grid;
}

.pipeline-card,
.side-card {
  min-width: 0;
}

.speed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  overflow: visible;
  padding: 2px;
  max-width: 100%;
}

.pipeline-column {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--background_light);
  padding: 14px;
  min-width: 0;
}

.pipeline-column.status-call_due {
  background: #ffffff;
  border-color: rgba(0, 144, 223, .3);
}

.pipeline-column.status-won {
  background: rgba(26, 140, 85, .06);
  border-color: rgba(26, 140, 85, .25);
}

.pipeline-column.status-not_interested {
  background: #f5f5f7;
  opacity: .85;
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
}

.pipeline-head strong,
.pipeline-head span {
  display: block;
  overflow-wrap: anywhere;
}

.pipeline-head b {
  flex: 0 0 auto;
  color: var(--primary);
  background: rgba(0, 144, 223, .1);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 13px;
}

.pipeline-head div,
.agenda-item,
td {
  display: grid;
  gap: 4px;
}

.pipeline-list,
.agenda-list {
  display: grid;
  gap: 12px;
}

.lead-card,
.agenda-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
  transition: box-shadow .15s, border-color .15s;
}

.lead-card:hover {
  border-color: rgba(0, 144, 223, .35);
  box-shadow: 0 4px 14px rgba(0, 61, 108, .1);
}

.lead-card {
  display: grid;
  gap: 8px;
  align-content: start;
}

.lead-card.due,
.agenda-item.due {
  border-color: rgba(231, 79, 16, .5);
  background: rgba(231, 79, 16, .06);
}

.lead-head,
.lead-value,
.actions-row {
  display: flex;
  justify-content: flex-start;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.lead-head {
  justify-content: space-between;
}

.lead-head strong {
  font-size: 16px;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.lead-company {
  color: var(--navy);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.lead-contact {
  color: #354152;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.lead-head span,
.tag {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--background_light);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.module-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag.module-tag {
  border-color: rgba(0, 144, 223, .3);
  background: rgba(0, 144, 223, .1);
  color: var(--primary_hover);
}

.tag.muted-tag {
  background: #f7f7f7;
  color: var(--muted);
}

.speed-chip {
  width: fit-content;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(0, 144, 223, .12);
  color: var(--primary_hover);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.speed-chip.late {
  background: rgba(231, 79, 16, .1);
  color: #c84000;
}

.speed-chip.watch {
  background: rgba(183, 101, 7, .12);
  color: var(--warning);
}

.speed-chip.handled {
  background: rgba(26, 140, 85, .1);
  color: var(--success);
}

.side-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  line-height: 1.45;
}

th {
  color: var(--text_light);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.empty {
  color: var(--muted);
  padding: 10px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.profile-card {
  align-content: start;
  display: grid;
  gap: 16px;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-identity img {
  width: 136px;
  height: auto;
}

.profile-identity div,
.profile-list div,
.module-row {
  display: grid;
  gap: 4px;
}

.profile-identity strong {
  font-family: "Bricolage Grotesque", "Radio Canada Big", "DM Sans", sans-serif;
  color: var(--navy);
  font-size: 22px;
  letter-spacing: -.02em;
}

.profile-identity span,
.profile-list dt,
.profile-note {
  color: var(--muted);
}

.profile-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 14px;
  margin: 0;
}

.profile-list dt {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-list dd {
  margin: 0;
  font-weight: 700;
}

.profile-note {
  margin: 0;
  line-height: 1.5;
}

.module-breakdown {
  display: grid;
  gap: 10px;
}

.module-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--background_light);
  transition: border-color .15s;
}

.module-row:hover {
  border-color: rgba(0, 144, 223, .3);
}

.module-row strong {
  color: var(--primary);
  font-size: 20px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

/* ── Lead detail (HubSpot-style) ───────────────────────────────────────────── */

.lead-detail {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
  max-height: calc(100vh - 96px);
  overflow: hidden;
}

/* Rimosso — la definizione principale è più in basso nel file */
.detail-main {
  min-width: 0;
}

/* Timeline e log-card con scroll interno */
.log-card {
  display: grid;
  gap: 10px;
}

.act-type-sel {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline {
  overflow-y: auto;
  max-height: inherit;
}

.tl-item {
  display: flex;
  gap: 12px;
}

.detail-header {
  display: grid;
  gap: 14px;
}

.detail-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text_light);
  padding: 6px 10px;
  min-height: unset;
}

.back-btn:hover { color: var(--navy); }

.detail-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-company {
  margin: 0;
  font-size: 22px;
  color: var(--navy);
  font-family: "Bricolage Grotesque", "DM Sans", sans-serif;
  letter-spacing: -.02em;
}

.detail-person {
  color: var(--text_light);
  font-size: 13px;
  margin-top: 2px;
}

.detail-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Log activity */
.log-card {
  padding: 0;
  overflow: hidden;
}

.log-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
}

.log-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text_light);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.log-tab:hover { color: var(--navy); }

.log-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.log-form-body {
  display: grid;
  gap: 12px;
  padding: 10px;
}

.log-form-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.log-date {
  display: grid;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.log-date small {
  font-weight: 400;
  color: var(--text_light);
}

/* Timeline */
.timeline-card h3 {
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: inherit;
}

.timeline {
  display: grid;
  gap: 0;
}

.tl-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}

.tl-item:last-child { padding-bottom: 0; }

.tl-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.tl-item:last-child::before { display: none; }

.tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  margin-top: 2px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.tl-open .tl-dot {
  border-color: var(--warning);
  background: rgba(183, 101, 7, .12);
}

.tl-done .tl-dot {
  border-color: var(--success);
  background: rgba(26, 140, 85, .12);
}

.tl-body { min-width: 0; }

.tl-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.tl-head strong { font-size: 13px; color: var(--navy); }

.tl-date {
  font-size: 12px;
  color: var(--text_light);
}

.tl-subject {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text);
}

.tl-notes {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text_light);
  line-height: 1.5;
}

.tl-sched {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--warning);
  font-weight: 600;
}

/* Lead detail body: layout a larghezza intera con scroll indipendente */
.detail-body {
  flex: 1;
  display: grid;
  gap: 20px;
  align-items: start;
  overflow-y: auto;
  padding-bottom: 24px;
}

/* Properties panel — consolidated */
.props-card {
  background: #fff;
  padding: 0;
  display: grid;
  gap: 12px;
  align-items: start;
}
.props-card-fixed {
  min-height: 160px;
}

.props-head {
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f6;
  background: #fbfdff;
  color: var(--ink-2);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1;
  height: fit-content;
}

.props-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text_light);
  font-family: inherit;
}

.props-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
}

.props-list-tags {
  display: block;
  align-self: flex-start;
}
.props-list-tags .tag {
  display: inline-block;
  margin: 2px 4px 2px 0;
}

.props-note {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
  align-self: start;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Card Note — stile specifico ─────────────────────────────── */
.props-card-note {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-left: 4px solid #f0b84e;
}
.props-card-note .props-head {
  background: #fff9e6;
  border-bottom-color: #fde68a;
}
.props-card-note .props-note {
  color: #7a5c1a;
  text-align: left;
  align-self: start;
}

.prop-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
}

.prop-row dt {
  color: var(--text_light);
  font-weight: 600;
  font-size: 12px;
}

.prop-row dd {
  margin: 0;
  color: var(--navy);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.prop-row a { color: var(--primary); text-decoration: none; }
.prop-row a:hover { text-decoration: underline; }

.prop-empty { color: var(--text_light); }

.detail-main {
  min-width: 0;
}

.detail-sidebar-1,
.detail-sidebar-2 {
  display: grid;
  gap: 20px;
  min-width: 0;
}

/* Lead detail footer */

/* @media 1200px: grid-template-columns removed — content fills full width */

@media (max-width: 960px) {
  .lead-detail {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .detail-body {
    overflow-y: visible;
  }
}

/* ── Leads table ───────────────────────────────────────────────────────────── */

.leads-table-card {
  padding: 0;
  overflow: hidden;
}

.leads-toolbar {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.leads-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text_light);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.leads-table {
  min-width: 1100px;
}

.leads-table thead th {
  background: var(--background_light);
  font-size: 11px;
  color: var(--text_light);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.th-sort {
  cursor: pointer;
  user-select: none;
}

.th-sort:hover {
  color: var(--primary);
}

.th-active {
  color: var(--primary) !important;
}

.leads-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.lead-row {
  cursor: pointer;
  transition: background .1s;
}

.lead-row:hover {
  background: rgba(0, 144, 223, .04);
}

.lead-row.row-due {
  background: rgba(231, 79, 16, .03);
}

.td-main strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
}

.td-main span,
.td-contact span {
  display: block;
  color: var(--text);
  font-size: 12px;
}

.td-main small,
.td-contact small {
  display: block;
  color: var(--text_light);
  font-size: 11px;
}

.td-modules .module-tags {
  flex-wrap: nowrap;
  gap: 3px;
  max-width: 160px;
  overflow: hidden;
}

.td-modules .tag {
  font-size: 10px;
  padding: 1px 6px;
}

.td-value strong {
  color: var(--primary_hover);
  font-weight: 700;
  font-size: 13px;
}

.td-date {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.td-date.date-due {
  color: var(--danger);
  font-weight: 700;
}

.due-pill {
  display: inline-block;
  background: rgba(192, 57, 43, .1);
  color: var(--danger);
  border: 1px solid rgba(192, 57, 43, .25);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */

.bdg {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.bdg-gray   { background: var(--background_light); color: var(--text); border-color: var(--line); }
.bdg-blue   { background: rgba(0,144,223,.1); color: var(--primary_hover); border-color: rgba(0,144,223,.2); }
.bdg-green  { background: rgba(26,140,85,.1); color: var(--success); border-color: rgba(26,140,85,.2); }
.bdg-orange { background: rgba(183,101,7,.1); color: var(--warning); border-color: rgba(183,101,7,.2); }
.bdg-purple { background: rgba(124,58,237,.08); color: #6d28d9; border-color: rgba(124,58,237,.18); }
.bdg-red    { background: rgba(192,57,43,.08); color: var(--danger); border-color: rgba(192,57,43,.18); }

@media (max-width: 1120px) {
  .crm-layout {
    grid-template-columns: 1fr;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Sidebar collapsable ───────────────────────────────────────────────────── */

.shell {
  transition: grid-template-columns .22s ease;
}

.shell.sidebar-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

/* Collapsed: head — nascondi logo+testo, mostra solo pulsante toggle */
.shell.sidebar-collapsed .sidebar-head {
  flex-direction: column;
  align-items: center;
  padding: 18px 8px 14px;
  gap: 0;
}

.shell.sidebar-collapsed .sidebar-logo { display: none; }
.shell.sidebar-collapsed .sidebar-head .sidebar-toggle {
  margin: 0;
  justify-content: center;
}

.shell.sidebar-collapsed .sidebar-logo-full { display: none; }
.shell.sidebar-collapsed .sidebar-logo-mark { display: block; }

.shell.sidebar-collapsed .sidebar-text { display: none; }

.shell.sidebar-collapsed .sidebar-divider {
  margin: 0 8px;
}

/* Collapsed: nav */
.shell.sidebar-collapsed .sidebar nav {
  padding: 4px 8px;
}

.shell.sidebar-collapsed .sidebar a {
  justify-content: center;
  padding: 11px 8px;
}

.shell.sidebar-collapsed .nav-label { display: none; }
.shell.sidebar-collapsed .nav-text { display: none; }

.shell.sidebar-collapsed .nav-icon {
  flex: 0 0 auto;
  opacity: .7;
}

.shell.sidebar-collapsed .sidebar a.active .nav-icon {
  opacity: 1;
}

/* Collapsed: logout */
.shell.sidebar-collapsed .logout-btn {
  margin: 8px;
  justify-content: center;
  padding: 9px;
}

.shell.sidebar-collapsed .logout-btn .nav-text { display: none; }

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 30, 60, .5);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: min(660px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 30, 60, .28);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  position: sticky;
  top: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}

.modal-head h2 {
  margin: 0;
  font-family: "Bricolage Grotesque", "Radio Canada Big", "DM Sans", sans-serif;
  color: var(--navy);
  letter-spacing: -.02em;
  font-size: 20px;
}

.modal-x {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
  border-radius: 8px;
}

.modal-body {
  padding: 20px 24px 28px;
}

/* ── Form: modal lead ──────────────────────────────────────────────────────── */

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: grid;
  gap: 8px;
}

/* Small inputs for settings page */
.form-input-sm {
  height: 32px;
  font-size: 13px;
  padding: 0 10px;
  max-width: 50%;
}

.pwd-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pwd-msg {
  font-size: 13px;
  display: none;
}

.pwd-msg[style*="block"] {
  display: block;
}

.form-label {
  font-weight: 650;
}

.form-checkgroup {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-pill {
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-weight: 500 !important;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--background_light);
  transition: border-color .15s, background .15s;
}

.check-pill:hover {
  border-color: rgba(0, 144, 223, .4);
  background: rgba(0, 144, 223, .06);
}

.check-pill:has(input:checked) {
  border-color: var(--primary);
  background: rgba(0, 144, 223, .1);
  color: var(--primary_hover);
}

.check-pill input[type="checkbox"] {
  min-height: auto;
  width: 15px;
  height: 15px;
  cursor: pointer;
  border-radius: 4px;
}

textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  color: var(--accent);
  resize: vertical;
  min-height: 80px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 144, 223, .15);
}

/* Lead cards are clickable */
.lead-card,
.directory-card {
  cursor: pointer;
}

@media (max-width: 760px) {
  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-head {
    flex-direction: row;
    padding: 16px 18px;
  }

  .sidebar-logo-full { display: block !important; }
  .sidebar-logo-mark { display: none !important; }

  .shell.sidebar-collapsed .sidebar a {
    flex-direction: row;
    justify-content: flex-start;
    padding: 10px 10px;
  }

  .shell.sidebar-collapsed .nav-text { display: block; }
  .shell.sidebar-collapsed .nav-label { display: block; }
  .shell.sidebar-collapsed .sidebar-text { display: block; }

  .shell.sidebar-collapsed .logout-btn {
    flex-direction: row;
    justify-content: flex-start;
    margin: 10px 10px 16px;
    padding: 9px 10px;
  }
  .shell.sidebar-collapsed .logout-btn .nav-text { display: block; }

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .toolbar,
  .lead-directory {
    grid-template-columns: 1fr;
  }

  .profile-list,
  .profile-stats {
    grid-template-columns: 1fr;
  }

  .directory-main,
  .directory-grid {
    grid-template-columns: 1fr;
  }

  .directory-value {
    text-align: left;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NEW CRM — inFactory HubSpot-style UI (2026)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0a1628 0%, #0d2137 30%, #0f2b47 60%, #112d4c 100%);
  background-image:
    linear-gradient(135deg, #0a1628 0%, #0d2137 30%, #0f2b47 60%, #112d4c 100%),
    radial-gradient(ellipse at 20% 80%, rgba(1,213,202,.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0,142,235,.20) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(155,89,183,.12) 0%, transparent 40%);
  padding: 24px;
}
.login-box {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
}
.login-brand {
  width: 140px;
  margin-bottom: 20px;
  filter: invert(1) brightness(0);
  opacity: .8;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--navy);
}
.login-sub { margin: 0 0 24px; color: var(--text); font-size: 14px; }
.login-err {
  color: #dc2626;
  font-size: 13px;
  padding: 8px 12px;
  background: #fef2f2;
  border-radius: 6px;
  margin-top: 10px;
}
.btn-block { width: 100%; }

/* ── Shell layout ────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}
.shell.sidebar-collapsed { grid-template-columns: 64px 1fr; }

.sidebar {
  background: var(--navy);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: 60px;
  width: 100%;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 0;
}

.sidebar-logo-svg {
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}
.sidebar-logo-full {
  height: 26px;
  flex: 1;
  object-fit: contain;
  object-position: left;
}
.sidebar-logo-mark {
  display: none;
  font-weight: 800;
  color: #fff;
  font-size: 18px;
  letter-spacing: -1px;
  flex: 1;
}

.sidebar-logo-text {
  font-weight: 700;
  color: #fff;
  font-size: 16px;
}
.shell.sidebar-collapsed .sidebar-logo-full { display: none; }
.shell.sidebar-collapsed .sidebar-logo-mark { display: block; }

.sidebar-toggle {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s;
}
.sidebar-toggle:hover { color: rgba(255,255,255,.9); }

.sidebar-head .sidebar-toggle {
  margin-left: auto;
  color: rgba(255,255,255,.4);
}
.sidebar-toggle svg { width: 16px; height: 16px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.nav-link.active {
  background: linear-gradient(-31deg, rgba(1,213,202,.18) 0%, rgba(0,142,235,.18) 100%);
  color: #fff;
  border: 1px solid rgba(1,213,202,.25);
}
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-text { transition: opacity .15s; }
.shell.sidebar-collapsed .nav-label { display: none; }
.shell.sidebar-collapsed .nav-text { display: none; }
.shell.sidebar-collapsed .nav-link { justify-content: center; padding: 10px; }
.shell.sidebar-collapsed .sidebar-foot-info { display: none; }
.shell.sidebar-collapsed .foot-logout { margin-left: auto; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-foot-info { flex: 1; min-width: 0; }
.foot-name { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-role { display: block; font-size: 11px; color: rgba(255,255,255,.45); text-transform: capitalize; }
.foot-logout {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s;
}
.foot-logout:hover { color: #ef4444; }
.foot-logout svg { width: 16px; height: 16px; }

/* ── Main wrap + topbar ──────────────────────────────────────────────────── */
.main-wrap {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100vh;
  background: #f1f5f9;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.topbar-breadcrumb {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.btn-icon, .topbar-help {
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.btn-icon:hover, .topbar-help:hover { background: #f1f5f9; color: #1e293b; }
.btn-icon svg, .topbar-help svg { width: 16px; height: 16px; }
.topbar-search { display: flex; align-items: center; gap: 8px; position: relative; padding: 0 12px; height: 36px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }
.topbar-search svg { width: 16px; height: 16px; flex-shrink: 0; color: #94a3b8; }
.topbar-logout { background: transparent; border: none; cursor: pointer; padding: 6px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #64748b; }
.topbar-logout:hover { background: #f1f5f9; color: #1e293b; }
.topbar-logout svg { width: 16px; height: 16px; }

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.main-content.is-loading { opacity: .5; pointer-events: none; }

/* ── Badge system extensions ─────────────────────────────────────────────── */
.bdg-indigo { background: #eef2ff; color: #4338ca; }
.bdg-amber  { background: #fffbeb; color: #b45309; }
.bdg-teal   { background: rgba(17,155,135,.1); color: #0d9488; border-color: rgba(17,155,135,.2); }

.score-bdg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.score-hot  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.score-warm { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.score-cold { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-sm { min-height: 28px !important; height: 28px; padding: 0 12px; font-size: 13px; }
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.btn-back:hover { background: #f1f5f9; color: #1e293b; }
.btn-back svg { width: 14px; height: 14px; }
.btn-ico {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.btn-ico:hover { background: #f1f5f9; color: #1e293b; }
.btn-ico.danger:hover { background: #fef2f2; color: #dc2626; }
.btn-ico svg { width: 14px; height: 14px; }

/* ── Form extras ─────────────────────────────────────────────────────────── */
.form-section-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 20px 0 10px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* ── Dashboard ───────────────────────────────────────────────────────────── */
.dashboard { max-width: 1200px; }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.kpi-card.kpi-hot   { border-top: 3px solid #dc2626; }
.kpi-card.kpi-demo  { border-top: 3px solid #7c3aed; }
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
}
.kpi-label { font-size: 13px; font-weight: 600; color: #475569; margin: 4px 0 2px; }
.kpi-sub   { font-size: 11px; color: #94a3b8; }

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.dash-card.dash-wide { grid-column: span 1; }
.dash-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.funnel { padding: 12px 16px; }
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.funnel-row:hover { background: #f8fafc; }
.funnel-lbl { font-size: 12px; color: #475569; width: 130px; flex-shrink: 0; }
.funnel-bar-wrap {
  flex: 1;
  background: #f1f5f9;
  border-radius: 4px;
  height: 8px;
  position: relative;
  display: flex;
  align-items: center;
}
.funnel-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--brand-grad);
  min-width: 4px;
  transition: width .4s ease;
}
.funnel-n {
  position: absolute;
  right: -24px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.src-list { padding: 8px 16px; }
.src-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.src-row:last-child { border-bottom: none; }
.src-n { font-weight: 700; color: var(--brand-blue); }

.top-leads { padding: 8px 16px; }
.top-lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 13px;
  border-radius: 6px;
  transition: background .15s;
}
.top-lead-row:hover { background: #f8fafc; padding-left: 8px; }
.top-lead-row:last-child { border-bottom: none; }
.tl-co { flex: 1; font-weight: 600; color: #1e293b; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-val { font-size: 12px; color: #64748b; white-space: nowrap; }

.act-feed { padding: 8px 16px; }
.act-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f8fafc; }
.act-item:last-child { border-bottom: none; }
.act-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
  background: #94a3b8;
}
.act-note     { background: #c7956c; }
.act-call     { background: #d4766a; }
.act-email    { background: #3b84a7; }
.act-whatsapp { background: #a89b63; }
.act-meeting  { background: #9b6dd8; }
.act-demo     { background: #5a9e8f; }
.act-stage    { background: #f59e0b; }
.act-body { flex: 1; min-width: 0; }
.act-who { font-size: 13px; font-weight: 600; color: #1e293b; }
.act-type-lbl { font-weight: 400; color: #64748b; }
.act-notes { font-size: 12px; color: #64748b; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.act-when { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.empty-hint { font-size: 13px; color: #94a3b8; text-align: center; padding: 20px; margin: 0; }

/* ── Contacts ────────────────────────────────────────────────────────────── */
.contacts-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
  min-width: 240px;
}
.search-ico { color: #94a3b8; display: flex; align-items: center; font-size: 16px; width: 16px; height: 16px; }
.search-inp { border: none; outline: none; font-size: 13px; background: transparent; color: #1e293b; flex: 1; }
.f-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.f-pill {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  border-radius: 99px;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: all .15s;
}
.f-pill:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.f-pill.active { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.toolbar-end { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.leads-count { font-size: 12px; color: #94a3b8; }

.table-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.leads-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leads-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #94a3b8;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.leads-table .th-sort { cursor: pointer; user-select: none; }
.leads-table .th-sort:hover { color: #475569; }
.leads-table .th-active { color: var(--brand-blue); }
.lead-row { border-bottom: 1px solid #f1f5f9; transition: background .1s; cursor: pointer; }
.lead-row:hover { background: #f8fafc; }
.lead-row:last-child { border-bottom: none; }
.leads-table td { padding: 10px 12px; vertical-align: middle; }
.co-name { font-weight: 600; color: #1e293b; }
.co-person { font-size: 12px; color: #64748b; margin-top: 1px; }
.td-sec { font-size: 12px; color: #64748b; }
.td-val { font-weight: 600; color: #1e293b; white-space: nowrap; }
.td-acts { white-space: nowrap; opacity: 0; transition: opacity .15s; }
.lead-row:hover .td-acts { opacity: 1; }
.td-empty { text-align: center; padding: 40px; color: #94a3b8; font-size: 14px; }

.contacts-view {
  display: grid;
  gap: 14px;
}

.contacts-toolbar {
  display: grid;
  gap: 12px;
}

.contacts-toolbar-top,
.contacts-toolbar-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.contacts-toolbar-top .search-wrap {
  flex: 1 1 360px;
}

.contacts-toolbar-filters {
  align-items: end;
}

.contact-selects {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.contact-filter {
  display: grid;
  gap: 5px;
  min-width: 154px;
  font-size: 11px;
  font-weight: 800;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.contact-filter select {
  min-height: 34px;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 650;
  color: #334155;
}

.contacts-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.contacts-summary > div {
  display: grid;
  gap: 3px;
  background: #fff;
  border: 1px solid #d9e2ea;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.contacts-summary span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.contacts-summary strong {
  color: #132238;
  font-size: 20px;
  line-height: 1.1;
}

.contact-inline {
  margin-top: 3px;
  color: #64748b;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.td-qual,
.td-pipeline,
.td-source {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.td-pipeline {
  justify-content: space-between;
}

.contact-value {
  color: #1e293b;
  font-weight: 800;
  white-space: nowrap;
}

.td-sec strong,
.td-sec span {
  display: block;
}

.td-sec strong {
  color: #334155;
  font-size: 12px;
}

.leads-table th,
.leads-table td {
  display: table-cell !important;
}

.leads-table .td-qual .sector-chip,
.leads-table .td-source .source-chip,
.leads-table .td-pipeline .bdg {
  margin-right: 6px;
  margin-bottom: 4px;
}

.leads-table .td-qual .score-bdg {
  margin-bottom: 4px;
}

.leads-table .contact-value {
  display: block;
  margin-top: 7px;
}

/* ── Activities / follow-up ─────────────────────────────────────────────── */
.tasks-view {
  display: grid;
  gap: 14px;
}

.tasks-toolbar .contacts-toolbar-top {
  align-items: center;
}

.tasks-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.task-group {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}

.task-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e8eef4;
}

.task-group-head span {
  color: #132238;
  font-size: 13px;
  font-weight: 850;
}

.task-group-head strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e9f2fb;
  color: #48627d;
  font-size: 12px;
}

.task-group.late .task-group-head {
  background: #fff6f5;
}

.task-group.late .task-group-head strong {
  background: #fde2df;
  color: #b42318;
}

.task-group.today .task-group-head {
  background: #eef8ff;
}

.task-list {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.task-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #dfe7ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}

.task-card:hover {
  border-color: rgba(0, 142, 235, .35);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
}

.task-card.task-late {
  border-left: 3px solid #d92d20;
}

.task-card.task-today {
  border-left: 3px solid #008EEB;
}

.task-top,
.task-meta,
.task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.task-top {
  justify-content: space-between;
}

.task-type {
  color: #0078c8;
  background: #e8f5ff;
  border: 1px solid #c9e7fb;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 850;
}

.task-due {
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
}

.task-late .task-due {
  color: #b42318;
  background: #fff6f5;
  border-color: #f3c7c2;
}

.task-title {
  color: #132238;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
}

.task-lead,
.task-note,
.task-done {
  color: #64748b;
  font-size: 12px;
}

.task-value {
  margin-left: auto;
  color: #132238;
  font-size: 12px;
  font-weight: 850;
}

.task-actions {
  justify-content: flex-end;
  padding-top: 4px;
}

/* ── Pipeline Kanban ─────────────────────────────────────────────────────── */
.pipeline-view { height: calc(100vh - 52px - 48px); overflow: hidden; }
.kk-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  height: 100%;
  padding-bottom: 8px;
}
.kk-col {
  min-width: 210px;
  max-width: 210px;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.kk-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.kk-title { font-size: 12px; font-weight: 600; color: #1e293b; flex: 1; }
.kk-cnt {
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #64748b;
  padding: 1px 6px;
  border-radius: 99px;
}
.kk-tot { font-size: 10px; color: #94a3b8; white-space: nowrap; }
.kk-drop {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
  transition: background .15s;
}
.kk-drop.kk-over { background: rgba(1,213,202,.08); }
.kk-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  transition: box-shadow .15s, opacity .15s;
}
.kk-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.kk-card.kk-dragging { opacity: .4; }
.kk-co { font-size: 12px; font-weight: 600; color: #1e293b; margin-bottom: 2px; }
.kk-who { font-size: 11px; color: #64748b; margin-bottom: 6px; }
.kk-foot { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.kk-val { font-size: 11px; color: #64748b; }
.urg-dot { color: #dc2626; font-size: 10px; }
.kk-empty { font-size: 12px; color: #cbd5e1; text-align: center; padding: 20px 8px; }

/* ── Lead detail ─────────────────────────────────────────────────────────── */
.lead-detail { max-width: 1100px; }
.detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.detail-nav-r { display: flex; gap: 8px; }
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.detail-company { font-size: 22px; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.detail-person  { font-size: 15px; color: #64748b; margin-bottom: 10px; }
.detail-badges  { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-stage-sel { text-align: right; }
.score-bar-wrap {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-bottom: 10px;
  overflow: hidden;
}
.score-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--brand-grad);
  transition: width .4s ease;
  min-width: 4px;
}
.bd-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  border-bottom: 1px solid #f8fafc;
}
.bd-pts { font-weight: 700; color: #22c55e; }

/* ── Timeline extra ──────────────────────────────────────────────────────── */
.tl-dot-stage    { background: #f59e0b; }
.tl-dot-note     { background: #c7956c; }
.tl-dot-call     { background: #d4766a; }
.tl-dot-email    { background: #3b84a7; }
.tl-dot-whatsapp { background: #a89b63; }
.tl-dot-meeting  { background: #9b6dd8; }
.tl-dot-demo     { background: #5a9e8f; }

/* Stati attività */
.tl-status-open          { color: #f59e0b; font-weight: 600; font-size: 11px; }
.tl-status-in_progress   { color: #008EEB; font-weight: 600; font-size: 11px; }
.tl-status-done           { color: #22c55e; font-weight: 600; font-size: 11px; }
.tl-status-cancelled      { color: #ef4444; font-weight: 600; font-size: 11px; }
.tl-text { font-size: 13px; color: #334155; margin-top: 2px; }
.tl-text strong { color: #1e293b; }
.tl-title { font-weight: 600; color: #1e293b; font-size: 13px; margin-bottom: 2px; }
.tl-status-change { font-weight: 600; color: #0090df; font-size: 12px; margin-top: 2px; }
.tl-notes { color: #64748b; font-size: 12px; margin-top: 4px; }
.tl-sched { color: #94a3b8; font-size: 12px; margin-top: 2px; }

/* ── Settings ────────────────────────────────────────────────────────────── */
.settings-view { max-width: 700px; display: flex; flex-direction: column; gap: 16px; }
.settings-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.settings-head {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.settings-hint {
  font-size: 12px;
  color: #94a3b8;
  padding: 0 16px 14px;
  margin: 8px 0 0;
}
.settings-hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.users-list { padding: 8px 16px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f8fafc; }
.user-row:last-child { border-bottom: none; }
.user-name  { font-size: 13px; font-weight: 600; color: #1e293b; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-email { font-size: 12px; color: #64748b; }
.score-cfg {
  padding: 12px 16px;
  font-size: 13px;
  color: #475569;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.score-cfg code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.score-table { width: calc(100% - 32px); margin: 0 16px 16px; border-collapse: collapse; font-size: 12px; }
.score-table th, .score-table td { padding: 6px 10px; border: 1px solid #e2e8f0; vertical-align: top; }
.score-table th { background: #f8fafc; font-weight: 600; }

/* ── User Guide ──────────────────────────────────────────────────────────── */
.modal-guide { max-width: 560px; }
.guide-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 16px;
}
.guide-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.guide-tab:hover { color: #1e293b; }
.guide-tab.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }
.guide-body { padding: 0; }
.guide-page { padding: 20px 24px; font-size: 14px; color: #334155; line-height: 1.6; }
.guide-page h3 { font-size: 16px; font-weight: 700; color: #1e293b; margin: 0 0 12px; }
.guide-page ol, .guide-page ul { margin: 0; padding-left: 20px; }
.guide-page li { margin-bottom: 8px; }
.guide-page p { margin: 10px 0 0; }
.guide-page code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.guide-page kbd { background: #e2e8f0; padding: 1px 6px; border-radius: 4px; font-family: monospace; font-size: 12px; border: 1px solid #cbd5e1; }

/* ═══════════════════════════════════════════════════════════════════════════
   Visual pass — Lead Center product UI
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --app-bg: #eef3f7;
  --ink: #132238;
  --ink-2: #334155;
  --ink-3: #64748b;
  --hairline: #d9e2ea;
  --card-shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 28px rgba(15, 23, 42, .06);
}

body {
  background: var(--app-bg);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border-color: var(--hairline);
  font-size: 13px;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary,
.btn.primary {
  background: #008EEB;
  border-color: #008EEB;
  color: #fff;
  box-shadow: 0 7px 18px rgba(0, 142, 235, .22);
  transition: background .2s, box-shadow .2s, opacity .2s;
}

.btn-primary:hover,
.btn.primary:hover {
  background: #0078c8;
  border-color: #0078c8;
}

.btn-secondary,
.btn.ghost {
  background: #fff;
  color: var(--ink-2);
}

.btn-danger {
  color: #b42318;
  border-color: #f3c7c2;
  background: #fff7f6;
}

.shell {
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--app-bg);
}

.shell.sidebar-collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}

.sidebar {
  background: #111827;
  border-right: 0;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06);
}

.sidebar-head {
  min-height: 68px;
  padding: 20px 16px;
}

.sidebar-logo-full {
  height: 30px;
}

.nav-link {
  min-height: 38px;
  font-weight: 650;
  color: rgba(255,255,255,.62);
}

.nav-link.active {
  background: rgba(0, 142, 235, .18);
  border: 1px solid rgba(1, 213, 202, .26);
  box-shadow: inset 3px 0 0 #01D5CA;
}

.main-wrap {
  background:
    linear-gradient(180deg, rgba(255,255,255,.72), rgba(255,255,255,0) 180px),
    var(--app-bg);
}

.topbar {
  height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 1px 0 rgba(255,255,255,.72);
}

.topbar-breadcrumb {
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
}

.main-content {
  padding: 24px 28px 28px;
}

.dashboard,
.lead-detail,
.settings-view {
  max-width: none;
}

.kpi-row {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
}

.kpi-card,
.dash-card,
.table-card,
.settings-card,
.detail-header,
.props-card,
.log-card,
.modal {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}

/* Feedback pulsante salvataggio attività */
#btn-log:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#btn-log[style*="background-color: #10b981"] {
  background: #10b981;
  border-color: #10b981;
}

#btn-log[style*="background-color: #ef4444"] {
  background: #ef4444;
  border-color: #ef4444;
}

.kpi-card {
  min-height: 112px;
  padding: 18px;
}

.kpi-card.kpi-task {
  border-top: 3px solid #0f9f6e;
}

.kpi-value {
  color: var(--ink);
  font-size: 30px;
  letter-spacing: 0;
}

.dash-grid {
  grid-template-columns: minmax(420px, 1.15fr) minmax(320px, .85fr);
  align-items: start;
}

/* Dashboard two-column layout (Task #12) */
.dash-columns {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-col-left {
  flex: 1.15;
  height: auto;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.dash-col-left::-webkit-scrollbar {
  width: 6px;
}
.dash-col-left::-webkit-scrollbar-track {
  background: transparent;
}
.dash-col-left::-webkit-scrollbar-thumb {
  background: #cdd5df;
  border-radius: 3px;
}
.dash-col-left {
  scrollbar-width: thin;
  scrollbar-color: #cdd5df #f8fafc;
}

.dash-col-right {
  flex: 0.85;
  height: calc(100vh - 200px);
  max-height: 700px;
  overflow-y: auto;
}

.dash-col-right::-webkit-scrollbar {
  width: 6px;
}
.dash-col-right::-webkit-scrollbar-track {
  background: transparent;
}
.dash-col-right::-webkit-scrollbar-thumb {
  background: #cdd5df;
  border-radius: 3px;
}
.dash-col-right {
  scrollbar-width: thin;
  scrollbar-color: #cdd5df #f8fafc;
}

.dash-card-recent {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.act-feed-scroll {
  flex: 1;
  overflow-y: auto;
}

.act-feed-scroll::-webkit-scrollbar {
  width: 4px;
}
.act-feed-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.act-feed-scroll::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 2px;
}

.dash-card-head,
.settings-head,
.props-head {
  color: var(--ink-2);
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1;
}

.contacts-toolbar,
.pipeline-toolbar {
  background: rgba(255,255,255,.74);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .03);
}

.search-wrap {
  border-color: var(--hairline);
  min-width: 300px;
}

.f-pill {
  border-radius: 7px;
  font-weight: 700;
}

.leads-table {
  min-width: 1040px;
}

.leads-table th {
  background: #f6f9fb;
  color: #66768a;
  font-weight: 800;
  letter-spacing: .03em;
}

.leads-table td {
  border-bottom: 1px solid #edf2f6;
}

.lead-row:hover {
  background: #f4f9fd;
}

.pipeline-view {
  height: calc(100vh - 64px - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.pipeline-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.pipeline-toolbar-main {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.pipe-filter {
  display: grid;
  gap: 5px;
  min-width: 168px;
  font-size: 11px;
  font-weight: 800;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pipe-filter select {
  min-height: 36px;
  border-radius: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
}

.seg-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #f6f9fb;
}

.seg-control button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.seg-control button.active {
  background: #fff;
  color: #0078c8;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.kk-board {
  gap: 10px;
  padding-bottom: 12px;
}

.kk-col {
  min-width: 252px;
  max-width: 252px;
  border-radius: 8px;
  background: #f7fafc;
  border-color: var(--hairline);
}

.kk-head {
  min-height: 48px;
  padding: 11px 12px;
  gap: 8px;
}

.kk-title {
  font-size: 13px;
  font-weight: 800;
}

.kk-tot {
  display: none;
}

.kk-drop {
  padding: 10px;
  gap: 9px;
}

.kk-card {
  border-radius: 8px;
  padding: 11px;
  border-color: #dfe7ef;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}

.kk-card:hover {
  border-color: rgba(0, 142, 235, .35);
  box-shadow: 0 10px 22px rgba(15, 23, 42, .1);
}

.kk-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.kk-co {
  font-size: 13px;
  line-height: 1.25;
}

.kk-who {
  margin: 3px 0 0;
}

.kk-age {
  flex: 0 0 auto;
  border: 1px solid #dbe6ef;
  border-radius: 6px;
  padding: 2px 6px;
  color: #526579;
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
}

.kk-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 9px;
}

.kk-foot {
  justify-content: space-between;
  gap: 8px;
}

.kk-val {
  margin-left: auto;
  color: var(--ink-2);
  font-weight: 800;
}

.sector-chip,
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.sector-chip {
  color: #17436b;
  background: #e9f5fd;
  border: 1px solid #cce8f8;
}

.sector-chip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 16px;
  border-radius: 4px;
  background: rgba(0, 142, 235, .12);
  color: #006fb7;
  font-size: 9px;
}

.sector-tessile {
  background: #f1efff;
  border-color: #ded8ff;
  color: #4a3f8f;
}

.sector-alimentare {
  background: #eef8ef;
  border-color: #d4edd8;
  color: #245b32;
}

.sector-packaging {
  background: #fff4e8;
  border-color: #ffe0ba;
  color: #7a410d;
}

.sector-stampa {
  background: #f7eef5;
  border-color: #ead1e4;
  color: #74335f;
}

.source-chip {
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.score-bdg {
  border-radius: 6px;
  padding: 3px 7px;
  font-weight: 800;
}

.detail-header {
  border-left: 4px solid #008EEB;
}

.detail-company {
  font-size: 26px;
  letter-spacing: 0;
}

.timeline {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--card-shadow);
}

.modal-head {
  border-radius: 8px 8px 0 0;
}

.check-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 1180px) {
  .kpi-row {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .dash-grid,
  .detail-body,
  .task-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    height: auto;
  }

  .main-wrap {
    height: auto;
  }

  .sidebar-head {
    min-height: 60px;
    padding: 14px 16px 10px;
    border-bottom: 0;
  }

  .sidebar-logo-full {
    display: block !important;
    height: 28px;
  }

  .sidebar-logo-mark,
  .sidebar-toggle {
    display: none !important;
  }

  .sidebar .sidebar-nav {
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 0 12px 12px;
    overflow-x: auto;
  }

  .nav-link,
  .shell.sidebar-collapsed .nav-link {
    flex: 0 0 auto;
    justify-content: flex-start;
    min-height: 38px;
    padding: 9px 11px;
  }

  .nav-text,
  .shell.sidebar-collapsed .nav-text,
  .nav-label,
  .shell.sidebar-collapsed .nav-label {
    display: block;
  }

  .sidebar-foot {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .kpi-row,
  .dash-grid {
    grid-template-columns: 1fr;
  }

  .contacts-toolbar,
  .pipeline-toolbar,
  .toolbar-end {
    align-items: stretch;
    flex-direction: column;
  }

  .search-wrap,
  .pipe-filter,
  .seg-control,
  .toolbar-end .btn {
    width: 100%;
    min-width: 0;
  }

  .seg-control button {
    flex: 1;
  }

  .pipeline-view {
    height: auto;
  }

  .kk-board {
    min-height: 70vh;
  }

  .detail-header {
    display: grid;
  }

  .detail-stage-sel {
    text-align: left;
  }
}

/* ── Import modal ─────────────────────────────────────────────────────────── */
.import-drop {
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 4px;
}
.import-drop:hover, .import-drop.drag-over {
  border-color: var(--brand-blue);
  background: #f0f9ff;
}
.import-drop-icon { font-size: 32px; color: #94a3b8; margin-bottom: 8px; }
.import-drop-label { font-size: 14px; font-weight: 600; color: #475569; margin-bottom: 4px; }
.import-drop-hint  { font-size: 12px; color: #94a3b8; }
.btn-link { background: none; border: none; color: var(--brand-blue); cursor: pointer; font-size: inherit; font-weight: 600; padding: 0; text-decoration: underline; }

.import-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #475569;
  margin-bottom: 8px;
  font-weight: 600;
}
.import-preview-table-wrap { max-height: 220px; overflow-y: auto; border-radius: 8px; border: 1px solid #e2e8f0; }
.import-preview-table { margin: 0; }

.import-prog-label { font-size: 13px; color: #475569; margin-bottom: 8px; font-weight: 600; }

.import-result { padding: 14px; border-radius: 8px; background: #f0fdf4; border: 1px solid #bbf7d0; }
.import-result.has-warn { background: #fffbeb; border-color: #fde68a; }
.import-result-ok   { font-size: 14px; font-weight: 600; color: #166534; }
.import-result-warn { font-size: 13px; color: #92400e; margin-top: 6px; }

/* ── Due activities widget ───────────────────────────────────────────────── */
.dash-card-due { border-top: 3px solid #f59e0b; }
.due-date { color: #dc2626 !important; font-weight: 600; }

/* ── Quick note button ───────────────────────────────────────────────────── */

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE — tablet (≤ 1024px) e mobile (≤ 640px)
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Tablet ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .detail-sidebar { order: -1; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .props-card { margin: 0; }
  .pipeline-view { height: auto; }
  .kk-board { overflow-x: auto; padding-bottom: 16px; }
  .dash-columns { flex-direction: column; }
  .dash-col-left {
    height: auto;
    max-height: none;
    overflow-y: visible;
    scrollbar-width: auto;
  }
  .dash-col-left::-webkit-scrollbar { width: 6px; }
  .dash-col-left::-webkit-scrollbar-track { background: transparent; }
  .dash-col-left::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
  .dash-col-right {
    flex: 1;
    height: calc(100vh - 200px);
    min-height: 200px;
    overflow-y: auto;
  }
}

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {

  /* Shell: layout a colonna intera, sidebar in overlay */
  .shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
    height: 100dvh !important;
    min-height: unset !important;
  }
  .main-wrap {
    height: 100dvh !important;
    min-height: unset !important;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .main-content { flex: 1; overflow-y: auto; }

  /* Sidebar: drawer overlay da sinistra */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -280px !important;
    bottom: 0 !important;
    height: 100dvh !important;
    width: 260px !important;
    z-index: 300;
    transition: left .22s ease !important;
    flex-direction: column !important;
    border-right: 1px solid rgba(255,255,255,.1);
    box-shadow: none;
    overflow-y: auto;
  }
  .shell.mobile-sidebar-open .sidebar {
    left: 0 !important;
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }

  /* Backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 299;
  }
  .shell.mobile-sidebar-open .sidebar-backdrop { display: block; }

  /* Hamburger: visibile solo mobile */
  .topbar-hamburger { display: flex !important; }

  /* Topbar */
  .topbar { padding: 0 14px; height: 52px; }
  .topbar-breadcrumb { font-size: 14px; }

  /* Main content padding */
  .main-content { padding: 12px; }

  /* KPI: 2 colonne */
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 22px; }

  /* Dashboard: single column — full width cards */
  .dash-grid { gap: 10px; }
  .dash-col-left,
  .dash-col-right {
    flex: 1;
    width: 100%;
  }
  .dash-col-right {
    height: auto;
    max-height: none;
    overflow-y: visible;
  }
  .dash-card { width: 100%; }
  .dash-card-recent {
    height: calc(100vh - 240px);
    min-height: 200px;
  }
  .act-feed-scroll {
    flex: 1;
    overflow-y: auto;
  }

  /* Contacts toolbar */
  .contacts-toolbar-top { flex-wrap: wrap; gap: 8px; }
  .search-wrap { min-width: 0; flex: 1; }
  .toolbar-end { flex-wrap: wrap; gap: 6px; }
  .toolbar-end .btn { font-size: 12px; padding: 0 10px; }
  .contact-selects { display: none; }

  /* Table → cards */
  .table-card { border-radius: 8px; overflow: hidden; }
  .leads-table thead { display: none; }
  .leads-table, .leads-table tbody { display: block; width: 100%; }
  .lead-row {
    display: block;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px;
    position: relative;
  }
  .lead-row td { display: none; }
  .lead-row .td-co,
  .lead-row .td-qual,
  .lead-row .td-pipeline { display: block; }
  .lead-row .td-co   { margin-bottom: 6px; }
  .lead-row .td-qual { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
  .lead-row .td-pipeline { display: flex; gap: 8px; align-items: center; }
  .lead-row .td-acts {
    display: flex;
    position: absolute;
    top: 10px; right: 10px;
    opacity: 1;
    gap: 4px;
  }
  .leads-table td { padding: 0; border: none; }

  /* Lead detail */
  .detail-header { flex-direction: column; gap: 10px; padding: 14px; }
  .detail-stage-sel { width: 100%; }
  .detail-stage-sel select { width: 100% !important; }
  .detail-body { gap: 12px; }
  .detail-sidebar { order: 0; display: flex; flex-direction: column; }
  .detail-nav { flex-wrap: wrap; gap: 8px; }
  .detail-company { font-size: 18px; }

  /* Pipeline kanban */
  .pipeline-view { height: auto; }
  .kk-board { padding-bottom: 16px; }
  .kk-col { min-width: 180px; }

  /* Settings */
  .settings-view { gap: 10px; }

  /* Modal */
  .modal { max-width: calc(100vw - 24px) !important; margin: 12px; }
  .modal-guide { max-height: 90dvh; overflow-y: auto; }

  /* Form rows */
  .form-row-2 { grid-template-columns: 1fr; }

  /* Log form footer */
  .log-form-footer { flex-wrap: wrap; }
  .log-form-footer input[style*="width:150px"] { width: 100% !important; }
  .log-form-footer select[style*="width:130px"] { width: 100% !important; }
}

/* Hamburger e backdrop: nascosti su desktop */
.topbar-hamburger { display: none; }
.sidebar-backdrop { display: none; }

/* ── Form submissions ─────────────────────────────────────────────────────── */
.form-submissions-list {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.form-sub-details {
  background: #f8fafc;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
}

.form-sub-summary {
  background: #fbfdff;
  border-bottom: 1px solid #edf2f6;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-sub-summary::-webkit-details-marker { display: none; }

.form-sub-summary::before {
  content: '\25B6';
  display: inline-block;
  transition: transform .15s;
  font-size: 10px;
  color: #94a3b8;
}

.form-sub-details[open] .form-sub-summary::before {
  transform: rotate(90deg);
}

.form-sub-summary:hover {
  color: #008EEB;
}

.form-sub-body {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
}

.form-sub-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  font-size: 13px;
}

.form-sub-label {
  color: #64748b;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

.form-sub-row span:last-child {
  color: #1e293b;
  overflow-wrap: anywhere;
}

/* Strip the inner input so it doesn't double-render a box inside .topbar-search */
.topbar-search .search-input {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: auto;
  height: 32px;
  padding-top: 0;
  padding-bottom: 0;
  outline: none;
}

.topbar-search .search-input:focus {
  border-color: transparent;
  box-shadow: none;
}

/* ── Activity Kanban Board ──────────────────────────────────────────────── */
.act-kanban-board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: auto;
  padding: 8px 0 12px;
  min-height: 200px;
  height: calc(70vh - 200px);
  scrollbar-width: thin;
  scrollbar-color: #cdd5df #f8fafc;
}

.act-kanban-board::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.act-kanban-board::-webkit-scrollbar-track {
  background: transparent;
}
.act-kanban-board::-webkit-scrollbar-thumb {
  background: #cdd5df;
  border-radius: 3px;
}
.act-kanban-board::-webkit-scrollbar-thumb:hover {
  background: #9aa0ab;
}

.ac-col {
  flex: 1;
  background: #f8fafc;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ac-col-head {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px 8px 0 0;
  text-align: center;
}

.ac-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ac-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 10px;
  border-top: 3px solid #0090df;
  font-size: 12px;
}

.ac-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.ac-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.ac-type {
  font-weight: 600;
  color: #1e293b;
  font-size: 11px;
  text-decoration: underline;
}
/* Colorazione tipologia attività — tavolozza separata dagli stati */
.ac-type-note     { color: #c7956c; }
.ac-type-call     { color: #d4766a; }
.ac-type-email    { color: #3b84a7; }
.ac-type-whatsapp { color: #a89b63; }
.ac-type-meeting  { color: #9b6dd8; }
.ac-type-demo     { color: #5a9e8f; }
.ac-type-task     { color: #7e7068; }

.ac-date {
  font-size: 10px;
  color: #94a3b8;
}

.ac-subj {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 2px;
  color: #1e293b;
}

.ac-notes {
  font-size: 11px;
  color: #5a6170;
  margin-bottom: 6px;
}

.ac-lead {
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ac-lead-name {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}

.ac-lead-sub {
  font-size: 13px;
  font-weight: 600;
  color: #5a6170;
}

.ac-company-link {
  color: #0090df;
  text-decoration: none;
  cursor: pointer;
}

.ac-company-link:hover {
  text-decoration: underline;
}

.ac-company {
  color: #5a6170;
  white-space: nowrap;
}

.ac-card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ac-empty {
  text-align: center;
  color: #cbd5e1;
  font-size: 11px;
  padding: 16px 8px;
}

.ac-card-history {
  background: #f8fafc;
  border: 1px dashed #dde3ea;
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 10px;
}

.ac-history-head {
  font-weight: 700;
  margin-bottom: 4px;
  color: #5a6170;
  font-size: 10px;
}

.ac-history-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  color: #5a6170;
}

.ac-history-date {
  white-space: nowrap;
  color: #9aa0ab;
  font-size: 10px;
}

/* Kanban column scroll — slim scrollbar */
.ac-col-body::-webkit-scrollbar {
  width: 6px;
}
.ac-col-body::-webkit-scrollbar-track {
  background: transparent;
}
.ac-col-body::-webkit-scrollbar-thumb {
  background: #cdd5df;
  border-radius: 3px;
}
.ac-col-body::-webkit-scrollbar-thumb:hover {
  background: #9aa0ab;
}
.ac-col-body {
  scrollbar-width: thin;
  scrollbar-color: #cdd5df #f8fafc;
}

/* Kanban board — mobile responsive: scroll orizzontale + verticale */
@media (max-width: 768px) {
  .act-kanban-board {
    flex-wrap: nowrap;
    max-height: calc(100vh - 140px);
    overflow-x: auto;
    overflow-y: auto;
  }
  .ac-col {
    flex: 0 0 200px;
    min-width: 200px;
  }
}

/* ── Tasks page: full-page kanban board ───────────────────────────── */
.page.page-tasks {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  max-height: calc(100vh - 56px);
  overflow: hidden;
}

.page-tasks .act-kanban-board {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-x: auto;
  overflow-y: auto;
}

/* ── Lead Detail Tab Layout (Task 11) ── */

.lead-detail {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 96px);
  max-height: calc(100vh - 96px);
  overflow: hidden;
}

/* Compact header — sticky */
.lead-detail .detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  padding: 12px 16px;
  border-bottom: 1px solid #eaecf0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.lead-detail .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lead-detail .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tab navigation — sticky below header */
.lead-tabs {
  position: sticky;
  top: 72px;
  z-index: 9;
  background: #f7f8fa;
  padding: 0 16px;
  border-bottom: 1px solid #eaecf0;
  display: flex;
  gap: 0;
  justify-content: space-between;
  align-items: center;
}
.lead-tabs-left {
  display: flex;
  gap: 0;
}
.lead-tabs-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lead-tab-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}

.lead-tab-btn:hover {
  color: #0090df;
}

.lead-tab-btn.active {
  color: #0090df;
  border-bottom-color: #0090df;
  background: #fff;
}

/* Tab body — scrollable */
.lead-detail .detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Tab 2 — Activities layout: main area + timeline sidebar */
.act-layout {
  display: grid;
  grid-template-columns: 4fr 1fr;
  gap: 16px;
  align-items: start;
}

.act-layout-main {
  /* si adatta al contenuto — lo scroll è gestito dal contenitore padre */
}

.act-layout-timeline {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 4px;
}

.act-layout-timeline .timeline {
  max-height: inherit;
  overflow-y: auto;
}

/* Compact detail company/person in header */
.detail-company-compact {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.detail-person-compact {
  font-size: 13px;
  color: #6b7280;
  margin: 0;
}

.detail-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Tab 1 — Info sections in 3-column layout */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}

/* Responsive: single column on mobile (from 3-col grid) */
@media (max-width: 900px) {
  .act-layout {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .act-layout-timeline {
    max-height: none;
  }

  .lead-tab-btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  .lead-detail .detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .lead-tabs {
    top: 60px;
  }
}
