/* Keystone – Asset Tree Homes brand: navy #28316F, gold #F4AA1C, grey #4E4E4E (same palette as Plinth / Plumbline) */
:root {
  --navy: #28316F; --navy-2: #1E2557; --navy-3: #3A4590; --navy-soft: #E7E9F4; --navy-tint: #F1F2F9;
  --gold: #F4AA1C; --gold-2: #D98F00; --gold-soft: #FEF3DA; --gold-ink: #6E4700; --grey: #4E4E4E;
  --bg: #F4F5FA; --surface: #FFFFFF; --surface-2: #EEF0F7; --line: #DCDFEE; --line-2: #C9CDE2;
  --ink: #1B1F3B; --muted: #5E6380;
  --ok: #1E8A4C; --ok-bg: #E2F3E9; --warn: #C2362B; --warn-bg: #FBE7E5; --info: #2F6FD0; --info-bg: #E5EEFB; --violet: #7048C8; --violet-bg: #EEE8FB;
  --radius: 12px; --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(27,31,59,.06), 0 1px 1px rgba(27,31,59,.04);
  --shadow-2: 0 8px 24px rgba(27,31,59,.10), 0 2px 6px rgba(27,31,59,.06);
  --shadow-3: 0 24px 60px rgba(20,24,60,.28);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2,.7,.2,1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
a { color: var(--navy); }
td, .kpi b, .num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .grow { flex: 1; }

/* loader */
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--navy); z-index: 100; transition: opacity .4s; }
.loader.out { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }
.loader .lg { display: grid; gap: 18px; justify-items: center; }
.loader img { height: 56px; filter: brightness(0) invert(1); }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 26px; }
.bars i { width: 7px; background: var(--gold); border-radius: 2px; animation: rise 1s var(--ease) infinite; }
.bars i:nth-child(2) { animation-delay: .12s } .bars i:nth-child(3) { animation-delay: .24s } .bars i:nth-child(4) { animation-delay: .36s }
@keyframes rise { 0%,100% { height: 6px } 50% { height: 26px } }

/* sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #3A4590 0, transparent 60%), var(--navy); position: relative; overflow: hidden; }
.auth .arch { position: absolute; inset: auto 0 0 0; width: 100%; height: 46vh; opacity: .12; pointer-events: none; }
.authcard { position: relative; width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 30px 28px 24px; box-shadow: var(--shadow-3); display: grid; gap: 18px; animation: pop .5s var(--ease); }
.authcard > img { height: 52px; justify-self: start; }
.authcard h1 { font-size: 22px; color: var(--navy); } .authcard p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.authcard label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.inp { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; outline: none; transition: border-color .2s, box-shadow .2s; }
.inp:focus { border-color: var(--navy-3); box-shadow: 0 0 0 3px var(--navy-soft); }
.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input { width: 46px; height: 52px; text-align: center; font-size: 22px; font-weight: 600; border-radius: 10px; border: 1px solid var(--line-2); outline: none; }
.otp input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.otp.good input { border-color: var(--ok); background: var(--ok-bg); }
.shake { animation: shake .4s; } @keyframes shake { 25% { transform: translateX(-6px) } 75% { transform: translateX(6px) } }
.msg { min-height: 18px; font-size: 13px; } .msg.err { color: var(--warn); } .msg.ok { color: var(--ok); }
.alt { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.lnk { background: none; border: 0; padding: 0; color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.lnk:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.qrwrap { display: flex; gap: 14px; align-items: center; } .qr { width: 168px; height: 168px; flex: none; } .key { display: block; font-size: 12px; word-break: break-all; background: var(--surface-2); padding: 6px 8px; border-radius: 6px; margin: 6px 0; }
.foot2 { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: rgba(255,255,255,.6); font-size: 11.5px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }

/* buttons, pills */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font-weight: 500; cursor: pointer; transition: background .2s, transform .1s; white-space: nowrap; }
.btn:hover { background: var(--navy-2); } .btn:active { transform: translateY(1px); } .btn:disabled { opacity: .6; cursor: default; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2B1C00; } .btn.gold:hover { background: var(--gold-2); }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line-2); } .btn.ghost:hover { background: var(--navy-tint); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; } .btn.danger { background: #fff; color: var(--warn); border-color: #F0C3BE; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .7s linear infinite; } @keyframes sp { to { transform: rotate(360deg) } }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill.info { background: var(--info-bg); color: var(--info); } .pill.navy { background: var(--navy-soft); color: var(--navy); } .pill.violet { background: var(--violet-bg); color: var(--violet); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 0 rgba(30,138,76,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(30,138,76,.5) } 70% { box-shadow: 0 0 0 8px rgba(30,138,76,0) } 100% { box-shadow: 0 0 0 0 rgba(30,138,76,0) } }

/* shell */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; box-shadow: 0 2px 10px rgba(20,24,60,.25); }
.topbar::after { content: ""; display: block; height: 3px; background: linear-gradient(90deg, var(--gold), #FFC85A 50%, var(--gold)); background-size: 200% 100%; animation: goldflow 8s linear infinite; }
@keyframes goldflow { to { background-position: 200% 0 } }
.topbar .in { max-width: 1500px; margin: 0 auto; padding: 10px max(16px, 2.5vw); display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
.brand img { height: 36px; }
.brand .ttl { display: grid; line-height: 1.2; border-left: 1px solid rgba(255,255,255,.25); padding-left: 14px; }
.brand .ttl b { font-size: 16px; } .brand .ttl small { font-size: 11.5px; color: rgba(255,255,255,.72); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: rgba(255,255,255,.82); text-decoration: none; padding: 7px 13px; border-radius: 8px; font-weight: 500; font-size: 13.5px; transition: background .2s; }
.nav a:hover { background: rgba(255,255,255,.1); } .nav a.on { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 -2px 0 var(--gold); }
.live { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.8); }
.who { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.who .av { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #2B1C00; display: grid; place-items: center; font-weight: 600; }
.who button { background: rgba(255,255,255,.12); border: 0; color: #fff; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
main { max-width: 1500px; margin: 0 auto; padding: 20px max(16px, 2.5vw) 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h2 { font-size: 21px; color: var(--navy); } .head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sel { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 9px; background: #fff; min-width: 120px; max-width: 260px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--navy); color: #fff; }

/* cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 16px 18px; }
.card h3 { font-size: 14.5px; color: var(--navy); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); } .g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-1); position: relative; overflow: hidden; animation: pop .45s var(--ease) both; cursor: default; }
.kpi[data-go] { cursor: pointer; } .kpi[data-go]:hover { border-color: var(--navy-3); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--navy)); }
.kpi span { font-size: 11.5px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.kpi b { display: block; font-size: 25px; font-weight: 600; color: var(--ink); line-height: 1.25; margin-top: 2px; }
.kpi small { font-size: 11.5px; color: var(--muted); }
.funnel { display: grid; gap: 8px; }
.frow { display: grid; grid-template-columns: 160px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.frow .bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.frow .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--navy), var(--navy-3)); border-radius: 6px; width: 0; transition: width .9s var(--ease); }
.frow:nth-child(n+3) .bar i { background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.frow b { text-align: right; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 10px; }
.chart .col { flex: 1; display: grid; align-content: end; gap: 2px; justify-items: center; min-width: 0; }
.chart .stk { width: 100%; max-width: 38px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 2px 2px; overflow: hidden; background: var(--surface-2); }
.chart .stk i { display: block; width: 100%; transition: height .8s var(--ease); }
.chart .lbl { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.chart .v { font-size: 10.5px; color: var(--ink); font-weight: 500; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.c1 { background: #C9CDE2 } .c2 { background: var(--navy) } .c3 { background: var(--gold) }

/* tables */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-1); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; background: var(--navy-tint); border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; transition: background .15s; } tr.click:hover td { background: var(--gold-soft); }
td .sub { display: block; font-size: 11.5px; color: var(--muted); }
.lid { font-weight: 600; color: var(--navy); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line-2); background: #fff; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--muted); transition: all .2s; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip b { font-weight: 600; margin-left: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; font-size: 12.5px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* lead drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(20,24,60,.35); z-index: 50; animation: fade .25s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--bg); z-index: 51; box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slide .35s var(--ease); }
@keyframes slide { from { transform: translateX(40px); opacity: 0 } } @keyframes fade { from { opacity: 0 } }
.dhead { background: var(--navy); color: #fff; padding: 16px 20px; display: grid; gap: 8px; }
.dhead .row1 { display: flex; align-items: center; gap: 10px; }
.dhead h3 { font-size: 18px; } .dhead .x { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 18px; }
.dhead .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: rgba(255,255,255,.8); }
.dbody { overflow: auto; padding: 16px 20px 40px; display: grid; gap: 14px; align-content: start; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.fact { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.fact > span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; } .fact b { font-size: 14px; font-weight: 600; }
.ai { background: linear-gradient(135deg, #fff, var(--gold-soft)); border: 1px solid #F3D9A0; border-radius: var(--radius); padding: 14px 16px; }
.ai h4 { font-size: 13.5px; color: var(--gold-ink); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ai p { margin: 4px 0; white-space: pre-wrap; } .ai .next { font-weight: 500; color: var(--navy); }
.tl { position: relative; display: grid; gap: 10px; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); }
.ev { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; animation: pop .35s var(--ease) both; }
.ev::before { content: ""; position: absolute; left: -20px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--k, var(--line-2)); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.ev .t { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; } .ev .t b { font-weight: 600; font-size: 13px; } .ev .t small { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.ev p { margin: 5px 0 0; font-size: 12.5px; color: var(--grey); white-space: pre-wrap; }
.ev.bot_call { --k: var(--gold); } .ev.bot_attempt { --k: #C9CDE2; } .ev.selldo { --k: var(--navy); } .ev.stage_change { --k: var(--violet); } .ev.booking { --k: var(--ok); }
.ev .acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.ev audio { width: 100%; margin-top: 8px; height: 36px; }
.tx { margin-top: 8px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; display: grid; gap: 5px; max-height: 300px; overflow: auto; font-size: 12.5px; }
.tx .u { color: var(--ink); } .tx .a { color: var(--navy); } .tx i { font-style: normal; font-weight: 600; margin-right: 6px; font-size: 11px; text-transform: uppercase; }
.tx .ta { display: block; color: var(--muted); font-size: 12px; }

/* assistant */
.fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; background: var(--navy); color: #fff; border: 0; border-radius: 999px; padding: 12px 18px 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-2); cursor: pointer; font-weight: 500; }
.fab .sp { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); display: grid; place-items: center; color: #2B1C00; font-weight: 700; }
.chat { position: fixed; right: 22px; bottom: 84px; width: min(420px, calc(100vw - 30px)); height: min(600px, calc(100vh - 120px)); background: #fff; border-radius: 16px; box-shadow: var(--shadow-3); z-index: 45; display: flex; flex-direction: column; overflow: hidden; animation: pop .3s var(--ease); }
.chat .ch { background: var(--navy); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; } .chat .ch b { font-size: 14px; } .chat .ch small { display: block; color: rgba(255,255,255,.7); font-size: 11px; }
.chat .ch button { margin-left: auto; background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.chat .msgs { flex: 1; overflow: auto; padding: 14px; display: grid; gap: 10px; align-content: start; background: var(--bg); }
.bub { max-width: 88%; padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; font-size: 13px; }
.bub.me { justify-self: end; background: var(--navy); color: #fff; border-bottom-right-radius: 4px; } .bub.bot { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bub .lk { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat form input { flex: 1; }
.sugs { display: flex; gap: 6px; flex-wrap: wrap; } .sugs button { border: 1px solid var(--line-2); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--navy); }

/* admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--navy); border-bottom-color: var(--gold); }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
code.url { display: block; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 12px; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 90; box-shadow: var(--shadow-2); font-size: 13px; animation: pop .3s var(--ease); }
.toast.err { background: var(--warn); } .toast.ok { background: var(--ok); }
.note { background: var(--info-bg); color: #1B4C93; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; }
.note.gold { background: var(--gold-soft); color: var(--gold-ink); }
@media (max-width: 760px) { .g2 { grid-template-columns: 1fr; } .frow { grid-template-columns: 110px 1fr 56px; } .brand .ttl small { display: none; } .fab span.t { display: none; } }
