/* ==========================================================================
   RentStable.NYC — Civic Broadsheet Editorial Ledger (v0.3 De-Slop)
   Girnar Design Doctrine: Zero nested-card bloat, 1px hairlines, WCAG AA,
   positive 10/10 health semantics, tabular numerals, compositor-only motion
   ========================================================================== */

:root {
  /* Light Theme: Crisp Archival Broadsheet Paper */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f6f8fa;
  --surface-hover: #f0f3f7;
  --surface-translucent: rgba(255, 255, 255, 0.92);
  --border: #dfe4ea;
  --border-strong: #c0cad5;
  --ink: #0f172a;
  --ink-secondary: #3f4b5e;
  --ink-muted: #5d6a7d;

  /* Single Civic Action Accent (NYC Municipal Blue, WCAG AA >= 4.5:1) */
  --accent: #1849a9;
  --accent-hover: #123a8a;
  --accent-soft: #edf3fc;
  --accent-ink: #123a8a;

  /* Positive Health & Grade Semantics (WCAG AA) */
  --health-good: #157347;
  --health-good-bg: #ebf7f0;
  --health-good-ink: #0f5132;

  --health-watch: #b45309;
  --health-watch-bg: #fef5e0;
  --health-watch-ink: #7c3f05;

  --health-poor: #b91c1c;
  --health-poor-bg: #fce8e8;
  --health-poor-ink: #881313;

  --grade-b-solid: #0369a1;
  --grade-b-bg: #e8f4fb;
  --grade-b-ink: #0c4a6e;

  --grade-d-solid: #c2410c;
  --grade-d-bg: #fdece3;
  --grade-d-ink: #8a2c0f;

  /* Typography */
  --font-display: "Bitstream Charter", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Liberation Mono", Menlo, Consolas, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-fast: 130ms;
  --dur-ui: 180ms;

  /* Layout */
  --max-width: 1400px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --row-height: 58px;

  --z-sticky: 20;
  --z-drawer: 50;

  caret-color: var(--accent);
  accent-color: var(--accent);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #0d1117;
  --surface-subtle: #161b22;
  --surface-hover: #1c222b;
  --surface-translucent: rgba(13, 17, 23, 0.92);
  --border: #262c36;
  --border-strong: #3d4654;
  --ink: #f0f6fc;
  --ink-secondary: #b4c0cf;
  --ink-muted: #8492a6;

  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-soft: #132238;
  --accent-ink: #8cc4ff;

  --health-good: #2ea06b;
  --health-good-bg: #10291d;
  --health-good-ink: #75e0a7;

  --health-watch: #d97706;
  --health-watch-bg: #31230a;
  --health-watch-ink: #fcd34d;

  --health-poor: #dc2626;
  --health-poor-bg: #381416;
  --health-poor-ink: #fca5a5;

  --grade-b-solid: #2b8fd6;
  --grade-b-bg: #112738;
  --grade-b-ink: #7cc4fa;

  --grade-d-solid: #ea580c;
  --grade-d-bg: #361c10;
  --grade-d-ink: #fdba74;

  color-scheme: dark;
}

/* Base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.45;
  text-wrap: pretty;
  overflow-x: hidden;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(3.75rem);
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Editorial Masthead */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  min-height: 54px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  display: grid;
  place-items: center;
}

.site-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-divider {
  color: var(--border-strong);
  font-weight: 300;
}

.site-tagline {
  font-size: 0.84rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.freshness-caption {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.icon-btn:active {
  transform: scale(0.97);
}

.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Sticky Command Rail */
.command-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--surface-translucent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--border);
}

