/* blakelor-pad UI */
:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f1ed;
  --text: #1b1c1a;
  --muted: #6a6b66;
  --faint: #9a9b95;
  --border: #e4e4de;
  --border-strong: #d2d2ca;
  --accent: #047857;
  --accent-hover: #065f46;
  --accent-text: #ffffff;
  --accent-soft: #e5f4ed;
  --accent-soft-text: #065f46;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --focus: #2563eb;
  --row-hover: #f8f8f5;
  --shadow: 0 1px 2px rgb(20 20 15 / 0.04), 0 1px 1px rgb(20 20 15 / 0.03);
  --radius: 10px;
  --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312;
    --surface: #181a19;
    --surface-2: #1f2220;
    --text: #ebece8;
    --muted: #a2a49d;
    --faint: #75776f;
    --border: #2a2d2b;
    --border-strong: #3a3e3b;
    --accent: #34d399;
    --accent-hover: #6ee7b7;
    --accent-text: #052e1f;
    --accent-soft: rgb(52 211 153 / 0.12);
    --accent-soft-text: #6ee7b7;
    --warn: #f59e0b;
    --warn-soft: rgb(245 158 11 / 0.12);
    --danger: #f87171;
    --danger-soft: rgb(248 113 113 / 0.12);
    --focus: #60a5fa;
    --row-hover: #1d201e;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 10;
  background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.skip:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.brand img { border-radius: 6px; }

.topbar-inner { justify-content: space-between; }
.signout { margin: 0; }
.signout .btn-link { color: var(--muted); font-weight: 450; }

/* ---------- login ---------- */
.page-login .topbar { display: none; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 360px; display: grid; gap: 10px; padding: 28px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.login-card img { border-radius: 9px; margin-bottom: 6px; }
.login-card h1 { font-size: 21px; letter-spacing: -0.015em; font-weight: 650; }
.login-label { font-size: 13.5px; font-weight: 550; margin-top: 8px; }
.login-card input[type=password] {
  height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--bg);
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
.login-card input[type=password]:focus-visible { outline-offset: 0; border-color: var(--focus); }
.login-card input[aria-invalid=true] { border-color: var(--danger); }
.login-card .btn { height: 42px; margin-top: 4px; }
.login-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; font-size: 14px; }

/* ---------- intro ---------- */
.intro {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  padding: 32px 0 20px;
}
.intro h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; text-wrap: balance; }
.criteria { color: var(--muted); margin-top: 6px; max-width: 62ch; text-wrap: pretty; }
.intro-meta { display: grid; justify-items: end; gap: 8px; text-align: right; }
.kpi { font-size: 14px; color: var(--muted); }
.kpi strong { font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; margin-right: 4px; font-weight: 650; }
.updated { font-size: 13px; color: var(--faint); }
.statuses { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted);
  padding: 2px 9px 2px 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  cursor: default;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-ok .dot { background: var(--accent); }
.status-warn .dot { background: var(--warn); }
.status-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, var(--border)); }
.status-err .dot { background: var(--danger); }
.status-err { color: var(--danger); }

/* ---------- filters ---------- */
.filters {
  display: grid; gap: 14px; padding: 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.search { position: relative; flex: 1 1 320px; max-width: 520px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px;
  background: var(--bg); border: 1px solid var(--border-strong); border-radius: 8px;
}
.search input::placeholder { color: var(--faint); }
.search input:focus-visible { outline-offset: 0; border-color: var(--focus); }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chips legend {
  float: left; margin-right: 6px; font-size: 13px; color: var(--muted); padding: 0;
}
.chip, .segmented label, .toggle { position: relative; display: inline-flex; cursor: pointer; }
.chip input, .segmented input {
  position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer;
}
.chip span {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; font-size: 13.5px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  user-select: none;
}
.chip:hover span { border-color: var(--faint); }
.chip input:checked + span { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-soft-text); }
.chip input:checked + span::before {
  content: ""; width: 10px; height: 6px; margin-right: 7px; margin-top: -3px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
}
.chip input:focus-visible + span, .segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border); }
.segmented span {
  display: inline-flex; align-items: center; height: 30px; padding: 0 14px; border-radius: 6px;
  font-size: 13.5px; color: var(--muted); user-select: none;
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); font-weight: 550; }

.toggle { align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }

/* ---------- results bar ---------- */
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 36px; margin-bottom: 8px; }
#count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
#count strong { color: var(--text); font-weight: 600; }
.results-actions { display: flex; align-items: center; gap: 12px; }
.btn-link { background: none; border: 0; padding: 4px 2px; color: var(--accent); cursor: pointer; font-size: 14px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.sort-mobile { display: none; }
.sort-mobile select {
  height: 34px; padding: 0 28px 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
}

/* ---------- table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 48px; overflow: clip;
}
.listings { width: 100%; border-collapse: collapse; font-size: 14px; }
.listings thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  text-align: left; font-weight: 550; font-size: 12.5px; color: var(--muted);
  padding: 0 12px; height: 38px; white-space: nowrap;
}
.listings th.c-num { text-align: right; }
.listings th button {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border-radius: 4px;
}
.listings th button:hover { color: var(--text); }
.listings th button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.listings th button::after {
  content: ""; width: 0; height: 0; border: 4px solid transparent; opacity: 0;
  border-top-color: currentColor; margin-top: 4px;
}
.listings th[aria-sort] button { color: var(--text); }
.listings th[aria-sort] button::after { opacity: 1; }
.listings th[aria-sort="ascending"] button::after { border-top-color: transparent; border-bottom-color: currentColor; margin-top: -4px; }

.listings td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.listings tbody tr:last-child td { border-bottom: 0; }
.listings tbody tr { cursor: pointer; transition: background-color 100ms ease; }
.listings tbody tr:hover { background: var(--row-hover); }
.listings tbody tr.is-gone { color: var(--muted); }
.listings tbody tr.is-gone .thumb { opacity: 0.5; filter: grayscale(1); }
.listings .c-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-photo { width: 92px; padding-right: 0 !important; }
.thumb {
  width: 80px; height: 60px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-2);
}
.thumb-empty { display: grid; place-items: center; color: var(--faint); }
.c-title { min-width: 260px; }
.t-title {
  font-weight: 550; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-wrap: pretty;
}
.t-title:hover { text-decoration: underline; text-underline-offset: 2px; }
.t-sub { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 8px; }
.t-sub > span + span::before { content: "·"; margin-right: 8px; color: var(--faint); }
.t-mobile { display: none; }
.price { font-weight: 600; }
.price-sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.perks-cell { display: flex; flex-wrap: wrap; gap: 4px; max-width: 220px; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag-reject { background: var(--danger-soft); color: var(--danger); }
.tag-gone { background: var(--surface-2); color: var(--muted); }
.tag-new { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 550; }
.score {
  display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px;
  border-radius: 7px; font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); color: var(--muted);
}
.score-mid { background: var(--accent-soft); color: var(--accent-soft-text); }
.score-high { background: var(--accent); color: var(--accent-text); }
.c-found { white-space: nowrap; color: var(--muted); font-size: 13px; }
.src { display: block; font-size: 12px; color: var(--faint); }

.empty { padding: 56px 24px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty-title { color: var(--text); font-weight: 600; font-size: 16px; }
.empty .btn { margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  font-size: 14px; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---------- detail ---------- */
.detail { padding-bottom: 64px; }
.crumbs { padding: 20px 0 16px; font-size: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

.gallery { position: relative; margin-bottom: 28px; }
.gallery ul {
  list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto;
  scroll-snap-type: x mandatory; border-radius: var(--radius); scrollbar-width: thin;
}
.gallery li { flex: 0 0 auto; scroll-snap-align: start; }
.gallery img {
  height: clamp(220px, 42vw, 400px); width: auto; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.gallery-count {
  position: absolute; right: 12px; bottom: 12px; font-size: 12.5px; padding: 3px 10px; border-radius: 999px;
  background: rgb(0 0 0 / 0.6); color: #fff; pointer-events: none;
}
.gallery-empty {
  height: 160px; display: grid; place-items: center; border-radius: var(--radius);
  background: var(--surface-2); color: var(--faint); border: 1px dashed var(--border-strong);
}

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 16px; min-width: 0; }
.detail-head { display: grid; gap: 8px; padding-bottom: 8px; }
.detail-head h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.02em; font-weight: 650; text-wrap: balance; }
.address { color: var(--muted); }
.detail-head .price { font-size: 24px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.detail-head .price strong { font-weight: 650; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; background: var(--surface-2); color: var(--muted);
}
.badge-match { background: var(--accent-soft); color: var(--accent-soft-text); }
.badge-reject { background: var(--danger-soft); color: var(--danger); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.card h2 { font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 20px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 550; font-variant-numeric: tabular-nums; }

.prose { white-space: pre-line; overflow-wrap: anywhere; max-width: 72ch; color: var(--text); }
.tags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.map { width: 100%; height: 300px; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); }

.score-total { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.score-total .muted { font-size: 14px; font-weight: 400; }
.score-breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.score-breakdown li { display: grid; grid-template-columns: 1fr 90px 52px; align-items: center; gap: 10px; font-size: 13.5px; }
.sb-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.sb-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.sb-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }

.perks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.perk { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.perk-icon { width: 18px; height: 18px; border-radius: 50%; position: relative; background: var(--surface-2); }
.perk-yes .perk-icon { background: var(--accent-soft); }
.perk-yes .perk-icon::after {
  content: ""; position: absolute; left: 5px; top: 5px; width: 8px; height: 4px;
  border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg);
}
.perk-no .perk-icon::after {
  content: ""; position: absolute; left: 5px; top: 8px; width: 8px; height: 2px; background: var(--muted);
}
.perk-unknown .perk-icon::after {
  content: ""; position: absolute; left: 7px; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--faint);
}
.perk-val { color: var(--muted); font-size: 13px; }
.perk-yes .perk-val { color: var(--accent-soft-text); font-weight: 550; }

.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.links a { font-weight: 550; text-underline-offset: 2px; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.tl-when { color: var(--muted); font-size: 13px; }
.ids { padding: 0 4px; }
.ids a { color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .c-sqft, .listings td.c-sqft { display: none; }
}
@media (max-width: 960px) {
  .c-perks, .listings td.c-perks { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .intro { padding-top: 22px; align-items: flex-start; }
  .intro h1 { font-size: 23px; }
  .intro-meta { justify-items: start; text-align: left; }
  .statuses { justify-content: flex-start; }
  .filters { padding: 12px; }
  .search { flex-basis: 100%; max-width: none; }
  .sort-mobile { display: inline-block; }
  .c-beds, .listings td.c-beds, .c-dist, .listings td.c-dist, .c-found, .listings td.c-found { display: none; }
  .c-photo { width: 76px; }
  .thumb { width: 64px; height: 52px; }
  .listings td { padding: 10px 8px; }
  .c-title { min-width: 0; }
  .t-mobile { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
  .detail-head h1 { font-size: 22px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .card { padding: 16px; }
  .gallery img { height: 240px; }
  .actions .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
