:root {
  --bg: #f4f6fa; --panel: #ffffff; --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e2e8f0; --line-2: #eef2f7;
  --navy: #0b1324; --navy-2: #131d33; --navy-3: #1e2a45;
  --accent: #2f5bea; --accent-2: #1e44c4; --accent-soft: #eaf0ff;
  --hot: #dc2626; --hot-soft: #fee2e2; --warm: #d97706; --warm-soft: #fef3c7; --cool: #475569; --cool-soft: #f1f5f9;
  --good: #059669; --good-soft: #d1fae5; --switch: #7c3aed; --switch-soft: #ede9fe; --teal: #0e7490; --teal-soft: #cffafe;
  --wa: #128c4a; --radius: 12px; --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 12px; margin: 16px 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--hot); } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
i[data-icon] { display: inline-flex; width: 16px; height: 16px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; }

/* ---------- layout */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--navy); color: #a9b4c9; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 18px; color: #fff; }
.brand small { display: block; color: #7f8aa3; font-size: 11px; font-weight: 500; }
.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #3b6cff, #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .02em; }
.logo-mark.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #5d6884; margin: 14px 10px 6px; font-weight: 600; }
.sidebar a { color: #b8c2d6; padding: 8px 10px; border-radius: 8px; margin-bottom: 2px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.sidebar a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.sidebar a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 #4f7bff; }
.sidebar .spacer { flex: 1; }
.me { display: flex; gap: 10px; align-items: center; padding: 10px 8px 0; border-top: 1px solid var(--navy-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-3); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.me-text { min-width: 0; font-size: 12px; } .me-text #whoami { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d5dbe7; }
.linkbtn { background: none; border: 0; color: #7f8aa3; padding: 0; font: inherit; cursor: pointer; } .linkbtn:hover { color: #fff; }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: rgba(244, 246, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.crumb { font-weight: 600; color: var(--ink-2); }
.topbar-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
main { padding: 24px 28px 48px; max-width: 1560px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ---------- primitives */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mt { margin-top: 16px; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wa { color: var(--wa); } .btn.wa:hover { background: #ecfdf3; }
.iconbtn { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 5px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }

/* ---------- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--cool-soft); color: var(--cool); white-space: nowrap; line-height: 18px; }
.badge.hot { background: var(--hot-soft); color: var(--hot); } .badge.warm { background: var(--warm-soft); color: #b45309; } .badge.cool { background: var(--cool-soft); color: var(--cool); }
.badge.switch { background: var(--switch-soft); color: var(--switch); } .badge.untapped { background: var(--good-soft); color: var(--good); }
.badge.teal { background: var(--teal-soft); color: var(--teal); } .badge.blue { background: var(--accent-soft); color: var(--accent-2); }
.badge.outline { background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }
.cc { display: inline-grid; place-items: center; min-width: 30px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--navy-3); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; }
.cc.unknown { background: #cbd5e1; color: var(--ink-2); }
.fit { display: flex; align-items: center; gap: 8px; min-width: 92px; }
.fit b { width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.fit .track { flex: 1; height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.fit .track span { display: block; height: 100%; border-radius: 3px; }
.channels { display: flex; gap: 4px; flex-wrap: wrap; }
.ch { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2); background: #fff; }
.ch:hover { text-decoration: none; border-color: #94a3b8; }
.ch.wa { color: var(--wa); border-color: #bbf7d0; background: #f0fdf4; }
.ch.em { color: var(--accent-2); border-color: #c7d6fe; background: #f5f8ff; }
.ch.tg { color: #0284c7; border-color: #bae6fd; background: #f0f9ff; }
.ch.ph { color: var(--ink-2); }
.ch i[data-icon] { width: 12px; height: 12px; }

/* ---------- KPI + dashboard */
.kpi { position: relative; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.progress { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #3b6cff, #7c3aed); border-radius: 4px; }
.bars .bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.bars .bar-row:last-child { border-bottom: 0; }
.bars .bar-row .track { height: 10px; background: var(--line-2); border-radius: 5px; overflow: hidden; position: relative; }
.bars .bar-row .track span { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.bars .bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.bars .bar-row .lbl { font-weight: 500; display: flex; gap: 8px; align-items: center; min-width: 0; }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.spark div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.spark span.b { width: 100%; max-width: 28px; background: linear-gradient(180deg, #5b82ff, #2f5bea); border-radius: 4px 4px 0 0; min-height: 2px; }
.spark small { font-size: 10px; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.quick button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 14px; cursor: pointer; font: inherit; display: flex; gap: 12px; align-items: flex-start; }
.quick button:hover { border-color: var(--accent); background: #fbfcff; }
.quick .qi { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.quick b { display: block; font-size: 13.5px; } .quick span { font-size: 12px; color: var(--muted); }

/* ---------- leads workspace */
.segments { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.seg { flex: 0 0 auto; min-width: 150px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 14px; cursor: pointer; text-align: left; font: inherit; box-shadow: var(--shadow); }
.seg:hover { border-color: #b6c4e0; }
.seg.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg .t { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; gap: 6px; align-items: center; }
.seg .n { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.facets { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding: 6px 0; }
.facet { padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.facet:last-child { border-bottom: 0; }
.facet h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.facet h4 button { background: none; border: 0; color: var(--accent); font-size: 11px; cursor: pointer; padding: 0; text-transform: none; letter-spacing: 0; }
.facet label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 0; color: var(--ink); font-size: 13px; cursor: pointer; font-weight: 400; }
.facet label .c { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.facet label.zero { opacity: .45; }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search input { padding-left: 34px; }
.toolbar .search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.range { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.range button { border: 0; background: none; padding: 7px 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); font-weight: 500; }
.range button + button { border-left: 1px solid var(--line); }
.range button.on { background: var(--navy-3); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); font-size: 12px; font-weight: 500; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; padding: 0 2px; }
.bulk { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--accent-soft); border-bottom: 1px solid #d5e0fd; font-size: 13px; }
.bulk select { width: auto; padding: 5px 8px; }
.tablewrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
th.sort { cursor: pointer; user-select: none; } th.sort:hover { color: var(--ink); }
th .arrow { opacity: .5; margin-left: 2px; }
tbody tr:hover { background: #f8faff; }
tr.selected { background: #f3f6ff; }
td.name { min-width: 220px; }
td.name a.title { color: var(--ink); font-weight: 600; }
td.name .sub { display: flex; gap: 6px; align-items: center; margin-top: 3px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
td select.status { width: auto; padding: 4px 6px; font-size: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; color: var(--muted); font-size: 12.5px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.brokers { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }

/* ---------- lead profile */
.hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.hero .avatar-lg { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, #3b6cff, #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none; }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; color: var(--muted); font-size: 13px; }
.hero .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hero .actions select { width: auto; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.list-plain { margin: 4px 0; padding-left: 18px; } .list-plain li { margin: 3px 0; }
.angle { background: linear-gradient(135deg, #f5f3ff, #eef2ff); border: 1px solid #ddd6fe; border-radius: 10px; padding: 12px 14px; }
.contact-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.contact-row:last-child { border-bottom: 0; }
.contact-row .val { font-weight: 600; word-break: break-all; }
.contact-row .act { margin-left: auto; display: flex; gap: 6px; }

/* ---------- export */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; }
.opt-grid label, .radio-list label { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 13px; margin: 0; font-weight: 400; cursor: pointer; }
.radio-list { display: grid; gap: 8px; }
.radio-list label { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.radio-list label:has(input:checked) { border-color: var(--accent); background: #f7f9ff; }
.radio-list label .c { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.step { display: flex; gap: 10px; align-items: center; margin: 18px 0 10px; font-weight: 600; }
.step span { width: 22px; height: 22px; border-radius: 50%; background: var(--navy-3); color: #fff; display: grid; place-items: center; font-size: 11px; }
.step:first-child { margin-top: 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; margin: 8px 0; }

/* ---------- modal, toast, login */
.modal-back { position: fixed; inset: 0; background: rgba(11, 19, 36, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: 760px; max-width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 14px 14px; }
.modal-foot .msg { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 10% -10%, #1e2a55 0%, var(--navy) 55%); padding: 16px; }
.login-card { width: 380px; background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.login-card h1 { margin-top: 14px; }
.login-card button { margin-top: 18px; padding: 10px; }

.only-mobile { display: none; }
@media (max-width: 1100px) { .workspace { grid-template-columns: 1fr; } .facets { position: static; max-height: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .only-mobile { display: grid; }
  main { padding: 16px; } .topbar { padding: 0 16px; } .topbar .btn span { display: none; }
  .bars .bar-row { grid-template-columns: 110px 1fr 50px; }
}
