/* ============ Design tokens ============ */
:root {
  --brand: #4361ee;
  --brand-600: #3651d4;
  --brand-50: #eef1fe;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e7eaf3;
  --bg: #f5f7fb;
  --card: #ffffff;
  --side: #111a33;
  --side-2: #1a2547;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px -6px rgba(15, 23, 42, .08);
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-primary: #4361ee;
  --bs-primary-rgb: 67, 97, 238;
  --bs-link-color: #3651d4;
  --bs-link-color-rgb: 54, 81, 212;
  --bs-link-hover-color: #2a40b0;
  --bs-border-color: #e7eaf3;
}
body { font-family: var(--bs-body-font-family); background: var(--bg); color: var(--ink); font-size: .92rem; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }
.text-muted { color: var(--muted) !important; }
h1, .h1, h2, .h2, h3, .h3, h4, .h4 { font-weight: 700; letter-spacing: -.01em; }

/* Buttons */
.btn { border-radius: 10px; font-weight: 500; }
.btn-sm { border-radius: 8px; }
.btn-primary, .btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, .btn-brand:hover, .btn-brand:focus { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-brand { box-shadow: 0 4px 12px -4px rgba(67, 97, 238, .6); }
.btn-outline-primary { color: var(--brand); border-color: #c9d2fb; }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-outline-secondary { border-color: var(--line); color: #334155; background: #fff; }
.btn-outline-secondary:hover, .btn-outline-secondary.active { background: var(--brand-50); color: var(--brand-600); border-color: #c9d2fb; }
.btn-light { background: #f1f4f9; border-color: #f1f4f9; }
.btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: #334155; background: transparent; border: 0; }
.btn-icon:hover { background: #eef1f6; }
.btn-icon-dark { color: rgba(255,255,255,.7); border: 0; }
.btn-icon-dark:hover { color: #fff; background: rgba(255,255,255,.08); }
.form-control, .form-select { border-radius: 10px; border-color: #dfe3ee; }
.form-control:focus, .form-select:focus { border-color: #9fb0f7; box-shadow: 0 0 0 .2rem rgba(67, 97, 238, .15); }
.form-control-sm, .form-select-sm { border-radius: 8px; }
.form-label { font-weight: 500; color: #334155; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.nav-pills .nav-link { border-radius: 999px; color: #475569; font-weight: 500; }
.nav-pills .nav-link.active { background: var(--ink); }
.nav-tabs .nav-link { color: #475569; font-weight: 500; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--brand-600); border-bottom-color: var(--brand); background: transparent; }
.nav-tabs { border-bottom-color: var(--line); }
.alert { border-radius: 12px; border: 0; box-shadow: var(--shadow-sm); }
.dropdown-menu { border-radius: 12px; border-color: var(--line); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .7rem; }
.modal-content { border-radius: 16px; border: 0; }
.modal-header, .modal-footer { border-color: var(--line); }
.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--line); color: #334155; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.table { --bs-table-hover-bg: #f8faff; }
.table > :not(caption) > * > * { border-bottom-color: #eef1f6; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfe !important; }

/* ============ App shell ============ */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--side); color: #fff; flex-direction: column; padding: 18px 14px; z-index: 1030; overflow-y: auto; }
.sidebar-drawer { background: var(--side); color: #fff; width: 280px !important; }
.main-wrap { min-height: 100vh; }
@media (min-width: 992px) { .main-wrap { margin-left: 248px; } }
.side-brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 1.02rem; padding: 4px 6px 18px; }
.side-brand:hover { color: #fff; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #5b7cfa, #3a4fd8); color: #fff; font-size: 16px; flex-shrink: 0; box-shadow: 0 6px 14px -6px rgba(67,97,238,.8); }
.brand-mark-lg { width: 60px; height: 60px; font-size: 28px; border-radius: 16px; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.4); padding: 8px 10px 6px; font-weight: 600; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: rgba(255,255,255,.72); font-weight: 500; margin-bottom: 2px; }
.side-link i { font-size: 1.08rem; width: 20px; text-align: center; }
.side-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.side-link.active { color: #fff; background: var(--side-2); box-shadow: inset 3px 0 0 var(--brand); }
.side-badge { margin-left: auto; background: #ef4444; color: #fff; font-size: .7rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #7c93fb, #4361ee); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
.avatar-xs { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: #e3e8ff; color: #3651d4; font-size: 10.5px; font-weight: 700; flex-shrink: 0; }

.topbar { position: sticky; top: 0; z-index: 1020; height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: rgba(245, 247, 251, .85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-brand { font-weight: 700; }
.topbar-search { align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; height: 40px; width: min(480px, 50vw); box-shadow: var(--shadow-sm); }
.topbar-search i { color: var(--muted); }
.topbar-search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: .9rem; }
.dot-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; border-radius: 999px; background: #ef4444; color: #fff; font-size: .62rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid var(--bg); }
.page { padding: 22px 24px 40px; max-width: 1600px; }

/* Mobile bottom bar */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; justify-content: space-around; align-items: center; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px -12px rgba(15,23,42,.2); }
.bottom-bar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #64748b; font-size: .68rem; font-weight: 500; position: relative; }
.bottom-bar a i { font-size: 1.25rem; }
.bottom-bar a.active { color: var(--brand); }
.bottom-bar .bottom-add { flex: 0 0 52px; height: 52px; border-radius: 50%; background: var(--brand); color: #fff; justify-content: center; margin-top: -26px; box-shadow: 0 8px 18px -6px rgba(67,97,238,.7); }
.bottom-bar .bottom-add i { font-size: 1.5rem; }
.mini-badge { position: absolute; top: -2px; left: 54%; background: #ef4444; color: #fff; font-size: .6rem; border-radius: 999px; padding: 0 5px; }
.toast-pos { bottom: 0; }
@media (max-width: 991.98px) {
  .page { padding: 16px 14px 96px; }
  .topbar { padding: 0 10px; height: 56px; }
  .toast-pos { bottom: 70px; }
}

/* ============ Cards & dashboard ============ */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--card); }
.card-header { background: transparent; font-weight: 600; border-bottom: 1px solid var(--line); padding: .85rem 1.1rem; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-footer { background: #fafbfe; border-top-color: var(--line); }
.card-footer:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.card-header i, .card-title i { color: var(--brand); }
.list-group-item { border-color: #eef1f6; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 1.45rem; }
.page-sub { color: var(--muted); font-size: .86rem; }

.stat-card { display: flex; gap: 14px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: inherit; height: 100%; box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); color: inherit; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; background: var(--brand-50); color: var(--brand); }
.stat-good .stat-icon { background: #e7f8ee; color: #15803d; }
.stat-bad .stat-icon { background: #fdecec; color: #dc2626; }
.stat-warn .stat-icon { background: #fff4e0; color: #d97706; }
.stat-purple .stat-icon { background: #f2ebff; color: #7c3aed; }
.stat-cyan .stat-icon { background: #e3f6fb; color: #0891b2; }
.stat-label { font-size: .76rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.stat-sub { font-size: .76rem; color: var(--muted); }

.hbar { display: block; color: inherit; margin-bottom: 12px; }
.hbar:hover { color: inherit; }
.hbar-track { height: 8px; background: #f1f4f9; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.hbar-track span { display: block; height: 100%; border-radius: 999px; }
.day-bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.day-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.day-bar span { display: block; width: 100%; background: linear-gradient(180deg, #6d86f8, #4361ee); border-radius: 4px 4px 1px 1px; opacity: .9; }
.day-bar:hover span { opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty i { font-size: 2rem; color: #c3cad9; display: block; margin-bottom: 6px; }

/* Badges */
.badge { font-weight: 600; border-radius: 999px; padding: .35em .7em; }
.src-badge, .stage-badge { background: color-mix(in srgb, var(--c) 12%, white); color: color-mix(in srgb, var(--c) 78%, black); border: 1px solid color-mix(in srgb, var(--c) 24%, white); }

/* Lead table */
.leads-table td { padding-top: .7rem; padding-bottom: .7rem; }
.leads-table .lead-name { max-width: 260px; color: var(--ink); }
.leads-table .lead-name:hover { color: var(--brand); }
.lead-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }

/* Lead detail */
.stage-bar { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.stage-step { flex: 1 0 auto; margin: 0; }
.stage-step button { width: 100%; border: 0; background: #e9edf5; padding: 9px 16px 9px 22px; font-size: .8rem; font-weight: 600; color: #475569; white-space: nowrap; clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%, 11px 50%); transition: background .12s; }
.stage-step:first-child button { clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 50%, calc(100% - 11px) 100%, 0 100%); padding-left: 16px; border-radius: 10px 0 0 10px; }
.stage-step:last-child button { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 11px 50%); border-radius: 0 10px 10px 0; }
.stage-step button:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 18%, white); color: #0f172a; }
.stage-step.current button { background: var(--c); color: #fff; opacity: 1; }
.lead-hero { display: flex; gap: 14px; align-items: center; }
.lead-hero .avatar { width: 52px; height: 52px; font-size: 1.05rem; border-radius: 16px; }
.lead-dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: .9rem; }
.lead-dl dt { color: var(--muted); font-weight: 500; }
.lead-dl dd { margin: 0; min-width: 0; }
.requirement { background: #f7f9fc; border: 1px solid #eef1f6; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.qa-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: #334155; font-weight: 600; font-size: .82rem; transition: all .12s; }
.qa-btn i { font-size: 1.3rem; }
.qa-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); color: #334155; }
.qa-call i { color: var(--brand); } .qa-wa i { color: #16a34a; } .qa-mail i { color: #d97706; } .qa-ig i { color: #e1306c; }

/* 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: #eef1f6; }
.timeline li { position: relative; padding-left: 50px; margin-bottom: 16px; }
.tl-icon { position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 13%, white); color: var(--c); border: 3px solid #fff; }
.tl-text { margin-top: 3px; word-break: break-word; }
.tl-inbound { background: #f0fbf4; border: 1px solid #d5f1df; border-radius: 4px 12px 12px 12px; padding: 8px 12px; display: inline-block; max-width: 100%; }

/* Follow-ups */
.fu-card { transition: box-shadow .12s; }
.fu-card:hover { box-shadow: var(--shadow); }
.fu-time { min-width: 72px; background: #f5f7fb; border-radius: 10px; padding: 6px 8px; }
.fu-overdue { border-left: 4px solid #ef4444; }
.fu-overdue .fu-time { background: #fdecec; }
.next-fu summary { cursor: pointer; }

/* Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; min-height: 60vh; }
.kanban-col { flex: 0 0 280px; background: #eef1f7; border-radius: 16px; max-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.kanban-head { padding: 12px 14px 8px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.kanban-head .fw-semibold::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.kanban-cards { padding: 0 10px 10px; overflow-y: auto; min-height: 70px; flex: 1; }
.kanban-card { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(15,23,42,.06); border: 1px solid #e9ecf4; cursor: grab; font-size: .87rem; transition: box-shadow .12s, transform .12s; }
.kanban-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card a { color: var(--ink); }
.kanban-card.dragging { opacity: .45; }
.kanban-col.drop-over { outline: 2px dashed var(--c); outline-offset: -4px; }

/* Auth */
.auth-body { background: #fff; }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-hero { flex: 1.1; background: radial-gradient(1200px 600px at 10% 10%, #2b3f8f 0%, #111a33 55%); color: #fff; align-items: center; justify-content: center; padding: 60px; position: relative; overflow: hidden; }
.auth-hero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -120px; bottom: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(91,124,250,.45), transparent 70%); }
.auth-hero > div { max-width: 460px; position: relative; z-index: 1; }
.auth-hero h1 { font-size: 2.2rem; }
.auth-hero .lead { color: rgba(255,255,255,.75); }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; }
.auth-points li { margin-bottom: 12px; color: rgba(255,255,255,.85); display: flex; gap: 10px; }
.auth-points i { color: #8ea2ff; }
.auth-form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .form-control { padding-left: 42px; }

.copy-group input { font-size: .8rem; }

@media (max-width: 575.98px) {
  .lead-dl { grid-template-columns: 92px 1fr; }
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 34px; height: 34px; font-size: 1rem; border-radius: 10px; }
  .stat-value { font-size: 1.3rem; }
  .leads-table .lead-name { max-width: 160px; }
  .page-head h1 { font-size: 1.25rem; }
}

/* Segmented control (dashboard period) */
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; box-shadow: var(--shadow-sm); }
.seg::-webkit-scrollbar { display: none; }
.seg a { white-space: nowrap; padding: 5px 12px; border-radius: 9px; color: #475569; font-weight: 500; font-size: .82rem; }
.seg a:hover { background: #f1f4f9; }
.seg a.active { background: var(--ink); color: #fff; }
