*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: ui-sans-serif, system-ui, sans-serif; background: #0f1419; color: #e8eef4; }
a { color: #8cb4ff; }
.shell { min-height: 100%; height: 100%; display: flex; flex-direction: column; }
.top { display: flex; gap: 1.2rem; padding: 0.8rem 1.2rem; background: #1a222c; align-items: center; }
.top a { color: #b7c7da; text-decoration: none; padding: 0.15rem 0; }
.top a.active, .top a[aria-current="page"] { color: #fff; box-shadow: inset 0 -2px 0 #8cb4ff; }
.top .legal { margin-left: auto; font-size: 0.8rem; opacity: 0.7; }
main { padding: 1.2rem; flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; }
.card { background: #1a222c; padding: 1rem; border-radius: 8px; }
.card h3 { margin: 0 0 0.4rem; font-size: 0.85rem; opacity: 0.7; font-weight: 500; }
.card p { margin: 0; font-size: 1.4rem; }
.banner { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.banner.err { background: #5a1d1d; }
.banner.warn { background: #5a4a1d; }
form, .stack { display: flex; flex-direction: column; gap: 0.6rem; max-width: 40rem; }
label { font-size: 0.85rem; }
.hint { font-size: 0.8rem; opacity: 0.7; margin: 0; max-width: 40rem; }
input, textarea, button, select { font: inherit; padding: 0.45rem 0.6rem; border-radius: 6px; border: 1px solid #334; background: #0f1419; color: inherit; }
button { background: #2b4c7e; cursor: pointer; border: 0; }
button.ghost { background: #333; }
button:disabled, button[disabled] { opacity: 0.55; cursor: progress; }
.banner a { color: #fff; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; margin-bottom: 0.6rem; background: #1a222c; padding: 0.55rem 0.75rem; border-radius: 8px; }
.toolbar .stats { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.85rem; margin-right: auto; }
.toolbar .stats b { font-weight: 600; }
.toolbar label { display: flex; align-items: center; gap: 0.35rem; margin: 0; }
.toolbar input[type=number] { width: 3.5rem; }
.toolbar input.jsess { min-width: 12rem; flex: 1; }
.toolbar .hint { max-width: none; }
.map-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.map-page h1 { margin: 0; font-size: 1.2rem; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem 1rem; flex-wrap: wrap; margin-bottom: 0.7rem; }
.map-wrap { position: relative; height: 100%; min-height: 16rem; }
.map-legend {
  position: absolute;
  left: 0.55rem;
  bottom: 1.5rem;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.7rem;
  max-width: calc(100% - 1.2rem);
  padding: 0.35rem 0.6rem;
  background: rgba(15, 20, 25, 0.86);
  border-radius: 6px;
  font-size: 0.75rem;
  pointer-events: none;
}
.map-legend .dot, .map-legend .tile {
  display: inline-block;
  margin-right: 0.28rem;
  vertical-align: -1px;
}
.map-legend .dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid #111;
}
.map-legend .dot.uni { background: #ffda6a; }
.map-legend .dot.plex { background: #75b798; }
.map-legend .dot.condo { background: #6ea8fe; }
.map-legend .dot.other { background: #adb5bd; }
.map-legend .dot.for-sale { background: #4fc3f7; }
.map-legend .dot.rent { background: #c792ea; }
.map-legend .dot.past { background: #8a6d3b; }
.map-legend .tile {
  width: 0.85rem;
  height: 0.55rem;
  background: rgba(255, 176, 32, 0.35);
  border: 2px solid #ffda6a;
  box-sizing: border-box;
}
.map-legend .note { opacity: 0.7; }
#map { width: 100%; height: 100%; min-height: 16rem; border-radius: 8px; }
.split { flex: 1; min-height: 24rem; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(20rem, 0.9fr); gap: 0.6rem; }
.tx-pane { display: flex; flex-direction: column; min-height: 0; background: #1a222c; border-radius: 8px; overflow: hidden; }
.tx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; padding: 0.65rem 0.8rem; border-bottom: 1px solid #2a3340; }
.tx-head h2 { margin: 0; font-size: 0.95rem; }
.tx-head span { font-size: 0.8rem; opacity: 0.7; }
.tx-detail { max-height: min(42vh, 28rem); overflow: auto; padding: 0.65rem 0.8rem; border-bottom: 1px solid #2a3340; background: #16202b; font-size: 0.85rem; }
.tx-detail:focus { outline: 2px solid #8cb4ff; outline-offset: -2px; }
.tx-detail .close { position: sticky; top: 0; float: right; font-size: 0.8rem; background: #16202b; padding-left: 0.4rem; }
.tx-detail strong { display: block; margin-bottom: 0.15rem; }
.tx-facts { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; margin-top: 0.4rem; opacity: 0.9; }
.tx-facts em { font-style: normal; opacity: 0.6; margin-right: 0.25rem; }
.tx-list { flex: 1; min-height: 20rem; overflow: auto; }
.tx-list .hint { padding: 0.8rem; }
.tx-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 0.55rem; align-items: center; padding: 0.45rem 0.7rem; min-height: 58px; border-bottom: 1px solid #2a3340; cursor: pointer; color: inherit; text-decoration: none; }
.tx-row:hover { background: #22303d; }
.tx-row.on { background: #2b4c7e; }
.tx-swatch { width: 8px; height: 2.2rem; border-radius: 4px; background: #adb5bd; }
.tx-swatch.condo { background: #6ea8fe; }
.tx-swatch.plex { background: #75b798; }
.tx-swatch.uni { background: #ffda6a; }
.tx-title { font-size: 0.9rem; }
.tx-sub { font-size: 0.75rem; opacity: 0.7; }
.tx-amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 0.9rem; }
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; grid-template-rows: minmax(16rem, 42%) minmax(0, 1fr); }
}
.filters { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.6rem; align-items: end; }
.filters.facts { gap: 0.45rem 0.7rem; max-height: 28vh; overflow: auto; padding-bottom: 0.3rem; flex-shrink: 0; }
.filters.facts label { display: flex; flex-direction: column; gap: 0.15rem; }
.filters.facts input, .filters.facts select { min-width: 7.5rem; }
.filters.facts .wide { min-width: 16rem; flex: 1; }
.filters.facts .wide input { min-width: 100%; }
.filters.nested { max-height: none; overflow: visible; margin-top: 0.5rem; }
.filters fieldset.types { border: 1px solid #334; border-radius: 6px; padding: 0.3rem 0.6rem; display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }
.filters fieldset.types label { flex-direction: row; align-items: center; gap: 0.3rem; }
.filters details { width: 100%; }
.filters summary { cursor: pointer; opacity: 0.8; }
.place { position: relative; }
.suggest { position: absolute; z-index: 20; left: 0; right: 0; margin: 0; padding: 0.2rem; list-style: none; background: #1a222c; border: 1px solid #334; border-radius: 6px; max-height: 12rem; overflow: auto; }
.suggest button { width: 100%; text-align: left; background: transparent; }
.suggest button:hover { background: #2b4c7e; }
.maplibregl-popup-content { background: #1a222c; color: #e8eef4; border-radius: 8px; max-height: 22rem; overflow: auto; min-width: 16rem; font-size: 0.85rem; }
.maplibregl-popup-content .k { opacity: 0.65; display: inline-block; min-width: 5.5rem; }
.maplibregl-popup-content .hist { margin-top: 0.45rem; padding-top: 0.4rem; border-top: 1px solid #334; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: #1a222c; }
.tx-hist { margin-top: 0.5rem; font-size: 0.8rem; }
.tx-hist em { display: block; font-style: normal; opacity: 0.6; margin-bottom: 0.2rem; }
.tx-thumbs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.45rem; }
.dlq { background: #1a222c; border-radius: 8px; margin-bottom: 0.8rem; overflow: hidden; }
.dlq .feed-head { gap: 0.8rem; }
.dlq .feed-head h2 { margin-right: auto; }
.dlq-list { overflow: auto; max-height: 22rem; }
.dlq-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dlq-table th, .dlq-table td { text-align: left; padding: 0.4rem 0.8rem; border-bottom: 1px solid #2a3340; vertical-align: top; }
.dlq-table th { opacity: 0.6; font-weight: 500; }
.dlq-table code { font-size: 0.8rem; }
.feeds { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.6rem; flex-shrink: 0; }
@media (max-width: 900px) { .feeds { grid-template-columns: 1fr; } }
.feed { background: #1a222c; border-radius: 8px; display: flex; flex-direction: column; min-height: 0; }
.feed-head { display: flex; align-items: baseline; gap: 0.8rem; padding: 0.55rem 0.8rem; border-bottom: 1px solid #2a3340; }
.feed-head h2 { margin: 0 auto 0 0; font-size: 0.95rem; }
.feed-head span { font-size: 0.8rem; opacity: 0.7; white-space: nowrap; }
.feed-list { overflow: auto; min-height: 0; }
.feed .tx-row { min-height: 48px; }

/* ---- unified browser (/browse) ---------------------------------------- */
/* Everything is scoped under .browse: .card, .filters and .row already mean
   something else elsewhere in this stylesheet. */
.browse {
  flex: 1;
  min-height: 0;
  margin: -1.2rem;
  display: grid;
  grid-template-columns: minmax(20rem, 26rem) minmax(0, 1fr);
}
.browse .map { height: 100%; min-height: 20rem; }
.browse .panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #141b23;
  border-right: 1px solid #263140;
}

.browse .filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.8rem;
  border-bottom: 1px solid #263140;
  margin: 0;
  align-items: stretch;
}
.browse .filters .row { display: flex; gap: 0.5rem; }
.browse .filters .row > * { flex: 1; min-width: 0; }
.browse .filters input, .browse .filters select { width: 100%; }
.browse .filters .go { flex: 0 0 auto; padding-inline: 1rem; }
.browse .toggles { display: flex; gap: 1rem; font-size: 0.85rem; opacity: 0.9; }
.browse .toggles label { display: flex; align-items: center; gap: 0.35rem; }
.browse .toggles input { width: auto; }

.browse .counts {
  display: flex;
  gap: 0.9rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  border-bottom: 1px solid #263140;
  background: #11181f;
}
.browse .counts .warn { color: #ffda6a; margin-left: auto; }

.browse .results { flex: 1; min-height: 0; overflow: auto; }

.browse .card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #222c38;
  border-radius: 0;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  color: inherit;
}
.browse .card:hover { background: #1c2733; }
.browse .card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.browse .card-price { font-size: 1rem; font-variant-numeric: tabular-nums; }
.browse .card-type { font-size: 0.75rem; opacity: 0.6; text-transform: capitalize; }
.browse .card-addr { font-size: 0.9rem; margin-top: 0.15rem; }
.browse .card-sub { font-size: 0.75rem; opacity: 0.65; }
.browse .card-facts { display: flex; gap: 0.6rem; margin-top: 0.3rem; font-size: 0.75rem; opacity: 0.75; }

.browse .back {
  width: 100%;
  text-align: left;
  background: #1c2733;
  border-radius: 0;
  border-bottom: 1px solid #263140;
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
}
.browse .detail { padding: 0.9rem 0.8rem 2rem; }
.browse .detail h2 { margin: 0; font-size: 1.05rem; }
.browse .detail .sub { font-size: 0.8rem; opacity: 0.65; margin-top: 0.1rem; }
.browse .detail .price {
  font-size: 1.5rem;
  margin: 0.6rem 0 0.8rem;
  font-variant-numeric: tabular-nums;
}
.browse .detail dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.8rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
.browse .detail dt { opacity: 0.6; }
.browse .detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.browse .history { border-top: 1px solid #263140; padding-top: 0.8rem; }
.browse .history h3 { margin: 0 0 0.5rem; font-size: 0.85rem; opacity: 0.8; font-weight: 600; }
.browse a.sale {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.2rem 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid #1d2630;
  font-size: 0.85rem;
  align-items: baseline;
  color: inherit;
  text-decoration: none;
}
.browse a.sale:hover { background: #1c2733; }
.browse .sale .when { font-variant-numeric: tabular-nums; opacity: 0.75; }
.browse .sale .amt { font-variant-numeric: tabular-nums; }
.browse .sale .meta { grid-column: 1 / -1; font-size: 0.72rem; opacity: 0.55; }
.browse .sale .delta { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.browse .sale .delta.up { color: #75b798; }
.browse .sale .delta.down { color: #ff8f8f; }

.browse .muted { opacity: 0.6; font-size: 0.85rem; padding: 0.8rem; margin: 0; }
.browse .detail .muted { padding: 0.5rem 0 0; }
.browse .muted.small { font-size: 0.75rem; }
.browse .src { display: inline-block; margin-top: 1rem; font-size: 0.85rem; }

@media (max-width: 900px) {
  .browse { grid-template-columns: 1fr; grid-template-rows: minmax(14rem, 40%) minmax(0, 1fr); }
  .browse .panel { border-right: 0; border-bottom: 1px solid #263140; order: 2; }
  .browse .map-wrap { order: 1; }
}

/* Photo frame. The box is sized before the bytes arrive, so the skeleton
   does not jump when the image fades in. */
button.photo {
  display: block;
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: zoom-in;
  background: #141c26;
}
button.photo:disabled { opacity: 1; cursor: zoom-in; }
.photo {
  display: block;
  position: relative;
  overflow: hidden;
  background: #141c26;
}
body.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 12, 0.94);
}
.lightbox:focus { outline: none; }
.lightbox-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  max-width: min(72rem, calc(100vw - 8rem));
  max-height: calc(100vh - 3rem);
}
.lightbox-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 6.5rem);
  object-fit: contain;
  border-radius: 4px;
  background: #0d1218;
}
.lightbox-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1rem;
  max-width: 46rem;
  font-size: 0.8rem;
  text-align: center;
  opacity: 0.85;
}
.lightbox-count { opacity: 0.7; }
.lightbox-close { position: absolute; top: 0.8rem; right: 0.8rem; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.6rem;
  height: 3.4rem;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
}
.lightbox-nav.prev { left: 0.6rem; }
.lightbox-nav.next { right: 0.6rem; }
.photo.pending {
  background: linear-gradient(90deg, #1a2430 25%, #2c3b4d 37%, #1a2430 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease infinite;
}
.photo.failed { animation: none; background: #1a2430; }
.photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.photo.ready img { opacity: 1; }
.photo.thumb { width: 4.5rem; height: 4.5rem; border-radius: 4px; flex: none; }

/* ---- view tabs, loading, manage --------------------------------------- */
.views { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.views a {
  text-decoration: none;
  color: #c5d4e8;
  background: #1a222c;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.views a[aria-current="page"] { background: #2b4c7e; color: #fff; }
.views button { border-radius: 999px; }

.manage-form {
  background: #1a222c;
  border-radius: 8px;
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 42rem;
}
.manage-form h2 { margin: 0.4rem 0 0; font-size: 1rem; }
.manage-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.manage-form input[type=number] { width: 5rem; }
.manage-form input.jsess { width: 100%; }

.feeds.grow { flex: 1; min-height: 0; margin-top: 0; }
.feeds.grow .feed { min-height: 14rem; }
.feeds.grow .feed-list { flex: 1; overflow: auto; }

.busy-bar {
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, #8cb4ff, transparent);
  background-size: 40% 100%;
  animation: busy 1s linear infinite;
}
@keyframes busy {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}
.map-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 25, 0.55);
  border-radius: 8px;
  z-index: 2;
  pointer-events: none;
}
.skel {
  display: block;
  height: 0.75rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #243140 25%, #314155 37%, #243140 63%);
  background-size: 400% 100%;
  animation: skel 1.4s ease infinite;
}
.skel.w40 { width: 40%; }
.skel.w60 { width: 60%; }
.skel.w70 { width: 70%; }
.skel-stat { width: 5.5rem; height: 0.9rem; display: inline-block; }
.skel-row { padding: 0.7rem 0.8rem; border-bottom: 1px solid #2a3340; }
.skel-row .skel + .skel { margin-top: 0.4rem; }
.skel-detail { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; }
@keyframes skel {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.browse .map-wrap { height: 100%; min-height: 20rem; }
.browse .map-wrap .map { height: 100%; min-height: 20rem; }
.browse a.card { color: inherit; text-decoration: none; }
.browse a.card.on { background: #1c2733; box-shadow: inset 3px 0 #4fc3f7; }
.browse a.back { display: block; color: inherit; text-decoration: none; }
.inline-retry { margin-left: 0.4rem; }
