/* ============================================================
   LeadBoard — App stylesheet
   ============================================================ */

/* ============================================
   LIGHT THEME (default)
   ============================================ */
:root,
[data-theme="light"] {
  --bg-app:          #f0f4f8;
  --bg-navbar:       #ffffff;
  --bg-sidebar:      #ffffff;
  --bg-card:         #ffffff;
  --bg-card-hover:   #f8fafc;
  --bg-column:       #e2e8f0;
  --bg-input:        #f8fafc;
  --border:          #cbd5e1;
  --border-focus:    #2563eb;
  --text-primary:    #0f172a;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;
  --text-white:      #ffffff;
  --navbar-text:     #0f172a;
  --navbar-border:   #e2e8f0;
  --logo-color:      #0f172a;
  --nav-link-color:  #64748b;
  --nav-link-active: #2563eb;
  --card-shadow:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08);
  --shadow:          0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:       0 8px 30px rgba(0,0,0,0.12);
  --accent:          #2563eb;
  --accent-hover:    #1d4ed8;
  --accent-light:    #eff6ff;
  --success:         #10b981;
  --success-light:   #d1fae5;
  --warning:         #f59e0b;
  --warning-light:   #fef3c7;
  --danger:          #ef4444;
  --danger-light:    #fee2e2;
  --purple:          #8b5cf6;
  --purple-light:    #ede9fe;
  --radius-sm:       6px;
  --radius:          10px;
  --radius-lg:       16px;
  --transition:      0.18s ease;
  --font:            'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-width:   240px;
  --navbar-height:   56px;
}

/* ============================================
   DARK THEME
   ============================================ */
[data-theme="dark"] {
  --bg-app:          #0f172a;
  --bg-navbar:       #1e293b;
  --bg-sidebar:      #1e293b;
  --bg-card:         #1e293b;
  --bg-card-hover:   #263548;
  --bg-column:       #162032;
  --bg-input:        #162032;
  --border:          #2d3f55;
  --border-focus:    #3b82f6;
  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;
  --text-white:      #ffffff;
  --navbar-text:     #f1f5f9;
  --navbar-border:   #2d3f55;
  --logo-color:      #ffffff;
  --nav-link-color:  #94a3b8;
  --nav-link-active: #60a5fa;
  --card-shadow:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.3);
  --shadow:          0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:       0 8px 30px rgba(0,0,0,0.4);
  --accent:          #3b82f6;
  --accent-hover:    #2563eb;
  --accent-light:    #1e3a5f;
  --success:         #10b981;
  --success-light:   #064e3b;
  --warning:         #f59e0b;
  --warning-light:   #451a03;
  --danger:          #ef4444;
  --danger-light:    #450a0a;
  --purple:          #a78bfa;
  --purple-light:    #2e1065;
}

/* ============================================
   TYPOGRAPHY SCALE
   ============================================ */

/* Base */
*, *::before, *::after {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  letter-spacing: 0;
}

/* Display — page titles */
.type-display {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  color: var(--text-primary);
}

/* Heading 1 — section titles */
.type-h1, h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  line-height: 1.3;
  color: var(--text-primary);
}

/* Heading 2 — card titles */
.type-h2, h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.4;
  color: var(--text-primary);
}

/* Heading 3 — subtitles */
.type-h3, h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  line-height: 1.4;
  color: var(--text-primary);
}

/* Body — base text */
.type-body {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Body medium — company names, important values */
.type-body-medium {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Secondary — metadata, supporting text */
.type-secondary {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Caption — timestamps, hints */
.type-caption {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Label — form labels, KPI labels, column headers */
.type-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  line-height: 1;
}

/* KPI number — dashboard big numbers */
.type-kpi {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--text-primary);
}

/* Mono — tokens, IDs, code */
.type-mono {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* ============================================
   APPLY SCALE TO COMPONENTS
   ============================================ */

/* Navbar */
.nav-logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

#user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

#nav-project-name {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
}

/* Kanban column header */
.column-header .column-title,
.kanban-column__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.column-count,
.kanban-badge {
  font-size: 11px;
  font-weight: 600;
}

/* Lead cards */
.lead-card .card-company,
.lead-card__company {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  line-height: 1.3;
}

.lead-card .card-contact,
.lead-card__contact {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

.lead-card .card-date,
.lead-card__date {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.source-badge {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Drawer */
.drawer-title h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.drawer-tabs .tab {
  font-size: 13px;
  font-weight: 500;
}

.field-row label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.field-display {
  font-size: 14px;
  font-weight: 400;
}

.activity-text {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Dashboard */
.dash-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin: 8px 0 4px;
}

.kpi-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
}

/* Settings */
.settings-nav-item {
  font-size: 13px;
  font-weight: 500;
}

.settings-card h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-desc {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-secondary);
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

/* Table view */
.leads-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.leads-table td {
  font-size: 13px;
  font-weight: 400;
}

/* Buttons */
.btn-primary, .btn-secondary {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.btn-sm {
  font-size: 12px;
  font-weight: 500;
}

/* Modals */
.modal-box h3,
.modal-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Badges and pills */
.role-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Inputs */
input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
}

input::placeholder,
textarea::placeholder {
  font-weight: 400;
  color: var(--text-muted);
}

/* Webhook/code */
.webhook-url-box code,
.token-box code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.code-block {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

/* Toast notifications */
.toast {
  font-size: 13px;
  font-weight: 500;
}

/* Empty states */
.empty-state p,
.empty-state {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Filter bar */
.filter-input,
.filter-select {
  font-size: 13px;
  font-weight: 400;
}

/* Import wizard */
.import-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.step-indicator {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 3px;
}

.val-number {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
}

.val-label {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

/* -------- Reset & base -------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* -------- Navbar -------- */
#navbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--navbar-height);
  background: var(--bg-navbar);
  color: var(--navbar-text);
  border-bottom: 1px solid var(--navbar-border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  min-width: 140px;
}
.nav-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--logo-color);
  letter-spacing: -0.3px;
  line-height: 1;
}
.nav-logo-accent {
  color: #2563eb;
}
[data-theme="dark"] .nav-logo-accent {
  color: #60a5fa;
}
.nav-project-name {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 10px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}
.nav-project-name:empty { display: none; }

/* Desktop-only utility: visible on desktop, hidden via media query below */
.desktop-only {
  display: flex;
}

#project-selector {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  outline: none;
  cursor: pointer;
  width: 180px;
  flex-shrink: 0;
  transition: border-color var(--transition);
}
#project-selector:hover,
#project-selector:focus {
  border-color: var(--border-focus);
}
#project-selector option { background: var(--bg-card); color: var(--text-primary); }
[data-theme="dark"] #project-selector {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: var(--text-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--nav-link-color);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  position: relative;
  transition: color var(--transition), background var(--transition);
}
.nav-link:hover { color: var(--nav-link-active); background: var(--bg-column); }
.nav-link.active { color: var(--nav-link-active); }
.nav-link.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -2px;
  height: 2px;
  background: var(--nav-link-active);
  border-radius: 2px;
}
[data-theme="dark"] .nav-link:hover { background: rgba(255,255,255,0.06); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
#user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------- App main -------- */
#app-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-app);
  position: relative;
}
.view {
  height: 100%;
  width: 100%;
  overflow: hidden;
}
.view.hidden { display: none !important; }

/* -------- Buttons -------- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}
.btn-primary { background: var(--accent); color: var(--text-white); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); }
.btn-danger { background: var(--danger); color: var(--text-white); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-icon {
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  color: var(--navbar-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg-column); }
[data-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,0.08); }

/* -------- Theme toggle button -------- */
.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle-btn:hover { background: var(--bg-column); }
[data-theme="dark"] .theme-toggle-btn:hover { background: rgba(255,255,255,0.08); }

/* -------- Form elements -------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* -------- Kanban board -------- */
.kanban-board {
  display: flex;
  gap: 16px;
  padding: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
  background: var(--bg-app);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.kanban-board::-webkit-scrollbar { height: 10px; width: 10px; }
.kanban-board::-webkit-scrollbar-track { background: transparent; }
.kanban-board::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.kanban-column {
  width: 280px;
  min-width: 280px;
  flex-shrink: 0;
  background: var(--bg-column);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  transition: background var(--transition);
}
.kanban-column.is-drop-target { background: var(--accent-light); outline: 2px dashed var(--accent); outline-offset: -4px; }

.kanban-column__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 8px;
}
.kanban-column__title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-column__badges { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.kanban-badge {
  display: inline-block;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  line-height: 1.4;
}
.kanban-badge--value {
  background: var(--success-light);
  color: var(--success);
}

.kanban-cards {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.kanban-cards::-webkit-scrollbar { width: 6px; }
.kanban-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* -------- Lead card -------- */
.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  user-select: none;
}
.lead-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); background: var(--bg-card-hover); }
.lead-card.is-dragging { opacity: 0.5; border: 2px dashed var(--accent); }

