/* ==========================================================================
   11 CRM — design system
   ========================================================================== */
:root {
  --brand: #4F46E5;
  --brand-600: #4338CA;
  --brand-700: #3730A3;
  --brand-50: #EEF2FF;
  --brand-100: #E0E7FF;
  --accent: #7C3AED;
  --grad: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --muted-2: #94A3B8;
  --line: #E8ECF4;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #0EA5E9;
  --wa: #25D366;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .12);
  --sidebar-w: 264px;
  --topbar-h: 68px;

  --bs-primary: #4F46E5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4F46E5;
  --bs-link-color-rgb: 79, 70, 229;
  --bs-link-hover-color: #3730A3;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: #1E293B;
  --bs-border-color: #E8ECF4;
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--bs-body-color);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { text-decoration: none; }
::selection { background: var(--brand-100); }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 1040;
  width: var(--sidebar-w);
  background: #0B1124;
  background-image: radial-gradient(1200px 400px at -20% -10%, rgba(124, 58, 237, .28), transparent 60%),
                    radial-gradient(800px 300px at 120% 110%, rgba(79, 70, 229, .25), transparent 60%);
  color: #CBD5E1;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 16px; color: #fff; min-height: var(--topbar-h);
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px;
  background: var(--grad); display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 15px; letter-spacing: -.5px;
  box-shadow: 0 6px 18px rgba(79, 70, 229, .45); overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; color: #fff; }
