/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #2563EB;
  --blue-light: #EFF6FF;
  --blue-dark:  #1D4ED8;
  --green:      #16A34A;
  --green-light:#F0FDF4;
  --amber:      #D97706;
  --amber-light:#FFFBEB;
  --red:        #DC2626;
  --red-light:  #FEF2F2;
  --purple:     #7C3AED;
  --purple-light:#F5F3FF;

  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --transition: 0.18s ease;
}

html, body { height: 100%; font-family: 'Inter', sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

a { text-decoration: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ═══════════════════════════════════════════════
   PAGE SYSTEM
═══════════════════════════════════════════════ */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════ */
.login-split { display: flex; width: 100%; min-height: 100vh; }

.login-brand {
  flex: 1;
  background: linear-gradient(135deg, #14532D 0%, #16A34A 60%, #4ADE80 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 60px 48px;
}
.brand-inner { max-width: 420px; color: white; }
.brand-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }
.brand-logo svg { width: 40px; height: 40px; }
.brand-logo span { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.brand-headline { font-size: 42px; font-weight: 700; line-height: 1.15; letter-spacing: -1px; margin-bottom: 20px; }
.brand-sub { font-size: 16px; color: rgba(255,255,255,0.75); line-height: 1.6; margin-bottom: 48px; }
.brand-stats { display: flex; gap: 32px; }
.bstat { display: flex; flex-direction: column; gap: 4px; }
.bstat-num { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.bstat-label { font-size: 12px; color: rgba(255,255,255,0.65); text-transform: uppercase; letter-spacing: 0.5px; }

.login-form-side {
  width: 460px; display: flex; align-items: center; justify-content: center;
  padding: 48px 40px; background: white;
}
.login-form-box { width: 100%; }
.login-form-box h2 { font-size: 26px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.login-sub { color: var(--gray-500); margin-bottom: 32px; font-size: 14px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--gray-400); text-align: center; font-family: 'JetBrains Mono', monospace; }

.input-eye { position: relative; }
.input-eye input { padding-right: 44px; width: 100%; }
.eye-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); padding: 4px; }
.eye-btn svg { width: 18px; height: 18px; display: block; }

/* ═══════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; font-size: 13px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; outline: none; transition: border-color var(--transition), box-shadow var(--transition);
  background: white; color: var(--gray-800);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  transition: all var(--transition); white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: white; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803D; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-warning { background: var(--amber); color: white; }
.btn-warning:hover { background: #B45309; }
.btn-ghost { color: var(--gray-600); padding: 8px 12px; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ═══════════════════════════════════════════════
   ALERTS
═══════════════════════════════════════════════ */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #FECACA; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #BBF7D0; }

/* ═══════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════ */
#page-app { flex-direction: row; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--gray-900);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform var(--transition);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; color: white; font-weight: 700; font-size: 16px; }
.sidebar-logo svg { width: 32px; height: 32px; }
.sidebar-close { color: var(--gray-400); font-size: 16px; display: none; }

.sidebar-nav { flex: 1; padding: 16px 8px; overflow-y: auto; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-500); padding: 12px 8px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--gray-400);
  font-size: 14px; font-weight: 500; margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--blue); color: white; }

.sidebar-footer {
  padding: 16px; border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.user-chip { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue);
  color: white; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--gray-500); text-transform: capitalize; }
.btn-logout { color: var(--gray-500); padding: 6px; border-radius: 6px; flex-shrink: 0; }
.btn-logout:hover { color: white; background: rgba(255,255,255,0.08); }
.btn-logout svg { width: 18px; height: 18px; display: block; }