.lead-card[data-status-key="in-attesa"]      { border-left-color: var(--warning); }
.lead-card[data-status-key="preventivo"]     { border-left-color: var(--accent);  }
.lead-card[data-status-key="lavorazione"]    { border-left-color: var(--purple);  }
.lead-card[data-status-key="confermato"]     { border-left-color: var(--success); }
.lead-card[data-status-key="lead-ko"]        { border-left-color: var(--danger);  }

.lead-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lead-card__date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.lead-card__company {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-card__contact {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

/* Source badges (pills) */
.source-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  line-height: 1.6;
  text-transform: capitalize;
}
.source-badge--organico { background: var(--success-light); color: var(--success); }
.source-badge--adv      { background: var(--purple-light);  color: var(--purple);  }
.source-badge--webhook  { background: var(--accent-light);  color: var(--accent);  }
.source-badge--csv      { background: var(--bg-column);      color: var(--text-secondary); }
.source-badge--manuale  { background: var(--warning-light); color: var(--warning); }

/* Sector pill (light bg) */
.sector-pill {
  display: inline-block;
  font-size: 11px;
  background: var(--bg-column);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 20px;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Follow-up indicator */
.followup {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
}
.followup__dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0;
}
.followup--overdue { color: var(--danger); }
.followup--overdue .followup__dot { background: var(--danger); }
.followup--today   { color: var(--warning); }
.followup--today .followup__dot   { background: var(--warning); }
.followup--future  { color: var(--success); }
.followup--future .followup__dot  { background: var(--success); }

/* -------- Empty / loading states -------- */
.kanban-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  margin: 4px;
  gap: 6px;
}
.kanban-empty__icon { font-size: 24px; opacity: 0.7; }

.skeleton {
  background: linear-gradient(90deg, var(--border) 0%, var(--bg-column) 50%, var(--border) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: skeleton-shimmer 1.4s infinite linear;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.lead-card--skeleton {
  height: 92px;
  border: 1px solid var(--border);
  cursor: default;
}
.lead-card--skeleton:hover { transform: none; box-shadow: var(--shadow-sm); }

/* -------- Floating Add Lead button -------- */
.fab-add-lead {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-white);
  font-size: 26px;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  transition: transform var(--transition), background var(--transition);
}
.fab-add-lead:hover { transform: scale(1.08); background: var(--accent-hover); }
.fab-add-lead:active { transform: scale(1.02); }

/* -------- Modal -------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.15s ease;
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  min-width: 420px;
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  animation: modal-pop 0.18s ease;
}
.modal-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  color: var(--text-secondary);
}
.modal-close:hover { background: var(--bg-card-hover); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.modal-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: none;
}
.modal-error.is-visible { display: block; }

/* -------- Drawer (lead detail) -------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.30);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
  z-index: 89;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 580px;
  max-width: 100vw;
  background: var(--bg-card);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
  z-index: 90;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.drawer.open { transform: translateX(0); }

@media (max-width: 1280px) {
  .drawer { width: 520px; }
}

.drawer-header {
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-header > .drawer-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drawer-title h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  margin-top: 6px;
  word-break: break-word;
}
.drawer-title .source-badge { align-self: flex-start; }

.drawer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.drawer-actions .btn-icon {
  color: var(--text-secondary);
}
.drawer-actions .btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.drawer-actions .btn-delete:hover { color: var(--danger); }

#lp-status-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.drawer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}
.tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
  min-height: 0;
}
.tab-content.hidden { display: none !important; }

/* Fields grid */
.fields-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.field-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  min-height: 42px;
}

