/* ===================================================
   iatoi CRM v2 — Design System
   Aesthetic: Refined dark-sidebar, clean data-dense
   Font: Syne (headings) + Geist (body)
   =================================================== */

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

/* ── Variables ─────────────────────────────────── */
:root {
  --bg:            #f4f5f7;
  --surface:       #ffffff;
  --surface-2:     #f8f9fb;
  --border:        #e8eaed;
  --border-soft:   #f0f1f3;

  --sidebar-bg:    #0f1117;
  --sidebar-hover: #1c1f2a;
  --sidebar-active:#1e2130;
  --sidebar-text:  #8b92a8;
  --sidebar-hi:    #ffffff;

  --primary:       #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dim:   rgba(108,92,231,0.12);
  --primary-glow:  rgba(108,92,231,0.25);

  --green:         #00b894;
  --green-dim:     rgba(0,184,148,0.12);
  --amber:         #fdcb6e;
  --amber-dim:     rgba(253,203,110,0.15);
  --red:           #e17055;
  --red-dim:       rgba(225,112,85,0.12);
  --blue:          #0984e3;
  --blue-dim:      rgba(9,132,227,0.12);

  --text-primary:  #1a1d23;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     18px;
  --radius-xl:     24px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:     0 12px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.05);
  --shadow-xl:     0 24px 64px rgba(0,0,0,.14);

  --sidebar-w:     240px;
  --header-h:      64px;
  --transition:    0.18s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Geist', 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Auth ───────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d2e 50%, #0f1117 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.auth-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(24px);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%; max-width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,.5);
}
.auth-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 28px; font-weight: 800;
  color: #fff; text-align: center;
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}
.auth-card input {
  width: 100%; padding: 13px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: #fff; font-size: 14px;
  margin-bottom: 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.auth-card input::placeholder { color: rgba(255,255,255,0.3); }
.auth-card input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.auth-card button {
  width: 100%; padding: 14px;
  background: var(--primary);
  color: #fff; border: none;
  border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 4px;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.auth-card button:hover {
  background: #7d6ff0;
  box-shadow: 0 8px 24px var(--primary-glow);
  transform: translateY(-1px);
}
.auth-switch {
  text-align: center; color: rgba(255,255,255,.4);
  font-size: 13px; margin-top: 16px;
}
.auth-switch a {
  color: var(--primary-light); cursor: pointer;
  text-decoration: none; font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────── */
.crm-container {
  display: flex; min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */
.crm-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto; overflow-x: hidden;
  transition: width var(--transition);
}
.crm-logo {
  padding: 24px 20px 20px;
  font-family: 'Syne', sans-serif;
  font-size: 18px; font-weight: 800;
  color: #fff; letter-spacing: -0.3px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.crm-logo .logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.crm-logo .plan-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; padding: 2px 7px;
  border-radius: 20px; margin-left: auto;
  text-transform: uppercase;
}

.crm-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1px;
  color: rgba(255,255,255,.25); text-transform: uppercase;
  padding: 16px 20px 6px;
}
.crm-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--sidebar-text);
  cursor: pointer; border-radius: 0;
  transition: background var(--transition), color var(--transition);
  font-size: 13.5px; font-weight: 500;
  position: relative; user-select: none;
}
.crm-nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.crm-nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}
.crm-nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-email {
  font-size: 12px; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1;
}
.sidebar-logout {
  background: none; border: none;
  color: rgba(255,255,255,.3); cursor: pointer;
  font-size: 15px; padding: 4px;
  transition: color var(--transition);
}
.sidebar-logout:hover { color: var(--red); }

/* ── Main ────────────────────────────────────────── */
.crm-main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

