/* TBF Leads: own design. Indigo-violet brand, soft cards, one clear action per screen. Light + dark follow the phone. */
:root {
  --bg: #F3F4FB; --card: #FFFFFF; --ink: #12142B; --mut: #6B7094; --line: #E6E8F4; --soft: #EEF0FC;
  --brand: #5B5BF0; --brand2: #8B5CF6; --brand-soft: #ECECFE; --gold: #FFB82E; --ok: #12B76A; --ok-soft: #E3F8EE; --warn: #F79009; --warn-soft: #FEF1DC; --bad: #F04438; --bad-soft: #FDE8E6;
  --shadow: 0 1px 2px rgba(18,20,43,.04), 0 8px 24px rgba(40,44,110,.08); --shadow-s: 0 1px 2px rgba(18,20,43,.05), 0 2px 8px rgba(40,44,110,.06);
  --r: 20px; --nav: 72px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0E1F; --card: #141936; --ink: #EEF0FF; --mut: #9BA2CC; --line: #232A52; --soft: #1B2142; --brand-soft: #25264F; --ok-soft: #12302A; --warn-soft: #3A2C12; --bad-soft: #3A1C1C;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px rgba(0,0,0,.35); --shadow-s: 0 1px 2px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", sans-serif; font-size: 15px; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
#app { min-height: 100%; padding-bottom: calc(var(--nav) + var(--safe-b) + 12px); }
.screen { padding: 0 16px 8px; animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ----- top bar + hero */
.top { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-t) + 16px) 16px 10px; }
.top h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.02em; line-height: 1.15; }
.top .sub { color: var(--mut); font-size: .82rem; margin-top: 2px; }
.top .grow { flex: 1; min-width: 0; }
.ic-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow-s); display: grid; place-items: center; color: var(--ink); flex: none; }
.ic-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic-btn:active, .btn:active, .act:active, .chip:active, .nav button:active { transform: scale(.96); }
.hero { margin: 4px 16px 12px; padding: 18px; border-radius: 24px; color: #fff; background: linear-gradient(135deg, var(--brand) 0%, var(--brand2) 100%); box-shadow: 0 14px 30px rgba(91,91,240,.35); position: relative; overflow: hidden; }
.hero:after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero .k { font-size: .78rem; opacity: .85; letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.hero .big { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 12px; }
.hero .row3 { display: flex; gap: 8px; position: relative; z-index: 1; }
.hero .stat { flex: 1; background: rgba(255,255,255,.16); border-radius: 14px; padding: 9px 10px; text-align: left; color: #fff; }
.hero .stat b { display: block; font-size: 1.15rem; }
.hero .stat span { font-size: .72rem; opacity: .85; }

/* ----- search + chips */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 16px; padding: 0 14px; height: 46px; box-shadow: var(--shadow-s); margin: 0 16px 10px; }
.search svg { width: 18px; height: 18px; stroke: var(--mut); fill: none; stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; border: 0; background: transparent; outline: 0; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow-s); font-weight: 600; font-size: .85rem; color: var(--mut); display: flex; gap: 6px; align-items: center; }
.chip i { font-style: normal; font-size: .72rem; background: var(--soft); border-radius: 999px; padding: 1px 7px; color: var(--mut); }
.chip.on { background: var(--ink); color: var(--bg); } .chip.on i { background: rgba(255,255,255,.2); color: inherit; }

/* ----- lead cards */
.list { display: flex; flex-direction: column; gap: 10px; }
.lead { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-s); padding: 14px; display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; }
.lead:active { transform: scale(.99); }
.av { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.05rem; flex: none; }
.lead .body { flex: 1; min-width: 0; }
.lead .nm { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.lead .nm span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead .meta { color: var(--mut); font-size: .8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead .note { color: var(--mut); font-size: .82rem; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.lead .side { display: flex; flex-direction: column; gap: 8px; flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.High { background: var(--bad); } .dot.Medium { background: var(--warn); } .dot.Low { background: #98A2B3; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--soft); color: var(--mut); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.act { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); color: var(--brand); }
.act.wa { background: #E3F8EE; color: #12B76A; } .act svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty { text-align: center; color: var(--mut); padding: 40px 24px; }
.empty .big { font-size: 2.4rem; margin-bottom: 8px; } .empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 1.05rem; }
.skel { height: 88px; border-radius: var(--r); background: linear-gradient(90deg, var(--card) 25%, var(--soft) 50%, var(--card) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.more { margin: 14px auto 0; display: block; color: var(--brand); font-weight: 700; padding: 10px 18px; }

/* ----- buttons + fields */
.btn { width: 100%; padding: 15px; border-radius: 16px; font-weight: 700; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; box-shadow: 0 8px 20px rgba(91,91,240,.3); }
.btn.ghost { background: var(--soft); color: var(--brand); box-shadow: none; } .btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; } .btn:disabled { opacity: .55; }
.btn.sm { width: auto; padding: 9px 16px; border-radius: 12px; font-size: .85rem; box-shadow: none; }
.field { margin: 0 0 12px; } .field label { display: block; font-size: .78rem; font-weight: 700; color: var(--mut); margin: 0 2px 6px; letter-spacing: .02em; }
.field input, .field textarea, .field select { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); outline: 0; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.field textarea { resize: none; min-height: 84px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow-s); padding: 16px; margin-bottom: 12px; }
.h { font-size: .78rem; font-weight: 800; color: var(--mut); letter-spacing: .06em; text-transform: uppercase; margin: 18px 4px 8px; }
.err { background: var(--bad-soft); color: var(--bad); padding: 11px 14px; border-radius: 14px; font-weight: 600; margin: 8px 0; font-size: .88rem; }
.muted { color: var(--mut); }

/* ----- detail */
.dhead { margin: 0 16px 14px; padding: 18px; border-radius: 26px; color: #fff; background: linear-gradient(135deg, #1D2145, #3A3FA8); box-shadow: 0 14px 30px rgba(29,33,69,.35); }
.dhead .r1 { display: flex; gap: 14px; align-items: center; } .dhead .av { width: 58px; height: 58px; border-radius: 20px; font-size: 1.3rem; }
.dhead h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.01em; } .dhead .ph { opacity: .8; font-size: .86rem; margin-top: 2px; }
.dhead .tags { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; } .dhead .pill { background: rgba(255,255,255,.16); color: #fff; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 16px 6px; }
.actions button { background: var(--card); border-radius: 18px; box-shadow: var(--shadow-s); padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; color: var(--ink); }
.actions button .i { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); } .actions button .i svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actions .wa .i { background: #E3F8EE; color: #12B76A; }
.stages { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; } .stages::-webkit-scrollbar { display: none; }
.stage { flex: none; padding: 8px 13px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow-s); font-size: .8rem; font-weight: 700; color: var(--mut); }
.stage.on { color: #fff; }
.fu { display: flex; align-items: center; gap: 12px; } .fu .ico { width: 40px; height: 40px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; flex: none; } .fu .grow { flex: 1; min-width: 0; }
.fu.late .ico { background: var(--bad-soft); color: var(--bad); }
.tl { position: relative; padding-left: 18px; } .tl:before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl .it { position: relative; padding: 0 0 14px; } .tl .it:before { content: ""; position: absolute; left: -18px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 3px solid var(--brand); }
.tl .it.act2:before { border-color: #C9CEE8; width: 10px; height: 10px; left: -17px; }
.bub { background: var(--soft); border-radius: 14px; padding: 10px 12px; font-size: .92rem; white-space: pre-wrap; word-break: break-word; }
.tl .when { font-size: .72rem; color: var(--mut); margin-top: 4px; } .tl .sm { font-size: .84rem; color: var(--mut); }
.composer { display: flex; gap: 8px; align-items: flex-end; } .composer textarea { flex: 1; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); min-height: 48px; max-height: 120px; resize: none; outline: 0; }
.composer .btn { width: 48px; height: 48px; padding: 0; border-radius: 16px; display: grid; place-items: center; } .composer .btn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ----- bottom nav */
.nav { position: fixed; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b)); height: 64px; background: var(--card); border-radius: 24px; box-shadow: 0 10px 34px rgba(30,34,90,.22); display: flex; align-items: center; justify-content: space-around; z-index: 20; padding: 0 6px; }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .68rem; font-weight: 700; color: var(--mut); width: 62px; padding: 6px 0; position: relative; }
.nav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav button.on { color: var(--brand); }
.nav button .b { position: absolute; top: 0; right: 10px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .62rem; display: grid; place-items: center; padding: 0 4px; }
.nav .plus { width: 54px; height: 54px; border-radius: 20px; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; margin-top: -26px; box-shadow: 0 10px 22px rgba(91,91,240,.45); justify-content: center; padding: 0; } .nav .plus svg { width: 26px; height: 26px; }

/* ----- sheet + toast */
.back { position: fixed; inset: 0; background: rgba(10,12,30,.5); z-index: 40; animation: fade .18s ease both; } @keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 86%; overflow-y: auto; background: var(--bg); border-radius: 28px 28px 0 0; padding: 10px 16px calc(18px + var(--safe-b)); z-index: 41; animation: up .24s cubic-bezier(.2,.8,.2,1) both; }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; } .sheet h3 { margin: 4px 2px 12px; font-size: 1.1rem; }
.tpl { width: 100%; text-align: left; background: var(--card); border-radius: 18px; padding: 13px 14px; margin-bottom: 8px; box-shadow: var(--shadow-s); display: block; } .tpl b { display: block; margin-bottom: 3px; } .tpl span { color: var(--mut); font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; } .quick button { background: var(--card); border-radius: 16px; padding: 12px; font-weight: 700; box-shadow: var(--shadow-s); font-size: .86rem; } .quick button.on { background: var(--brand); color: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; background: var(--soft); padding: 4px; border-radius: 14px; } .seg button { flex: 1; padding: 9px; border-radius: 11px; font-weight: 700; color: var(--mut); font-size: .84rem; } .seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-s); }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); background: #12142B; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: .88rem; z-index: 60; max-width: 86%; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.3); }

