/* ===== Base & Font ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple-900: #3b0764;
  --purple-800: #4c1d95;
  --purple-700: #6d28d9;
  --purple-600: #7c3aed;
  --purple-500: #8b5cf6;
  --purple-400: #a78bfa;
  --purple-200: #ddd6fe;
  --purple-100: #ede9fe;
  --purple-50:  #f5f3ff;
  --white:      #ffffff;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --green:      #16a34a;
  --red:        #dc2626;
  --orange:     #d97706;
  --blue:       #2563eb;
  --radius:     12px;
  --shadow:     0 4px 24px rgba(109,40,217,.10);
  --shadow-sm:  0 2px 8px rgba(109,40,217,.08);
  --transition: .2s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
}

body {
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--purple-50); }
::-webkit-scrollbar-thumb { background: var(--purple-400); border-radius: 99px; }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 240px;
  background: linear-gradient(160deg, var(--purple-900) 0%, var(--purple-700) 100%);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 28px 24px 20px;
  font-size: 20px; font-weight: 700; color: var(--white);
  letter-spacing: -.3px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo span { color: var(--purple-400); }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--purple-400); text-transform: uppercase;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,.75); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all var(--transition); margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.15);
  color: var(--white);
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

/* ===== Top Bar ===== */
.topbar {
  position: fixed; top: 0; left: 240px; right: 0; height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 90;
  box-shadow: 0 1px 8px rgba(109,40,217,.06);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--purple-800); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ===== Notification Bell ===== */
.notif-bell {
  position: relative; cursor: pointer;
  background: var(--purple-50); border: none;
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--purple-600); transition: all var(--transition);
}
.notif-bell:hover { background: var(--purple-100); }
.notif-badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--red); color: var(--white);
  width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white);
}
.notif-dropdown {
  position: absolute; top: 52px; right: 0;
  width: 340px; background: var(--white);
  border-radius: var(--radius); box-shadow: 0 8px 40px rgba(0,0,0,.15);
  border: 1px solid var(--gray-200); display: none;
  overflow: hidden; z-index: 200;
}
.notif-dropdown.show { display: block; }
.notif-header {
  padding: 14px 18px;
  font-weight: 700; font-size: 14px; color: var(--purple-800);
  border-bottom: 1px solid var(--gray-200);
  background: var(--purple-50);
}
.notif-item {
  padding: 12px 18px; border-bottom: 1px solid var(--gray-100);
  font-size: 13px; line-height: 1.5;
}
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ===== Toast Popup (top-right) ===== */
#toast-container {
  position: fixed; top: 80px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  min-width: 280px; max-width: 380px;
  background: var(--white); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(109,40,217,.18);
  border-left: 4px solid var(--purple-600);
  padding: 14px 18px; font-size: 14px;
  display: flex; align-items: flex-start; gap: 12px;
  animation: slideIn .3s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--orange); }
.toast-icon { flex-shrink: 0; margin-top: 2px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; color: var(--gray-800); }
.toast-msg   { color: var(--gray-600); margin-top: 2px; font-size: 13px; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 18px; line-height: 1; padding: 0; }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ===== Main Content ===== */
.main { margin-left: 240px; padding-top: 64px; min-height: 100vh; }
.page { padding: 28px 28px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--purple-900); }

/* ===== Stats Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200); transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--gray-400); margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--purple-800); }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--purple-600); color: var(--white); }
.btn-primary:hover { background: var(--purple-700); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,58,237,.35); }
.btn-outline   { background: transparent; color: var(--purple-700); border: 1.5px solid var(--purple-300, #c4b5fd); }
.btn-outline:hover { background: var(--purple-50); }
.btn-danger    { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-green     { background: var(--green); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ===== Card / Panel ===== */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--purple-50);
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--purple-800); }
.card-body { padding: 20px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--purple-50); padding: 12px 14px;
  text-align: left; font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--purple-800); white-space: nowrap;
  border-bottom: 2px solid var(--purple-200);
}
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background var(--transition); }
tbody tr:hover { background: var(--purple-50); }
tbody td { padding: 12px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ===== Stage Badge ===== */
.stage-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ===== Form ===== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 13px; font-weight: 600; color: var(--gray-600); }
input, select, textarea {
  padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  transition: border var(--transition), box-shadow var(--transition);
  background: var(--white); color: var(--gray-800);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(139,92,246,.15);
}
textarea { resize: vertical; min-height: 90px; }
.search-box { position: relative; }
.search-box input { padding-left: 38px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

/* ===== Pipeline Kanban ===== */
.pipeline-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.pipeline-col {
  min-width: 240px; width: 240px;
  background: var(--gray-100); border-radius: var(--radius);
  overflow: hidden; flex-shrink: 0;
}
.pipeline-col-header {
  padding: 12px 14px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.pipeline-col-header .count {
  background: rgba(0,0,0,.12); color: var(--white);
  padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
}
.pipeline-cards { padding: 10px; min-height: 80px; display: flex; flex-direction: column; gap: 8px; }
.lead-card {
  background: var(--white); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200); cursor: pointer;
  transition: all var(--transition);
}
.lead-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--purple-300, #c4b5fd); }
.lead-card .lead-name { font-weight: 700; font-size: 14px; color: var(--gray-800); }
.lead-card .lead-meta { font-size: 12px; color: var(--gray-400); margin-top: 3px; }
.lead-card .lead-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
  z-index: 500; display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 700px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { transform: scale(.94); opacity:0; } to { transform: scale(1); opacity:1; } }
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h2 { font-size: 18px; font-weight: 700; color: var(--purple-900); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ===== Import Box ===== */
.import-zone {
  border: 2px dashed var(--purple-300, #c4b5fd);
  border-radius: var(--radius); padding: 40px;
  text-align: center; cursor: pointer;
  transition: all var(--transition); background: var(--purple-50);
}
.import-zone:hover, .import-zone.drag { border-color: var(--purple-600); background: var(--purple-100); }
.import-zone svg { color: var(--purple-600); margin-bottom: 12px; }
.import-zone p { font-size: 15px; color: var(--purple-700); font-weight: 600; }
.import-zone small { color: var(--gray-400); font-size: 13px; }

/* ===== Hamburger (mobile) ===== */
.hamburger { display: none; background: none; border: none; cursor: pointer; color: var(--purple-700); }

/* ===== Pagination ===== */
.pagination { display: flex; align-items: center; gap: 6px; padding: 16px 20px; border-top: 1px solid var(--gray-200); }
.page-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--gray-200);
  background: var(--white); cursor: pointer; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; color: var(--gray-600);
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--purple-600); color: var(--white); border-color: var(--purple-600); }

/* ===== Responsive ===== */
@media(max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; padding: 0 16px; }
  .main  { margin-left: 0; }
  .hamburger { display: flex; }
  .page { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media(max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .pipeline-board { flex-direction: column; }
  .pipeline-col { width: 100%; min-width: unset; }
}

/* ===== Utilities ===== */
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.text-sm { font-size: 13px; } .text-xs { font-size: 11px; }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }
.overlay-sidebar { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:99; display:none; }
.overlay-sidebar.show { display:block; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select, .filter-bar input { max-width: 180px; }
