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

:root {
  /* Brand Colors */
  --green-primary: #1B6B45;
  --green-dark: #145236;
  --green-light: #24915E;
  --green-50: #f0faf5;
  --green-100: #d1f0e0;
  --green-200: #a3e1c1;

  /* Backgrounds */
  --bg-primary: #f8faf9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-hover: #f0f4f2;
  --bg-sidebar-active: #e8f0ec;
  --bg-glass: rgba(27,107,69,0.04);

  /* Borders */
  --border: #eaeeeb;
  --border-hover: #cbe0d5;
  --border-focus: #1B6B45;

  /* Text */
  --text-primary: #121b16;
  --text-secondary: #405047;
  --text-muted: #80968a;
  --text-sidebar: #304037;
  --text-sidebar-muted: #70857a;

  /* Status */
  --green-500: #16a34a;
  --yellow-500: #d97706;
  --red-500: #dc2626;
  --blue-500: #2563eb;
  --orange-500: #ea580c;
  --cyan-500: #0891b2;
  --purple-500: #7c3aed;

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --shadow-green: 0 4px 20px rgba(27,107,69,0.2);
  --sidebar-w: 240px;
  --header-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aac4b8; }

/* ===== LAYOUT ===== */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.3s ease;
  box-shadow: none;
  border-right: 1px solid var(--border);
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo .brand {
  display: block;
  flex-shrink: 0;
}
.sidebar-logo .brand img {
  display: block;
  height: 140px;
  width: 140px;
  margin-top: -42px;
  margin-bottom: -42px;
  margin-left: -22px;
  object-fit: contain;
}

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  padding: 12px 24px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  position: relative;
  margin: 2px 12px;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--green-primary); }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--green-primary); font-weight: 600; }
.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sidebar-muted);
  transition: color 0.18s;
}
.nav-item:hover .nav-icon, .nav-item.active .nav-icon {
  color: var(--green-primary);
}

.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--green-50);
  border: 1.5px solid var(--green-200);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--green-primary); flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .user-role { font-size: 11px; color: var(--text-sidebar-muted); text-transform: capitalize; }
.logout-btn { color: var(--text-sidebar-muted); cursor: pointer; padding: 4px; border-radius: 6px; transition: color 0.2s, background-color 0.2s; background: none; border: none; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.logout-btn:hover { color: var(--red-500); background-color: #fef2f2; }

/* ===== MAIN AREA ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 18px; font-weight: 800; flex: 1; color: var(--text-primary); }
.topbar-subtitle { font-size: 12px; color: var(--text-muted); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { flex: 1; overflow-y: auto; padding: 28px; background: var(--bg-primary); }

/* ===== CARDS ===== */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-green); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-card.green::before { background: linear-gradient(90deg, var(--green-primary), var(--green-light)); }
.kpi-card.purple::before { background: linear-gradient(90deg, var(--green-primary), #24915E); }
.kpi-card.cyan::before { background: linear-gradient(90deg, var(--cyan-500), var(--green-light)); }
.kpi-card.yellow::before { background: linear-gradient(90deg, var(--yellow-500), #f59e0b); }
.kpi-card.red::before { background: linear-gradient(90deg, var(--red-500), #f97316); }
.kpi-icon { font-size: 24px; margin-bottom: 10px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; font-weight: 500; }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all 0.18s;
  text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn-primary {
  background: var(--green-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(27,107,69,0.3);
}
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); box-shadow: var(--shadow-green); }
.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-secondary:hover { border-color: var(--green-primary); color: var(--green-primary); background: var(--green-50); }
.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--red-500); color: white; }
.btn-warning { background: var(--yellow-500); color: white; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-purple { background: rgba(27,107,69,0.1); color: var(--green-primary); border: 1px solid rgba(27,107,69,0.2); }
.badge-green { background: rgba(22,163,74,0.1); color: #15803d; border: 1px solid rgba(22,163,74,0.2); }
.badge-yellow { background: rgba(217,119,6,0.1); color: #b45309; border: 1px solid rgba(217,119,6,0.2); }
.badge-red { background: rgba(220,38,38,0.1); color: #b91c1c; border: 1px solid rgba(220,38,38,0.2); }
.badge-cyan { background: rgba(8,145,178,0.1); color: #0e7490; border: 1px solid rgba(8,145,178,0.2); }
.badge-gray { background: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; }
.badge-orange { background: rgba(234,88,12,0.1); color: #c2410c; border: 1px solid rgba(234,88,12,0.2); }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  background: var(--green-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:hover { background: var(--green-50); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 12px 16px; font-size: 13.5px; color: var(--text-secondary); }
tbody td strong { color: var(--text-primary); font-weight: 600; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 11.5px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.form-control {
  width: 100%; padding: 10px 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
  outline: none;
}
.form-control:focus { border-color: var(--green-primary); box-shadow: 0 0 0 3px rgba(27,107,69,0.1); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 24px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.modal-title { font-size: 17px; font-weight: 800; color: var(--text-primary); }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; border-radius: 6px; transition: all 0.18s; }
.modal-close:hover { background: var(--green-50); color: var(--green-primary); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 24px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 16px; }

/* ===== KANBAN ===== */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.kanban-col {
  min-width: 220px; max-width: 240px; flex-shrink: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.kanban-col-header {
  padding: 11px 14px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: white;
}
.kanban-col-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; }
.kanban-col-count {
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-primary);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px;
}
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.kanban-card:hover { border-color: var(--green-primary); transform: translateY(-1px); box-shadow: var(--shadow-green); }
.kanban-card .lead-name { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.kanban-card .lead-biz { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.kanban-card .lead-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 6px; background: var(--green-100); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--green-primary), var(--green-light)); transition: width 0.5s ease; }

/* ===== CHECKLIST ===== */
.checklist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-box {
  width: 20px; height: 20px;
  border: 2px solid var(--border-hover);
  border-radius: 6px;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.checklist-box.checked { background: var(--green-primary); border-color: var(--green-primary); }
.checklist-box.checked::after { content: '✓'; color: white; font-size: 12px; font-weight: 800; }
.checklist-label { font-size: 13.5px; color: var(--text-secondary); }
.checklist-label.checked { text-decoration: line-through; color: var(--text-muted); }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  min-width: 280px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  font-size: 13.5px;
  color: var(--text-primary);
}
.toast.success { border-left: 3px solid var(--green-primary); }
.toast.error { border-left: 3px solid var(--red-500); }
.toast.info { border-left: 3px solid var(--cyan-500); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green-50) 0%, #e8f5ee 50%, white 100%);
}
.login-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(27,107,69,0.04);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-big {
  width: 80px; height: 80px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo .logo-big img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--text-primary); }
.login-logo p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

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

/* ===== SPINNER ===== */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--green-primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ===== MISC ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); z-index: 200; }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-col { min-width: unset; max-width: unset; }
}

/* ===== UTILITIES ===== */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; } .text-muted { color: var(--text-muted); } .text-green { color: var(--green-primary); }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; }
.w-full { width: 100%; } .text-center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
