/* ===================================================
   LOAN CRM — MINIMAL UI v2
   =================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --accent: #4f6ef7;
  --accent-dark: #3b56d6;
  --accent-light: #eef1fe;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --bg: #f5f6fa;
  --white: #ffffff;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #0891b2;
  --info-bg: #e0f2fe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-logo {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 12px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  border-radius: 0;
  transition: all .15s;
  position: relative;
}
.sidebar-link:hover { color: var(--text); background: var(--bg); }
.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 14px; }
.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.user-info:hover { background: var(--bg); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: capitalize;
}

/* ── TOPBAR ──────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  z-index: 100;
}

.topbar-title { font-weight: 600; font-size: 15px; flex: 1; }
.menu-toggle { display: none; background: none; border: none; font-size: 18px; color: var(--text); cursor: pointer; padding: 4px 8px; }

/* ── MAIN CONTENT ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 24px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── OVERLAY (mobile) ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

/* ── PAGE HEADER ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
}
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; color: var(--text); }
.stat-icon-wrap {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  margin-bottom: 4px;
}
.stat-card.blue .stat-icon-wrap   { background: var(--accent-light); color: var(--accent); }
.stat-card.green .stat-icon-wrap  { background: var(--success-bg); color: var(--success); }
.stat-card.amber .stat-icon-wrap  { background: var(--warning-bg); color: var(--warning); }
.stat-card.red .stat-icon-wrap    { background: var(--danger-bg); color: var(--danger); }
.stat-card.cyan .stat-icon-wrap   { background: var(--info-bg); color: var(--info); }
.stat-card.purple .stat-icon-wrap { background: #f3e8ff; color: #7c3aed; }

/* ── TABLES ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #fafafa;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-blue   { background: var(--accent-light); color: var(--accent); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-amber  { background: var(--warning-bg); color: var(--warning); }
.badge-red    { background: var(--danger-bg); color: var(--danger); }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-cyan   { background: var(--info-bg); color: var(--info); }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-ghost     { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger    { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-success   { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #15803d; }

.btn-warning   { background: var(--warning); color: white; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 6px 8px; }
.btn-icon.btn-sm { padding: 4px 6px; }

/* Click to call */
.btn-call {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
}
.btn-call:hover { background: var(--success); color: white; border-color: var(--success); }

/* ── FORMS ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
label.form-label .req { color: var(--danger); margin-left: 2px; }

input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea { resize: vertical; min-height: 80px; }
input::placeholder, textarea::placeholder { color: #9ca3af; }
input[type="color"] { padding: 3px; height: 36px; cursor: pointer; }

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

.form-section { margin-bottom: 24px; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── FILTERS ─────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filter-row input, .filter-row select {
  width: auto;
  flex: 1;
  min-width: 120px;
  max-width: 200px;
}
.filter-row input[type="text"] { max-width: 240px; }

/* ── TOAST / FLASH ───────────────────────────────── */
.toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  animation: slideIn .2s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.success i { color: var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.error i { color: var(--danger); }
.toast-close { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }

@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── TABS ────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state i { font-size: 36px; margin-bottom: 12px; opacity: 0.4; display: block; }
.empty-state h6 { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 13px; margin: 0; }

/* ── TIMELINE ────────────────────────────────────── */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 16px;
}
.timeline-dot {
  position: absolute;
  left: -28px; top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--white);
  background: var(--accent);
}
.timeline-dot.green  { background: var(--success); }
.timeline-dot.amber  { background: var(--warning); }
.timeline-dot.red    { background: var(--danger); }
.timeline-dot.gray   { background: #9ca3af; }
.timeline-date { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.timeline-body { font-size: 13px; }

/* ── LEAD DETAIL HEADER ──────────────────────────── */
.lead-hero {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.lead-hero-name { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.lead-hero-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ── FOLLOW-UP INDICATORS ────────────────────────── */
.fu-overdue { border-left: 3px solid var(--danger) !important; }
.fu-today   { border-left: 3px solid var(--warning) !important; }
.fu-future  { border-left: 3px solid #e5e7eb !important; }
.fu-done    { opacity: 0.6; }

/* ── LIST ITEMS ──────────────────────────────────── */
.list-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: background .15s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #fafbff; }
.list-item-link { cursor: pointer; }

/* ── MOBILE BOTTOM NAV ───────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 300;
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
.mobile-nav-items {
  display: flex;
  justify-content: space-around;
}
.mobile-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 8px;
  transition: color .15s;
  min-width: 52px;
}
.mobile-nav-link i { font-size: 20px; }
.mobile-nav-link.active { color: var(--accent); }

/* ── LOGIN PAGE ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .icon {
  width: 52px; height: 52px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  color: white;
  font-size: 22px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; margin-bottom: 3px; }
.login-logo p { font-size: 13px; color: var(--muted); }

/* ── MISC ─────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-600 { font-weight: 600; }
.gap-8 { gap: 8px; }
.gap-6 { gap: 6px; }

.source-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.source-facebook { background: #dbeafe; color: #1d4ed8; }
.source-whatsapp { background: #dcfce7; color: #15803d; }
.source-manual   { background: #f3f4f6; color: #374151; }
.source-website  { background: #fef3c7; color: #92400e; }
.source-referral { background: #f3e8ff; color: #6b21a8; }

.progress-bar-wrap { background: #f3f4f6; border-radius: 20px; height: 6px; overflow: hidden; margin-top: 4px; }
.progress-bar-fill { height: 100%; border-radius: 20px; background: var(--accent); transition: width .3s; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; padding-bottom: 72px; }
  .menu-toggle { display: block; }
  .mobile-nav { display: block; }
  .topbar-title { font-size: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 576px) {
  .main-content { padding: 14px; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .filter-row input, .filter-row select { max-width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .lead-hero { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 22px; }
}

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.pagination-info {
  font-size: 13px;
  color: var(--muted);
}
.pagination-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; pointer-events: none; }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-btn.ellipsis { border: none; background: transparent; pointer-events: none; color: var(--muted); }

/* per-page selector */
.per-page-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.per-page-wrap select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 640px) {
  .pagination { justify-content: center; }
  .pagination-info { width: 100%; text-align: center; }
}
