:root {
  --navy: #13235b;
  --blue: #2346c8;
  --gold: #e3a92b;
  --green: #2e8b3e;
  --wa: #1fa855;
  --red: #c8342d;
  --bg: #f4f6fb;
  --card: #fff;
  --text: #1b2238;
  --muted: #667089;
  --line: #e2e6f0;
  --radius: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 18px; }
h3 { font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
}
.top .brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.top .brand i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); display: inline-block; }
.top .me { margin-left: auto; font-size: 13px; opacity: .85; display: flex; gap: 10px; align-items: center; }
.top .me button { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; padding: 3px 8px; cursor: pointer; }

/* bottom tabs on phone, top tabs on desktop */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center; padding: 8px 2px 9px; font-size: 12px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.tabs a b { display: block; font-size: 19px; line-height: 1.2; font-weight: 400; }
.tabs a.on { color: var(--blue); }
.tabs a.add b { color: #fff; background: var(--blue); border-radius: 50%; width: 30px; height: 30px; margin: -2px auto 0; line-height: 29px; }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 96px; }
@media (min-width: 760px) {
  .tabs { position: sticky; top: 49px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; }
  .tabs a { flex: 0 0 120px; font-size: 14px; }
  main { padding-bottom: 40px; }
}

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 22px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .who { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.row .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); padding: 6px 0; margin: 0; }
.late { color: var(--red); font-weight: 600; }

/* pills */
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #eef1f8; color: var(--navy); white-space: nowrap; }
.st-new { background: #fff3d6; color: #8a5a00; }
.st-contacted { background: #e5ecff; color: #2346c8; }
.st-demo_booked { background: #efe4ff; color: #6b2bc4; }
.st-demo_done { background: #dff4f7; color: #146b78; }
.st-enrolled { background: #dff3e2; color: #1d6b2c; }
.st-paused { background: #eceef3; color: #555e75; }
.st-lost { background: #fbe3e1; color: #a1271f; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 10px; padding: 8px 12px; cursor: pointer; text-decoration: none; font-weight: 600;
  min-height: 38px;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; font-size: 17px; }
.btn:disabled { opacity: .6; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* filters */
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input { flex: 1; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; white-space: nowrap; cursor: pointer; font-size: 13px; }
.chips button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* forms */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .form { grid-template-columns: 1fr; } }
input, select, textarea {
  width: 100%; border: 1px solid #cdd3e2; border-radius: 10px; padding: 9px 10px; background: #fff; color: var(--text);
  font-size: 16px; /* stops iPhone zooming in */
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: var(--blue); }

/* lead page */
.lead-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.lead-head h2 { font-size: 22px; margin-bottom: 2px; }
.meta { color: var(--muted); font-size: 13px; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; }
.stages button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.stages button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.timeline li:first-child { border-top: 0; }
.timeline small { color: var(--muted); display: block; }
.timeline .t-note { white-space: pre-wrap; }
.timeline .t-stage, .timeline .t-system { color: var(--muted); }
.timeline .t-payment { color: var(--green); }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; }

/* reports */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; border-top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--blue); border-radius: 3px; min-width: 2px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}
.toast.err { background: var(--red); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 24px; }
.login h1 { font-size: 22px; color: var(--navy); }
.login p { color: var(--muted); margin-top: 0; }
.login label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.login .btn { width: 100%; margin-top: 4px; }
.login .error { color: var(--red); min-height: 20px; margin: 8px 0 0; font-size: 14px; }