/* ── Header ──────────────────────────────────────── */
.crm-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.crm-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 17px; font-weight: 700;
  color: var(--text-primary);
  margin-right: 8px; white-space: nowrap;
}
.header-search {
  flex: 1; max-width: 380px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 0 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.header-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.header-search input {
  border: none; background: none;
  font-size: 13.5px; color: var(--text-primary);
  width: 100%; padding: 8px 0; outline: none;
}
.header-search input::placeholder { color: var(--text-muted); }
.search-icon { color: var(--text-muted); font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.header-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--transition); border: none;
}
.header-btn-primary {
  background: var(--primary); color: white;
}
.header-btn-primary:hover {
  background: #7d6ff0; box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}
.header-btn-ghost {
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.header-btn-ghost:hover { background: var(--border); color: var(--text-primary); }

.online-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(0,184,148,.25);
}
.online-dot.offline { background: var(--text-muted); box-shadow: none; }

/* ── Page Content ─────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
  max-width: 1440px;
}

/* ── Page Header ──────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title-block h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  letter-spacing: -0.3px;
}
.page-title-block p {
  font-size: 13px; color: var(--text-secondary); margin-top: 2px;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── KPI Cards ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.kpi-card.clickable { cursor: pointer; }
.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 12px;
}
.kpi-icon.purple { background: var(--primary-dim); }
.kpi-icon.green  { background: var(--green-dim); }
.kpi-icon.amber  { background: var(--amber-dim); }
.kpi-icon.blue   { background: var(--blue-dim); }
.kpi-icon.red    { background: var(--red-dim); }
.kpi-value {
  font-family: 'Syne', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.5px;
  line-height: 1;
}
.kpi-label {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 4px; font-weight: 500;
}
.kpi-trend {
  font-size: 11px; font-weight: 600;
  margin-top: 8px; display: flex; align-items: center; gap: 3px;
}
.kpi-trend.up   { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* ── Card ────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
}
.card-body { padding: 20px 22px; }

/* ── Tables ──────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap; gap: 10px;
}
.table-title {
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 700;
  color: var(--text-primary);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  text-align: left; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td {
  padding: 13px 16px;
  font-size: 13.5px; color: var(--text-primary);
  vertical-align: middle;
}
.td-muted { color: var(--text-secondary) !important; font-size: 12.5px !important; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-prospect { background: var(--amber-dim); color: #b8860b; }
.badge-contact  { background: var(--blue-dim);  color: var(--blue); }
.badge-client   { background: var(--green-dim); color: #00856b; }
.badge-purple   { background: var(--primary-dim); color: var(--primary); }
.badge-red      { background: var(--red-dim); color: var(--red); }
.badge-gray     { background: #f1f3f5; color: var(--text-secondary); }

/* Invoice status badges */
.badge-devis    { background: #f1f3f5; color: var(--text-secondary); }
.badge-envoye   { background: var(--blue-dim); color: var(--blue); }
.badge-accepte  { background: var(--green-dim); color: #00856b; }
.badge-facture  { background: var(--primary-dim); color: var(--primary); }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary); color: white;
}
.btn-primary:hover {
  background: #7d6ff0;
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--green); color: white;
}
.btn-success:hover { background: #00a381; transform: translateY(-1px); }
.btn-danger {
  background: var(--red-dim); color: var(--red);
}
.btn-danger:hover { background: var(--red); color: white; }
.btn-ghost {
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-icon {
  padding: 6px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition); font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px;
}
.btn-icon:hover { background: var(--border); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--red); color: white; border-color: var(--red); }

