/* Airbnb-inspired tokens */
:root {
  --rausch: #ff385c;          /* primary accent */
  --rausch-dark: #e0124a;
  --babu: #00a699;
  --foggy: #767676;
  --hof: #484848;
  --night: #222222;
  --white: #ffffff;
  --offwhite: #f7f7f7;
  --bg: #fafafa;
  --line: #ebebeb;
  --line-strong: #dddddd;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 6px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.14);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; color: var(--night); background: var(--bg); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
a { color: inherit; }

/* Top bar */
.topbar { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 18px; padding: 14px 32px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--rausch), #ff7a59); }
.logo-text { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.meta { font-size: 13px; color: var(--foggy); text-align: right; line-height: 1.5; }

/* Filter chips */
.filterbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filter-chips { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.filterbar.collapsed .filter-chips { display: none; }
.filter-toggle { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s ease; }
.filter-toggle:hover { border-color: var(--night); color: var(--night); }
.filter-toggle svg { transition: transform .2s ease; }
.filterbar.collapsed .filter-toggle svg { transform: rotate(-90deg); }
.filter-summary { display: none; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--foggy); }
.filterbar.collapsed .filter-summary { display: inline-flex; }
.filter-summary .pill-sum { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--offwhite); color: var(--hof); font-weight: 600; }
.filter-summary .pill-sum.region { background: var(--rausch); color: var(--white); }
.filter-summary .pill-sum.fav { background: #fff0f3; color: var(--rausch); }
.chip-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 13px; font-weight: 500; transition: all .15s ease; }
.chip:hover { border-color: var(--night); }
.chip.active { background: var(--night); color: var(--white); border-color: var(--night); }
.chip.region { font-weight: 700; }
.chip.region.active { background: var(--rausch); color: var(--white); border-color: var(--rausch); }
.region-group { padding-right: 8px; margin-right: 4px; border-right: 1px solid var(--line); }
.chip.select { padding-right: 10px; }
.chip select.select, .chip.select { appearance: none; cursor: pointer; }
.chip.range { padding-right: 6px; }
.chip.range input { width: 70px; height: 24px; border: none; outline: none; background: transparent; font-weight: 500; padding: 0 4px; text-align: right; -moz-appearance: textfield; }
.chip.search { padding-left: 10px; padding-right: 4px; gap: 6px; }
.chip.search input { width: 180px; height: 26px; border: none; outline: none; background: transparent; font: inherit; font-weight: 500; color: var(--hof); }
.chip.search input::placeholder { color: var(--foggy); font-weight: 400; }
.chip.range input::-webkit-outer-spin-button, .chip.range input::-webkit-inner-spin-button { -webkit-appearance: none; }
.chip.toggle input { margin-right: 4px; accent-color: var(--rausch); }
.chip.toggle:has(input:checked),
.chip.toggle.checked { background: #fff0f3; border-color: var(--rausch); color: var(--rausch); }
.chip.toggle.fav.checked { background: var(--rausch); color: var(--white); border-color: var(--rausch); }

/* Heart / favorite button */
.fav-btn { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(255,255,255,0.92); color: var(--hof); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: transform .15s ease, color .15s ease; z-index: 1; }
.fav-btn:hover { transform: scale(1.1); }
.fav-btn svg { width: 13px; height: 13px; }
.fav-btn.is-fav { color: var(--rausch); }
.fav-btn.is-fav svg { fill: var(--rausch); }
.card { position: relative; }
.card .addr, .card .hero { padding-left: 28px; }
.card .pills { padding-left: 0; }

.fav-btn-detail { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-weight: 600; font-size: 13px; cursor: pointer; transition: all .15s ease; }
.fav-btn-detail:hover { border-color: var(--rausch); color: var(--rausch); }
.fav-btn-detail.is-fav { background: var(--rausch); color: var(--white); border-color: var(--rausch); }
.fav-btn-detail svg { width: 16px; height: 16px; }
.fav-btn-detail.is-fav svg { fill: currentColor; }
.muted { color: var(--foggy); font-weight: 400; }
.chip.secondary { gap: 8px; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(560px, 1fr) minmax(0, 1.1fr); height: calc(100vh - 65px); transition: grid-template-columns .25s ease; }
.layout[data-list="collapsed"] { grid-template-columns: 0 1fr; }
/* When collapsed, the list stays in the DOM + grid as a 0-width invisible
   track so the map keeps its grid column 2 placement. Using display:none
   removes the first grid item, which auto-shifts the map into the 0-width
   first column and visually erases the map. */
.layout[data-list="collapsed"] .results { padding: 0; visibility: hidden; overflow: hidden; min-width: 0; }
@media (min-width: 1101px) {
  .layout > .map-wrap { grid-column: 2; }
}
.results { padding: 24px 32px 32px; overflow-y: auto; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 10px; }
.results-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; flex: 1; min-width: 0; }
.results-head #result-count { white-space: nowrap; }
.list-collapse { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); cursor: pointer; flex-shrink: 0; transition: all .15s ease; }
.list-collapse:hover { border-color: var(--night); color: var(--night); }

