/* Permit Postcards — contractor tones: warm-neutral greys + safety orange
   Type: Newsreader (display), IBM Plex Sans (UI), IBM Plex Mono (data).
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32. Radius: 6 (controls) / 10 (cards) / 14 (panels). */
:root {
  --paper: #f4f4f2;
  --panel: #ffffff;
  --sunk: #ecece9;
  --rule: #e3e3df;
  --line: #cfcfca;
  --ink: #1b1d1f;
  --pencil: #5f6368;
  --faint: #9a9ea3;
  /* accent = safety orange. --blue is the accent for text/controls (AA on white); --stamp is the bright orange for fills */
  --blue: #c4510c;
  --blue-soft: rgba(196, 81, 12, .09);
  --on-blue: #ffffff;
  --stamp: #f26b1d;
  --stamp-soft: rgba(242, 107, 29, .1);
  --link: #2f6fdb;
  --s-contacted: #2f6fdb; --s-quoting: #d9a400; --s-won: #2e8b57;
  --dot: #c4c7cb;
  --shadow-sm: 0 1px 2px rgba(20, 21, 26, .06);
  --shadow: 0 1px 2px rgba(20, 21, 26, .08), 0 12px 32px -8px rgba(20, 21, 26, .22);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  /* vector basemap (published Artifact) */
  --water: #e3e6e9; --land: #f1f1ef; --covered: #e6e6e3;
  /* the postcard is paper in both themes */
  --card-paper: #f6f2ea;
  --card-ink: #1b1d1f;
  --card-pencil: #5f6368;
  --card-blue: #1b1d1f;
  --card-accent: #c4510c;
  --card-stamp: #e05e12;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121416; --panel: #1a1d20; --sunk: #16191b; --rule: #2a2e33; --line: #3a3f45;
    --ink: #e8e9ea; --pencil: #a0a4a9; --faint: #8b9097;
    --blue: #ff7a2e; --blue-soft: rgba(255, 122, 46, .14); --on-blue: #121416;
    --stamp: #ff7a2e; --stamp-soft: rgba(255, 122, 46, .12);
    --link: #7fa8f5;
    --s-contacted: #5c93f0; --s-quoting: #e6b800; --s-won: #4fbf86;
    --dot: #3a3f45;
    --water: #0e1113; --land: #1a1d20; --covered: #23272b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px -8px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121416; --panel: #1a1d20; --sunk: #16191b; --rule: #2a2e33; --line: #3a3f45;
  --ink: #e8e9ea; --pencil: #a0a4a9; --faint: #8b9097;
  --blue: #ff7a2e; --blue-soft: rgba(255, 122, 46, .14); --on-blue: #121416;
  --stamp: #ff7a2e; --stamp-soft: rgba(255, 122, 46, .12);
  --link: #7fa8f5;
  --s-contacted: #5c93f0; --s-quoting: #e6b800; --s-won: #4fbf86;
  --dot: #3a3f45;
  --water: #0e1113; --land: #1a1d20; --covered: #23272b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px -8px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* status colours: New = stamp, Contacted = blue, Quoting/Won = own tokens, Lost = faint ring */
.s-new { --c: var(--stamp); } .s-contacted { --c: var(--s-contacted); } .s-quoting { --c: var(--s-quoting); }
.s-won { --c: var(--s-won); } .s-lost { --c: var(--faint); }

/* Layout: the map is the page; one floating card asks one question and answers it.
   Everything else (adjustments, the address list, the postcard, the data sources) is one click deeper. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  min-height: 100dvh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- header ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px;
  border: 2px dashed var(--stamp); outline: 1.5px solid var(--stamp); outline-offset: -5px; transform: rotate(-3deg);
  color: var(--stamp); font: 600 12px/1 var(--serif);
}
.top h1 { margin: 0; font: 500 22px/1 var(--serif); letter-spacing: -.01em; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.link-btn { background: none; border: 0; padding: 6px 4px; font: 500 13px/1 var(--sans); color: var(--pencil); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---- layout ---- */
.app { flex: 1; min-height: 0; position: relative; }
.stage { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; background: var(--rule); }
@media (min-width: 881px) { body { height: 100dvh; overflow: hidden; } }

/* ---- the one card ---- */
.ask {
  position: absolute; z-index: 600; top: 20px; left: 20px; width: 380px; max-height: calc(100% - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin;
}
.sentence { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 8px; font: 400 22px/1.3 var(--serif); }
.sentence select {
  font: 500 19px/1.2 var(--serif); color: var(--blue); background: transparent; border: 0; border-bottom: 2px solid var(--blue);
  border-radius: 0; padding: 2px 22px 3px 2px; min-height: 0; max-width: 100%; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--blue) 50%), linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position: calc(100% - 10px) 55%, calc(100% - 5px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.sentence select:focus { outline: none; background-color: var(--blue-soft); }
.hint-line { margin: -6px 0 0; font: 400 13px/1.4 var(--sans); color: var(--blue); }

/* Status strip: the big "new leads" number on its own line, the other four as small pills under it */
.pipe { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 2px; }
.seg {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  padding: 5px 10px 5px 8px; background: transparent; color: var(--ink); border: 1px solid var(--rule); border-radius: 999px;
  cursor: pointer; font: inherit; text-align: left; white-space: nowrap;
}
.seg::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c, var(--faint)); }
.seg[data-s="contacted"] { --c: var(--s-contacted); }
.seg[data-s="quoting"] { --c: var(--s-quoting); }
.seg[data-s="won"] { --c: var(--s-won); }
.seg[data-s="lost"]::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--faint); }
.seg:hover { background: var(--sunk); }
.seg[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); }
.seg b { font: 600 13px/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); }
.seg span { font: 400 13px/1 var(--sans); color: var(--pencil); }
.seg-new { flex: 1 0 100%; align-items: baseline; gap: 12px; padding: 4px 8px; margin: 0 -8px 2px; border-color: transparent; border-radius: var(--r-md); }
.seg-new::before { display: none; }
.seg-new b { font: 500 64px/.9 var(--serif); letter-spacing: -.02em; color: var(--stamp); font-variant-numeric: tabular-nums lining-nums; }
.seg-new span { font: 400 17px/1.25 var(--serif); color: var(--ink); white-space: normal; }
.today {
  align-self: flex-start; margin-top: -4px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  font: 500 13px/1.2 var(--sans); color: var(--blue); background: var(--stamp-soft); border: 1px solid var(--blue);
}
.today[aria-pressed="true"] { background: var(--blue); color: var(--on-blue); }
.answer-sub { margin: -6px 0 0; font: 400 13px/1.45 var(--sans); color: var(--pencil); }
.note.warn { color: var(--blue); margin: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--sans); padding: 0 16px; min-height: 40px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1px solid var(--ink); transition: background .15s, transform .1s;
}
.btn:hover { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { min-height: 48px; font-size: 15px; font-weight: 600; background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.primary:hover { filter: brightness(1.08); background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--sunk); border-color: var(--pencil); color: var(--ink); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--pencil); font-size: 15px; cursor: pointer; }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }

