/* Urban Stream — Commercial Scan
   Palette taken from Birmingham's canal-industrial hardware: oxidised copper,
   brick oxide, brass, on weathered zinc. Archivo for signage, Plex Mono for
   every figure — this is an instrument, so the numbers get the engineered face. */

:root {
  --ground: #e4e9e7;
  --panel: #f4f7f6;
  --panel-2: #eceff0;
  --ink: #131f1d;
  --slate: #566b67;
  --faint: #8496a0;
  --verdigris: #1f7a6c;
  --verdigris-soft: rgba(31, 122, 108, 0.12);
  --oxide: #ad4720;
  --brass: #9a7826;
  --line: rgba(19, 31, 29, 0.13);
  --line-firm: rgba(19, 31, 29, 0.26);
  --shadow: 0 1px 2px rgba(19, 31, 29, 0.06), 0 8px 24px rgba(19, 31, 29, 0.06);
  --radius: 3px;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0d1514;
    --panel: #141f1e;
    --panel-2: #1a2625;
    --ink: #e2eae7;
    --slate: #93a5a1;
    --faint: #6d8079;
    --verdigris: #45b9a3;
    --verdigris-soft: rgba(69, 185, 163, 0.14);
    --oxide: #e08050;
    --brass: #cfa956;
    --line: rgba(226, 234, 231, 0.13);
    --line-firm: rgba(226, 234, 231, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

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

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

/* ── Status bar ────────────────────────────────────────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-firm);
}

.bar__id { display: flex; align-items: baseline; gap: 9px; min-width: 0; }

.bar__mark {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--verdigris);
  align-self: center;
  position: relative;
  flex: none;
}
.bar__mark::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--brass);
}

.bar__co {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.bar__div { color: var(--faint); }
.bar__app {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__right { display: flex; align-items: center; gap: 14px; }

.bar__stat {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--slate);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.btn:hover { background: var(--verdigris-soft); border-color: var(--verdigris); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: transparent; border-color: var(--line-firm); }

.btn--go { border-color: var(--verdigris); color: var(--verdigris); font-weight: 600; }
.btn--quiet { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }

/* ── The signature: polar plot of listings around Victoria Square ──────── */

.plot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.plot__title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.plot__sub {
  margin: 4px 0 0;
  color: var(--slate);
  font-size: 13.5px;
  max-width: 46ch;
}

.plot__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.viewtoggle { display: flex; flex: none; border: 1px solid var(--line-firm); border-radius: var(--radius); overflow: hidden; }
.viewtoggle__btn {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--slate);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.viewtoggle__btn + .viewtoggle__btn { border-left: 1px solid var(--line-firm); }
.viewtoggle__btn:hover { background: var(--verdigris-soft); }
.viewtoggle__btn[aria-pressed="true"] { background: var(--verdigris); color: var(--panel); }

.plot__stage { margin-top: 14px; }

#map {
  height: 460px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  z-index: 0; /* keep Leaflet panes under the sticky bar and the drawer */
}
#map[hidden] { display: none; }

/* Distance rings drawn to scale on the real map. */
.leaflet-container .ringcircle {
  fill: var(--verdigris);
  fill-opacity: 0.04;
  stroke: var(--verdigris);
  stroke-opacity: 0.4;
  stroke-width: 1;
  stroke-dasharray: 3 5;
}
.leaflet-container .centremark { fill: var(--oxide); fill-opacity: 1; stroke: var(--panel); stroke-width: 2; }

.leaflet-container { font-family: var(--sans); background: var(--panel-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); border-radius: var(--radius); }
.leaflet-popup-content { margin: 11px 13px; font-size: 12.5px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--faint); }

.pin b { font-family: var(--mono); font-size: 14px; }
.pin em { color: var(--faint); font-style: normal; font-size: 11px; }
.pin div + div { margin-top: 2px; color: var(--slate); }
.pin__actions { display: flex; gap: 8px; margin-top: 9px; }
.pin__actions button, .pin__actions a {
  padding: 3px 9px;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--slate);
  text-decoration: none;
}
.pin__actions button:hover, .pin__actions a:hover { border-color: var(--verdigris); color: var(--verdigris); }

