:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0284c7;
  --danger: #dc2626;
  --ok: #16a34a;

  /* Status colors — these drive the pins, the list dots and the legend.
     Changing one here changes it everywhere. */
  --s-to-visit:       #6b7280;  /* grey   */
  --s-visited:        #2563eb;  /* blue   */
  --s-follow-up:      #f97316;  /* orange */
  --s-signed:         #16a34a;  /* green  */
  --s-not-interested: #dc2626;  /* red    */

  /* Everything gets tapped with a thumb, standing next to a car. */
  --tap: 52px;
  --tap-lg: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

/* ─────────────── top bar ─────────────── */
.topbar {
  flex: none;
  background: #0f172a;
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 7px) 10px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 11px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

/* The recurring-revenue counter. Always on screen, never scrolls away. */
.revenue {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding-left: 3px;
  overflow: hidden;
}
.rev-num {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: #4ade80;
}
.rev-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
  font-weight: 600;
}
.rev-sep {
  width: 1px;
  height: 15px;
  background: #334155;
  margin: 0 3px;
  align-self: center;
}

.pill {
  flex: none;
  height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 14.5px;
  font-weight: 650;
  cursor: pointer;
}
.pill.is-on { background: var(--accent); }
.pill.has-filters::after {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ─────────────── map stage ─────────────── */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
  background: #e2e8f0;
  z-index: 0;
}

.legend {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 500;
  background: rgba(255,255,255,.94);
  border-radius: 9px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: #334155;
  box-shadow: 0 1px 6px rgba(15,23,42,.18);
  pointer-events: none;
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(15,23,42,.2);
}
.legend i[data-s="to-visit"]       { background: var(--s-to-visit); }
.legend i[data-s="visited"]        { background: var(--s-visited); }
.legend i[data-s="follow-up"]      { background: var(--s-follow-up); }
.legend i[data-s="signed"]         { background: var(--s-signed); }
.legend i[data-s="not-interested"] { background: var(--s-not-interested); }

/* Recenter-on-me button, sits above the list panel */
.fab {
  position: absolute;
  right: 12px;
  bottom: 130px;
  z-index: 600;
  width: 48px; height: 48px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15,23,42,.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: bottom .22s ease;
}
.fab-ring {
  width: 18px; height: 18px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  position: relative;
}
.fab-ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--accent);
  border-radius: 50%;
}
.fab.is-live .fab-ring { border-color: var(--ok); }
.fab.is-live .fab-ring::after { background: var(--ok); }
body.list-open .fab { bottom: calc(58dvh + 12px); }

/* ─────────────── floating list panel ─────────────── */
.listpanel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 700;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -3px 18px rgba(15,23,42,.18);
  display: flex;
  flex-direction: column;
  height: 112px;
  transition: height .22s ease;
}
body.list-open .listpanel { height: 58dvh; }