/* Bulk-select toggle + CSV-export buttons (results-head). The bulk
 * toggle flips on checkboxes per card + the sticky action bar; the CSV
 * button is always available and reflects the current filter. */
.bulk-toggle, .export-csv { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; height: 28px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.bulk-toggle:hover, .export-csv:hover { border-color: var(--night); }
.bulk-toggle.active { background: var(--rausch); color: var(--white); border-color: var(--rausch); }
.export-csv:disabled { opacity: 0.45; cursor: not-allowed; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
/* In bulk mode the cards are denser and accommodate the checkbox in
 * the top-left corner. Selection state highlights the card outline. */
.cards.bulk-mode .card { padding-left: 32px; }
.cards .card.bulk-selected { outline: 2px solid var(--rausch); outline-offset: -1px; }
.bulk-check { position: absolute; top: 8px; left: 8px; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.bulk-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--rausch); }

/* Sticky bulk-action bar at the bottom of the results pane. */
.bulk-bar { position: sticky; bottom: 0; left: 0; right: 0; margin: 12px -22px -22px; padding: 12px 22px; background: var(--white); border-top: 1px solid var(--line-strong); box-shadow: 0 -2px 12px rgba(0,0,0,0.04); z-index: 5; }
.bulk-bar.hidden { display: none; }
.bulk-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bulk-bar-count { font-size: 13px; color: var(--hof); }
.bulk-bar-count strong { font-size: 16px; color: var(--rausch); }
.bulk-bar-count .muted { font-size: 11px; }
.bulk-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bulk-bar-actions .btn { flex: 0 0 auto; height: auto; padding: 7px 14px; font-size: 12px; font-weight: 600; line-height: 1; }
.bulk-bar-actions .btn.ghost { background: var(--white); color: var(--hof); border-color: var(--line-strong); }
.bulk-bar-actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bulk-bar-actions select.btn { padding: 7px 10px; cursor: pointer; }

/* Card */
.card { background: var(--white); border-radius: var(--radius-md); border: 1px solid var(--line); padding: 10px 12px 11px; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; position: relative; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: transparent; }
.card .hero { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card .lot-sf { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.card .lot-sf small { font-size: 10px; font-weight: 500; color: var(--foggy); margin-left: 3px; }
.card .score { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 700; font-size: 12px; }
.score.tier-call { background: var(--rausch); color: var(--white); }
.score.tier-mail { background: #ffefe6; color: #c2410c; }
.score.tier-watch { background: var(--offwhite); color: var(--hof); }
.score.tier-skip { background: transparent; color: var(--foggy); border: 1px dashed var(--line-strong); }
.card .addr { font-size: 12px; color: var(--hof); margin-bottom: 2px; line-height: 1.3; max-height: 1.3em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.card .city-line { font-size: 11px; color: var(--foggy); margin-bottom: 7px; }
.card .pills { display: flex; gap: 4px; flex-wrap: wrap; }
.card .pills .pill { font-size: 10px; padding: 1px 7px; }
.pill { display: inline-block; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 500; background: var(--offwhite); color: var(--hof); }
.pill.listed { background: #e6f7ee; color: #0a7d3b; }
.pill.investor { background: #f3e8ff; color: #6b21a8; }
.pill.teardown { background: #ffeacc; color: #9a3412; }
.pill.transit { background: #e0f2fe; color: #0369a1; }
.pill.duplex { background: #ede9fe; color: #5b21b6; }
.pill.cottage { background: #fef3c7; color: #92400e; }

/* Map */
.map-wrap { background: var(--white); border-left: 1px solid var(--line); position: relative; }
.list-expand { display: none; position: absolute; top: 16px; left: 12px; z-index: 5; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-md); transition: all .15s ease; }
.list-expand:hover { border-color: var(--night); color: var(--night); }
.layout[data-list="collapsed"] .list-expand { display: inline-flex; }
#map { width: 100%; height: 100%; }
.maplibregl-popup-content { padding: 14px 16px !important; border-radius: var(--radius-md) !important; box-shadow: var(--shadow-md) !important; font-family: inherit; }

/* Selected-parcel address pill on the map */
.maplibregl-popup.parcel-addr-popup .maplibregl-popup-content {
  padding: 8px 14px !important;
  background: var(--rausch);
  color: var(--white);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  border-radius: var(--radius-pill) !important;
  box-shadow: 0 6px 18px rgba(255, 56, 92, 0.35) !important;
  border: 2px solid var(--white);
  white-space: nowrap;
  max-width: none;
}
.maplibregl-popup.parcel-addr-popup .maplibregl-popup-tip { display: none; }
.parcel-addr-popup-text { display: block; line-height: 1.2; }
.parcel-addr-popup-sub { display: block; font-weight: 500; font-size: 11px; opacity: 0.85; margin-top: 2px; }

/* Drawer */
.drawer { position: fixed; top: 65px; right: 0; width: 420px; max-width: 92vw; height: calc(100vh - 65px); background: var(--white); box-shadow: var(--shadow-lg); padding: 28px 28px 32px; overflow-y: auto; z-index: 30; transform: translateX(0); transition: transform .25s ease; }
.drawer.drawer-wide { width: 540px; right: 420px; z-index: 31; border-right: 1px solid var(--line); }
@media (max-width: 1100px) { .drawer.drawer-wide { right: 0; z-index: 32; width: 480px; } }
.drawer.hidden { transform: translateX(100%); }
/* The wide drawer sits to the LEFT of the regular drawer (right: 420px), so
   translating by 100% of its own width still leaves the 420px right-offset
   visible as a blank white strip. Push it past that offset too. The mobile
   breakpoint above resets right:0, which the default rule already covers. */
@media (min-width: 1101px) {
  .drawer.drawer-wide.hidden { transform: translateX(calc(100% + 420px)); }
}
.drawer-close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); font-size: 20px; line-height: 1; color: var(--hof); }
.drawer-close:hover { background: var(--offwhite); }
.detail-h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.detail-sub { color: var(--foggy); font-size: 14px; margin-bottom: 12px; }
.detail-quicklinks { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.quicklink { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 13px; font-weight: 600; text-decoration: none; transition: all .15s ease; }
.quicklink:hover { border-color: var(--night); color: var(--night); }
.quicklink.primary { background: var(--night); color: var(--white); border-color: var(--night); }
.quicklink.primary:hover { background: var(--rausch); border-color: var(--rausch); }
.detail-score { display: flex; align-items: center; gap: 14px; margin: 0 0 18px; padding: 14px; background: var(--offwhite); border-radius: var(--radius-md); }
.detail-score .score { width: 56px; height: 56px; font-size: 18px; }
.detail-score .label { font-weight: 600; font-size: 15px; }
.detail-score .label small { display: block; color: var(--foggy); font-weight: 400; font-size: 12px; margin-top: 2px; }

.detail-section { margin-top: 18px; }
.detail-section h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--foggy); font-weight: 600; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: var(--foggy); }
.detail-row span:last-child { color: var(--night); font-weight: 500; text-align: right; }
ul.notes { padding-left: 18px; font-size: 12px; color: var(--hof); margin: 6px 0; }
ul.notes li { margin: 4px 0; }

/* Pro-forma drawer */
.pf-h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.pf-sub { color: var(--foggy); font-size: 13px; margin-bottom: 18px; }
.pf-strategy-title { font-size: 16px; font-weight: 700; color: var(--rausch); margin: 6px 0 6px; }
.pf-narrative { font-size: 13px; line-height: 1.55; color: var(--hof); margin: 0 0 12px; }
.pf-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.pf-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.pf-table td.label { color: var(--foggy); }
.pf-table td.value { text-align: right; font-weight: 600; }
.pf-table tr.highlight td { font-size: 14px; font-weight: 700; color: var(--rausch); }
.pf-table tr.total td { border-top: 2px solid var(--night); border-bottom: 2px solid var(--night); font-weight: 700; }
.pf-callout { background: var(--offwhite); border-radius: var(--radius-md); padding: 12px 14px; font-size: 13px; line-height: 1.5; margin: 12px 0; }
.pf-callout strong { color: var(--rausch); }
.pf-comps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; margin: 8px 0 16px; }
.pf-comp { padding: 10px 12px; background: var(--offwhite); border-radius: var(--radius-md); }
.pf-comp-addr { font-weight: 600; margin-bottom: 2px; }
.pf-comp-meta { color: var(--foggy); font-size: 11px; }

/* Development-scenario controls: concept dropdown + cost/SF + sale/SF
 * inputs. Three-column grid on desktop, stacks on narrow widths. */
.pf-dev-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
@media (max-width: 600px) { .pf-dev-controls { grid-template-columns: 1fr 1fr; } }
.pf-trade-details { margin: 6px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0; }
.pf-trade-details > summary { padding: 8px 12px; cursor: pointer; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--foggy); }
.pf-trade-details[open] > summary { border-bottom: 1px solid var(--line); }
.pf-trade-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pf-trade-table td { padding: 6px 12px; border-bottom: 1px solid var(--line); }
.pf-trade-table td.label { color: var(--foggy); }
.pf-trade-table td.value { text-align: right; font-weight: 600; color: var(--hof); }
.pf-trade-table tr:last-child td { border-bottom: 0; }
.pf-exit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px; margin: 6px 0 10px; }
.pf-exit-toggle button { border: 0; background: transparent; padding: 6px 14px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; color: var(--foggy); cursor: pointer; }
.pf-exit-toggle button.active { background: var(--rausch); color: var(--white); }

/* Portfolios drawer */
.port-card { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); margin: 10px 0; background: var(--white); }
.port-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 14px; }
.port-badge { font-size: 11px; color: var(--foggy); padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--radius-pill); }
.port-card-meta { font-size: 11px; color: var(--foggy); margin-bottom: 4px; }
.port-create { background: var(--offwhite); padding: 12px; border-radius: var(--radius-md); margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.port-create-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.port-create-row .pf-dev-field { font-size: 11px; }
.port-proj { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 6px 0; cursor: pointer; background: var(--white); }
.port-proj:hover { border-color: var(--rausch); }
.port-proj-head { font-size: 13px; }
.port-proj-meta { font-size: 11px; color: var(--foggy); }
.pf-dev-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--foggy); }
.pf-dev-field > span { font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pf-dev-field > small { font-size: 10px; color: var(--foggy); }
.pf-dev-input { font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: white; color: var(--hof); font-weight: 600; }
.pf-dev-input:focus { outline: 2px solid var(--rausch); outline-offset: -1px; }
.pf-dev-summary { font-size: 12px; color: var(--hof); margin: 4px 0 8px; padding: 8px 12px; background: var(--offwhite); border-radius: var(--radius-md); }
.pf-dev-summary strong { color: var(--rausch); }
.pf-summary { background: var(--night); color: var(--white); border-radius: var(--radius-md); padding: 14px 16px; margin: 12px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5; white-space: pre-wrap; max-height: 220px; overflow-y: auto; }
.pf-disclaimer { font-size: 11px; color: var(--foggy); font-style: italic; margin: 8px 0 0; }
.pf-pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-pill); background: var(--rausch); color: var(--white); border: none; font-weight: 600; font-size: 13px; cursor: pointer; margin-top: 8px; }
.pf-pill:hover { background: var(--rausch-dark); }
.pf-copy-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; height: 28px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 11px; font-weight: 600; cursor: pointer; margin: 0 0 4px; }
.pf-copy-btn.copied { background: #ecfdf5; color: #065f46; border-color: #065f46; }

/* AI narrative controls (above the Strategy section in the proforma drawer). */
.pf-narrative-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--radius-md); background: var(--offwhite); margin: 12px 0 16px; }
.pf-narrative-row.stale { background: #fef3c7; border: 1px solid #f59e0b; align-items: flex-start; }
.pf-narrative-row.fresh { background: #ecfdf5; border: 1px solid #10b981; }
.pf-narrative-stale { font-size: 12px; line-height: 1.4; color: #78350f; flex: 1; min-width: 220px; }
.pf-narrative-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--radius-pill); background: var(--night); color: var(--white); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.pf-narrative-meta { font-size: 11px; color: var(--foggy); }
.pf-gen-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: var(--radius-pill); background: var(--rausch); color: var(--white); border: none; font-weight: 600; font-size: 12px; cursor: pointer; margin-left: auto; }
.pf-gen-btn:hover { background: var(--rausch-dark); }
.pf-gen-btn.ghost { background: var(--white); color: var(--hof); border: 1px solid var(--line-strong); }
.pf-gen-btn.ghost:hover { background: var(--offwhite); border-color: var(--night); }
.pf-gen-btn:disabled { opacity: 0.7; cursor: progress; }

.action-row { display: flex; gap: 10px; margin: 18px 0 0; }
.btn { flex: 1; height: 44px; border-radius: var(--radius-pill); font-weight: 600; font-size: 14px; border: 1px solid var(--line-strong); background: var(--white); color: var(--night); transition: all .15s ease; }
.btn:hover { border-color: var(--night); }
.btn.primary { background: var(--rausch); color: var(--white); border-color: var(--rausch); }
.btn.primary:hover { background: var(--rausch-dark); border-color: var(--rausch-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.contact-block { margin-top: 14px; }
.contact-block .contact-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--foggy); font-weight: 600; margin: 12px 0 6px; }
.contact-block .phone, .contact-block .email { font-size: 14px; padding: 4px 0; font-weight: 500; }
.contact-block .phone .meta { font-size: 11px; color: var(--foggy); font-weight: 400; margin-left: 4px; }

/* WA SoS entity-unmasking block. Appears below skip-trace results when
 * the owner is an LLC / Trust / Corp. */
.entity-row { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--offwhite); }
.entity-row .contact-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--foggy); font-weight: 600; margin-bottom: 4px; }
.entity-row .principal { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.entity-row .principal:last-of-type { border-bottom: 0; }
.entity-row .principal .muted { font-size: 11px; color: var(--foggy); margin-left: 6px; }

/* Mail-outreach fallback block. Shown alongside skip-trace results so
 * direct mail is always one click away when phone/email aren't found. */
.mail-fallback { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--offwhite); }
.mail-fallback .contact-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--foggy); font-weight: 600; margin-bottom: 4px; }
.mail-fallback .mail-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--white); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 6px 0; white-space: pre-wrap; }

