/* Field tool.
   Designed for a phone held in one hand on a doorstep in daylight: high
   contrast, 44px minimum tap targets, no hover-dependent affordances. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #d9dee5;
  --text: #12181f;
  --muted: #5d6b7a;
  --accent: #b85519;
  --accent-text: #ffffff;
  /* Chrome (top bar) is decoupled from the button accent so the app can have
     a dark, serious frame while keeping a warm colour for actions. */
  --chrome: #23272e;
  --chrome-text: #f6f7f9;
  --good: #1a7f4b;
  --warn: #a35b00;
  --bad: #b3261e;
  --radius: 10px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a;
    --surface: #182029;
    --border: #2c3742;
    --text: #e8edf3;
    --muted: #9aa8b7;
    --accent: #d06a24;
    --accent-text: #ffffff;
    --chrome: #0d0f13;
    --chrome-text: #e8edf3;
    --good: #4ec98a;
    --warn: #e0a33e;
    --bad: #ef6a63;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- topbar */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  padding-top: max(.6rem, env(safe-area-inset-top));
  background: var(--chrome);
  color: var(--chrome-text);
}

.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title strong { font-size: 1rem; }
.topbar-title .muted,
#topbar .muted { color: inherit; opacity: .78; font-size: .8rem; }
.topbar-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn, .text-btn {
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-height: var(--tap);
  padding: 0 .5rem;
}
.icon-btn { font-size: 1.3rem; }
.text-btn { font-size: .85rem; text-decoration: underline; }

/* ----------------------------------------------------------------- layout */

main { padding: 1rem; max-width: 60rem; margin: 0 auto; }
main.wide { max-width: 88rem; }

h1 { font-size: 1.3rem; margin: 0 0 .2rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: .95rem; margin: 0 0 .3rem; }
p { margin: .4rem 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.loading, .empty {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem;
  margin-bottom: .8rem;
}

/* A card that is also a button (the product doors) keeps card looks but
   sheds the UA button font/color, same trap as the password input. */
button.card { font: inherit; color: inherit; }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spread { flex: 1; }
.stack > * + * { margin-top: .6rem; }

.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 62rem) {
  .grid-2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .sticky-side { position: sticky; top: 4.2rem; }
}

/* ---------------------------------------------------------------- controls */

/* `a.btn` exists for one reason: the call screen's dial control is a real
   tel: link, so a phone treats it as a phone number, and it has to look like
   the button beside it rather than a stray blue hyperlink. */