.field-row:last-child {
  border-bottom: none;
}

.field-row label {
  width: 130px;
  min-width: 130px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin: 0;
}

.field-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.field-display {
  font-size: 14px;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-display a { color: var(--accent); }
.field-display a:hover { text-decoration: underline; }

.field-input {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.btn-edit-field {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  flex-shrink: 0;
}
.btn-edit-field:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.field-row:hover .btn-edit-field,
.field-row:focus-within .btn-edit-field { opacity: 1; }

/* Follow-up + Notes sections */
.followup-section,
.notes-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.followup-section h4,
.notes-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}
.followup-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.followup-row input[type="date"] { flex: 1; min-width: 140px; }
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.followup-state { margin-top: 10px; min-height: 20px; }
.followup-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.followup-badge--overdue { background: var(--danger-light);  color: var(--danger);  }
.followup-badge--today   { background: var(--warning-light); color: var(--warning); }
.followup-badge--future  { background: var(--accent-light);  color: var(--accent);  }
.followup-badge--done    { background: var(--success-light); color: var(--success); }

.notes-section textarea { margin-bottom: 8px; }

/* Add note + activity timeline */
.add-note-form {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.add-note-form textarea { margin: 0; }
.add-note-form .btn-primary { align-self: flex-end; }

.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 20px;
}
.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  line-height: 1.4;
}
.activity-body { flex: 1; min-width: 0; }
.activity-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
}
.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.activity-arrow { color: var(--text-muted); margin: 0 2px; }

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-column);
  color: var(--text-secondary);
  margin: 0 2px;
}
.value-old,
.value-new {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--bg-column);
  color: var(--text-secondary);
  margin: 0 2px;
}
.status-pill--new,
.value-new { background: var(--accent-light); color: var(--accent); }

/* Full-slug status pill colour variants (used by dashboard + follow-up table) */
.status-in-attesa-di-info  { background: var(--warning-light); color: var(--warning); }
.status-preventivo-inviato { background: var(--accent-light);  color: var(--accent);  }
.status-in-lavorazione     { background: var(--purple-light);  color: var(--purple);  }
.status-confermato         { background: var(--success-light); color: var(--success); }
.status-lead-ko            { background: var(--danger-light);  color: var(--danger);  }

/* Meta info */
.meta-info {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}
.raw-payload {
  margin-top: 6px;
  font-size: 11px;
}
.raw-payload summary {
  cursor: pointer;
  color: var(--text-secondary);
  user-select: none;
  padding: 4px 0;
}
.raw-payload pre {
  background: var(--bg-column);
  padding: 10px;
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 240px;
  font-size: 11px;
  margin: 6px 0 0;
}

/* Small button modifier */
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   CSV Import wizard
   ============================================================ */

.import-modal {
  min-width: 560px;
  max-width: 720px;
}

.import-header {
  margin-bottom: 16px;
}
.import-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.step-indicator {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.import-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Step 1 — upload */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--bg-input);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.upload-zone .upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  line-height: 1;
}
.upload-zone p { margin: 6px 0; color: var(--text-secondary); font-size: 14px; }
.upload-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 500;
}
.upload-hint {
  font-size: 12px;
  color: var(--text-muted) !important;
  margin-top: 8px !important;
}

#file-preview .file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}
#file-preview .file-info #file-name { font-weight: 600; color: var(--text-primary); }
#file-preview .file-info #file-stats { color: var(--text-muted); font-size: 12px; }

.preview-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.preview-table th {
  background: var(--bg-column);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.preview-table td {
  padding: 5px 10px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Step 2 — mapping */
.mapping-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.mapping-row {
  display: grid;
  grid-template-columns: 1fr 24px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
.mapping-row.auto-mapped {
  border-color: var(--success);
  background: var(--success-light);
}
.col-preview { min-width: 0; }
.col-header {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-sample {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-sample.muted { opacity: 0.7; }
.col-arrow {
  color: var(--text-muted);
  text-align: center;
  font-size: 16px;
}
.col-map-select { width: 100%; }

/* Step 3 — validation */
.validation-summary {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0;
}
.val-stat {
  text-align: center;
  padding: 16px 24px;
  border-radius: var(--radius);
  background: var(--bg-column);
  flex: 1;
}
.val-stat.success .val-number { color: var(--success); }
.val-stat.warning .val-number { color: var(--warning); }
.val-stat.info    .val-number { color: var(--accent); }
.val-number {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}
.val-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.error-rows-list {
  max-height: 180px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 8px;
}
.error-rows-list h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.error-rows-list ul { margin: 0; padding-left: 18px; font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.error-rows-list li.muted { color: var(--text-muted); list-style: none; margin-left: -18px; }

.import-confirm-msg {
  text-align: center;
  padding: 16px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 16px;
  color: var(--text-primary);
}

/* Step 4 — progress + results */
.import-progress { padding: 20px 0; }
.progress-bar {
  height: 8px;
  background: var(--bg-column);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}
#progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.import-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0;
}
.result-stat {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.result-stat span {
  font-weight: 700;
  font-size: 20px;
}
.result-stat.success { background: var(--success-light); color: var(--success); }
.result-stat.warning { background: var(--warning-light); color: var(--warning); }
.result-stat.danger  { background: var(--danger-light);  color: var(--danger);  }
.result-stat .errors-list {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-primary);
  max-height: 160px;
  overflow-y: auto;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .import-modal { min-width: 0; }
  .validation-summary { flex-direction: column; gap: 8px; }
  .val-stat { padding: 12px 16px; }
}

/* ============================================================
   Dashboard view
   ============================================================ */

#view-dashboard {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
  background: var(--bg-app);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.dash-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.2px;
}
.dash-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.dash-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  min-width: 180px;
}
.dash-select:hover { border-color: var(--accent); }
.dash-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* KPI grid — definitive rule lives at the bottom of this file */
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
  min-width: 0;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.kpi-card.success { border-top: 3px solid var(--success); }
.kpi-card.accent  { border-top: 3px solid var(--accent);  }
.kpi-card.warning { border-top: 3px solid var(--warning); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-card.success .kpi-value { color: var(--success); }
.kpi-card.accent  .kpi-value { color: var(--accent);  }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Charts grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
/* All cards same size — no wide override */
.chart-card.wide { grid-column: span 1; }
.chart-header { margin-bottom: 16px; }
.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.chart-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
}
.chart-card canvas { display: block; max-width: 100%; }
.chart-card #chart-source,
.chart-card #chart-status { margin: 0 auto; }

/* Follow-up section */
.dash-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}
.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-column);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-input); }
.data-table .text-muted { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.row-overdue td:first-child { border-left: 3px solid var(--danger);  }
.row-today   td:first-child { border-left: 3px solid var(--warning); }

/* Skeleton placeholders */
.skeleton-kpi   { height: 100px; border-radius: var(--radius-lg); }
.skeleton-chart { height: 220px; border-radius: var(--radius-lg); }

/* Empty + error states */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}
.error-state {
  text-align: center;
  padding: 40px;
  color: var(--danger);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.error-state p { margin: 0; }

/* Responsive */
@media (max-width: 768px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Settings view
   ============================================================ */

#view-settings {
  padding: 24px;
  overflow-y: auto;
  height: 100%;
  background: var(--bg-app);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  align-self: start;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}
.settings-nav-item:hover {
  background: var(--bg-column);
  color: var(--text-primary);
}
.settings-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.settings-section { display: none; }
.settings-section.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.settings-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.settings-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 18px 0 8px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.5;
}
.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header-row h3 { margin: 0; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}
.field-hint.danger { color: var(--danger); }