@media (prefers-reduced-transparency: reduce) {
  .command-bar {
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.command-inner {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.15rem;
  padding-bottom: 0.65rem;
}

/* Editorial Underline Borough Tabs */
.borough-nav {
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.borough-nav::-webkit-scrollbar {
  display: none;
}

.borough-tabs {
  display: inline-flex;
  align-items: stretch;
  gap: 0.25rem;
  min-width: max-content;
}

.boro-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.boro-tab .boro-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.boro-tab[aria-pressed="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.boro-tab[aria-pressed="true"] .boro-count {
  color: var(--ink);
  font-weight: 700;
}

/* Primary Controls Row */
.controls-grid {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.search-combo {
  display: flex;
  align-items: stretch;
  flex: 1 1 300px;
  min-width: 220px;
  gap: 0.35rem;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.ask-ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 0.78rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.ask-ai-btn:active {
  transform: scale(0.97);
}

.ask-ai-btn[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.ai-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
}

.ai-status-bar[hidden] {
  display: none;
}

.ai-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-status-reset {
  min-height: 44px;
  padding: 0 0.5rem;
  border: none;
  background: transparent;
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 44px;
  padding: 0.45rem 3.4rem 0.45rem 2.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.search-input::placeholder {
  color: var(--ink-muted);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-input:focus {
  border-color: var(--accent);
}

.kbd-hint {
  position: absolute;
  right: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--ink-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 0.25rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  display: inline-grid;
  place-items: center;
}

.search-clear-btn[hidden] {
  display: none;
}

.select-field {
  flex: 0 1 auto;
}

.radius-field[hidden] {
  display: none;
}

.control-select {
  min-height: 44px;
  max-width: 220px;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 500;
}

/* Clean Hairline Filter Strip */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.filter-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 0.2rem;
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.toggle-btn:active {
  transform: scale(0.97);
}

.toggle-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.toggle-open-listings {
  border-color: var(--health-good);
  color: var(--health-good-ink);
  background: var(--health-good-bg);
}

.toggle-open-listings[aria-pressed="true"] {
  background: var(--health-good);
  border-color: var(--health-good);
  color: #ffffff;
}

.open-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--health-good);
  flex-shrink: 0;
}

.toggle-open-listings[aria-pressed="true"] .open-dot {
  background: #ffffff;
}

.toggle-count {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
}

.toggle-grade {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 0.35rem 0.5rem;
}

.toggle-grade-a[aria-pressed="true"] { background: var(--health-good); border-color: var(--health-good); color: #ffffff; }
.toggle-grade-b[aria-pressed="true"] { background: var(--grade-b-solid); border-color: var(--grade-b-solid); color: #ffffff; }
.toggle-grade-c[aria-pressed="true"] { background: var(--health-watch); border-color: var(--health-watch); color: #ffffff; }
.toggle-grade-d[aria-pressed="true"] { background: var(--grade-d-solid); border-color: var(--grade-d-solid); color: #ffffff; }
.toggle-grade-f[aria-pressed="true"] { background: var(--health-poor); border-color: var(--health-poor); color: #ffffff; }

.clear-filters-btn {
  margin-left: auto;
  min-height: 44px;
  padding: 0.3rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.clear-filters-btn[hidden] {
  display: none;
}

/* Est. Rent Dual-Range Slider */
.rent-range-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.rent-range-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.dual-slider {
  position: relative;
  width: 132px;
  height: 28px;
  display: flex;
  align-items: center;
}

.dual-slider-track {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  pointer-events: none;
}

.dual-slider-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left center;
  transform: translateX(0%) scaleX(1);
}

.dual-range-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.dual-range-input::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: ew-resize;
}

.dual-range-input::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: ew-resize;
}

.dual-range-input::-webkit-slider-runnable-track {
  background: transparent;
}

.dual-range-input::-moz-range-track {
  background: transparent;
}

.rent-range-readout {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 78px;
  text-align: right;
  white-space: nowrap;
}

/* Main Content */
.main-content {
  padding-top: 0.9rem;
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  flex: 1;
}

/* Single-Band Civic Ledger Strip (Zero Box-Inside-Box) */
.ledger-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 1rem 1.75rem;
  padding-bottom: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.ledger-left {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.ledger-title-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.ledger-heading {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.scope-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.16rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.top-rated-btn {
  margin-left: auto;
  min-height: 44px;
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.top-rated-btn:active {
  transform: scale(0.97);
}

.top-rated-btn[aria-pressed="true"] {
  background: var(--health-good);
  border-color: var(--health-good);
  color: #ffffff;
}

.ledger-stats {
  margin: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem 1.35rem;
}

.stat-pair {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.stat-pair dt {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.stat-pair dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

/* Directly Labeled Flat A-F Distribution Bar */
.ledger-right {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.grade-dist-bar {
  display: flex;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  gap: 2px;
  background: var(--surface-subtle);
}

.dist-seg {
  border: none;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.dist-seg-a { background: var(--health-good); }
.dist-seg-b { background: var(--grade-b-solid); }
.dist-seg-c { background: var(--health-watch); }
.dist-seg-d { background: var(--grade-d-solid); }
.dist-seg-f { background: var(--health-poor); }

.dist-seg.is-dimmed { opacity: 0.25; }
.dist-seg.is-empty { display: none; }
.dist-seg-label { pointer-events: none; }

.grade-dist-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.3rem 0.65rem;
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.legend-item strong {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 700;
}

.swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.swatch-a { background: var(--health-good); }
.swatch-b { background: var(--grade-b-solid); }
.swatch-c { background: var(--health-watch); }
.swatch-d { background: var(--grade-d-solid); }
.swatch-f { background: var(--health-poor); }

/* Results Directory Table */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.results-toolbar-left {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  min-width: 70px;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.view-toggle-btn:last-child {
  border-right: none;
}

.view-toggle-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Interactive Apartment Map View */
.map-view-wrap[hidden],
.table-frame[hidden] {
  display: none;
}

.map-view-wrap {
  display: block;
}

.map-stage {
  position: relative;
  width: 100%;
  height: clamp(440px, 66dvh, 760px);
  overflow: hidden;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.map-stage.is-panning {
  cursor: grabbing;
}

.map-tile-layer,
.map-dot-canvas,
.map-overlay-layer,
.map-card-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-tile-layer,
.map-dot-canvas,
.map-overlay-layer {
  pointer-events: none;
}

.map-tile-layer {
  filter: saturate(0.42) contrast(0.95) brightness(1.03);
}

[data-theme="dark"] .map-tile-layer {
  filter: invert(100%) hue-rotate(180deg) saturate(0.42) brightness(0.84) contrast(0.96);
}

.map-tile {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  pointer-events: none;
  user-select: none;
}

.map-overlay-svg {
  position: absolute;
  inset: 0;
}

.map-radius-circle {
  fill: rgba(24, 73, 169, 0.08);
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

[data-theme="dark"] .map-radius-circle {
  fill: rgba(88, 166, 255, 0.12);
}

.map-landmark-pin {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transform-origin: center center;
  margin-left: -7px;
  margin-top: -12px;
}

.map-landmark-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  border: 2.5px solid #ffffff;
  flex-shrink: 0;
}

.map-landmark-label {
  padding: 0.15rem 0.48rem;
  border-radius: 4px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Modern Apartment Price+Beds Map Cards */
.map-card {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  font-variant-numeric: tabular-nums;
  transition: transform var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.map-card-active {
  z-index: 4;
  background: #15803d;
  color: #ffffff;
  border: 1.5px solid #ffffff;
}

[data-theme="dark"] .map-card-active {
  background: #16a34a;
  color: #ffffff;
  border-color: #0d1117;
}

.map-card-est {
  z-index: 2;
  background: #ffffff;
  color: #334155;
  border: 1px solid #94a3b8;
}

[data-theme="dark"] .map-card-est {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

.map-card.is-selected {
  z-index: 6;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mc-beds {
  opacity: 0.88;
  font-weight: 600;
}

.mc-grade {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
}

.map-card-active .mc-grade {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.map-card-est .mc-grade-a { background: var(--health-good-bg); color: var(--health-good-ink); }
.map-card-est .mc-grade-b { background: var(--grade-b-bg); color: var(--grade-b-ink); }
.map-card-est .mc-grade-c { background: var(--health-watch-bg); color: var(--health-watch-ink); }
.map-card-est .mc-grade-d { background: var(--grade-d-bg); color: var(--grade-d-ink); }
.map-card-est .mc-grade-f { background: var(--health-poor-bg); color: var(--health-poor-ink); }

/* Floating Map Legend, Tooltip, Controls & Attribution */
.map-legend {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  max-width: calc(100% - 4.5rem);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-translucent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

@media (prefers-reduced-transparency: reduce) {
  .map-legend {
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.map-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.ml-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.ml-dot-active { background: #15803d; }
.ml-dot-est    { background: #64748b; }

.map-legend-sep {
  color: var(--border-strong);
}

.map-legend-stats {
  font-family: var(--font-mono);
  color: var(--ink-secondary);
}

.map-legend-hint {
  color: var(--ink-muted);
  font-weight: 500;
}

.map-tooltip {
  position: absolute;
  left: 0.65rem;
  bottom: 0.65rem;
  z-index: 9;
  max-width: min(460px, calc(100% - 10rem));
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
}

.map-tooltip[hidden] {
  display: none;
}

.map-controls {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 8;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.map-ctrl-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.map-ctrl-btn:last-child {
  border-bottom: none;
}

.map-attribution {
  position: absolute;
  right: 0.5rem;
  bottom: 0.45rem;
  z-index: 7;
  padding: 0.12rem 0.42rem;
  border-radius: 3px;
  background: var(--surface-translucent);
  font-size: 0.72rem;
  color: var(--ink-muted);
  pointer-events: none;
}

.results-heading {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
}

.results-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.table-frame {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

/* Shared 6-column editorial ledger grid */
.table-header-row,
.bldg-row {
  display: grid;
  grid-template-columns: 88px minmax(220px, 1.85fr) minmax(155px, 1.15fr) 68px 155px minmax(175px, 1.2fr);
  align-items: center;
  gap: 0.75rem;
}

.table-header-row {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
}

.col-units {
  text-align: right;
}

.table-viewport {
  position: relative;
  height: clamp(380px, 62dvh, 720px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  contain: strict;
}

.table-spacer {
  position: relative;
  width: 100%;
}

.table-rows {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.bldg-row {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--row-height);
  width: 100%;
  padding: 0 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font: inherit;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.bldg-row.is-selected {
  background: var(--accent-soft);
}

/* Neighborhood Group Divider Row (Virtualized at exact --row-height) */
.group-divider-row {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--row-height);
  width: 100%;
  padding: 0 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
}

.group-divider-name {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.group-divider-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-secondary);
  white-space: nowrap;
}

/* Crisp Editorial Grade Cell */
.grade-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.grade-square {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1;
}

.grade-a { background: var(--health-good-bg); color: var(--health-good-ink); }
.grade-b { background: var(--grade-b-bg); color: var(--grade-b-ink); }
.grade-c { background: var(--health-watch-bg); color: var(--health-watch-ink); }
.grade-d { background: var(--grade-d-bg); color: var(--grade-d-ink); }
.grade-f { background: var(--health-poor-bg); color: var(--health-poor-ink); }

.grade-score-num {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

/* Address Column */
.cell-address {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.addr-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.addr-primary {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.open-badge {
  flex-shrink: 0;
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  background: var(--health-good);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
}

.multi-tag {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.addr-sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Location / Neighborhood / Landmark Distance */
.cell-location {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.loc-primary {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-secondary {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loc-distance {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent-ink);
  white-space: nowrap;
}

/* Units */
.cell-units {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Est. Rent Column */
.cell-rent {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
}

.rent-range {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rent-range-empty {
  color: var(--ink-muted);
  font-weight: 400;
}

.rent-src-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.2;
}

.rent-src-live { color: var(--health-good-ink); }
.rent-src-last { color: var(--accent-ink); }
.rent-src-zip  { color: var(--ink-muted); }

/* HPD Signals Column (Clean Typographic Ledger — Zero Pill Clutter) */
.cell-signals {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  white-space: nowrap;
}

.sig-tok-crit  { color: var(--health-poor-ink); font-weight: 700; }
.sig-tok-heat  { color: var(--grade-d-ink); }
.sig-tok-pest  { color: var(--health-watch-ink); }
.sig-tok-bug   { color: var(--health-poor-ink); }
.sig-tok-clean { color: var(--health-good-ink); font-family: var(--font-sans); font-weight: 600; }

/* Table States */
.table-state {
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.65rem;
  color: var(--ink-secondary);
}

.table-state[hidden] {
  display: none;
}

.table-state h3 {
  font-size: 1rem;
  color: var(--ink);
}

.table-state p {
  max-width: 48ch;
  font-size: 0.875rem;
}

.state-loading {
  padding: 0;
  align-items: stretch;
  gap: 0;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 88px minmax(220px, 1.85fr) minmax(155px, 1.15fr) 68px 155px minmax(175px, 1.2fr);
  align-items: center;
  gap: 0.75rem;
  height: var(--row-height);
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--border);
}

.skel {
  display: block;
  height: 15px;
  border-radius: 3px;
  background: var(--surface-subtle);
  animation: skel-pulse 1.4s var(--ease-out) infinite;
}

.skel-badge { width: 68px; height: 24px; }
.skel-addr  { width: 76%; }
.skel-loc   { width: 68%; }
.skel-num   { width: 38px; margin-left: auto; }
.skel-rent  { width: 92px; }
.skel-sig   { width: 72%; }
.skel-block { width: 100%; height: 84px; }
.skel-block-sm { width: 64%; height: 22px; }

@keyframes skel-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Primary & Secondary Action Buttons */
.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.primary-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

[data-theme="dark"] .primary-btn {
  color: #0b1220;
}

.secondary-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.97);
}

/* Minimal Footer */
.site-footer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.25rem;
}

.methodology-disclosure {
  border-bottom: 1px solid var(--border);
}

.methodology-summary {
  list-style: none;
  padding: 0.65rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.methodology-summary::-webkit-details-marker {
  display: none;
}

.chevron-icon {
  flex-shrink: 0;
  transition: transform var(--dur-ui) var(--ease-out);
}

.methodology-disclosure[open] .chevron-icon {
  transform: rotate(180deg);
}

.methodology-body {
  padding-bottom: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.84rem;
  color: var(--ink-secondary);
  max-width: 78ch;
}

.footer-colophon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.footer-colophon strong {
  font-family: var(--font-display);
  color: var(--ink);
}

/* ==========================================================================
   Native Dialog Slide-Over Inspector Drawer (Flat Editorial Sections)
   ========================================================================== */
.inspector-drawer {
  margin: 0 0 0 auto;
  padding: 0;
  border: none;
  border-left: 1px solid var(--border-strong);
  width: min(620px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  transform: translateX(0);
  transition: transform var(--dur-ui) var(--ease-out);
}

@starting-style {
  .inspector-drawer[open] {
    transform: translateX(28px);
  }
}

.inspector-drawer::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.drawer-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.drawer-header-main {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

/* Crisp SVG Grade Ring */
.grade-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: transparent;
}

.ring-svg {
  display: block;
  width: 64px;
  height: 64px;
}

.ring-track {
  stroke: var(--border);
}

.ring-arc {
  transition: stroke-dashoffset var(--dur-ui) var(--ease-out);
}

.grade-ring.grade-a .ring-arc { stroke: var(--health-good); }
.grade-ring.grade-b .ring-arc { stroke: var(--grade-b-solid); }
.grade-ring.grade-c .ring-arc { stroke: var(--health-watch); }
.grade-ring.grade-d .ring-arc { stroke: var(--grade-d-solid); }
.grade-ring.grade-f .ring-arc { stroke: var(--health-poor); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ring-letter {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
}

.ring-score {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.drawer-title-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.drawer-subtitle {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-secondary);
}

.drawer-program-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

.meta-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
}

.meta-tag.is-accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}

.drawer-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.65rem 1.25rem;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

.drawer-rent-bar {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.drawer-rent-bar[hidden] {
  display: none;
}

.drawer-rent-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.drawer-rent-label {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.drawer-action-links {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.drawer-loading,
.drawer-content {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.drawer-loading[hidden],
.drawer-error[hidden],
.drawer-content[hidden] {
  display: none;
}

.drawer-error {
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--health-poor);
  background: var(--health-poor-bg);
  color: var(--health-poor-ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.drawer-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.drawer-section h3 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.drawer-section-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* Open Listings Flat Hairline Band */
.drawer-listings-band {
  margin: -0.15rem -1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--health-good-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.drawer-listings-band[hidden] {
  display: none;
}

.drawer-listings-band h3,
.drawer-listings-band .drawer-section-meta {
  color: var(--health-good-ink);
}

.listings-list {
  display: flex;
  flex-direction: column;
}

.listing-row {
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.listing-row:first-child {
  border-top: none;
  padding-top: 0.15rem;
}

.listing-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1 1 240px;
}

.listing-meta-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--health-good-ink);
}

.listing-headline {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.listing-summary {
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

.listing-deadline {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--health-watch-ink);
}

.more-listings-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--health-good-ink);
}

.more-listings-summary::-webkit-details-marker {
  display: none;
}

.more-listings-disclosure[open] .chevron-icon {
  transform: rotate(180deg);
}

/* Positive 0–10 Health Meters */
.drawer-verdict {
  font-size: 0.875rem;
  color: var(--ink-secondary);
}

.health-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.health-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.health-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
}

.health-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink);
}

.health-score-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-left: auto;
}

.health-detail {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.health-num {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.health-num-good  { color: var(--health-good-ink); }
.health-num-watch { color: var(--health-watch-ink); }
.health-num-poor  { color: var(--health-poor-ink); }

.health-track {
  position: relative;
  height: 8px;
  border-radius: 2px;
  background: var(--surface-subtle);
  overflow: hidden;
}

.health-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  transform-origin: left center;
  transform: scaleX(var(--fill-ratio, 0));
  transition: transform var(--dur-ui) var(--ease-out);
}

.fill-good  { background: var(--health-good); }
.fill-watch { background: var(--health-watch); }
.fill-poor  { background: var(--health-poor); }

/* Flat Hairline Hierarchy Tree */
.hierarchy-tree {
  display: flex;
  flex-direction: column;
}

.lot-header-line {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-secondary);
}

.sub-bldg-details {
  border-bottom: 1px solid var(--border);
}

.sub-bldg-details:last-child {
  border-bottom: none;
}

.sub-bldg-summary {
  list-style: none;
  padding: 0.6rem 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.86rem;
}

.sub-bldg-summary::-webkit-details-marker {
  display: none;
}

.sub-bldg-summary.is-current {
  background: var(--surface-subtle);
}

.sub-bldg-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  min-width: 0;
}

.sub-bldg-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-secondary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.sibling-inspect-btn {
  min-height: 32px;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
}

.current-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-ink);
}

.unit-grid {
  padding: 0.5rem 0 0.75rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.45rem 0.9rem;
}

.unit-row {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.unit-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
}

.unit-counts {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.unit-empty-note {
  padding: 0.5rem 0 0.7rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* HPD Filings Underline Tabs & Flat Rows */
.record-tabs {
  display: inline-flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.record-tab {
  min-height: 40px;
  padding: 0.25rem 0.6rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.record-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.records-list {
  display: flex;
  flex-direction: column;
}

.record-row {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.record-row:last-child {
  border-bottom: none;
}

.record-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.record-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.rec-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.38rem;
  border-radius: 3px;
}

.rec-class-c { background: var(--health-poor-bg); color: var(--health-poor-ink); }
.rec-class-b { background: var(--grade-d-bg); color: var(--grade-d-ink); }
.rec-class-a { background: var(--health-watch-bg); color: var(--health-watch-ink); }
.rec-open    { background: var(--health-poor-bg); color: var(--health-poor-ink); }
.rec-closed  { background: var(--health-good-bg); color: var(--health-good-ink); }
.rec-neutral { background: var(--surface-subtle); color: var(--ink-secondary); }

.record-date {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.record-desc {
  font-size: 0.84rem;
  color: var(--ink);
  line-height: 1.45;
}

.record-empty {
  padding: 0.85rem 0;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

/* Hover States Guarded for Fine Pointers Only */
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover,
  .secondary-btn:hover,
  .top-rated-btn:not([aria-pressed="true"]):hover,
  .toggle-btn:not([aria-pressed="true"]):hover {
    background-color: var(--surface-hover);
    border-color: var(--border-strong);
  }

  .boro-tab:not([aria-pressed="true"]):hover {
    color: var(--ink);
  }

  .primary-btn:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
  }

  .ask-ai-btn:hover {
    background-color: var(--accent);
    color: #ffffff;
  }

  [data-theme="dark"] .ask-ai-btn:hover {
    color: #0b1220;
  }

  .bldg-row:hover {
    background-color: var(--surface-hover);
  }

  .map-ctrl-btn:hover {
    background-color: var(--surface-hover);
  }

  .map-card-active:hover {
    background-color: #166534;
    z-index: 7;
  }

  .map-card-est:hover {
    border-color: var(--ink);
    z-index: 7;
  }

  .dist-seg:hover {
    opacity: 0.88;
  }

  .sub-bldg-summary:hover {
    background-color: var(--surface-hover);
  }
}

/* Tablet */
@media (max-width: 1080px) {
  .ledger-strip {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .table-header-row,
  .bldg-row,
  .skeleton-row {
    grid-template-columns: 80px minmax(185px, 1.6fr) minmax(130px, 1fr) 58px 136px minmax(145px, 1fr);
    gap: 0.5rem;
  }
}

/* Mobile (390x844 iPhone priority) */
@media (max-width: 768px) {
  :root {
    --row-height: 118px;
  }

  .container {
    padding-left: max(0.9rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.9rem, env(safe-area-inset-right, 0px));
  }

  .brand-divider,
  .site-tagline,
  .freshness-caption {
    display: none;
  }

  /* Prevent iOS Safari auto-zoom on input/select focus (>= 16px) */
  .search-input,
  .control-select {
    font-size: 1rem;
  }

  .controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .search-combo {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .map-controls {
    right: max(0.65rem, env(safe-area-inset-right, 0px));
  }

  .map-tooltip {
    bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  }

  .controls-grid .select-field:last-child {
    grid-column: 1 / -1;
  }

  .control-select {
    width: 100%;
    max-width: none;
  }

  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-group {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .filter-divider {
    flex-shrink: 0;
  }

  .ledger-heading {
    font-size: 1.4rem;
  }

  .table-header-row {
    display: none;
  }

  .table-viewport {
    height: clamp(380px, 58dvh, 620px);
  }

  .map-stage {
    height: clamp(380px, 58dvh, 580px);
  }

  .map-legend-hint {
    display: none;
  }

  .bldg-row {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    align-content: center;
    gap: 0.3rem 0.55rem;
    padding: 0.6rem 0.35rem;
  }

  .bldg-row .col-grade {
    grid-column: 1;
    grid-row: 1;
  }

  .bldg-row .cell-address {
    grid-column: 2 / -1;
    grid-row: 1;
  }

  .bldg-row .cell-location {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .bldg-row .cell-rent {
    grid-column: 1 / 3;
    grid-row: 3;
    flex-direction: row;
    align-items: baseline;
    gap: 0.4rem;
  }

  .bldg-row .cell-signals {
    grid-column: 3;
    grid-row: 3;
    justify-content: flex-end;
  }

  .bldg-row .cell-units {
    display: none;
  }

  .skeleton-row {
    grid-template-columns: 76px minmax(0, 1fr);
    padding: 0.55rem 0.5rem;
  }

  .skeleton-row .skel-loc,
  .skeleton-row .skel-num,
  .skeleton-row .skel-rent,
  .skeleton-row .skel-sig {
    display: none;
  }

  .inspector-drawer {
    width: 100vw;
    border-left: none;
  }

  .drawer-header,
  .drawer-actions-bar,
  .drawer-body {
    padding-left: 0.95rem;
    padding-right: 0.95rem;
  }

  .drawer-listings-band {
    margin-left: -0.95rem;
    margin-right: -0.95rem;
    padding-left: 0.95rem;
    padding-right: 0.95rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
