/* Territory Scout (Data Donkey v0.7.15): teal + signal amber, light and dark, phone first. */
@font-face { font-family: "Public Sans"; src: url("fonts/public-sans.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #EEF2F1; --surface: #FFFFFF; --sunk: #E3E9E8; --ink: #0E2A30; --muted: #5A6E72; --line: #D3DCDB;
  --brand: #0F5E63; --brand-ink: #FFFFFF; --signal: #F2A23A; --signal-ink: #3A2405;
  --lease: #B5476B; --permit: #3D6FB8; --new: #2E8A57; --public: #7A5BC0; --other: #6B7C80;
  --up: #2E8A57; --down: #B5476B; --bad: #B3261E; --scrim: rgba(5, 15, 17, .45);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1719; --surface: #132427; --sunk: #0E1C1E; --ink: #E6EFEE; --muted: #93A8AB; --line: #24393C;
    --brand: #3FB3AE; --brand-ink: #06201F; --signal: #F5B556; --signal-ink: #2B1A02;
    --lease: #E07C9C; --permit: #7FA6E6; --new: #5CC38A; --public: #A88BEA; --other: #93A8AB;
    --up: #5CC38A; --down: #E07C9C; --bad: #F2B8B5; --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body); -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin: 0; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { flex: 1; display: flex; align-items: center; gap: 8px; font: 700 18px var(--f-display); }
.brand b { color: var(--brand); font-weight: 700; }
.who { font-size: 13px; color: var(--muted); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 6px 4px; white-space: nowrap; }
@media (max-width: 520px) { .who { display: none; } }

main {
  max-width: 760px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* Buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px;
  padding: 10px 14px; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { color: var(--muted); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* Sign in */
.login { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: start; padding-top: 16px; }
@media (max-width: 720px) { .login { grid-template-columns: minmax(0, 1fr); gap: 24px; } }
.pitch { display: flex; flex-direction: column; gap: 14px; }
.pitch h1 { font-size: clamp(28px, 6vw, 40px); font-weight: 800; line-height: 1.1; }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.points li { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.k-lease, .dot.k-incumbent { background: var(--lease); } .dot.k-permit { background: var(--permit); }
.dot.k-new { background: var(--new); } .dot.k-public { background: var(--public); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.signin { display: flex; flex-direction: column; gap: 10px; }
.signin form { display: flex; flex-direction: column; gap: 10px; }
.signin input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px; min-height: 46px; }
.signin p { margin: 0; }
.msg { border-radius: 10px; padding: 12px; background: var(--sunk); font-size: 14px; }
.msg.ok { border-left: 4px solid var(--brand); }
.msg.bad { border-left: 4px solid var(--bad); }
.msg ol { margin: 6px 0 0; padding-left: 20px; }
#err { color: var(--bad); }
#err:empty { display: none; }

/* Install banner */
.install { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--signal); border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.install img { border-radius: 10px; }
.install p { margin: 0; flex: 1; min-width: 160px; font-size: 14px; }

/* Views */
.view { display: flex; flex-direction: column; gap: 14px; }
.hello h1 { font-size: 26px; font-weight: 700; }
.hello p { margin: 2px 0 0; font-size: 14px; }
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { flex: 1; height: 6px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.bar b { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s; }
.tally { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tally div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.2; }
.tally b { display: block; font: 700 18px var(--f-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.tools { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.tools select { width: 100%; }
.tools input, .tools select { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; min-height: 42px; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.zipbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; }

/* Lead cards */
.feed { display: flex; flex-direction: column; gap: 12px; }
.lead { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: opacity .25s, transform .25s; }
.lead.out { opacity: 0; transform: translateX(40px); }
.lead.worked { opacity: .62; }
.lead.flash { outline: 2px solid var(--signal); }
.lead-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.kind { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.kind::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.k-lease, .k-incumbent { color: var(--lease); } .k-permit { color: var(--permit); } .k-new { color: var(--new); }
.k-public { color: var(--public); } .k-other { color: var(--other); }
.when { font: 500 12px var(--f-mono); color: var(--muted); white-space: nowrap; }
.when.hot { background: var(--signal); color: var(--signal-ink); padding: 1px 7px; border-radius: 6px; }
.lead h3 { font-size: 17px; line-height: 1.25; }
.lead h3 button { all: unset; cursor: pointer; }
.lead h3 button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.why { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.facts { display: flex; gap: 6px; flex-wrap: wrap; }
.facts span { font-size: 12px; background: var(--sunk); padding: 3px 8px; border-radius: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; }
.actions .btn { padding: 10px 6px; }
.outcome { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--brand); }
.lead dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; font-size: 13px; background: var(--sunk); padding: 10px; border-radius: 10px; }
.lead dt { color: var(--muted); }
.lead dd { margin: 0; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; font-size: 14px; }
.exports { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.exports span { flex: 1 1 100%; font-size: 13px; }

/* Growth board */
.board { display: flex; flex-direction: column; gap: 8px; }
.zhead, .zrow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(5, 36px) 48px; gap: 4px; align-items: center; text-align: center; }
.zhead { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 0 10px; }
.zhead span:first-child { text-align: left; }
.zrow { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; cursor: pointer; width: 100%; }
.zrow.top { border-color: var(--signal); box-shadow: inset 3px 0 0 var(--signal); }
.z { text-align: left; min-width: 0; }
.z b { display: block; font: 600 15px var(--f-mono); }
.z small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n { font-weight: 600; font-variant-numeric: tabular-nums; }
.n.zero { color: var(--muted); font-weight: 400; }
.trend { font: 600 12px var(--f-mono); }
.trend.up { color: var(--up); } .trend.down { color: var(--down); } .trend.flat { color: var(--muted); }
@media (max-width: 380px) { .zhead, .zrow { grid-template-columns: minmax(0, 1fr) repeat(5, 28px) 40px; } }

/* Map */
.map { height: min(62vh, 560px); min-height: 320px; border-radius: 16px; border: 1px solid var(--line); overflow: hidden; background: var(--sunk); }
.leaflet-container { font-family: var(--f-body); background: var(--sunk); }
.leaflet-tooltip.zlabel { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; font: 600 11px var(--f-mono); padding: 1px 5px; }
.leaflet-tooltip.zlabel::before { display: none; }
.leaflet-tooltip.zcount { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 99px; box-shadow: none; font: 700 12px var(--f-mono); padding: 1px 7px; }
.leaflet-tooltip.zcount::before { display: none; }

/* Bottom nav (phone), top tabs (wide) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.nav button { background: none; border: 0; padding: 10px 0 12px; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; position: relative; }
.nav button[aria-current="true"] { color: var(--brand); }
.nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--signal); color: var(--signal-ink); font-size: 10px; font-weight: 700; border-radius: 99px; padding: 0 5px; min-width: 16px; }
@media (min-width: 900px) {
  .nav { position: sticky; top: 57px; bottom: auto; margin: -16px 0 16px; border: 0; border-bottom: 1px solid var(--line); grid-template-columns: repeat(4, max-content); gap: 8px; padding: 0; background: var(--bg); z-index: 10; }
  .nav button { flex-direction: row; font-size: 14px; padding: 12px 14px; gap: 8px; }
  .nav button[aria-current="true"] { box-shadow: inset 0 -2px 0 var(--brand); }
  .nav svg { width: 18px; height: 18px; }
  .badge { position: static; }
  #app { display: flex; flex-direction: column; }
  #app .nav { order: -1; }
  main { padding-bottom: 48px; }
}

/* Sheet + toast */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto; max-height: 85vh; overflow: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--line);
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet .eyebrow { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.sheet h2 { font-size: 20px; }
.sheet pre { white-space: pre-wrap; font: 14px/1.5 var(--f-body); background: var(--sunk); padding: 12px; border-radius: 10px; margin: 0; }
.outs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outs .btn { flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; padding: 12px; }
.outs .btn small { font-weight: 400; font-size: 12px; opacity: .8; }
.outs .btn.span { grid-column: 1 / -1; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 50; max-width: 520px; margin: 0 auto;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px;
}
.toast .link { color: var(--signal); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.pinpop .leaflet-popup-content { margin: 6px; font: 14px/1.4 var(--f-body); }
.pinpop .lead { box-shadow: none; border: 0; margin: 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.fresh { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.fresh.stale { color: var(--ink); background: color-mix(in srgb, var(--signal) 22%, var(--surface)); border-radius: 10px; padding: 8px 12px; }
.runnote { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--signal); background: var(--surface); font-size: 14px; }
.runnote ul { margin: 6px 0; padding-left: 18px; }
.runnote .muted { color: var(--muted); font-size: 12px; }