.input-readonly {
  background: var(--bg-column) !important;
  color: var(--text-muted);
  cursor: not-allowed;
}

.info-grid {
  display: flex;
  flex-direction: column;
}
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-row > span:first-child {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Sortable list (statuses) */
.sortable-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.sortable-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: border-color var(--transition), background var(--transition), opacity var(--transition);
}
.sortable-item:active { cursor: grabbing; }
.sortable-item.drag-over,
.sortable-item.is-dragging {
  border-color: var(--accent);
  background: var(--accent-light);
}
.sortable-item.is-dragging { opacity: 0.5; }
.drag-handle {
  color: var(--text-muted);
  font-size: 16px;
  cursor: grab;
  user-select: none;
}
.sortable-item input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  padding: 0;
  color: var(--text-primary);
}
.btn-remove-status {
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.btn-remove-status:hover:not(:disabled) { background: var(--danger-light); }
.btn-remove-status:disabled { opacity: 0.35; cursor: not-allowed; }

.status-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.settings-warning {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--warning-light);
  color: var(--warning);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.6;
  border-left: 3px solid var(--warning);
}

/* Webhook URL / token */
.webhook-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-column);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.webhook-url-box code {
  flex: 1;
  font-size: 12px;
  word-break: break-all;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-primary);
  min-width: 0;
}
.webhook-url-box .btn-icon { color: var(--text-secondary); flex-shrink: 0; }
.webhook-url-box .btn-icon:hover { background: var(--bg-card); color: var(--text-primary); }

.token-box {
  padding: 10px 14px;
  background: var(--bg-column);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.token-box code {
  font-size: 13px;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-secondary);
  word-break: break-all;
}

.btn-danger-soft {
  color: var(--danger) !important;
  border-color: var(--danger) !important;
  margin-top: 12px;
}
.btn-danger-soft:hover { background: var(--danger-light) !important; }

.code-block {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: 'Courier New', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-x: auto;
  line-height: 1.6;
  margin: 0;
  white-space: pre;
}
[data-theme="dark"] .code-block {
  background: #0f172a;
  color: #94a3b8;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.alert.success { background: var(--success-light); color: var(--success); }
.alert.danger  { background: var(--danger-light);  color: var(--danger); }

/* Role badges */
.role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.role-badge.role-super_admin { background: var(--warning-light); color: var(--warning); }
.role-badge.role-admin       { background: var(--accent-light);  color: var(--accent); }
.role-badge.role-client      { background: var(--bg-column);     color: var(--text-secondary); }
.role-badge.role-viewer      { background: var(--bg-column);     color: var(--text-muted); }

/* User row + status dot */
.row-disabled td { opacity: 0.5; }
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  background: var(--text-muted);
}
.status-dot.active   { background: var(--success); }
.status-dot.inactive { background: var(--text-muted); }

.action-buttons {
  display: flex;
  gap: 4px;
}
.action-buttons .btn-icon {
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  font-size: 13px;
}
.action-buttons .btn-icon:hover { background: var(--bg-column); color: var(--text-primary); }

/* Project assignments — extension to the spec's basic Users section */
.assignment-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-input);
}
.assignment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.assignment-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assignment-row {
  display: grid;
  grid-template-columns: 1fr auto 32px;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.assignment-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Modal header used by lbModal title in user/project forms */
.modal-header { margin-bottom: 16px; }
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
    position: static;
  }
  .settings-nav-item { padding: 7px 12px; }
}

/* ============================================================
   Polish: page loader, quick search, hamburger, empty states
   ============================================================ */

/* Top loading bar */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
  pointer-events: none;
}

/* Quick search */
.nav-search {
  flex: 1;
  max-width: 280px;
  margin: 0 16px;
  display: flex;
  align-items: center;
}
.search-input {
  width: 100%;
  padding: 7px 14px;
  background: var(--bg-column);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
  font-family: inherit;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
[data-theme="dark"] .search-input {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-white);
}
[data-theme="dark"] .search-input::placeholder { color: rgba(255, 255, 255, 0.4); }
[data-theme="dark"] .search-input:focus {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .search-input:focus::placeholder { color: rgba(255, 255, 255, 0.55); }

/* Cards filtered out by quick search are removed from layout */
.lead-card.search-hidden { display: none !important; }

/* ============================================
   HAMBURGER BUTTON
   ============================================ */

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--bg-column);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--navbar-text);
  border-radius: 2px;
  transition: all 0.25s ease;
  transform-origin: center;
}

/* Hamburger -> X animation */
.hamburger-btn.open .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hamburger-btn.open .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 400;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.mobile-overlay.open {
  opacity: 1;
}

/* ============================================
   MOBILE SIDEBAR
   ============================================ */

.mobile-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 401;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.mobile-sidebar.open {
  transform: translateX(0);
}

/* Sidebar header */
.mobile-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Sidebar sections */
.mobile-sidebar-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.mobile-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Mobile project select */
.mobile-project-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
}

