:root {
  /* Mahabhoomi palette — sampled from the logo */
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #f6f9f7;
  --ink: #142a22;
  --ink-2: #4b5f57;
  --ink-3: #82938b;
  --line: #dfe7e2;
  --brand: #17573f;        /* logo emerald */
  --brand-deep: #0f3a2c;   /* logo shadow green */
  --brand-2: #e2f1e9;      /* light tint */
  --mint: #35e08f;         /* logo highlight */
  --accent: #1fae6b;
  --warn: #c97a0a;
  --danger: #c2412d;
  --wa: #1fa855;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 58, 44, .06), 0 4px 16px rgba(15, 58, 44, .06);
  --s-new: #2f6fde; --s-contacted: #7a5af5; --s-interested: #c98a0b;
  --s-follow-up: #e0742f; --s-won: #17874f; --s-lost: #8a938e;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 10px 20px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.logo img { width: 150px; height: auto; display: block; }
.logo-tag, .auth-brand span { font-size: 11px; font-weight: 700; letter-spacing: .32em; color: #fff; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); padding: 3px 10px 3px 13px; border-radius: 99px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; }
.auth-brand img { width: 190px; height: auto; }
.nav-btn { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--ink-2); font-weight: 500; text-align: left; width: 100%; }
.nav-btn:hover { background: var(--surface-2); color: var(--ink); }
.nav-btn.on { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(15,58,44,.18); }
.nav-btn.on .nav-badge { background: var(--mint); color: var(--brand-deep); }
.nav-btn svg { width: 19px; height: 19px; flex: none; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-foot { margin-top: auto; font-size: 13px; color: var(--ink-3); padding: 10px 12px; }
.main { min-width: 0; padding: 26px 32px 60px; max-width: 1180px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }
.bottom-nav { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 96px; }
  .topbar h1 { font-size: 21px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .bottom-nav .nav-btn.on { background: var(--brand-2); color: var(--brand); box-shadow: none; }
  .bottom-nav .nav-btn { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 2px; justify-content: center; align-items: center; position: relative; }
  .bottom-nav .nav-badge { position: absolute; top: 0; right: 18%; margin: 0; }
}

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); border-color: var(--brand-deep); color: #fff; }
.btn.primary:hover { border-color: var(--brand-deep); filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn svg { width: 17px; height: 17px; }
.btn:disabled { opacity: .55; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-2); }
textarea.input { resize: vertical; min-height: 80px; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card h3 { margin: 0 0 4px; font-size: 16px; }

/* ---------- tabs & chips ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 12px; scrollbar-width: none; }
.tab { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; color: var(--ink-2); }
.tab.on { background: var(--brand-deep); color: #fff; border-color: var(--brand-deep); }
.tab .cnt { opacity: .7; margin-left: 4px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.src { font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- lead list ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters .input { width: auto; }
.search { flex: 1; min-width: 180px; }
.lead-list { display: flex; flex-direction: column; }
.lead { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lead:last-child { border-bottom: 0; }
.lead:hover { background: var(--surface-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; flex: none; }
.lead-name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lead-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-sub { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lead-quick { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.icon-btn.wa { color: var(--wa); }
.icon-btn svg { width: 17px; height: 17px; }
.dot-new { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.due { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.due.late { color: var(--danger); }
.check { width: 18px; height: 18px; accent-color: var(--brand); }
.empty { padding: 50px 20px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.bulkbar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: var(--brand-2); border-radius: 12px; margin-bottom: 10px; flex-wrap: wrap; }
@media (max-width: 820px) {
  .lead { grid-template-columns: auto 1fr; padding: 12px; }
  .lead-right { grid-column: 2; flex-direction: row; justify-content: space-between; align-items: center; width: 100%; }
}

/* ---------- drawer (lead detail) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 20, 18, .38); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg); z-index: 41; overflow-y: auto; animation: slide .2s ease-out; display: flex; flex-direction: column; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.d-head { background: var(--surface); padding: 16px 18px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.d-title { display: flex; align-items: center; gap: 12px; }
.d-title h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.d-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.act svg { width: 20px; height: 20px; }
.act.call { color: var(--brand); } .act.wa { color: var(--wa); }
.act:disabled { opacity: .4; cursor: default; }
.d-body { padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 14px; }
.sec-title { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; }
.status-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.status-opt { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.status-opt.on { background: var(--c); border-color: var(--c); color: #fff; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.quick-times { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 8px 0; }
.tl-ic { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-2); }
.tl-ic svg { width: 14px; height: 14px; }
.tl-body { font-size: 14px; white-space: pre-wrap; }
.tl-meta { font-size: 12px; color: var(--ink-3); }
.tl.note .tl-body { background: var(--surface); border: 1px solid var(--line); padding: 8px 11px; border-radius: 10px; }

/* ---------- sheet/modal ---------- */
.modal { position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100% - 24px)); max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--surface); border-radius: 18px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: fade .15s; }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.modal.scrim-top { z-index: 52; }
@media (max-width: 820px) {
  .modal { top: auto; bottom: 0; transform: translateX(-50%); width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.tpl { border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; margin-top: 8px; }
.tpl:hover { border-color: var(--brand); }
.tpl b { display: block; font-size: 14px; margin-bottom: 3px; }
.tpl p { margin: 0; font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { padding: 16px; }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.stat.warn .n { color: var(--warn); }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; margin: 9px 0; font-size: 14px; }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c, var(--brand)); border-radius: 99px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px 6px; border-bottom: 1px solid var(--line); }
table.t td.num, table.t th.num { text-align: right; }

