*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222535;
  --border: #2a2d3e;
  --accent: #6366f1;
  --accent-hover: #5254cc;
  --accent-light: rgba(99,102,241,.15);
  --text: #e2e8f0;
  --muted: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --sidebar-w: 230px;
}
[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --accent: #6366f1;
  --accent-hover: #5254cc;
  --accent-light: rgba(99,102,241,.10);
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
}
[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: #ffffff;
  color: #1e293b;
  border-color: #cbd5e1;
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder { color: #94a3b8; }
[data-theme="light"] .modal { background: #ffffff; }
[data-theme="light"] .modal-header { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="light"] code { background: #f1f5f9; color: #6366f1; }

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}
.sidebar-logo { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-logo h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
.sidebar-logo p { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted);
  transition: all .15s; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 18px; text-align: center; display: flex; align-items: center; justify-content: center; }
.nav-item .icon i[class*="ph-"] { font-size: 16px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--accent); color: white; font-size: 10px; padding: 1px 6px; border-radius: 10px; }

.sidebar-user { padding: 12px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.user-info:hover { background: var(--surface2); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 60px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 24px; gap: 16px; flex-shrink: 0; background: var(--surface);
}
.topbar-title { font-size: 18px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

/* ── NOTIFICATION BELL ── */
.notif-bell {
  position: relative; cursor: pointer; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--muted); transition: background .15s, color .15s;
  flex-shrink: 0;
}
.notif-bell:hover { background: var(--surface2); color: var(--text); }
.notif-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px;
  background: #ef4444; color: #fff; font-size: 9px; font-weight: 700;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
}
.notif-panel {
  position: fixed; top: 60px; right: 16px; width: 340px; max-height: 480px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3); z-index: 300; overflow: hidden;
  display: flex; flex-direction: column;
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: default;
  transition: background .1s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: rgba(99,102,241,.06); }
.notif-item-icon { font-size: 20px; flex-shrink: 0; line-height: 1.2; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 12px; font-weight: 600; line-height: 1.4; }
.notif-item-text { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.notif-item-text.expanded { white-space: normal; overflow: visible; text-overflow: clip; word-break: break-word; }
.notif-item-time { font-size: 10px; color: var(--muted); margin-top: 3px; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; }
#view-assistant.active { display: flex; margin: -24px; height: calc(100% + 48px); }

/* ── STAT CARDS (legacy) ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-icon { font-size: 20px; margin-bottom: 8px; }

/* ── KPI CARDS ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; align-items: flex-start; gap: 12px; transition: border-color .15s; }
.kpi-card:hover { border-color: var(--accent); }
.kpi-icon { margin-top: 2px; flex-shrink: 0; }
.kpi-body { flex: 1; min-width: 0; }
.kpi-label-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.kpi-label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-trend-wrap { flex-shrink: 0; }
.kpi-trend { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
.trend-up   { color: #22c55e; background: rgba(34,197,94,.12); }
.trend-down { color: #ef4444; background: rgba(239,68,68,.12); }

/* ── GUIDA ── */
.guide-section { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.guide-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; user-select: none; transition: background .12s; }
.guide-header:hover { background: var(--surface2); }
.guide-chevron { color: var(--muted); font-size: 12px; transition: transform .2s; }
.guide-body { padding: 8px 20px 20px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.guide-body a { color: var(--accent); }
.guide-body h4 { font-size: 13px; font-weight: 700; color: var(--accent); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.guide-body h4:first-child { margin-top: 12px; }
.guide-body p { font-size: 13px; line-height: 1.7; color: var(--text); margin-bottom: 8px; }
.guide-table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 12px; }
.guide-table th { background: var(--surface2); padding: 8px 12px; text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing:.04em; }
.guide-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; line-height: 1.5; }
.guide-table tr:last-child td { border-bottom: none; }
.guide-table td:first-child { font-weight: 600; white-space: nowrap; }
.guide-tip { background: rgba(34,197,94,.08); border-left: 3px solid #22c55e; padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 12px 0; font-size: 12px; color: var(--text); line-height: 1.6; }
.guide-warn { background: rgba(245,158,11,.08); border-left: 3px solid #f59e0b; padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 12px 0; font-size: 12px; color: var(--text); line-height: 1.6; }
.guide-info { background: rgba(99,102,241,.08); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 0 6px 6px 0; margin: 12px 0; font-size: 12px; color: var(--text); line-height: 1.6; }
.guide-steps { padding-left: 20px; display: flex; flex-direction: column; gap: 7px; margin: 10px 0 14px; }
.guide-steps li { font-size: 13px; line-height: 1.6; color: var(--text); }
.guide-ul { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; margin: 8px 0 14px; }
.guide-ul li { font-size: 13px; line-height: 1.6; color: var(--text); }
.guide-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; margin-right: 4px; }
.guide-badge.nuovo { background: rgba(99,102,241,.2); color: #a5b4fc; }
.guide-badge.warm { background: rgba(245,158,11,.2); color: #fcd34d; }
.guide-badge.hot { background: rgba(239,68,68,.2); color: #fca5a5; }
.guide-badge.freddo { background: rgba(100,116,139,.2); color: #94a3b8; }
.guide-badge.cliente { background: rgba(34,197,94,.2); color: #86efac; }
.guide-badge.perso { background: rgba(239,68,68,.15); color: #f87171; }
.guide-badge.optout { background: rgba(239,68,68,.1); color: #ef4444; }

/* ── INFO TOOLTIP ── */
.info-tip { position: relative; display: inline-flex; align-items: center; color: var(--muted); cursor: default; opacity: .6; transition: opacity .15s; }
.info-tip:hover { opacity: 1; }
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e2030;
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.45;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  max-width: 220px;
  width: max-content;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 200;
}
.info-tip:hover::after { opacity: 1; }

/* ── DASHBOARD CHARTS ── */
.dash-charts-row { display: grid; grid-template-columns: 1fr 340px; gap: 16px; margin-bottom: 16px; }
.dash-chart-calls { flex: 1; }
.dash-chart-wrap { padding: 8px 20px 4px; }
#callsChart text { font-family: inherit; }
.dash-funnel { padding: 12px 20px 16px; }
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.funnel-label { font-size: 12px; color: var(--text-secondary); width: 72px; flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 4px; transition: width .4s ease; }
.funnel-n { font-size: 12px; color: var(--muted); width: 28px; text-align: right; }

/* ── DASHBOARD BOTTOM ROW ── */
.dash-bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.link-sm { font-size: 12px; color: var(--accent); text-decoration: none; }
.link-sm:hover { text-decoration: underline; }

/* ── DASHBOARD TABS ── */
.dash-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 18px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 6px; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.dash-tab:hover { color: var(--fg); }
.dash-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── PIPELINE TEMPLATE CARDS ── */
.tpl-card { border: 1.5px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.tpl-card:hover { border-color: var(--accent); background: rgba(99,102,241,.04); }
.tpl-card-selected { border-color: var(--accent) !important; background: rgba(99,102,241,.08) !important; }

/* ── TABLES ── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-header h3 { font-size: 15px; font-weight: 600; flex: 1; }
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface2); }
td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-whatsapp { background: #25d366; color: white; }
.btn-whatsapp:hover { background: #1da851; }
.badge-paused { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-pending { background: rgba(100,116,139,.2); color: #94a3b8; }
.badge-in_progress { background: rgba(99,102,241,.2); color: #818cf8; }
.badge-opted_out { background: rgba(100,116,139,.15); color: #64748b; }

/* ── BADGES / STATUS ── */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-new { background: rgba(100,116,139,.2); color: #94a3b8; }
.badge-contacted { background: rgba(59,130,246,.2); color: #60a5fa; }
.badge-warm { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-hot { background: rgba(239,68,68,.2); color: #f87171; }
.badge-customer { background: rgba(34,197,94,.2); color: #4ade80; }
.badge-cold { background: rgba(59,130,246,.22) !important; color: #3b82f6 !important; }
.badge-lost { background: rgba(100,116,139,.15); color: #64748b; }
.badge-inbound { background: rgba(99,102,241,.2); color: #818cf8; }
.badge-outbound { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-active { background: rgba(34,197,94,.2); color: #4ade80; }
.badge-draft { background: rgba(100,116,139,.2); color: #94a3b8; }
.badge-completed { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-failed { background: rgba(239,68,68,.2); color: #f87171; }
.badge-busy { background: rgba(245,158,11,.2); color: #fbbf24; }
.badge-no-answer { background: rgba(168,85,247,.2); color: #c084fc; }
.badge-voicemail { background: rgba(99,102,241,.2); color: #818cf8; }
.badge-no_answer { background: rgba(168,85,247,.2); color: #c084fc; }

/* ── SEARCH & FILTERS ── */
.search-input { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 14px; outline: none; width: 240px; }
.search-input:focus { border-color: var(--accent); }
.filter-select { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 14px; outline: none; cursor: pointer; width: auto; max-width: 200px; flex-shrink: 0; }

/* ── PAGINATION ── */
.btn:disabled, .btn[disabled] { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* ══════════════════════════════════════════════════
   CONTACTS — Professional CRM UI
═══════════════════════════════════════════════════ */

/* ── View toggle (Lista | Board) ── */
.view-toggle-group {
  display: flex; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden; flex-shrink: 0;
}
.view-toggle-btn {
  background: none; border: none; padding: 6px 11px;
  color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
  transition: all .12s;
}
.view-toggle-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,.04); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }

/* ── Toolbar (search + filters + actions, one row) ── */
.contacts-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap; /* su schermi medi i bottoni (Importa/Nuovo) venivano tagliati a destra */
}
.contacts-search-wrap {
  position: relative; flex: 1; max-width: 340px; min-width: 140px;
}
.contacts-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; font-size: 12px; line-height: 1;
}
.contacts-search {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px 7px 30px; color: var(--text);
  font-size: 13px; outline: none; transition: border-color .15s;
}
.contacts-search::placeholder { color: var(--muted); }
.contacts-search:focus { border-color: var(--accent); }
.contacts-search:-webkit-autofill,
.contacts-search:-webkit-autofill:hover,
.contacts-search:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px #222535 inset !important;
  -webkit-text-fill-color: #e2e8f0 !important;
}

/* Inline filter selects */
.contacts-filter-group {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: nowrap;
}
.contacts-filter-pill {
  display: block; width: auto; flex-shrink: 0; max-width: 160px; min-width: 100px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 26px 7px 10px; color: var(--text);
  font-size: 13px; outline: none; cursor: pointer; white-space: nowrap;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='5'%3E%3Cpath d='M0 0l4.5 5L9 0z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color .15s;
}
.contacts-filter-pill:hover,
.contacts-filter-pill:focus { border-color: var(--accent); }
.contacts-filter-pill.active {
  border-color: var(--accent); background-color: rgba(99,102,241,.1);
  color: #a5b4fc;
}
.contacts-reset-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 7px 10px; color: var(--muted); font-size: 12px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; transition: all .15s;
}
.contacts-reset-btn:hover { border-color: #ef4444; color: #f87171; background: rgba(239,68,68,.07); }

/* ── Meta row (count + sort) ── */
.contacts-meta {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; min-height: 26px;
}
.contacts-count { font-size: 12px; color: var(--muted); }
.contacts-sort-select {
  background: transparent; border: none; color: var(--accent);
  font-size: 12px; font-weight: 600; outline: none; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  padding-right: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236366f1'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1px center;
}

/* ── Bulk bar ── */
.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(99,102,241,.07); border: 1px solid rgba(99,102,241,.25);
  border-radius: 8px; padding: 8px 14px; margin-bottom: 8px;
}
.bulk-label { font-size: 13px; font-weight: 600; color: #a5b4fc; white-space: nowrap; }
.bulk-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Table wrapper ── */
.contacts-table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px;
  max-height: calc(100vh - 250px); overflow-y: auto; overflow-x: auto;
}
/* scrollbar */
.contacts-table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.contacts-table-wrap::-webkit-scrollbar-track { background: transparent; }
.contacts-table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.contacts-table-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.contacts-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: fixed; }

/* Column resize handle */
.contacts-table thead th { position: relative; }
.col-resize-handle {
  position: absolute; right: 0; top: 0; bottom: 0; width: 5px;
  cursor: col-resize; user-select: none; z-index: 1;
}
.col-resize-handle:hover, .col-resize-handle.dragging { background: var(--accent); opacity: .5; }

.contacts-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface2); border-bottom: 1px solid var(--border);
  padding: 9px 14px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 700;
  white-space: nowrap; text-align: left;
}
.contacts-table td {
  padding: 0 14px; height: 50px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle; overflow: hidden;
}
.contacts-table tbody tr:last-child td { border-bottom: none; }
.contacts-table tbody tr { transition: background .08s; cursor: pointer; }
.contacts-table tbody tr:hover { background: rgba(255,255,255,.025); }
.contacts-table tbody tr:hover .row-actions { opacity: 1; }

/* Generic reusable table */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  background: var(--surface2); border-bottom: 1px solid var(--border);
  padding: 9px 14px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 700;
  white-space: nowrap; text-align: left;
}
.data-table td {
  padding: 0 14px; height: 48px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .08s; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }

/* Column widths */
/* Nome più largo (prima troncato anche con spazio libero), colonne secondarie più strette;
   azioni 96px: con 3 bottoni (modifica/rimuovi da lista/elimina) 68px le tagliava */
.col-check   { width: 40px; }
.col-name    { width: 30%; }
.col-company { width: 13%; }
.col-phone   { width: 130px; }
.col-status  { width: 108px; }
.col-source  { width: 8%; }
.col-lists   { width: auto; }
.col-tags    { width: 120px; }
.col-actions { width: 96px; }

/* Sort headers */
.sort-th { cursor: pointer; }
.sort-th:hover { color: var(--text); }
.sort-arrow { font-size: 9px; opacity: .25; margin-left: 3px; }
.sort-th.sort-active { color: var(--accent); }
.sort-th.sort-active .sort-arrow { opacity: 1; }

/* ── Avatar ── */
.contact-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: .02em;
}

/* ── Name cell ── */
.contact-name-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.contact-name-info { display: flex; flex-direction: column; min-width: 0; }
.contact-name-main {
  font-weight: 600; font-size: 13px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contact-name-sub {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Helpers ── */
.cell-muted { color: var(--muted); font-size: 12px; }
.cell-link { color: var(--text); text-decoration: none; }
.cell-link:hover { color: var(--accent); }

/* ── Inline status select ── */
.status-select {
  border: none; border-radius: 5px; cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  outline: none; appearance: none; -webkit-appearance: none;
  transition: filter .12s; letter-spacing: .01em;
  width: auto; /* la regola globale select{width:100%} lo allargava a tutta la riga */
}
.status-select:hover { filter: brightness(1.2); }
.status-select.status-new       { background: rgba(99,102,241,.18);  color: #a5b4fc; }
.status-select.status-contacted { background: rgba(59,130,246,.18);  color: #93c5fd; }
.status-select.status-warm      { background: rgba(245,158,11,.18);  color: #fcd34d; }
.status-select.status-hot       { background: rgba(239,68,68,.18);   color: #fca5a5; }
.status-select.status-customer  { background: rgba(34,197,94,.18);   color: #86efac; }
.status-select.status-cold      { background: rgba(59,130,246,.18);  color: #93c5fd; }
.status-select.status-lost      { background: rgba(100,116,139,.18); color: #94a3b8; }

/* ── List pills ── */
.list-pill {
  display: inline-block;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
  margin-right: 3px; white-space: nowrap; letter-spacing: .02em;
  border: 1px solid transparent;
}

/* ── RAG Test Panel ── */
.rag-test-panel {
  margin-top: 28px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.rag-test-header {
  padding: 16px 20px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.rag-test-input-row {
  display: flex; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border);
  align-items: center;
}
.rag-test-input {
  flex: 1; background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; outline: none;
}
.rag-test-input:focus { border-color: var(--accent); }
.rag-test-loading { padding: 24px 20px; color: var(--muted); font-size: 13px; }
.rag-test-empty   { padding: 24px 20px; color: var(--muted); font-size: 13px; }

.rag-result-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 20px;
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s;
}
.rag-result-row:last-child { border-bottom: none; }
.rag-result-row:hover { background: var(--surface2); }
.rag-result-rank  { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.rag-result-main  { flex: 1; min-width: 0; }
.rag-result-name  { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.rag-result-meta  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rag-result-chunk { font-size: 11px; color: var(--muted); font-style: italic; }
.rag-result-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; width: 90px; }
.rag-score-bar-wrap { width: 80px; height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.rag-score-bar    { height: 100%; border-radius: 3px; transition: width .4s ease; }
.rag-score-label  { font-size: 12px; font-weight: 700; }

/* ── Sub-tabs ── */
.sub-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.sub-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 13px; font-weight: 500; padding: 8px 16px;
  cursor: pointer; transition: all .15s; margin-bottom: -1px;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ── Product cards (Overview) ── */
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column;
}
.product-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(99,102,241,.15); }
.product-card-img { width: 100%; height: 140px; overflow: hidden; background: var(--surface2); }
.product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.product-card-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.product-card-brand { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.product-card-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.product-card-price { font-weight: 700; font-size: 15px; color: var(--text); }

/* ── Products DB table ── */
.products-db-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.products-db-table th { padding: 8px 10px; text-align: left; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface2); white-space: nowrap; }
.products-db-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.products-db-table tbody tr:hover { background: var(--surface2); }
.products-db-table tbody tr:hover .row-actions { opacity: 1; }

/* ── Product tag pills ── */
.tag-pill {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 4px; margin: 1px 2px 1px 0; white-space: nowrap;
  background: rgba(99,102,241,.18); color: #a5b4fc; border: 1px solid rgba(99,102,241,.3);
}

/* ── Category pill ── */
.id-chip {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 5px;
  border-radius: 4px; background: rgba(99,102,241,.12); color: #818cf8;
  border: 1px solid rgba(99,102,241,.25); font-family: monospace; cursor: pointer;
  user-select: none; white-space: nowrap; vertical-align: middle;
}
.id-chip:hover { background: rgba(99,102,241,.25); border-color: rgba(99,102,241,.5); }

.category-pill {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 4px; background: rgba(245,158,11,.15); color: #fbbf24;
  border: 1px solid rgba(245,158,11,.3);
}

/* ── Active toggle button ── */
.active-toggle {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 20px; border: none; cursor: pointer; transition: all .15s;
}
.active-toggle-on  { background: rgba(34,197,94,.18); color: #4ade80; }
.active-toggle-on:hover  { background: rgba(34,197,94,.3); }
.active-toggle-off { background: rgba(100,116,139,.18); color: #94a3b8; }
.active-toggle-off:hover { background: rgba(100,116,139,.3); }

/* ── Clickable product row ── */
.product-row { cursor: pointer; }
.product-row:hover .row-actions { opacity: 1; }

/* ── Modal large ── */
.modal-lg { width: 720px; }

/* ── Product detail layout ── */
.detail-grid { display: flex; flex-direction: column; gap: 20px; }
.detail-section { background: var(--surface2); border-radius: 10px; padding: 16px; }
.detail-row { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 100px; text-transform: uppercase; letter-spacing: .04em; }

/* ── Import dropzone ── */
.import-dropzone {
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 32px 24px; text-align: center; cursor: pointer;
  transition: all .2s; color: var(--muted);
}
.import-dropzone:hover, .import-dropzone.drag-over {
  border-color: var(--accent); background: var(--accent-light); color: var(--text);
}
.import-map-select {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 5px 8px; font-size: 12px;
}
.import-map-select:focus { outline: none; border-color: var(--accent); }

/* ── Row actions (visible on hover) ── */
.row-actions { opacity: 0; transition: opacity .1s; display: flex; align-items: center; gap: 1px; }

/* ── Checkboxes ── */
.contacts-table input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }

/* ── Pagination ── */
.contacts-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 12px 20px;
}
.page-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 9px; color: var(--muted);
  font-size: 12px; cursor: pointer; transition: all .1s;
  min-width: 30px; text-align: center; line-height: 1.4;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,.07); }
.page-btn:disabled { opacity: .2; cursor: not-allowed; }
.page-btn.page-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.page-info { font-size: 12px; color: var(--muted); padding: 0 4px; }

/* ── PRODUCT PAGINATION ── */
.product-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; padding: 12px 20px; flex-wrap: wrap;
}
.product-pagination .btn { min-width: 30px; text-align: center; font-size: 12px; }
.product-pagination .btn:disabled { opacity: .25; cursor: not-allowed; }
.product-pagination .pg-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.product-pagination .pg-info { font-size: 12px; color: var(--muted); margin-right: 8px; white-space: nowrap; }

/* ── KANBAN ── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { min-width: 220px; width: 220px; flex-shrink: 0; }
.kanban-col-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px 8px 0 0; background: var(--surface); border: 1px solid var(--border); border-bottom: none; }
.kanban-col-header h4 { font-size: 13px; font-weight: 600; flex: 1; }
.kanban-col-header .count { font-size: 11px; color: var(--muted); }
.kanban-col-body { background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 8px 8px; min-height: 400px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; cursor: grab; transition: box-shadow .15s; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.kanban-card.dragging { opacity: .5; }
.kanban-card h5 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.kanban-card p { font-size: 12px; color: var(--muted); }
.kanban-col-body.drag-over { background: var(--accent-light); border-color: var(--accent); }

/* ── MODALS ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 1000; backdrop-filter: blur(4px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 560px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ── TOOL OPTIONS ── */
#builtinToolsList, .tools-list { display: flex; flex-direction: column; gap: 8px; }
.tool-option { display: block; }
.tool-option-label { display: flex; align-items: flex-start; gap: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; cursor: pointer; box-sizing: border-box; }
.tool-option-added .tool-option-label { border-color: var(--success); opacity: 0.65; cursor: default; }
.tool-option-label input[type="checkbox"] { width: 16px; height: 16px; min-width: 16px; flex-shrink: 0; margin-top: 2px; cursor: pointer; }
.tool-option-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; overflow: hidden; }
.tool-option-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-option-desc { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-option-path { font-size: 10px; color: var(--accent); }
.badge-success { font-size: 11px; color: var(--success); margin-left: 6px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; width: 100%; font-family: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
/* Checkbox/radio non devono ereditare il width:100%/padding/background della regola sopra —
   altrimenti si espandono a piena larghezza dentro un flex container, schiacciando a 0px il
   fratello con flex:1 (bug reale trovato: riga contatto invisibile, solo checkbox visibile) */
input[type="checkbox"], input[type="radio"] { width: auto; height: auto; background: none; border: none; padding: 0; border-radius: 0; }
textarea { resize: vertical; min-height: 80px; }

/* ── TOASTS ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-size: 14px; min-width: 240px; animation: slideIn .2s ease; display: flex; align-items: center; gap: 10px; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes livePulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.75); } }

/* ── LUCIDE ICON HELPERS ── */
.btn-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }
/* Phosphor Icons global */
i[class*="ph-"] { font-style: normal; line-height: 1; }

.view-toggle-btn i[class*="ph-"] { font-size: 15px; }
.contacts-search-icon i[class*="ph-"] { font-size: 13px; }
.contacts-reset-btn i[class*="ph-"] { font-size: 12px; }

/* ── AGENT CARD ── */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.agent-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; cursor: pointer; transition: border-color .15s; }
.agent-card:hover { border-color: var(--accent); }
.agent-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.agent-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-light); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.agent-card h4 { font-size: 15px; font-weight: 600; }
.agent-card p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.agent-card-footer { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── PIPELINE STEPS ── */
.pipeline-steps { display: flex; flex-direction: column; gap: 8px; }
.step-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.step-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.step-type { font-size: 13px; font-weight: 600; }
.step-desc { font-size: 12px; color: var(--muted); }
.step-connector { height: 16px; width: 2px; background: var(--border); margin-left: 22px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── MISC ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-header h2 { font-size: 20px; font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--muted); font-size: 13px; }
.tag { display: inline-flex; align-items: center; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 12px; color: var(--muted); gap: 4px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.ml-auto { margin-left: auto; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }

/* ── APPOINTMENTS CALENDAR ── */
.appt-cal-nav {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
.appt-cal-month {
  font-size: 16px; font-weight: 700; min-width: 180px; text-align: center;
}
.appt-cal-grid {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.appt-cal-header {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.appt-cal-header > div {
  text-align: center; padding: 10px 0; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.appt-cal-body {
  display: grid; grid-template-columns: repeat(7, 1fr);
}
.appt-cal-cell {
  min-height: 100px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px; cursor: pointer; transition: background .1s; vertical-align: top;
}
.appt-cal-cell:hover { background: rgba(99,102,241,.04); }
.appt-cal-cell:nth-child(7n) { border-right: none; }
.appt-cal-cell.appt-cal-empty { cursor: default; background: rgba(0,0,0,.03); }
.appt-cal-cell.appt-cal-today { background: rgba(99,102,241,.06); }
.appt-cal-day-num {
  font-size: 13px; font-weight: 600; color: var(--muted);
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; margin-bottom: 4px;
}
.appt-cal-day-num.today {
  background: var(--accent); color: #fff;
}
.appt-cal-events { display: flex; flex-direction: column; gap: 2px; }
.appt-cal-event {
  font-size: 10px; padding: 2px 5px; border-radius: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; transition: filter .1s;
}
.appt-cal-event:hover { filter: brightness(1.3); }

/* ── CONTACT AUTOCOMPLETE (appointment modal) ── */
.appt-ac-wrap {
  position: relative;
}
.appt-ac-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px;
  outline: none; font-family: inherit; transition: border-color .15s;
}
.appt-ac-input:focus { border-color: var(--accent); }
.appt-ac-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-height: 240px; overflow-y: auto;
}
.appt-ac-item {
  padding: 10px 14px; cursor: pointer; transition: background .1s; border-radius: 4px;
}
.appt-ac-item:hover, .appt-ac-item.appt-ac-active {
  background: rgba(99,102,241,.12);
}
.appt-ac-name { font-size: 13px; font-weight: 600; color: var(--text); }
.appt-ac-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.appt-ac-empty { padding: 12px 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ── HAMBURGER ── */
.hamburger-btn {
  display: none; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 6px; border-radius: 8px; flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--surface2); }
.hamburger-btn i[class*="ph-"] { font-size: 20px; }

/* ── SIDEBAR BACKDROP ── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 499; backdrop-filter: blur(2px);
}
.sidebar-backdrop.open { display: block; }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {
  body { overflow: auto; }

  /* Sidebar: hidden off-screen, slides in as drawer */
  .sidebar {
    position: fixed; left: -280px; top: 0; bottom: 0; z-index: 500;
    width: 260px; transition: left .25s ease; box-shadow: none;
  }
  .sidebar.open {
    left: 0; box-shadow: 6px 0 32px rgba(0,0,0,.6);
  }

  /* Main takes full width */
  .main { width: 100%; min-width: 0; }

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* Topbar tighter */
  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-title { font-size: 15px; }

  /* Content padding */
  .content { padding: 14px; }

  /* Stats: 2 columns on mobile */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .dash-charts-row { grid-template-columns: 1fr; }
  .dash-bottom-row { grid-template-columns: 1fr; }

  /* All plain tables: scroll horizontally */
  .table-card { overflow-x: auto; }
  .table-card table { min-width: 580px; }

  /* Contacts toolbar: wrap */
  .contacts-bar { flex-wrap: wrap; gap: 6px; }
  .contacts-search-wrap { max-width: 100%; width: 100%; flex: none; }
  .contacts-filter-group { flex-wrap: wrap; width: 100%; gap: 6px; }
  .contacts-filter-pill { flex: 1 1 130px; max-width: none; }
  .contacts-reset-btn { flex: 0 0 auto; }

  /* Contact table height */
  .contacts-table-wrap { max-height: calc(100vh - 340px); }

  /* Hide less-critical columns on mobile */
  .col-company, .col-source, .col-lists { display: none; }
  .contacts-table th.col-company,
  .contacts-table th.col-source,
  .contacts-table th.col-lists { display: none; }

  /* Form grid single column */
  .form-grid { grid-template-columns: 1fr; }

  /* Modal: bottom sheet style */
  .modal-overlay { align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-lg { width: 100%; }

  /* Section header stack */
  .section-header { flex-wrap: wrap; gap: 10px; }
  .section-header h2 { font-size: 16px; }

  /* Agent grid single column */
  .agent-grid { grid-template-columns: 1fr; }

  /* Table header wrap */
  .table-header { flex-wrap: wrap; gap: 8px; }
  .table-header h3 { width: 100%; }

  /* Search input full width */
  .search-input { width: 100%; }

  /* Topbar actions wrap on very small screens */
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn span { display: none; } /* hide button labels, show only icons */

  /* Sub-tabs scroll horizontally */
  .sub-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .sub-tab { flex-shrink: 0; }

  /* Bulk bar wrap */
  .bulk-bar { flex-wrap: wrap; }

  /* Calendar: min-height smaller on mobile */
  .appt-cal-cell { min-height: 60px; }
}

/* ── NODE CANVAS ─────────────────────────────────────────────────── */
.nc-wrapper { border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow: hidden; position: relative; cursor: grab; min-height: 480px; }
.nc-wrapper:active { cursor: grabbing; }
.nc-toolbar { display: flex; gap: 6px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.nc-toolbar-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-right: 4px; }
.nc-canvas { position: relative; overflow: visible; background: radial-gradient(var(--border) 1px, transparent 1px) 0 0 / 24px 24px; }
.nc-canvas svg.nc-edges { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.nc-zoom-ctrl { position: absolute; bottom: 10px; right: 10px; display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 11px; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.15); pointer-events: all; }
.nc-node { position: absolute; width: 192px; background: var(--surface); border: 2px solid var(--border); border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.18); user-select: none; z-index: 2; }
.nc-node::before { content:''; position:absolute; left:-6px; top:50%; transform:translateY(-50%); width:10px; height:10px; border-radius:50%; background:var(--surface); border:2px solid var(--border); z-index:3; }
.nc-node::after  { content:'▶'; position:absolute; right:-14px; top:50%; transform:translateY(-50%); font-size:9px; color:var(--muted); z-index:3; }
.nc-node-ro::before, .nc-node-ro::after { display: none; }
.nc-node-current { border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(99,102,241,.25), 0 2px 8px rgba(0,0,0,.18) !important; }
.nc-node:hover { border-color: var(--accent); }
.nc-node.nc-selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }
/* Config modal — default/unchanged value styling */
.nc-cfg-default { color: var(--muted) !important; }
/* Contact detail tabs */
.detail-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: 0 -16px 14px; padding: 0 16px; }
.detail-tab { padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-size: 13px; color: var(--muted); transition: color .15s; }
.detail-tab:hover { color: var(--text); }
.detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.detail-tab-content { display: none; }
.detail-tab-content.active { display: block; }
.nc-node-header { display: flex; align-items: center; gap: 6px; padding: 7px 8px; cursor: move; border-radius: 8px 8px 0 0; }
.nc-node-icon { font-size: 15px; flex-shrink: 0; }
.nc-node-label { flex: 1; font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc-node-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; border-radius: 3px; }
.nc-node-del:hover { color: #f87171; background: rgba(248,113,113,.1); }
.nc-node-body { padding: 6px 8px 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.nc-node-desc { margin-bottom: 6px; min-height: 14px; line-height: 1.4; }
.nc-node-actions { display: flex; gap: 4px; }
.nc-port-section { padding: 4px 8px 6px; border-top: 1px solid var(--border); }
.nc-port-row { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; }
.nc-port-label { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.nc-port-label.hot   { color: #f87171; }
.nc-port-label.warm  { color: #fb923c; }
.nc-port-label.cold  { color: #60a5fa; }
.nc-port-label.lost  { color: #9ca3af; }
.nc-port-label.no_answer { color: #a78bfa; }
.nc-port-label.always { color: var(--accent); }
.nc-connect-btn { font-size: 16px; line-height: 1; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 2px; border-radius: 3px; opacity: .7; }
.nc-connect-btn:hover { opacity: 1; background: rgba(99,102,241,.15); }
.nc-port-dot { font-size: 15px; line-height: 1; background: none; border: none; color: var(--accent); cursor: crosshair; padding: 0 2px; border-radius: 3px; opacity: .7; user-select: none; }
.nc-port-dot:hover { opacity: 1; background: rgba(99,102,241,.15); transform: scale(1.2); }
.nc-node-drop { outline: 2.5px solid var(--accent) !important; box-shadow: 0 0 0 4px rgba(99,102,241,.25) !important; }
.nc-port-in  { top: -6px; left: 50%; transform: translateX(-50%); }
.nc-port-out { bottom: -6px; left: 50%; transform: translateX(-50%); }
.nc-edge-path { fill: none; stroke-width: 2; opacity: .8; }
.nc-edge-path.always   { stroke: #818cf8; }
.nc-edge-path.hot      { stroke: #f87171; }
.nc-edge-path.warm     { stroke: #fb923c; }
.nc-edge-path.cold     { stroke: #60a5fa; }
.nc-edge-path.lost     { stroke: #9ca3af; }
.nc-edge-path.no_answer { stroke: #a78bfa; }
.nc-edge-label { font-size: 9px; font-weight: 700; fill: var(--muted); }
.nc-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 240px; gap: 10px; color: var(--muted); }
.nc-node-call     .nc-node-header { background: rgba(99,102,241,.12); }
.nc-node-whatsapp .nc-node-header { background: rgba(34,197,94,.12); }
.nc-node-email    .nc-node-header { background: rgba(59,130,246,.12); }
.nc-node-wait     .nc-node-header { background: rgba(245,158,11,.12); }
.nc-node-ai-tag   .nc-node-header { background: rgba(168,85,247,.12); }
.nc-node-end      .nc-node-header { background: rgba(248,113,113,.1); }

/* ── ASSISTENTE AI — bottone flottante di accesso rapido ──────────── */
.assistant-fab {
  position: fixed; right: 20px; bottom: 20px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; z-index: 400;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  box-shadow: 0 4px 16px rgba(99,102,241,.45); transition: transform .15s ease;
}
.assistant-fab:hover { transform: scale(1.08); }
.assistant-fab.hidden { display: none; }
@media (max-width: 768px) {
  .assistant-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; font-size: 20px; }
}

/* ── ASSISTENTE AI — sidebar sessioni ─────────────────────────────── */
.assistant-sessions { width: 220px; min-width: 220px; }
.assistant-sessions-close, .assistant-sessions-toggle, .assistant-sessions-backdrop { display: none; }

@media (max-width: 768px) {
  /* Sidebar sessioni: drawer fuori schermo, sopra la sidebar principale */
  .assistant-sessions {
    position: fixed; top: 0; bottom: 0; left: -280px; width: 260px; min-width: 260px;
    z-index: 600; transition: left .25s ease; box-shadow: none;
  }
  .assistant-sessions.open { left: 0; box-shadow: 6px 0 32px rgba(0,0,0,.6); }
  .assistant-sessions-close { display: inline-flex; flex: 0 0 auto; }
  .assistant-sessions-toggle { display: inline-flex; flex-shrink: 0; }
  .assistant-sessions-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 590;
  }
  .assistant-sessions-backdrop.open { display: block; }

  /* Header: nascondi sottotitolo e testo bottone per lasciare spazio alla chat */
  .assistant-subtitle { display: none; }
  .assistant-analyze-label { display: none; }

  /* iOS fa zoom automatico se un input ha font-size < 16px al focus — il testo digitato
     resta 16px, ma il placeholder può essere più piccolo così non sembra sproporzionato */
  #assistantInput { font-size: 16px !important; }
  #assistantInput::placeholder { font-size: 13px; }
}

/* Contatti su mobile: card impilate invece della tabella desktop compressa con scroll
   orizzontale — nome/stato/telefono visibili senza scorrere */
@media (max-width: 640px) {
  .contacts-table { min-width: 0; table-layout: auto; display: block; }
  .contacts-table thead { display: none; }
  .contacts-table tbody { display: block; }
  .contacts-table tbody tr {
    display: grid; grid-template-columns: 22px minmax(0,1fr) auto;
    grid-template-areas: "check name status" "check phone actions" "check tags tags";
    gap: 6px 10px; padding: 12px; border-bottom: 1px solid var(--border); align-items: center;
  }
  .contacts-table tbody tr.contacts-empty-row { display: block; }
  .contacts-table td { display: block; padding: 0; border: none; min-width: 0; width: auto; overflow: visible; }  /* le .col-* hanno width fisse pensate per le th */
  .contacts-table td.col-check { grid-area: check; align-self: start; padding: 10px 0 0 0 !important; }
  .contacts-table td.col-name { grid-area: name; }
  .contacts-table td.col-status { grid-area: status; }
  .contacts-table td.col-phone { grid-area: phone; font-size: 13px; }
  .contacts-table td.col-actions { grid-area: actions; }
  .contacts-table td.col-tags { grid-area: tags; }
  .contacts-table td.col-tags:has(.cell-muted) { display: none; }
  .contacts-table td.col-company, .contacts-table td.col-source, .contacts-table td.col-lists { display: none; }
  .contacts-table .row-actions { opacity: 1; }
  .contacts-table-wrap { max-height: none; }
}

/* Very small screens */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 24px; }
  .content { padding: 10px; }
}

/* Settings Tabs */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.stab { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: 0; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.stab:hover { color: var(--text); }
.stab-active { color: var(--accent); border-bottom-color: var(--accent); }
.stab-panel { }
.stab-hidden { display: none; }

/* Interruttore on/off (impostazioni booleane) */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; inset: 0; cursor: pointer; background: var(--border); border-radius: 22px; transition: background .15s; }
.switch-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Filtri a scelta multipla (Contatti) — bottone-pill + pannello a checkbox */
.multi-filter { position: relative; display: inline-block; }
.multi-filter > button.contacts-filter-pill { text-align: left; overflow: hidden; text-overflow: ellipsis; }
.multi-filter > button.contacts-filter-pill.active { border-color: var(--accent); color: var(--text); }
.multi-filter-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 220px; max-width: 320px;
  max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: 6px;
}
.multi-filter-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.multi-filter-opt:hover { background: var(--surface2); }
.multi-filter-foot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; text-align: right; }
@media (max-width: 768px) { .multi-filter { flex: 1 1 130px; } .multi-filter > button.contacts-filter-pill { width: 100%; max-width: none; } }

/* ── Guida: indice + lettura ───────────────────────────────────────── */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.guide-layout { display:grid; grid-template-columns: 260px minmax(0,1fr); gap:28px; align-items:start; max-width:1100px; }
.guide-nav { position:sticky; top:12px; max-height:calc(100vh - 24px); overflow-y:auto; padding-right:4px; }
.guide-search { position:relative; margin-bottom:12px; }
.guide-search i { position:absolute; left:10px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.guide-search input { width:100%; padding:10px 12px 10px 32px; font-size:13px; border-radius:10px; }
.guide-nav-cat { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin:16px 0 6px 10px; }
.guide-nav-item { display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:9px 10px; border:0; border-radius:8px; background:transparent; color:var(--text); font-size:13px; cursor:pointer; line-height:1.3; }
.guide-nav-item i { font-size:16px; color:var(--muted); flex-shrink:0; }
.guide-nav-item:hover { background:var(--surface2); }
.guide-nav-item:focus-visible, .guide-card:focus-visible, .guide-home-list button:focus-visible, .guide-results button:focus-visible, .guide-pager .btn:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.guide-nav-item.active { background:rgba(99,102,241,.14); font-weight:600; }
.guide-nav-item.active i { color:var(--accent); }
.guide-nav-toggle { display:none; margin-bottom:12px; }
.guide-main { min-width:0; outline:none; }
.guide-hero { padding:22px 24px; border-radius:14px; background:rgba(99,102,241,.08); border:1px solid rgba(99,102,241,.2); margin-bottom:8px; }
.guide-hero h3 { font-size:20px; margin:0 0 6px; }
.guide-hero p { margin:0; font-size:14px; color:var(--muted); line-height:1.6; }
.guide-home-h { font-size:12px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin:24px 0 10px; }
.guide-cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:10px; }
.guide-card { display:flex; align-items:center; gap:12px; padding:14px 16px; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); font-size:13px; font-weight:600; text-align:left; cursor:pointer; line-height:1.35; }
.guide-card i { font-size:22px; color:var(--accent); flex-shrink:0; }
.guide-card:hover { border-color:var(--accent); background:var(--surface2); }
.guide-home-cat { margin-bottom:6px; }
.guide-home-cat .guide-nav-cat { margin-left:0; }
.guide-home-list, .guide-results { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.guide-home-list button, .guide-results button { display:flex; flex-direction:column; align-items:flex-start; gap:2px; width:100%; text-align:left; padding:11px 14px; border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); cursor:pointer; }
.guide-home-list button:hover, .guide-results button:hover { border-color:var(--accent); background:var(--surface2); }
.guide-home-list strong, .guide-results strong { font-size:14px; }
.guide-home-list small, .guide-results small { font-size:12px; color:var(--muted); }
.guide-results span { font-size:12px; color:var(--muted); line-height:1.5; }
.guide-crumb { font-size:12px; color:var(--muted); margin-bottom:8px; }
.guide-crumb button { background:none; border:0; padding:0; color:var(--accent); cursor:pointer; font-size:12px; }
.guide-title { font-size:24px; margin:0 0 6px; display:flex; align-items:center; gap:10px; line-height:1.25; }
.guide-lead { font-size:15px; color:var(--muted); margin:0 0 16px; line-height:1.6; }
.guide-toc { border:1px solid var(--border); border-radius:12px; background:var(--surface2); padding:14px 18px; margin-bottom:8px; font-size:13px; }
.guide-toc ul { margin:8px 0 0; padding-left:18px; columns:2; column-gap:28px; }
.guide-toc li { margin-bottom:5px; break-inside:avoid; }
.guide-toc a { color:var(--accent); text-decoration:none; }
.guide-toc a:hover { text-decoration:underline; }
.guide-article { border:0; background:transparent; padding:0; font-size:14px; }
.guide-article h4 { scroll-margin-top:16px; font-size:15px; text-transform:none; letter-spacing:0; color:var(--text); margin:28px 0 8px; padding-top:6px; border-top:1px solid var(--border); }
.guide-article h4:first-child { border-top:0; margin-top:8px; }
.guide-article p, .guide-article li { font-size:14px !important; line-height:1.7; }
.guide-pager { display:flex; justify-content:space-between; gap:10px; margin-top:32px; padding-top:16px; border-top:1px solid var(--border); flex-wrap:wrap; }
@media (max-width: 900px) {
  .guide-layout { grid-template-columns:1fr; gap:0; }
  .guide-nav-toggle { display:inline-flex; align-items:center; gap:8px; }
  .guide-nav { display:none; position:static; max-height:none; margin-bottom:16px; padding:12px; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
  .guide-nav.open { display:block; }
  .guide-toc ul { columns:1; }
  .guide-title { font-size:20px; }
  .guide-article .guide-table { display:block; overflow-x:auto; }
}

/* ── Licenza e utilizzo: barre di consumo, avvisi, area di caricamento (tema scuro di default, chiaro con [data-theme="light"]) ── */
:root {
  --lic-ok: #34d399; --lic-ok-2: #10b981;
  --lic-warn: #fbbf24; --lic-warn-2: #f59e0b;
  --lic-bad: #f87171; --lic-bad-2: #ef4444;
  --lic-track: rgba(255,255,255,.07); --lic-track-line: rgba(255,255,255,.06);
  --lic-banner-bg: rgba(245,158,11,.10); --lic-banner-line: rgba(245,158,11,.35); --lic-banner-text: #fcd34d;
  --lic-warn-text: #fbbf24; --lic-bad-text: #f87171;
}
[data-theme="light"] {
  --lic-ok: #22c55e; --lic-ok-2: #16a34a;
  --lic-warn: #fbbf24; --lic-warn-2: #d97706;
  --lic-bad: #f87171; --lic-bad-2: #dc2626;
  --lic-track: #e8ecf2; --lic-track-line: #dbe1ea;
  --lic-banner-bg: #fffbeb; --lic-banner-line: #f59e0b; --lic-banner-text: #92400e;
  --lic-warn-text: #b45309; --lic-bad-text: #dc2626;
}
.lic-banner { background: var(--lic-banner-bg); border: 1px solid var(--lic-banner-line); color: var(--lic-banner-text); padding: 9px 14px; font-size: 13px; border-radius: 10px; margin: 8px 16px; line-height: 1.5; }
.lic-banner a { color: inherit; font-weight: 700; text-decoration: underline; }
.lic-mode-warn { color: var(--lic-warn-text); }
.lic-mode-bad { color: var(--lic-bad-text); }
.lic-st { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.lic-st-warn { color: var(--lic-warn-text); }
.lic-st-bad { color: var(--lic-bad-text); }

.lic-bar { position: relative; height: 10px; margin-top: 8px; border-radius: 999px; background: var(--lic-track); box-shadow: inset 0 0 0 1px var(--lic-track-line); overflow: hidden; }
.lic-bar > span { display: block; height: 100%; min-width: 0; border-radius: 999px; transition: width .7s cubic-bezier(.2,.8,.2,1); position: relative; }
.lic-bar > span::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,0) 60%); }
.lic-bar.ok > span { background: linear-gradient(90deg, var(--lic-ok-2), var(--lic-ok)); }
.lic-bar.warn > span { background: linear-gradient(90deg, var(--lic-warn-2), var(--lic-warn)); }
.lic-bar.bad > span { background: linear-gradient(90deg, var(--lic-bad-2), var(--lic-bad)); }
.lic-bar.bad > span { background-image: linear-gradient(90deg, var(--lic-bad-2), var(--lic-bad)), repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); background-blend-mode: overlay; }
.lic-pct { font-weight: 400; color: var(--text-muted, #94a3b8); }
.lic-drop { margin-top: 14px; border: 2px dashed var(--border); border-radius: 12px; padding: 22px 16px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.lic-drop:hover, .lic-drop:focus-visible { background: rgba(99,102,241,.07); border-color: var(--accent, #6366f1); outline: none; }
@media (prefers-reduced-motion: reduce) { .lic-bar > span, .lic-drop { transition: none; } }

/* Sottoschede (es. dentro Integrazioni) */
.integ-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.integ-tab { background: var(--surface2); color: var(--text-muted, #94a3b8); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.integ-tab:hover { color: var(--text); }
.integ-tab-active { background: rgba(99,102,241,.16); color: var(--accent, #818cf8); border-color: rgba(99,102,241,.5); }
.integ-tab:focus-visible { outline: 2px solid var(--accent, #6366f1); outline-offset: 2px; }
