/* PBSA 日報 — light, simple theme (2026-10 redesign) */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --line: #e3e7ec;
  --accent: #0f6e6a;        /* calm teal */
  --accent-soft: #e6f2f1;
  --hi: #a8321e;  --hi-bg: #fbece8;
  --mid: #8a5a00; --mid-bg: #fdf3dc;
  --lo: #55606e;  --lo-bg: #eef0f3;
  --radius: 10px;
  --font: "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* Header: one line */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 16px; padding-top: 18px; padding-bottom: 16px;
}
.site-header h1 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.01em; }
.updated { margin: 0; font-size: 0.875rem; color: var(--muted); }

.counts { margin: 18px 0 0; font-size: 0.9rem; color: var(--muted); }

/* Sections */
main section, main > details.fold {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 16px 0;
}
h2 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  line-height: 1.3;
}

/* 今日要留意 */
.watch-list { list-style: none; margin: 0; padding: 0; }
.watch-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.watch-list li:first-child { border-top: 0; padding-top: 2px; }
#watch-more li:first-child { border-top: 1px solid var(--line); padding-top: 9px; }
.pri {
  flex: none; display: inline-block; min-width: 1.9em; text-align: center;
  font-size: 0.75rem; font-weight: 700; line-height: 1.5rem; height: 1.5rem;
  border-radius: 999px; padding: 0 6px; margin-top: 1px;
}
.pri.high { color: var(--hi); background: var(--hi-bg); }
.pri.medium { color: var(--mid); background: var(--mid-bg); }
.pri.low { color: var(--lo); background: var(--lo-bg); }
.w-body { min-width: 0; flex: 1; }
.w-title {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-rest { display: none; margin: 4px 0 0; font-size: 0.9rem; color: var(--muted); }
.watch-list li.open .w-title { white-space: normal; }
.watch-list li.open .w-rest { display: block; }
.more-btn {
  margin-top: 8px; background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--accent); font-size: 0.9rem; font-weight: 500;
}
.more-btn:hover { text-decoration: underline; }