/* Mobile nav items */
.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--transition);
}

.mobile-nav-item:hover {
  background: var(--bg-column);
  color: var(--text-primary);
}

.mobile-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.mobile-nav-item .ti {
  font-size: 18px;
  flex-shrink: 0;
}

/* Sidebar footer */
.mobile-sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.mobile-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.mobile-user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-user-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.mobile-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all var(--transition);
}

.mobile-action-btn:hover {
  background: var(--bg-column);
  color: var(--text-primary);
}

.mobile-action-btn.danger {
  color: var(--danger);
}

.mobile-action-btn.danger:hover {
  background: var(--danger-light);
}

/* Board-level empty state */
.board-empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  color: var(--text-primary);
  padding: 40px 20px;
  background: var(--bg-app);
}
.board-empty-state h3 {
  margin: 12px 0 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.board-empty-state p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 380px;
}
.board-empty-state .btn-primary { margin-top: 16px; padding: 10px 20px; }

/* Dashboard empty state */
.dash-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  color: var(--text-secondary);
  padding: 60px 20px;
}
.dash-empty h3 {
  margin: 12px 0 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.dash-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 380px;
}
.dash-empty .btn-primary { margin-top: 16px; padding: 10px 20px; }

/* Drawer header — split source badge + status pill on the same row */
.drawer-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================
   RESPONSIVE - hide/show elements
   ============================================ */

@media (max-width: 768px) {

  /* Hide everything tagged desktop-only */
  .desktop-only {
    display: none !important;
  }

  /* Show hamburger */
  .hamburger-btn {
    display: flex !important;
  }

  /* Show overlay (still kept off-screen until .open) */
  .mobile-overlay {
    display: block;
  }

  /* Compact navbar; spread hamburger/logo and right-side actions */
  #navbar {
    padding: 0 12px;
    justify-content: space-between;
  }

  /* Reset action-group separator on mobile */
  .nav-actions {
    padding-left: 0;
    margin-left: 0;
    border-left: none;
    gap: 4px;
  }

  /* Drop the inline project-name divider on mobile to keep navbar tight */
  .nav-project-name {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
  }

  /* Kanban horizontal scroll on mobile */
  #kanban-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .kanban-column {
    min-width: 260px;
  }

  /* Floating button */
  #btn-floating-add {
    bottom: 20px;
    right: 16px;
  }

  /* board empty state shrinks gracefully */
  .board-empty-state h3 { font-size: 18px; }
}

/* -------- Toast -------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide-up 0.2s ease;
  min-width: 200px;
  pointer-events: auto;
}
[data-theme="dark"] .toast {
  background: #1e293b;
  color: #f1f5f9;
  border: 1px solid var(--border);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger);  }
.toast.is-leaving { animation: fade-out 0.18s ease forwards; }

@keyframes slide-up {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fade-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-4px); }
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* -------- Placeholders for stub views -------- */
.view-placeholder {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg-app);
}
.view-placeholder__inner {
  background: var(--bg-card);
  padding: 32px 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--text-secondary);
  text-align: center;
}

/* -------- Responsive: stack columns vertically below 768px -------- */
@media (max-width: 768px) {
  .drawer { width: 100vw; }
  .modal-box { min-width: 0; }
}

/* ---------- Locked sortable items (statuses & sources) ---------- */
.sortable-item[data-locked="true"] {
  background: var(--bg-column);
  border-style: dashed;
}
.sortable-item[data-locked="true"] input {
  color: var(--text-secondary);
  cursor: default;
}
.lock-icon {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 0 6px;
  flex-shrink: 0;
}

/* ---------- Sources preview ---------- */
.source-colors-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.source-color-row { display: inline-flex; }
.source-badge--preview {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.btn-remove-source {
  background: transparent;
  color: var(--danger);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.btn-remove-source:hover:not(:disabled) { background: var(--danger-light); }
.btn-remove-source:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Fields config ---------- */
.fields-config-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.field-config-row {
  display: grid;
  grid-template-columns: 56px 1fr 1.2fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.field-config-toggle { display: flex; justify-content: center; }
.field-config-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field-original-name { font-weight: 600; color: var(--text-primary); font-size: 14px; }
.field-original-key {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-muted);
}
.field-config-rename input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
}
.field-config-rename input:focus { outline: none; border-color: var(--accent); }

/* Toggle switch */
.toggle-label {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  cursor: pointer;
}
.toggle-label input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle-label input:checked + .toggle-slider { background: var(--accent); }
.toggle-label input:checked + .toggle-slider::before { transform: translateX(16px); }

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.inline-check input { width: auto; }

/* ---------- Custom fields list ---------- */
.custom-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.cf-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cf-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.cf-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-edit-cf:hover { background: var(--accent-light); color: var(--accent); }
.btn-delete-cf { color: var(--danger); }
.btn-delete-cf:hover { background: var(--danger-light); }

@media (max-width: 720px) {
  .field-config-row {
    grid-template-columns: 44px 1fr;
    grid-template-rows: auto auto;
  }
  .field-config-rename { grid-column: 1 / -1; }
}

/* ---------- Board toolbar (top row, view toggle right-aligned) ---------- */
.board-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---------- Filter bar (second row, all left-aligned) ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Filter inputs */
.filter-input,
.filter-select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
}
.filter-input:focus,
.filter-select:focus {
  border-color: var(--border-focus);
}

/* Search filter slightly wider */
#filter-search {
  width: 200px;
}

/* Date inputs */
#filter-date-from,
#filter-date-to {
  width: 140px;
}

/* Clear button */
#btn-clear-filters {
  margin-left: 4px;
  height: 32px;
  white-space: nowrap;
}

.filter-arrow { color: var(--text-muted); font-size: 13px; }

/* Filter count badge */
.filter-count {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  padding: 3px 10px;
  background: var(--accent-light);
  border-radius: 20px;
  white-space: nowrap;
}

/* ---------- View toggle (Kanban / Table) — right side of board-toolbar ---------- */
.view-toggle {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-column);
  border-radius: var(--radius-sm);
  margin-left: auto;
}

.view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.view-toggle-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.view-toggle-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
  .board-toolbar {
    padding: 8px 12px;
  }
  .filter-bar {
    padding: 8px 12px;
    gap: 6px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar {
    display: none;
  }
  #filter-search {
    width: 160px;
  }
  #filter-date-from,
  #filter-date-to {
    width: 120px;
  }
}

/* ---------- Table view ---------- */
/* Note: no `display` rules on .kanban-wrapper / .table-wrapper — visibility is
   controlled imperatively in kanban.js (_setViewMode). Adding rules here
   would override inline style/hidden and break the toggle. */
.table-view-wrap {
  overflow-x: auto;
  padding: 20px;
}
.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
  background: var(--bg-card);
}
.leads-table th {
  padding: 10px 14px;
  text-align: left;
  background: var(--bg-column);
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
}
.leads-table th:hover { background: var(--border); }
.leads-table th.sorted-asc,
.leads-table th.sorted-desc { color: var(--accent); }
.leads-table th .sort-icon { font-size: 10px; opacity: 0.7; margin-left: 4px; }
.leads-table th.th-actions { cursor: default; text-align: right; }
.leads-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leads-table td.td-actions { text-align: right; }
.leads-table tr.lead-row { cursor: pointer; transition: background 0.1s; }
.leads-table tr.lead-row:hover td { background: var(--bg-input); }
.leads-table a { color: var(--accent); text-decoration: none; }
.leads-table a:hover { text-decoration: underline; }

.table-footer {
  display: flex;
  justify-content: space-between;
  padding: 12px 4px 4px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Dashboard date range / quick periods ---------- */
.date-range-picker {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  flex-wrap: wrap;
}
.date-range-picker label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.dash-quick-periods { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.period-btn {
  padding: 5px 10px;
  border: none;
  background: var(--bg-column);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.period-btn:hover:not(.active) { background: var(--border); color: var(--text-primary); }
.period-btn.active { background: var(--accent); color: var(--text-white); }

/* ---------- Custom fields section on the lead panel ---------- */
.custom-fields-section {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.custom-fields-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.custom-field-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}
.custom-field-input:focus { border-color: var(--accent); }
.field-row--custom { padding-top: 4px; }
.field-row--custom label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-secondary); }

/* (Old 720px toolbar overrides removed — replaced by the 768px block
   above which handles padding/gap and keeps the 32px input height.) */

/* ============================================================
   Light theme — kanban visibility tweaks
   Real class names in this codebase are .kanban-column__header,
   .kanban-cards, .kanban-badge, .kanban-empty. We target both
   the real names and the conventional .column-* / .cards-container
   names so the rules apply regardless of which the markup uses.
   ============================================================ */

[data-theme="light"] #view-board { background: #f0f4f8; }

[data-theme="light"] .kanban-board { background: #f0f4f8; }

[data-theme="light"] .kanban-column {
  background: #e8eef5;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .kanban-column .kanban-column__header,
[data-theme="light"] .kanban-column .column-header {
  background: #dde5ef;
  border-bottom: 1px solid #cbd5e1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

[data-theme="light"] .kanban-column .kanban-cards,
[data-theme="light"] .kanban-column .cards-container {
  background: #e8eef5;
}

[data-theme="light"] .lead-card {
  background: #ffffff;
  border-top: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  border-left-width: 4px;
  /* border-left-color is set by .lead-card[data-status-key="..."] rules
     or by kanban.js via card.style.borderLeftColor — do not touch it here */
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .lead-card:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  border-top-color: #94a3b8;
  border-right-color: #94a3b8;
  border-bottom-color: #94a3b8;
  /* leave border-left-color alone on hover */
}

[data-theme="light"] .kanban-badge,
[data-theme="light"] .column-count {
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
}

[data-theme="light"] .kanban-empty,
[data-theme="light"] .column-empty {
  background: rgba(255, 255, 255, 0.5);
  border: 2px dashed #cbd5e1;
}

[data-theme="light"] .filter-bar,
[data-theme="light"] .board-toolbar {
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
}

/* ============================================
   TABLER ICONS — monochromatic, theme-aware
   Icons inherit color from their parent. No
   colored variants; size is controlled via
   font-size only. Outline-only (no -filled).
   ============================================ */
.ti {
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
  color: inherit;
}
.ti-sm { font-size: 13px; }
.ti-lg { font-size: 20px; }
.ti-xl { font-size: 24px; }

/* Navbar icon buttons */
.btn-icon .ti { font-size: 18px; }

/* Settings nav */
.settings-nav-item .ti {
  font-size: 16px;
  margin-right: 2px;
}

/* KPI card icons */
.kpi-label .ti {
  font-size: 14px;
  margin-right: 6px;
  opacity: 0.7;
}

/* Field label icons (modals + drawer) */
.field-row label .ti,
.form-group label .ti {
  font-size: 12px;
  margin-right: 5px;
  opacity: 0.6;
}

/* Activity timeline icons */
.activity-icon .ti { font-size: 16px; }

/* Tab icons */
.tab .ti {
  font-size: 14px;
  margin-right: 5px;
}

/* Lead card icons */
.lead-card .ti {
  font-size: 12px;
  color: var(--text-muted);
}

/* Search input wrap (icon-inside) */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .ti {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-wrap input,
.search-wrap .search-input,
.search-wrap .filter-input {
  padding-left: 32px;
}

/* Button icon spacing */
.btn-primary .ti,
.btn-secondary .ti {
  margin-right: 5px;
  font-size: 14px;
}

/* Source/sector pills inside cards */
.source-badge .ti,
.sector-pill .ti,
.followup .ti {
  font-size: 11px;
  margin-right: 3px;
  vertical-align: middle;
}

/* ============================================
   KPI GRID — DEFINITIVE RULE
   Placed at end of file so it wins the cascade.
   ============================================ */
.kpi-grid {
  display: grid !important;
  grid-template-columns: repeat(7, 1fr) !important;
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 1280px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================
   NOTIFICATIONS — bell + badge + dropdown panel
   ============================================ */
.nav-notifications {
  position: relative;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-navbar);
  pointer-events: none;
  animation: badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badge-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: -8px;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  animation: notif-drop 0.2s ease;
}

@keyframes notif-drop {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.notif-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.notif-panel-body {
  max-height: 320px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-column); }

.notif-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.notif-item-dot.overdue { background: var(--danger);  }
.notif-item-dot.today   { background: var(--warning); }

.notif-item-body {
  flex: 1;
  min-width: 0;
}

.notif-item-company {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notif-item-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
}
.notif-item-tag.overdue {
  background: var(--danger-light);
  color: var(--danger);
}
.notif-item-tag.today {
  background: var(--warning-light);
  color: var(--warning);
}

.notif-loading {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.notif-empty .ti {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  color: var(--success);
}

.notif-panel-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.notif-btn.has-notifications .ti-bell {
  animation: bell-ring 0.5s ease;
}

@keyframes bell-ring {
  0%   { transform: rotate(0deg); }
  20%  { transform: rotate(15deg); }
  40%  { transform: rotate(-12deg); }
  60%  { transform: rotate(8deg); }
  80%  { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}

[data-theme="dark"] .notif-panel {
  background: var(--bg-card);
  border-color: var(--border);
}

/* ============================================
   GLOBAL SEARCH — navbar search with dropdown
   ============================================ */
.global-search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
  min-width: 180px;
}

.global-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-column);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
  pointer-events: none;
  font-family: var(--font);
  line-height: 1.4;
  transition: opacity var(--transition);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 1;
}
.search-clear:hover {
  color: var(--text-primary);
  background: var(--bg-column);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  overflow: hidden;
  animation: notif-drop 0.15s ease;
  max-height: 480px;
  display: flex;
  flex-direction: column;
}

#search-results-body {
  overflow-y: auto;
  flex: 1;
}

.search-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px 4px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover,
.search-result-item.selected {
  background: var(--accent-light);
}
.search-result-item.selected .search-result-company {
  color: var(--accent);
}

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg-column);
  color: var(--text-secondary);
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-company {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-company mark {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-status {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
}

.search-result-arrow {
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.search-empty .ti {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}

.search-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.search-results-footer {
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.search-results-footer:empty { display: none; }

.search-footer-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-footer-hint kbd {
  font-size: 10px;
  background: var(--bg-column);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font);
}

.search-footer-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Source icon colors */
.search-icon-organico { background: var(--success-light); color: var(--success); }
.search-icon-adv      { background: var(--purple-light);  color: var(--purple);  }
.search-icon-webhook  { background: var(--accent-light);  color: var(--accent);  }
.search-icon-csv      { background: var(--bg-column);     color: var(--text-secondary); }
.search-icon-manuale  { background: var(--warning-light); color: var(--warning); }

/* Navbar responsive — gracefully shrink selector + search before mobile breakpoint */
@media (max-width: 1200px) {
  .global-search-wrap {
    max-width: 220px;
    min-width: 150px;
  }
  #project-selector {
    width: 160px;
  }
}

@media (max-width: 1024px) {
  .nav-links .nav-link span {
    display: none;
  }
  .global-search-wrap {
    max-width: 180px;
  }
}

@media (max-width: 768px) {
  .search-kbd { display: none; }
}

/* ============================================
   DRAG & DROP — smooth animations
   ============================================ */
.lead-card { cursor: grab; }
.lead-card:active { cursor: grabbing; }

.lead-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
  transform: scale(0.98);
}

.kanban-column.drop-target .kanban-cards,
.kanban-column.drop-target .cards-container {
  background: var(--accent-light);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.drop-indicator {
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 2px 4px;
  animation: indicator-appear 0.15s ease;
  flex-shrink: 0;
}

@keyframes indicator-appear {
  from { opacity: 0; transform: scaleX(0.5); }
  to   { opacity: 1; transform: scaleX(1); }
}

@keyframes card-drop-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

/* ============================================
   KEYBOARD SHORTCUTS PANEL
   ============================================ */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.shortcuts-overlay.open { opacity: 1; }

.shortcuts-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -44%);
  width: 580px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 501;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.shortcuts-panel.open {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.shortcuts-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  padding: 8px 0;
  max-height: 400px;
  overflow-y: auto;
}

.shortcuts-category {
  padding: 12px 20px;
}

.shortcuts-category-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}

.shortcut-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

.shortcut-keys {
  display: flex;
  gap: 3px;
  align-items: center;
}

.shortcut-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--bg-column);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font);
}