button.btn, a.btn {
  min-height: var(--tap);
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
a.btn {
  display: block;
  text-align: center;
  text-decoration: none;
  line-height: var(--tap);
}
button.btn.secondary, a.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
button.btn.danger, a.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.block, a.btn.block { width: 100%; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  min-height: var(--tap);
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 4.5rem; resize: vertical; }
label.field { display: block; margin-bottom: .6rem; }
label.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem;
  margin: 0 0 .8rem;
  background: var(--surface);
}
legend { font-size: .8rem; color: var(--muted); padding: 0 .3rem; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: .88rem;
  min-height: 36px;
  user-select: none;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip .n { opacity: .7; font-variant-numeric: tabular-nums; font-size: .8em; }

.scroll-box { max-height: 13rem; overflow-y: auto; }

/* -------------------------------------------------------------- live count */

.count-hero { text-align: center; padding: .4rem 0 .8rem; }
.count-hero .n {
  font-size: 2.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.count-hero.stale { opacity: .45; }

.bar-list { display: flex; flex-direction: column; gap: .3rem; }
.bar-row { display: grid; grid-template-columns: 5.5rem 1fr 3.2rem; gap: .5rem; align-items: center; font-size: .85rem; }
.bar-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { background: var(--border); border-radius: 3px; height: 8px; overflow: hidden; }
.bar-row .fill { background: var(--accent); height: 100%; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ------------------------------------------------------------------ lists */

ul.plain { list-style: none; margin: 0; padding: 0; }

/* Live navigation banner: the always-visible "next stop" pointer. */
.nav-banner { border-left: 4px solid var(--accent); }
.nav-arrow {
  font-size: 2rem;
  line-height: 1;
  color: var(--accent);
  width: 2.2rem;
  text-align: center;
  transition: transform .3s ease;
  flex: none;
}

/* Shared building access note — crowd-sourced entry intel. */
.access-note {
  margin-top: .5rem;
  padding: .5rem .65rem;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  font-size: .85rem;
  line-height: 1.45;
}
.access-note strong { color: var(--warn); }
.link-btn {
  background: none;
  border: 0;
  padding: 0 .25rem;
  color: var(--accent);
  font: inherit;
  font-size: .82rem;
  text-decoration: underline;
  cursor: pointer;
  min-height: 32px;
}

/* A multi-unit building: one stop, its units nested inside. The accent stripe
   marks it as a building rather than a single door at a glance. */
.building-stop {
  border-left: 4px solid var(--accent);
}
.building-stop.done { opacity: .62; }
.building-stop .household {
  margin-bottom: .4rem;
  background: var(--bg);
}
.building-stop .household:last-child { margin-bottom: 0; }

.household {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .6rem;
  overflow: hidden;
}
.household > summary {
  padding: .8rem;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: .6rem;
  list-style: none;
}
.household > summary::-webkit-details-marker { display: none; }
.household .addr { font-weight: 600; flex: 1; }
.household .body { padding: 0 .8rem .8rem; border-top: 1px solid var(--border); }
.household.done { opacity: .62; }

.donor-line {
  margin-top: .3rem;
  font-size: .82rem;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem;
}
.donor-tag {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent);
  padding: .1rem .4rem;
  border-radius: 4px;
}
.donor-comms { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .1rem; }
.donor-comm {
  font-size: .75rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .05rem .35rem;
}
.donor-comm.opp { color: var(--bad); border-color: var(--bad); }
.donor-comm.self { color: var(--accent); border-color: var(--accent); }
.donor-flag {
  font-size: .75rem;
  font-weight: 600;
  padding: .05rem .4rem;
  border-radius: 4px;
}
.donor-flag.opp { color: #fff; background: var(--bad); }
.donor-flag.self { color: var(--accent-text); background: var(--accent); }

.person { padding: .45rem 0; border-bottom: 1px dashed var(--border); font-size: .92rem; }
.person:last-child { border-bottom: 0; }
.person .meta { color: var(--muted); font-size: .82rem; }

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.bad  { color: var(--bad); }

.disp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 30rem) { .disp-grid { grid-template-columns: repeat(3, 1fr); } }
.disp-grid button { min-height: 52px; }

.support-scale { display: flex; gap: .4rem; }
.support-scale button { flex: 1; min-height: 46px; }
.support-scale button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table-scroll { overflow-x: auto; }

.swatch {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  border-radius: 3px;
  margin-right: .45rem;
  vertical-align: baseline;
  flex: none;
}

/* Leaflet renders into a bare div; it needs an explicit height and its own
   stacking context so the sticky topbar stays above it. */
#turf-map { height: 26rem; border-radius: var(--radius); overflow: hidden; z-index: 0; }
#turf-map .leaflet-container { background: var(--bg); font: inherit; }

code.token {
  display: block;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .45rem .55rem;
  font-size: .78rem;
  margin: .3rem 0;
}

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  z-index: 50;
  max-width: 92vw;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast.bad { background: var(--bad); color: #fff; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: .7rem 0;
  padding-bottom: max(.7rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* ---------------------------------------------------- fundraising tracks */
/* Four strategies, one screen. The toggle is the only chrome on the page, so
   it is small, quiet, and always in the same place. */
.tracks { display:grid; grid-template-columns:repeat(4,1fr); gap:.3rem;
  margin:0 0 .5rem; }
.tracks .track { min-height:2.5rem; padding:.35rem .3rem; border-radius:var(--radius);
  border:1px solid var(--border); background:transparent; color:var(--muted);
  font:inherit; font-size:.78rem; font-weight:600; line-height:1.15;
  cursor:pointer; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:.1rem; }
.tracks .track.on { border-color:var(--accent); background:var(--accent);
  color:var(--accent-text); }
.tracks .track .n { font-size:.7rem; font-weight:500; opacity:.75; }
p.who { margin:.1rem 0 .7rem; }

/* Gift history and the cross-committee crossref, on the call card. Left-aligned
   inside a centred card because a column of dates and amounts is read down. */
.hist { margin-top:.9rem; text-align:left; border-top:1px solid var(--border);
  padding-top:.6rem; }
.hist .lbl { font-size:.7rem; font-weight:700; letter-spacing:.09em;
  text-transform:uppercase; color:var(--muted); margin-bottom:.35rem; }
.hist .rows { max-height:16rem; overflow-y:auto; }
.hist .lbl .n { font-weight:600; opacity:.7; }
.hist .rows .more span { font-style:italic; opacity:.8; }
/* Year on a crossref line — quiet, but present, so "gave $1,000" is never
   read as "gives $1,000 now". */
.hist.also .rows i { font-style:normal; font-size:.86em; opacity:.7;
  margin-left:.3rem; }
/* Name left, amount right, and the amount stays put however long the name is.
   A committee called "Ranked Choice Voting 2020 Committee" was wrapping its
   year onto a line of its own and stranding the amount above it. */
.hist .rows > div { display:flex; gap:.75rem; align-items:baseline;
  padding:.16rem 0; font-size:.88rem; font-variant-numeric:tabular-nums; }
.hist .rows > div span { color:var(--muted); flex:1 1 auto; min-width:0;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hist .rows > div b { flex:0 0 auto; }
.hist.also .rows > div span { white-space:normal; }
/* A January deposit the filer attributed to the previous calendar year (OCPF's
   Is_Previous_Year_Receipt). The caller needs the date and the year it counts
   in: without this, a gift dated 9 January reads as this year's money on a card
   that also says the donor has given nothing this year, and the two cannot be
   reconciled from the screen. Quiet — it explains a number, it is not one. */
.hist .rows > div em.pyr { flex:0 0 auto; font-style:normal; font-size:.72rem;
  font-weight:700; letter-spacing:.04em; text-transform:uppercase;
  color:var(--muted); opacity:.85; }

/* District status: shown on every individual's card, in all three states.
   Deliberately a badge rather than grey body text — on a prospect call it is
   the reason the person is on the list at all. */
/* Can they vote for him? He asks for the vote and the cheque on one call, so
   this is a verdict with its reason, not a badge to decode. */
.dist { display:block; margin:.6rem auto 0; max-width:24rem; padding:.4rem .7rem;
  border-radius:.5rem; font-size:.82rem; line-height:1.35; }
.dist b { display:block; font-weight:700; letter-spacing:.01em; }
.dist span { display:block; opacity:.85; }
.dist.yes   { background:rgba(34,139,84,.12); color:#166b3f; }
.dist.no    { background:rgba(180,83,31,.12); color:#a8410f; }
.dist.check { background:rgba(191,140,0,.14); color:#8a6100; }
.dist.unknown { background:var(--surface-2, rgba(128,128,128,.1)); color:var(--muted); }
@media (prefers-color-scheme: dark) {
  .dist.yes   { background:rgba(52,199,123,.15); color:#5cd39a; }
  .dist.no    { background:rgba(217,89,38,.17); color:#f08a5f; }
  .dist.check { background:rgba(230,180,60,.16); color:#e6b43c; }
}

/* Which conversation this is. Sits under the giving line because it changes
   the first sentence: "thank them first" is not the same call as "lead with
   the challenger". */
.cue { margin-top:.3rem; font-size:.82rem; font-weight:600; color:var(--accent); }

/* Sort control — one line, two choices, quieter than the track tabs so it
   never competes with them. */
.sorter { display:flex; gap:.35rem; margin:0 0 .55rem; }
.sorter button { flex:1; min-height:2rem; padding:.25rem .4rem;
  border-radius:var(--radius); border:1px solid var(--border);
  background:transparent; color:var(--muted); font:inherit; font-size:.76rem;
  font-weight:600; cursor:pointer; }
.sorter button.on { color:var(--text); border-color:var(--text); }

/* One tap to see the full giving history and the crossref. Deliberately quiet
   and deliberately closed by default — the outcome buttons must stay above the
   fold on a phone. */
.detail-toggle { display:flex; justify-content:center; align-items:center;
  gap:.5rem; width:100%; margin-top:.8rem; padding:.45rem .6rem;
  border:1px solid var(--border); border-radius:var(--radius);
  background:transparent; color:var(--muted); font:inherit; font-size:.8rem;
  font-weight:600; cursor:pointer; }
.detail-toggle span { font-size:1rem; line-height:1; opacity:.7; }

/* "Wrong number?" under the dial button. A correction is worth offering and is
   not worth a button that competes with the one thing this screen exists to
   do, so it reads as a link and sits below the call. */
.linkish { display:block; width:100%; margin-top:.5rem; padding:.35rem;
  border:0; background:transparent; color:var(--muted); font:inherit;
  font-size:.8rem; text-decoration:underline; cursor:pointer; }
