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

:root {
  --blue: #2563EB;
  --blue-light: #EFF6FF;
  --blue-text: #1D4ED8;
  --green: #16A34A;
  --green-light: #F0FDF4;
  --green-text: #15803D;
  --red: #DC2626;
  --red-light: #FEF2F2;
  --red-text: #B91C1C;
  --amber: #D97706;
  --amber-light: #FFFBEB;
  --amber-text: #B45309;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-900);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  border-bottom: 1px solid var(--gray-100);
}

nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--gray-50); color: var(--gray-700); }
.nav-item.active { background: var(--blue-light); color: var(--blue-text); }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--gray-100);
}

.export-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-500);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.export-btn svg { width: 16px; height: 16px; }
.export-btn:hover { background: var(--gray-50); color: var(--gray-700); }

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: calc(100vw - var(--sidebar-w));
}

.view { display: none; }
.view.active { display: block; }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--gray-900); }
.page-sub { font-size: 13px; color: var(--gray-400); margin-top: 2px; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-primary:hover { background: var(--blue-text); }

.btn-ghost {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.btn-ghost:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger:hover { background: var(--red-text); }

/* ── DASHBOARD HERO ── */
.dash-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563EB 100%);
  border-radius: 16px;
  padding: 28px 32px;
  margin-bottom: 20px;
  color: #fff;
}
.dash-greeting { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; margin-bottom: 6px; }
.dash-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; color: #fff; }
.dash-sub { font-size: 13px; opacity: 0.6; margin: 0; }
.dash-hero .btn-primary { background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.3); color: #fff; white-space: nowrap; flex-shrink: 0; }
.dash-hero .btn-primary:hover { background: rgba(255,255,255,0.28); }

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon-wrap {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap svg { width: 20px; height: 20px; }
.stat-icon-blue  { background: #EFF6FF; color: #2563EB; }
.stat-icon-green { background: #F0FDF4; color: #16A34A; }
.stat-icon-red   { background: #FEF2F2; color: #DC2626; }
.stat-icon-amber { background: #FFFBEB; color: #D97706; }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 11.5px; font-weight: 500; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1.1; margin-bottom: 8px; }
.stat-bar-wrap { height: 4px; background: var(--gray-100); border-radius: 4px; margin-bottom: 5px; overflow: hidden; }
.stat-bar { height: 4px; border-radius: 4px; transition: width 0.5s ease; }
.stat-bar-green { background: #16A34A; }
.stat-bar-red   { background: #DC2626; }
.stat-bar-amber { background: #D97706; }
.stat-pct { font-size: 11.5px; color: var(--gray-400); font-weight: 500; }

.stat-total .stat-value { color: #2563EB; }

/* ── DASHBOARD ROW ── */
.dash-row { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-link { background: none; border: none; color: var(--blue); font-size: 12.5px; font-weight: 500; cursor: pointer; padding: 0; }
.section-link:hover { text-decoration: underline; }

/* ── PIPELINE CARD ── */
.pipeline-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.donut-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-total { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.donut-label { font-size: 11px; color: var(--gray-400); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.pipeline-legend { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--gray-500); }
.legend-val { font-weight: 600; color: var(--gray-900); }

/* ── TABLE ── */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.table-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; min-width: 640px; }

thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--gray-100); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--gray-700);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-row {
  text-align: center;
  padding: 48px 0;
  color: var(--gray-400);
  font-size: 14px;
  max-width: none;
}

/* ── STATUS BADGES ── */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-interested { background: var(--green-light); color: var(--green-text); }
.badge-not { background: var(--red-light); color: var(--red-text); }
.badge-na { background: var(--amber-light); color: var(--amber-text); }

/* ── STATUS DROPDOWN ── */
select {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-700);
  cursor: pointer;
  font-family: inherit;
  min-width: 130px;
}
select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* delete icon button */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-300);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, background 0.1s;
}
.icon-btn:hover { color: var(--red); background: var(--red-light); }
.icon-btn svg { width: 16px; height: 16px; }

.td-remarks { min-width: 160px; max-width: 220px; }
.remarks-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--gray-700);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
}
.remarks-input:hover { border-color: var(--gray-200); background: var(--gray-50); }
.remarks-input:focus { outline: none; border-color: var(--blue); background: #fff; }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--gray-400);
}
.search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--gray-900);
}
.search-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }

.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-tab {
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  background: #fff;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.1s;
}
.filter-tab:hover { border-color: var(--gray-300); color: var(--gray-700); }
.filter-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── ADD LEAD VIEW ── */
.add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.form-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.form-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
}
.form-card-title svg { width: 18px; height: 18px; color: var(--gray-400); flex-shrink: 0; }

textarea {
  width: 100%;
  min-height: 280px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: 'Inter', monospace;
  color: var(--gray-700);
  resize: vertical;
  line-height: 1.6;
}
textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--gray-500);
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--gray-900);
  background: #fff;
  min-width: 0;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }

.field-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.field-sm { min-width: 100px; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: #fff;
  font-size: 13.5px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-900); margin-bottom: 10px; }
.modal-body { font-size: 13.5px; color: var(--gray-500); margin-bottom: 22px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .dash-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .add-grid { grid-template-columns: 1fr; }
  .dash-hero { padding: 20px 20px; }
}
@media (max-width: 640px) {
  .main { padding: 16px; margin-left: 0; max-width: 100vw; }
  .sidebar { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