.shortcuts-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.shortcuts-footer kbd { font-family: var(--font); }

.btn-shortcuts {
  opacity: 0.6;
  font-size: 13px;
  font-weight: 600;
}
.btn-shortcuts:hover { opacity: 1; }

@media (max-width: 640px) {
  .shortcuts-grid { grid-template-columns: 1fr; }
}

/* ============================================
   USER PROFILE
   ============================================ */
.profile-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.profile-info h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
}

.profile-info p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.profile-grid .settings-card:first-child {
  grid-column: span 2;
}

.theme-picker {
  display: flex;
  gap: 10px;
}

.theme-option { flex: 1; cursor: pointer; }
.theme-option input { display: none; }

.theme-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.theme-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

@media (max-width: 768px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-grid .settings-card:first-child { grid-column: span 1; }
}

/* ============================================
   KANBAN COLUMN SORT
   ============================================ */
.column-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.column-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.column-sort { display: flex; }

.column-sort-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  max-width: 110px;
  font-family: var(--font);
}

.column-sort-select:hover { border-color: var(--accent); }
.column-sort-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* ============================================
   ONBOARDING EMPTY STATE
   ============================================ */
.onboarding-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 40px 20px;
  text-align: center;
}

.onboarding-hero { margin-bottom: 40px; }
.onboarding-logo { margin-bottom: 16px; opacity: 0.9; }

.onboarding-hero h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.onboarding-hero p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 760px;
  margin-bottom: 32px;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  text-align: center;
}

.onboarding-step:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.ob-step-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.ob-step-body h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.ob-step-body p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.onboarding-hint {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 640px) {
  .onboarding-steps { grid-template-columns: 1fr; }
}

/* ============================================
   CONFIRM DIALOG — context-aware
   ============================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.confirm-overlay.open { opacity: 1; }

.confirm-box {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 32px 28px 24px;
  animation: modal-pop 0.2s ease;
}

@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.confirm-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--danger-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.confirm-detail {
  padding: 12px 16px;
  background: var(--bg-column);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  text-align: left;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.confirm-actions .btn-secondary,
.confirm-actions .btn-danger,
.confirm-actions .btn-warning,
.confirm-actions .btn-primary {
  flex: 1;
  justify-content: center;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
  font-family: var(--font);
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition);
  font-family: var(--font);
}
.btn-warning:hover { background: #d97706; }

/* ============================================
   ACTIVITY TIMELINE — change diff badges
   ============================================ */