/* ── Filters toolbar ─────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 6px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary); color: white; border-color: var(--primary);
}
.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  font-size: 13px; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--primary); }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  font-size: 13.5px; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Modal ───────────────────────────────────────── */
.crm-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(10,10,15,0.6);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.crm-modal.active { display: flex; }
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .2s cubic-bezier(.34,1.36,.64,1);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 17px; font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 14px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--red); color: white; border-color: var(--red); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Kanban ──────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px; align-items: start;
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 200px;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.kanban-col-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.kanban-col-count {
  background: var(--border);
  color: var(--text-secondary);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.kanban-col-body { padding: 10px; min-height: 100px; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: grab; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  position: relative;
}
.kanban-card:hover {
  box-shadow: var(--shadow); transform: translateY(-1px);
  border-color: var(--primary);
}
.kanban-card.dragging { opacity: .5; cursor: grabbing; }
.kanban-card-name {
  font-size: 13.5px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 3px;
}
.kanban-card-company {
  font-size: 12px; color: var(--text-secondary); margin-bottom: 6px;
}
.kanban-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.kanban-card-value {
  font-size: 13px; font-weight: 700; color: var(--primary);
}
.kanban-score {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
}
.score-high   { background: var(--green-dim);  color: #00856b; }
.score-medium { background: var(--amber-dim);  color: #b8860b; }
.score-low    { background: var(--red-dim);    color: var(--red); }
.kanban-drop-zone {
  border: 2px dashed var(--primary); border-radius: var(--radius);
  height: 60px; display: none; align-items: center; justify-content: center;
  color: var(--primary); font-size: 12px; font-weight: 600; margin-bottom: 8px;
}
.kanban-col.dragover .kanban-drop-zone { display: flex; }

/* ── Pipeline stages ─────────────────────────────── */
.pipeline-stages {
  display: flex; gap: 0;
  overflow-x: auto; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0; overflow: hidden;
}
.pipeline-stage {
  flex: 1; min-width: 140px;
  padding: 16px; text-align: center;
  border-right: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
  position: relative;
}
.pipeline-stage:last-child { border-right: none; }
.pipeline-stage:hover { background: var(--surface-2); }
.pipeline-stage.active { background: var(--primary-dim); }
.pipeline-stage.active::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--primary);
}
.pipeline-stage-count {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
}
.pipeline-stage-label {
  font-size: 11px; color: var(--text-secondary);
  font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  margin-top: 2px;
}
.pipeline-stage-value {
  font-size: 12px; font-weight: 600; color: var(--primary);
  margin-top: 3px;
}

/* ── Score indicator ─────────────────────────────── */
.score-bar {
  height: 4px; border-radius: 2px;
  background: var(--border); overflow: hidden;
  margin-top: 4px;
}
.score-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s ease;
}
.score-fill.high   { background: var(--green); }
.score-fill.medium { background: var(--amber); }
.score-fill.low    { background: var(--red); }