.listhead {
  flex: none;
  border: 0;
  background: none;
  width: 100%;
  padding: 9px 14px 7px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "grip grip" "count caret";
  align-items: center;
  gap: 4px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.grip {
  grid-area: grip;
  width: 36px; height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  justify-self: center;
  margin-bottom: 3px;
}
#count { grid-area: count; }
.caret {
  grid-area: caret;
  font-size: 11px;
  transition: transform .22s ease;
}
body.list-open .caret { transform: rotate(180deg); }

.list {
  list-style: none;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  min-height: var(--tap);
}
.item:active { background: #f1f5f9; }

.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex: none;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(15,23,42,.18);
}
.dot[data-s="to-visit"]       { background: var(--s-to-visit); }
.dot[data-s="visited"]        { background: var(--s-visited); }
.dot[data-s="follow-up"]      { background: var(--s-follow-up); }
.dot[data-s="signed"]         { background: var(--s-signed); }
.dot[data-s="not-interested"] { background: var(--s-not-interested); }

.item-main { flex: 1; min-width: 0; }
.item-name {
  font-weight: 640;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-meta {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-right {
  flex: none;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.dist {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.badge {
  font-size: 10.5px;
  font-weight: 750;
  padding: 2px 6px;
  border-radius: 5px;
  background: #ecfdf5;
  color: #047857;
  white-space: nowrap;
}
.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* ─────────────── sheets ─────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 900;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 34px rgba(15,23,42,.3);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(18px); opacity: .5; } }

.sheet-grip {
  width: 40px; height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 9px auto 2px;
  flex: none;
}

.lead-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 16px 4px;
}
.lead-head-text { flex: 1; min-width: 0; }
.lead-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.24;
  letter-spacing: -0.01em;
}
.lead-head .icon-btn {
  background: #f1f5f9;
  color: var(--muted);
  font-size: 23px;
  border-radius: 50%;
  width: 34px; height: 34px;
}
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.lead-body {
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.block { display: flex; flex-direction: column; gap: 8px; }
.block-label {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* Navigate — the biggest thing on the card */
.navbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: var(--tap-lg);
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}
.navbtn:active { background: #0369a1; }
.navbtn-arrow { transform: rotate(-45deg); font-size: 15px; }
.navbtn.as-button { font-size: 17px; }

/* Station counter — huge +/- , no keyboard */
.stepper {
  display: grid;
  grid-template-columns: var(--tap-lg) 1fr var(--tap-lg);
  align-items: center;
  gap: 10px;
}
.step {
  height: var(--tap-lg);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}
.step:active { background: #e2e8f0; }
.step:disabled { opacity: .35; }
.stepnum {
  text-align: center;
  font-size: 40px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Text inputs — only used for the contact, the one thing worth typing */
.lead-body input,
.lead-body select,
.lead-body textarea {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 13px;
  font-size: 16px; /* keeps iOS from zooming */
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
}
.lead-body textarea { resize: vertical; }

.phonerow { display: flex; gap: 8px; }
.phonerow input { flex: 1; min-width: 0; }
.callbtn {
  flex: none;
  display: grid;
  place-items: center;
  width: 78px;
  border-radius: 12px;
  background: var(--ok);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}
.callbtn.is-off {
  background: #e2e8f0;
  color: #94a3b8;
  pointer-events: none;
}

/* One-tap tag chips: outcomes, and the filter panel's options */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  min-height: var(--tap);
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: 26px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.tag.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* Status buttons — one tap saves and closes */
.statusgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.statusbtn {
  min-height: var(--tap-lg);
  border: 2px solid transparent;
  border-radius: 14px;
  color: #fff;
  font-size: 16.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  opacity: .93;
}
.statusbtn:active { transform: scale(.97); }
.statusbtn.is-current {
  border-color: var(--ink);
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(15,23,42,.13);
}
.statusbtn.is-current::after { content: "✓"; font-size: 15px; }
.statusbtn[data-s="to-visit"]       { background: var(--s-to-visit); }
.statusbtn[data-s="visited"]        { background: var(--s-visited); }
.statusbtn[data-s="follow-up"]      { background: var(--s-follow-up); }
.statusbtn[data-s="signed"]         { background: var(--s-signed); grid-column: 1 / -1; }
.statusbtn[data-s="not-interested"] { background: var(--s-not-interested); grid-column: 1 / -1; }

.notes-block summary {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
}

.wide-ghost {
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 620;
  cursor: pointer;
  padding: 0 14px;
  text-align: left;
}
.wide-ghost:active { background: #f1f5f9; }

.searchrow { display: flex; gap: 8px; }
.searchrow input { flex: 1; min-width: 0; }
.searchrow button {
  flex: none;
  width: 66px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.searchrow button:disabled { opacity: .6; }

.hint { font-size: 12.5px; color: var(--muted); margin: 0; }

.danger-text {
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  padding: 8px;
  cursor: pointer;
  align-self: center;
}

.sheet-msg {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  padding: 11px 13px;
  border-radius: 11px;
}
.sheet-msg.ok  { background: #dcfce7; color: #14532d; }
.sheet-msg.bad { background: #fee2e2; color: #7f1d1d; }

/* ─────────────── toasts ─────────────── */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: 92vw;
  pointer-events: none;
}
.toast {
  padding: 13px 20px;
  border-radius: 13px;
  color: #fff;
  font-size: 15.5px;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(15,23,42,.35);
  animation: pop .15s ease-out;
  text-align: center;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.toast.ok   { background: var(--ok); }
.toast.bad  { background: var(--danger); }
.toast.info { background: #334155; }

.offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1300;
  background: var(--danger);
  color: #fff;
  font-size: 13.5px;
  font-weight: 650;
  text-align: center;
  padding: calc(env(safe-area-inset-top) + 7px) 12px 7px;
}

/* ─────────────── map markers ─────────────── */
.me-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #0284c7;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(2,132,199,.5), 0 2px 6px rgba(15,23,42,.4);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 2px rgba(2,132,199,.5), 0 2px 6px rgba(15,23,42,.4); }
  70%  { box-shadow: 0 0 0 16px rgba(2,132,199,0), 0 2px 6px rgba(15,23,42,.4); }
  100% { box-shadow: 0 0 0 2px rgba(2,132,199,0), 0 2px 6px rgba(15,23,42,.4); }
}

/* ─────────────── laptop ─────────────── */
@media (min-width: 900px) {
  .listpanel {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: 400px;
    height: auto !important;
    border-radius: 0;
    border-left: 1px solid var(--line);
    box-shadow: -3px 0 18px rgba(15,23,42,.1);
  }
  .listhead { cursor: default; }
  .listhead .grip, .listhead .caret { display: none; }
  .fab, body.list-open .fab { right: 424px; bottom: 24px; }
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    border-radius: 18px;
    max-height: 88dvh;
    animation: none;
  }
  .sheet-grip { display: none; }
}