/* nested detail */
.more { border-top: 1px solid var(--rule); }
.more summary {
  list-style: none; cursor: pointer; padding: 12px 0 2px; display: flex; align-items: center; justify-content: space-between;
  font: 500 14px/1.2 var(--sans); color: var(--ink);
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: "+"; font: 400 18px/1 var(--sans); color: var(--pencil); }
.more[open] summary::after { content: "–"; }
.more-body { padding-top: 12px; }
.field { margin-bottom: 14px; }
label { display: block; margin-bottom: 6px; font: 500 12.5px/1.3 var(--sans); color: var(--pencil); }
.hint { font-weight: 400; color: var(--faint); margin-left: 4px; }
input[type=text], input[type=number], .sort select {
  width: 100%; min-height: 38px; padding: 8px 12px; font: 400 15px/1.2 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input[type=number] { font-family: var(--mono); }
input[type=text]:focus, input[type=number]:focus, .sort select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.range-label { display: flex; justify-content: space-between; align-items: center; }
.range-label output { font: 500 12px/1 var(--mono); color: var(--ink); background: var(--sunk); border: 1px solid var(--rule); padding: 4px 8px; border-radius: 999px; }
input[type=range] { width: 100%; height: 24px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.rate { display: grid; grid-template-columns: 1fr 100px; align-items: center; gap: 12px; }
.rate label { margin: 0; }
.facts { margin: 4px 0 0; display: grid; gap: 0; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; background: var(--paper); }
.facts div + div { border-top: 1px solid var(--rule); }
.facts dt { font: 400 13px/1.3 var(--sans); color: var(--pencil); }
.facts dd { margin: 0; font: 500 14px/1.3 var(--mono); font-variant-numeric: tabular-nums; }

/* address list */
.sort { display: block; margin-bottom: 8px; }
.sort select { width: auto; min-height: 32px; padding: 4px 28px 4px 10px; font-size: 13px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--pencil) 50%), linear-gradient(135deg, var(--pencil) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; cursor: pointer; }
.matches { list-style: none; margin: 0 -8px; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; width: 100%; text-align: left;
  background: transparent; color: inherit; border: 0; border-radius: var(--r-sm); padding: 9px 10px; cursor: pointer; font: inherit;
  box-shadow: inset 3px 0 0 transparent;
}
.row:hover { background: var(--sunk); }
.row[aria-current="true"] { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.row .addr { font: 500 15px/1.25 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val { font: 500 12.5px/1.25 var(--mono); text-align: right; }
.row .sub { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font: 400 12px/1.3 var(--sans); color: var(--pencil); }
.pill { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font: 500 11px/1.4 var(--sans); color: var(--ink); border: 1px solid var(--c); }
.pill.s-new { background: var(--stamp-soft); }
.pill.s-lost { border-style: dashed; color: var(--pencil); }
.fu { font: 500 11px/1.4 var(--mono); color: var(--pencil); }
.fu.due { color: var(--blue); }
.kind { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font: 500 11px/1.3 var(--sans); color: var(--pencil); background: var(--sunk); border: 1px solid var(--rule); }
.note, .empty { font: 400 12px/1.45 var(--sans); color: var(--pencil); margin: 10px 0 0; }
.empty-list { padding: 16px 12px; font: 400 13px/1.45 var(--sans); color: var(--pencil); text-align: center; }

/* ---- dialogs ---- */
dialog { padding: 0; border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 11, 14, .45); backdrop-filter: blur(2px); }
.card-dialog { width: min(640px, calc(100vw - 32px)); }
.about-dialog { width: min(520px, calc(100vw - 32px)); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--rule); }
.drawer-head h2 { margin: 0; font: 600 15px/1.2 var(--sans); }
.drawer-body { padding: 16px 20px 20px; background: var(--sunk); }
.card-for { margin: 0 0 12px; font: 400 12px/1.4 var(--mono); color: var(--pencil); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.card-actions .btn { flex: 1; }
.about-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: var(--pencil); }
.about-body p { margin: 0; }
.fresh { display: flex; flex-wrap: wrap; gap: 6px; font: 400 12px/1.3 var(--mono); }
.src { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; background: var(--paper); border: 1px solid var(--rule); color: var(--ink); white-space: nowrap; }
.src i { width: 6px; height: 6px; border-radius: 50%; background: #3c9a5f; }
.src em { font-style: normal; color: var(--pencil); }
.src.total { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 500; }
.src.off { color: var(--faint); border-style: dashed; background: transparent; }
.foot { font: 400 11.5px/1.6 var(--mono); }

/* postcard: 6x4 */
.card-wrap { perspective: 1400px; }
.postcard { position: relative; width: 100%; aspect-ratio: 3 / 2; container-type: inline-size; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.postcard.flipped { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) { .postcard { transition: none; } }
.face {
  position: absolute; inset: 0; overflow: hidden; border-radius: 1.2cqw; color: var(--card-ink);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background-color: var(--card-paper);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 20% 10%, rgba(255,255,255,.55), transparent 60%),
    linear-gradient(180deg, rgba(120,95,50,.05), rgba(120,95,50,.12));
  box-shadow: 0 .4cqw 1.6cqw rgba(0,0,0,.22), 0 .1cqw .3cqw rgba(0,0,0,.18), inset 0 0 0 .25cqw rgba(60,45,20,.1);
}
.face.back { transform: rotateY(180deg); }

/* front */
.front { display: flex; flex-direction: column; padding: 5cqw 5.5cqw 0; }
.front .tag { font: 500 2.1cqw/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--card-accent); }
.front .head { margin: 2.2cqw 0 0; font: 500 6.4cqw/1.08 var(--serif); letter-spacing: -.01em; text-wrap: balance; }
.front .offer { margin: 2.6cqw 0 0; font: 400 3cqw/1.35 var(--serif); color: var(--card-pencil); max-width: 34ch; }
.front .where { margin-top: auto; padding-bottom: 2.4cqw; font: 400 1.9cqw/1.3 var(--mono); color: var(--card-pencil); }
.front .band {
  margin: 0 -5.5cqw; padding: 2.6cqw 5.5cqw; background: var(--card-blue); color: #f6f2ea;
  display: flex; align-items: baseline; justify-content: space-between; gap: 3cqw;
}
.front .biz { font: 600 4.2cqw/1.1 var(--serif); }
.front .contact { font: 400 2.1cqw/1.5 var(--mono); text-align: right; white-space: nowrap; }

/* back */
.back { display: grid; grid-template-columns: 1fr 1fr; padding: 4.5cqw 5cqw; gap: 0; }
.back .left { padding-right: 4cqw; border-right: .25cqw solid rgba(20,21,26,.35); display: flex; flex-direction: column; }
.back .msg { font: 400 2.9cqw/1.4 var(--serif); margin: 0; }
.back .msg b { font-weight: 600; }
.back .legal { margin: auto 0 0; font: 400 1.75cqw/1.45 var(--mono); color: var(--card-pencil); }
.back .right { padding-left: 4cqw; display: flex; flex-direction: column; align-items: flex-end; }
.stamp {
  width: 15cqw; height: 18cqw; display: grid; place-items: center; text-align: center; color: var(--card-stamp);
  font: 500 1.7cqw/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  border: .5cqw dashed var(--card-stamp); outline: .35cqw solid var(--card-stamp); outline-offset: -1.6cqw; transform: rotate(2deg);
}
.stamp i { display: block; font: normal 600 4.4cqw/1 var(--serif); letter-spacing: 0; margin-bottom: .6cqw; }
.addr-block { margin-top: auto; align-self: stretch; padding-bottom: 6cqw; }
.addr-block .to { font: 400 1.8cqw/1.3 var(--mono); color: var(--card-pencil); text-transform: uppercase; letter-spacing: .08em; }
.addr-block .line { font: 500 3.3cqw/1.35 var(--serif); text-transform: uppercase; letter-spacing: .02em; border-bottom: .2cqw solid rgba(20,21,26,.3); padding: .6cqw 0; }

/* ---- leaflet skin ---- */
.leaflet-container { font-family: var(--sans); background: var(--rule); }
.leaflet-bar { border: 1px solid var(--rule) !important; border-radius: var(--r-sm) !important; box-shadow: var(--shadow-sm) !important; overflow: hidden; }
.leaflet-bar a { background: var(--panel) !important; color: var(--ink) !important; border-bottom-color: var(--rule) !important; }
.leaflet-bar a:hover { background: var(--sunk) !important; }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 14px 16px; font: 400 14px/1.4 var(--sans); min-width: 230px; }
.leaflet-popup-content a { color: var(--link); }
.leaflet-container a.leaflet-popup-close-button { color: var(--pencil); top: 6px; right: 6px; }
.pp strong { font: 500 17px/1.25 var(--serif); display: block; }
.pp .k { font: 500 12px/1.3 var(--sans); color: var(--blue); margin: 3px 0 8px; }
.pp dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font: 400 12px/1.4 var(--mono); }
.pp dt { color: var(--pencil); } .pp dd { margin: 0; }
.pp p { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--pencil); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 85%, transparent) !important; color: var(--pencil) !important; font: 400 10.5px/1.6 var(--sans); }