.warn { font-size: 13px; color: #92400e; padding: 10px 12px; background: #fef3c7; border-radius: var(--radius-sm); margin: 8px 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--foggy); }
.empty h2 { font-weight: 600; color: var(--hof); margin: 8px 0; }

/* Admin / refresh panel */
.admin-wrap { position: relative; }
.admin-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius-pill); border: 1px solid var(--night); background: var(--night); color: var(--white); font-size: 13px; font-weight: 600; transition: background .15s ease; }
.admin-btn:hover { background: #000; }
.admin-btn svg { display: block; }

.admin-panel { position: absolute; right: 0; top: calc(100% + 12px); width: 360px; max-height: calc(100vh - 110px); overflow-y: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 18px 20px 14px; z-index: 40; }
.admin-panel.hidden { display: none; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.admin-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.admin-close { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); font-size: 18px; line-height: 1; color: var(--hof); }
.admin-close:hover { background: var(--offwhite); }
.admin-action { padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-action:last-child { border-bottom: none; }
.admin-action.diag { padding: 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-action.diag .admin-action-h { margin: 0; }
.admin-action.diag .btn { width: auto; padding: 0 16px; height: 36px; flex-shrink: 0; }
.admin-action-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; gap: 8px; }
.admin-action-h strong { font-size: 14px; font-weight: 600; color: var(--night); }
.admin-est { font-size: 11px; color: var(--foggy); white-space: nowrap; }
.admin-action p { font-size: 12px; color: var(--foggy); margin: 0 0 10px; line-height: 1.45; }
.last-run { font-size: 11px; color: var(--foggy); margin: 0 0 8px; }
.last-run.fresh { color: #0a7d3b; }
.last-run.stale { color: #c2410c; }
.last-run.running { color: var(--rausch); font-weight: 600; }
.last-run.running::before { content: "● "; animation: pulse 1.2s infinite; }
.admin-action .btn { width: 100%; height: 36px; font-size: 13px; }
.admin-row { display: flex; gap: 8px; align-items: center; }
.admin-row .chip.select { flex: 1; height: 36px; }

.parallel-progress { display: none; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.parallel-progress.active { display: flex; }
.parallel-progress .city-line { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--offwhite); border-radius: 6px; }
.parallel-progress .city-line .name { flex: 1; font-weight: 600; color: var(--hof); }
.parallel-progress .city-line .state { color: var(--foggy); }
.parallel-progress .city-line.done { background: #ecfdf5; color: #065f46; }
.parallel-progress .city-line.done .name, .parallel-progress .city-line.done .state { color: #065f46; }
.parallel-progress .city-line.error { background: #fef2f2; color: #991b1b; }
.parallel-progress .city-line.error .name, .parallel-progress .city-line.error .state { color: #991b1b; }
.parallel-progress .city-line.running .state::after { content: " …"; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.admin-row .btn { flex-shrink: 0; width: auto; padding: 0 16px; }
.admin-divider { height: 1px; background: var(--line); margin: 8px 0; }
.admin-status { margin-top: 4px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.5; min-height: 0; max-height: 160px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; display: none; white-space: pre-wrap; word-break: break-word; }
.admin-status.show { display: block; }
.admin-status.running { background: #fff7ed; color: #92400e; }
.admin-status.ok { background: #ecfdf5; color: #065f46; }
.admin-status.error { background: #fef2f2; color: #991b1b; }

.admin-copy { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 4px 10px; height: 28px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-size: 11px; font-weight: 600; cursor: pointer; transition: all .15s ease; -webkit-tap-highlight-color: rgba(0,0,0,0.06); }
.admin-copy.hidden { display: none; }
.admin-copy:hover { border-color: var(--night); color: var(--night); }
.admin-copy.copied { background: #ecfdf5; color: #065f46; border-color: #065f46; }
/* Make the SVG/span inside non-interactive so the click always lands
   on the <button> on iOS, which otherwise picks the inner element
   as the event target and loses the user-gesture context. */
.admin-copy svg, .admin-copy span { pointer-events: none; }

/* Map / List toggle (mobile only) */
.view-toggle { display: none; position: sticky; top: 65px; z-index: 15; padding: 10px 16px; background: var(--white); border-bottom: 1px solid var(--line); gap: 6px; justify-content: center; }
.view-toggle .vt-btn { flex: 1; max-width: 200px; height: 40px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--white); color: var(--hof); font-weight: 600; font-size: 14px; }
.view-toggle .vt-btn.active { background: var(--night); color: var(--white); border-color: var(--night); }

/* ≤1100px: stack list + map */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .map-wrap { height: 420px; border-left: none; border-top: 1px solid var(--line); position: sticky; top: 65px; }
  .results { height: auto; max-height: none; overflow: visible; }
  /* Mobile already uses the List|Map toggle for view switching, so the
     desktop collapse button + expand handle would be redundant noise. */
  .list-collapse, .list-expand { display: none !important; }
}

/* ≤900px: smaller padding, tighter cards */
@media (max-width: 900px) {
  .topbar { padding: 12px 18px; gap: 12px; }
  .results { padding: 18px 18px 24px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .map-wrap { position: static; height: 380px; }
}

/* ≤768px: stack the topbar to two rows, scroll filters horizontally,
   show the view toggle, and hide the meta count (admin panel surfaces it). */
@media (max-width: 768px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
      "brand meta admin"
      "filters filters filters";
    padding: 10px 14px 0;
    gap: 10px 12px;
  }
  .brand { grid-area: brand; }
  .meta { grid-area: meta; font-size: 11px; }
  .admin-wrap { grid-area: admin; }
  .filterbar {
    grid-area: filters;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 12px;
    margin: 0 -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .filterbar::-webkit-scrollbar { display: none; }
  .filterbar { scrollbar-width: none; }
  .chip-group { flex-wrap: nowrap; }
  .chip { scroll-snap-align: start; flex-shrink: 0; }
  .chip-group.secondary { gap: 6px; }
  .admin-label { display: none; }
  .admin-btn { padding: 0 12px; height: 38px; }

  .view-toggle { display: flex; }

  .layout { grid-template-rows: auto; }
  .layout[data-view="list"] .map-wrap { display: none; }
  .layout[data-view="map"] .results { display: none; }
  .layout[data-view="map"] .map-wrap { height: calc(100vh - 175px); }

  .results-head h1 { font-size: 18px; }

  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; }
  .card .lot-sf { font-size: 20px; }
  .card .score { width: 40px; height: 40px; font-size: 13px; }

  /* Drawer: bottom sheet on phones */
  .drawer {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: auto; max-height: 88vh;
    border-top-left-radius: 18px; border-top-right-radius: 18px;
    transform: translateY(0);
    padding: 18px 20px 28px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  .drawer.hidden { transform: translateY(100%); }
  .drawer::before {
    content: ""; display: block; width: 36px; height: 4px;
    background: var(--line-strong); border-radius: 2px;
    margin: -4px auto 12px;
  }
  .drawer-close { top: 10px; right: 10px; }
  .detail-h1 { font-size: 19px; }
  .detail-score .score { width: 48px; height: 48px; font-size: 16px; }

  /* Admin panel: bottom sheet on phones */
  .admin-panel {
    position: fixed; top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%; max-height: 80vh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.18);
    padding: 16px 18px 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .admin-panel::before {
    content: ""; display: block; width: 36px; height: 4px;
    background: var(--line-strong); border-radius: 2px;
    margin: -4px auto 10px;
  }
}

/* ≤480px: smallest phones */
@media (max-width: 480px) {
  .topbar { padding: 8px 12px 0; }
  .logo-text { font-size: 15px; }
  .meta { display: none; }
  .results { padding: 14px 14px 20px; }
  .results-head { margin-bottom: 12px; }
  .chip { height: 34px; font-size: 12px; padding: 0 12px; }
  .chip.range input { width: 60px; }
  .vt-btn { font-size: 13px; }
  .layout[data-view="map"] .map-wrap { height: calc(100vh - 165px); }
}
