/* GPC Lead Radar: same Good People Co. brand as the GPC Outreach app.
   Cream canvas, navy ink, orange accent, Klein blue links.
   Fonts: Bricolage Grotesque (display), Figtree (body), Space Mono (labels).
   Phone: bottom tab bar. PC: top tab bar. Light and dark. */
:root {
  --bg: #f1eee7; --surface: #fbfaf6; --surface-2: #f6f3ec; --ink: #0a0f2c; --muted: #5b5f76; --line: #e0dbd0;
  --primary: #0a0f2c; --primary-ink: #f1eee7;
  --accent: #ff5b2e; --accent-strong: #e0441a; --accent-soft: #ffe3d9; --link: #2338ff; --link-soft: #e2e5ff;
  --good: #17663f; --good-soft: #e3f3ea; --warn: #b54a12; --warn-soft: #ffe8dc; --amber: #8a5300; --amber-soft: #fdf1dc;
  --danger: #b3261e; --danger-soft: #fbe3e0;
  --shadow: 0 1px 2px rgba(10, 15, 44, 0.05), 0 6px 18px rgba(10, 15, 44, 0.05);
  --radius: 14px; --tab-h: 64px;
  --font-display: 'Bricolage Grotesque', 'Figtree', -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f2c; --surface: #11173a; --surface-2: #161d45; --ink: #f1eee7; --muted: #a3a7c0; --line: #232a57;
    --primary: #f1eee7; --primary-ink: #0a0f2c;
    --accent: #ff6b42; --accent-strong: #ff8a66; --accent-soft: #3a1e22; --link: #a9b8ff; --link-soft: #1d2563;
    --good: #7fd3a4; --good-soft: #183325; --warn: #ffa27a; --warn-soft: #3a2220; --amber: #f0b45a; --amber-soft: #3a2c14;
    --danger: #ff8f84; --danger-soft: #3d1c24; --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font-body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--line); padding: 0 5px; border-radius: 5px; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); }
.small { font-size: 13px; }
.count { font-family: var(--font-mono); font-size: 11px; color: var(--accent-strong); font-weight: 700; margin-left: 3px; }

/* ---------- top bar (PC) / header (phone) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand img.logo { width: 30px; height: 30px; border-radius: 8px; }
.brand b { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; border: 0; background: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.active { color: var(--ink); }
.tabs button.active::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 1px; height: 3px; border-radius: 3px; background: var(--accent); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); font-size: 18px; }

/* phone: bottom tab bar */
.bottombar { display: none; }
@media (max-width: 899px) {
  .tabs { display: none; }
  .topbar { justify-content: space-between; }
  .bottombar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottombar-inner { max-width: 560px; margin: 0 auto; display: flex; height: var(--tab-h); }
  .bottombar button { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 10.5px; font-weight: 600; cursor: pointer; white-space: nowrap; letter-spacing: -0.01em; }
  .bottombar svg { width: 23px; height: 23px; }
  .bottombar button.active { color: var(--ink); }
  .bottombar button.active::after { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .bottombar .dot { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; }
  .view { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px) !important; }
}
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 44, 0.35); z-index: 9; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-radius: 18px 18px 0 0; padding: 10px 12px calc(env(safe-area-inset-bottom) + 14px); box-shadow: 0 -8px 30px rgba(10, 15, 44, 0.15); }
.sheet button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 14px 12px; border: 0; background: none; border-radius: 12px; font-size: 16px; font-weight: 600; cursor: pointer; text-align: left; }
.sheet button:active { background: var(--surface-2); }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 2px auto 8px; }