/* 最新消息 */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.news-list li:first-child { border-top: 0; padding-top: 2px; }
.n-date { flex: none; width: 6.2em; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.n-body { min-width: 0; }
.n-title { color: var(--text); font-weight: 500; }
@media (max-width: 640px) { .n-title { font-size: 0.95rem; } }
.n-title:hover { color: var(--accent); }
.n-src { font-size: 0.8rem; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.n-src::before { content: "· "; }
.n-sum { display: inline; margin-left: 6px; font-size: 0.8rem; }
.n-sum > summary { display: inline; cursor: pointer; color: var(--accent); list-style: none; }
.n-sum > summary::-webkit-details-marker { display: none; }
.n-sum[open] { display: block; margin: 4px 0 0; }
.n-sum p { margin: 4px 0 0; font-size: 0.875rem; color: var(--muted); line-height: 1.6; }

/* 近5年成交 */
/* status badges: prominent, coloured */
.badge {
  display: inline-block; flex: none; padding: 1px 8px; border-radius: 999px; border: 1px solid transparent;
  font-size: 0.74rem; font-weight: 700; line-height: 1.5; white-space: nowrap; vertical-align: 1px;
}
.st-land_registry_verified { background: #1a7f37; color: #fff; }
.st-announced_media { background: #0f6e6a; color: #fff; box-shadow: inset 0 0 0 2px #f0c27a; }
.st-announced { background: #0f6e6a; color: #fff; }
.st-media { background: #fde9c8; color: #8a4500; border-color: #f0c27a; }
.st-rumour { background: #f3f4f6; color: #5f6b7a; border: 1px dashed #9aa4b1; }
.pend { margin-left: 5px; font-size: 0.74rem; font-weight: 500; color: #8a4500; white-space: nowrap; }
.legend { margin: -2px 0 10px; font-size: 0.78rem; color: var(--muted); line-height: 2; }
.legend .badge { margin-left: 8px; } .legend-lr { margin-left: 8px; } .legend .badge:first-child { margin-left: 0; }
.refs { margin-top: 3px; font-size: 0.8rem; }
.deal-ref { color: var(--muted); margin-right: 8px; } .deal-ref:hover { text-decoration: none; color: var(--accent); }

/* filters */
details.filters { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; background: #fafbfc; }
details.filters > summary { cursor: pointer; font-size: 0.88rem; font-weight: 500; list-style: none; }
details.filters > summary::-webkit-details-marker { display: none; }
details.filters > summary::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--accent); transition: transform .15s; }
details.filters[open] > summary::before { transform: rotate(90deg); }
#f-active { margin-left: 4px; color: var(--accent); font-weight: 400; font-size: 0.8rem; }
.f-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; margin-top: 8px; align-items: end; }
.f-grid label { display: flex; flex-direction: column; gap: 2px; font-size: 0.75rem; color: var(--muted); min-width: 0; }
.f-grid .f-wide { grid-column: span 2; }
.f-grid input, .f-grid select {
  font: inherit; font-size: 0.88rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-width: 0; width: 100%;
}
.f-grid input:focus, .f-grid select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.f-reset { justify-self: start; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 12px; font-size: 0.85rem; color: var(--accent); cursor: pointer; }
.m-sort { display: none !important; }

/* summary: median + range */
.summary { margin: 0 0 10px; }
.sum-n { margin: 0 0 4px; font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.sum-n b { color: var(--text); }
.toggle { display: inline-flex; align-items: center; gap: 4px; color: var(--text); cursor: pointer; white-space: nowrap; }
.toggle input { accent-color: var(--accent); margin: 0; }
.sum-main, .sum-side { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 22px; font-size: 0.88rem; }
.sum-side { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.sum-main b { color: var(--accent); font-weight: 700; }
.sum-side b { color: var(--text); font-weight: 500; }
.s-l { color: var(--muted); }
.s-r { color: var(--muted); font-size: 0.8rem; }
.few { font-style: normal; font-size: 0.72rem; color: #8a4500; background: #fdf3dc; border-radius: 4px; padding: 0 4px; margin-left: 2px; white-space: nowrap; }
.est-line b { color: #6b6f76; }
.method { margin: 4px 0 0; font-size: 0.75rem; color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
table.deals { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.deals > thead > tr > th, table.deals > tbody > tr > td { text-align: left; vertical-align: top; padding: 10px 7px; }
table.deals > thead > tr > th {
  font-size: 0.78rem; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line); padding-top: 4px; vertical-align: bottom;
}
table.deals > * > tr > .num { text-align: right; }
th.sortable button {
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font-size: inherit; font-weight: inherit; text-align: inherit;
}
th.sortable button::after { content: " ↕"; opacity: 0.4; }
th[aria-sort="descending"] button::after { content: " ↓"; opacity: 1; color: var(--accent); }
th[aria-sort="ascending"] button::after { content: " ↑"; opacity: 1; color: var(--accent); }
th[aria-sort="descending"] button, th[aria-sort="ascending"] button { color: var(--text); }
tbody.deal > tr.main > td { border-top: 1px solid var(--line); }
tbody.deal:first-of-type tr.main td { border-top: 0; }
tbody.deal.open tr.main td { background: #fafbfc; }
tbody.deal:target tr.main td { background: var(--accent-soft); }
.c-first { min-width: 14em; width: 21%; }
.c-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.c-date { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.82rem; }
.a-name { font-weight: 500; margin-top: 3px; }
.use { display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 4px; font-size: 0.7rem; font-weight: 400; color: var(--muted); background: var(--lo-bg); vertical-align: 1px; white-space: nowrap; }
.m-key { display: none; }
.c-parties { min-width: 12em; width: 19%; font-size: 0.8rem; }
.p-seller { color: var(--muted); margin-top: 2px; }
.bs { display: inline-block; font-size: 0.68rem; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; margin-right: 4px; line-height: 1.3; }
.c-price { white-space: nowrap; font-weight: 500; font-variant-numeric: tabular-nums; }
.media { display: block; font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.c-src { font-size: 0.76rem; min-width: 8em; width: 10%; }
.c-src a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.c-src a:hover { color: var(--accent); }
.src-links { display: block; }
.src2 { white-space: nowrap; }
.more-link {
  display: inline-block; margin-top: 4px;
  background: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px;
  font-size: 0.78rem; color: var(--accent); cursor: pointer;
}
.more-link:hover { border-color: var(--accent); }
tr.detail > td { background: #fafbfc; padding: 4px 12px 16px; font-size: 0.85rem; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 20px; margin: 4px 0 10px; }
dl.facts.m-only { display: none; }
.fact { min-width: 0; }
.fact dt { font-size: 0.75rem; color: var(--muted); }
.fact dd { margin: 0; overflow-wrap: anywhere; }
.basis { font-size: 0.68rem; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 4px; }
.d-links { margin: 6px 0 10px; font-size: 0.82rem; }
tr.detail h4 { margin: 8px 0 6px; font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.rt-wrap { overflow-x: auto; }
table.rt { border-collapse: collapse; width: 100%; font-size: 0.8rem; background: var(--surface); }
table.rt th, table.rt td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
table.rt th { font-weight: 500; color: var(--muted); white-space: nowrap; }

.c-m { white-space: nowrap; font-variant-numeric: tabular-nums; }
th.c-m { white-space: normal; min-width: 4.5em; }
th.c-est { min-width: 6.5em; }
.mtag {
  display: inline-block; margin-left: 3px; padding: 0 4px; border-radius: 4px;
  font-size: 0.68rem; line-height: 1.35; vertical-align: 1px;
  color: var(--accent); background: var(--accent-soft);
}
.mtag.warn { color: var(--muted); background: var(--lo-bg); }
.c-bed .mtag.warn { display: block; width: max-content; margin: 2px 0 0 auto; }
/* estimate column: muted, clearly tagged */
.est { color: #6b6f76; }
.mtag.est-tag { color: #6b6f76; background: #f1f1f3; border: 1px dashed #b9bdc4; }
.est-rng { display: block; font-size: 0.7rem; color: var(--muted); }
.foot-note { margin: 8px 0 0; font-size: 0.75rem; color: var(--muted); line-height: 1.6; }

/* Folds (待核實 / 資料缺口) */
details.fold > summary {
  cursor: pointer; font-size: 0.92rem; font-weight: 500; color: var(--text); list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; display: inline-block; width: 1.1em; color: var(--accent); transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold .n { margin-left: 6px; font-size: 0.8rem; font-weight: 400; color: var(--muted); }
details.fold .n:empty { display: none; }
details.fold .n::before { content: "("; } details.fold .n::after { content: ")"; }
details.fold ul { margin: 10px 0 0; padding-left: 1.2em; font-size: 0.88rem; color: var(--text); }
details.fold li { margin: 6px 0; }
section details.fold { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
main > details.fold { padding-top: 14px; padding-bottom: 14px; }

/* Footer */
.site-footer { padding: 8px 0 36px; }
.site-footer p { margin: 0; font-size: 0.8rem; color: var(--muted); }

/* Mobile */
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .site-header h1 { font-size: 1.1rem; }
  .header-inner { padding-top: 14px; padding-bottom: 12px; }
  main section, main > details.fold { padding: 16px 14px; margin: 12px 0; border-radius: 8px; }
  .counts { margin-top: 14px; }

  .w-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .watch-list li.open .w-title { display: block; -webkit-line-clamp: unset; }

  .news-list li { flex-direction: column; gap: 2px; }
  .n-date { width: auto; font-size: 0.78rem; }
  .n-src { display: inline-block; margin-left: 0; }
  .n-src::before { content: ""; }
  .n-sum { margin-left: 8px; }

  dl.facts { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
}

/* Phones / narrow: compact deal cards (物業, 日期, 金額, 每床或每房價, 狀態); the rest lives in 詳情. */
@media (max-width: 720px) {
  .table-wrap { overflow: visible; margin: 0; }
  table.deals, table.deals > tbody, table.deals > tbody > tr, table.deals > tbody > tr > td { display: block; width: 100%; }
  table.deals > thead { display: none; }
  .m-sort { display: flex !important; }
  .f-grid { grid-template-columns: 1fr 1fr; }
  .f-grid .f-wide { grid-column: 1 / -1; }
  tbody.deal { border-top: 1px solid var(--line); padding: 10px 0; }
  tbody.deal:first-of-type { border-top: 0; }
  tbody.deal tr.main { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 10px; }
  tbody.deal > tr.main > td { width: auto !important; border: 0 !important; padding: 0; background: none !important; }
  tbody.deal > tr.main > td.c-parties, tbody.deal > tr.main > td.c-m { display: none; }
  .c-first { order: 1; flex: 1 1 0; min-width: 0; }
  .c-price { order: 2; flex: none; text-align: right; font-size: 0.98rem; padding-top: 1px !important; }
  .c-src { order: 3; flex: 1 1 100%; max-width: none; min-width: 0; text-align: right; margin-top: -2px; }
  .src-links { display: none; }
  .more-link { margin-top: 0; }
  .a-name { font-size: 0.95rem; overflow-wrap: anywhere; }
  .m-key { display: block; margin-top: 3px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
  .k-l { color: var(--muted); font-size: 0.78rem; }
  .m-key .mtag.warn { display: inline-block; margin-left: 4px; }
  .media { margin-top: 1px; }
  tbody.deal.open tr.main td { background: none; }
  tr.detail > td { padding: 10px 10px 12px; margin-top: 8px; border-radius: 6px; }
  dl.facts.m-only { display: grid; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
  dl.facts { grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .fact.d-only { display: none; }
  .est-rng { display: inline; margin-left: 4px; }
  .sum-main { flex-direction: column; gap: 2px; font-size: 0.85rem; }
  .sum-side { flex-direction: column; gap: 1px; }
  .legend { line-height: 1.9; }
}
@media (max-width: 640px) { table.rt { min-width: 560px; } table.rt td { min-width: 4.5em; } }
@media (max-width: 380px) { dl.facts { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  tbody.deal > tr.main > td.c-src { text-align: right; }
  .a-name .use { display: none; }
}

/* v4: 9-column desktop table */
.c-dt { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.82rem; }
.c-status { white-space: nowrap; }
.c-status .pend { display: block; margin: 3px 0 0; }
.c-top { display: none; }
.c-first { min-width: 12em; width: 22%; }
.c-parties { min-width: 9em; width: 16%; }
th.c-bedh { min-width: 7.5em; }
th.c-bedh small { display: block; font-size: 0.7rem; font-weight: 400; }
.c-bed .mtag { display: block; width: max-content; margin: 2px 0 0 auto; }
dl.facts.moved { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
dl.facts.moved:empty { display: none; }
@media (max-width: 720px) {
  tbody.deal > tr.main > td.c-dt, tbody.deal > tr.main > td.c-status { display: none; }
  .c-top { display: flex; }
  .m-key .mtag { display: inline-block; margin-left: 4px; }
  .c-first { width: auto; }
}

/* v5: separate type badge row; two per-bed columns */
.type-row { margin-top: 3px; }
.type-row .use { margin-left: 0; }
.c-bed .mtag, .c-unreno .mtag { display: inline-block; margin: 0 0 0 3px; }
.c-unreno { color: var(--muted); }
.note-cmp { font-style: italic; }
@media (max-width: 720px) { .type-row { display: none; } }