.activity-change {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  flex-wrap: wrap;
}

.change-old {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-column);
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: line-through;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change-new {
  font-size: 12px;
  background: var(--success-light);
  color: var(--success);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   CALENDAR VIEW — month + week
   ============================================ */
.calendar-wrap {
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  min-width: 200px;
  text-align: center;
  text-transform: capitalize;
  margin: 0;
}

.calendar-controls { display: flex; align-items: center; gap: 8px; }

.calendar-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

.cal-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.cal-legend-item.overdue .cal-legend-dot { background: var(--danger);  }
.cal-legend-item.today   .cal-legend-dot { background: var(--warning); }
.cal-legend-item.future  .cal-legend-dot { background: var(--accent);  }
.cal-legend-item.done    .cal-legend-dot { background: var(--success); }

.calendar-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Month grid */
.cal-header-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}

.cal-day-header {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 6px 0;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}

.cal-cell {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.cal-cell-outside { background: var(--bg-app); opacity: 0.4; }
.cal-cell-today   { border-color: var(--accent); border-width: 2px; }
.cal-cell-past    { background: var(--bg-column); }

.cal-cell-header {
  display: flex;
  justify-content: flex-end;
}

.cal-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.cal-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-today-num {
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

/* Lead chips */
.cal-lead-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition);
  overflow: hidden;
}

.cal-lead-chip:hover { opacity: 0.8; }

.cal-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.cal-chip-overdue { background: var(--danger-light);  color: var(--danger);  }
.cal-chip-today   { background: var(--warning-light); color: var(--warning); }
.cal-chip-future  { background: var(--accent-light);  color: var(--accent);  }
.cal-chip-done {
  background: var(--success-light);
  color: var(--success);
  text-decoration: line-through;
  opacity: 0.7;
}

.cal-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 4px;
  cursor: pointer;
}

/* Week grid */
.cal-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.cal-week-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cal-col-today { border-color: var(--accent); border-width: 2px; }
.cal-col-past  { background: var(--bg-column); }

.cal-week-header {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--bg-column);
}

.cal-week-dayname {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.cal-week-daynum {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-week-events {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.cal-week-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

.cal-chip-status {
  font-size: 10px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .cal-cell { min-height: 60px; }
  .cal-week-grid { grid-template-columns: 1fr; }
}

/* ============================================
   TAGS / LABELS
   ============================================ */
.tags-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.tags-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.lead-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: default;
}

.tag-remove {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 10px;
  opacity: 0.6;
  transition: opacity var(--transition);
  color: inherit;
}
.tag-remove:hover { opacity: 1; }

.btn-add-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-add-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Tag dropdown (assign / create) */
.tag-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 240px;
  padding: 6px 0;
  animation: notif-drop 0.15s ease;
}

.tag-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}
.tag-dropdown-item:hover { background: var(--bg-column); }

.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.tag-create-form {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.tag-create-form input[type="text"] {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
}

.tag-create-form input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-card);
}

/* Tag chips on kanban cards */
.lead-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.card-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}
.card-tag--more {
  background: var(--bg-column);
  color: var(--text-secondary);
}

/* Tag filter row — sibling of .filter-bar, continues the filter strip */
.tag-filter-row {
  padding: 6px 20px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
[data-theme="light"] .tag-filter-row {
  background: #f8fafc;
  border-bottom-color: #cbd5e1;
}

/* Tag filter chips */
.filter-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 0;
}
.filter-tags-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.filter-tag-btn {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tag-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-tag-btn.active { font-weight: 600; }

/* Settings → Etichette list */
.tags-settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.tag-settings-row {
  display: grid;
  grid-template-columns: 140px 1fr 40px 80px auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tag-settings-row .lead-tag { justify-self: start; }
.tag-edit-name {
  padding: 5px 8px;
  font-size: 13px;
}
.tag-edit-color {
  width: 32px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg-card);
}
.tag-usage {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}
.tag-create-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.tag-create-row input[type="text"] { flex: 1; padding: 6px 10px; }
.tag-create-row input[type="color"] { width: 36px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; background: var(--bg-card); }

/* ============================================
   COMMENTS / @MENTIONS
   ============================================ */
.comment-input-wrap {
  position: relative;
}

#new-note {
  width: 100%;
  resize: vertical;
  min-height: 60px;
}

.comment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}

.comment-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.comment-hint kbd {
  font-size: 10px;
  background: var(--bg-column);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font);
}

.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  animation: notif-drop 0.15s ease;
}

.mention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.mention-item:hover,
.mention-item.selected {
  background: var(--accent-light);
}

.mention-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.mention-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.mention-email {
  font-size: 11px;
  color: var(--text-muted);
}

.mention-highlight {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
  padding: 0 3px;
  border-radius: 3px;
}

/* ── GLOBAL SEARCH INPUT — FINAL RULE ──
   Single source of truth for .global-search-input and .global-search-icon.
   Lives at the bottom of app.css with !important to defeat any future
   override added higher in the cascade. Do not duplicate these selectors
   elsewhere in this file. */
.global-search-input {
  width: 100% !important;
  height: 36px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: 34px !important;
  padding-right: 60px !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  font-size: 13px !important;
  font-family: var(--font) !important;
  outline: none !important;
  transition: border-color 0.18s ease,
              box-shadow 0.18s ease,
              background 0.18s ease !important;
  box-sizing: border-box !important;
}

.global-search-input:focus {
  border-color: var(--border-focus) !important;
  background: var(--bg-card) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

.global-search-input::placeholder {
  color: var(--text-muted) !important;
  font-size: 13px !important;
  padding: 0 !important;
}

.global-search-icon {
  position: absolute !important;
  left: 10px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  font-size: 14px !important;
  color: var(--text-muted) !important;
  pointer-events: none !important;
  z-index: 2 !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center !important;
}

/* Fade the ⌘K hint while the input is focused. .search-kbd already has
   transition: opacity, so this just changes the target value. */
.global-search-input:focus ~ .search-kbd {
  opacity: 0;
}
