:root {
  color-scheme: light;
  --ink: #17231d;
  --muted: #68736d;
  --paper: #f4f0e7;
  --panel: #fffdf8;
  --line: #d9d4c8;
  --green: #1f5d48;
  --orange: #d16f32;
  --blue: #2c6d91;
  --grey: #7c817d;
  --red: #9f4a45;
  --shadow: 0 18px 50px rgba(31, 44, 37, 0.12);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

.masthead {
  align-items: center;
  display: flex;
  gap: 2rem;
  justify-content: space-between;
  padding: 1.25rem clamp(1rem, 4vw, 4rem) 1rem;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}

.dek { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

.freshness {
  align-items: center;
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  flex: 0 0 auto;
  font-size: 0.78rem;
  gap: 0.55rem;
  padding: 0.62rem 0.85rem;
}

.pulse { background: var(--green); border-radius: 50%; height: 0.55rem; width: 0.55rem; }

.stats {
  border-block: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 clamp(1rem, 4vw, 4rem) 1.25rem;
}

.stats div { padding: 0.85rem 1rem; }
.stats div + div { border-left: 1px solid var(--line); }
.stats strong { display: block; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; }
.stats span { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }

.workspace {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.45fr) minmax(23rem, 0.75fr);
  height: calc(100vh - 15.6rem);
  min-height: 37rem;
  padding: 0 clamp(1rem, 4vw, 4rem);
}

.map-panel, .list-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
}

.map-panel { display: grid; grid-template-rows: 1fr auto; }
.map-frame { min-height: 0; position: relative; }
#map { height: 100%; min-height: 28rem; }

.map-toolbar {
  align-items: center;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  display: flex;
  font-size: 0.72rem;
  gap: 0.65rem;
  left: 0.75rem;
  padding: 0.35rem;
  position: absolute;
  top: 0.75rem;
  z-index: 500;
}
.map-toolbar button {
  background: var(--ink);
  border: 0;
  border-radius: 0.35rem;
  color: white;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.4rem 0.55rem;
}
.map-toolbar span { color: var(--muted); padding-right: 0.25rem; }

.map-note {
  color: var(--muted);
  display: flex;
  font-size: 0.7rem;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
}

.list-panel { display: flex; flex-direction: column; }
.controls { border-bottom: 1px solid var(--line); padding: 1rem; }
.search input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
  outline: none;
  padding: 0.72rem 0.8rem;
  width: 100%;
}
.search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31, 93, 72, 0.12); }

.filter-group { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.filter {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.38rem 0.62rem;
}
.filter.active { background: var(--ink); border-color: var(--ink); color: white; }

.filter-row { align-items: end; display: grid; gap: 0.6rem; grid-template-columns: 1fr 1fr auto; margin-top: 0.75rem; }
.filter-row label { color: var(--muted); font-size: 0.7rem; }
.filter-row select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  color: var(--ink);
  display: block;
  margin-top: 0.25rem;
  padding: 0.48rem;
  width: 100%;
}
.filter-row .check { align-items: center; display: flex; gap: 0.35rem; padding-bottom: 0.55rem; white-space: nowrap; }

.results-head { color: var(--muted); display: flex; font-size: 0.72rem; justify-content: space-between; padding: 0.75rem 1rem 0.5rem; }
.results-head p { margin: 0; }
.listing-list { overflow: auto; padding: 0 0.75rem 1rem; }

.listing-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 0.28rem solid var(--status-colour);
  border-radius: 0.8rem;
  cursor: pointer;
  margin-top: 0.55rem;
  padding: 0.82rem;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.listing-card:hover { box-shadow: 0 8px 24px rgba(31, 44, 37, 0.12); transform: translateY(-1px); }
.card-top { align-items: start; display: flex; gap: 0.7rem; justify-content: space-between; }
.listing-card h2 { font-family: Georgia, serif; font-size: 1.05rem; font-weight: 500; line-height: 1.2; margin: 0; }
.price { font-size: 0.88rem; font-weight: 750; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.55rem 0; }
.chip { background: #f1eee7; border-radius: 0.35rem; color: #4f5c55; font-size: 0.67rem; padding: 0.25rem 0.38rem; }
.chip.tier-a { background: #dceade; color: #22513e; }
.chip.tier-b { background: #e2ebf0; color: #275b78; }
.chip.tier-c { background: #f0e5dc; color: #815237; }
.assessment { color: #4f5c55; font-size: 0.76rem; line-height: 1.45; margin: 0.5rem 0; }
.card-bottom { align-items: center; display: flex; justify-content: space-between; }
.agent { color: var(--muted); font-size: 0.68rem; }
.source-link { color: var(--green); font-size: 0.72rem; font-weight: 700; text-decoration: none; }

.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }

footer { color: var(--muted); display: flex; font-size: 0.7rem; justify-content: space-between; padding: 1.1rem clamp(1rem, 4vw, 4rem) 1.5rem; }
footer p { margin: 0; }

.leaflet-popup-content-wrapper { border-radius: 0.8rem; box-shadow: var(--shadow); }
.popup-title { font-family: Georgia, serif; font-size: 1rem; margin-bottom: 0.35rem; }
.popup-meta { color: var(--muted); font-size: 0.75rem; }

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

@media (max-width: 900px) {
  .masthead { align-items: start; flex-direction: column; gap: 1rem; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .map-panel { height: 34rem; max-height: 52vh; }
  #map { min-height: 0; }
  .list-panel { max-height: 70vh; }
}

@media (max-width: 560px) {
  .masthead { padding-top: 1rem; }
  .dek { font-size: 0.9rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stats div:nth-child(4) { border-top: 1px solid var(--line); }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .filter-row .check { grid-column: 1 / -1; }
  .map-panel { height: 27rem; }
  .map-note, footer { align-items: start; flex-direction: column; gap: 0.3rem; }
}