/* ----- connect */
.conn { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-t) + 24px) 22px 28px; background: radial-gradient(120% 70% at 50% 0%, #6D6DF5 0%, var(--bg) 62%); }
.conn .logo { width: 76px; height: 76px; border-radius: 26px; margin: 0 auto 18px; box-shadow: 0 16px 34px rgba(91,91,240,.45); } .conn h1 { text-align: center; margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -.03em; } .conn .lead2 { text-align: center; color: var(--mut); margin: 0 12px 22px; line-height: 1.45; }
.conn .steps { color: var(--mut); font-size: .84rem; margin: 14px 4px 0; line-height: 1.6; } .powered { text-align: center; color: var(--mut); font-size: .76rem; margin: 22px 0 0; } .powered b { color: var(--brand); }
.upd { margin: 0 16px 12px; padding: 12px 14px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: flex; align-items: center; gap: 10px; } .upd .grow { flex: 1; } .pbar { height: 8px; background: var(--soft); border-radius: 6px; overflow: hidden; margin: 12px 0 6px; } .pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); transition: width .2s; }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto; } @keyframes spin { to { transform: rotate(360deg); } }
.fu .ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hero .stat { border: 0; font: inherit; cursor: pointer; }

/* ---- Phase 4 */
.toolrow { display: flex; gap: 8px; padding: 0 16px 10px; }
.lead .chk { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); flex: none; align-self: center; display: grid; place-items: center; background: var(--card); }
.lead .chk svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.lead.sel { box-shadow: 0 0 0 2px var(--brand), var(--shadow-s); } .lead.sel .chk { background: var(--brand); border-color: var(--brand); }
.selmode .lead .side { display: none; }
.selbar { position: fixed; left: 12px; right: 12px; bottom: calc(86px + var(--safe-b)); background: var(--ink); color: var(--bg); border-radius: 18px; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 8px; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.3); font-weight: 700; }
.selbar span { flex: 1; } .selbar .btn.sm { box-shadow: none; }
.lockov { position: fixed; inset: 0; z-index: 90; background: radial-gradient(120% 70% at 50% 0%, #6D6DF5 0%, var(--bg) 62%); display: grid; place-items: center; padding: 24px; }
.lockbox { width: 100%; max-width: 340px; text-align: center; } .lockbox h2 { margin: 6px 0 4px; } .lockic { width: 64px; height: 64px; border-radius: 22px; margin: 0 auto 12px; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand2)); box-shadow: 0 14px 30px rgba(91,91,240,.4); }
.lockic svg { width: 30px; height: 30px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lockbox input { width: 100%; text-align: center; letter-spacing: .6em; font-size: 1.6rem; font-weight: 800; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); outline: 0; }
.pick { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.pick.off { opacity: .55; cursor: default; }
.connrow { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; font: inherit; color: inherit; background: transparent; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.connrow.on { border-color: var(--brand); }
.swchip { font: inherit; font-size: .84rem; font-weight: 700; color: var(--brand); background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
/* the web version in a wide window: one centred, phone-width column instead of stretching every card across the screen */
@media (min-width: 700px) {
  html.web body { background: var(--bg); }
  html.web #app { max-width: 560px; margin: 0 auto; }
  html.web .nav { left: 0; right: 0; margin: 0 auto; max-width: 536px; }
  html.web .sheet { left: 0; right: 0; margin: 0 auto; max-width: 560px; }
  html.web .conn { max-width: 480px; margin: 0 auto; }
}
