:root {
  --bg: #0d0f14; --panel: #151922; --panel2: #1b2030; --line: #262c3b; --text: #e9ebf0; --muted: #8a91a3;
  --accent: #f2994a; --hot: #ef5b4c; --warm: #f2994a; --curious: #e9c46a; --cold: #6c8ebf; --dq: #6b6f7b;
  --ok: #3ccf91; --wa-bg: #0b141a; --wa-in: #202c33; --wa-out: #005c4b;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); color: #1a1208; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
button.link { background: none; padding: 0; color: var(--muted); font-weight: 400; text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { width: 100%; resize: vertical; min-height: 70px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--hot); min-height: 1em; }
.small { font-size: 12px; }

.login { min-height: 100vh; display: grid; place-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login .card { width: 340px; display: grid; gap: 12px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand span { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.brand.big { font-size: 24px; }

.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 8px 16px; }
.side a { text-decoration: none; padding: 9px 10px; border-radius: 8px; color: var(--muted); }
.side a.on { background: rgba(242,153,74,.12); color: var(--text); outline: 1px solid rgba(242,153,74,.4); }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 8px; }
.flag { font-size: 12px; padding: 4px 8px; border-radius: 6px; width: fit-content; }
.flag.live { background: rgba(60,207,145,.15); color: var(--ok); }
.flag.test { background: rgba(233,196,106,.15); color: var(--curious); }
main { padding: 22px 26px; min-width: 0; }
h1 { font-size: 20px; margin: 0 0 16px; }
h3 { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }

/* Leads */
.tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 0; text-decoration: none; color: var(--muted); cursor: pointer; }
.tabs a.on { color: var(--text); border-bottom: 2px solid var(--accent); }
.tabs b { font-weight: 400; color: var(--muted); margin-left: 4px; }
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { width: 240px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--panel2); }
td .sub { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.band { font-weight: 600; text-transform: capitalize; }
.band.hot { color: var(--hot); } .band.warm { color: var(--warm); } .band.curious { color: var(--curious); }
.band.cold { color: var(--cold); } .band.disqualified { color: var(--dq); }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 5px; background: var(--panel2); color: var(--muted); margin-left: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Lead / test chat */
.split { display: grid; grid-template-columns: minmax(320px, 420px) minmax(300px, 1fr); gap: 22px; align-items: start; }
.phone { background: #000; border-radius: 36px; padding: 12px; border: 1px solid #2a2a2a; }
.phone-head { background: #1f2c34; border-radius: 26px 26px 0 0; padding: 12px 16px; display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #1a1208; font-weight: 700; }
.phone-head .who { font-weight: 600; } .phone-head .st { font-size: 12px; color: var(--muted); }
.thread { background: var(--wa-bg); height: 560px; overflow-y: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 82%; padding: 7px 9px 4px; border-radius: 8px; line-height: 1.38; white-space: pre-wrap; word-wrap: break-word; position: relative; }
.msg.in { background: var(--wa-in); align-self: flex-start; }
.msg.out { background: var(--wa-out); align-self: flex-end; }
.msg.member { background: #33415c; align-self: flex-end; }
.msg .meta { font-size: 10.5px; color: rgba(255,255,255,.55); text-align: right; margin-top: 2px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.msg .meta .lk { color: var(--curious); }
.msg .meta .fl { color: var(--hot); }
.msg.sel { outline: 2px solid var(--accent); }
.msg.out { cursor: pointer; }
.msg a { color: #53bdeb; }
.compose { background: #1f2c34; border-radius: 0 0 26px 26px; padding: 10px; display: flex; gap: 8px; }
.compose input { flex: 1; border-radius: 20px; background: #2a3942; border: 0; }
.compose button { border-radius: 20px; background: var(--ok); color: #062014; }
.below { display: flex; gap: 14px; justify-content: center; margin-top: 10px; font-size: 13px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 12px; padding: 4px 8px; }

.panel { background: linear-gradient(180deg, #171b26, #121620); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.score-top { display: flex; gap: 18px; align-items: center; }
.ring { width: 96px; height: 96px; }
.ring text { fill: var(--text); font-weight: 700; }
.bandbar { display: grid; grid-template-columns: var(--cols); gap: 3px; margin-top: 14px; }
.bandbar div { height: 6px; border-radius: 3px; background: var(--line); }
.bandbar div.on { background: var(--accent); }
.bandlabels { display: grid; grid-template-columns: var(--cols); gap: 3px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 4px; }
.bandlabels .on { color: var(--text); font-weight: 700; }
.readnote { font-style: italic; line-height: 1.5; color: #d6d9e2; }
.miles { display: grid; gap: 6px; }
.mile { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.mile.on { color: var(--text); border-color: rgba(60,207,145,.35); }
.mile .ck { width: 16px; text-align: center; color: var(--ok); }
.events { display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.ev { display: flex; gap: 8px; font-size: 13px; }
.ev .d { width: 34px; text-align: right; font-weight: 700; }
.ev .d.up { color: var(--ok); } .ev .d.down { color: var(--hot); }
.ev .why { flex: 1; color: #cfd3dc; }
.ev .after { color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.note { background: var(--panel2); border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; margin-bottom: 6px; }
.note .by { color: var(--muted); font-size: 11px; margin-top: 4px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rate { display: flex; gap: 3px; flex-wrap: wrap; }
.rate button { padding: 4px 8px; background: var(--panel2); color: var(--text); font-weight: 500; }
.rate button.on { background: var(--accent); color: #1a1208; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips label { font-size: 12px; background: var(--panel2); padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.list { display: grid; gap: 10px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.item .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.keybox { background: #10251c; border: 1px solid rgba(60,207,145,.4); padding: 12px; border-radius: 8px; font-family: ui-monospace, monospace; word-break: break-all; }
.prev { display: grid; gap: 6px; margin-top: 12px; }
.prev a { text-decoration: none; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; display: flex; justify-content: space-between; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; } .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0; } .split { grid-template-columns: 1fr; }
}