.leaflet-control-attribution { background: var(--panel); color: var(--faint); font-size: 10px; }
.leaflet-control-attribution a { color: var(--slate); }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel-2); color: var(--ink); }

/* Dark tiles are already dark; don't double-darken the controls. */
@media (prefers-color-scheme: dark) {
  .leaflet-control-attribution a { color: var(--slate); }
}

.plot__svgwrap { position: relative; }
.plot__svgwrap[hidden] { display: none; }

#polar { width: 100%; height: auto; max-width: 460px; display: block; margin: 0 auto; overflow: visible; }

.plot__tip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  background: var(--ink);
  color: var(--ground);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.4;
  max-width: 230px;
  box-shadow: var(--shadow);
}
.plot__tip b { font-family: var(--mono); font-weight: 600; }

.key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--slate);
}
.key li { display: flex; align-items: center; gap: 6px; }
.key__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.key__dot--target { background: var(--verdigris); }
.key__dot--other { background: var(--brass); }
.key__dot--land { background: var(--faint); }
.key__dot--approx { background: transparent; border: 1.5px dashed var(--slate); }
.key__note { font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em; }

/* Ring readout beside the plot */

.bands { display: flex; flex-direction: column; gap: 1px; margin-bottom: 20px; }

.band {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-left: 3px solid var(--line-firm);
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.band:hover { background: var(--verdigris-soft); }
.band[aria-pressed="true"] { border-color: var(--verdigris); background: var(--verdigris-soft); }
.band--core { border-left-color: var(--oxide); }
.band--inner { border-left-color: var(--brass); }
.band--outer { border-left-color: var(--verdigris); }
.band--midlands { border-left-color: var(--faint); }

.band__name { font-size: 13px; font-weight: 600; }
.band__range {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.03em;
  font-weight: 400;
}
.band__n { font-family: var(--mono); font-size: 17px; font-weight: 600; }

.figures { margin: 0; display: grid; gap: 12px; }
.figures div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.figures dt { font-size: 12.5px; color: var(--slate); }
.figures dd { margin: 0; font-family: var(--mono); font-size: 14px; font-weight: 600; text-align: right; }
.figures dd a { color: var(--verdigris); text-decoration: none; }
.figures dd a:hover { text-decoration: underline; }

/* ── Filters ───────────────────────────────────────────────────────────── */

.controls {
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}

.controls__row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.controls__row--toggles { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); align-items: center; }
.controls__spacer { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 132px; }
.field--grow { flex: 1 1 200px; }

.field__label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

.field select,
.field input {
  padding: 7px 9px;
  background: var(--ground);
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  font-size: 13.5px;
  width: 100%;
}

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; color: var(--slate); }
.check input { accent-color: var(--verdigris); width: 15px; height: 15px; }

/* ── Results ───────────────────────────────────────────────────────────── */