.brand-sub { font-size: 11.5px; color: #94A3B8; white-space: nowrap; }

.sidebar .nav-scroll { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }
.sidebar .nav-scroll::-webkit-scrollbar { width: 6px; }
.sidebar .nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 6px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748B; padding: 18px 12px 8px; font-weight: 600; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: 12px;
  color: #CBD5E1; font-weight: 500; font-size: 14px; position: relative;
  transition: background .15s, color .15s;
}
.side-link i { font-size: 18px; width: 22px; text-align: center; opacity: .9; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: rgba(99, 102, 241, .22); color: #fff; }
.side-link.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: #818CF8;
}
.side-link .count { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.sidebar .user-card {
  margin: 12px; padding: 12px; border-radius: 14px;
  background: rgba(255,255,255,.06); display: flex; align-items: center; gap: 10px;
}
.sidebar .user-card .name { color: #fff; font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.sidebar .user-card .role { font-size: 11.5px; color: #94A3B8; }
.sidebar .user-card a { color: #94A3B8; margin-left: auto; font-size: 18px; }
.sidebar .user-card a:hover { color: #fff; }

.sidebar-backdrop { display: none; }
.sidebar-close {
  display: none; position: absolute; top: 24px; right: 12px; z-index: 2;
  width: 30px; height: 30px; border-radius: 9px; border: 0; place-items: center;
  background: rgba(255,255,255,.08); color: #CBD5E1; font-size: 14px; transition: background .15s, color .15s;
}
.sidebar-close:hover { background: rgba(255,255,255,.16); color: #fff; }
.main { transition: margin-left .25s ease; }
@media (min-width: 992px) {
  .sidebar-close { display: grid; }
  .sidebar .brand { padding-right: 48px; }
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  body.sidebar-collapsed .main { margin-left: 0; }
  body.sidebar-collapsed .menu-toggle { display: inline-grid; }
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: rgba(244, 246, 251, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .page-heading { min-width: 0; }
.topbar h1 { font-size: 20px; font-weight: 700; margin: 0; color: var(--ink); letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar .search {
  margin-left: auto; position: relative; width: min(360px, 32vw);
}
.topbar .search input {
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
  padding: 9px 14px 9px 38px; width: 100%; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.topbar .search input:focus { border-color: #A5B4FC; box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.topbar .search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; display: inline-grid; place-items: center; color: var(--ink-2);
  position: relative; font-size: 18px; transition: all .15s;
}
.icon-btn:hover { color: var(--brand); border-color: #C7D2FE; }
.icon-btn .dot {
  position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 20px; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--bg);
}
.icon-btn .dot:empty, .icon-btn .dot[data-count="0"] { display: none; }
.menu-toggle { display: none; }

.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 38px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center;
}
.avatar.sm { width: 30px; height: 30px; flex-basis: 30px; border-radius: 9px; font-size: 11.5px; }
.avatar.lg { width: 64px; height: 64px; flex-basis: 64px; border-radius: 18px; font-size: 22px; }

.page { padding: 8px 28px 40px; flex: 1; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--card);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--line);
  padding: 16px 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-title { font-size: 15.5px; font-weight: 700; margin: 0; color: var(--ink); }
.card-sub { font-size: 12.5px; color: var(--muted); }
.card-body { padding: 20px; }

.stat-card { padding: 18px 20px; display: flex; flex-direction: row; align-items: center; gap: 16px; height: 100%; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 52px; height: 52px; border-radius: 15px; flex: 0 0 52px;
  display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--c, #4F46E5) 13%, white); color: var(--c, #4F46E5);
}
.stat-value { font-size: 26px; font-weight: 800; color: var(--ink); line-height: 1.1; letter-spacing: -.5px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-card .trend { font-size: 12px; font-weight: 600; }

.hero {
  background: var(--grad); color: #fff; border-radius: 20px; padding: 24px 26px;
  position: relative; overflow: hidden; box-shadow: 0 14px 40px rgba(79, 70, 229, .28);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px;
  border-radius: 50%; background: rgba(255,255,255,.09);
}
.hero::before {
  content: ""; position: absolute; right: 80px; bottom: -90px; width: 200px; height: 200px;
  border-radius: 50%; background: rgba(255,255,255,.07);
}
.hero h2 { font-size: 22px; font-weight: 800; margin: 0 0 4px; letter-spacing: -.3px; }
.hero p { margin: 0; opacity: .88; }
.hero .btn-light { color: var(--brand-700); font-weight: 600; }
.hero > * { position: relative; z-index: 1; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: 12px; }
.btn-primary { background: var(--brand); border-color: var(--brand); box-shadow: 0 4px 12px rgba(79, 70, 229, .25); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-600); border-color: var(--brand-600); }
.btn-primary:active { background: var(--brand-700) !important; border-color: var(--brand-700) !important; }
.btn-grad { background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 18px rgba(79, 70, 229, .32); }
.btn-grad:hover { color: #fff; filter: brightness(1.06); }
.btn-soft { background: var(--brand-50); color: var(--brand); border: 1px solid transparent; }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-700); }
.btn-white { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-white:hover { border-color: #C7D2FE; color: var(--brand); background: #fff; }
.btn-outline-primary { color: var(--brand); border-color: #C7D2FE; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

/* Quick action buttons: call / whatsapp / mail */
.qa { display: inline-flex; gap: 6px; }
.qa-btn {
  width: 36px; height: 36px; border-radius: 11px; display: inline-grid; place-items: center;
  font-size: 16px; border: 0; transition: transform .12s, filter .12s; color: #fff;
}
.qa-btn:hover { transform: translateY(-1px); filter: brightness(1.05); color: #fff; }
.qa-btn.call { background: #2563EB; }
.qa-btn.wa { background: var(--wa); }
.qa-btn.mail { background: #F97316; }
.qa-btn.disabled, .qa-btn[aria-disabled="true"] { background: #E2E8F0; color: #94A3B8; pointer-events: none; }
.qa-lg .qa-btn { width: auto; height: 46px; padding: 0 18px; gap: 8px; display: inline-flex; align-items: center; font-weight: 600; font-size: 14.5px; border-radius: 13px; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: var(--radius-sm); border-color: #DFE4EE; padding: 9px 13px; font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus { border-color: #A5B4FC; box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.form-control[readonly] { background: #F8FAFC; color: var(--muted); }
.form-select { padding-right: 2.25rem; }
.form-control-sm, .form-select-sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.form-select-sm { padding-right: 2rem; }
.form-text { font-size: 12.5px; color: var(--muted); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.input-icon > .form-control { padding-left: 38px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(99,102,241,.15); border-color: #A5B4FC; }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 4px 0 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { margin: 0; --bs-table-hover-bg: #F8FAFF; }
.table > :not(caption) > * > * { padding: 12px 14px; border-bottom-color: #F0F2F7; vertical-align: middle; }
.table thead th {
  background: #F8FAFC; color: var(--muted); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.table thead th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table thead th a:hover { color: var(--brand); }
.table thead tr.filters th { background: #fff; padding: 8px 10px; text-transform: none; letter-spacing: 0; font-weight: 400; top: 41px; }
.table thead tr.filters .form-control, .table thead tr.filters .form-select { min-width: 110px; font-size: 12.5px; padding: 5px 9px; }
.table tbody tr { transition: background .1s; }
.table .lead-name { font-weight: 600; color: var(--ink); }
.table .lead-name:hover { color: var(--brand); }
.table .sub { font-size: 12px; color: var(--muted); }
.table-check { width: 40px; }
.col-hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 30px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, white);
}
.badge-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 30px; font-size: 12px; font-weight: 600; background: #F1F5F9; color: var(--ink-2); }
.chip.green { background: #ECFDF5; color: #047857; }
.chip.red { background: #FEF2F2; color: #B91C1C; }
.chip.amber { background: #FFFBEB; color: #B45309; }
.chip.blue { background: #EFF6FF; color: #1D4ED8; }
.chip.violet { background: var(--brand-50); color: var(--brand-700); }

/* ---------- Lists / reminders ---------- */
.rem-item { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid #F1F3F8; align-items: flex-start; }
.rem-item:last-child { border-bottom: 0; }
.rem-item .when { font-size: 12px; color: var(--muted); }
.rem-item .title { font-weight: 600; color: var(--ink); font-size: 14px; }
.rem-dot { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 38px; font-size: 17px; }
.rem-dot.overdue { background: #FEF2F2; color: var(--danger); }
.rem-dot.today { background: #FFFBEB; color: var(--warning); }
.rem-dot.upcoming { background: #EFF6FF; color: #2563EB; }
.rem-dot.done { background: #ECFDF5; color: var(--success); }

.empty {
  text-align: center; padding: 34px 20px; color: var(--muted);
}
.empty i { font-size: 36px; color: #CBD5E1; display: block; margin-bottom: 8px; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: #EEF0F6; }
.timeline li { display: flex; gap: 14px; padding: 8px 0 14px; position: relative; }
.tl-icon { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 36px; z-index: 1; font-size: 15px; background: var(--brand-50); color: var(--brand); border: 3px solid #fff; }
.tl-icon.call { background: #EFF6FF; color: #2563EB; }
.tl-icon.whatsapp { background: #ECFDF5; color: #16A34A; }
.tl-icon.email { background: #FFF7ED; color: #EA580C; }
.tl-icon.status { background: #F5F3FF; color: #7C3AED; }
.tl-icon.followup, .tl-icon.followup_done { background: #FFFBEB; color: #D97706; }
.tl-icon.duplicate { background: #FEF2F2; color: #DC2626; }
.tl-body { flex: 1; min-width: 0; }
.tl-body .txt { color: var(--ink-2); font-size: 14px; word-wrap: break-word; }
.tl-body .meta { font-size: 12px; color: var(--muted); }

/* Detail list */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 500; font-size: 13px; }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; word-break: break-word; }

/* Mobile lead cards */
.lead-card { display: block; padding: 14px 16px; border-bottom: 1px solid #F1F3F8; color: inherit; }
.lead-card:last-child { border-bottom: 0; }
.lead-card .top { display: flex; align-items: center; gap: 10px; }
.lead-card .nm { font-weight: 700; color: var(--ink); font-size: 15px; }
.lead-card .meta { font-size: 12.5px; color: var(--muted); }

/* Toolbar / filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1; }
.bulkbar {
  display: none; position: sticky; top: calc(var(--topbar-h) + 6px); z-index: 20;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-lg); align-items: center; gap: 10px; flex-wrap: wrap;
}
.bulkbar.show { display: flex; }
.bulkbar .form-select { width: auto; min-width: 150px; }

.pagination { --bs-pagination-border-radius: 10px; --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--ink-2); gap: 4px; }
.pagination .page-link { border-radius: 10px !important; border-color: var(--line); min-width: 36px; text-align: center; font-weight: 600; font-size: 13px; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.auth-art {
  background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art::before, .auth-art::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); }
.auth-art::before { width: 420px; height: 420px; right: -140px; top: -120px; }
.auth-art::after { width: 300px; height: 300px; left: -100px; bottom: -110px; }
.auth-art > * { position: relative; z-index: 1; }
.auth-art h1 { font-size: 38px; font-weight: 800; letter-spacing: -1px; line-height: 1.15; }
.auth-art .feat { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.auth-art .feat i { width: 38px; height: 38px; border-radius: 11px; background: rgba(255,255,255,.16); display: grid; place-items: center; flex: 0 0 38px; font-size: 17px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card { padding: 30px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.auth-card h2 { font-weight: 800; font-size: 24px; letter-spacing: -.4px; color: var(--ink); }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 6px; }

/* Progress */
.progress { height: 12px; border-radius: 20px; background: #EEF0F6; }
.progress-bar { background: var(--grad); border-radius: 20px; }

/* Settings tabs */
.nav-pills .nav-link { border-radius: 10px; color: var(--ink-2); font-weight: 600; font-size: 14px; padding: 9px 14px; }
.nav-pills .nav-link.active { background: var(--brand); }
.logo-preview { width: 120px; height: 120px; border-radius: 18px; border: 2px dashed #CBD5E1; display: grid; place-items: center; overflow: hidden; background: #F8FAFC; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Toasts */
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; max-width: min(400px, calc(100vw - 32px)); }
.toast-x {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px 16px; display: flex; gap: 12px;
  border-left: 4px solid var(--brand); animation: toastIn .3s ease; font-size: 14px;
}
.toast-x.success { border-left-color: var(--success); }
.toast-x.danger { border-left-color: var(--danger); }
.toast-x.warning { border-left-color: var(--warning); }
.toast-x i.lead { font-size: 20px; }
.toast-x.success i.lead { color: var(--success); }
.toast-x.danger i.lead { color: var(--danger); }
.toast-x.warning i.lead { color: var(--warning); }
.toast-x.info i.lead { color: var(--brand); }
.toast-x .x { margin-left: auto; border: 0; background: none; color: var(--muted-2); padding: 0 0 0 6px; font-size: 18px; line-height: 1; }
/* Due reminder popup */
.due-pop { position: fixed; inset: 0; z-index: 2100; background: rgba(15, 23, 42, .45); display: none; align-items: center; justify-content: center; padding: 16px; }
.due-pop.show { display: flex; animation: duePopFade .2s ease; }
.due-pop-card { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 20px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); overflow: hidden; animation: duePopIn .25s ease; }
.due-pop-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; background: var(--grad); color: #fff; }
.due-pop-bell { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 22px; animation: duePopRing 1.2s ease-in-out 3; }
.due-pop-title { font-weight: 800; font-size: 17px; }
.due-pop-sub { font-size: 12.5px; opacity: .85; }
.due-pop-x { border: 0; background: rgba(255,255,255,.15); color: #fff; width: 32px; height: 32px; border-radius: 10px; font-size: 20px; line-height: 1; }
.due-pop-x:hover { background: rgba(255,255,255,.28); }
.due-pop-list { overflow-y: auto; padding: 6px 0; }
.due-item { padding: 14px 20px; border-bottom: 1px solid #F1F3F8; transition: opacity .25s; }
.due-item:last-child { border-bottom: 0; }
.due-item-title { font-weight: 700; color: var(--ink); font-size: 15px; }
.due-item-note { font-size: 13px; color: var(--ink-2); background: #F8FAFC; border-radius: 10px; padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; }
.due-pop-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: #FAFBFD; }
@keyframes duePopFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes duePopIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes duePopRing { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@media (max-width: 575.98px) { .due-pop { align-items: flex-end; padding: 0; } .due-pop-card { max-width: none; border-radius: 20px 20px 0 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Dropdowns */
.dropdown-menu { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; font-size: 14px; }
.dropdown-item { border-radius: 9px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.dropdown-item:active { background: var(--brand); }
.notif-menu { width: min(370px, 92vw); padding: 0; overflow: hidden; }
.notif-menu .head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.notif-menu .list { max-height: 360px; overflow-y: auto; }
.notif-menu .n-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #F3F4F8; color: inherit; }
.notif-menu .n-item:hover { background: #F8FAFF; }

.modal-content { border: 0; border-radius: 20px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--line); padding: 18px 22px; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--line); padding: 14px 22px; }
.modal-title { font-weight: 700; font-size: 17px; }

/* Bottom nav (mobile app feel) */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; position: relative; }
.bottom-nav a i { font-size: 20px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.fab i {
  width: 48px; height: 48px; border-radius: 16px; background: var(--grad); color: #fff; display: grid; place-items: center;
  margin-top: -22px; box-shadow: 0 8px 20px rgba(79, 70, 229, .4); font-size: 22px;
}
.bottom-nav .dot { position: absolute; top: 0; left: 55%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 10px; }
.bottom-nav .dot[data-count="0"], .bottom-nav .dot:empty { display: none; }

.install-btn { display: none; }

/* Chart container */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 230px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13.5px; }
.bar-row .lbl { width: 130px; flex: 0 0 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); font-weight: 500; }
.bar-row .track { flex: 1; height: 10px; background: #F1F3F8; border-radius: 10px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 10px; background: var(--c, var(--brand)); }
.bar-row .val { width: 70px; text-align: right; font-weight: 700; color: var(--ink); }

/* Lead profile tabs */
.lead-tabs-wrap { border-bottom: 1px solid var(--line); position: sticky; top: var(--topbar-h); z-index: 15; background: #fff; border-radius: var(--radius) var(--radius) 0 0; }
.lead-tabs {
  display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; padding: 6px 10px 0; margin: 0; list-style: none;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.lead-tabs::-webkit-scrollbar { display: none; }
.lead-tabs .nav-link {
  border: 0; background: none; white-space: nowrap; color: var(--muted); font-weight: 600; font-size: 13.5px;
  padding: 12px 12px 11px; border-bottom: 3px solid transparent; border-radius: 0; display: inline-flex; align-items: center; gap: 7px;
}
.lead-tabs .nav-link:hover { color: var(--ink); }
.lead-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); }
.lead-tabs .nav-link .n { background: #F1F5F9; color: var(--ink-2); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.lead-tabs .nav-link.active .n { background: var(--brand-50); color: var(--brand); }
.tab-pane-body { padding: 20px; }
.tab-intro { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

.compose { background: #F8FAFF; border: 1px solid #E0E7FF; border-radius: 14px; padding: 14px; margin-bottom: 18px; }
.compose textarea { background: #fff; }
.file-pick { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--brand); padding: 6px 12px; border-radius: 9px; background: #fff; border: 1px dashed #A5B4FC; }
.file-pick:hover { background: var(--brand-50); }
.file-list { font-size: 12.5px; color: var(--muted); }

.note-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.note-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.note-card .who { font-weight: 600; color: var(--ink); font-size: 13.5px; }
.note-card .when { font-size: 12px; color: var(--muted); }
.note-card .body { white-space: pre-wrap; word-break: break-word; color: var(--ink-2); font-size: 14px; }
.note-card .money { font-weight: 800; color: var(--ink); font-size: 16px; }
.att-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: #F8FAFC; color: var(--ink-2); font-size: 12.5px; font-weight: 500;
}
.att-chip:hover { border-color: #C7D2FE; color: var(--brand); background: #fff; }
.att-chip i { font-size: 16px; color: var(--brand); }
.att-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.att-chip .sz { color: var(--muted-2); font-size: 11px; }
.att-thumb { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: #F1F5F9; display: block; }
.att-tile { border: 1px solid var(--line); border-radius: 14px; padding: 10px; height: 100%; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.att-tile .icon-box { aspect-ratio: 4/3; border-radius: 10px; background: #F8FAFC; display: grid; place-items: center; font-size: 38px; color: var(--brand); }
.att-tile .nm { font-weight: 600; font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-tile .meta { font-size: 11.5px; color: var(--muted); }
.sum-box { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sum-box .item { flex: 1; min-width: 140px; border-radius: 14px; padding: 12px 14px; background: #F8FAFC; border: 1px solid var(--line); }
.sum-box .item .v { font-weight: 800; font-size: 20px; color: var(--ink); }
.sum-box .item .l { font-size: 12px; color: var(--muted); }
.loc-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; height: 100%; position: relative; background: #fff; }
.loc-card.primary { border-color: #A5B4FC; box-shadow: 0 0 0 3px rgba(99,102,241,.08); }
.loc-card .lbl { font-weight: 700; color: var(--ink); }
.timeline-scroll { max-height: calc(100vh - 160px); overflow-y: auto; }
.tl-icon.lead_note { background: #FEFCE8; color: #CA8A04; }
.tl-icon.quotation { background: #ECFEFF; color: #0891B2; }
.tl-icon.billing { background: #F0FDF4; color: #15803D; }
.tl-icon.file { background: #F1F5F9; color: #475569; }
.tl-icon.location { background: #FDF2F8; color: #DB2777; }
.tl-icon.deleted { background: #FEF2F2; color: #DC2626; }
.tl-body .att-chips { margin-top: 6px; }
.tl-body .att-chip { padding: 4px 8px; font-size: 12px; }
@media (max-width: 991.98px) { .lead-tabs-wrap { position: static; } .timeline-scroll { max-height: none; } }
@media (max-width: 575.98px) { .tab-pane-body { padding: 16px; } .att-chip .nm { max-width: 150px; } }

.min-w-0 { min-width: 0; }
.text-ink { color: var(--ink) !important; }
.text-muted { color: var(--muted) !important; }
.fw-800 { font-weight: 800; }
.gap-row { row-gap: 20px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
  .topbar .search { width: min(280px, 30vw); }
}
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1039; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .search { display: none; }
  .page { padding: 6px 16px 96px; }
  .bottom-nav { display: flex; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 575.98px) {
  body { font-size: 14px; }
  .topbar h1 { font-size: 17px; }
  .topbar .crumb { display: none; }
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .stat-card { padding: 14px; gap: 12px; }
  .stat-icon { width: 44px; height: 44px; flex-basis: 44px; font-size: 19px; border-radius: 13px; }
  .stat-value { font-size: 21px; }
  .hero { padding: 20px; border-radius: 18px; }
  .hero h2 { font-size: 19px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .qa-lg { display: grid !important; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .qa-lg .qa-btn { padding: 0 8px; justify-content: center; }
  .auth-card .card { padding: 22px; }
  .rem-item { padding: 12px 16px; }
}

@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .toast-stack { display: none !important; }
  .main { margin: 0; }
  .page { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-only { display: block !important; }
  body { background: #fff; }
}
.print-only { display: none; }

/* Standalone (installed PWA) */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
}
