:root {
  /* Layout: compact header (title, updated line, settings + add), one filter bar with a collapsible panel, then the sortable table. */
  --bg: #f3f6f5;
  --surface: #ffffff;
  --ink: #15211f;
  --muted: #586966;
  --line: #d9e1df;
  --accent: #0b6e6e;
  --accent-ink: #ffffff;
  --danger: #b93a31;
  --h-new: #7b8a87;
  --h-short: #2f6fd6;
  --h-agent: #8a56c9;
  --h-booked: #c2920c;
  --h-viewed: #d9772b;
  --h-offer: #2a9d57;
  --h-out: #c4453c;
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1514; --surface: #18201f; --ink: #e5eeec; --muted: #93a5a1; --line: #2a3735;
    --accent: #56c9c3; --accent-ink: #06201f; --danger: #ef7d73; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1514; --surface: #18201f; --ink: #e5eeec; --muted: #93a5a1; --line: #2a3735;
  --accent: #56c9c3; --accent-ink: #06201f; --danger: #ef7d73; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; line-height: 1.45; }
.wrap { max-width: 1600px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 12px; }
header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.head-actions { display: flex; gap: 8px; align-items: center; }
h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.sub { color: var(--muted); margin: 2px 0 0; }
.updated { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
button, select, input, textarea { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center; }
.icon-btn svg { width: 18px; height: 18px; }
.linkbtn { all: unset; cursor: pointer; color: var(--accent); text-decoration: underline; font-weight: 500; font-size: 13px; }
:focus-visible, .linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; margin-left: 4px; }
.badge[hidden] { display: none; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bar input[type="search"] { width: min(280px, 100%); }
.bar input, .bar select, .panel input, .panel select, dialog input[type="text"], dialog input[type="url"], dialog input[type="number"], dialog input[type="datetime-local"], dialog select, dialog textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-height: 36px;
}
.bar .grow { flex: 1; }
.sortbox { display: inline-flex; gap: 6px; align-items: center; }
.sortbox label { font-size: 12px; color: var(--muted); }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tokens:empty { display: none; }
.token { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; font-weight: 500; }
.token button { all: unset; cursor: pointer; width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); }
.token button:hover { background: var(--line); color: var(--ink); }
.token button:focus-visible { outline: 2px solid var(--accent); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 14px; }
.panel[hidden] { display: none; }
.panel .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label, .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.panel input[type="number"] { width: 120px; }
.stage-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.count {
  --h: var(--h-new);
  display: inline-flex; align-items: baseline; gap: 6px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 3px 11px; font-weight: 500;
}
.count b { font-variant-numeric: tabular-nums; }
.count[aria-pressed="true"] { color: var(--ink); border-color: color-mix(in oklab, var(--h) 50%, var(--line)); background: color-mix(in oklab, var(--h) 16%, var(--surface)); }