.legend { background: var(--panel); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--shadow-sm); font: 400 12px/1.6 var(--sans); min-width: 170px; }
.legend summary { list-style: none; cursor: pointer; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 500; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::after { content: "Key ▾"; font: 400 11px/1 var(--mono); color: var(--faint); }
.legend details[open] summary { border-bottom: 1px solid var(--rule); }
.legend details[open] summary::after { content: "▴"; }
.legend details > div { display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--pencil); }
.legend details > div:nth-of-type(1) { padding-top: 6px; }
.legend details > div:last-child { padding-bottom: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend h4 { margin: 6px 12px 2px; padding-top: 6px; border-top: 1px solid var(--rule); font: 500 10.5px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.legend .sdot { background: var(--c); }
.legend .sdot.s-lost { background: transparent; box-shadow: inset 0 0 0 2px var(--faint); }
.legend .hit { display: inline-flex; align-items: center; gap: 8px; }
.legend .hit i { background: var(--stamp); box-shadow: 0 0 0 1.5px var(--panel), 0 0 0 2.5px var(--stamp); }

.city-label { background: none; border: 0; }
.city-label span {
  display: inline-block; transform: translate(-50%, -50%); white-space: nowrap;
  font: 500 10.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--pencil);
  text-shadow: 0 0 3px var(--land), 0 0 3px var(--land);
}

/* Basemap tone: desaturated paper in light, inverted ink in dark */
html[data-tiles="light"] .leaflet-tile-pane { filter: grayscale(1) contrast(1.05) brightness(.98); opacity: .85; }
html[data-tiles="dark"] .leaflet-tile-pane { filter: invert(1) grayscale(1) contrast(1.25) brightness(.9); }

/* ---- lead panel ---- */
.lead-panel {
  position: absolute; z-index: 650; top: 0; right: 0; bottom: 0; width: 380px; overflow-y: auto; scrollbar-width: thin;
  background: var(--panel); border-left: 1px solid var(--rule); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 14px;
}
.lp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lp-title { min-width: 0; }
.lp-head h2 { margin: 0; font: 500 26px/1.15 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.lp-city { margin: 2px 0 0; font: 400 14px/1.4 var(--sans); color: var(--pencil); }
.lp-links { display: flex; gap: 16px; align-items: center; margin-top: -6px; font: 500 13px/1 var(--sans); }
.lp-links .link-btn { padding: 0; color: var(--link); text-decoration-color: currentColor; }
.lp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font: 400 12.5px/1.4 var(--sans); color: var(--pencil); }
.lp-meta .mono { font-family: var(--mono); font-size: 12px; }
.lp-contractor { margin: 0; padding: 8px 10px; background: var(--sunk); border-radius: var(--r-sm); font: 400 13px/1.4 var(--sans); user-select: text; overflow-wrap: anywhere; }
.lp-sec { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lp-label { margin: 0; font: 600 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--pencil); }
.lp-status { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 100%; }
.lp-status button {
  min-height: 38px; padding: 0 2px; border-radius: var(--r-sm); cursor: pointer; font: 500 11.5px/1.1 var(--sans);
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.lp-status button:hover:not(:disabled) { background: var(--sunk); }
.lp-status button[aria-pressed="true"] { border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); font-weight: 600; }
.lp-status button:disabled, .lp-panel input:disabled { cursor: not-allowed; opacity: .6; }
.lp-follow { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.lp-follow input[type=date], .lead-panel textarea {
  width: 100%; min-height: 38px; padding: 8px 12px; font: 400 15px/1.3 var(--sans); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.lead-panel textarea { resize: vertical; min-height: 72px; }
.lp-follow input:focus, .lead-panel textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.lead-panel :disabled { cursor: not-allowed; opacity: .6; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.lp-notes { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.lp-notes li { padding-left: 10px; border-left: 2px solid var(--rule); }
.n-top { display: flex; justify-content: space-between; gap: 8px; font: 400 12px/1.3 var(--sans); color: var(--pencil); }
.n-top b { font-weight: 600; color: var(--ink); }
.lp-notes p { margin: 2px 0 0; font: 400 14px/1.45 var(--sans); white-space: pre-wrap; overflow-wrap: anywhere; }
.lp-notes .n-empty { border: 0; padding: 0; font: 400 13px/1.4 var(--sans); color: var(--pencil); }
.lp-actions { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
.lp-actions .btn { padding: 0 8px; }
.lp-foot { margin: 0; }
@media (min-width: 881px) {
  .app.has-panel .leaflet-right { right: 380px; }
}

/* ---- phone ---- */
@media (max-width: 880px) {
  body { height: auto; }
  .top { padding: 10px 16px; }
  .top h1 { font-size: 17px; }
  .top { gap: 8px; }
  .link-btn, .btn.small { white-space: nowrap; }
  #theme-toggle { display: none; }
  .link-btn { font-size: 12.5px; }
  .mark { width: 30px; height: 30px; }
  .app { display: flex; flex-direction: column; }
  .stage { position: relative; height: 46vh; flex: none; }
  .ask { position: static; width: auto; max-height: none; margin: 12px 12px 16px; }
  .seg-new b { font-size: 54px; }
  .lead-panel { position: static; width: auto; margin: 0 12px 16px; border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: visible; }
  html, body { max-width: 100%; overflow-x: hidden; }
  .sentence { font-size: 20px; }
  .sentence select { font-size: 18px; }
}