.results__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.results__count { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.results__hint { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }

.row {
  display: grid;
  grid-template-columns: 46px 92px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 11px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.row:hover { border-color: var(--verdigris); }
.row.is-flash { animation: flash 1.4s ease; }
.row--gone { opacity: 0.5; }

@keyframes flash {
  0%, 100% { background: var(--panel); }
  25% { background: var(--verdigris-soft); }
}

.row__score {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  padding: 5px 0;
  border-radius: var(--radius);
  background: var(--panel-2);
  border-left: 3px solid var(--faint);
}
.row__score--high { border-left-color: var(--oxide); color: var(--oxide); }
.row__score--mid { border-left-color: var(--brass); color: var(--brass); }

.row__thumb {
  width: 92px;
  height: 62px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--panel-2);
  display: block;
}
.row__thumb--none {
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.row__body { min-width: 0; }

.row__top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.row__price { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.row__price--poa { color: var(--faint); font-size: 13px; }
.row__qual { font-size: 11.5px; color: var(--faint); }
.row__est {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate);
  border-bottom: 1px dotted var(--line-firm);
  cursor: help;
}

.row__title {
  margin: 2px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__meta {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--slate);
  letter-spacing: 0.02em;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.row__meta em { font-style: normal; color: var(--faint); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid var(--line-firm);
}
.tag--new { border-color: var(--oxide); color: var(--oxide); }
.tag--target { border-color: var(--verdigris); color: var(--verdigris); }
.tag--approx { border-color: var(--line-firm); color: var(--faint); }
.tag--shortlist { border-color: var(--brass); color: var(--brass); }
.tag--viewing { border-color: var(--verdigris); color: var(--verdigris); background: var(--verdigris-soft); }
.tag--rejected { border-color: var(--line-firm); color: var(--faint); }
.tag--over { border-color: var(--oxide); color: var(--oxide); }
.tag--auction { border-color: var(--brass); color: var(--brass); }
.tag--dupe { border-color: var(--line-firm); color: var(--faint); cursor: help; }

.row__actions { display: flex; gap: 5px; }

.chip {
  padding: 4px 8px;
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  color: var(--slate);
  transition: border-color 0.14s ease, color 0.14s ease;
}
.chip:hover { border-color: var(--verdigris); color: var(--verdigris); }
.chip[aria-pressed="true"] { border-color: var(--verdigris); color: var(--verdigris); background: var(--verdigris-soft); }

.empty {
  padding: 40px 20px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--line-firm);
  border-radius: var(--radius);
  color: var(--slate);
}
.empty strong { display: block; font-size: 15px; color: var(--ink); margin-bottom: 5px; }

/* ── Detail drawer ─────────────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(9, 16, 15, 0.5);
  z-index: 50;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line-firm);
  z-index: 60;
  overflow-y: auto;
  box-shadow: -12px 0 40px rgba(9, 16, 15, 0.18);
  animation: slide 0.2s ease;
}

@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

.drawer__inner { padding: 22px 24px 60px; }

.drawer__close {
  position: absolute;
  top: 14px; right: 16px;
  border: 1px solid var(--line-firm);
  background: var(--panel);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 12px;
}

.drawer h3 { margin: 0 22px 3px 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.drawer__addr { margin: 0 0 16px; color: var(--slate); font-size: 13px; }
.drawer__hero { width: 100%; border-radius: var(--radius); margin-bottom: 16px; display: block; }

.drawer__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.drawer__cell { background: var(--panel); padding: 10px 12px; }
.drawer__cell dt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.drawer__cell dd { margin: 3px 0 0; font-family: var(--mono); font-size: 14px; font-weight: 600; }

.drawer h4 {
  margin: 20px 0 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

.drawer ul { margin: 0; padding-left: 18px; font-size: 13.5px; }
.drawer li { margin-bottom: 4px; }
.drawer p { font-size: 13.5px; line-height: 1.6; color: var(--slate); }

/* Score breakdown bars — show why a listing ranks where it does. */
.breakdown { display: grid; gap: 7px; }
.breakdown__item { display: grid; grid-template-columns: 104px 1fr 38px; gap: 9px; align-items: center; font-size: 12px; }
.breakdown__track { display: block; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
/* Must be block — width and height are ignored on an inline span, which leaves
   every bar looking empty regardless of the score. */
.breakdown__fill { display: block; height: 100%; background: var(--verdigris); }
.breakdown__val { font-family: var(--mono); font-size: 11.5px; text-align: right; color: var(--slate); }

.notes {
  width: 100%;
  min-height: 90px;
  padding: 9px 11px;
  background: var(--ground);
  border: 1px solid var(--line-firm);
  border-radius: var(--radius);
  font-size: 13.5px;
  resize: vertical;
}

.drawer__actions { display: flex; gap: 7px; flex-wrap: wrap; margin: 12px 0 4px; }
.drawer__save { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.drawer__saved { font-family: var(--mono); font-size: 11px; color: var(--verdigris); }

.history { font-family: var(--mono); font-size: 12px; }
.history div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }

/* ── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .plot { grid-template-columns: 1fr; }
  .plot__read { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
  .bands { margin-bottom: 0; }
}

@media (max-width: 640px) {
  main { padding: 14px 12px 60px; }
  .plot { padding: 16px; }
  #map { height: 340px; }
  .plot__read { grid-template-columns: 1fr; }
  .plot__title { font-size: 21px; }
  .row { grid-template-columns: 42px minmax(0, 1fr); gap: 10px; }
  .row__thumb { display: none; }
  .row__actions { grid-column: 1 / -1; }
  .bar__app, .bar__div { display: none; }
  .bar__co { white-space: nowrap; }
  .bar { padding: 0 12px; gap: 10px; }
  .field { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