/* ── Charts ──────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.chart-card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 14px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 16px;
}
.chart-full { grid-column: span 2; }
canvas { max-height: 280px; }

/* ── Tags ────────────────────────────────────────── */
.tags-container {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.tag {
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
  background: var(--primary-dim); color: var(--primary);
  white-space: nowrap; cursor: default;
}
.tag-remove {
  margin-left: 3px; cursor: pointer; opacity: .6;
}
.tag-remove:hover { opacity: 1; }

/* ── Activity timeline ───────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0; margin-top: 2px;
}
.activity-dot.note    { background: var(--blue-dim);   }
.activity-dot.call    { background: var(--green-dim);  }
.activity-dot.email   { background: var(--primary-dim);}
.activity-dot.status  { background: var(--amber-dim);  }
.activity-dot.create  { background: var(--green-dim);  }
.activity-content { flex: 1; min-width: 0; }
.activity-text {
  font-size: 13px; color: var(--text-primary); line-height: 1.4;
}
.activity-time {
  font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
}

/* ── Detail panel ────────────────────────────────── */
.detail-modal .modal-content { max-width: 720px; }
.contact-detail-header {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 24px; border-bottom: 1px solid var(--border-soft);
}
.contact-big-avatar {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.contact-detail-info h3 {
  font-family: 'Syne', sans-serif;
  font-size: 19px; font-weight: 700;
  color: var(--text-primary);
}
.contact-detail-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 6px;
}
.contact-meta-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 12.5px; color: var(--text-secondary);
}
.detail-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.detail-tab {
  padding: 13px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.detail-tab:hover { color: var(--text-primary); }
.detail-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.detail-tab-content { display: none; padding: 20px 24px; }
.detail-tab-content.active { display: block; }

/* ── Score badge ─────────────────────────────────── */
.lead-score {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700;
}
.lead-score-circle {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 700;
  color: white;
}
.lsc-high   { background: var(--green); }
.lsc-medium { background: var(--amber); }
.lsc-low    { background: var(--red); }

/* ── Welcome banner ──────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #a29bfe 100%);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  color: white; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.welcome-text h3 {
  font-family: 'Syne', sans-serif;
  font-size: 18px; font-weight: 700;
  margin-bottom: 4px;
}
.welcome-text p { font-size: 13px; opacity: .85; }
.welcome-action {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.3);
  color: white; padding: 9px 18px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background var(--transition);
}
.welcome-action:hover { background: rgba(255,255,255,.3); }

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px; margin-bottom: 16px; opacity: .4;
}
.empty-state h4 {
  font-family: 'Syne', sans-serif;
  font-size: 16px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
}
.empty-state p { font-size: 13px; max-width: 280px; margin: 0 auto 20px; }

/* ── Toast ───────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 13px 20px; border-radius: var(--radius);
  color: white; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg); display: none;
  z-index: 9000; max-width: 360px;
  animation: toastIn .25s cubic-bezier(.34,1.36,.64,1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Loading ─────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(15,17,23,.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
}
.loading-overlay.active { display: flex; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: rgba(255,255,255,.7); font-size: 13px; }

/* ── Inline edit ─────────────────────────────────── */
.inline-edit {
  border: none; background: transparent;
  font-size: inherit; font-family: inherit; font-weight: inherit;
  color: inherit; outline: none; width: 100%;
}
.inline-edit:focus {
  background: var(--primary-dim);
  border-radius: 4px; padding: 2px 6px;
}

/* ── Reminder / automation cards ─────────────────── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 8px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.task-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-sm); }
.task-card.done { opacity: .55; }
.task-checkbox {
  width: 18px; height: 18px; border-radius: 5px;
  border: 2px solid var(--border); background: var(--surface);
  cursor: pointer; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.task-checkbox.checked {
  background: var(--green); border-color: var(--green);
  color: white; font-size: 10px;
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.task-meta { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.task-actions { display: flex; gap: 4px; }

/* ── Monthly targets ─────────────────────────────── */
.targets-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.target-item {
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px;
}
.target-month {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px;
}
.target-input {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13px;
  outline: none; transition: border-color var(--transition);
}
.target-input:focus { border-color: var(--primary); }

/* ── Chatbot dashboard ───────────────────────────── */
.chatbot-kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.chatbot-kpi {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 16px; text-align: center;
}
.chatbot-kpi-value {
  font-family: 'Syne', sans-serif;
  font-size: 24px; font-weight: 800;
  color: var(--text-primary); line-height: 1;
}
.chatbot-kpi-label {
  font-size: 11px; color: var(--text-secondary);
  font-weight: 600; margin-top: 4px;
  text-transform: uppercase; letter-spacing: .4px;
}
.chatbot-charts-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
}

/* ── Webhook cards ───────────────────────────────── */
.webhook-card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px;
}
.webhook-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-dim); display: flex;
  align-items: center; justify-content: center; font-size: 16px;
  flex-shrink: 0;
}
.webhook-url {
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  word-break: break-all;
}
.webhook-event {
  font-size: 11.5px; color: var(--text-secondary); margin-top: 2px;
}

/* ── Automation cards ────────────────────────────── */
.auto-card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.auto-arrow {
  padding: 0 8px; color: var(--text-muted); font-size: 18px; flex-shrink: 0;
}
.auto-block {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.auto-block-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted); margin-bottom: 3px;
}
.auto-block-value { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ── Team ────────────────────────────────────────── */
.team-card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px;
}
.team-avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: 'Syne', sans-serif;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
}

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

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-full { grid-column: span 1; }
  .chatbot-charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .crm-sidebar { transform: translateX(-100%); }
  .crm-sidebar.open { transform: translateX(0); width: 240px; }
  .crm-main { margin-left: 0; }
  .page-content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
  .targets-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-content { max-width: 100% !important; border-radius: var(--radius-lg); }
  .crm-header h1 { display: none; }
  .header-search { max-width: 100%; }
}

/* ── Utilities ───────────────────────────────────── */
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.text-right  { text-align: right; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full      { width: 100%; }
