:root {
  --teal: #00b0b9;
  --amber: #f0a613;
  --ink: #1a2b3c;
  --muted: #6b7c8c;
  --bg: #f7fbfc;
  --card: #ffffff;
  --line: #d5e3e8;
  --ok: #1a7f5a;
  --warn: #b86e00;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.wrap { padding: 14px 14px 20px; max-width: 960px; margin: 0 auto; }
.brand {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.brand h1 {
  margin: 0; font-size: 1.15rem; color: var(--teal); letter-spacing: 0.02em;
}
.brand .sub { color: var(--muted); font-size: 0.85rem; }
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e6f7f8;
  color: var(--teal);
  border: 1px solid #b7e4e7;
}
.badge.warn { background: #fff6e8; color: var(--warn); border-color: #f0d3a0; }
.badge.ok { background: #e9f7f1; color: var(--ok); border-color: #b7e5d1; }
.tabs {
  display: flex; gap: 6px; margin: 12px 0 10px; flex-wrap: wrap;
}
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tabs button.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.panelwrap { position: relative; transition: min-height .25s ease; }
.panel { display: none; }
.panel.active { display: block; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.meta {
  font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.5;
}
.chart-wrap { width: 100%; overflow-x: auto; }
canvas { width: 100% !important; max-height: 280px; }
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
th, td {
  padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.price { color: var(--teal); font-weight: 700; }
.foot {
  margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.55;
}
.foot a { color: var(--teal); }
.actions { margin: 8px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.actions a, .actions button {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.actions a.primary, .actions button.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1200;
  font-weight: 600;
}
.empty { padding: 24px; text-align: center; color: var(--muted); }
.chart-card .chart-title {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--teal);
}
.chart-card .chart-desc {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}
.tag-special {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff6e8;
  color: var(--warn);
  border: 1px solid #f0d3a0;
  cursor: help;
  white-space: nowrap;
}
.tag-outlier {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  cursor: help;
  white-space: nowrap;
}
/* 數字欄不可斷行：加了「含車位」標記後總價欄變寬，
   會把坪單價擠成「48.5」與「萬」兩行 */
td.num {
  white-space: nowrap;
}
/* 總價欄的「含車位」標記：坪單價不含車位、總價含車位，逐列標清楚 */
.tag-park {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #5b6675;
  border: 1px solid #dde1e7;
  cursor: help;
  white-space: nowrap;
  vertical-align: middle;
}
/* 比對層級退到路名／行政區時的警示：這批不是本案成交 */
.scope-warn {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff6e8;
  border: 1px solid #f0d3a0;
  color: #8a5a12;
  font-size: 13px;
  line-height: 1.6;
}
.scope-warn strong {
  display: block;
  margin-bottom: 2px;
  color: #a1500a;
}
th small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.2;
}
.tag-outlier.hi {
  background: #fdecea;
  color: #c0392b;
  border: 1px solid #f0b8b0;
}
.tag-outlier.lo {
  background: #eaf4ff;
  color: #1a6fb5;
  border: 1px solid #b8d4f0;
}
td.tags {
  white-space: normal;
}
td.tags .tag-special,
td.tags .tag-outlier {
  margin: 1px 2px 1px 0;
}
tr.row-outlier td.price {
  font-weight: 700;
}
.tag-room {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f5;
  color: #3a4a58;
  border: 1px solid #d5e3e8;
  white-space: nowrap;
}
.tag-room-2 {
  background: #e6f7f8;
  color: #007a82;
  border-color: #b7e4e7;
}
.tag-room-3 {
  background: #eef4fa;
  color: #1f4e79;
  border-color: #c5d8ea;
}
tr.row-special td { background: #fffaf3; }
.room-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 12px;
}
.room-label { font-size: 13px; color: var(--muted); }
.room-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.room-btn.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.room-counts { font-size: 12.5px; color: var(--muted); }
.forsale-body { display: block; }
.forsale-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  padding: 8px;
}
.forsale-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: start;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.forsale-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.forsale-row-floor {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
  padding: 6px 2px 0 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  position: sticky;
  top: 8px;
}
.fs-floor-btn-f {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  text-align: left;
}
.fs-floor-btn-n {
  font-size: 12px;
  color: var(--muted);
}
/* 同層單列橫向捲動；卡片不換行 */
.fs-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.fs-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: #fff;
  min-height: 0;
  height: 36px;
  /* 先前整列約 20%；固定寬度以便橫向並排滾動 */
  flex: 0 0 20%;
  width: 20%;
  min-width: 140px;
  max-width: 220px;
  box-sizing: border-box;
}
.fs-card:hover { border-color: #9ad8dc; }
.fs-card.is-other {
  background: #eceff2;
  border-color: #d5d9de;
}
.fs-card.is-fusheng {
  border-color: #9ad8dc;
  background: #fff;
}
/* 前方正方形虛線框 + 中央＋ */
.fs-card-ph {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  box-sizing: border-box;
  margin: 0 0 0 4px;
  border: 1.5px dashed #a8b4be;
  border-radius: 3px;
  background: #e8ecf0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7a8794;
  font-size: 14px;
  font-weight: 300;
  line-height: 1;
  user-select: none;
}
.fs-card.is-fusheng .fs-card-ph {
  border-color: #7ec8cd;
  background: #eef9fa;
  color: var(--teal);
}
.fs-card-body {
  flex: 1;
  min-width: 0;
  padding: 0 6px 0 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.fs-card-top {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
}
.fs-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 0 3px;
  border-radius: 999px;
  background: #e6f7f8;
  color: var(--teal);
  border: 1px solid #b7e4e7;
  flex-shrink: 0;
}
.fs-price {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.fs-price small { font-size: 9px; font-weight: 600; margin-left: 1px; }
.fs-meta, .fs-unit {
  font-size: 10px;
  color: var(--muted);
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* 手機版特殊交易顏色點點；show-sm 僅手機顯示 */
.show-sm { display: none; }
.deal-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--warn);
  vertical-align: middle;
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .show-sm { display: inline-block; }
  .brand h1 { font-size: 1.05rem; }
  .forsale-row { grid-template-columns: 56px 1fr; gap: 6px; }
  .fs-card {
    height: 34px;
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
    max-width: 180px;
    justify-content: center;
  }
  /* 手機版在售：不呈現數量、卡片不出現圖示、只留價格 */
  #forsaleRoomCounts { display: none; }
  .forsale-row-floor .fs-floor-btn-n { display: none; }
  .fs-card-ph { display: none; }
  .fs-card .fs-meta { display: none; }

  /* 手機版成交明細：讓「坪單價」「總價」擠得進來。
     實價登錄看不到價格等於沒有意義，寧可縮欄距也要留住兩個價格欄；
     行政區在建案頁恆為同一區，改為手機隱藏騰出空間。 */
  #panel-deals th,
  #panel-deals td {
    padding-left: 4px;
    padding-right: 4px;
    font-size: 13px;
  }
  #panel-deals th { font-size: 12px; }
  #panel-deals th small { font-size: 9.5px; }
  #panel-deals td.num { font-size: 13px; }
  #panel-deals td.num small { font-size: 10px; }
  #panel-deals td.tags { padding-left: 0; padding-right: 0; }
}