.banner { background: var(--warn-soft); color: var(--warn); padding: 9px 20px; font-size: 13.5px; }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; padding: 16px 20px 0; max-width: 1400px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12.5px; }
.kpi.hot b { color: var(--accent-strong); }
@media (max-width: 899px) {
  .kpis { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 12px 14px 2px; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpi { flex: 0 0 142px; scroll-snap-align: start; } .kpi b { font-size: 24px; } .kpi span { font-size: 12px; line-height: 1.3; display: block; }
}
.view { padding: 16px 20px 60px; max-width: 1400px; }
@media (max-width: 899px) { .view { padding: 12px 14px; } }

/* ---------- controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--ink); color: var(--bg); }
select, input[type=text], input[type=search], input[type=url], input[type=email], input[type=password], textarea {
  min-height: 38px; padding: 7px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; outline: none; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 110px; resize: vertical; }
@media (max-width: 899px) {
  .toolbar select, .toolbar input[type=search] { flex: 1 1 45%; min-width: 0; font-size: 16px; }
  .toolbar input[type=search] { flex-basis: 100%; }
  input, select, textarea { font-size: 16px !important; } /* stops iPhone zooming in */
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.open { background: var(--accent); border-color: var(--accent); color: #fff; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a:hover { color: var(--accent); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.tiny { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.on-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.btn.on-bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }

/* ---------- lead cards ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card { display: grid; grid-template-columns: 1fr 300px; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card.dim { opacity: 0.6; }
@media (max-width: 899px) { .card { grid-template-columns: 1fr; gap: 10px; padding: 13px 14px; } }
.card-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 7px; }
.card h3 { font-family: var(--font-display); font-weight: 650; font-size: 17.5px; letter-spacing: -0.01em; line-height: 1.3; margin: 0 0 3px; }
.who { color: var(--muted); font-size: 13.5px; margin-bottom: 6px; }
.snippet { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; max-height: 4.4em; overflow: hidden; margin: 8px 0 6px; padding-left: 12px; border-left: 3px solid var(--accent); cursor: pointer; }
.snippet.open { max-height: none; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600; }
.chip.kw { background: none; border-style: dashed; color: var(--muted); font-weight: 500; font-family: var(--font-mono); font-size: 11px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.age-fresh { background: var(--good-soft); color: var(--good); }
.age-mid { background: var(--amber-soft); color: var(--amber); }
.age-old { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.score-hi { background: var(--accent); color: #fff; }
.score-mid { background: var(--accent-soft); color: var(--accent-strong); }
.score-lo { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.src { background: var(--link-soft); color: var(--link); }
.warn { background: var(--danger-soft); color: var(--danger); }
.contact { border-left: 1px solid var(--line); padding-left: 16px; font-size: 14px; display: flex; flex-direction: column; gap: 7px; }
@media (max-width: 899px) { .contact { border-left: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line); } }
.contact h4 { margin: 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.contact .line { display: flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.contact .none { color: var(--muted); font-style: italic; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.actions select { min-height: 30px; padding: 3px 8px; font-size: 13px; }
.notes { margin-top: 8px; min-height: 40px !important; }

/* ---------- tables & panels ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); overflow-x: auto; }
.panel h2 { font-family: var(--font-display); font-size: 19px; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 4px; }
.panel p.muted { margin-top: 0; font-size: 13.5px; }
@media (max-width: 1100px) { .panel td:last-child .bar { display: none; } }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.form-row > * { flex: 1; min-width: 140px; }
.form-row .btn { flex: 0 0 auto; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.empty { text-align: center; padding: 44px 22px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
pre.log { white-space: pre-wrap; font-family: var(--font-mono); font-size: 11px; max-height: 220px; overflow: auto; background: var(--surface-2); padding: 8px; border-radius: 8px; }

/* ---------- sign in + toast ---------- */
.login { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 22px 40px; }
.login .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 22px; }
.login .wordmark { height: 26px; width: auto; display: block; margin-bottom: 6px; }
.login .wordmark.dark { display: none; }
@media (prefers-color-scheme: dark) { .login .wordmark.light { display: none; } .login .wordmark.dark { display: block; } }
.login h1 { font-family: var(--font-display); font-size: 30px; margin: 10px 0 6px; letter-spacing: -0.02em; }
.login p { color: var(--muted); margin: 0 0 20px; }
.login label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login label input { display: block; width: 100%; margin-top: 5px; min-height: 44px; font-size: 16px; background: var(--surface-2); }
.login .btn { width: 100%; min-height: 46px; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 600; z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
@media (max-width: 899px) { .toast { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); } }

/* region selector in the top bar */
.top-actions { display: flex; gap: 8px; align-items: center; }
.region-select { min-height: 40px; border-radius: 12px; font-weight: 600; max-width: 170px; }
@media (max-width: 899px) { .region-select { max-width: 150px; font-size: 14px !important; } }
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: 14px; padding-right: 14px; }
  .brand b { font-size: 18px; }
  .brand img.logo { width: 26px; height: 26px; }
  .region-select { max-width: 128px; min-height: 36px; padding: 4px 8px; }
  .icon-btn { width: 36px; height: 36px; }
}