.note { border: 1px solid var(--line); border-left: 4px solid var(--h-booked); background: var(--surface); border-radius: 8px; padding: 10px 12px; }
.note[hidden] { display: none; }
.scroller { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; background: var(--surface); font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort] button { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
td:first-child, th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 210px; max-width: 260px; box-shadow: 1px 0 0 var(--line); }
th:first-child { z-index: 2; }
.name { all: unset; cursor: pointer; font-weight: 600; display: block; }
.name:hover { color: var(--accent); text-decoration: underline; }
.name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
a { color: var(--accent); }
tr.out td { color: var(--muted); }
tr.out .name { text-decoration: line-through; font-weight: 500; }
select.pill {
  --h: var(--h-new);
  appearance: none; -webkit-appearance: none; cursor: pointer;
  border: 1px solid color-mix(in oklab, var(--h) 45%, var(--line));
  background: color-mix(in oklab, var(--h) 16%, var(--surface));
  border-radius: 999px; padding: 3px 12px; font-weight: 500; min-width: 96px;
}
select.pill:disabled { cursor: default; opacity: 1; }
select.pill.empty { background: transparent; border-style: dashed; color: var(--muted); }
.s-New { --h: var(--h-new); } .s-Shortlisted { --h: var(--h-short); } .s-Agent { --h: var(--h-agent); }
.s-Viewing { --h: var(--h-booked); } .s-Viewed { --h: var(--h-viewed); } .s-Offer { --h: var(--h-offer); } .s-Ruled { --h: var(--h-out); }
.p-High { --h: var(--h-out); } .p-Medium { --h: var(--h-booked); } .p-Low { --h: var(--h-new); }
.o-Pending { --h: var(--h-booked); } .o-Countered { --h: var(--h-viewed); } .o-Accepted { --h: var(--h-offer); } .o-Declined { --h: var(--h-out); } .o-Not { --h: var(--h-new); }
.chip { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; border: 1px solid color-mix(in oklab, var(--h-booked) 50%, var(--line)); background: color-mix(in oklab, var(--h-booked) 16%, var(--surface)); }
td.tags { min-width: 150px; max-width: 220px; }
.tagbtn { all: unset; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px; min-height: 24px; border-radius: 6px; }
.tagbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tagbtn:disabled { cursor: default; }
.tag { --h: var(--h-booked); display: inline-block; font-size: 12px; font-weight: 500; border-radius: 6px; padding: 1px 8px; color: var(--ink); border: 1px solid color-mix(in oklab, var(--h) 45%, var(--line)); background: color-mix(in oklab, var(--h) 14%, var(--surface)); }
.tag.reason { --h: var(--h-out); }
.tag.add { background: transparent; border-style: dashed; border-color: var(--line); color: var(--muted); }
td.notes { min-width: 280px; max-width: 380px; white-space: pre-wrap; }
.empty-row td { text-align: center; color: var(--muted); padding: 28px 10px; position: static; max-width: none; box-shadow: none; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100% - 32px); }
dialog.small { width: min(460px, calc(100vw - 32px)); }
dialog.settings { width: min(580px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form, .dlg-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
dialog h2 { font-family: var(--font-display); font-size: 20px; margin: 0; }
dialog h3 { font-size: 14px; margin: 6px 0 0; }
dialog textarea { min-height: 84px; resize: vertical; width: 100%; }
dialog input[type="text"], dialog input[type="url"], dialog input[type="number"], dialog input[type="datetime-local"], dialog select { width: 100%; }
.dlg-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab { all: unset; cursor: pointer; padding: 8px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tabpanel { display: flex; flex-direction: column; gap: 12px; min-height: 220px; }
.tabpanel[hidden] { display: none; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline .field { flex: 1; }
.people { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; }
.people li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people .who { font-weight: 600; }
.people .when { color: var(--muted); font-size: 12px; text-align: right; }
.role { font-size: 11px; font-weight: 600; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-left: 6px; color: var(--muted); white-space: nowrap; }
.role.owner { color: var(--accent); border-color: var(--accent); }
.people li.pending .who { font-weight: 500; }
.people li.pending { background: color-mix(in oklab, var(--accent) 5%, var(--surface)); }
.people .right { display: flex; align-items: center; gap: 8px; }
.invite { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.invite h3 { margin: 0; }
.invite ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.invite .linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.invite .linkrow input { flex: 1; min-width: 180px; }
.invite a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
#people-open .n { font-weight: 600; color: var(--muted); margin-left: 4px; }
.you { font-size: 11px; font-weight: 600; color: var(--accent); margin-left: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.check:has(input:checked) { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, var(--surface)); }
.check input { accent-color: var(--accent); margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.actions .spacer { flex: 1; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; }
.ok { color: var(--h-offer); min-height: 1.2em; margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; }
#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; max-width: calc(100vw - 32px); }
#toast[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .btn, .count { transition: border-color .15s, background-color .15s; } }

/* Budget: opt-in per listing, one budget doc per listing (budgets/{listingId}); As-Is lives in household/main */
dialog.budget { width: min(1000px, calc(100vw - 32px)); }
.budget-ui input[type="date"], .budget-ui input.b-lbl { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-height: 36px; width: 100%; }
.budget-ui input.b-lbl { min-height: 0; padding: 2px 6px; font-size: 12px; color: var(--muted); border-style: dashed; }
.b-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.b-cols section { border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.b-cols h3 { margin: 0; }
.b-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.unitrow { display: flex; gap: 6px; }
.unitrow input { flex: 1; min-width: 0; }
.budget-ui .unitrow select { width: auto; }
.b-verdict { font-weight: 600; padding: 10px 12px; border-radius: 8px; border-left: 4px solid var(--h-offer); background: color-mix(in oklab, var(--h-offer) 10%, var(--surface)); }
.b-verdict.bad { border-left-color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, var(--surface)); }
.b-verdict.none { border-left-color: var(--h-new); background: var(--surface); font-weight: 500; }
.b-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.b-tables > div { overflow-x: auto; }
.budget-ui table { font-size: 13px; }
.budget-ui th, .budget-ui td { padding: 6px 8px; }
.budget-ui th { position: static; }
.budget-ui td:first-child, .budget-ui th:first-child { position: static; min-width: 0; max-width: none; box-shadow: none; }
.budget-ui tr.total td { font-weight: 600; }
.budget-ui tr.cur td { background: color-mix(in oklab, var(--accent) 10%, var(--surface)); }
td.good { color: var(--h-offer); } td.bad { color: var(--danger); }
.b-cell .meta { white-space: nowrap; }
/* Listing page: #listing-<id> (details) and #budget-<id> (budget tab) */
.wrap[hidden] { display: none; }
.budget-ui input[type="number"], .budget-ui input[type="text"], .budget-ui select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-height: 36px; width: 100%; }
.budget-ui .unitrow { display: flex; gap: 6px; }
#lp-budget .budget-ui { padding: 0; }
#lp-budget .budget-ui [data-close], #lp-budget .budget-ui .dlg-top h2 { display: none; }
.lp-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lp-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.lp-head h1 { font-size: 28px; }
.lp-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; color: var(--muted); }
.lp-status { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.lp-status .field { gap: 4px; }
.lp-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.lp-tabs .tab small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.lp-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.lp-panel[hidden] { display: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.tile .v { font-family: var(--font-display); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .s { font-size: 12px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 24px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.lp-sec h3 { font-size: 14px; margin: 0 0 8px; }
.lp-notes { white-space: pre-wrap; max-width: 75ch; margin: 0; }
.lp-tags { display: flex; flex-wrap: wrap; gap: 16px; }
.lp-tags .tagbtn { padding: 2px 0; }
.lp-empty { text-align: center; padding: 24px 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.lp-empty p { max-width: 60ch; margin: 0; color: var(--muted); }
#lp-link { width: min(520px, 100%); border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 9px; }
a.name { color: inherit; text-decoration: none; }

/* Additions for the hosted app: classes that replace the artifact's inline styles. */
form.flush { padding: 0; }
.field.narrow { flex: .6; }
.invite .linkrow { margin-top: 6px; }
.grid.spaced, .hint.spaced { margin-top: 10px; }
.cols-sub { flex-basis: 100%; margin: 8px 0 0; }
#b-ladder tr.pick { cursor: pointer; }
