:root {
  --bg: #f4f2ec;
  --fg: #1c1c1c;
  --muted: #5c5c5c;
  --line: #d8d4c8;
  --row: #fff;
  --row2: #eceae3;
  --hi: #fff6d8;
  --gold: #8a6d1f;
  --bank: #1f5f8a;
  --hoa: #8a4b1f;
  --ok: #2a6b2a;
  --warn: #8a6d1f;
  --bad: #9a3030;
  --sold: #2a6b2a;
  --hover: #efe8d4;
}
input, select { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 ui-sans-serif, system-ui, sans-serif; overflow-x: hidden; max-width: 100%; }
html:not(.map-page), body:not(.map-page) { touch-action: manipulation; }
header { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 10px 14px 6px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: 0.02em; }
h2 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.meta, .count { color: var(--muted); font-size: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line); }
input, select { background: var(--row); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; font: inherit; }
#q { min-width: 0; max-width: 100%; flex: 1; }
.watch-filter { color: var(--muted); display: flex; gap: 6px; align-items: center; }
.changes { padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--row2); }
.changes ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.changes li { color: var(--muted); font-size: 14px; }
.changes li.watched { color: var(--gold); }
.changes .addr { color: var(--fg); }
.empty { padding: 28px 14px; color: var(--muted); }
table { width: 100%; max-width: 100%; border-collapse: collapse; }
#grid { width: 100%; max-width: 100%; table-layout: fixed; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.star, td.star { width: 28px; max-width: 28px; padding-right: 0; white-space: nowrap; overflow: hidden; }
tbody tr.sale { cursor: pointer; }
tbody tr.sale:nth-child(4n+1) { background: var(--row); }
tbody tr.sale:hover { background: var(--hover); }
tbody tr.sale.watched td:first-child + td { color: var(--gold); }
button.star { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; }
button.star.on { color: var(--gold); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 12px; font-weight: 650; line-height: 1.3; }
.badge.Bank { color: var(--bank); background: #e4eef6; }
.badge.HOA { color: var(--hoa); background: #f6ebe4; }
.badge.status-new { color: #184e73; background: #d7e8f5; }
.badge.status-post { color: #6d5514; background: #f4e6b3; }
.badge.status-cancel { color: #7a2020; background: #f4d6d6; }
.badge.status-sold { color: #1f5a1f; background: #d7edd7; }
.detail { background: var(--row2); }
.detail td { white-space: normal; padding: 10px 14px 14px 36px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 3px 10px; max-width: none; margin-bottom: 10px; }
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px 32px;
  align-items: start;
}
.detail-sec {
  min-width: 0;
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px 6px;
}
.detail-sec h2 {
  margin: 0 0 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.detail-wide { grid-column: 1 / -1; }
.kv dt, .kv dd { padding: 4px 0; border-bottom: 1px solid #e6e2d6; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
.drawer .detail-grid { grid-template-columns: 1fr; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.timeline { margin: 0; padding-left: 16px; }
.timeline li { margin: 0 0 4px; color: var(--muted); }
.timeline li strong { color: var(--fg); font-weight: 600; }

table.recorder { width: auto; max-width: 100%; margin: 0 0 10px; table-layout: auto; }
table.recorder th, table.recorder td {
  padding: 4px 8px; white-space: normal; vertical-align: top;
  position: static; background: transparent; text-transform: none;
  letter-spacing: 0; font-size: 14px; font-weight: 400;
}
table.recorder th {
  color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.recorder-empty, .recorder-nln { color: var(--muted); margin: 0 0 8px; }

a { color: var(--gold); }

th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--fg); }
th[data-sort].asc::after { content: " \25b2"; font-size: 9px; }
th[data-sort].desc::after { content: " \25bc"; font-size: 9px; }
.flag-true { color: var(--ok); }
.flag-false { color: var(--bad); }

.nav { display: flex; align-items: center; gap: 12px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.view-toggle button { background: var(--row); color: var(--muted); border: 0; padding: 3px 10px; cursor: pointer; font: inherit; }
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button.on, .view-toggle button[aria-pressed="true"] { background: var(--hover); color: var(--fg); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; padding: 12px 14px; }
.card {
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(28,28,28,.04);
  border-left-width: 4px;
}
.card:hover { background: var(--hover); }
.card.watched h3 { color: var(--gold); }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px #e6d7a2; }
.card-status-new { border-left-color: #3a7ca5; }
.card-status-post { border-left-color: #c4a03a; }
.card-status-cancel { border-left-color: #c45c5c; }
.card-status-sold { border-left-color: #3d9a3d; }
.card-top { display: flex; align-items: flex-start; gap: 6px; min-width: 0; padding: 9px 10px 6px; }
.card h3 { margin: 0; flex: 1; font-size: 15px; font-weight: 650; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.card-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px 8px; }
.card-status .days { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.addr-line { display: block; padding: 0 10px 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }
.card-band {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #f8f6f0;
}
.card-bid { font-weight: 700; font-variant-numeric: tabular-nums; }
.card-when { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.card-specs, .card-money {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
}
.card-money { padding-bottom: 9px; }
.card-facts { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.card-detail { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.card-detail .kv { max-width: none; }

@media (max-width: 800px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 8px; overflow-x: hidden; }
  .card { min-width: 0; }
  .card-facts { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .card-top .days { font-size: 12px; }
  .addr-line { font-size: 12px; }
  .card-detail .kv { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
}

#bidmin, #bidmax { width: 100px; }
.export { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.export span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.export button { background: var(--row); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; font: inherit; cursor: pointer; }
.export button:hover { background: var(--hover); }

html.map-page, body.map-page { height: 100%; }
body.map-page { display: flex; flex-direction: column; overflow: hidden; }
body.map-page .map-body { flex: 1 1 auto; min-height: 0; display: flex; width: 100%; position: relative; }
body.map-page #map { flex: 1 1 auto; width: 100%; min-height: 0; background: var(--row2); }
.filters.slim { padding: 6px 14px; }
.results { flex: 0 0 280px; width: 280px; overflow: auto; border-right: 1px solid var(--line); background: var(--row2); }
.result { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--fg); padding: 7px 10px; cursor: pointer; font: inherit; }
.result:hover, .result.on { background: var(--hover); }
.result.on { box-shadow: inset 2px 0 0 var(--gold); }
.result-addr { display: block; font-weight: 600; }
.result-meta { display: block; color: var(--muted); font-size: 13px; }
.result-more { padding: 8px 10px; color: var(--muted); margin: 0; font-size: 14px; }
.result-card { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); background: var(--row); }
.result-card .kv { max-width: none; }
@media (max-width: 800px) {
  body.map-page .map-body { flex-direction: column; }
  .results { flex: 0 0 150px; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
}
.map-note { color: var(--muted); font-size: 14px; background: var(--row); border: 1px solid var(--line); border-radius: 4px; padding: 2px 8px; }
.pin { background: none !important; border: none !important; }
.pin-dot { display: block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.pin-watched .pin-dot { box-shadow: 0 0 0 3px #d4b45a, 0 1px 2px rgba(0,0,0,.4); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--row); color: var(--fg); }
.leaflet-popup-content-wrapper { border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.map-pop h3 { margin: 0 0 6px; font-size: 16px; }
.map-pop p { margin: 0 0 8px; }
.map-pop .watch-star { color: var(--gold); }
.kv.compact { margin-bottom: 8px; grid-template-columns: 110px 1fr; }
.leaflet-control-attribution { background: var(--row) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--gold); }

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100%;
  height: 100%;
  max-height: calc(100vh - 7.5rem);
  overflow: auto;
  background: var(--row);
  border-left: 1px solid var(--line);
  z-index: 1500;
  padding: 10px 14px 16px;
  box-shadow: -6px 0 24px rgba(0,0,0,.28);
}
.drawer[hidden] { display: none !important; }
#drawer-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 1;
  background: var(--row);
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px 4px 8px;
}
#drawer-close:hover { color: var(--fg); }
.drawer-title { margin: 0 28px 10px 0; font-size: 16px; font-weight: 650; line-height: 1.3; }
.drawer .kv { max-width: none; }
.map-pop button.drawer-open {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold);
  cursor: pointer;
  font: inherit;
}
@media (max-width: 800px) {
  .drawer { width: min(360px, 100%); max-height: calc(100vh - 10rem); }
}

html.locked header h1,
html.locked header .nav,
html.locked header .meta,
html.locked header .map-note,
html.locked #changes,
html.locked .filters,
html.locked #empty,
html.locked #grid,
html.locked #cards,
html.locked .map-body,
html.locked #sheet {
  display: none !important;
}
html.locked header { border-bottom: 0; }
html.locked body { overflow: hidden; }
#lock { display: none; }
html.locked #lock {
  display: flex;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.lock-card {
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px 24px 18px;
  width: min(280px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.lock-card h2 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--fg);
}
.lock-card input { width: 100%; }
.lock-card button {
  background: var(--row);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
.lock-card button:hover { background: var(--hover); }
.lock-error { color: var(--bad); font-size: 14px; margin: 0; }
@keyframes lock-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.lock-card.shake { animation: lock-shake 0.35s ease; }

.spread-low { color: var(--ok); font-variant-numeric: tabular-nums; }
.spread-mid { color: var(--gold); font-variant-numeric: tabular-nums; }
.spread-high { color: var(--muted); font-variant-numeric: tabular-nums; }
.flag-hot { color: var(--bad); }
.flags { font-size: 12px; letter-spacing: 0.02em; }
#liens { min-width: 7.5em; }

.tax-empty { color: var(--muted); margin: 0 0 8px; }
.tax { margin: 0 0 10px; }
.tax-delinquent {
  background: #f8e4e4;
  border-left: 3px solid var(--bad);
  padding: 8px 10px;
  margin: 0 0 10px;
}
.tax-delinquent dt:nth-of-type(2),
.tax-delinquent dd:nth-of-type(2),
.tax-delinquent dt:nth-of-type(3),
.tax-delinquent dd:nth-of-type(3) { color: var(--bad); font-weight: 600; }


.sheet { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: flex-start; justify-content: center; padding: 28px 16px 16px; }
.sheet[hidden] { display: none !important; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(28,28,28,.35); }
.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  background: var(--row);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 20px 20px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
#sheet-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 1;
  background: var(--row);
  border: 0;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px 4px 10px;
}
#sheet-close:hover { color: var(--fg); }
.sheet-title {
  margin: 0 36px 12px 0;
  font-size: 18px;
  font-weight: 650;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.sheet-panel .detail-grid { margin-top: 4px; }
body.sheet-open { overflow: hidden; }
@media (max-width: 800px) {
  .sheet { padding: 0; }
  .sheet-panel { width: 100%; max-height: 100vh; border-radius: 0; }
}
