*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --header-bg: #1e293b;
  --header-text: #f1f5f9;
  --accent: #3b82f6;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius: 8px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Header */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
header h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }
nav { display: flex; gap: .5rem; }
nav button {
  background: none;
  border: 2px solid transparent;
  color: #94a3b8;
  padding: .35rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
}
nav button:hover { color: var(--header-text); border-color: #475569; }
nav button.active { color: #fff; border-color: var(--accent); background: rgba(59,130,246,.15); }

/* Filter bar */
#filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  position: sticky;
  top: 56px;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}
.filter-group { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); }
.filter-group label { font-weight: 600; white-space: nowrap; }

/* Status pills */
.pill-row { display: flex; gap: .35rem; flex-wrap: wrap; }
.status-pill {
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: all .12s;
  user-select: none;
}
.status-pill.on { border-color: var(--accent); background: rgba(59,130,246,.1); color: var(--accent); }

/* Radio row */
.radio-row { display: flex; gap: .5rem; }
.radio-row label { display: flex; align-items: center; gap: .25rem; cursor: pointer; font-size: .82rem; }

/* Score slider */
#score-slider { accent-color: var(--accent); width: 100px; cursor: pointer; }
#score-val { font-weight: 700; color: var(--text); }

/* Search */
#search-box {
  padding: .35rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .82rem;
  width: 200px;
  outline: none;
  transition: border-color .15s;
}
#search-box:focus { border-color: var(--accent); }

/* Total badge */
#total-badge { margin-left: auto; font-size: .82rem; color: var(--muted); font-weight: 600; }

/* Main content */
main { padding: 1.25rem 1.5rem; }

/* Cards grid */
#cards-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
#map-view { display: none; height: calc(100vh - 140px); border-radius: var(--radius); overflow: hidden; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.12); }

.card-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
}
.card-thumb svg { width: 48px; height: 48px; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.card-body { padding: .85rem 1rem 1rem; }
.card-address { font-weight: 700; font-size: .95rem; margin-bottom: .15rem; }
.card-city { font-size: .82rem; color: var(--muted); margin-bottom: .65rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

.score-badge {
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
}
.score-green { background: var(--green); }
.score-yellow { background: var(--yellow); }
.score-red { background: var(--red); }
.score-na { background: #94a3b8; }

.chip {
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--border);
}
.chip-status-active { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.chip-status-flagged { background: #fef9c3; color: #92400e; border-color: #fde68a; }
.chip-status-dismissed { background: #f1f5f9; color: var(--muted); }
.chip-status-showings { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.chip-status-deal { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }

.chip-buildout-high { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.chip-buildout-medium { background: #fefce8; color: #854d0e; border-color: #fde68a; }
.chip-buildout-low { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.chip-buildout-none { background: #f1f5f9; color: var(--muted); }
.chip-buildout-unknown { background: #f1f5f9; color: var(--muted); }

.card-price { font-size: .82rem; color: var(--text); margin-top: .5rem; font-weight: 500; }

/* Empty state */
#empty-state {
  display: none;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
#empty-state p { margin-bottom: 1rem; font-size: 1rem; }
#empty-state button {
  padding: .45rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
}

/* Modal */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#modal-overlay.open { display: flex; }

#modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

#modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
#modal-title { font-size: 1.1rem; font-weight: 700; }
#modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--muted);
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

#modal-body { padding: 1.25rem 1.5rem; }

.gallery { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.gallery img {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .12s;
}
.gallery img:hover, .gallery img.active { border-color: var(--accent); }
.gallery-main {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 6px;
  background: #f1f5f9;
  margin-bottom: .75rem;
  display: none;
}
.gallery-main.show { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: .875rem;
}
.detail-item label { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .1rem; }
.detail-item span { color: var(--text); }

.section-heading {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 1.25rem 0 .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}

.reasons-list { list-style: disc; padding-left: 1.25rem; font-size: .85rem; line-height: 1.65; color: var(--text); }
.signals-list { display: flex; flex-wrap: wrap; gap: .35rem; }

.prose { font-size: .875rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; }

a.source-link {
  display: inline-block;
  margin-top: .75rem;
  color: var(--accent);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 600;
}
a.source-link:hover { text-decoration: underline; }

/* Leaflet map marker overrides */
.map-popup-content { font-size: .82rem; line-height: 1.5; }
.map-popup-content strong { display: block; font-weight: 700; margin-bottom: .15rem; }

/* Loading */
#loading { text-align: center; padding: 3rem; color: var(--muted); font-size: .9rem; }