.main-wrap { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  height: var(--topbar-h); background: white; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 16px; padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.hamburger { display: none; color: var(--gray-600); padding: 6px; }
.hamburger svg { width: 22px; height: 22px; display: block; }
.topbar-title { font-size: 17px; font-weight: 700; color: var(--gray-900); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { flex: 1; padding: 28px 24px; }

/* ═══════════════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }

.stat-card {
  background: white; border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--blue-light); color: var(--blue); }
.stat-icon.green  { background: var(--green-light); color: var(--green); }
.stat-icon.amber  { background: var(--amber-light); color: var(--amber); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-num { font-size: 28px; font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ═══════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════ */
.card {
  background: white; border-radius: var(--radius);
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ═══════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500);
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ═══════════════════════════════════════════════
   BADGES / STATUS
═══════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge-open      { background: var(--blue-light);   color: var(--blue); }
.badge-follow-up { background: var(--amber-light);  color: var(--amber); }
.badge-rescheduled{ background: var(--purple-light); color: var(--purple); }
.badge-closed    { background: var(--gray-100);     color: var(--gray-500); }
.badge-admin     { background: var(--red-light);    color: var(--red); }
.badge-manager   { background: var(--amber-light);  color: var(--amber); }
.badge-executive { background: var(--green-light);  color: var(--green); }

/* ═══════════════════════════════════════════════
   LEADS PAGE
═══════════════════════════════════════════════ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: gap; gap: 12px; }
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--gray-900); }

.filters-bar {
  background: white; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 14px 16px; display: flex; gap: 12px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); }
.search-box input { padding-left: 36px; width: 100%; border: 1.5px solid var(--gray-200); border-radius: 8px; padding-top: 8px; padding-bottom: 8px; outline: none; }
.search-box input:focus { border-color: var(--blue); }
.filter-select { padding: 8px 12px; border: 1.5px solid var(--gray-200); border-radius: 8px; outline: none; color: var(--gray-700); }
.filter-select:focus { border-color: var(--blue); }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-top: 1px solid var(--gray-100); }
.pagination-info { font-size: 13px; color: var(--gray-500); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
  padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: 1.5px solid var(--gray-200); background: white; color: var(--gray-700);
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.page-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Lead detail panel */
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Timeline */
.timeline { list-style: none; padding: 0; }
.timeline li { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 15px; top: 28px; bottom: 0; width: 1px; background: var(--gray-200); }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--gray-100); border: 2px solid var(--gray-300); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tl-dot svg { width: 14px; height: 14px; color: var(--gray-500); }
.tl-body { flex: 1; padding-top: 4px; }
.tl-text { font-size: 14px; color: var(--gray-700); }
.tl-time { font-size: 12px; color: var(--gray-400); margin-top: 3px; }

/* Remarks */
.remark-item { padding: 12px; background: var(--gray-50); border-radius: 8px; margin-bottom: 10px; border-left: 3px solid var(--blue); }
.remark-text { font-size: 14px; color: var(--gray-700); }
.remark-meta { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ═══════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: white; border-radius: 14px; width: 100%; max-width: 540px;
  box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column;
}
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 17px; font-weight: 700; color: var(--gray-900); }
.modal-close { font-size: 18px; color: var(--gray-400); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }

/* Wide modal */
.modal.modal-wide { max-width: 760px; }

/* ═══════════════════════════════════════════════
   REPORTS
═══════════════════════════════════════════════ */
.reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.progress-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-label { width: 110px; font-size: 13px; color: var(--gray-600); flex-shrink: 0; text-transform: capitalize; }
.progress-track { flex: 1; height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.progress-count { width: 32px; text-align: right; font-size: 13px; font-weight: 600; color: var(--gray-700); font-family: 'JetBrains Mono', monospace; }

/* ═══════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════ */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--gray-900); color: white; padding: 12px 20px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); max-width: 360px;
  animation: slideUp 0.25s ease;
}
.toast.toast-success { background: var(--green); }
.toast.toast-error   { background: var(--red); }
.toast.toast-warning {
  background: #D97706;
  color: #fff;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════════ */
.empty-state { padding: 56px 20px; text-align: center; color: var(--gray-400); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--gray-400); font-size: 14px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--gray-200); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .login-brand { display: none; }
  .login-form-side { width: 100%; padding: 40px 24px; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .hamburger { display: block; }
  .main-wrap { margin-left: 0; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}


.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-box {
  background: white;
  width: 400px;
  border-radius: 10px;
  padding: 20px;
}

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

.modal-body input {
  width:100%;
  padding:10px;
  margin-top:8px;
}

.modal-footer {
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:20px;
}


/* ── Toggle Switch ── */
.toggle-switch {
  position: relative; display: inline-block;
  width: 42px; height: 24px; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--gray-300); border-radius: 24px;
  transition: background 0.25s;
}
.toggle-slider::before {
  content: '';
  position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: white; border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }