/* ═══════════════════════════════════════════════════════════════════
   LeadCRM Dashboard – main.css
   Design: Refined dark-capable UI with clean sans-serif typography
   ═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables (Light theme) ─────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #f0f2f8;
  --border: #e2e6f0;
  --text: #1a1d2e;
  --text2: #5a6580;
  --text3: #9aa3bb;
  --primary: #4361ee;
  --primary-dark: #2f4cd8;
  --primary-light: #eef1fd;
  --green: #22c55e;
  --green-light: #dcfce7;
  --red: #ef4444;
  --red-light: #fee2e2;
  --orange: #f97316;
  --orange-light: #ffedd5;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --yellow: #eab308;
  --yellow-light: #fef9c3;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.12);
  --font: 'Plus Jakarta Sans', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 180ms ease;
}

/* ── Dark theme ───────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface2: #22263a;
  --border: #2d3150;
  --text: #e8eaf4;
  --text2: #8a91b0;
  --text3: #545b7a;
  --primary: #5a78f5;
  --primary-dark: #4361ee;
  --primary-light: #1e2442;
  --green-light: #142a1e;
  --red-light: #2a1414;
  --orange-light: #2a1d0e;
  --purple-light: #1e1530;
  --blue-light: #111e35;
  --shadow: 0 1px 4px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

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

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform var(--transition), background var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  padding: 10px 8px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-item i { width: 16px; text-align: center; font-size: 13px; }
.nav-item span:first-of-type { flex: 1; }

.nav-item:hover, .nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.nav-badge {
  background: var(--surface2);
  color: var(--text2);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.nav-badge.urgent { background: var(--red-light); color: var(--red); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text2);
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

.sidebar-version { font-size: 11px; color: var(--text3); }

/* ── Main Wrapper ────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 16px;
}

.topbar-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.2px;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text2);
}

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  width: 200px;
}

.topbar-search input::placeholder { color: var(--text3); }

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: default;
}

.notif-bell {
  position: relative;
  cursor: pointer;
  color: var(--text2);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.notif-bell:hover { background: var(--surface2); color: var(--text); }

.notif-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

/* ── Page content ─────────────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── KPI Cards ───────────────────────────────────────────────────── */
.kpi-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 160px;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); }

.kpi-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.kpi-blue .kpi-icon   { background: var(--blue-light);   color: var(--blue); }
.kpi-green .kpi-icon  { background: var(--green-light);  color: var(--green); }
.kpi-red .kpi-icon    { background: var(--red-light);    color: var(--red); }
.kpi-orange .kpi-icon { background: var(--orange-light); color: var(--orange); }
.kpi-purple .kpi-icon { background: var(--purple-light); color: var(--purple); }

.kpi-info { display: flex; flex-direction: column; }
.kpi-number { font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.kpi-label  { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Charts ──────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-title i { color: var(--text2); }

/* ── Status Cards ─────────────────────────────────────────────────── */
.status-section, .followup-section, .sync-card-section {
  margin-bottom: 24px;
}

.section-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.status-cards-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
}
.status-card:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }

.status-count { font-size: 18px; font-weight: 700; }
.status-pct   { font-size: 11px; color: var(--text3); margin-left: auto; }

/* ── Status Badges (dynamic colors by content) ──────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Dynamically assigned via JS using data-status */
.status-badge[data-status="Did not pick"]               { background: #fef3c7; color: #92400e; }
.status-badge[data-status="Not interested"]             { background: var(--red-light); color: var(--red); }
.status-badge[data-status="Follow up"]                  { background: #dbeafe; color: #1d4ed8; }
.status-badge[data-status="Call scheduled"]             { background: var(--green-light); color: #15803d; }
.status-badge[data-status="Busy"]                       { background: #f3e8ff; color: #7e22ce; }
.status-badge[data-status="Call back later"]            { background: #ffedd5; color: #c2410c; }
.status-badge[data-status="Incoming call not available"]{ background: #e0f2fe; color: #0369a1; }
.status-badge[data-status="Switch off"]                 { background: #f1f5f9; color: #475569; }
.status-badge[data-status="Invalid"]                    { background: #fee2e2; color: #991b1b; }
.status-badge[data-status="Not able to connect"]        { background: #fce7f3; color: #9d174d; }
.status-badge[data-status="Converted"]                  { background: var(--green-light); color: #166534; }
.status-badge[data-status="New"]                        { background: var(--blue-light); color: var(--blue); }
/* Fallback for unknown statuses */
.status-badge:not([data-status])                        { background: var(--surface2); color: var(--text2); }

/* ── Priority badges ─────────────────────────────────────────────── */
.priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.priority-high   { background: var(--red-light);    color: var(--red); }
.priority-medium { background: var(--orange-light);  color: var(--orange); }
.priority-low    { background: var(--green-light);   color: var(--green); }

/* ── Sync Info Card ──────────────────────────────────────────────── */
.sync-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.sync-info-left  { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.sync-info-left i { font-size: 20px; color: var(--primary); }
.sync-info-left strong { display: block; }
.sync-sub { font-size: 11px; color: var(--text2); }

/* ── Leads Page ──────────────────────────────────────────────────── */
.leads-page { display: flex; flex-direction: column; gap: 16px; }

.leads-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.toolbar-form { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; margin-left: auto; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text2);
}
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font); font-size: 13px; width: 200px;
}

select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
}
select:focus { outline: 2px solid var(--primary); }

.results-info { font-size: 13px; color: var(--text2); }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.leads-table thead tr {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.leads-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
  white-space: nowrap;
}

.leads-table th a { color: var(--text2); text-decoration: none; display: flex; align-items: center; gap: 4px; }
.leads-table th a:hover { color: var(--primary); }

.leads-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.lead-row:hover { background: var(--surface2); }
.lead-row:last-child td { border-bottom: none; }

.lead-name-cell { display: flex; align-items: center; gap: 10px; }

/* Avatar circle */
.lead-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.lead-name  { font-weight: 600; font-size: 13px; }
.lead-email { font-size: 11px; color: var(--text2); }

.mono { font-family: var(--mono); font-size: 12px; }

.followup-date { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; }
.followup-date.overdue { color: var(--red); font-weight: 600; }
.followup-date.today   { color: var(--orange); font-weight: 600; }

.call-count {
  background: var(--surface2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
}

.col-actions { text-align: right; width: 100px; }

.action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 11px;
  transition: all var(--transition);
  margin-left: 2px;
}
.action-btn:hover        { background: var(--surface2); color: var(--text); }
.action-edit:hover       { border-color: var(--primary); color: var(--primary); }
.action-delete:hover     { border-color: var(--red); color: var(--red); }

.empty-state {
  text-align: center;
  padding: 48px 24px !important;
  color: var(--text3);
}
.empty-state i { font-size: 32px; display: block; margin-bottom: 12px; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 4px;
}

.page-btn {
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  text-decoration: none;
}
.page-dots { padding: 0 6px; color: var(--text3); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--surface2); text-decoration: none; color: var(--text); }

.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { filter: brightness(0.9); text-decoration: none; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  background: none; border: none; cursor: pointer; color: var(--text2);
  padding: 4px; border-radius: 4px; transition: all var(--transition);
}
.btn-icon:hover { background: var(--surface2); color: var(--red); }

/* ── Follow-ups page ────────────────────────────────────────────── */
.followup-cards { display: flex; flex-direction: column; gap: 10px; }

.followup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.followup-card:hover { border-color: var(--primary); }

.followup-overdue { border-left: 3px solid var(--red); }
.followup-today   { border-left: 3px solid var(--orange); }
.followup-upcoming{ border-left: 3px solid var(--blue); }

.fc-left  { flex-shrink: 0; }
.fc-body  { flex: 1; }
.fc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

.fc-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.fc-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--text2);
}
.fc-meta span { display: flex; align-items: center; gap: 4px; }
.fc-notes {
  margin-top: 6px; font-size: 12px; color: var(--text2);
  background: var(--surface2); border-radius: 4px; padding: 6px 10px;
}
.fc-date { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 4px; }
.fc-actions { display: flex; gap: 6px; margin-top: 4px; }

.tag-today   { background: var(--orange-light); color: var(--orange); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.tag-overdue { background: var(--red-light);    color: var(--red);    padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }

.empty-state-inline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  color: var(--text2);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.empty-state-inline i { font-size: 18px; color: var(--green); }

/* ── Upload page ─────────────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.upload-card-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.upload-card-header h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.upload-card-header p  { font-size: 12px; color: var(--text2); }

.upload-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.upload-icon.google { background: #fce8e6; color: #d93025; }
.upload-icon.file   { background: var(--blue-light); color: var(--blue); }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text2);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.dropzone-icon { font-size: 32px; display: block; margin-bottom: 10px; color: var(--text3); }
.dropzone p    { font-size: 13px; margin: 4px 0; }
.dropzone-sub  { color: var(--text3); font-size: 12px; }
.dropzone-hint { font-size: 11px !important; color: var(--text3); margin-top: 8px !important; }

.file-selected {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 12px;
  font-size: 13px;
}
.file-selected i { color: var(--primary); }

.upload-result {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.upload-result.success { background: var(--green-light); color: #166534; }
.upload-result.error   { background: var(--red-light);   color: var(--red); }

.setup-instructions {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.setup-instructions summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.setup-instructions ol { padding: 0 16px 16px 32px; font-size: 12px; color: var(--text); line-height: 1.8; }
.setup-instructions code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-family: var(--mono); font-size: 11px; }

.info-box {
  background: var(--blue-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  margin-top: 8px;
  color: var(--text);
}

.sync-status-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 12px 0; font-size: 12px;
}

.last-sync-info {
  margin-top: 14px; font-size: 12px; color: var(--text2);
  display: flex; align-items: center; gap: 6px;
}

.tag {
  background: var(--surface2); color: var(--text2);
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px;
}
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }

/* ── Settings page ────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.settings-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.info-table td:first-child { color: var(--text2); width: 120px; }
.info-table tr:last-child td { border-bottom: none; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 22px; transition: var(--transition);
}
.slider:before {
  content: ''; position: absolute;
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: var(--transition);
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-md { max-width: 640px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-size: 16px; padding: 4px;
  border-radius: 4px; transition: all var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body { padding: 20px; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input[type="text"], input[type="email"], input[type="url"],
input[type="number"], input[type="date"], textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

textarea { resize: vertical; }

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px;
}

/* Lead detail in modal */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.detail-item label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; display: block; margin-bottom: 3px; }
.detail-item span  { font-size: 13px; color: var(--text); }

.notes-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.note-item {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12px;
}
.note-item .note-meta { font-size: 10px; color: var(--text3); margin-top: 4px; }

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  min-width: 240px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red);   }
.toast-info    { border-left: 3px solid var(--blue);  }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Code block ──────────────────────────────────────────────────── */
.code-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* ── Alert ───────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: var(--green-light); color: #166534; }
.alert-error   { background: var(--red-light);   color: var(--red); }
.alert-info    { background: var(--blue-light);  color: #1e40af; }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-muted  { color: var(--text2); }
.text-sm     { font-size: 12px; }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 16px; }

.loading-spinner { text-align: center; padding: 32px; color: var(--text2); font-size: 13px; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .charts-row { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .kpi-row { gap: 10px; }
  .kpi-card { min-width: 130px; }
  .topbar-search input { width: 130px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .leads-toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-right { margin-left: 0; }
  .followup-card { flex-direction: column; }
  .fc-right { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
}

/* ── Upload result states (generated by upload.js) ──────────────── */
.upload-result {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.result-success {
  background: rgba(34,197,94,0.08);
  border-color: rgba(34,197,94,0.3);
  color: #16a34a;
}
[data-theme="dark"] .result-success {
  color: #4ade80;
}
.result-error {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
  color: #dc2626;
}
[data-theme="dark"] .result-error {
  color: #f87171;
}

/* ── Sync status row on upload page ─────────────────────────────── */
.sync-status-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text1);
}

/* ── mt-* utilities ──────────────────────────────────────────────── */
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 24px; }