/* ---------- settings ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); padding: 9px 11px; border-radius: 9px; word-break: break-all; }
.ok { color: var(--s-won); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; margin: 12px 0; font-size: 14px; }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-2); color: var(--brand); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.fb-btn { background: #1877f2; border-color: #1877f2; color: #fff; }
.page-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.page-item:last-child { border-bottom: 0; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { margin: 6px 0 4px; font-size: 22px; letter-spacing: -.02em; }
.err { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
@media (max-width: 820px) { .toast { bottom: 84px; } }
.fab { display: none; }
@media (max-width: 820px) {
  .fab { display: grid; position: fixed; right: 16px; bottom: 84px; width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: #fff; border: 0; place-items: center; box-shadow: 0 6px 20px rgba(15,58,44,.35); z-index: 25; cursor: pointer; }
  .fab svg { width: 24px; height: 24px; }
  .hide-m { display: none !important; }
}
@media (max-width: 820px) {
  .filters .search { flex-basis: 100%; }
  .filters select.input { flex: 1; min-width: 0; }
}

/* auth screen backdrop */
.auth { background: radial-gradient(1200px 500px at 50% -10%, var(--brand-2), transparent 70%), var(--bg); }
.auth .card { border-top: 4px solid var(--brand); }

.m-head { display: none; }
@media (max-width: 820px) {
  .m-head { display: flex; align-items: center; justify-content: space-between; margin: -4px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .m-head img { height: 40px; width: auto; }
}

/* push notification prompt */
.push-banner { display: flex; align-items: center; gap: 10px; background: var(--brand-2); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); color: var(--ink); padding: 10px 12px; border-radius: 12px; margin: 0 0 14px; font-size: 14px; font-weight: 500; }
.push-banner .pb-ic { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.push-banner .pb-ic svg { width: 17px; height: 17px; }
@media (max-width: 820px) {
  .push-banner { flex-wrap: wrap; row-gap: 8px; }
  .push-banner .grow { flex: 1 1 calc(100% - 90px); }
  .push-banner [data-action=push-dismiss] { order: 2; }
  .push-banner .btn.primary { order: 3; margin-left: 42px; }
}
.howto .step { margin: 8px 0; }
