/* 主儀表板專用（共用樣式在 theme.css；2026-09-30 依 Claude Design「大新竹實登儀表板.html」改版） */
:root { --bar: oklch(0.3 0.005 250); --bar2: oklch(0.82 0.004 250); }
.wrap { gap: 48px; }

/* 開關 */
.tg { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); cursor: pointer; user-select: none; padding: 0 4px; white-space: nowrap; }
.tg input { position: absolute; opacity: 0; width: 0; height: 0; }
.tg span { width: 28px; height: 16px; border-radius: 8px; background: var(--bar2); position: relative; transition: .15s; }
.tg span:after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: .15s; }
.tg input:checked + span { background: var(--acc); }
.tg input:checked + span:after { left: 14px; }
.tg input:focus-visible + span { outline: 2px solid var(--acc); outline-offset: 2px; }
.reset { border: 0; background: none; color: var(--ink3); cursor: pointer; font-size: 13px; }
.reset:hover { color: var(--ink); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.kpi { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; border-left: 1px solid var(--line2); }
.kpi:first-child { border-left: 0; }
.kpi .lb { font-size: 12.5px; color: var(--ink2); }
.kpi .v { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi .v small { font-size: 13px; font-weight: 400; color: var(--ink3); margin-left: 5px; letter-spacing: 0; }
.kpi .sub { font-size: 12px; color: var(--ink3); font-family: var(--mono); min-height: 18px; }
.kpi .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 8px; }
.dl { font-family: var(--mono); font-size: 11.5px; color: var(--ink3); white-space: nowrap; }
.dl b { font-weight: 500; border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.up b { background: var(--acc-bg); color: var(--acc); }
.dn b, .fl b { background: var(--line2); color: var(--ink); }

/* 重點卡 */
.hl { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.hl .card { padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hl small { font-size: 12px; color: var(--ink3); }
.hl b { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl span { font-family: var(--mono); font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl .qa { cursor: pointer; text-align: left; border-color: var(--ink); font: inherit; color: inherit; }
.hl .qa:hover { background: var(--line2); }
.hl .qa b { display: flex; gap: 8px; align-items: center; }
.hl .qa b i { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); flex: none; }
.hl .qa.ok { border-color: var(--line); cursor: default; }
.hl .qa.ok:hover { background: var(--card); }
.hl .qa.ok b i { background: var(--lo); }

/* 洞察 */
.insight { margin-top: 12px; padding: 16px 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; background: transparent; border-style: dashed; }
.insight div { display: flex; flex-direction: column; gap: 4px; }
.insight small { font-family: var(--mono); font-size: 11px; color: var(--ink3); letter-spacing: .06em; }
.insight p { margin: 0; font-size: 13.5px; text-wrap: pretty; color: var(--ink2); }
.insight strong { font-weight: 700; color: var(--ink); }

/* 圖表格線 */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c4 { grid-column: span 4; }
.panel { display: flex; flex-direction: column; }
.chart { width: 100%; min-height: 200px; }
.mk { stroke: var(--acc); stroke-dasharray: 3 3; }
.mkt { font-size: 11px; fill: var(--acc); font-weight: 500; }

/* 區域橫條 */
.hbar { display: flex; flex-direction: column; gap: 8px; justify-content: center; flex: 1; }
.hb { display: grid; grid-template-columns: 52px minmax(0, 1fr) 96px; gap: 12px; align-items: center; font-size: 13px; }
.hb .t { height: 18px; background: var(--line2); border-radius: 3px; overflow: hidden; }
.hb .t i { display: block; height: 100%; background: var(--bar2); border-radius: 3px; }
.hb.top .t i { background: var(--ink); }
.hb .n { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--ink3); }
.hb .n b { color: var(--ink); font-weight: 500; }

/* 熱門建案 */
.rank { display: flex; flex-direction: column; }
.rk { display: grid; grid-template-columns: 22px minmax(0, 1fr) 110px 52px; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line2); font-size: 13px; }
.rk:last-child { border-bottom: 0; }
.rk .no { font-family: var(--mono); font-size: 11.5px; color: var(--ink3); }
.rk .nm b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk .nm a, .hl b a { color: inherit; }
.rk .nm a:hover, .hl b a:hover { color: var(--acc); }
.rk .nm small { color: var(--ink3); font-size: 11.5px; }
.rk .ct { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12.5px; }
.rk .ct span { flex: 1; height: 4px; background: var(--line2); border-radius: 2px; overflow: hidden; }
.rk .ct span i { display: block; height: 100%; background: var(--ink); }
.rk:first-child .ct span i { background: var(--acc); }
.rk .pr { text-align: right; font-family: var(--mono); font-size: 12.5px; color: var(--ink2); }

/* 房型 */
.stack { display: flex; height: 28px; border-radius: 5px; overflow: hidden; gap: 2px; margin: 2px 0 14px; }
.stack div { display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-family: var(--mono); min-width: 0; overflow: hidden; }
.rtbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.rtbl th { font-weight: 400; color: var(--ink3); font-size: 12px; text-align: right; padding: 5px 0; border-bottom: 1px solid var(--line); }
.rtbl th:first-child, .rtbl td:first-child { text-align: left; }
.rtbl td { padding: 6px 0; border-bottom: 1px solid var(--line2); text-align: right; font-family: var(--mono); font-size: 12.5px; }
.rtbl tr:last-child td { border-bottom: 0; }
.rtbl td:first-child { font-family: var(--sans); font-size: 13px; }
.sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; }

/* 明細表 */
.tbl-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tbl-top .search { width: min(320px, 100%); }
.tbl-scroll { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.dt th { text-align: left; font-weight: 400; font-size: 12px; color: var(--ink3); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dt th.s { cursor: pointer; }
.dt th.s:hover { color: var(--ink); }
.dt th.r, .dt td.r { text-align: right; }
.dt td { padding: 11px 16px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.dt tr.main { cursor: pointer; }
.dt tr.main:hover td { background: var(--bg); }
.dt tr.main.open td { background: var(--bg); border-bottom-color: transparent; }
.dt td.m { font-family: var(--mono); font-size: 12.5px; }
.dt td.pj { font-weight: 500; }
.dt td.pj a { color: inherit; }
.dt td.pj a:hover { color: var(--acc); }
.dt td b { font-weight: 500; }
.dt td.ex { color: var(--ink3); width: 28px; text-align: center; }
.dt tr.more td { background: var(--bg); padding: 4px 16px 14px; white-space: normal; }
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 24px; font-size: 12.5px; }
.more-grid span { color: var(--ink3); margin-right: 8px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--acc); color: var(--acc); margin-right: 4px; }
.badge.g { border-color: var(--line); color: var(--ink2); }
.pg { display: flex; justify-content: flex-end; align-items: center; padding: 12px 16px; font-size: 13px; color: var(--ink2); }
.pg div { display: flex; gap: 8px; align-items: center; }
.pg button { border: 1px solid var(--line); background: var(--card); border-radius: 6px; height: 30px; padding: 0 12px; cursor: pointer; }
.pg button:disabled { opacity: .4; cursor: default; }
.pg button:not(:disabled):hover { border-color: var(--ink); }

/* 數據品質抽屜 */
.drawer-bg { position: fixed; inset: 0; background: oklch(0.2 0.005 250 / .25); z-index: 40; display: none; }
.drawer-bg.on { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); background: var(--card); border-left: 1px solid var(--line); z-index: 41; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.on { transform: none; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer h3 { margin: 0; font-size: 16px; }
.drawer .x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--ink3); }
.drawer .body { padding: 16px 22px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.drawer h4 { margin: 8px 0 0; font-size: 12.5px; font-weight: 500; color: var(--ink2); }
.drawer .note { margin: 0; font-size: 12.5px; color: var(--ink3); }
.qi { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.qi b { font-size: 13.5px; font-weight: 500; }
.qi span { font-size: 12.5px; color: var(--ink2); }
.qi code { font-family: var(--mono); font-size: 11.5px; color: var(--ink3); }

@media (max-width: 1180px) {
  .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; }
  /* 5 張卡：上排 3、下排 2 */
  .kpis, .hl { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hl > * { grid-column: span 2; }
  .hl > :nth-child(n+4) { grid-column: span 3; }
  .kpi { grid-column: span 2; }
  .kpi:nth-child(n+4) { grid-column: span 3; border-top: 1px solid var(--line2); }
  .kpi:nth-child(4) { border-left: 0; }
  .insight { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpis, .hl { grid-template-columns: minmax(0, 1fr); }
  .hl > *, .hl > :nth-child(n+4) { grid-column: auto; }
  .kpi, .kpi:nth-child(n+4) { border-left: 0; grid-column: auto; }
  .kpi:nth-child(n+2) { border-top: 1px solid var(--line2); }
  .kpi .v { font-size: 28px; }
}
