/* GPC Outreach app — mobile-first, light and dark. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1b1a17;
  --muted: #6e6a62;
  --line: #e4e0d8;
  --accent: #1e5b43;
  --accent-soft: #e3efe8;
  --accent-ink: #ffffff;
  --warn: #9a5a00;
  --warn-soft: #fdf1dc;
  --danger: #a32a1c;
  --danger-soft: #fbe5e2;
  --shadow: 0 1px 2px rgba(27, 26, 23, 0.05), 0 4px 16px rgba(27, 26, 23, 0.04);
  --radius: 14px;
  --tab-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1c1c1a;
    --surface-2: #222220;
    --ink: #edebe6;
    --muted: #a19d94;
    --line: #2f2e2b;
    --accent: #6cc59c;
    --accent-soft: #1f3a2e;
    --accent-ink: #0f1f17;
    --warn: #f0b45a;
    --warn-soft: #3a2c14;
    --danger: #f08a7c;
    --danger-soft: #3d1f1b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  padding: calc(env(safe-area-inset-top) + 10px) 18px 10px;
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; min-height: 40px; }
.topbar h1 { font-size: 24px; letter-spacing: -0.01em; margin: 0; flex: 1; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }

.tabbar {
  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);
}
.tabbar-inner { max-width: 520px; margin: 0 auto; display: flex; height: var(--tab-h); }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab .dot {
  position: absolute; top: 9px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center;
}

@media (min-width: 900px) {
  .tabbar { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .tabbar-inner { max-width: 760px; justify-content: flex-start; gap: 4px; height: 52px; padding: 0 12px; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 14px; font-size: 14px; }
  .tab svg { width: 20px; height: 20px; }
  .tab .dot { position: static; }
  .topbar { top: 52px; padding-top: 14px; }
  .app { padding-top: 52px; }
  main { padding-bottom: 48px; }
}

/* ---------- Sections & cards ---------- */
.section { margin: 22px 0 8px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin: 0 4px 10px; }
.section-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; font-weight: 700; }
.section-head .count { font-size: 13px; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px;
}
.card.tap { cursor: pointer; }
.card-row { display: flex; align-items: flex-start; gap: 12px; }
.card-main { flex: 1; min-width: 0; }
.name { font-weight: 650; font-size: 16.5px; }
.company { color: var(--muted); font-size: 14px; }
.meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.meta.late { color: var(--warn); font-weight: 600; }
.hint {
  margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px dashed var(--line); font-size: 14px; color: var(--ink);
}
.hint b { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 2px; }
.quote {
  margin-top: 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent);
  font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.row:first-child { border-top: 0; }
.row:active, .card.tap:active { background: var(--surface-2); }
.row .right { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.chev { color: var(--muted); flex: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 11px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }
.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);
}
.icon-btn svg { width: 20px; height: 20px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Status pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill.s-active { background: #e6eef9; color: #1d4e89; }
.pill.s-replied { background: #e3f3ea; color: #17663f; }
.pill.s-call-booked { background: #dff2f1; color: #0f5e5a; }
.pill.s-proposal-sent { background: #eee8f8; color: #5b3a9a; }
.pill.s-won { background: #1e5b43; color: #fff; }
.pill.s-not-interested { background: #eeedea; color: #5f5b53; }
.pill.s-no-response { background: #f1ece4; color: #6b5b45; }
.pill.s-paused { background: #fdf1dc; color: #8a5300; }
.pill.s-bounced { background: #fbe5e2; color: #9b2c1e; }
@media (prefers-color-scheme: dark) {
  .pill.s-active { background: #1c2a3d; color: #8fb6ec; }
  .pill.s-replied { background: #183325; color: #7fd3a4; }
  .pill.s-call-booked { background: #143332; color: #79d0c9; }
  .pill.s-proposal-sent { background: #2a2140; color: #bba2ec; }
  .pill.s-won { background: #6cc59c; color: #0f1f17; }
  .pill.s-not-interested { background: #2a2927; color: #b3aea4; }
  .pill.s-no-response { background: #2e2920; color: #cdbb9c; }
  .pill.s-paused { background: #3a2c14; color: #f0b45a; }
  .pill.s-bounced { background: #3d1f1b; color: #f08a7c; }
}

/* ---------- Summary strip ---------- */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 4px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat.hot .n { color: var(--accent); }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 16px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; }
.intervals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.intervals label { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; }
.intervals input { text-align: center; padding: 10px 4px; }
.total { margin-top: 8px; font-size: 14px; }
.total b { color: var(--accent); }

/* ---------- Lead detail ---------- */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); text-decoration: none; font-weight: 600; font-size: 15px; margin: 4px 0 6px; cursor: pointer; background: none; border: 0; padding: 0; }
.lead-head h2 { font-size: 24px; margin: 4px 0 2px; letter-spacing: -0.01em; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 14px; }
.fact { background: var(--surface); padding: 10px 14px; }
.fact .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.fact .v { font-size: 15px; font-weight: 600; margin-top: 1px; }
.msg { border-top: 1px solid var(--line); padding: 12px 16px; }
.msg:first-child { border-top: 0; }
.msg .who { font-size: 13.5px; font-weight: 650; display: flex; gap: 8px; align-items: baseline; }
.msg .who span { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.msg .body { font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; max-height: 8.6em; overflow: hidden; position: relative; }
.msg .body.open { max-height: none; }
.msg.mine { background: var(--surface-2); }
.more { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 13.5px; padding: 6px 0 0; cursor: pointer; }
.timeline { font-size: 13.5px; }
.timeline .t { display: flex; gap: 10px; padding: 7px 16px; border-top: 1px solid var(--line); }
.timeline .t:first-child { border-top: 0; }
.timeline .t .d { color: var(--muted); width: 74px; flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Leads list ---------- */
.search { position: relative; margin: 4px 0 10px; }
.search input { padding-left: 38px; background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 12px; width: 20px; height: 20px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .big { font-size: 20px; font-weight: 650; color: var(--ink); margin-bottom: 6px; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 8px 0; }
.banner.err { background: var(--danger-soft); color: var(--danger); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 20; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.skeleton { height: 76px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin-bottom: 10px; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
.signin { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 22px 40px; }
.signin .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 18px; }
.signin h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -0.02em; }
.signin p { color: var(--muted); margin: 0 0 20px; }
.signin ol { color: var(--muted); padding-left: 20px; font-size: 14.5px; margin: 0 0 20px; }
.signin ol li { margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 12px; }
.hidden { display: none !important; }
