:root {
  --c-bg: #f7f7f5;
  --c-panel: #ffffff;
  --c-text: #1d1d1f;
  --c-muted: #6b6b6f;
  --c-border: #e2e2e0;
  --c-accent: #0066cc;
  --c-accent-dark: #004999;
  --c-danger: #c0392b;
  --c-ok: #2e7d32;
  --c-warn: #b26500;
  --c-row-alt: #fafaf9;
  --c-surface: #ffffff;     /* 卡片/輸入框/彈窗 panel 面（淺色）*/
  --c-surface-2: #f1f1ef;   /* 表頭/巢狀區塊的次層底色（淺色）*/
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--c-bg); color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
  gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 600; }
.brand .ver { color: var(--c-accent); font-weight: 700; }
.year-badge {
  background: #eef4fb; color: var(--c-accent-dark);
  padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600;
}
.stats-badge {
  background: #f0f0ee; color: var(--c-muted);
  padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-family: ui-monospace, SF Mono, monospace;
}
/* Dataset 切換 segmented — 2026-06-02 v0.8.0 */
.dataset-tabs {
  display: inline-flex;
  background: #f0f0ee;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--c-border);
}
.ds-tab {
  padding: 4px 11px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.ds-tab:hover {
  background: rgba(255,255,255,0.6);
  color: var(--c-text);
  text-decoration: none;
}
.ds-tab.active {
  background: #fff;
  color: var(--c-accent-dark);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
html[data-theme="dark"] .dataset-tabs {
  background: #2a2f37;
  border-color: #3a4049;
}
html[data-theme="dark"] .ds-tab { color: #aab2bd; }
html[data-theme="dark"] .ds-tab:hover { background: #353b44; color: #e8ebf0; }
html[data-theme="dark"] .ds-tab.active {
  background: #1e88e5;
  color: #fff;
  box-shadow: 0 1px 4px rgba(30,136,229,0.4);
}
.mainnav { display: flex; gap: 4px; }
.navlink {
  padding: 8px 14px; border-radius: 6px;
  color: var(--c-text); font-size: 14px;
}
.navlink:hover { background: #f0f0ee; text-decoration: none; }
.navlink.active { background: var(--c-accent); color: #fff; }
.navlink.active:hover { background: var(--c-accent-dark); }

/* ⚙️ API 設定按鈕（topbar 右側） */
.ak-btn {
  border: 1px solid var(--c-border); background: #fff; cursor: pointer;
  font: inherit; display: inline-flex; align-items: center; gap: 6px;
}
.ak-status {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: #f5e6e6; color: #8a4a4a;
}
.ak-status.ok { background: #e1f3df; color: #25602a; }

/* API 金鑰 modal */
.ak-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.ak-overlay[hidden] { display: none; }
.ak-modal {
  background: var(--c-panel); border-radius: var(--radius);
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.ak-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: var(--c-panel); z-index: 1;
}
.ak-head h2 { margin: 0; font-size: 16px; }
.ak-close {
  background: transparent; border: none; font-size: 18px;
  cursor: pointer; color: var(--c-muted); padding: 4px 8px;
}
.ak-body { padding: 16px 18px 18px; }
.ak-hint { color: var(--c-muted); font-size: 12.5px; margin: 0 0 12px; }
.ak-field { display: block; margin-bottom: 12px; }
.ak-field > span { display: block; font-weight: 500; margin-bottom: 4px; }
.ak-field > span small { color: var(--c-muted); font-weight: normal; }
.ak-field input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--c-border);
  border-radius: 6px; font: inherit; font-family: ui-monospace, SF Mono, monospace;
}
.ak-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.ak-show { color: var(--c-muted); font-size: 12px; cursor: pointer; }
.ak-tutorial {
  margin-top: 18px; border-top: 1px solid var(--c-border); padding-top: 14px;
}
.ak-tutorial summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.ak-tutorial h3 { font-size: 14px; margin: 14px 0 6px; }
.ak-tutorial ol { margin: 0 0 10px 20px; padding: 0; }
.ak-tutorial li { margin-bottom: 4px; }
.ak-tutorial code {
  background: #f0f0ee; padding: 1px 5px; border-radius: 3px;
  font-size: 12px;
}

.content { padding: 16px 24px 40px; }

.btn {
  border: 1px solid var(--c-border); background: #fff; color: var(--c-text);
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 500;
}
.btn:hover:not(:disabled) { background: #f5f5f3; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--c-accent-dark); }
.btn.ghost { background: transparent; }
.btn-link { color: var(--c-accent); padding: 6px 10px; border-radius: 6px; }
.btn-link:hover { background: #eef4fb; text-decoration: none; }
.count-badge {
  display: inline-block; background: #efeeec; color: var(--c-text);
  border-radius: 10px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
/* v0.4.8 提案籃計數 — 強調有內容時 */
#basket-count {
  background: #d04848;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  padding: 3px 13px;
  border-radius: 14px;
  min-width: 28px;
  text-align: center;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(208, 72, 72, 0.3);
  transition: all 0.2s;
  display: inline-block;
}
#basket-count:empty,
#basket-count[data-empty="1"] { background: #d8d8d6; color: #999; box-shadow: none; }
#basket-count.bump {
  animation: basket-bump 0.55s ease-out 1;
}
@keyframes basket-bump {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.45); background: #ff6b48; }
  60%  { transform: scale(0.94); }
  100% { transform: scale(1); background: #d04848; }
}

/* Database */
.db-page { display: flex; flex-direction: column; gap: 12px; }
.db-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: var(--c-panel); padding: 10px 14px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.view-tabs { display: flex; gap: 4px; }
.tab {
  border: 1px solid var(--c-border); background: #fff;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type="search"], .filters select {
  border: 1px solid var(--c-border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; background: #fff;
}
.filters input[type="search"] { min-width: 240px; }

.db-view { display: none; }
.db-view.active { display: block; }

.table-wrap {
  overflow: auto; max-height: calc(100vh - 220px);
  background: var(--c-panel);
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--c-border); vertical-align: top;
}
.data-table th {
  background: #f5f5f3; font-weight: 600;
  position: sticky; top: 0; z-index: 1;
}
.data-table tbody tr:nth-child(even) { background: var(--c-row-alt); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.src { color: var(--c-muted); font-size: 11px; max-width: 260px; word-break: break-all; }
.tag-chip {
  display: inline-block; background: #eef4fb; color: var(--c-accent-dark);
  padding: 1px 7px; border-radius: 8px;
  font-size: 11px; margin: 1px 2px 1px 0; white-space: nowrap;
}

.tree-root {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 8px 12px;
  max-height: calc(100vh - 220px); overflow: auto;
}
.tree-node { margin: 2px 0; }
.tree-header {
  cursor: pointer; padding: 6px 8px; border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
}
.tree-header:hover { background: #f0f0ee; }
.tree-header .twisty { width: 14px; color: var(--c-muted); }
.tree-header .t-name { font-weight: 500; }
.tree-header .t-count { color: var(--c-muted); font-size: 12px; }
/* 委員會（最外層）：背景與粗體強化 */
.tree-header.tree-committee {
  background: #eef4fb; font-size: 15px;
  border-left: 3px solid var(--c-accent);
}
.tree-header.tree-committee .t-name { font-weight: 700; color: var(--c-accent-dark); }
.tree-header.tree-committee:hover { background: #dde9f5; }
/* 部會（第二層） */
.tree-header.tree-ministry {
  background: #f7f5f0;
  border-left: 3px solid #c9a050;
}
.tree-header.tree-ministry .t-name { font-weight: 600; color: #6a4d18; }
.tree-header.tree-ministry:hover { background: #efeadc; }
/* 預算類型分隔線（部會內視覺分組，非可點節點） */
.tree-type-divider {
  margin: 6px 8px 2px 22px;
  padding: 2px 8px;
  font-size: 12px; color: #888;
  border-bottom: 1px dashed #d0d0cd;
  font-weight: 500;
}
.tree-children { margin-left: 22px; display: none; }
.tree-node.open > .tree-children { display: block; }
.tree-item {
  padding: 4px 8px; font-size: 13px;
  border-left: 2px solid transparent; margin-left: 22px;
  display: grid; grid-template-columns: 50px 1fr 140px 110px; gap: 10px;
}
.tree-item:hover { background: #f6f6f4; border-left-color: var(--c-accent); }
.tree-item .ti-page { color: var(--c-muted); }
.tree-item .ti-num { text-align: right; font-variant-numeric: tabular-nums; }

/* Workspace */
.ws-page {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 1.8fr;
  gap: 16px; align-items: start;
}
.ws-left, .ws-right {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 14px;
}
.ws-search-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ws-search-bar input, .ws-search-bar select {
  border: 1px solid var(--c-border); border-radius: 6px;
  padding: 7px 10px; font-size: 13px;
}
.ws-search-bar input[type="search"] { flex: 1; min-width: 220px; }

.ws-results-meta {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--c-muted); font-size: 12px; margin-bottom: 8px;
}
.ws-results-meta .hint { font-style: italic; }

.ws-results {
  list-style: none; padding: 0; margin: 0;
  max-height: calc(100vh - 230px); overflow: auto;
  border-top: 1px solid var(--c-border);
}
.ws-results li.r-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 8px; padding: 10px;
  border-bottom: 1px solid var(--c-border); align-items: center;
}
.ws-results li.r-item:hover { background: #fafaf9; }
.r-info .r-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.r-info .r-meta {
  color: var(--c-muted); font-size: 12px;
  display: flex; flex-wrap: wrap; gap: 10px;
}
.r-info .r-meta b { color: var(--c-text); font-variant-numeric: tabular-nums; }
.r-info .r-tags { margin-top: 4px; }
.btn-add {
  background: var(--c-accent); color: #fff; border: none;
  padding: 7px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; white-space: nowrap;
}
.btn-add:hover:not(:disabled) { background: var(--c-accent-dark); }
.btn-add.added { background: var(--c-ok); }
.btn-add:disabled { cursor: not-allowed; opacity: 0.85; }

.basket-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; gap: 8px; flex-wrap: wrap;
}
.basket-head h2 {
  margin: 0; font-size: 16px;
  display: flex; gap: 8px; align-items: center;
}
.basket-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.basket-global {
  display: flex; flex-direction: column; gap: 6px;
  background: #fafaf9; border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px;
}
.basket-global .bg-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.basket-global .bg-row span { color: var(--c-muted); min-width: 88px; }
.basket-global .bg-row input {
  flex: 1; min-width: 0;
  border: 1px solid var(--c-border); border-radius: 5px;
  padding: 5px 8px; font-size: 13px; background: #fff;
}
.basket-global .bg-row.hint { color: var(--c-muted); font-size: 12px; }
.basket-global .bg-ratios { gap: 10px; flex-wrap: wrap; }
.basket-global .ratio-cell {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--c-text); font-size: 12px;
}
.basket-global .ratio-cell input {
  width: 4.5em; flex: none; padding: 4px 6px;
  text-align: right;
}
.btn-mini { padding: 4px 10px; font-size: 12px; }

.basket-list {
  list-style: none; padding: 0; margin: 0;
  max-height: calc(100vh - 300px); overflow: auto;
}
.basket-empty {
  color: var(--c-muted); text-align: center;
  padding: 30px 10px; font-size: 13px;
}

/* 提案卡片：上方工具列 + 下方提案表預覽 (.pp-sheet) */
.proposal-card {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: var(--radius); margin: 10px 0;
  list-style: none; overflow: hidden;
}
.pc-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; background: #f5f5f3;
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
}
.pc-toolbar .pc-no { font-weight: 700; color: var(--c-accent); }
.pc-toolbar .pc-tags { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pc-toolbar .btn-x {
  background: transparent; border: none; color: var(--c-danger);
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.btn-ai {
  background: #fef6e0; border: 1px solid #f0c97a; color: var(--c-warn);
  padding: 3px 8px; border-radius: 12px; cursor: pointer; font-size: 11px;
  white-space: nowrap;
}
.btn-ai:hover { background: #fbecc4; }
.btn-ai:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ai-pro {
  background: #e8f0fe; border: 1px solid #5b8def; color: #1554c2;
  padding: 3px 8px; border-radius: 12px; cursor: pointer; font-size: 11px;
  white-space: nowrap; font-weight: 600;
}
.btn-ai-pro:hover { background: #d3e2fc; }
.btn-ai-pro:disabled { opacity: 0.6; cursor: not-allowed; }

/* AI Pro Handoff modal — 復用 reason-* class，但增加幾個專屬樣式 */
.ai-pro-step { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ai-pro-step h3 { margin: 0; font-size: 14px; color: var(--c-text); }
.ai-pro-hint { margin: 0; color: var(--c-muted); font-size: 12px; }
.ai-pro-textarea {
  width: 100%; box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", monospace;
  font-size: 12.5px; line-height: 1.55;
  border: 1px solid var(--c-border); border-radius: 6px;
  padding: 10px 12px; background: #fafaf9; color: var(--c-text);
  resize: vertical;
}
.ai-pro-textarea:focus { outline: none; border-color: var(--c-accent); background: #fff; }
.ai-pro-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.ai-pro-meta { color: var(--c-muted); font-size: 11px; }

/* 提案表預覽：仿 docx 標楷體版面 — 用自然 inline 流，不要 flex
   字級用 pt（列印單位），確保不會小於 15pt */
.pp-sheet {
  font-family: "DFKai-SB", "BiauKai", "標楷體", "Kaiti TC", "STKaiti", serif;
  font-size: 15pt; line-height: 1.9; color: #000;
  padding: 22px 26px; background: #fff;
  position: relative;   /* AI 載入 overlay 以此為定位基準 */
}
.pp-title {
  font-size: 15pt; word-break: break-word;
}
.pp-committee {
  font-weight: 600;
  border-bottom: 1px dashed #b8b8b8;
  min-width: 8em; display: inline-block; line-height: 1.4;
}
/* 每行：block 元素，內部 span/input 自然 inline 流動 */
.pp-line {
  display: block; margin: 0;
  white-space: normal; word-break: break-word;
}
.pp-line.pp-muted { color: #777; }
/* 凍結數縮排，對齊「減列數」起始位置。
   「〔●〕歲出—〔●〕減」前綴 = 9 個 CJK 字寬 (〔●〕=3 + 歲+出+— = 3 + 〔●〕=3)
   「凍」前綴 = indent + 〔●〕(3) = 9，故 indent = 6em */
.pp-line.pp-indent { text-indent: 6em; }
.pp-spacer { height: 0.9em; }

.pp-unit, .pp-page, .pp-kxmj {
  font-weight: 600;
}
/* 填空格底線：模擬樣本的「___值___」樣式（只在文字下方，不要 inline-block 撐寬） */
.pp-subject, .pp-usage {
  font-weight: 600;
  border-bottom: 1px solid #000;
  padding: 0 8px;
}

/* 「[」型左側括弧：只有左邊一條垂直線 + 上下兩個短「勾子」，右側完全不畫 */
.pp-bracket {
  position: relative;
  border-left: 1px solid #000;
  padding: 4px 0 4px 10px;
  margin: 2px 0;
}
.pp-bracket::before,
.pp-bracket::after {
  content: ""; position: absolute; left: 0;
  width: 8px; height: 1px; background: #000;
}
.pp-bracket::before { top: 0; }
.pp-bracket::after { bottom: 0; }

/* 行內可編輯數字欄位：底線樣式、寬度自動跟隨內容 */
.pp-num {
  font-family: inherit; font-size: 15pt; color: #000;
  border: none; border-bottom: 1px solid #999;
  background: transparent; padding: 0 4px;
  width: 5em; text-align: right;
  vertical-align: baseline;
  -webkit-appearance: none; -moz-appearance: textfield; appearance: none;
}
.pp-num.pp-num-wide { width: 6.5em; }
.pp-num::-webkit-outer-spin-button,
.pp-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pp-num:focus { outline: none; border-bottom-color: var(--c-accent); background: #f7fbff; }

.pp-reason {
  display: block; width: 100%; box-sizing: border-box;
  font-family: inherit; font-size: 15pt; line-height: 1.9;
  border: 1px dashed #ccc; border-radius: 4px;
  padding: 8px 10px; resize: vertical;
  background: #fff; color: #000;
  margin: 4px 0;
}
.pp-reason:focus { outline: none; border-color: var(--c-accent); background: #fbfdff; }
/* 列印用案由（螢幕隱藏，列印時取代 textarea 以利跨頁印全文）*/
.pp-reason-print { display: none; }
/* 金額國字大寫（壹億…元整）— 正式提案格式，螢幕+列印都顯示 */
.pp-cap { margin-left: 6px; color: #333; font-size: 0.95em; letter-spacing: 0.5px; }
html[data-theme="dark"] .pp-sheet .pp-cap { color: #000 !important; }

/* 提案表縮放（看全貌用）— 只影響螢幕，不影響列印/Word */
.pp-sheet { zoom: var(--pp-zoom, 1); }
.pp-zoom {
  display: inline-flex; align-items: center; gap: 2px;
  margin-right: 8px; padding: 2px; border-radius: 8px;
  background: #f0f0ee; border: 1px solid var(--c-border);
}
.pp-zoom button {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 4px 8px; border-radius: 6px;
  color: var(--c-text); font-family: inherit;
}
.pp-zoom button:hover { background: rgba(0,0,0,0.06); }
.pp-zoom #pp-zoom-level {
  font-size: 12px; min-width: 40px; text-align: center;
  color: var(--c-muted); font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .pp-zoom { background: #1b2740; border-color: var(--c-border); }
html[data-theme="dark"] .pp-zoom button { color: var(--c-dim); }
html[data-theme="dark"] .pp-zoom button:hover { background: rgba(34,211,238,0.14); color: var(--c-accent-bright); }

.pp-proposer-input {
  font-family: inherit; font-size: 15pt; color: #000;
  border: none; border-bottom: 1px solid #999;
  background: transparent; padding: 0 4px;
  width: 8em; vertical-align: baseline;
  -webkit-appearance: none; appearance: none;
}
.pp-proposer-input:focus { outline: none; border-bottom-color: var(--c-accent); background: #f7fbff; }

.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: #2a2a2c; color: #fff;
  padding: 10px 18px; border-radius: 20px;
  font-size: 13px; z-index: 1000;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 1000px) {
  .ws-page { grid-template-columns: 1fr; }
}

/* ---------- Reason Engine Modal ---------- */

.tree-item .ti-actions {
  display: flex; gap: 4px; justify-content: flex-end;
}
.btn-reason-mini {
  background: #faf4dc; border: 1px solid #e9c45a; color: #5a3f00;
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  cursor: pointer; white-space: nowrap;
}
.btn-reason-mini:hover { background: #f5e9b6; }
/* 燈號版本：綠＝建議輕度處分，紅＝可考慮處分。右鍵翻面 */
.btn-reason-mini.btn-light-green {
  background: #e1f3df; border-color: #6ab669; color: #25602a;
}
.btn-reason-mini.btn-light-green:hover { background: #cdebca; }
.btn-reason-mini.btn-light-red {
  background: #fbe2e2; border-color: #d96a6a; color: #7a1f1f;
}
.btn-reason-mini.btn-light-red:hover { background: #f6cccc; }

.reason-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 20, 22, 0.55);
  z-index: 2000;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto;
}
.reason-overlay[hidden] { display: none !important; }
.reason-modal {
  background: var(--c-panel);
  width: 100%; max-width: 800px;
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
}
.reason-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--c-border);
}
.reason-modal-head h2 { margin: 0; font-size: 17px; }
.reason-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 18px; color: var(--c-muted); padding: 4px 8px;
}
.reason-close:hover { color: var(--c-text); }
.reason-modal-body {
  padding: 16px 20px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 14px;
}
.reason-modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--c-border);
  display: flex; gap: 8px; justify-content: flex-end;
}

.reason-item-info {
  background: #f5f5f3; border-radius: 6px;
  padding: 10px 12px; font-size: 13px;
  display: flex; flex-direction: column; gap: 4px;
}
.reason-item-info b { font-weight: 600; }
.reason-item-info .ri-account { color: var(--c-muted); font-size: 12px; }

.reason-issue-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.reason-issue-row label {
  flex: 1; display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--c-muted);
}
.reason-issue-row textarea {
  border: 1px solid var(--c-border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-family: inherit;
  resize: vertical;
}

/* 雙模式按鈕列 */
.reason-mode-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 6px 0;
}
.reason-btn-pro {
  background: linear-gradient(135deg, #5b8def 0%, #6e5cff 100%);
  border-color: #4a78e0;
  font-weight: 600;
}
.reason-btn-pro:hover:not(:disabled) {
  background: linear-gradient(135deg, #4a78e0 0%, #5c4ce0 100%);
}
.reason-mode-badge {
  font-size: 11px; color: var(--c-muted);
  background: #f0f0ee; border-radius: 10px; padding: 2px 8px;
}
.reason-mode-badge.free { background: #eef4fb; color: var(--c-accent-dark); }
.reason-mode-badge.pro { background: #ede9ff; color: #4a35a8; font-weight: 600; }
.reason-mode-badge.mocked { background: #fef3c7; color: #92400e; }

/* Pro section 樣式 */
.reason-pro-section {
  background: linear-gradient(180deg, #faf9ff 0%, #f5f3ff 100%);
  border: 1px solid #d6cffb; border-radius: 8px; padding: 12px 14px;
}
.reason-pro-section h3 { color: #4a35a8; }
.reason-pro-model-info {
  display: grid; gap: 4px; margin-bottom: 8px; font-size: 13px;
}
.reason-pro-model-info .mi-row {
  display: grid; grid-template-columns: 90px 1fr; align-items: baseline;
}
.reason-pro-model-info .mi-k { color: var(--c-muted); }
.reason-pro-model-info .mi-v { font-family: ui-monospace, SF Mono, monospace; }
.reason-pro-chain {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin-bottom: 8px;
}
.reason-pro-chain-cell {
  background: #fff; border-radius: 6px; padding: 8px 10px;
  border: 1px solid #e0d8f5;
}
.reason-pro-chain-cell .cell-label {
  font-size: 11px; color: var(--c-muted); margin-bottom: 2px;
}
.reason-pro-chain-cell .cell-value {
  font-size: 12px; font-weight: 600; color: var(--c-text);
}
.reason-pro-chain-cell.ok .cell-value { color: var(--c-ok); }
.reason-pro-chain-cell.fail .cell-value { color: var(--c-danger); }
.reason-pro-validation {
  margin: 6px 0;
}
.reason-pro-validation .v-line {
  font-size: 12px; margin: 2px 0;
}
.reason-pro-validation .v-err { color: var(--c-danger); }
.reason-pro-validation .v-warn { color: var(--c-warn); }
.reason-pro-validation .v-ok { color: var(--c-ok); }
.reason-pro-details { margin-top: 8px; }
.reason-pro-details summary {
  cursor: pointer; font-size: 12px; color: var(--c-muted);
  user-select: none;
}

.reason-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; background: #eef4fb; border-radius: 6px;
  color: var(--c-accent-dark);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #c8ddf2; border-top-color: var(--c-accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.reason-error {
  padding: 12px 14px; background: #fdecea;
  border: 1px solid #f5c2c0; border-radius: 6px;
  color: #b3261e; font-size: 13px; white-space: pre-wrap;
}

.reason-result { display: flex; flex-direction: column; gap: 14px; }

.reason-warn {
  padding: 10px 14px; background: #fff8dc;
  border: 1px solid #e9c45a; border-radius: 6px;
  color: #5a3f00; font-size: 13px;
}
.reason-warn-light {
  background: #fbf6e6; border-color: #f0d98f;
}

.reason-action-row {
  display: flex; align-items: center; gap: 12px;
  background: #eef4fb; border-radius: 6px; padding: 12px 16px;
}
.reason-action-label { color: var(--c-muted); font-size: 12px; }
.reason-action-value {
  font-size: 22px; font-weight: 700; color: var(--c-accent-dark);
}
.reason-action-amount {
  margin-left: auto; color: var(--c-text); font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.reason-scores {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.reason-score { display: flex; flex-direction: column; gap: 4px; }
.reason-score-label { font-size: 12px; color: var(--c-muted); }
.reason-bar {
  height: 8px; background: #efeeec; border-radius: 4px; overflow: hidden;
}
.reason-bar-fill { height: 100%; width: 0%; transition: width 0.4s; }
.reason-bar-strength { background: var(--c-accent); }
.reason-bar-risk { background: #c0392b; }
.reason-score-text {
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--c-text);
}

.reason-section h3 {
  margin: 0 0 6px 0; font-size: 14px; font-weight: 600;
  color: var(--c-text);
}
.reason-md {
  background: #fafaf9; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 12px 14px; font-size: 13px; line-height: 1.7;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", monospace;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto; margin: 0;
}
.reason-legi-meta {
  font-size: 12px; color: var(--c-muted); margin-bottom: 6px;
}
.reason-legi-list {
  margin: 0; padding-left: 22px;
  display: flex; flex-direction: column; gap: 8px;
}
.reason-legi-list li {
  font-size: 13px;
}
.reason-legi-list .ll-meta {
  color: var(--c-muted); font-size: 11px; margin-top: 2px;
}
.reason-legi-list .ll-score {
  display: inline-block; background: #eef4fb; color: var(--c-accent-dark);
  border-radius: 8px; padding: 1px 7px; font-size: 11px; margin-right: 6px;
  font-variant-numeric: tabular-nums;
}
.reason-missing-list {
  margin: 0; padding-left: 22px; font-size: 13px;
  color: var(--c-text);
}
.reason-missing-list li { margin: 3px 0; }

/* ---------- 列印 ---------- */
/* @page 必須放在 @media print 外層（部分瀏覽器在巢狀內會忽略） */
@page { size: A4 portrait; margin: 1.8cm 1.8cm; }

@media print {
  html, body { background: #fff !important; }
  /* 🖨 全站字級縮放（topbar A± → .content zoom:var(--app-zoom)）不得跟進列印：
     CSS zoom 會直接縮放列印輸出 → 放大過爆出 A4、縮小過整頁縮水（用戶 2026-07-04
     「視窗放大縮小過列印就跑版」真因）。列印一律回 1，螢幕縮放只影響螢幕。 */
  .content { zoom: 1 !important; }
  .no-print, .toast, #__toast { display: none !important; }
  /* 浮動釘選 popup（popup.js .ml-popup）在列印時必須隱藏 — 只印提案單，
     不印 sidebar 的釘選 detail 視窗。包含 backdrop / overlay 同類。 */
  .ml-popup,
  .ml-popup-backdrop,
  .popup-overlay { display: none !important; }
  .topbar, .content { padding: 0 !important; }
  .ws-page { display: block !important; gap: 0 !important; }
  .ws-right {
    background: transparent !important;
    border: none !important; padding: 0 !important;
  }
  .basket-list { max-height: none !important; overflow: visible !important; }
  .proposal-card {
    background: transparent !important; border: none !important;
    margin: 0 !important;
    /* 每張提案表從新頁開始；但長案由(>1頁)要能流到下一頁不截字 → inside auto */
    page-break-inside: auto;
    page-break-after: always;
  }
  .proposal-card:last-child { page-break-after: auto; }
  .pc-toolbar { display: none !important; }
  .pp-sheet { padding: 0 !important; zoom: 1 !important; }  /* 列印恢復原尺寸，不受螢幕縮放影響 */
  /* 列印時保留底線（樣本即填空底線格式），其餘樣式淨化。
     appearance:none 去掉瀏覽器列印 input 預設的「圓角外框」（用戶 2026-06-23：文字不該有外框）。*/
  .pp-num, .pp-proposer-input {
    -webkit-appearance: none !important; appearance: none !important;
    border: none !important;
    border-bottom: 1px solid #000 !important;
    background: transparent !important;
    color: #000 !important; padding: 0 4px !important;
    width: auto !important; min-width: 4em;
    border-radius: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  /* 金額欄列印定寬：input 的 width:auto = 瀏覽器預設約 20 字寬 → 底線過長把大寫金額擠爆、
     國字在括號中間斷行（用戶 2026-10-21）。定寬到足以容納 9 位數含逗號、靠右。 */
  .pp-num {
    width: 6em !important; min-width: 0 !important;
    text-align: right !important; box-sizing: border-box;
  }
  .pp-num.pp-num-wide { width: 7.5em !important; }
  /* 國字大寫金額整段不可拆：放不下就整塊掉到下一行（從左緣起），絕不在（…元整）中間斷 */
  .pp-cap {
    display: inline-block; white-space: nowrap;
    font-size: 0.8em; letter-spacing: 0; margin-left: 2px;
    text-indent: 0;   /* 不繼承 .pp-indent 的 6em 首行縮排 */
    color: #000 !important;
  }
  /* textarea 無法跨頁、長文會截字 → 列印時隱藏，改印可流動的 .pp-reason-print div */
  .pp-reason { display: none !important; }
  .pp-reason-print {
    display: block !important;
    white-space: pre-wrap; word-break: break-word;
    font-family: inherit; font-size: 15pt; line-height: 1.9;
    color: #000 !important; margin: 4px 0;
    page-break-inside: auto;   /* 允許在段落間斷頁 */
    orphans: 2; widows: 2;
  }
  .pp-reason::placeholder { color: transparent !important; }
  .pp-proposer-input::placeholder { color: transparent !important; }
  .pp-committee { border-bottom: none !important; }
  /* 列印時 [ 括弧保留為黑色實線（含 hooks） */
  .pp-bracket {
    border-color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .pp-bracket::before,
  .pp-bracket::after {
    background: #000 !important;
  }
}

/* === 4.0 資料庫頁專屬 === */
.db4-page { display: flex; flex-direction: column; gap: 18px; }
.muted { color: var(--c-muted); font-size: 13px; }

/* =================================================
   v0.8.0 (2026-05-31) /database 主頁總覽 dashboard
   取代舊 /dashboard 獨立頁；4 區塊整合進主頁
   ================================================= */
.db4-overview {
  display: flex; flex-direction: column; gap: 14px;
  margin-bottom: 4px;
}

/* Hero — 大標題 + 大數字 */
.dbov-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 24px;
  align-items: center;
  background: linear-gradient(135deg, #f8fafc 0%, #eef4fa 100%);
  border: 1px solid var(--c-border); border-radius: 12px;
  padding: 20px 26px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dbov-hero-text { min-width: 0; }
.dbov-eyebrow {
  font-size: 12px; font-weight: 600; color: #7c8597;
  letter-spacing: 1px; text-transform: uppercase;
}
.dbov-title {
  margin: 4px 0 6px; font-size: 26px; font-weight: 800;
  color: #1f2937; letter-spacing: 0.5px;
}
.dbov-tagline { margin: 0; font-size: 13px; }
.dbov-tagline code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 3px; }
.dbov-tagline a { color: #2563eb; text-decoration: none; }
.dbov-tagline a:hover { text-decoration: underline; }
.dbov-hero-grand {
  text-align: right; padding-left: 18px;
  border-left: 3px solid #2563eb;
}
.dbov-grand-lab { font-size: 12px; color: #6b7280; }
.dbov-grand-amt {
  font-size: 32px; font-weight: 800; color: #1e40af;
  margin: 4px 0; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.dbov-grand-sub { font-size: 11px; }
@media (max-width: 768px) {
  .dbov-hero { grid-template-columns: 1fr; }
  .dbov-hero-grand { text-align: left; padding-left: 0; padding-top: 14px;
                     border-left: none; border-top: 3px solid #2563eb; }
}

/* Block — 共用容器 */
.dbov-block {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 14px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.dbov-block-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.dbov-pill {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  padding: 3px 9px; border-radius: 10px;
  text-transform: uppercase;
}
.dbov-pill-official { background: #fef3c7; color: #92400e; }
.dbov-pill-our      { background: #dbeafe; color: #1e40af; }
.dbov-pill-rank     { background: #ddd6fe; color: #5b21b6; }
.dbov-block-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--c-text); }
.dbov-block-sub { font-size: 12px; }

/* 4-card grids */
.dbov-cards {
  display: grid; gap: 12px;
}
.dbov-cards-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .dbov-cards-4 { grid-template-columns: repeat(2, 1fr); } }

/* v0.8.5 (2026-06-24) 左（歲出 headline + 3 小卡）｜右（進入預算星河大按鈕）2 欄 */
.dbov-block-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch;
}
.dbov-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dbov-exp-head .cdf-val { font-size: 30px; }      /* 歲出主數字較大 */
.dbov-cards-3 { grid-template-columns: repeat(3, 1fr); }
.dbov-cards-sm .dbov-card { padding: 8px 11px; border-left-width: 3px; gap: 1px; }
.dbov-cards-sm .cdf-lab { font-size: 11px; }
.dbov-cards-sm .cdf-val { font-size: 16.5px; }
.dbov-cards-sm .cdf-sub { font-size: 10px; }
@media (max-width: 860px) {
  .dbov-block-split { grid-template-columns: 1fr; }
  .dbov-cards-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) { .dbov-cards-3 { grid-template-columns: 1fr; } }

/* 🌌 進入預算星河 — 精緻科幻大按鈕（取代頂列 navlink） */
.cosmos-enter {
  position: relative; overflow: hidden; text-decoration: none;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  min-height: 100%; padding: 24px 28px; border-radius: 16px;
  background:
    radial-gradient(130% 150% at 12% 8%, rgba(124,58,237,.40), transparent 55%),
    radial-gradient(130% 150% at 88% 92%, rgba(56,189,248,.34), transparent 55%),
    linear-gradient(135deg, #0a0f20, #131b36 58%, #090d1c);
  border: 1px solid rgba(124,158,255,.34);
  box-shadow: 0 0 0 1px rgba(124,158,255,.06) inset,
              0 12px 44px rgba(56,99,255,.20), 0 0 70px rgba(124,58,237,.12);
  color: #eaf2ff; transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.cosmos-enter:hover {
  transform: translateY(-2px);
  border-color: rgba(140,170,255,.75);
  box-shadow: 0 0 0 1px rgba(140,170,255,.18) inset,
              0 16px 60px rgba(56,99,255,.36), 0 0 110px rgba(124,58,237,.24);
}
.cosmos-enter-ic {
  font-size: 44px; line-height: 1; flex: none;
  filter: drop-shadow(0 0 16px rgba(140,170,255,.75));
  animation: cosmosFloat 6s ease-in-out infinite;
}
@keyframes cosmosFloat { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-4px) } }
.cosmos-enter-txt b {
  display: block; font-size: 22px; font-weight: 800; letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(140,170,255,.55);
}
.cosmos-enter-txt i {
  display: block; font-style: normal; font-size: 12.5px; color: #9fb3e0; margin-top: 5px;
  letter-spacing: .5px;
}
/* 星點閃爍 */
.cosmos-enter-stars {
  position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(1.5px 1.5px at 18% 28%, #fff, transparent),
    radial-gradient(1px 1px at 68% 62%, #cfe3ff, transparent),
    radial-gradient(1.3px 1.3px at 42% 78%, #fff, transparent),
    radial-gradient(1px 1px at 84% 22%, #bcd4ff, transparent),
    radial-gradient(1px 1px at 55% 42%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 30% 58%, #e8f0ff, transparent),
    radial-gradient(1px 1px at 92% 70%, #fff, transparent);
  animation: cosmosTwinkle 4.2s ease-in-out infinite;
}
@keyframes cosmosTwinkle { 0%,100% { opacity: .32 } 50% { opacity: .72 } }
/* 掃光 */
.cosmos-enter::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 38%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(180,200,255,.16), transparent);
  transform: skewX(-18deg); animation: cosmosSweep 6s ease-in-out infinite;
}
@keyframes cosmosSweep { 0% { left: -60% } 38%,100% { left: 135% } }
@media (prefers-reduced-motion: reduce) {
  .cosmos-enter-ic, .cosmos-enter-stars, .cosmos-enter::after { animation: none; }
}
.dbov-card {
  padding: 12px 14px; background: #fafaf7;
  border-left: 4px solid var(--c-border); border-radius: 4px;
  display: flex; flex-direction: column; gap: 3px;
}
/* 官方 4 分項配色 (繼承 .dbf-* 配色) */
.dbov-card.cdf-exp       { border-left-color: #2563eb; }
.dbov-card.cdf-debt      { border-left-color: #f59e0b; }
.dbov-card.cdf-deficit   { border-left-color: #ef4444; }
.dbov-card.cdf-financing { border-left-color: #8b5cf6; }
.dbov-card .cdf-lab { font-size: 12.5px; color: #6b6b6b; font-weight: 500; }
.dbov-card .cdf-val { font-size: 22px; font-weight: 700; color: #222;
                      font-variant-numeric: tabular-nums; }
.dbov-card .cdf-sub { font-size: 11px; color: #8a8a8a; }
/* v0.8.3 (2026-06-01) 即時加總顯示 — 本系統 vs 官方 對帳 */
.dbov-card .cdf-live { font-size: 11px; color: #8a8a8a; margin-top: 2px;
                       font-variant-numeric: tabular-nums; }
.dbov-card .cdf-live .cdf-live-over  { color: #c0392b; font-weight: 600; }
.dbov-card .cdf-live .cdf-live-under { color: #2563eb; font-weight: 600; }
.dbov-card .cdf-live .cdf-live-ok    { color: #16a34a; font-weight: 600; }
.dbov-card .cdf-live .cdf-live-bd    { color: #9a9a9a; font-size: 10px; margin-top: 1px;
                                       line-height: 1.4; cursor: help; }
html[data-theme="dark"] .dbov-card .cdf-live .cdf-live-ok { color: #4ade80; }
html[data-theme="dark"] .dbov-card .cdf-live .cdf-live-bd { color: #6b7a8d; }
/* 部會卡主數字也用 tabular-nums 動畫期間數字不抖 */
.mc-total-amt { font-variant-numeric: tabular-nums; }
/* 解析 4 卡配色 */
.dbov-card.cdo-min   { border-left-color: #14b8a6; }
.dbov-card.cdo-items { border-left-color: #0ea5e9; }
.dbov-card.cdo-fund  { border-left-color: #d4af37; }
.dbov-card.cdo-prog  { border-left-color: #22c55e; }
.dbov-card .cdo-icon { font-size: 18px; opacity: 0.7; margin-bottom: -2px; }
.dbov-card .cdo-lab  { font-size: 12.5px; color: #6b6b6b; font-weight: 500; }
.dbov-card .cdo-val  { font-size: 22px; font-weight: 700; color: #222;
                       font-variant-numeric: tabular-nums; }
.dbov-card .cdo-sub  { font-size: 11px; color: #8a8a8a; }
.cdo-tag {
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  background: #d4af37; color: #4a3a00; border-radius: 8px;
  margin-left: 4px; vertical-align: middle;
}

/* Top 8 部會 ranking — 條狀 */
.dbov-ranking {
  display: flex; flex-direction: column; gap: 6px;
}
.dbov-rank-row {
  display: grid;
  grid-template-columns: 28px minmax(120px, 200px) 1fr 100px;
  align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 5px;
  text-decoration: none; color: inherit;
  background: #fbfbf8;
  border: 1px solid transparent;
  transition: border-color .1s, background .1s;
}
.dbov-rank-row:hover {
  background: #f0f7ff; border-color: #c5d9e8;
}
.dbov-rank-no {
  font-size: 13px; font-weight: 700; color: #6b7280;
  text-align: center;
}
.dbov-rank-row:nth-child(1) .dbov-rank-no { color: #c9920a; }
.dbov-rank-row:nth-child(2) .dbov-rank-no { color: #9ca3af; }
.dbov-rank-row:nth-child(3) .dbov-rank-no { color: #b67843; }
.dbov-rank-name { font-size: 13.5px; font-weight: 600; color: #1f2937; }
.dbov-rank-bar {
  height: 14px; background: #eef2f7; border-radius: 7px;
  position: relative; overflow: hidden;
}
.dbov-rank-bar-fill {
  display: block; height: 100%; border-radius: 7px;
  background: linear-gradient(90deg, #4a7fdf 0%, #2563eb 100%);
  transition: width .3s ease;
}
.dbov-rank-amt {
  font-size: 13px; font-weight: 700; color: #1e40af;
  text-align: right; font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .dbov-rank-row { grid-template-columns: 24px minmax(80px, 1fr) 1fr 80px; gap: 6px; }
  .dbov-rank-name { font-size: 12px; }
  .dbov-rank-amt  { font-size: 12px; }
}

/* Dark theme */
html[data-theme="dark"] .dbov-hero {
  background: linear-gradient(135deg, #0f1623 0%, #131c2d 100%);
  border-color: #1f2937;
}
html[data-theme="dark"] .dbov-title { color: #e2e8f0; }
html[data-theme="dark"] .dbov-grand-amt { color: #93c5fd; }
html[data-theme="dark"] .dbov-block { background: #121826; border-color: #1f2937; }
html[data-theme="dark"] .dbov-block-title { color: #d4d8e0; }
html[data-theme="dark"] .dbov-card { background: #1a2032; }
html[data-theme="dark"] .dbov-card .cdf-val, html[data-theme="dark"] .dbov-card .cdo-val { color: #e2e8f0; }
html[data-theme="dark"] .dbov-rank-row { background: #1a2032; }
html[data-theme="dark"] .dbov-rank-row:hover { background: #1e2942; }
html[data-theme="dark"] .dbov-rank-name { color: #e2e8f0; }
html[data-theme="dark"] .dbov-rank-bar { background: #2a3344; }
html[data-theme="dark"] .dbov-rank-amt { color: #93c5fd; }

/* =================================================
   Toolbar — v0.8.0 重整：分 2 區（search / filter）對齊 dashboard
   ================================================= */
.db4-toolbar {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 10px; padding: 12px 16px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.db4-tb-search {
  display: flex; gap: 10px; align-items: center; flex: 1; min-width: 260px;
}
.db4-tb-filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.db4-toolbar input[type="search"], .db4-toolbar select {
  border: 1px solid var(--c-border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; background: #fff;
}
.db4-toolbar input[type="search"] { min-width: 320px; flex: 1; max-width: 480px; }
.db4-toolbar #db4-search-stats {
  font-size: 12.5px; color: #555;
  padding: 4px 10px; border-radius: 6px;
  background: #fff8f0;
  border: 1px solid #ffe1cc;
  white-space: nowrap;
}
.db4-toolbar #db4-search-stats:empty { display: none; }

/* === 重點關注基金 banner (3 央行系統) — 2026-05-28 === */
.db4-funds-banner {
  margin: 12px 0 18px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fff8e7 0%, #fef3d0 100%);
  border: 1px solid #e8c878; border-radius: 10px;
  box-shadow: 0 1px 3px rgba(180,140,40,.08);
}
.db4-funds-banner .dfb-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px;
}
.db4-funds-banner .dfb-title { font-size: 14px; font-weight: 700; color: #7a5c0e; }
.db4-funds-banner .dfb-sub   { font-size: 12px; }
.db4-funds-banner .dfb-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.db4-funds-banner .dfb-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; border-radius: 7px;
  background: #fff; border: 1px solid #d9b961;
  text-decoration: none; color: inherit;
  transition: transform .1s, box-shadow .1s, border-color .1s;
}
.db4-funds-banner .dfb-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(180,140,40,.18);
  border-color: #b08a32;
}
.db4-funds-banner .dfb-card-name { font-weight: 700; font-size: 14.5px; color: #594110; }
.db4-funds-banner .dfb-card-amt  { font-size: 13px; font-variant-numeric: tabular-nums; }
.db4-funds-banner .dfb-amt-num   { font-weight: 700; color: #1b5e20; }
.db4-funds-banner .dfb-amt-unit  { font-size: 11px; color: #777; }
.db4-funds-banner .dfb-card-note { font-size: 11px; }
@media (max-width: 720px) {
  .db4-funds-banner .dfb-cards { grid-template-columns: 1fr; }
}

.db4-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.ministry-card {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .12s;
}
.ministry-card:hover { border-color: var(--c-accent); }
.mc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-title { font-weight: 600; font-size: 14px; }
.mc-meta { display: flex; gap: 4px; flex-wrap: wrap; }
.mc-url { font-size: 11px; word-break: break-all; }
.mc-url a { color: var(--c-accent); }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; background: #f0f0ee; color: var(--c-text);
}
.chip.ok { background: #e7f5ea; color: var(--c-ok); }
.chip.empty { background: #f5f5f3; color: var(--c-muted); font-style: italic; }

/* =================================================
   Explorer 頁（/budget-explorer/<ministry>）
   ================================================= */
.explorer-page { padding: 12px 16px 32px; }
.explorer-head h2 { margin: 0 0 6px; font-size: 18px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.explorer-head .exp-year { background: #fff7d6; color: #5e4500; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.explorer-head .exp-stats { color: var(--c-muted); font-size: 12px; font-weight: 400; }
/* v0.4.12: 款 layer collapse 後在 header 顯示強調的款 badge */
.explorer-head .exp-collapse-badges { display: inline-flex; gap: 6px; align-items: center; }
.explorer-head .exp-kuan-badge {
  background: linear-gradient(135deg, #4a7fdf, #5b8def);
  color: #fff; padding: 4px 12px; border-radius: 6px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.5px;
  border: 1px solid #25457f;
  box-shadow: 0 2px 5px rgba(74,127,223,0.25);
}
.explorer-head p { margin: 4px 0 14px; font-size: 13px; color: #555; }

/* v0.4.10 整合 header：[← 主畫面] [第 N 款] 衛福部 [年度] [切換部會] [stats] 同一列 */
.explorer-head .exp-title-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 6px;
}
.explorer-head .exp-title-bar .exp-back {
  text-decoration: none;
  flex-shrink: 0;
  /* 黃色強調「← 主畫面」回主畫面鈕（2026-06-22 用戶：主畫面按鈕不夠顯眼，用黃色）*/
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #3a2c00;
  font-weight: 800;
  border: 1px solid #d97706;
  box-shadow: 0 2px 6px rgba(245,158,11,.35);
}
.explorer-head .exp-title-bar .exp-back:hover {
  background: linear-gradient(135deg, #fcd34d, #fbbf24);
  color: #3a2c00;
  filter: brightness(1.03);
}
/* 夜色：須蓋過 html[data-theme="dark"] .btn.ghost（specificity 較高）→ 維持黃底深字 */
html[data-theme="dark"] .explorer-head .exp-title-bar .exp-back {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #3a2c00;
  border-color: #b45309;
}
html[data-theme="dark"] .explorer-head .exp-title-bar .exp-back:hover {
  background: linear-gradient(135deg, #fcd34d, #fbbf24);
  color: #3a2c00;
}
.explorer-head .exp-kuan-badge-big {
  background: linear-gradient(135deg, #4a7fdf, #5b8def);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid #25457f;
  box-shadow: 0 2px 5px rgba(74,127,223,0.25);
  flex-shrink: 0;
  white-space: nowrap;
}
.explorer-head .exp-kuan-badge-big[hidden] { display: none; }
.explorer-head h2.exp-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.explorer-head h2.exp-title .exp-ministry { color: #1a1a1a; }
.explorer-head .exp-min-switch {
  padding: 6px 28px 6px 10px;
  border: 1px solid #c8c8d0;
  border-radius: 6px;
  background-color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23555' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
  color: inherit;
  flex-shrink: 0;
  max-width: 280px;
}
.explorer-head .exp-min-switch:hover { border-color: #4a7fdf; }
.explorer-head .exp-min-switch:focus {
  outline: none;
  border-color: #4a7fdf;
  box-shadow: 0 0 0 3px rgba(74,127,223,0.2);
}
.explorer-head .exp-min-switch option[data-empty="1"] { color: #999; }
.explorer-head .exp-title-bar .exp-stats {
  color: var(--c-muted);
  font-size: 12px;
  font-weight: 400;
  margin-left: auto;
}
.explorer-head .exp-desc { margin: 4px 0 14px; font-size: 13px; color: #555; }
/* v0.7.1 (2026-05-30) 鐵律 7 — 頁面註腳：tree 數字 = 業務總支出 */
.explorer-head .exp-footnote {
  margin: 0 0 14px; padding: 6px 10px;
  background: #f5f5f5; border-left: 3px solid #ff9800;
  border-radius: 4px; font-size: 12px; color: #6d4c41; line-height: 1.5;
}
.explorer-head .exp-fn-mark { color: #f57c00; font-weight: 700; margin-right: 4px; }

@media (max-width: 720px) {
  .explorer-head .exp-title-bar { gap: 8px; }
  .explorer-head h2.exp-title { font-size: 18px; }
  .explorer-head .exp-title-bar .exp-stats { margin-left: 0; width: 100%; }
  .explorer-head .exp-min-switch { max-width: 100%; flex: 1 1 160px; }
}

.explorer-grid {
  /* v0.7.0 (2026-05-31) 三欄: 左樹 / 可拖曳分隔線 / 右詳情
     --exp-split: 左欄寬度比例（百分比 or px），存 localStorage */
  display: grid;
  grid-template-columns: var(--exp-split, 58%) 8px 1fr;
  gap: 0; align-items: start;
}
.exp-splitter {
  cursor: col-resize;
  background: transparent;
  position: relative;
  align-self: stretch;
  min-height: 200px;
  transition: background 0.15s;
  z-index: 10;
}
.exp-splitter::before {
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 2px;
  background: var(--c-border);
  transform: translateX(-50%);
  transition: background 0.15s, width 0.15s;
}
.exp-splitter::after {
  /* 中央抓手圖示 (3 個橫條) */
  content: "⋮";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: #aaa;
  font-size: 18px;
  letter-spacing: -2px;
  pointer-events: none;
  transition: color 0.15s, font-size 0.15s;
}
.exp-splitter:hover::before,
.exp-splitter.is-dragging::before {
  background: var(--c-accent);
  width: 3px;
}
.exp-splitter:hover::after,
.exp-splitter.is-dragging::after {
  color: var(--c-accent);
  font-size: 20px;
}
.exp-splitter.is-dragging {
  background: rgba(208, 72, 72, 0.05);
}
/* 拖曳期間禁用全頁 selection */
body.is-resizing,
body.is-resizing * {
  user-select: none !important;
  cursor: col-resize !important;
}
/* 加左右 padding 給 tree/detail 取代原 gap: 16px */
.exp-tree-wrap { margin-right: 4px; }
.exp-detail { margin-left: 4px; }

/* v0.7.0 詳情右欄 container query — 內部文字依容器寬度排版 */
.exp-detail {
  container-type: inline-size;
  container-name: detail;
}
.exp-detail-card {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 8px; padding: 12px;
  max-height: calc(100vh - 180px); overflow-y: auto;
}
/* 數據卡 grid 依容器寬度自動降欄 */
@container detail (max-width: 420px) {
  .ed-amts { grid-template-columns: 1fr !important; }
  .ed-amt.main { grid-column: 1 / -1; }
}
@container detail (min-width: 600px) {
  .ed-rich { font-size: 14.5px; line-height: 1.75; }
}
@container detail (min-width: 800px) {
  .ed-rich { font-size: 15.5px; line-height: 1.8; }
}

.exp-tree-wrap {
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 8px; padding: 10px; max-height: calc(100vh - 180px); overflow-y: auto;
}
.exp-toolbar { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.exp-toolbar input { flex: 1; min-width: 200px; padding: 5px 8px; border: 1px solid var(--c-border); border-radius: 5px; font-size: 13px; }
.exp-toolbar select { padding: 5px 8px; border: 1px solid var(--c-border); border-radius: 5px; font-size: 13px; background: #fff; }
.lv-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.lv-chip {
  padding: 4px 10px; border: 1px solid var(--c-border); background: #fff;
  border-radius: 14px; font-size: 12px; cursor: pointer; transition: background .12s, border-color .12s;
  color: var(--c-text); white-space: nowrap;
}
.lv-chip:hover { background: #f5f5f3; }
.lv-chip.is-active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.lv-chip.is-active:hover { background: var(--c-accent-dark); }
.btn-mini { padding: 3px 8px !important; font-size: 11px !important; }

/* v0.4.7 搜尋：tokens 計數 & 紅框高亮 */
.exp-search-stats {
  font-size: 12px;
  color: #555;
  padding: 4px 8px;
  min-height: 18px;
  margin-bottom: 4px;
}
.exp-search-stats b { color: #c0392b; font-weight: 700; font-variant-numeric: tabular-nums; }
.exp-search-stats .muted { color: #888; font-size: 11px; }
mark.hl-search {
  background: #fff2c8;
  color: #c0392b;
  font-weight: 600;
  padding: 0 1px;
  border-radius: 2px;
}
/* v0.4.8 樹節點 match 視覺 — 弱化「全紅框」改用淺色 tint + 左側細條，
   active (使用者剛點過 / gotoNode 目標) 才用強紅框 + 動畫脈動，避免大量 match 時眼花 */
.tn.is-match > .tn-row-wrap {
  background: #fff7ee;
  border-left: 3px solid #ffb169;
  border-radius: 0 4px 4px 0;
  padding-left: 4px;
}
.tn.has-descendant-match > .tn-row-wrap {
  border-left: 3px solid #ffe1cc;
}
/* 被點擊／goto 過去的「對焦那一筆」才上強紅框 + 微動畫 */
.tn.is-active-match > .tn-row-wrap {
  background: #fff0e8;
  border: 2px solid #d04848;
  border-radius: 5px;
  box-shadow: 0 0 0 3px rgba(208, 72, 72, 0.18), 0 2px 8px rgba(208, 72, 72, 0.15);
  animation: tn-active-pulse 1.2s ease-out 1;
}
@keyframes tn-active-pulse {
  0%   { box-shadow: 0 0 0 0    rgba(208, 72, 72, 0.6),  0 2px 8px rgba(208, 72, 72, 0.15); }
  50%  { box-shadow: 0 0 0 10px rgba(208, 72, 72, 0.0),  0 2px 8px rgba(208, 72, 72, 0.15); }
  100% { box-shadow: 0 0 0 3px  rgba(208, 72, 72, 0.18), 0 2px 8px rgba(208, 72, 72, 0.15); }
}

/* v0.4.8 浮動 popup 視窗（多開可拖曳比對）
   v0.7.0 (2026-05-31): 可 resize（右下角拉伸）+ container query 讓內部文字流式排版 */
.ml-popup {
  position: fixed;
  width: 480px;
  height: 540px;
  min-width: 320px;
  min-height: 240px;
  max-width: calc(100vw - 40px);
  max-height: 95vh;
  background: #fff;
  border: 1px solid #e0d6cc;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  container-type: inline-size;
  container-name: popup;
}
/* 右下角 resize 視覺 indicator (= 大小 18px) */
.ml-popup::after {
  content: "";
  position: absolute;
  bottom: 0; right: 0;
  width: 14px; height: 14px;
  background:
    linear-gradient(135deg, transparent 50%, #c0a094 50%, #c0a094 60%, transparent 60%,
                            transparent 70%, #c0a094 70%, #c0a094 80%, transparent 80%);
  pointer-events: none;
  opacity: 0.7;
  border-bottom-right-radius: 10px;
}
/* popup 內部 container query — 寬度大就放大字, 窄就收回 */
@container popup (min-width: 600px) {
  .ml-popup-body { font-size: 14px; }
  .popup-body-inner .pb-cur { font-size: 26px; }
}
@container popup (min-width: 800px) {
  .ml-popup-body { font-size: 15px; line-height: 1.75; }
  .popup-body-inner .pb-cur { font-size: 30px; }
}
@container popup (max-width: 360px) {
  .popup-body-inner .pb-amt-sub { grid-template-columns: auto 1fr !important; }
}
.ml-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #fff8f5 0%, #ffeee5 100%);
  border-bottom: 1px solid #ffe0d2;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}
.ml-popup-head::before {
  content: "⋮⋮";
  color: #c0a094;
  font-size: 14px;
  letter-spacing: -1px;
  flex-shrink: 0;
}
.ml-popup-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 12px;
  background: #f0f0ee;
  color: #555;
  font-weight: 600;
  white-space: nowrap;
}
.ml-popup-badge.badge-主管 { background: #ffe4cf; color: #8a4500; }
.ml-popup-badge.badge-機關 { background: #ffe1d6; color: #8a3a00; }
.ml-popup-badge.badge-目 { background: #fff2c8; color: #6b5200; }
.ml-popup-badge.badge-分支計畫 { background: #d6ecff; color: #1a4a7a; }
.ml-popup-badge.badge-用途別大類 { background: #e0e9ff; color: #2a3a8a; }
.ml-popup-badge.badge-用途別細項 { background: #f0f0fa; color: #555; }
.ml-popup-title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: #222;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ml-popup-mini {
  font-size: 11px;
  background: rgba(0,0,0,0.05);
  padding: 2px 7px;
  border-radius: 10px;
  color: #666;
  flex-shrink: 0;
}
.ml-popup-close,
.ml-popup-pin {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  color: #666;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  line-height: 1;
  font-weight: 500;
}
.ml-popup-close:hover {
  background: #d04848;
  color: #fff;
}
.ml-popup-pin {
  filter: grayscale(80%);
  opacity: 0.55;
}
.ml-popup-pin:hover {
  filter: none;
  opacity: 1;
  background: rgba(251, 191, 36, 0.25);
}
.ml-popup-pin.is-pinned {
  filter: none;
  opacity: 1;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.35);
}
.ml-popup-pin.is-pinned:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}
.ml-popup-body {
  overflow-y: auto;
  flex: 1;
  padding: 12px 14px;
  background: #fafafa;
}
.ml-popup-body .ed-card { box-shadow: none; border: none; background: transparent; padding: 0; }

/* 共用 popup body (popup.js buildPopupBody 用) */
.popup-body-inner { font-size: 13px; color: #333; }
.popup-body-inner .pb-amts {
  background: #fff;
  border: 1px solid #f0e6e0;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.popup-body-inner .pb-amt-main { margin-bottom: 6px; }
.popup-body-inner .pb-lab { font-size: 11px; color: #888; font-weight: 500; }
.popup-body-inner .pb-cur {
  font-size: 22px; font-weight: 700; color: #c0392b;
  font-variant-numeric: tabular-nums; letter-spacing: 0.5px;
}
.popup-body-inner .pb-amt-sub {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  gap: 4px 8px;
  align-items: baseline;
  font-size: 12px;
  border-top: 1px dashed #eee;
  padding-top: 6px;
}
.popup-body-inner .pb-amt-sub .pb-val { font-variant-numeric: tabular-nums; font-weight: 600; color: #555; }
.popup-body-inner .pb-amt-sub .pb-val.up { color: #c0392b; }
.popup-body-inner .pb-amt-sub .pb-val.down { color: #2a8854; }
.popup-body-inner .pb-code {
  font-size: 11.5px; color: #888;
  background: #f5f5f3; padding: 5px 10px; border-radius: 5px;
  margin-bottom: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.popup-body-inner .pb-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 12px;
  margin: 0 0 12px;
}
.popup-body-inner .pb-meta dt { color: #888; font-weight: 500; white-space: nowrap; }
.popup-body-inner .pb-meta dd { margin: 0; color: #333; }
.popup-body-inner .pb-meta .pb-path { color: #666; line-height: 1.5; }
.popup-body-inner .pb-section {
  background: #fff;
  border: 1px solid #f0e6e0;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.popup-body-inner .pb-section h4 {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: #555;
  font-weight: 600;
}
.popup-body-inner .pb-stub-tag {
  font-size: 10.5px;
  background: #fff8e0; color: #8a6500;
  padding: 1px 6px; border-radius: 8px;
  font-weight: 500;
}
.popup-body-inner .pb-rich {
  font-size: 12.5px;
  color: #333;
  line-height: 1.65;
}
.popup-body-inner .pb-rich div { margin-bottom: 3px; }
.popup-body-inner .pb-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.popup-body-inner .pb-cut {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(180deg, #d04848 0%, #b03838 100%);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  box-shadow: 0 1px 3px rgba(208, 72, 72, 0.3);
}
.popup-body-inner .pb-cut:hover {
  background: linear-gradient(180deg, #e05050 0%, #c04040 100%);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(208, 72, 72, 0.4);
}
.popup-body-inner .pb-cut:active { transform: translateY(0); }

/* match-list row 內的 ⊕ popup 按鈕 */
.exp-match-list .ml-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.exp-match-list .ml-popout {
  background: #fff5f2;
  border: 1px solid #ffd3c4;
  color: #c0392b;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.exp-match-list .ml-popout:hover {
  background: #d04848;
  color: #fff;
  border-color: #d04848;
  transform: scale(1.08);
}
.exp-match-list .ml-popout:active { transform: scale(0.95); }

/* v0.4.8 match-list 面板 — 卡片化重設計：大字、寬鬆、可閱讀 */
/* v0.6.9 (2026-05-30) 搜尋結果 tab 分類: 全部 / 款項目 / 基金 */
.exp-match-list .ml-tabs {
  display: flex; gap: 4px;
  padding: 6px 10px 4px;
  border-bottom: 1px solid #ffebd5;
  background: #fffaf6;
}
.exp-match-list .ml-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 16px;
  background: #fff; border: 1px solid #e6c8b3;
  color: #8b5a3c; font-size: 12px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.exp-match-list .ml-tab:hover {
  background: #fff3e9; border-color: #d49972;
}
.exp-match-list .ml-tab.is-active {
  background: #c14a1a; border-color: #c14a1a; color: #fff;
}
.exp-match-list .ml-tab-count {
  background: rgba(0,0,0,0.08); color: inherit;
  padding: 0 7px; border-radius: 10px;
  font-size: 11px; font-weight: 600; min-width: 18px;
  text-align: center;
}
.exp-match-list .ml-tab.is-active .ml-tab-count {
  background: rgba(255,255,255,0.25); color: #fff;
}
.exp-match-list .ml-row.ml-row-fund {
  background: linear-gradient(to right, #fffbe5 0%, transparent 50%);
}
.exp-match-list .ml-badge.badge-fund {
  background: #ffd700; color: #5a4a00;
}

.exp-match-list {
  background: #fff;
  border: 1px solid #ffd3c4;
  border-radius: 10px;
  margin-bottom: 12px;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(208, 72, 72, 0.06);
}
.exp-match-list .ml-head {
  padding: 12px 18px;
  font-size: 14px;
  border-bottom: 1px solid #ffe7dd;
  background: linear-gradient(180deg, #fff8f5 0%, #fff3ee 100%);
  border-radius: 10px 10px 0 0;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.exp-match-list .ml-head b {
  color: #c0392b;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 17px;
  margin: 0 3px;
}
.exp-match-list .ml-list {
  overflow-y: auto;
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.exp-match-list .ml-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  width: 100%;
  background: #fff;
  border: 1px solid #f0e6e0;
  border-radius: 8px;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  align-items: start;
  transition: all 0.12s ease;
}
.exp-match-list .ml-row:hover {
  background: #fffaf7;
  border-color: #ffc9b8;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(208, 72, 72, 0.1);
}
.exp-match-list .ml-row:active { transform: translateY(0); }
.exp-match-list .ml-row:focus-visible {
  outline: 2px solid #d04848;
  outline-offset: 1px;
}
.exp-match-list .ml-badge {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 14px;
  background: #f0f0ee;
  color: #555;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.3px;
  align-self: start;
  margin-top: 2px;
}
.exp-match-list .ml-badge.badge-主管 { background: #ffe4cf; color: #8a4500; }
.exp-match-list .ml-badge.badge-機關 { background: #ffe1d6; color: #8a3a00; }
.exp-match-list .ml-badge.badge-目 { background: #fff2c8; color: #6b5200; }
.exp-match-list .ml-badge.badge-分支計畫 { background: #d6ecff; color: #1a4a7a; }
.exp-match-list .ml-badge.badge-用途別大類 { background: #e0e9ff; color: #2a3a8a; }
.exp-match-list .ml-badge.badge-用途別細項 { background: #f0f0fa; color: #555; }
.exp-match-list .ml-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.exp-match-list .ml-name {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: #1f1f1f;
  line-height: 1.4;
  word-break: break-word;
  letter-spacing: 0.1px;
}
.exp-match-list .ml-path {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  color: #888;
  line-height: 1.5;
}
.exp-match-list .ml-path::before {
  content: "📂 ";
  opacity: 0.7;
  margin-right: 2px;
}
.exp-match-list .ml-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13.5px;
  color: #444;
  line-height: 1.7;
  background: #fffbed;
  padding: 9px 13px;
  border-radius: 6px;
  border-left: 3px solid #ffc44a;
  margin-top: 3px;
}
.exp-match-list .ml-amt {
  font-size: 15px;
  color: #c0392b;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  align-self: start;
  white-space: nowrap;
  margin-top: 2px;
  padding: 4px 10px;
  background: #fff5f2;
  border-radius: 6px;
  letter-spacing: 0.3px;
}
.exp-match-list .ml-amt::after {
  content: " 千元";
  font-size: 11px;
  color: #999;
  font-weight: 500;
  margin-left: 2px;
}
.exp-match-list .ml-empty {
  padding: 36px;
  text-align: center;
  font-size: 13px;
  color: #999;
}
.exp-match-list .ml-more {
  padding: 11px 18px;
  border-top: 1px solid #ffe7dd;
  font-size: 12.5px;
  background: #fff8f5;
  border-radius: 0 0 10px 10px;
  color: #888;
}

.exp-tree, .tn-children { list-style: none; padding: 0; margin: 0; }
.tn { border-left: 2px solid transparent; }
.tn-row {
  display: grid;
  grid-template-columns: 18px 64px 110px 1fr 140px 110px auto auto;
  gap: 6px; align-items: center;
  padding: 4px 6px 4px calc(8px + var(--depth, 0) * 16px);
  font-size: 12.5px; border-bottom: 1px dotted #eee;
  cursor: pointer;
}
.tn-row:hover { background: #fafafa; }
.tn-toggle {
  background: none; border: none; cursor: pointer; padding: 0; width: 18px;
  font-size: 10px; color: #888;
}
.tn-badge {
  display: inline-block; text-align: center; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 9px; background: #eee; color: #555;
  white-space: nowrap;
}
.tn-badge.badge-款        { background: #fff0d6; color: #8a4b00; }
.tn-badge.badge-項        { background: #ffe7e7; color: #842020; }
.tn-badge.badge-目        { background: #d6e8ff; color: #1f4e8a; }
.tn-badge.badge-分支計畫 { background: #e3f3e0; color: #2f6a1d; }
.tn-badge.badge-用途別   { background: #eee2ff; color: #4b2e7e; }
.tn-badge.badge-細目      { background: #f0e5d6; color: #5a3a16; }

.tn-code { font-family: ui-monospace, Menlo, monospace; color: #999; font-size: 11px; }
.tn-name { color: var(--c-text); }
.tn-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tn-amt.amt-xxl { color: #b80000; }
.tn-amt.amt-xl  { color: #d96b00; }
.tn-amt.amt-l   { color: #1f4e8a; }
.tn-amt.amt-m   { color: #555; font-weight: 500; }
.tn-diff { text-align: right; font-size: 11px; }
.tn-diff.diff-up   { color: #2f6a1d; }
.tn-diff.diff-down { color: #b03030; }

/* 右側：詳細卡 */
.exp-detail { position: sticky; top: 80px; }
.exp-detail-empty { background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 8px; padding: 24px; text-align: center; color: var(--c-muted); }
.ed-card { background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 8px; padding: 14px 16px; }
.ed-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ed-head h3 { margin: 0; font-size: 15px; flex: 1; }
.ed-code { font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.ed-amts { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.ed-amt { background: #fafafa; border-radius: 6px; padding: 6px 8px; }
.ed-amt.main { background: #fff7d6; }
.ed-amt .lab { font-size: 10px; color: #888; }
.ed-amt .val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ed-amt-diff.diff-up { color: #2f6a1d; }
.ed-amt-diff.diff-down { color: #b03030; }

.ed-meta { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; font-size: 12px; margin: 8px 0; }
.ed-meta dt { color: var(--c-muted); }
.ed-meta dd { margin: 0; }

.ed-section { background: #fafafa; border: 1px solid #eee; border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.ed-section summary { cursor: pointer; font-size: 13px; font-weight: 600; }

/* v0.7.9 (2026-06-01) R-FUND-31: 業務計畫及預算說明 區塊 — 內容很長 (5K-100K chars)
   open 時 scroll 限高，避免吃掉整頁；微黃底色區別於「基金概況」紙白 */
.ed-fund-intro { background: #fffdf5; border: 1px solid #f3e9c6; }
.ed-fund-intro summary { color: #8b6914; }
.ed-fund-intro[open] .ed-rich {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
  border-top: 1px dashed #f3e9c6;
  margin-top: 6px;
  padding-top: 8px;
}
.ed-text { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 12.5px; line-height: 1.55; color: #333; margin: 8px 0 0; }

.ed-proposal-preview { background: #f5f7fa; border: 1px solid #d8e0ec; border-radius: 6px; padding: 10px 12px; margin-top: 10px; }
.ed-proposal-preview h4 { margin: 0 0 6px; font-size: 13px; }
.pp-mini { font-size: 12px; line-height: 1.8; color: #333; }
.pp-mini b { color: #555; }
.btn-wide { width: 100%; margin-top: 10px; }

/* =================================================
   /import-status 頁  (v0.4.7 重新設計)
   ================================================= */
.status-page {
  padding: 16px 20px 40px;
  max-width: 1280px;
  margin: 0 auto;
}

/* Hero header with KPI bar */
.status-hero { margin-bottom: 18px; }
.status-hero h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.status-hero p.muted { margin: 0 0 14px; font-size: 13px; }
.status-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.kpi {
  background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--c-text);
  line-height: 1.1;
}
.kpi-label {
  font-size: 11.5px;
  color: var(--c-muted);
  margin-top: 4px;
  font-weight: 500;
}
.kpi-sub { font-size: 10.5px; margin-top: 2px; }

/* Section cards */
.status-card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.status-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid #f0f0ee;
  padding-bottom: 8px;
}
.status-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.status-card-sub {
  font-size: 11.5px;
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
}
.status-card p.muted.small {
  font-size: 12px;
  margin: 4px 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Foldable secondary sections */
.status-fold {
  background: #fafaf9;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.status-fold > summary {
  cursor: pointer;
  padding: 10px 16px;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  user-select: none;
}
.status-fold > summary::-webkit-details-marker { display: none; }
.status-fold > summary::before {
  content: "▸";
  color: var(--c-muted);
  font-size: 10px;
  transition: transform 0.15s;
  display: inline-block;
  width: 10px;
}
.status-fold[open] > summary::before { transform: rotate(90deg); }
.status-fold > summary:hover { background: #f3f3f1; }
.fold-title { font-weight: 600; font-size: 13px; }
.fold-sub { color: var(--c-muted); font-size: 11.5px; }
.status-fold[open] > summary { border-bottom: 1px solid var(--c-border); }
.status-fold > *:not(summary) {
  padding: 12px 16px;
}

/* tables */
.tbl-books {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  margin: 4px 0 4px;
}
.tbl-books th {
  background: #f7f7f5;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--c-border);
  font-size: 11.5px;
  color: #555;
  position: sticky;
  top: 0;
}
.tbl-books td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0ee;
}
.tbl-books tbody tr:hover { background: #fafaf8; }
.tbl-books td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-books td.ts { color: #777; font-size: 11px; font-variant-numeric: tabular-nums; }
.tbl-books td.src { color: #777; font-size: 11px; }
.tbl-books code { font-size: 10.5px; background: #f0f0ee; padding: 1px 5px; border-radius: 3px; }

/* CLI command block */
.status-cmd {
  background: #1d1d1f;
  color: #e8e8e6;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.55;
  margin: 4px 0 10px;
}

/* paths definition list */
.status-paths {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 12px;
  margin: 0;
}
.status-paths dt {
  color: var(--c-muted);
  font-weight: 500;
}
.status-paths dd { margin: 0; }
.status-paths code {
  background: #f0f0ee;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  word-break: break-all;
}

/* logs list */
.log-list { list-style: none; padding: 0; margin: 0; }
.log-list li {
  padding: 4px 0;
  border-bottom: 1px solid #f3f3f1;
}
.log-list li:last-child { border-bottom: none; }
.log-pre {
  background: #1d1d1f;
  color: #e8e8e6;
  padding: 10px 12px;
  border-radius: 5px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.5;
  max-height: 400px;
  margin: 6px 0 0;
}

/* v0.4.8 /database 跨部會搜尋區 */
.db4-search-section {
  margin-top: 24px;
  padding: 18px 20px;
  background: linear-gradient(180deg, #fffefb 0%, #fff8ee 100%);
  border: 1px solid #ffe0c8;
  border-radius: 12px;
}
.db4-search-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.db4-search-section p.small {
  font-size: 12px;
  margin: 0 0 12px;
}
.db4-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.db4-search-bar input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid #ffd3b4;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.15s;
}
.db4-search-bar input:focus {
  outline: none;
  border-color: #d04848;
  box-shadow: 0 0 0 3px rgba(208, 72, 72, 0.12);
}
.db4-search-stats {
  font-size: 12.5px;
  color: #555;
  white-space: nowrap;
}
.db4-search-stats b { color: #c0392b; font-weight: 700; font-size: 14px; }
.db4-search-stats .muted { color: #999; font-size: 11px; }

/* database card 加 explorer 按鈕區 */
.mc-actions { margin-top: 6px; }
.mc-imported { display: block; font-size: 10.5px; margin-top: 4px; }

/* =================================================
   Explorer：說明 / 編列理由 排版優化
   ================================================= */
.ed-rich {
  font-size: 13px;
  line-height: 1.7;
  color: #2a2a2a;
  padding: 6px 4px 2px;
  word-break: break-word;
}
.ed-rich .ex-empty { color: #999; font-style: italic; }

.ed-rich p, .ed-rich .ex-p {
  margin: 0 0 0.85em;
  text-indent: 2em;          /* 中文段落首行縮排，像正式文章 */
  letter-spacing: 0.01em;
}
/* 業務計畫及預算說明這類長文：放大行高 + 段距，避免一大坨牆 */
.ed-fund-intro .ed-rich .ex-p { line-height: 1.95; margin-bottom: 1em; }

/* 「本年度預算數XX千元，包括…」整段加底色框 */
.ed-rich .ex-hi-budget {
  background: #fff7e6;
  border-left: 3px solid #f0b400;
  padding: 8px 10px;
  border-radius: 4px;
  margin: 6px 0 10px;
  font-size: 13px;
}

/* 「較如下」「上年度比較如下」之類的小標 */
.ed-rich .ex-h {
  margin: 12px 0 4px;
  font-size: 13px;
  color: #555;
  font-weight: 600;
  border-bottom: 1px dashed #ccc;
  padding-bottom: 3px;
}

/* 列表項 ( (1) (2) (3) ... ) */
.ed-rich .ex-li {
  position: relative;
  padding: 4px 8px 4px 14px;
  margin: 2px 0;
  border-radius: 4px;
  background: #fafafa;
  border-left: 2px solid transparent;
}
.ed-rich .ex-li:hover { background: #f4f4f4; }
/* 表格式編號三階降冪縮排（2026-07-24 用戶訂「從大項到小項退縮要更明確」）
   1. 大項(num)=0 → (1) 中項(paren)=22px → <1> 小項(angle)=44px，每階 +22px 明顯階梯 */
.ed-rich .ex-li-num   {                                     /* 1. 大項 */
  border-left-color: #2f6a1d;
  margin-left: 0;
}
.ed-rich .ex-li-paren {                                     /* (1) 中項 */
  border-left-color: #5b8def;
  margin-left: 22px;
}
.ed-rich .ex-li-cn    { border-left-color: #b03030; }       /* 一、 */
.ed-rich .ex-li-cn-paren {                                   /* (一) 子小標 */
  border-left-color: #6b46c1;
  background: #f6f4ff;
  font-weight: 600;
  margin-left: 22px;
}
.ed-rich .ex-li-angle {                                      /* <1> 小項 */
  border-left-color: #aaa;
  margin-left: 44px;
  background: #f6f6f6;
  font-size: 12.5px;
}

/* 章節大標：「壹、基金概況」 */
.ed-rich .ex-h-chap {
  margin: 16px 0 8px;
  padding: 6px 10px;
  background: linear-gradient(to right, #1e40af 0%, #3b82f6 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 1px;
}
.ed-rich .ex-h-chap:first-child { margin-top: 0; }

/* 長文抽取（項層/基金業務計畫）章節收折＋目錄（2026-07-24 用戶「分段更清晰」） */
.ed-rich .ex-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.ed-rich .ex-toc-chip {
  border: 1px solid #bfdbfe; background: #eff6ff; color: #1e40af;
  font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
}
.ed-rich .ex-toc-chip:hover { background: #dbeafe; }
.ed-rich .ex-chapd { margin: 8px 0; border: 1px solid #e2e8f0; border-radius: 6px; overflow: hidden; }
.ed-rich .ex-chapd[open] { border-color: #93c5fd; }
.ed-rich .ex-chapsum {
  cursor: pointer; padding: 7px 10px; list-style: none;
  background: linear-gradient(to right, #1e40af 0%, #3b82f6 100%);
  color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 1px;
  display: flex; align-items: center; gap: 8px;
}
.ed-rich .ex-chapsum::-webkit-details-marker { display: none; }
.ed-rich .ex-chapmeta { font-size: 11px; font-weight: 400; opacity: .85; margin-left: auto; }
.ed-rich .ex-chapsum::after { content: "▾"; font-size: 12px; opacity: .8; }
.ed-rich .ex-chapd:not([open]) .ex-chapsum { background: #eff6ff; color: #1e3a8a; }
.ed-rich .ex-chapd:not([open]) .ex-chapsum::after { content: "▸"; }
.ed-rich .ex-chapbody { padding: 8px 10px; }

/* 中型小標：「一、設立宗旨：」 */
.ed-rich .ex-h-sec {
  margin: 12px 0 4px;
  padding: 4px 0 4px 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e3a8a;
  border-left: 4px solid #1e40af;
  background: #eff6ff;
}

/* 金額高亮 */
.ed-rich .hl-amt,
.pb-rich .hl-amt {
  color: #b80000;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* 日期：民國 39 年 / 107 年 11 月 1 日 */
.ed-rich .hl-date {
  color: #075985;
  background: #e0f2fe;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.95em;
}
/* 百分比 */
.ed-rich .hl-pct {
  color: #166534;
  background: #dcfce7;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* 法條/項號參照 */
.ed-rich .hl-ref {
  color: #581c87;
  background: #faf5ff;
  padding: 1px 3px;
  border-radius: 3px;
  font-size: 0.95em;
}

/* Fund summary strip — 「淨值 / 業務總收入 / 業務總支出 / 賸餘」橫排卡片 */
.ed-rich .fund-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 4px 0 14px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  position: relative;
}
.ed-rich .fs-cell {
  padding: 4px 8px;
  background: #fff;
  border-radius: 4px;
  border-left: 3px solid #94a3b8;
  text-align: right;
}
.ed-rich .fs-cell.fs-inc { border-left-color: #16a34a; }   /* 收入 — 綠 */
.ed-rich .fs-cell.fs-exp { border-left-color: #dc2626; }   /* 支出 — 紅 */
.ed-rich .fs-cell.fs-pos { border-left-color: #2563eb; }   /* 賸餘 — 藍 */
.ed-rich .fs-cell.fs-neg { border-left-color: #ea580c; }   /* 短絀 — 橙 */
.ed-rich .fs-cell.fs-net { border-left-color: #7c3aed; }   /* 淨值 — 紫 */
.ed-rich .fs-lab {
  font-size: 11px;
  color: #475569;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-align: left;
}
.ed-rich .fs-num {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.ed-rich .fund-summary-strip .fs-cell.fs-neg .fs-num { color: #c2410c; }
.ed-rich .fund-summary-strip .fs-cell.fs-pos .fs-num { color: #1e40af; }
.ed-rich .fs-unit {
  align-self: center;
  font-size: 11px;
  color: #64748b;
  text-align: right;
  padding-right: 4px;
}

/* PDF 連結指示 chip */
.ed-rich .pdf-ref {
  display: inline-block;
  padding: 2px 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 0.85em;
  color: #475569;
  margin: 0 2px;
}

/* 區塊整體外框：原本的 .ed-section 升級 */
.ed-section {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.ed-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  padding: 2px 0;
}
.ed-section[open] summary {
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
  margin-bottom: 6px;
}

/* 說明區更突出 */
.ed-section-explain {
  background: linear-gradient(to bottom, #fffdf5 0%, #fff 60px);
  border-color: #f0d990;
}

/* 大綱：金額卡更鬆 */
.ed-amts { gap: 10px; }
.ed-amt { padding: 8px 10px; }
.ed-amt .lab { margin-bottom: 2px; }

/* v0.7.6 (2026-06-01): 詳細卡不再卡 max-width，讓拖曳分隔線後能撐滿可用空間。
   原 max-width: 640px 會造成大螢幕右側大片空白浪費。
   實際寬度由 .explorer-grid 的 1fr 控制，splitter 可拖曳調比例。 */
.exp-detail { max-width: none; }

/* 「本分支計畫係辦理…」概覽段落 */
.ed-rich .ex-hi-overview {
  background: #f0f5ff;
  border-left: 3px solid #5b8def;
  padding: 8px 10px;
  border-radius: 4px;
  margin: 6px 0 10px;
  font-size: 13px;
  line-height: 1.65;
}

/* =================================================
   Explorer v0.3 — 整列即按鈕、用途別大類/細項層次
   ================================================= */

/* 取消舊 .tn-row 樣式（被 button 包住的版本） */
.tn-row-wrap {
  display: flex; align-items: stretch; gap: 2px;
  padding: 0 4px 0 calc(8px + var(--depth, 0) * 14px);
  border-bottom: 1px dotted #eee;
}
.tn-row-wrap:hover { background: #fafafa; }

/* v0.6.4 (2026-05-29) database 主頁 ministry-level review checkbox */
/* v0.6.6 (2026-05-29) 右上 stack: 標記已修好 + 預算書狀態 + 開啟 PDF */
.mc-right-stack {
  position: absolute; top: 6px; right: 6px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  z-index: 2;
}
.mc-review-box {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border: 1px solid #d4af37; border-radius: 12px;
  background: #fffaf0; cursor: pointer;
  font-size: 10.5px; color: #8b6914;
  user-select: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.mc-book-state {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 12px;
  font-size: 10.5px; font-weight: 500;
  white-space: nowrap; user-select: none;
  border: 1px solid transparent;
}
.mc-bs-imported   { background: #e8f5e9; color: #1b5e20; border-color: #4caf50; }
.mc-bs-downloaded {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  color: #e65100; border-color: #ff9800;
  box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.45);
  animation: mc-bs-pulse 2s ease-in-out infinite;
  font-weight: 600;
}
.mc-bs-missing    { background: #f5f5f5; color: #757575; border-color: #bdbdbd; }
.mc-bs-partial    { background: #fff8e1; color: #8d6e00; border-color: #f0c33c; }
/* 2026-09-15 應收／已收預算書 pill（取代標記已修好） */
.mc-books {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px;
  font-size: 10.5px; white-space: nowrap; user-select: none;
  border: 1px solid #bdbdbd; background: #f5f5f5; color: #616161;
  font-variant-numeric: tabular-nums;
}
.mc-books b { font-weight: 700; }
.mc-books-full { background: #e8f5e9; color: #1b5e20; border-color: #4caf50; }
.mc-books-part { background: #fff8e1; color: #8d6e00; border-color: #f0c33c; }
.min-cell.is-partial { border-left-color: #f0c33c !important; }
html[data-theme="dark"] .mc-books { background: #2a2a2a; color: #bdbdbd; border-color: #555; }
html[data-theme="dark"] .mc-books-full { background: #1b3a1e; color: #a5d6a7; border-color: #4caf50; }
html[data-theme="dark"] .mc-books-part,
html[data-theme="dark"] .mc-bs-partial { background: #3a3010; color: #ffe082; border-color: #c9a227; }
@keyframes mc-bs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.45); }
  50%      { box-shadow: 0 0 0 4px rgba(255, 152, 0, 0); }
}
.mc-bs-downloaded svg circle:last-of-type {
  animation: mc-bs-dot 1.4s ease-in-out infinite;
}
@keyframes mc-bs-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.mc-pdf-btn {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 12px;
  font-size: 10.5px; font-weight: 500;
  background: #e3f2fd; color: #1565c0; border: 1px solid #64b5f6;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.mc-pdf-btn:hover { background: #bbdefb; border-color: #1976d2; text-decoration: none; }
.mc-review-box:hover { background: #fff3d6; border-color: #b8860b; }
.mc-review-cb { margin: 0; cursor: pointer; accent-color: #2e7d32; }
.mc-review-label { font-weight: 500; }
.min-cell.is-reviewed {
  border-color: #2e7d32 !important;
  box-shadow: 0 0 0 1px #2e7d32 inset;
}
.min-cell.is-reviewed .mc-review-box {
  background: #e8f5e9; border-color: #2e7d32; color: #1b5e20;
}
.min-cell.is-reviewed::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(232,245,233,0.35) 0%, transparent 55%);
  pointer-events: none; border-radius: 8px;
}

/* v0.6.7 (2026-05-29) fund top 詳情面板 4 數字格：淨值(main) / 收入 / 支出 / 賸絀 */
.fund-amts { display: grid !important; grid-template-columns: 2.2fr 1fr 1fr 1fr; gap: 8px; }
.fund-amts .ed-amt.main {
  background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 100%);
  border-left: 4px solid #00897b; padding: 10px 14px; border-radius: 8px;
}
.fund-amts .ed-amt.main .val { color: #00695c; font-weight: 700; font-size: 1.4em; }
.fund-amts .fund-amt-income {
  background: #e8f5e9; border-left: 3px solid #43a047;
  padding: 8px 10px; border-radius: 6px;
}
.fund-amts .fund-amt-income .val { color: #2e7d32; font-weight: 600; font-size: 1em; }
.fund-amts .fund-amt-expense {
  background: #ffebee; border-left: 3px solid #e53935;
  padding: 8px 10px; border-radius: 6px;
}
.fund-amts .fund-amt-expense .val { color: #c62828; font-weight: 600; font-size: 1em; }
.fund-amts .fund-amt-surplus {
  background: #fff3e0; border-left: 3px solid #fb8c00;
  padding: 8px 10px; border-radius: 6px;
}
.fund-amts .fund-amt-surplus .val { color: #ef6c00; font-weight: 600; font-size: 1em; }
.fund-amts .ed-amt .lab { font-size: 11px; color: #555; line-height: 1.3; }
/* v0.7.0 (2026-05-30) 鐵律 7「資料 label 不偷換」: 缺值 "—" 用低調樣式 */
.fund-amts .val .val-na {
  color: #bbb !important; font-weight: 400; font-style: italic;
  font-size: 0.85em !important;
}
.fund-amts .ed-amt.main .val .val-na { color: #80cbc4 !important; }

/* v0.6.5 (2026-05-29) 預計數 vs 預算數 — source_table 結尾「預計表」的 row 不同 UI */
.tn.is-projected-row > .tn-row-wrap {
  border-left: 3px solid #7e57c2 !important;
  background: linear-gradient(to right, #f5f0fb 0%, transparent 35%);
}
.tn-basis-pill {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; font-size: 9px; font-weight: 600;
  border-radius: 6px; vertical-align: middle;
  letter-spacing: 0.5px;
}
.basis-projected {
  background: #7e57c2; color: #fff;
}
/* v0.7.2 (2026-05-31) 基金淨值 sub-pill — 金融型基金 (勞退/勞保/退撫) 顯示淨值規模，
 * 提醒使用者列上「業務支出」只是管理費、淨值才是基金實際規模 */
.basis-equity {
  background: #d4af37; color: #4a3a00;
  border: 1px solid #b8860b;
}

/* v0.6.3 (2026-05-29) fund top row review checkbox */
.tn-review-box {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; margin-left: 6px; align-self: center;
  border: 1px solid #d4af37; border-radius: 12px;
  background: #fffaf0; cursor: pointer;
  font-size: 11px; color: #8b6914;
  user-select: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tn-review-box:hover { background: #fff3d6; border-color: #b8860b; }
.tn-review-cb { margin: 0; cursor: pointer; accent-color: #2e7d32; }
.tn-review-label { font-weight: 500; }
.tn.is-fund-reviewed > .tn-row-wrap .tn-review-box {
  background: #e8f5e9; border-color: #2e7d32; color: #1b5e20;
}
.tn.is-fund-reviewed > .tn-row-wrap {
  background: linear-gradient(to right, #f1f8e9 0%, transparent 40%);
}

/* v0.6.8 (2026-05-29) 🔒 鐵律 5: 結構大項不可消失 — parser 漏抓 row 灰階顯示 */
.tn.is-parser-missed > .tn-row-wrap {
  background: repeating-linear-gradient(
    45deg, #fafafa, #fafafa 6px, #f0f0f0 6px, #f0f0f0 12px
  );
  border-left: 2px dashed #999 !important;
  opacity: 0.75;
}
.tn.is-parser-missed > .tn-row-wrap .tn-name {
  color: #757575; font-style: italic;
}
.tn.is-parser-missed > .tn-row-wrap .tn-amt {
  color: #aaa; font-style: italic;
}
.tn.is-parser-missed > .tn-row-wrap .tn-badge {
  background: #e0e0e0; color: #616161; border: 1px dashed #999;
}
.tn-warn.parser-missed {
  display: inline-block; color: #f57c00; font-size: 14px;
  margin-right: 4px; cursor: help;
  animation: tn-warn-pulse 2s ease-in-out infinite;
}
@keyframes tn-warn-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* v0.6.7 (2026-05-29) fund 3-態狀態 pill + 開啟 PDF 按鈕 (在 explorer fund top row) */
.tn-book-state {
  display: inline-flex; align-items: center;
  padding: 2px 8px; margin-left: 4px; align-self: center;
  border-radius: 12px; border: 1px solid transparent;
  font-size: 11px; font-weight: 500;
  white-space: nowrap; user-select: none;
}
.tn-bs-imported   { background: #e8f5e9; color: #1b5e20; border-color: #4caf50; }
.tn-bs-downloaded {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  color: #e65100; border-color: #ff9800;
  box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.45);
  animation: tn-bs-pulse 2s ease-in-out infinite;
  font-weight: 600;
}
.tn-bs-missing    { background: #f5f5f5; color: #757575; border-color: #bdbdbd; }
@keyframes tn-bs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.45); }
  50%      { box-shadow: 0 0 0 4px rgba(255, 152, 0, 0); }
}
.tn-bs-downloaded svg circle:last-of-type {
  animation: tn-bs-dot 1.4s ease-in-out infinite;
}
@keyframes tn-bs-dot {
  0%, 100% { opacity: 1; transform-origin: center; }
  50%      { opacity: 0.4; }
}
.tn-pdf-btn {
  display: inline-flex; align-items: center;
  padding: 2px 8px; margin-left: 4px; align-self: center;
  border-radius: 12px; border: 1px solid #64b5f6;
  background: #e3f2fd; color: #1565c0;
  font-size: 11px; font-weight: 500;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.tn-pdf-btn:hover { background: #bbdefb; border-color: #1976d2; text-decoration: none; }

.tn-toggle {
  background: none; border: none; cursor: pointer; padding: 0 2px;
  font-size: 10px; color: #888; flex: 0 0 16px;
  align-self: center;
}
.tn-row {
  display: grid;
  /* 金額欄 max-content：數字＋千元永遠同一行，塞不下時壓名稱欄（名稱有 ellipsis） */
  grid-template-columns: 60px 1fr max-content 110px 16px;
  gap: 8px; align-items: center;
  flex: 1; padding: 6px 8px;
  background: none; border: none; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
  border-radius: 4px; transition: background 0.1s;
}
.tn-row:hover {
  background: #eef4ff;
}
.tn-row.is-selected {
  background: #d8e8ff;
  box-shadow: inset 3px 0 0 #4a78ff;
}
.tn-row .tn-cut-hint {
  color: #aaa; text-align: right; font-size: 14px;
  transition: color 0.1s, transform 0.1s;
}
.tn-row:hover .tn-cut-hint { color: #4a78ff; transform: translateX(2px); }

.tn-badge {
  display: inline-block; text-align: center; font-size: 10px; font-weight: 700;
  padding: 2px 0; border-radius: 9px; background: #eee; color: #555;
  white-space: nowrap; letter-spacing: 0.5px;
}
.tn-badge.badge-主管        { background: #ffe5cc; color: #9a4500; }
.tn-badge.badge-機關        { background: #ffdada; color: #842020; }
.tn-badge.badge-目          { background: #d6e8ff; color: #1f4e8a; }
.tn-badge.badge-分支計畫    { background: #e3f3e0; color: #2f6a1d; }
.tn-badge.badge-用途別大類  { background: #eee2ff; color: #4b2e7e; font-weight: 800; }
.tn-badge.badge-用途別細項  { background: #f3eff8; color: #6b5599; font-size: 9px; }
.tn-badge.badge-細目        { background: #f0e5d6; color: #5a3a16; }

/* v0.6.5 (2026-05-29 user): 基金樹專屬 chip 配色 — 4 階層各有獨立色相 */
/*   大項 (kind=目 in fund tree) → 橙紅 (top 業務計畫，類比 款) */
/*   中項 (分支計畫)             → 茶/teal */
/*   大類 (用途別大類)           → 紫 (保留) */
/*   細項 (用途別)               → 灰藍 */
.is-fund-row .tn-badge.badge-目          { background: #ffd9b8; color: #8a3d00; font-weight: 800; }
.is-fund-row .tn-badge.badge-分支計畫    { background: #c8eee8; color: #0b5b54; font-weight: 700; }
.is-fund-row .tn-badge.badge-用途別大類  { background: #eee2ff; color: #4b2e7e; font-weight: 700; }
.is-fund-row .tn-badge.badge-用途別      { background: #e2e8f0; color: #1e293b; font-size: 10px; }
.is-fund-row .tn-badge.badge-用途別細項  { background: #e2e8f0; color: #1e293b; font-size: 10px; }

/* v0.7.8 (2026-07-11 用戶): 項目名稱是主角 — 款項編號縮成名稱上方一行小字，
   名稱吃滿整欄寬不再被編號擠掉 */
.tn-label {
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0; gap: 1px;
}
.tn-code-prefix {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px; color: #888; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tn-code-prefix:empty { display: none; }
.tn-name {
  color: var(--c-text);
  font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 各層級的名稱字體調整 */
.kind-主管 .tn-name, .kind-機關 .tn-name { font-weight: 700; }
.kind-目 .tn-name { font-weight: 600; }
.kind-分支計畫 .tn-name { font-weight: 500; }
.kind-用途別大類 .tn-name { font-weight: 600; color: #4b2e7e; }
.kind-用途別細項 .tn-name { color: #555; font-size: 12.5px; }

.tn-amt {
  text-align: right; font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: 13px;
  white-space: nowrap;   /* 「千元」不落單、不被拆成「千/元」兩行 */
}
.tn-amt.amt-xxl { color: #b80000; font-size: 14px; }
.tn-amt.amt-xl  { color: #d96b00; }
.tn-amt.amt-l   { color: #1f4e8a; }
.tn-amt.amt-m   { color: #555; font-weight: 500; }
.tn-diff { text-align: right; font-size: 11px; }
.tn-diff.diff-up   { color: #2f6a1d; }
.tn-diff.diff-down { color: #b03030; }

/* 不同層級的左側裝飾色條 */
.kind-主管        > .tn-row-wrap { border-left: 3px solid #ff8a00; background: #fff8f0; }
.kind-機關        > .tn-row-wrap { border-left: 3px solid #d04040; background: #fff5f5; }
.kind-目          > .tn-row-wrap { border-left: 3px solid #1f4e8a; }
.kind-分支計畫    > .tn-row-wrap { border-left: 3px solid #2f6a1d; }
.kind-用途別大類  > .tn-row-wrap { border-left: 3px solid #5b3d99; background: #faf8ff; }
.kind-用途別細項  > .tn-row-wrap { border-left: 1px solid #ccc; }

/* 用途別大類展開時加底色強調 */
.kind-用途別大類.expanded > .tn-row-wrap {
  background: #f3edff;
}

/* Override 之前 grid-template-columns 過舊樣式 */
.tn-row[old-style] { display: none !important; }

/* 通用代碼對照表 */
.ref-tables details {
  background: #fafafa; border: 1px solid #e4e4e4; border-radius: 6px;
  padding: 8px 12px; margin: 6px 0;
}
.ref-tables summary { cursor: pointer; font-size: 13px; }
.tbl-ref {
  width: 100%; border-collapse: collapse; font-size: 11.5px;
  margin: 8px 0;
}
.tbl-ref th, .tbl-ref td {
  border: 1px solid #e4e4e4; padding: 3px 6px; text-align: left;
}
.tbl-ref th { background: #f0f0f0; font-weight: 600; }
.tbl-ref tbody tr:nth-child(odd) { background: #fff; }

/* =================================================
   字體大小調整（zoom 對 .content 整塊縮放，layout 比例不變）
   ================================================= */
.content {
  zoom: var(--app-zoom, 1);
}

/* topbar 不縮放，控制按鈕在 topbar 內 */
.font-zoom {
  display: flex; align-items: center; gap: 4px;
  margin-left: 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px; padding: 2px 4px;
}
.fz-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; font-size: 13px; font-weight: 600;
  color: var(--c-text); border-radius: 4px;
  transition: background 0.1s;
  font-family: inherit;
}
.fz-btn:hover { background: rgba(0,0,0,0.08); }
.fz-btn:active { background: rgba(0,0,0,0.15); }
.fz-level {
  font-size: 11px; color: var(--c-muted);
  min-width: 38px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.fz-reset { font-size: 14px; }

/* 把幾處關鍵字體再加大一點，讓預設更易讀 */
body { font-size: 14px; }
.tn-row { grid-template-columns: 60px 1fr max-content 110px 18px; }
.tn-name { font-size: 14px; }
.tn-amt  { font-size: 14px; }
.tn-amt.amt-xxl { font-size: 15px; }
.tn-code-prefix { font-size: 11px; }
.tn-badge { font-size: 11px; padding: 3px 6px; }
.tn-badge.badge-用途別細項 { font-size: 10px; }

.ed-card { padding: 16px 18px; }
.ed-head h3 { font-size: 17px; }
.ed-code { font-size: 12px; }
.ed-amt .lab { font-size: 11px; }
.ed-amt .val { font-size: 16px; }
.ed-amt.main .val { font-size: 18px; }
.ed-meta { font-size: 13px; }
.ed-section summary { font-size: 14px; }
.ed-rich { font-size: 14px; line-height: 1.75; }
.ed-rich .ex-hi-budget,
.ed-rich .ex-hi-overview { font-size: 14px; }
.ed-rich .ex-li-angle { font-size: 13.5px; }

.explorer-head h2 { font-size: 20px; }
.exp-toolbar input, .exp-toolbar select { font-size: 14px; padding: 6px 10px; }
.exp-toolbar .lv-chip { font-size: 13px; padding: 5px 12px; }

/* 確保 topbar 內元素本身有足夠 padding 不被 nav 擠壞 */
.topbar { gap: 8px; flex-wrap: wrap; }
.mainnav { flex-wrap: wrap; }

/* v0.7.6 (2026-06-01): 同上 — 大字體模式也撐滿 */
.exp-detail { max-width: none; }

/* tn-row 內部 gap 加大、icon 更顯眼 */
.tn-row { gap: 10px; padding: 8px 10px; }
.tn-cut-hint { font-size: 18px; }

/* =================================================
   Topbar 全域部會切換器
   ================================================= */
.ministry-switcher {
  display: flex; align-items: center; gap: 6px;
  margin-left: 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px; padding: 4px 8px;
}
.ministry-switcher label {
  font-size: 12px; color: var(--c-muted); white-space: nowrap;
}
#topbar-min-pick {
  border: 1px solid var(--c-border); border-radius: 5px;
  padding: 4px 6px; font-size: 13px;
  background: #fff; font-family: inherit;
  max-width: 260px;
}
#topbar-min-pick option[data-empty="1"] {
  color: #aaa;
}

/* v0.7.1 (2026-05-31) Grand total banner — 大字版總預算 */
.db4-grand {
  background: linear-gradient(135deg, #2a3f5f 0%, #4a6798 60%, #6b88c5 100%);
  color: #fff;
  border-radius: 14px;
  padding: 22px 28px 24px;
  margin: 14px 0 16px;
  box-shadow: 0 4px 16px rgba(42, 63, 95, 0.18);
  position: relative;
  overflow: hidden;
}
.db4-grand::before {
  content: "";
  position: absolute;
  right: -20px; top: -30px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.db4-grand .dg-yr {
  font-size: 14px;
  opacity: 0.75;
  letter-spacing: 2px;
  margin-bottom: 2px;
}
.db4-grand .dg-label {
  font-size: 16px;
  font-weight: 500;
  opacity: 0.85;
  margin-bottom: 6px;
}
.db4-grand .dg-amt {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.db4-grand .dg-breakdown {
  margin-top: 12px;
  font-size: 13.5px;
  opacity: 0.92;
  line-height: 1.6;
}
.db4-grand .dg-breakdown b {
  font-weight: 700;
  color: #ffd54f;
  font-variant-numeric: tabular-nums;
}
.db4-grand .dg-cta {
  display: inline-block;
  margin-left: 14px;
  padding: 4px 12px;
  background: rgba(255,255,255,0.18);
  border-radius: 14px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.db4-grand .dg-cta:hover {
  background: rgba(255,255,255,0.30);
  transform: translateX(2px);
}
.db4-dashboard-link {
  margin-left: 8px;
  padding: 2px 8px;
  background: #fff7c8;
  border-radius: 4px;
  color: #8a6800;
  font-weight: 600;
  text-decoration: none;
}
.db4-dashboard-link:hover { background: #ffec80; }

/* v0.7.5 (2026-05-31) 官方分項對帳 — 主表 (取代舊 db4-grand 8 兆 banner) */
.db4-financing {
  background: var(--c-panel); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 18px 22px; margin: 0 auto 20px; max-width: 1200px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dbf-title { font-size: 15px; color: var(--c-text); font-weight: 700; margin-bottom: 12px; }
.dbf-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.dbf-card {
  border-left: 4px solid var(--c-border); padding: 12px 16px; background: #fafaf7;
  border-radius: 4px;
}
.dbf-card.dbf-exp     { border-left-color: #2563eb; }
.dbf-card.dbf-debt    { border-left-color: #f59e0b; }
.dbf-card.dbf-deficit { border-left-color: #ef4444; }
.dbf-card.dbf-financing { border-left-color: #8b5cf6; }
.dbf-lab { font-size: 13px; color: #6b6b6b; }
.dbf-val { font-size: 24px; font-weight: 700; color: #222; margin-top: 4px; }
.dbf-sub { font-size: 12px; color: #888; margin-top: 6px; }
.dbf-sub .dbf-ok   { color: #16a34a; font-weight: 600; }
.dbf-sub .dbf-warn { color: #ea580c; font-weight: 600; }
@media (max-width: 768px) {
  .dbf-grid { grid-template-columns: 1fr 1fr; }
}
html[data-theme="dark"] .db4-financing { background: #121826; border-color: #1f2937; }
html[data-theme="dark"] .dbf-card { background: #1a2032; }
html[data-theme="dark"] .dbf-val { color: #e2e8f0; }
html[data-theme="dark"] .dbf-title { color: #d4d8e0; }

@media (max-width: 720px) {
  .db4-grand .dg-amt { font-size: 32px; }
  .db4-grand .dg-breakdown { font-size: 12.5px; }
  .db4-grand { padding: 16px 18px 18px; }
}

/* =================================================
   /database — 緊湊型「主管號方格」
   ================================================= */
.db4-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  margin-top: 12px;
}
.min-cell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  padding: 12px 14px 13px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 9px;
  font-size: 12.5px;
  text-decoration: none; color: inherit;
  transition: transform 0.08s, box-shadow 0.08s, border-color 0.08s;
  position: relative;
  min-height: 100px;
}
.min-cell.imported {
  background: linear-gradient(180deg, #ffffff 0%, #f5fbff 100%);
  border-color: #c5d9e8;
  cursor: pointer;
}
.min-cell.imported:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
  border-color: #5b8def;
}
/* v0.4.13：分類配色 — 4px 左邊條 + 淡背景 */
.min-cell.cat-fu-yuan.imported {
  background: linear-gradient(180deg, #fffaf0 0%, #fff4d6 100%);
  border-left: 4px solid #d4a017;
}
.min-cell.cat-fu-yuan.imported:hover { border-color: #b8860b; border-left-color: #b8860b; }
.min-cell.cat-bu.imported {
  background: linear-gradient(180deg, #ffffff 0%, #ebf3ff 100%);
  border-left: 4px solid #4a7fdf;
}
.min-cell.cat-bu.imported:hover { border-color: #2c5db5; border-left-color: #2c5db5; }
.min-cell.cat-weiyuanhui.imported {
  background: linear-gradient(180deg, #f8fff5 0%, #e6f5e0 100%);
  border-left: 4px solid #4a9648;
}
.min-cell.cat-weiyuanhui.imported:hover { border-color: #2f7a2c; border-left-color: #2f7a2c; }
.min-cell.cat-other.imported {
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
  border-left: 4px solid #999;
}
/* v0.4.13 legend */
.db4-legend { display: inline-flex; gap: 10px; align-items: center; font-size: 12px; color: #666; margin-left: auto; }
.db4-legend .lg-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 3px; vertical-align: middle;
}
.db4-legend .lg-fu-yuan { background: #d4a017; }
.db4-legend .lg-bu { background: #4a7fdf; }
.db4-legend .lg-weiyuanhui { background: #4a9648; }
.db4-legend .lg-other { background: #999; }
.min-cell.not-imported {
  background: #fafafa;
  border-color: #e8e8e8;
  filter: grayscale(0.6);
  opacity: 0.75;
}
.min-cell .mc-kuan {
  font-size: 11px; color: #888;
  font-family: ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.min-cell.imported .mc-kuan { color: #5b8def; font-weight: 600; }
.min-cell .mc-name {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.22;
  letter-spacing: -0.2px;
}
/* 總預算 banner */
.min-cell .mc-total {
  margin: 3px 0 1px;
  padding: 5px 9px;
  background: rgba(255,255,255,0.55);
  border: 1px dashed rgba(91, 141, 239, 0.35);
  border-radius: 6px;
  text-align: center;
}
.min-cell.cat-fu-yuan .mc-total { border-color: rgba(212, 160, 23, 0.45); background: rgba(255, 251, 240, 0.7); }
.min-cell.cat-bu .mc-total      { border-color: rgba(74, 127, 223, 0.40); background: rgba(235, 243, 255, 0.7); }
.min-cell.cat-weiyuanhui .mc-total { border-color: rgba(74, 150, 72, 0.40); background: rgba(232, 245, 224, 0.7); }
.min-cell.cat-other .mc-total   { border-color: rgba(150,150,150, 0.35); background: rgba(245,245,245,0.7); }
.min-cell .mc-total-amt {
  font-size: 20px;
  font-weight: 800;
  color: #c0392b;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
  line-height: 1.1;
}
.min-cell .mc-total-sub {
  font-size: 11px;
  color: #777;
  margin-top: 2px;
}
.min-cell.not-imported .mc-total { display: none; }
.min-cell .mc-type {
  display: inline-block;
  font-size: 10px; color: #888;
  background: #f0f0f0;
  padding: 1px 6px; border-radius: 8px;
  width: fit-content;
}
.min-cell .mc-status {
  font-size: 11.5px; font-weight: 500;
}
.min-cell .mc-status.ok { color: #2f6a1d; }
.min-cell .mc-status.pending { color: #888; }
.min-cell .mc-status.ok { color: #2f6a1d; }
.min-cell .mc-status.pending { color: #888; }
/* v0.4.9: 行政院本院系統 hint */
.min-cell .mc-branch-hint {
  display: inline-block; margin-top: 2px;
  font-size: 10.5px; color: #5b6e94; font-weight: 500;
  padding: 1px 5px; border-radius: 3px;
  background: #eef4ff; border: 1px solid #cfdcf2;
}
.min-cell .mc-branch-hint.sub {
  color: #7a6b3a; background: #fff8e1; border-color: #f0d883;
}

/* 預算書抓取來源表 */
.tbl-sources {
  width: 100%; border-collapse: collapse; font-size: 12px;
  margin: 6px 0 18px;
}
.tbl-sources th, .tbl-sources td {
  border: 1px solid #e6e6e6; padding: 5px 8px;
  vertical-align: middle;
}
.tbl-sources th { background: #f4f4f4; font-weight: 600; }
.tbl-sources td.num { text-align: center; font-variant-numeric: tabular-nums; }
.tbl-sources td.src-url a { color: #5b8def; text-decoration: none; font-size: 11.5px; }
.tbl-sources td.src-url a:hover { text-decoration: underline; }

.src-st {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.src-st.imported   { background: #e0f5dc; color: #2f6a1d; }
.src-st.downloaded { background: #fff3d6; color: #8a5a00; }
.src-st.none       { color: #888; background: #f0f0f0; }
.src-st.absent     { color: #aaa; background: #ececec; }

/* =================== 組織樹 v2 (Polished) =================== */
:root {
  --st-green-bg: #e7f5e0;
  --st-green-fg: #2c6219;
  --st-amber-bg: #fff4d6;
  --st-amber-fg: #8a5a00;
  --st-red-bg: #ffe4e4;
  --st-red-fg: #b22222;
  --st-red-bd: #f4a4a4;
  --st-gray-bg: #f0f0ee;
  --st-gray-fg: #999;
  --st-blue-bg: #eef2f7;
  --st-blue-fg: #5b6b85;
}

/* card head toolbar (filter bar) */
.status-card-head {
  flex-wrap: wrap;
  gap: 10px;
}
.status-card-head h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tree-search {
  width: 180px;
  padding: 5px 10px;
  border: 1px solid #d6d6d2;
  border-radius: 16px;
  font-size: 12px;
  background: #fff;
  outline: none;
}
.tree-search:focus { border-color: #a0a09a; }
.tg-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: #555;
  background: #f5f5f2;
  padding: 4px 9px;
  border-radius: 14px;
  cursor: pointer;
  user-select: none;
}
.tg-chip input { margin: 0; cursor: pointer; }
.tg-chip:has(input:checked) {
  background: #2c2c2a; color: #fff;
}

.status-tree { display: flex; flex-direction: column; gap: 5px; }

/* ministry-level card */
.org-group {
  border: 1px solid #e8e8e3;
  border-radius: 8px;
  background: #fcfcfa;
  transition: border-color 0.15s;
}
.org-group[open] { border-color: #d8d8d2; background: #fff; }
.org-group.is-done { opacity: 0.85; }
.org-group.is-done .org-name { color: #555; }

.org-head {
  cursor: pointer;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 28px 60px 1fr auto;
  align-items: center;
  gap: 12px;
  list-style: none;
  user-select: none;
}
.org-head::-webkit-details-marker { display: none; }
.org-toggle {
  color: #b0b0a8;
  font-size: 11px;
  display: inline-block;
  transition: transform 0.15s;
  text-align: center;
}
.org-group[open] .org-toggle { transform: rotate(90deg); }
.org-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #b0b0a8;
  font-size: 11px;
  letter-spacing: -0.3px;
}
.org-name {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a17;
}

/* progress bar + stats on right side */
.org-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.og-bar {
  width: 110px;
  height: 6px;
  border-radius: 3px;
  background: #ececea;
  overflow: hidden;
  display: flex;
}
.og-bar-fill {
  height: 100%;
  background: var(--st-green-fg);
  transition: width 0.3s;
}
.og-bar-fill.partial { background: linear-gradient(90deg, var(--st-green-fg), #6cb04a); }
.og-pct {
  font-size: 11.5px;
  font-weight: 700;
  color: #444;
  min-width: 30px;
  text-align: right;
}
.org-counts {
  display: flex;
  gap: 4px;
  font-size: 11px;
}
.org-counts .cnt {
  padding: 1px 7px;
  border-radius: 9px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
}
.cnt.imp { background: var(--st-green-bg); color: var(--st-green-fg); }
.cnt.dl  { background: var(--st-amber-bg); color: var(--st-amber-fg); }
.cnt.lm  { background: var(--st-red-bg); color: var(--st-red-fg); border: 1px solid var(--st-red-bd); }
.cnt.mu  { background: var(--st-gray-bg); color: var(--st-gray-fg); }
.cnt.zero { opacity: 0.3; }

/* agency rows */
.ag-list {
  list-style: none;
  margin: 0;
  padding: 2px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid #f0f0ee;
}
.ag-row {
  display: grid;
  grid-template-columns: 86px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 5px;
  border-left: 3px solid transparent;
}
.ag-row.is-filtered-out { display: none; }
.ag-row:hover { background: #f7f7f3; }
.ag-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: #b0b0a8;
}
.ag-name { color: #333; }

.ag-row.ag-imported { border-left-color: var(--st-green-fg); }
.ag-row.ag-imported .ag-name { color: #1a4f08; }
.ag-row.ag-downloaded { background: #fffaef; border-left-color: var(--st-amber-fg); }
.ag-row.ag-likely_missing {
  background: #fff5f5;
  border-left-color: #d04848;
}
.ag-row.ag-likely_missing .ag-name { color: var(--st-red-fg); font-weight: 600; }
.ag-row.ag-no_independent_pdf { color: #b8b8b3; opacity: 0.75; }
.ag-row.ag-no_independent_pdf .ag-name { color: #b8b8b3; }
.ag-row.ag-unknown { color: #888; }

.ag-chip {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  white-space: nowrap;
  font-weight: 600;
}
.ag-chip.imported   { background: var(--st-green-bg); color: var(--st-green-fg); }
.ag-chip.downloaded { background: var(--st-amber-bg); color: var(--st-amber-fg); }
.ag-chip.missing    { background: var(--st-red-bg); color: var(--st-red-fg); border: 1px solid var(--st-red-bd); }
.ag-chip.deprecated   { background: #e5e5e5; color: #777; border: 1px solid #bbb; text-decoration: line-through; }
.ag-chip.not-published { background: #f3e8ff; color: #6b21a8; border: 1px solid #c084fc; }
.ag-row.ag-not_published { opacity: .65; }
.fund-row.state-deprecated { opacity: .55; }
.fund-row.state-deprecated .c-fund b { text-decoration: line-through; color: #888; }
.ag-chip.unknown    { background: var(--st-blue-bg); color: var(--st-blue-fg); }
.ag-chip.absent     { color: #bbb; background: transparent; font-weight: 400; }

.ag-merged {
  margin-top: 4px;
  border-top: 1px dashed #ececea;
  padding-top: 4px;
}
.ag-merged-head {
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11.5px;
  user-select: none;
  color: #999;
}
.ag-merged-head::-webkit-details-marker { display: none; }
.ag-merged-head::before { content: "▸ "; color: #ccc; }
.ag-merged[open] .ag-merged-head::before { content: "▾ "; }
.ag-merged[open] .ag-merged-head { color: #555; }
.ag-act { display: flex; gap: 4px; min-width: 70px; justify-content: flex-end; }

/* KPI 改 4 卡 + 顏色 hint */
.status-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.kpi.kpi-good .kpi-value { color: var(--st-green-fg); }
.kpi.kpi-warn .kpi-value { color: var(--st-amber-fg); }
.kpi.kpi-danger .kpi-value { color: var(--st-red-fg); }

/* =================== 待辦清單 =================== */
#todo-card { border-left: 4px solid var(--st-red-bd); }

.td-group {
  background: #fff;
  border: 1px solid #e8e8e3;
  border-radius: 6px;
  margin-bottom: 5px;
}
.td-group[open] { border-color: #d8d8d2; }
.td-head {
  cursor: pointer;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 22px 50px 1fr auto;
  align-items: center;
  gap: 10px;
  list-style: none;
  user-select: none;
}
.td-head::-webkit-details-marker { display: none; }
.td-toggle { color: #b0b0a8; font-size: 10px; transition: transform 0.15s; }
.td-group[open] .td-toggle { transform: rotate(90deg); }
.td-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #aaa;
  font-size: 11px;
}
.td-mname { font-weight: 600; font-size: 13.5px; color: #1a1a17; }
.td-prog {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-variant-numeric: tabular-nums;
}
.td-pct {
  font-weight: 700; min-width: 32px; text-align: right; color: #444;
}
.td-bar {
  width: 80px; height: 6px; border-radius: 3px;
  background: #ececea; overflow: hidden;
}
.td-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--st-green-fg), #6cb04a);
  transition: width 0.3s;
}
.td-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 8px 70px;
  display: flex; flex-direction: column; gap: 3px;
  border-top: 1px dashed #e8e8e3; padding-top: 6px;
}
.td-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 12.5px;
}
.td-row:hover { background: #fafaf5; }
.td-row.td-likely_missing { background: #fff5f5; border-left: 3px solid #d04848; padding-left: 6px; }
.td-row.td-likely_missing .td-name { color: var(--st-red-fg); font-weight: 600; }
.td-row.td-downloaded { background: #fffaef; }
.td-row.td-unknown { color: #888; }
.td-name { font-size: 13px; }

#refresh-status { margin-left: 8px; vertical-align: middle; }

/* 主畫面 topbar 徽章紅色化（有待辦） */
#stats-badge.has-pending {
  background: #ffe4e4;
  color: var(--st-red-fg);
  border: 1px solid var(--st-red-bd);
  font-weight: 600;
  cursor: pointer;
}
#stats-badge.has-pending:hover { background: #ffd0d0; }

/* v0.4.3 R20: stub 說明（整段引用非精純切段）視覺降權 */
.ed-explain-stub {
  background: #fff8e6;
  border-left: 3px solid #d4a017;
  padding: 6px 10px;
  font-style: italic;
  color: #6b5400;
}
.ed-explain-stub .stub-badge {
  display: inline-block;
  font-size: 0.85em;
  font-weight: 600;
  color: #d4a017;
  margin-bottom: 4px;
  font-style: normal;
  cursor: help;
}

/* BP_DESC_AUTOFILL：說明空白自動彙整卡（與原文分區、虛線框 + 🤖 徽章） */
.auto-digest {
  margin-top: 8px;
  border: 1px dashed rgba(110, 150, 220, 0.45);
  border-radius: 8px;
  padding: 10px 12px;
}
.auto-digest .adg-badge {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(110, 150, 220, 0.14);
  color: #5b7fc7;
  margin-bottom: 6px;
}
html[data-theme="dark"] .auto-digest .adg-badge { color: #9db8ff; }
.auto-digest .adg-disclaimer { font-size: 0.82em; margin-bottom: 8px; }
.auto-digest .adg-sec { margin: 8px 0; }
.auto-digest .adg-title { margin: 0 0 4px; font-size: 0.9em; opacity: 0.85; }
.auto-digest .adg-line { font-size: 0.92em; line-height: 1.55; }
.auto-digest .adg-note { font-size: 0.8em; margin-top: 3px; }

/* ============================================================
   v0.5 附屬基金 section — separate block from 公務 budget tree
   Different color (teal) to distinguish from blue/red public budget
   ============================================================ */
.exp-fund-section {
  margin-top: 32px;
  padding: 16px;
  background: linear-gradient(180deg, #e6f7f5 0%, #f0fafa 100%);
  border: 2px solid #14b8a6;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(20, 184, 166, 0.15);
}

.fund-section-title {
  margin: 0 0 4px 0;
  color: #0f766e;
  font-size: 1.15em;
  font-weight: 700;
}

.fund-section-hint {
  margin: 0 0 12px 0;
  font-size: 0.85em;
  color: #555;
}

.exp-fund-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.exp-fund-tree .fund-tn {
  margin-bottom: 2px;
}

/* 基金 top row — slightly larger / bold */
.exp-fund-tree .is-fund-top > .tn-row-wrap > .fund-row {
  background: #14b8a6;
  color: #fff;
  font-weight: 700;
  border: 1px solid #0f766e;
}

.exp-fund-tree .is-fund-top > .tn-row-wrap > .fund-row:hover {
  background: #0f766e;
}

/* 基金 inner rows (目 / 分支計畫 / 用途別 等) — teal-tinted, no level prefix */
.exp-fund-tree .fund-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 0.95em;
  transition: filter 0.12s;
}

.exp-fund-tree .fund-row:hover {
  filter: brightness(0.93);
}

/* v0.5.1: 不同色系 per level - rainbow palette for clear distinction */

/* L1 = 目 (大表分類: 保險成本/業務費用 等) — 深紫 (royal purple) */
.exp-fund-tree .fund-row.fund-l1 {
  background: #6b21a8;
  color: #fff;
  font-weight: 700;
  border-color: #581c87;
}
.exp-fund-tree .fund-row.fund-l1 .fund-name,
.exp-fund-tree .fund-row.fund-l1 .fund-amt { color: #fff; }

/* L2 = 分支計畫 — 藍 (sky blue) */
.exp-fund-tree .fund-row.fund-l2 {
  background: #1e40af;
  color: #fff;
  font-weight: 600;
  border-color: #1e3a8a;
}
.exp-fund-tree .fund-row.fund-l2 .fund-name,
.exp-fund-tree .fund-row.fund-l2 .fund-amt { color: #fff; }

/* L3 = 用途別大類 — 綠 (emerald) */
.exp-fund-tree .fund-row.fund-l3 {
  background: #15803d;
  color: #fff;
  font-weight: 600;
  border-color: #166534;
}
.exp-fund-tree .fund-row.fund-l3 .fund-name,
.exp-fund-tree .fund-row.fund-l3 .fund-amt { color: #fff; }

/* L4 = 用途別 (leaf) — 橘 (orange) */
.exp-fund-tree .fund-row.fund-l4 {
  background: #fff7ed;
  color: #7c2d12;
  border-color: #fb923c;
  border-width: 1px;
}
.exp-fund-tree .fund-row.fund-l4 .fund-name { color: #7c2d12; }
.exp-fund-tree .fund-row.fund-l4 .fund-amt { color: #c2410c; font-weight: 700; }

/* L5+ deep — 粉紅 (rose) — 罕見 */
.exp-fund-tree .fund-row.fund-l5,
.exp-fund-tree .fund-row.fund-l6 {
  background: #fdf2f8;
  color: #831843;
  border-color: #f9a8d4;
  font-size: 0.9em;
}
.exp-fund-tree .fund-row.fund-l5 .fund-amt,
.exp-fund-tree .fund-row.fund-l6 .fund-amt { color: #be185d; font-weight: 600; }

/* Section title with amount inline */
.fund-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fund-section-amt {
  font-size: 0.95em;
  color: #0f766e;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fund-section-title:hover {
  filter: brightness(1.1);
}

/* Indentation per child level */
.exp-fund-tree .tn-children {
  list-style: none;
  padding-left: 20px;
  margin: 4px 0;
}

.exp-fund-tree .fund-name {
  color: #134e4a;
  font-weight: 500;
}

.exp-fund-tree .is-fund-top .fund-name {
  color: #fff;
}

.exp-fund-tree .fund-amt {
  color: #0f766e;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.exp-fund-tree .is-fund-top .fund-amt {
  color: #fff;
}

/* Toggle button — keep simple */
.exp-fund-tree .tn-toggle {
  background: transparent;
  border: none;
  color: #0f766e;
  font-size: 0.75em;
  cursor: pointer;
  padding: 0 4px;
  min-width: 16px;
}

.exp-fund-tree .tn-toggle:disabled {
  color: #aac6c1;
  cursor: default;
}

/* === 政府基金預算 table (import_status page) === */
.status-funds-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.funds-group {
  margin-bottom: 24px;
}
.funds-group-title {
  margin: 8px 0;
  font-size: 1em;
  border-left: 4px solid #6e8c87;
  padding-left: 8px;
}
.tbl-funds {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.tbl-funds th,
.tbl-funds td {
  padding: 6px 8px;
  border-bottom: 1px solid #e2ebe9;
  text-align: left;
  vertical-align: top;
}
.tbl-funds th {
  background: #f3f6f5;
  font-weight: 600;
  font-size: 0.85em;
  color: #4a5d59;
}
.tbl-funds .c-amt {
  text-align: right;
  white-space: nowrap;
}
.tbl-funds .c-state {
  width: 50px;
  text-align: center;
}
.tbl-funds .fund-row.state-missing {
  background: #fff5f5;
}
.tbl-funds .fund-row.state-downloaded {
  background: #fffbed;
}
.tbl-funds .fund-row.state-imported {
  background: #f3faf6;
}
.ag-chip.imported {
  background: #c8e6c9;
  color: #2e6630;
}
.ag-chip.downloaded {
  background: #fff3b8;
  color: #8a6d10;
}

/* ============================================================
   v0.5.2 附屬基金 merged into main tree
   每個基金以「機關」kind 掛在主管下，用 .is-fund-row 標記套金色/茶色配色
   badge_override="基金" 用 .is-fund-top 套加重視覺
   ============================================================ */
.exp-tree .tn.is-fund-row > .tn-row-wrap > .tn-row {
  background: linear-gradient(90deg, #fff8e1 0%, #fffdf7 100%);
  border-left: 3px solid #d4a017;
}
.exp-tree .tn.is-fund-row > .tn-row-wrap > .tn-row:hover {
  background: linear-gradient(90deg, #fef3c7 0%, #fffaf0 100%);
}
.exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row {
  background: linear-gradient(90deg, #0f766e 0%, #14b8a6 100%);
  color: #fff;
  border-left: 4px solid #047857;
}
.exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-name,
.exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-amt,
.exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-code-prefix {
  color: #fff;
}
.exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row:hover {
  background: linear-gradient(90deg, #115e59 0%, #0d9488 100%);
}
.exp-tree .badge-fund {
  background: #fbbf24;
  color: #78350f;
  border-color: #d97706;
  font-weight: 700;
}
.exp-tree .tn.is-fund-top .badge-fund {
  background: #fde68a;
  color: #78350f;
}

/* ============================================================
   v0.6.8 (2026-05-30) 6 大類基金 fund_type badge 配色
   各類用不同 hue 區分 — 解析重點/UI template 不同
   ============================================================ */
/* I 營業基金 — 藍 (公司會計式) */
.exp-tree .badge-fund.fund-type-ent {
  background: #dbeafe; color: #1e3a8a; border-color: #3b82f6;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-ent {
  background: #bfdbfe; color: #1e3a8a;
}
/* II 作業基金 — 翠綠 (業務收支式) */
.exp-tree .badge-fund.fund-type-ops {
  background: #d1fae5; color: #064e3b; border-color: #10b981;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-ops {
  background: #a7f3d0; color: #064e3b;
}
/* III 特別收入基金 — 金 (用途編列式，現狀色) */
.exp-tree .badge-fund.fund-type-sip {
  background: #fde68a; color: #78350f; border-color: #d97706;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-sip {
  background: #fef3c7; color: #78350f;
}
/* IV 資本計畫基金 — 橘 (建設計畫式) */
.exp-tree .badge-fund.fund-type-capital {
  background: #fed7aa; color: #7c2d12; border-color: #ea580c;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-capital {
  background: #fdba74; color: #7c2d12;
}
/* V 債務基金 — 暗紅 (舉借/還本/利息) */
.exp-tree .badge-fund.fund-type-debt {
  background: #fecaca; color: #7f1d1d; border-color: #dc2626;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-debt {
  background: #fca5a5; color: #7f1d1d;
}
/* VI 信託基金 — 紫 (信託會計式) */
.exp-tree .badge-fund.fund-type-trust {
  background: #e9d5ff; color: #581c87; border-color: #9333ea;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-trust {
  background: #d8b4fe; color: #581c87;
}
/* 非基金 — 行政法人 / 財團法人 (灰，已有 budget_type=行政法人 邏輯區隔) */
.exp-tree .badge-fund.fund-type-admin,
.exp-tree .badge-fund.fund-type-found {
  background: #e5e7eb; color: #1f2937; border-color: #6b7280;
}
.exp-tree .tn.is-fund-top .badge-fund.fund-type-admin,
.exp-tree .tn.is-fund-top .badge-fund.fund-type-found {
  background: #d1d5db; color: #1f2937;
}

/* ============================================================
   v0.6.8 (2026-05-30) 基金 6 大類分類規則 legend (explorer 下方)
   ============================================================ */
.exp-fund-type-legend {
  margin: 24px 0 16px;
  padding: 12px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
}
.exp-fund-type-legend summary {
  cursor: pointer;
  font-weight: 600;
  color: #374151;
  padding: 4px 0;
  user-select: none;
}
.exp-fund-type-legend summary:hover { color: #111827; }
.fund-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.ft-card {
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 4px solid;
  background: #fff;
}
.ft-card .ft-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.ft-card .ft-icon { font-size: 18px; }
.ft-card .ft-desc { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.ft-card .ft-points { font-size: 11px; color: #374151; line-height: 1.6; }
.ft-card .ft-points small { color: #9ca3af; }
.ft-card.ft-ent     { border-color: #3b82f6; background: #eff6ff; }
.ft-card.ft-ops     { border-color: #10b981; background: #ecfdf5; }
.ft-card.ft-sip     { border-color: #d97706; background: #fffbeb; }
.ft-card.ft-capital { border-color: #ea580c; background: #fff7ed; }
.ft-card.ft-debt    { border-color: #dc2626; background: #fef2f2; }
.ft-card.ft-trust   { border-color: #9333ea; background: #faf5ff; }
.ft-rule {
  margin-top: 14px;
  padding: 8px 12px;
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  color: #4b5563;
  line-height: 1.7;
}
.ft-rule code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}

/* ============================================================
   v0.5.3 未匯入紅徽章 + popover
   funds.csv 期望但 budget_items.csv 沒對應 → 款 (主管) node 顯示「⚠ 缺 N」
   點擊徽章 → 浮出 .missing-popover 列出全部待匯入 fund/行政法人
   ============================================================ */
.tn-missing-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #dc2626;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 0 0 1px #991b1b, 0 1px 3px rgba(220, 38, 38, 0.4);
  transition: transform 0.1s ease, background 0.1s ease;
  user-select: none;
}
.tn-missing-badge:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}
.tn-missing-badge:active {
  transform: translateY(0);
}

.missing-popover {
  position: fixed;
  min-width: 340px;
  max-width: 480px;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 2px solid #dc2626;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 1000;
  font-size: 13px;
}
.missing-popover .mp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.missing-popover .mp-close {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.missing-popover .mp-close:hover {
  background: rgba(255, 255, 255, 0.35);
}
.missing-popover .mp-body {
  overflow-y: auto;
  padding: 8px 14px 12px;
}
.missing-popover .mp-group {
  margin-top: 8px;
}
.missing-popover .mp-group h5 {
  margin: 6px 0 4px;
  font-size: 13px;
  color: #7f1d1d;
  border-bottom: 1px solid #fecaca;
  padding-bottom: 3px;
}
.missing-popover .mp-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.missing-popover .mp-group li {
  padding: 5px 0;
  border-bottom: 1px dashed #f3f4f6;
}
.missing-popover .mp-group li:last-child {
  border-bottom: 0;
}
.missing-popover .mp-group li b {
  display: block;
  color: #111827;
  font-weight: 600;
}
.missing-popover .mp-group li small {
  display: block;
  margin-top: 2px;
  color: #6b7280;
  font-size: 11px;
}
.missing-popover .mp-foot {
  padding: 8px 14px;
  background: #fef2f2;
  color: #7f1d1d;
  font-size: 11px;
  border-top: 1px solid #fecaca;
}

/* === Rule 21 父子金額不符 warning badge (v0.6.2 / 2026-05-29) === */
.tn-warn.sum-mismatch {
  display: inline-block;
  color: #d97706;          /* amber-600 */
  background: #fff7ed;     /* amber-50 */
  border: 1px solid #fcd34d; /* amber-300 */
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 6px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: help;
}
.tn-warn.sum-mismatch:hover {
  background: #fed7aa;     /* amber-200 */
}

/* ============================================================ */
/* v0.7.2 (2026-05-30) UI Toggles: 主題 (🌙) + 狀態裝飾 (👁)        */
/* ============================================================ */

.ui-toggles {
  display: flex; align-items: center; gap: 4px;
  margin-left: 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px; padding: 2px 4px;
}
.ui-tg-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; font-size: 15px; line-height: 1;
  border-radius: 4px;
  transition: background 0.12s, transform 0.12s;
  font-family: inherit;
  color: var(--c-text);
}
.ui-tg-btn:hover { background: rgba(0,0,0,0.08); transform: scale(1.1); }
.ui-tg-btn:active { background: rgba(0,0,0,0.15); transform: scale(0.95); }

/* ============================================================ */
/* 夜色主題 (data-theme="dark")                                   */
/* 採半透明遮罩 + 全套色票，cover 主要 surface                       */
/* ============================================================ */

html[data-theme="dark"] {
  --c-bg: #0f1419;
  --c-panel: #1a1f2c;
  --c-text: #d4d8e0;
  --c-muted: #8a96a8;
  --c-border: #2c3340;
  --c-accent: #5ba0ff;
  --c-accent-dark: #4080d0;
  --c-danger: #ff6b6b;
  --c-ok: #66bb6a;
  --c-warn: #ffa726;
  --c-row-alt: #161b25;
}

/* topbar */
html[data-theme="dark"] .topbar {
  background: #14181f; border-bottom: 1px solid #2c3340;
  color: #d4d8e0;
}
html[data-theme="dark"] .topbar h1 { color: #e8ebf0; }
html[data-theme="dark"] .navlink { color: #c9d0db; }
html[data-theme="dark"] .navlink.active,
html[data-theme="dark"] .navlink:hover { background: #2a3140; color: #fff; }
html[data-theme="dark"] .ministry-switcher { color: #c9d0db; }
html[data-theme="dark"] .ui-toggles,
html[data-theme="dark"] .font-zoom { background: rgba(255,255,255,0.06); }
html[data-theme="dark"] .ui-tg-btn:hover,
html[data-theme="dark"] .fz-btn:hover { background: rgba(255,255,255,0.12); }
html[data-theme="dark"] .ui-tg-btn:active,
html[data-theme="dark"] .fz-btn:active { background: rgba(255,255,255,0.2); }

/* select / input */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #1a1f2c; color: #d4d8e0;
  border-color: #2c3340;
}
html[data-theme="dark"] input::placeholder { color: #5a6478; }

/* 主介面 ministry cards */
html[data-theme="dark"] .min-cell {
  background: #1c2230 !important;
  border-color: #2c3340 !important;
  color: #d4d8e0;
}
html[data-theme="dark"] .min-cell.imported { background: #1f2837 !important; }
html[data-theme="dark"] .min-cell:hover { background: #2a3245 !important; }
html[data-theme="dark"] .min-cell.is-reviewed { background: #1c2e1f !important; border-color: #4caf50 !important; }
html[data-theme="dark"] .mc-kuan { color: #ffb74d; }
html[data-theme="dark"] .mc-name { color: #e8ebf0; }
html[data-theme="dark"] .mc-type { color: #8a96a8; }
html[data-theme="dark"] .mc-status.ok { color: #81c784; }
html[data-theme="dark"] .mc-status.pending { color: #ff8a65; }
html[data-theme="dark"] .mc-review-box {
  background: rgba(255, 193, 7, 0.12); color: #ffd54f; border-color: #c69500;
}
html[data-theme="dark"] .mc-bs-imported {
  background: rgba(76, 175, 80, 0.18); color: #81c784; border-color: #4caf50;
}
html[data-theme="dark"] .mc-bs-missing {
  background: rgba(120, 130, 145, 0.18); color: #b0bec5; border-color: #546e7a;
}

/* 工具列、搜尋、tabs */
html[data-theme="dark"] .db4-toolbar { background: #14181f; border-color: #2c3340; }
html[data-theme="dark"] .count-badge { background: #2c3340; color: #c9d0db; }
html[data-theme="dark"] .db4-legend { color: #8a96a8; }

/* explorer 樹 */
html[data-theme="dark"] .explorer-page { color: #d4d8e0; }
html[data-theme="dark"] .explorer-head { color: #d4d8e0; }
html[data-theme="dark"] .exp-desc { color: #b0b8c5 !important; }
html[data-theme="dark"] .exp-footnote {
  background: rgba(255, 152, 0, 0.10); border-left-color: #ffa726; color: #ffb74d;
}
html[data-theme="dark"] .exp-tree-wrap,
html[data-theme="dark"] .exp-detail { background: #1a1f2c; border-color: #2c3340; }
html[data-theme="dark"] .exp-toolbar { background: #14181f; border-bottom-color: #2c3340; }
html[data-theme="dark"] .tn-row-wrap { border-bottom-color: #232936; }
html[data-theme="dark"] .tn-row-wrap:hover { background: #232936; }
html[data-theme="dark"] .tn-name { color: #d4d8e0; }
html[data-theme="dark"] .tn-code-prefix { color: #6c7585; }
html[data-theme="dark"] .tn-amt { color: #b0b8c5; }
/* 樹列金額按量級上色：light 用紅/橙/藍(#b80000…) 透過高特異度洩漏進夜色 → 紅字刺眼且與內文金額(琥珀)不一致。
   改成「金→柔藍→muted」量級 ramp，與 narrative hl-amt 同系，保留「越大越亮」線索（2026-06-17）。*/
html[data-theme="dark"] .tn-amt.amt-xxl { color: #fcd34d; }   /* 最大額=亮金 */
html[data-theme="dark"] .tn-amt.amt-xl  { color: #fbbf24; }   /* 大額=金 */
html[data-theme="dark"] .tn-amt.amt-l   { color: #93c5fd; }   /* 中額=柔藍 */
html[data-theme="dark"] .tn-amt.amt-m   { color: #94a3b8; }   /* 小額=muted slate */
html[data-theme="dark"] .tn.is-fund-row > .tn-row-wrap {
  background: linear-gradient(to right, rgba(212, 175, 55, 0.10) 0%, transparent 50%);
}
html[data-theme="dark"] .tn.is-fund-top > .tn-row-wrap {
  background: linear-gradient(to right, rgba(212, 175, 55, 0.22) 0%, rgba(212, 175, 55, 0.08) 100%);
}

/* fund detail 4 cards */
html[data-theme="dark"] .fund-amts .ed-amt.main {
  background: linear-gradient(135deg, #1b3a36 0%, #1a4a44 100%);
  border-left-color: #00897b;
}
html[data-theme="dark"] .fund-amts .ed-amt.main .val { color: #80cbc4; }
html[data-theme="dark"] .fund-amts .fund-amt-income { background: #16291a; }
html[data-theme="dark"] .fund-amts .fund-amt-income .val { color: #81c784; }
html[data-theme="dark"] .fund-amts .fund-amt-expense { background: #2c1517; }
html[data-theme="dark"] .fund-amts .fund-amt-expense .val { color: #ef9a9a; }
html[data-theme="dark"] .fund-amts .fund-amt-surplus { background: #2c2014; }
html[data-theme="dark"] .fund-amts .fund-amt-surplus .val { color: #ffb74d; }
html[data-theme="dark"] .fund-amts .ed-amt .lab { color: #aab4c4; }
html[data-theme="dark"] .fund-amts .val .val-na { color: #5a6478 !important; }

/* 詳情卡 */
html[data-theme="dark"] .ed-card { background: #1a1f2c; color: #d4d8e0; }
html[data-theme="dark"] .ed-amts .ed-amt { background: #232936; }
html[data-theme="dark"] .ed-amts .ed-amt.main { background: #233144; border-color: #5ba0ff; }
html[data-theme="dark"] .ed-amt .lab { color: #aab4c4; }
html[data-theme="dark"] .ed-amt .val { color: #e8ebf0; }
html[data-theme="dark"] .ed-meta dt { color: #aab4c4; }
html[data-theme="dark"] .ed-meta dd { color: #d4d8e0; }
html[data-theme="dark"] .ed-section summary { color: #d4d8e0; }
html[data-theme="dark"] .ed-rich { color: #c9d0db; }
html[data-theme="dark"] .ed-rich .ex-hi-budget {
  background: rgba(91, 160, 255, 0.12); border-left: 3px solid #5ba0ff;
}
html[data-theme="dark"] .ed-rich .ex-hi-overview {
  background: rgba(255, 167, 38, 0.10); border-left: 3px solid #ffa726;
}

/* 搜尋結果 list */
html[data-theme="dark"] .exp-match-list { background: #1a1f2c; border-color: #ff8a65; }
html[data-theme="dark"] .ml-head { background: #14181f; color: #ffb74d; border-color: #2c3340; }
html[data-theme="dark"] .ml-row { background: #1a1f2c; border-color: #2c3340; }
html[data-theme="dark"] .ml-row:hover { background: #232936; }
html[data-theme="dark"] .ml-row.ml-row-fund {
  background: linear-gradient(to right, rgba(255, 215, 0, 0.10) 0%, transparent 50%);
}
html[data-theme="dark"] .ml-name { color: #d4d8e0; }
html[data-theme="dark"] .ml-path { color: #8a96a8; }
html[data-theme="dark"] .ml-amt { color: #c9d0db; }
html[data-theme="dark"] .ml-tabs { background: #14181f; border-bottom-color: #2c3340; }
html[data-theme="dark"] .ml-tab { background: #1a1f2c; border-color: #3a4456; color: #b0b8c5; }
html[data-theme="dark"] .ml-tab:hover { background: #232936; border-color: #5ba0ff; }
html[data-theme="dark"] .ml-tab.is-active { background: #5ba0ff; border-color: #5ba0ff; color: #0f1419; }
html[data-theme="dark"] .ml-tab-count { background: rgba(255,255,255,0.10); color: inherit; }

/* tree row checkboxes / pills */
html[data-theme="dark"] .tn-review-box {
  background: rgba(255, 193, 7, 0.12); color: #ffd54f; border-color: #c69500;
}
html[data-theme="dark"] .tn-bs-imported {
  background: rgba(76, 175, 80, 0.18); color: #81c784; border-color: #4caf50;
}
html[data-theme="dark"] .tn-bs-missing {
  background: rgba(120, 130, 145, 0.18); color: #b0bec5; border-color: #546e7a;
}
html[data-theme="dark"] .tn-pdf-btn {
  background: rgba(91, 160, 255, 0.18); color: #5ba0ff; border-color: #5ba0ff;
}
html[data-theme="dark"] .mc-pdf-btn {
  background: rgba(91, 160, 255, 0.18); color: #5ba0ff; border-color: #5ba0ff;
}

/* import_status page */
html[data-theme="dark"] .tbl-sources,
html[data-theme="dark"] .tbl-books,
html[data-theme="dark"] .tbl-funds,
html[data-theme="dark"] .tbl-ref { background: #1a1f2c; color: #d4d8e0; }
html[data-theme="dark"] .tbl-sources thead,
html[data-theme="dark"] .tbl-books thead,
html[data-theme="dark"] .tbl-funds thead,
html[data-theme="dark"] .tbl-ref thead { background: #232936; color: #e8ebf0; }
html[data-theme="dark"] .tbl-sources td,
html[data-theme="dark"] .tbl-books td,
html[data-theme="dark"] .tbl-funds td,
html[data-theme="dark"] .tbl-ref td { border-color: #2c3340; }
html[data-theme="dark"] .tbl-sources tr:hover td,
html[data-theme="dark"] .tbl-books tr:hover td,
html[data-theme="dark"] .tbl-funds tr:hover td { background: #232936; }

/* workspace */
html[data-theme="dark"] .ws-card,
html[data-theme="dark"] .ws-form { background: #1a1f2c; border-color: #2c3340; color: #d4d8e0; }

/* button base */
html[data-theme="dark"] .btn { background: #2c3340; color: #d4d8e0; border-color: #3a4456; }
html[data-theme="dark"] .btn:hover { background: #3a4456; }
html[data-theme="dark"] .btn.primary { background: #5ba0ff; color: #0f1419; }
html[data-theme="dark"] .btn.primary:hover { background: #4080d0; }
html[data-theme="dark"] .btn.ghost { background: transparent; color: #aab4c4; }
html[data-theme="dark"] .btn.ghost:hover { background: #2c3340; }

/* scroll bar */
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: #14181f; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4456; border-radius: 5px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a5468; }

/* code / pre */
html[data-theme="dark"] code,
html[data-theme="dark"] pre { background: #232936; color: #e8ebf0; }

/* search highlight */
html[data-theme="dark"] mark.hl-search { background: #ffd700; color: #0f1419; }

/* footnote special handling */
html[data-theme="dark"] .ft-card { background: #1a1f2c; border-color: #2c3340; color: #d4d8e0; }
html[data-theme="dark"] .ft-head b { color: #e8ebf0; }
html[data-theme="dark"] .ft-desc { color: #aab4c4; }
html[data-theme="dark"] .ft-points { color: #b0b8c5; }

/* ============================================================ */
/* status-clean: 隱藏所有「已修好 / 已完成 / 已下載待配對」狀態裝飾  */
/* 點 👁 切換                                                     */
/* ============================================================ */

html.status-clean .mc-right-stack,
html.status-clean .mc-books,
html.status-clean .mc-review-box,
html.status-clean .mc-book-state,
html.status-clean .tn-review-box,
html.status-clean .tn-book-state,
html.status-clean .ag-chip,
html.status-clean .src-st {
  display: none !important;
}

/* 隱藏後 main page card 重新置中佈局 */
html.status-clean .min-cell { padding-top: 12px !important; }

/* 隱藏 funds_status 整列 状態 chip 但保留 row */
html.status-clean .tbl-funds .c-state .ag-chip { display: none !important; }
html.status-clean .tbl-funds .c-state::after {
  content: "—"; color: var(--c-muted); font-size: 0.85em;
}

/* =====================================================================
   v0.7.3 (2026-05-30) Sci-fi 夜色強化 — 收斂色調、neon badge、tech glow
   覆蓋 v0.7.2 既有 dark rules，採 cyan/violet/teal 主軸 + 微 glow
   ===================================================================== */

/* —— 主色票收緊 —— */
html[data-theme="dark"] {
  --c-bg: #0a0e17;            /* 深空黑 */
  --c-panel: #121826;         /* 卡片底 */
  --c-text: #e2e8f0;          /* 主文字 */
  --c-muted: #748296;         /* 次文字 */
  --c-border: #1f2937;        /* 細邊框 */
  --c-accent: #22d3ee;        /* cyan 主強調 */
  --c-accent-dark: #0891b2;
  --c-violet: #a78bfa;
  --c-ok: #34d399;            /* neon green */
  --c-warn: #fbbf24;
  --c-danger: #fb7185;
  --c-row-alt: #0f1521;
  --c-surface: #1b2335;       /* 卡片/輸入框/彈窗 panel 面（夜色）*/
  --c-surface-2: #0b1220;     /* 表頭/巢狀區塊次層底色（夜色）*/
  --glow-cyan: 0 0 6px rgba(34, 211, 238, 0.4);
  --glow-violet: 0 0 6px rgba(167, 139, 250, 0.4);
}

/* —— body 加微微 grid 紋路 (subtle tech vibe) —— */
html[data-theme="dark"] body {
  background:
    linear-gradient(rgba(34, 211, 238, 0.02) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(34, 211, 238, 0.02) 1px, transparent 1px) 0 0 / 32px 32px,
    #0a0e17 !important;
}

/* —— topbar: 深底 + cyan 底邊光 —— */
html[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, #0d1320 0%, #0a0e17 100%);
  border-bottom: 1px solid #1f2937;
  box-shadow: 0 1px 0 rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .brand h1 {
  color: #e2e8f0;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.25);
}
html[data-theme="dark"] .topbar .ver {
  color: #22d3ee; text-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}
html[data-theme="dark"] .year-badge {
  background: rgba(34, 211, 238, 0.15);
  color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.35);
}

html[data-theme="dark"] .navlink {
  color: #94a3b8; border-radius: 6px;
  transition: all 0.15s;
}
html[data-theme="dark"] .navlink:hover {
  background: rgba(34, 211, 238, 0.1); color: #67e8f9;
}
html[data-theme="dark"] .navlink.active {
  background: rgba(34, 211, 238, 0.18);
  color: #22d3ee;
  box-shadow: inset 0 -2px 0 #22d3ee;
}

/* topbar toggles */
html[data-theme="dark"] .ui-toggles,
html[data-theme="dark"] .font-zoom {
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .ui-tg-btn,
html[data-theme="dark"] .fz-btn { color: #cbd5e1; }
html[data-theme="dark"] .ui-tg-btn:hover,
html[data-theme="dark"] .fz-btn:hover {
  background: rgba(34, 211, 238, 0.15); color: #22d3ee;
}
html[data-theme="dark"] .stats-badge {
  background: rgba(34, 211, 238, 0.10);
  color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.25);
}

/* —— inputs / select —— */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0f172a; color: #e2e8f0;
  border: 1px solid #1f2937;
  transition: border-color 0.15s, box-shadow 0.15s;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  outline: none;
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] input::placeholder { color: #475569; }

/* —— main /database 部會卡片 —— */
html[data-theme="dark"] .db4-toolbar {
  background: #0d1320; border: 1px solid #1f2937;
}
html[data-theme="dark"] .min-cell {
  background: #121826 !important;
  border: 1px solid #1f2937 !important;
  color: #e2e8f0 !important;
  transition: all 0.15s;
}
html[data-theme="dark"] .min-cell.imported {
  background: #131c2e !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .min-cell.imported:hover {
  border-color: #22d3ee !important;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.3), 0 4px 12px rgba(34, 211, 238, 0.15) !important;
  transform: translateY(-1px);
}
html[data-theme="dark"] .min-cell.not-imported {
  background: #0e1421 !important; opacity: 0.7;
}
html[data-theme="dark"] .min-cell.is-reviewed {
  background: linear-gradient(135deg, #0f2018 0%, #131c2e 100%) !important;
  border-color: #34d399 !important;
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.25) !important;
}
html[data-theme="dark"] .min-cell.is-reviewed::before {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.08) 0%, transparent 50%) !important;
}

/* 分類色＝唯一整圈外框信號（府院青/部紫/委員會金/其他灰），四類清楚分離。
   specificity(3 類)+!important+排在 is-reviewed 之後 → 壓過「已修好」綠框，
   一張卡不再「又綠又紫」。已修好狀態改由底色微染＋「✓已修好」標籤呈現（見下）。 */
html[data-theme="dark"] .min-cell.cat-fu-yuan.imported  { border-color: #22d3ee !important; box-shadow: 0 0 0 1px rgba(34,211,238,.30), 0 0 10px rgba(34,211,238,.12) !important; }
html[data-theme="dark"] .min-cell.cat-bu.imported       { border-color: #a78bfa !important; box-shadow: 0 0 0 1px rgba(167,139,250,.30), 0 0 10px rgba(167,139,250,.12) !important; }
html[data-theme="dark"] .min-cell.cat-weiyuanhui.imported { border-color: #fbbf24 !important; box-shadow: 0 0 0 1px rgba(251,191,36,.30), 0 0 10px rgba(251,191,36,.12) !important; }
html[data-theme="dark"] .min-cell.cat-other.imported    { border-color: #94a3b8 !important; box-shadow: 0 0 0 1px rgba(148,163,184,.25) !important; }
/* 已修好：保留綠底微染當狀態信號，但不搶外框色（外框一律走分類色）。 */
html[data-theme="dark"] .min-cell.is-reviewed.cat-fu-yuan.imported,
html[data-theme="dark"] .min-cell.is-reviewed.cat-bu.imported,
html[data-theme="dark"] .min-cell.is-reviewed.cat-weiyuanhui.imported,
html[data-theme="dark"] .min-cell.is-reviewed.cat-other.imported { background: #16241b !important; }

html[data-theme="dark"] .mc-kuan { color: #67e8f9; font-weight: 600; }
html[data-theme="dark"] .mc-name { color: #f1f5f9; }
html[data-theme="dark"] .mc-type { color: #94a3b8; }
html[data-theme="dark"] .mc-status.ok { color: #34d399; }
html[data-theme="dark"] .mc-status.pending { color: #fbbf24; }
html[data-theme="dark"] .mc-branch-hint {
  background: rgba(167, 139, 250, 0.12); color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

/* status pills (主介面) */
html[data-theme="dark"] .mc-review-box {
  background: rgba(251, 191, 36, 0.10);
  color: #fbbf24; border-color: rgba(251, 191, 36, 0.4);
}
html[data-theme="dark"] .mc-bs-imported {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399; border-color: rgba(52, 211, 153, 0.4);
}
html[data-theme="dark"] .mc-bs-downloaded {
  background: rgba(251, 146, 60, 0.12) !important;
  color: #fb923c !important;
  border-color: rgba(251, 146, 60, 0.5) !important;
}
html[data-theme="dark"] .mc-bs-missing {
  background: rgba(116, 130, 150, 0.10);
  color: #94a3b8; border-color: rgba(116, 130, 150, 0.3);
}

/* legend dots */
html[data-theme="dark"] .db4-legend { color: #94a3b8; }
html[data-theme="dark"] .lg-fu-yuan { background: #22d3ee !important; box-shadow: 0 0 6px rgba(34, 211, 238, 0.5); }
html[data-theme="dark"] .lg-bu { background: #a78bfa !important; box-shadow: 0 0 6px rgba(167, 139, 250, 0.5); }
html[data-theme="dark"] .lg-weiyuanhui { background: #fbbf24 !important; box-shadow: 0 0 6px rgba(251, 191, 36, 0.5); }
html[data-theme="dark"] .lg-other { background: #94a3b8 !important; }

html[data-theme="dark"] .count-badge {
  background: rgba(34, 211, 238, 0.10);
  color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.3);
}

/* —— explorer 樹 —— */
html[data-theme="dark"] .explorer-head { color: #e2e8f0; }
html[data-theme="dark"] .exp-title { color: #f1f5f9; }
html[data-theme="dark"] .exp-title-bar { background: transparent; }
html[data-theme="dark"] .exp-ministry { color: #22d3ee; text-shadow: 0 0 8px rgba(34, 211, 238, 0.3); }
html[data-theme="dark"] .exp-year { color: #94a3b8; }
html[data-theme="dark"] .exp-desc { color: #94a3b8 !important; }
html[data-theme="dark"] .exp-footnote {
  background: rgba(251, 191, 36, 0.07);
  border-left: 3px solid #fbbf24;
  color: #fcd34d;
}
html[data-theme="dark"] .exp-fn-mark { color: #fbbf24; }

html[data-theme="dark"] .exp-tree-wrap,
html[data-theme="dark"] .exp-detail {
  background: #121826;
  border: 1px solid #1f2937;
}
html[data-theme="dark"] .exp-toolbar {
  background: #0d1320; border-bottom: 1px solid #1f2937;
}
html[data-theme="dark"] .lv-chip {
  background: #1a2032; border-color: #2c3340; color: #d4d8e0;
}
html[data-theme="dark"] .lv-chip:hover { background: #232b40; }
html[data-theme="dark"] .lv-chip.is-active {
  background: var(--c-accent); color: #fff; border-color: var(--c-accent);
}

/* tree rows — 重做底色 + 微 hover glow */
html[data-theme="dark"] .tn-row-wrap {
  background: transparent;
  border-bottom: 1px solid #1a2333;
}
html[data-theme="dark"] .tn-row-wrap:hover {
  background: rgba(34, 211, 238, 0.05);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .tn-row { color: #e2e8f0; }
html[data-theme="dark"] .tn-name { color: #e2e8f0; }
html[data-theme="dark"] .tn-code-prefix { color: #64748b; font-family: monospace; }
html[data-theme="dark"] .tn-amt { color: #cbd5e1; font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .tn-amt.amt-xxl { color: #fb7185; font-weight: 700; }
html[data-theme="dark"] .tn-amt.amt-xl  { color: #f472b6; }
html[data-theme="dark"] .tn-amt.amt-l   { color: #a78bfa; }
html[data-theme="dark"] .tn-amt.amt-m   { color: #cbd5e1; }
html[data-theme="dark"] .tn-toggle { color: #64748b; }
html[data-theme="dark"] .tn-toggle:hover { color: #22d3ee; }
html[data-theme="dark"] .tn-diff { color: #94a3b8; }
html[data-theme="dark"] .tn-diff.diff-up { color: #34d399; }
html[data-theme="dark"] .tn-diff.diff-down { color: #fb7185; }
html[data-theme="dark"] .tn-cut-hint { color: #475569; }

/* badge 全套：neon-on-dark */
html[data-theme="dark"] .tn-badge {
  font-weight: 700;
  background: transparent;
  border: 1px solid;
}
html[data-theme="dark"] .tn-badge.badge-款,
html[data-theme="dark"] .tn-badge.badge-主管        {
  background: rgba(34, 211, 238, 0.10); color: #22d3ee; border-color: rgba(34, 211, 238, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-項,
html[data-theme="dark"] .tn-badge.badge-機關        {
  background: rgba(167, 139, 250, 0.10); color: #a78bfa; border-color: rgba(167, 139, 250, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-目          {
  background: rgba(96, 165, 250, 0.10); color: #60a5fa; border-color: rgba(96, 165, 250, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-分支計畫    {
  background: rgba(52, 211, 153, 0.10); color: #34d399; border-color: rgba(52, 211, 153, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-用途別大類  {
  background: rgba(244, 114, 182, 0.10); color: #f472b6; border-color: rgba(244, 114, 182, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-用途別細項,
html[data-theme="dark"] .tn-badge.badge-用途別      {
  background: rgba(251, 191, 36, 0.08); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35);
}
html[data-theme="dark"] .tn-badge.badge-細目,
html[data-theme="dark"] .tn-badge.badge-節          {
  background: rgba(94, 234, 212, 0.10); color: #5eead4; border-color: rgba(94, 234, 212, 0.4);
}
html[data-theme="dark"] .tn-badge.badge-fund,
html[data-theme="dark"] .tn-badge.badge-基金,
html[data-theme="dark"] .tn-badge.badge-分基金 {
  background: rgba(251, 191, 36, 0.18); color: #fcd34d;
  border-color: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.2);
}
html[data-theme="dark"] .tn-badge.badge-行政法人 {
  background: rgba(244, 114, 182, 0.18); color: #f9a8d4;
  border-color: #f472b6;
}
html[data-theme="dark"] .tn-badge.badge-財團法人 {
  background: rgba(94, 234, 212, 0.18); color: #99f6e4;
  border-color: #5eead4;
}
html[data-theme="dark"] .tn-badge.badge-信託基金 {
  background: rgba(167, 139, 250, 0.18); color: #c4b5fd;
  border-color: #a78bfa;
}

/* fund row 全列 — 改為深底 + 金色 accent border */
html[data-theme="dark"] .tn.is-fund-row > .tn-row-wrap {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.08) 0%, rgba(251, 191, 36, 0.02) 50%, transparent 100%);
  border-left: 2px solid rgba(251, 191, 36, 0.5);
}
html[data-theme="dark"] .tn.is-fund-top > .tn-row-wrap {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.15) 0%, rgba(251, 191, 36, 0.04) 60%, transparent 100%);
  border-left: 3px solid #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.10);
}
html[data-theme="dark"] .tn.is-fund-top:hover > .tn-row-wrap {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.22) 0%, rgba(251, 191, 36, 0.06) 60%, transparent 100%);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.20);
}
html[data-theme="dark"] .tn.is-fund-reviewed > .tn-row-wrap {
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.12) 0%, rgba(52, 211, 153, 0.03) 50%, transparent 100%);
  border-left: 3px solid #34d399;
}

/* parser-missed row */
html[data-theme="dark"] .tn.is-parser-missed > .tn-row-wrap {
  background: repeating-linear-gradient(
    45deg, #0f1421, #0f1421 6px, #131a28 6px, #131a28 12px
  );
  border-left: 2px dashed #475569 !important;
}
html[data-theme="dark"] .tn.is-parser-missed > .tn-row-wrap .tn-name { color: #475569; }
html[data-theme="dark"] .tn.is-parser-missed > .tn-row-wrap .tn-amt { color: #334155; }

/* projected row */
html[data-theme="dark"] .tn.is-projected-row > .tn-row-wrap {
  border-left-color: #a78bfa !important;
  background: linear-gradient(to right, rgba(167, 139, 250, 0.08) 0%, transparent 35%) !important;
}
html[data-theme="dark"] .tn-basis-pill.basis-projected {
  background: rgba(167, 139, 250, 0.18); color: #c4b5fd;
  border: 1px solid #a78bfa;
}

/* —— review checkbox & status pills (in-tree) —— */
html[data-theme="dark"] .tn-review-box {
  background: rgba(251, 191, 36, 0.10);
  color: #fbbf24; border-color: rgba(251, 191, 36, 0.4);
}
html[data-theme="dark"] .tn-bs-imported {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399; border-color: rgba(52, 211, 153, 0.4);
}
html[data-theme="dark"] .tn-bs-downloaded {
  background: rgba(251, 146, 60, 0.15) !important;
  color: #fdba74 !important;
  border-color: rgba(251, 146, 60, 0.5) !important;
}
html[data-theme="dark"] .tn-bs-missing {
  background: rgba(116, 130, 150, 0.10);
  color: #94a3b8; border-color: rgba(116, 130, 150, 0.3);
}
html[data-theme="dark"] .tn-pdf-btn,
html[data-theme="dark"] .mc-pdf-btn {
  background: rgba(34, 211, 238, 0.12);
  color: #22d3ee; border-color: rgba(34, 211, 238, 0.4);
}
html[data-theme="dark"] .tn-pdf-btn:hover,
html[data-theme="dark"] .mc-pdf-btn:hover {
  background: rgba(34, 211, 238, 0.22);
  border-color: #22d3ee;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
  color: #67e8f9;
}

/* missing-badge (⚠ 缺 N) */
html[data-theme="dark"] .tn-missing-badge {
  background: rgba(251, 113, 133, 0.15);
  color: #fda4af; border: 1px solid #fb7185;
}

/* —— 詳情卡 ed-card —— */
html[data-theme="dark"] .ed-card {
  background: #121826; color: #e2e8f0;
  border: 1px solid #1f2937; box-shadow: 0 0 20px rgba(34, 211, 238, 0.05);
}
html[data-theme="dark"] .ed-head { border-bottom: 1px solid #1f2937; }
html[data-theme="dark"] .ed-name { color: #f1f5f9; }
html[data-theme="dark"] .ed-code { color: #64748b; font-family: monospace; }
html[data-theme="dark"] .ed-amts .ed-amt { background: #0f172a; border: 1px solid #1f2937; }
html[data-theme="dark"] .ed-amts .ed-amt.main {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-color: #22d3ee;
}
html[data-theme="dark"] .ed-amt .lab { color: #94a3b8; }
html[data-theme="dark"] .ed-amt .val { color: #f1f5f9; }
html[data-theme="dark"] .ed-meta dt { color: #94a3b8; }
html[data-theme="dark"] .ed-meta dd { color: #e2e8f0; }
html[data-theme="dark"] .ed-section summary { color: #e2e8f0; }
html[data-theme="dark"] .ed-rich,
html[data-theme="dark"] .ed-rich .ex-p,
html[data-theme="dark"] .ed-rich .ex-li { color: #cbd5e1; }
html[data-theme="dark"] .ed-rich .hl-amt {
  background: rgba(251, 191, 36, 0.18); color: #fcd34d;
  border-radius: 3px; padding: 0 4px;
}
html[data-theme="dark"] .ed-rich .ex-hi-budget {
  background: rgba(34, 211, 238, 0.08);
  border-left: 3px solid #22d3ee;
}
html[data-theme="dark"] .ed-rich .ex-hi-overview {
  background: rgba(167, 139, 250, 0.08);
  border-left: 3px solid #a78bfa;
}

/* fund 4-cards in detail */
html[data-theme="dark"] .fund-amts .ed-amt.main {
  background: linear-gradient(135deg, #0a1f2e 0%, #0c2530 100%);
  border-left: 4px solid #22d3ee;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .fund-amts .ed-amt.main .val { color: #67e8f9; }
html[data-theme="dark"] .fund-amts .fund-amt-income {
  background: rgba(52, 211, 153, 0.08);
  border-left: 3px solid #34d399;
}
html[data-theme="dark"] .fund-amts .fund-amt-income .val { color: #34d399; }
html[data-theme="dark"] .fund-amts .fund-amt-expense {
  background: rgba(251, 113, 133, 0.08);
  border-left: 3px solid #fb7185;
}
html[data-theme="dark"] .fund-amts .fund-amt-expense .val { color: #fb7185; }
html[data-theme="dark"] .fund-amts .fund-amt-surplus {
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid #fbbf24;
}
html[data-theme="dark"] .fund-amts .fund-amt-surplus .val { color: #fcd34d; }
html[data-theme="dark"] .fund-amts .ed-amt .lab { color: #94a3b8; }
html[data-theme="dark"] .fund-amts .val .val-na { color: #475569 !important; }

/* —— 搜尋結果 + tabs —— */
html[data-theme="dark"] .exp-match-list {
  background: #121826;
  border: 1px solid rgba(34, 211, 238, 0.3);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.08);
}
html[data-theme="dark"] .ml-head {
  background: #0d1320; color: #67e8f9;
  border-bottom: 1px solid #1f2937;
}
html[data-theme="dark"] .ml-row {
  background: transparent; border-bottom: 1px solid #1a2333;
  transition: background 0.15s;
}
html[data-theme="dark"] .ml-row:hover { background: rgba(34, 211, 238, 0.06); }
html[data-theme="dark"] .ml-row.ml-row-fund {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.06) 0%, transparent 50%);
}
html[data-theme="dark"] .ml-name { color: #e2e8f0; }
html[data-theme="dark"] .ml-path { color: #64748b; }
html[data-theme="dark"] .ml-amt { color: #cbd5e1; font-variant-numeric: tabular-nums; }
html[data-theme="dark"] .ml-snippet { color: #94a3b8; }
html[data-theme="dark"] .ml-tabs {
  background: #0d1320;
  border-bottom: 1px solid #1f2937;
}
html[data-theme="dark"] .ml-tab {
  background: rgba(34, 211, 238, 0.05);
  border: 1px solid rgba(34, 211, 238, 0.20);
  color: #94a3b8;
}
html[data-theme="dark"] .ml-tab:hover {
  background: rgba(34, 211, 238, 0.12); color: #67e8f9;
  border-color: #22d3ee;
}
html[data-theme="dark"] .ml-tab.is-active {
  background: #22d3ee; color: #0a0e17;
  border-color: #22d3ee;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}
html[data-theme="dark"] .ml-tab-count {
  background: rgba(255,255,255,0.10); color: inherit;
}
html[data-theme="dark"] .ml-tab.is-active .ml-tab-count {
  background: rgba(10, 14, 23, 0.3); color: #0a0e17;
}
html[data-theme="dark"] mark.hl-search {
  background: #fbbf24; color: #0a0e17; border-radius: 2px; padding: 0 2px;
}

/* —— buttons —— */
html[data-theme="dark"] .btn {
  background: rgba(34, 211, 238, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(34, 211, 238, 0.25);
  transition: all 0.15s;
}
html[data-theme="dark"] .btn:hover {
  background: rgba(34, 211, 238, 0.18);
  color: #67e8f9;
  border-color: #22d3ee;
}
html[data-theme="dark"] .btn.primary {
  background: linear-gradient(135deg, #22d3ee 0%, #0891b2 100%);
  color: #0a0e17; font-weight: 700;
  border: 1px solid #22d3ee;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.3);
}
html[data-theme="dark"] .btn.primary:hover {
  background: linear-gradient(135deg, #67e8f9 0%, #22d3ee 100%);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.5);
}
html[data-theme="dark"] .btn.ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid #1f2937;
}
html[data-theme="dark"] .btn.ghost:hover {
  background: rgba(34, 211, 238, 0.08); color: #67e8f9;
  border-color: rgba(34, 211, 238, 0.4);
}

/* —— tables: import-status —— */
html[data-theme="dark"] .tbl-sources,
html[data-theme="dark"] .tbl-books,
html[data-theme="dark"] .tbl-funds,
html[data-theme="dark"] .tbl-ref {
  background: #121826; color: #e2e8f0;
}
html[data-theme="dark"] .tbl-sources thead,
html[data-theme="dark"] .tbl-books thead,
html[data-theme="dark"] .tbl-funds thead,
html[data-theme="dark"] .tbl-ref thead {
  background: #0d1320; color: #67e8f9;
  border-bottom: 1px solid rgba(34, 211, 238, 0.25);
}
html[data-theme="dark"] .tbl-sources td,
html[data-theme="dark"] .tbl-books td,
html[data-theme="dark"] .tbl-funds td,
html[data-theme="dark"] .tbl-ref td {
  border-color: #1f2937;
}
html[data-theme="dark"] .tbl-sources tr:hover td,
html[data-theme="dark"] .tbl-books tr:hover td,
html[data-theme="dark"] .tbl-funds tr:hover td {
  background: rgba(34, 211, 238, 0.04);
}
html[data-theme="dark"] .src-st.imported { color: #34d399; }
html[data-theme="dark"] .src-st.downloaded { color: #fb923c; }
html[data-theme="dark"] .src-st.none { color: #64748b; }

/* funds_status chips (in /import-status) */
html[data-theme="dark"] .ag-chip.imported {
  background: rgba(52, 211, 153, 0.15); color: #34d399; border-color: #34d399;
}
html[data-theme="dark"] .ag-chip.downloaded {
  background: rgba(251, 146, 60, 0.15); color: #fdba74; border-color: #fb923c;
}
html[data-theme="dark"] .ag-chip.missing {
  background: rgba(251, 113, 133, 0.12); color: #fda4af; border-color: #fb7185;
}
html[data-theme="dark"] .ag-chip.deprecated {
  background: rgba(116, 130, 150, 0.12); color: #94a3b8; border-color: #64748b;
}
html[data-theme="dark"] .ag-chip.not-published {
  background: rgba(116, 130, 150, 0.12); color: #94a3b8; border-color: #475569;
}
html[data-theme="dark"] .ag-chip.unknown {
  background: rgba(167, 139, 250, 0.12); color: #c4b5fd; border-color: #a78bfa;
}

/* org tree groups */
html[data-theme="dark"] .org-group {
  background: #121826; border: 1px solid #1f2937;
}
html[data-theme="dark"] .org-head { color: #e2e8f0; }
html[data-theme="dark"] .org-head:hover { background: rgba(34, 211, 238, 0.06); }
html[data-theme="dark"] .org-code { color: #22d3ee; font-weight: 700; }
html[data-theme="dark"] .org-name { color: #f1f5f9; }
html[data-theme="dark"] .ag-row { color: #cbd5e1; border-bottom-color: #1a2333; }
html[data-theme="dark"] .ag-row:hover { background: rgba(34, 211, 238, 0.04); }
html[data-theme="dark"] .ag-name { color: #e2e8f0; }
html[data-theme="dark"] .ag-code { color: #64748b; }
html[data-theme="dark"] .og-bar { background: #1a2333; }
html[data-theme="dark"] .og-bar-fill { background: #22d3ee; }
html[data-theme="dark"] .og-bar-fill.partial { background: linear-gradient(90deg, #22d3ee, #a78bfa); }
html[data-theme="dark"] .og-pct { color: #94a3b8; }

/* KPIs */
html[data-theme="dark"] .kpi {
  background: #121826; border: 1px solid #1f2937; color: #e2e8f0;
}
html[data-theme="dark"] .kpi-value { color: #22d3ee; text-shadow: 0 0 8px rgba(34, 211, 238, 0.25); }
html[data-theme="dark"] .kpi-label { color: #94a3b8; }
html[data-theme="dark"] .kpi-sub { color: #64748b; }
html[data-theme="dark"] .kpi.kpi-good { border-color: rgba(52, 211, 153, 0.4); }
html[data-theme="dark"] .kpi.kpi-good .kpi-value { color: #34d399; text-shadow: 0 0 8px rgba(52, 211, 153, 0.25); }
html[data-theme="dark"] .kpi.kpi-danger { border-color: rgba(251, 113, 133, 0.4); }
html[data-theme="dark"] .kpi.kpi-danger .kpi-value { color: #fb7185; text-shadow: 0 0 8px rgba(251, 113, 133, 0.25); }

/* workspace */
html[data-theme="dark"] .ws-card,
html[data-theme="dark"] .ws-form {
  background: #121826; border: 1px solid #1f2937; color: #e2e8f0;
}

/* fund-type legend cards */
html[data-theme="dark"] .ft-card {
  background: #121826; border: 1px solid #1f2937; color: #e2e8f0;
  transition: all 0.15s;
}
html[data-theme="dark"] .ft-card:hover {
  border-color: #22d3ee; box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .ft-head b { color: #f1f5f9; }
html[data-theme="dark"] .ft-desc { color: #94a3b8; }
html[data-theme="dark"] .ft-points { color: #cbd5e1; }
html[data-theme="dark"] .ft-rule {
  background: rgba(34, 211, 238, 0.06);
  border-left: 3px solid #22d3ee; color: #cbd5e1;
}
html[data-theme="dark"] .exp-fund-type-legend > summary { color: #67e8f9; }

/* —— scrollbar tech style —— */
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0a0e17; border-left: 1px solid #1f2937;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1f2937 0%, #2c3a52 100%);
  border-radius: 5px; border: 1px solid #0a0e17;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #22d3ee 0%, #0891b2 100%);
}

/* code / pre */
html[data-theme="dark"] code,
html[data-theme="dark"] pre {
  background: #0d1320; color: #67e8f9;
  border: 1px solid #1f2937; border-radius: 4px;
}

/* form button mini */
html[data-theme="dark"] .btn-mini { font-size: 11.5px; }

/* selection */
html[data-theme="dark"] ::selection { background: rgba(34, 211, 238, 0.35); color: #f1f5f9; }

/* —— popup —— */
html[data-theme="dark"] .bp-popup,
html[data-theme="dark"] .missing-popover {
  background: #121826; border: 1px solid rgba(34, 211, 238, 0.4);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 12px rgba(34, 211, 238, 0.15);
  color: #e2e8f0;
}
html[data-theme="dark"] .mp-head { background: #0d1320; color: #67e8f9; border-bottom-color: #1f2937; }
html[data-theme="dark"] .mp-group h5 { color: #fbbf24; }
html[data-theme="dark"] .mp-foot { color: #64748b; border-top-color: #1f2937; }

/* focus visible (a11y) */
html[data-theme="dark"] :focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

/* v0.6.9 (2026-05-31): 結構大項組 — 實施平均地權基金 等 fund 用，
   把 manual_added_structural_大項 row 從 fund-top 直接 children 移到此分組
   視覺：紫灰底色 + 虛線左邊框，跟 業務支出 大項區分 */
.exp-tree .tn.kind-結構大項組 > .tn-row-wrap {
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.08), transparent 60%);
  border-left: 3px dashed #a78bfa;
}
.exp-tree .tn-badge.badge-結構大項組 {
  background: #a78bfa;
  color: #fff;
  font-weight: 700;
}
html[data-theme="dark"] .exp-tree .tn-badge.badge-結構大項組 {
  background: #7c3aed;
}

/* =================================================
   v0.7.1 (2026-05-31) /dashboard — 中央政府預算儀表板
   ================================================= */
.dash-page { max-width: 1280px; margin: 0 auto; padding: 0 16px 40px; }

/* Hero with grand total */
.dash-hero {
  position: relative;
  background: linear-gradient(135deg, #1e3a5f 0%, #2a5298 40%, #5b8def 100%);
  color: #fff;
  border-radius: 16px;
  margin: 16px 0 24px;
  padding: 30px 40px 36px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(30, 58, 95, 0.22);
}
.dash-hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(255, 213, 79, 0.10) 0%, transparent 40%);
  pointer-events: none;
}
.dash-hero-inner { position: relative; }
.dash-hero .dh-eyebrow {
  font-size: 14px; letter-spacing: 4px; opacity: 0.75; margin-bottom: 4px;
}
.dash-hero .dh-title {
  font-size: 30px; font-weight: 800; margin: 0 0 18px; letter-spacing: -0.5px;
}
.dash-hero .dh-grand {
  display: flex; align-items: baseline; gap: 14px;
  margin: 10px 0 14px; flex-wrap: wrap;
}
.dash-hero .dh-grand-amt {
  /* 完整一串數字（~17 位）→ 用 clamp 隨寬度縮放，避免 overflow */
  font-size: clamp(30px, 4.2vw, 54px); font-weight: 900;
  letter-spacing: -1px; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: #ffd54f;
  text-shadow: 0 4px 16px rgba(0,0,0,0.20);
  word-break: break-all;
}
.dash-hero .dh-grand-unit {
  font-size: 22px; opacity: 0.85;
}
.dash-hero .dh-stats {
  font-size: 14.5px; opacity: 0.92; letter-spacing: 0.3px;
}
.dash-hero .dh-stats b {
  color: #ffd54f; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* KPI grid */
.dash-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 720px) { .dash-kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
  background: #fff; border: 1px solid var(--c-border);
  border-radius: 10px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.kpi-card .kpi-icon { font-size: 22px; opacity: 0.75; margin-bottom: 2px; }
.kpi-card .kpi-label { font-size: 13px; color: #666; font-weight: 500; }
.kpi-card .kpi-amt {
  font-size: 32px; font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}
.kpi-card .kpi-sub { font-size: 12px; color: #888; }
.kpi-gov  .kpi-amt { color: #5b8def; }
.kpi-fund .kpi-amt { color: #d4a017; }
.kpi-min  .kpi-amt { color: #4a9648; }
.kpi-items .kpi-amt { color: #c0392b; }

/* Sections */
.dash-section {
  background: #fff; border: 1px solid var(--c-border);
  border-radius: 10px; padding: 20px 24px; margin-bottom: 18px;
}
.dash-section .ds-title {
  font-size: 18px; font-weight: 700;
  margin: 0 0 4px; color: var(--c-text);
}
.dash-section .ds-desc { font-size: 12.5px; color: #888; margin: 0 0 14px; }
.dash-row {
  display: grid; grid-template-columns: 1fr 1.3fr; gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 900px) { .dash-row { grid-template-columns: 1fr; } }

/* Bar chart */
.dash-bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bc-row {
  display: grid; grid-template-columns: 160px 1fr;
  gap: 12px; align-items: center; min-height: 26px;
}
@media (max-width: 720px) { .bc-row { grid-template-columns: 110px 1fr; } }
.bc-label {
  font-size: 13.5px; color: #333; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: right;
}
.bc-bar-wrap {
  position: relative; height: 24px;
  background: #f5f5f3; border-radius: 4px; overflow: visible;
}
.bc-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  background: #5b8def;
}
.bc-amt {
  position: absolute; right: -2px; top: 50%;
  transform: translate(100%, -50%);
  padding: 0 8px;
  font-size: 12.5px; font-weight: 600;
  color: #444; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Pie */
.pie-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
@media (max-width: 600px) { .pie-wrap { grid-template-columns: 1fr; } .pie-wrap svg { margin: 0 auto; display: block; } }
.pie-svg { cursor: pointer; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; }
.pl-item {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  gap: 8px; align-items: center;
  font-size: 13px;
}
.pl-dot {
  width: 12px; height: 12px; border-radius: 3px;
  display: inline-block;
}
.pl-lab { color: #333; }
.pl-amt { font-variant-numeric: tabular-nums; font-weight: 600; color: #c0392b; }
.pl-pct { font-size: 11.5px; }

.dash-cta { text-align: center; margin-top: 20px; }

/* v0.7.2 (2026-05-31, 鐵律 9): 預算分類嚴格分開 — UI 警語 + 副指標標記 */
.db4-grand .dg-warn {
  display: inline-block;
  font-size: 11.5px;
  opacity: 0.85;
  background: rgba(255,255,255,0.16);
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.dash-hero .dh-sublabel {
  font-size: 14px;
  opacity: 0.85;
  margin-top: -4px;
  margin-bottom: 8px;
}
/* 我們資料庫 vs 主計庫 對齊率 */
.dash-hero .dh-align {
  font-size: 14px; margin: 2px 0 10px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
}
.dash-hero .dh-align:empty { display: none; }
.dash-hero .dh-align .dh-align-rate {
  font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: #ffd54f; padding: 0 2px;
}
.dash-hero .dh-align.dh-align-ok .dh-align-rate { color: #6ee7b7; }
.dash-hero .dh-align .dh-align-sub { font-size: 12.5px; opacity: 0.8; }
.dash-hero .dh-warning {
  margin-top: 10px;
  padding: 7px 12px;
  background: rgba(255, 213, 79, 0.18);
  border-left: 3px solid #ffd54f;
  border-radius: 4px;
  font-size: 12.5px;
  display: inline-block;
}
.dash-hero .dh-warning b { color: #ffd54f; }
.kpi-card .kpi-tag {
  display: inline-block;
  font-size: 9.5px;
  padding: 1px 5px;
  background: #ffd54f;
  color: #8a6500;
  border-radius: 3px;
  font-weight: 700;
  vertical-align: 2px;
  margin-left: 4px;
}
.min-cell .mc-total-sub .mc-extra-fund {
  color: #8a6500;
  background: #fff7c8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}
.min-cell .mc-total-sub .mc-extra-admin {
  color: #4a3a8a;
  background: #ece5ff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

/* ============ R49-MINISTRY-INTRO (2026-05-31): 機關說明 card ============ */
.exp-min-intro {
  margin: 16px 0 20px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #fefce8 0%, #fef9c3 100%);
  border: 1px solid #fde047;
  border-left: 5px solid #ca8a04;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.75;
  color: #292524;
}
/* R49 v2 (2026-06-01): embedded variant — 嵌在右側 detail panel 內，邊距收緊 */
.exp-min-intro.embedded-min-intro {
  margin: 0 0 12px;
  padding: 10px 14px;
  font-size: 13px;
}
.exp-min-intro.embedded-min-intro .emi-title { font-size: 13.5px; }
.exp-min-intro.embedded-min-intro .emi-body { max-height: 60vh; overflow-y: auto; }
/* R49-RESOLUTIONS (2026-06-03): 立法院決議卡 — 用靛藍區隔 預算總說明(黃) */
.exp-min-intro.embedded-min-reso {
  margin: 0 0 12px; padding: 10px 14px; font-size: 13px;
  background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
  border: 1px solid #c7d2fe; border-left: 5px solid #6366f1; color: #1e1b4b;
}
.exp-min-intro.embedded-min-reso summary { color: #3730a3; }
.exp-min-intro.embedded-min-reso .emi-meta { color: #4f46e5; }
.exp-min-intro.embedded-min-reso .emi-body { max-height: 55vh; overflow-y: auto; }
html[data-theme="dark"] .exp-min-intro.embedded-min-reso {
  background: rgba(99,102,241,0.10); border-color: rgba(129,140,248,0.4);
  border-left-color: #818cf8; color: var(--c-dim);
}
html[data-theme="dark"] .exp-min-intro.embedded-min-reso summary,
html[data-theme="dark"] .exp-min-intro.embedded-min-reso .emi-meta { color: #a5b4fc; }

/* 📌 年度重點計畫卡（2026-07-14 用戶）— 用綠系區隔 機關說明(黃)/決議(靛) */
.exp-agency-plans .eap-plan {
  margin: 0 0 12px; padding: 10px 14px; font-size: 13px;
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac; border-left: 5px solid #16a34a; color: #14532d;
}
.exp-agency-plans .eap-plan summary { color: #166534; }
.exp-agency-plans .eap-plan .emi-meta { color: #16a34a; }
.exp-agency-plans .eap-plan .emi-body { max-height: 60vh; overflow-y: auto; }
.exp-agency-plans .eap-item { margin: 8px 0 12px; }
.exp-agency-plans .eap-item-title {
  font-weight: 700; margin-bottom: 3px; color: #166534;
  border-bottom: 1px dashed #86efac; padding-bottom: 2px;
}
html[data-theme="dark"] .exp-agency-plans .eap-plan {
  background: rgba(34,197,94,0.08); border-color: rgba(74,222,128,0.35);
  border-left-color: #4ade80; color: var(--c-dim);
}
html[data-theme="dark"] .exp-agency-plans .eap-plan summary,
html[data-theme="dark"] .exp-agency-plans .eap-plan .emi-meta,
html[data-theme="dark"] .exp-agency-plans .eap-item-title { color: #86efac; }

/* AI剖析卡（2026-06-04 用戶）— 115 預算 vs 114 法定；青色 AI 調，預設展開置頂 */
.exp-ai-diff {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 8px;
  background: linear-gradient(180deg, #ecfeff 0%, #cffafe 100%);
  border: 1px solid #67e8f9; border-left: 5px solid #0891b2;
  font-size: 13px; line-height: 1.7; color: #0e2a30;
}
.exp-ai-diff summary {
  cursor: pointer; font-weight: 700; color: #0e7490; padding: 4px 0;
  user-select: none; display: flex; align-items: center; gap: 8px; list-style: none;
}
.exp-ai-diff summary::-webkit-details-marker { display: none; }
.exp-ai-diff .aid-icon { font-size: 17px; }
.exp-ai-diff .aid-title { font-size: 13.5px; flex-shrink: 0; }
.exp-ai-diff .aid-delta { margin-left: auto; font-size: 12.5px; font-weight: 700;
  padding: 1px 8px; border-radius: 10px; }
.exp-ai-diff .aid-delta.aid-up { background: #fee2e2; color: #b91c1c; }
.exp-ai-diff .aid-delta.aid-down { background: #dcfce7; color: #15803d; }
.exp-ai-diff .aid-delta.aid-na { background: #e5e7eb; color: #6b7280; font-weight: 600; }
.exp-ai-diff .aid-body { margin-top: 8px; max-height: 60vh; overflow-y: auto;
  white-space: normal; }
/* 🔽 可收合提示（2026-06-23 用戶「AI剖析/監察院/立院質詢都應該可以收合」）：
   區塊本是 <details> 可收，但繼承了 marker:none、看不出能點 → 補旋轉三角＋分隔線，明確可收合。 */
.exp-ai-diff > summary::before,
.exp-ai-diff .aid-pbc > summary::before,
.exp-ai-diff .aid-oversight > summary::before,
.exp-ai-diff .aid-interp > summary::before {
  content: "▸"; display: inline-block; font-size: 11px; line-height: 1;
  transition: transform 0.15s ease; flex-shrink: 0; color: inherit; opacity: 0.8;
}
.exp-ai-diff[open] > summary::before,
.exp-ai-diff .aid-pbc[open] > summary::before,
.exp-ai-diff .aid-oversight[open] > summary::before,
.exp-ai-diff .aid-interp[open] > summary::before { transform: rotate(90deg); }
.exp-ai-diff .aid-pbc > summary,
.exp-ai-diff .aid-oversight > summary,
.exp-ai-diff .aid-interp > summary {
  cursor: pointer; font-weight: 700; font-size: 12.5px; padding: 6px 0; gap: 6px;
  list-style: none; display: flex; align-items: center;
  border-top: 1px solid rgba(8,145,178,0.18); margin-top: 8px;
}
.exp-ai-diff .aid-pbc > summary::-webkit-details-marker,
.exp-ai-diff .aid-oversight > summary::-webkit-details-marker,
.exp-ai-diff .aid-interp > summary::-webkit-details-marker { display: none; }
.exp-ai-diff .aid-up { color: #b91c1c; font-weight: 700; }
.exp-ai-diff .aid-down { color: #15803d; font-weight: 700; }
.exp-ai-diff .aid-new { color: #0891b2; font-weight: 700; }
.exp-ai-diff .aid-warn { color: #b45309; font-weight: 700; }
/* 逐項可點跳轉（2026-06-05 用戶：每項分析後加連結跳到該筆預算）*/
.exp-ai-diff .aid-summary-line { font-size: 12.5px; line-height: 1.6; margin-bottom: 8px; }
.exp-ai-diff .aid-sec { margin-top: 10px; }
.exp-ai-diff .aid-sec-h { font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.exp-ai-diff .aid-item-list { margin: 0; padding: 0; list-style: none; }
.exp-ai-diff .aid-item { display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0; border-bottom: 1px dotted rgba(100,116,139,0.22); font-size: 12.5px; line-height: 1.5; }
.exp-ai-diff .aid-item-text { flex: 1 1 auto; min-width: 0; }
.exp-ai-diff .aid-item-label { color: #334155; }
.exp-ai-diff .aid-goto { flex: 0 0 auto; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  color: #0891b2; text-decoration: none; padding: 1px 8px; border-radius: 999px;
  background: rgba(8,145,178,0.10); border: 1px solid rgba(8,145,178,0.30); cursor: pointer; }
.exp-ai-diff .aid-goto:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
.exp-ai-diff .aid-goto-miss { color: #b45309 !important; background: rgba(180,83,9,0.12) !important;
  border-color: rgba(180,83,9,0.40) !important; }
.exp-ai-diff .aid-missing { margin-top: 10px; font-size: 12px; line-height: 1.55; color: #b45309; }
.exp-ai-diff .aid-note { margin-top: 10px; font-size: 11.5px; color: #64748b; font-style: italic; line-height: 1.5; }
html[data-theme="dark"] .exp-ai-diff .aid-item { border-bottom-color: rgba(148,163,184,0.20); }
html[data-theme="dark"] .exp-ai-diff .aid-item-label { color: var(--c-dim); }
html[data-theme="dark"] .exp-ai-diff .aid-goto { color: #67e8f9;
  background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.38); }
html[data-theme="dark"] .exp-ai-diff .aid-goto:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }
html[data-theme="dark"] .exp-ai-diff .aid-goto-miss { color: #fbbf24 !important;
  background: rgba(251,191,36,0.14) !important; border-color: rgba(251,191,36,0.40) !important; }
html[data-theme="dark"] .exp-ai-diff .aid-missing { color: #fbbf24; }
html[data-theme="dark"] .exp-ai-diff .aid-note { color: #94a3b8; }
html[data-theme="dark"] .exp-ai-diff {
  background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.40);
  border-left-color: #22d3ee; color: var(--c-dim);
}
html[data-theme="dark"] .exp-ai-diff summary,
html[data-theme="dark"] .exp-ai-diff .aid-title { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-diff .aid-delta.aid-up { background: rgba(248,113,113,0.18); color: #fca5a5; }
html[data-theme="dark"] .exp-ai-diff .aid-delta.aid-down { background: rgba(74,222,128,0.18); color: #86efac; }
html[data-theme="dark"] .exp-ai-diff .aid-delta.aid-na { background: rgba(148,163,184,0.18); color: #94a3b8; }
html[data-theme="dark"] .exp-ai-diff .aid-up { color: #fca5a5; }
html[data-theme="dark"] .exp-ai-diff .aid-down { color: #86efac; }
html[data-theme="dark"] .exp-ai-diff .aid-new { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-diff .aid-warn { color: #fbbf24; }
/* 相關立委質詢 sub-section */
.exp-ai-diff .aid-interp { margin-top: 10px; border-top: 1px dashed #67e8f9; padding-top: 8px; }
.exp-ai-diff .aid-interp > summary { cursor: pointer; font-weight: 700; color: #0e7490;
  font-size: 12.5px; list-style: none; }
.exp-ai-diff .aid-interp > summary::-webkit-details-marker { display: none; }
.exp-ai-diff .aid-q-list { margin: 8px 0 0; padding: 0; list-style: none; max-height: 46vh; overflow-y: auto; }
.exp-ai-diff .aid-q { padding: 5px 0; border-bottom: 1px dotted rgba(8,145,178,0.25); font-size: 12.5px; line-height: 1.55; }
.exp-ai-diff .aid-q-date { color: #0891b2; font-weight: 600; margin-right: 6px; }
.exp-ai-diff .aid-q-who { color: #b45309; font-weight: 700; margin-right: 6px; }
.exp-ai-diff .aid-q-why { color: #334155; }
/* 問題重點（2026-06-22 用戶「事由只有第一句、那不是重點」）：條列委員實際問的重點 */
.exp-ai-diff .aid-q-pts { margin: 3px 0 0; padding-left: 18px; list-style: disc; color: #1e293b; }
.exp-ai-diff .aid-q-pts li { margin: 1px 0; }
.aid-q-aitag, .exp-diff-modal .aid-q-aitag { display: inline-block; font-size: 10px; font-weight: 700;
  color: #0e7490; background: rgba(8,145,178,0.12); border: 1px solid rgba(8,145,178,0.3);
  border-radius: 4px; padding: 0 4px; margin-right: 6px; vertical-align: 1px; }
.exp-diff-modal .edm-pts { margin: 3px 0 0; padding-left: 18px; list-style: disc; color: #1e293b; }
.exp-diff-modal .edm-pts li { margin: 1px 0; }
.exp-ai-diff .aid-q-more { margin-top: 6px; font-size: 11.5px; color: #64748b; font-style: italic; }
/* 質詢「前後文」展開（2026-06-23 用戶「只有一小段、要能點開看前後200字看懂在質詢什麼」）*/
.aid-q-ctx { margin: 4px 0 2px; }
.aid-q-ctx > summary { cursor: pointer; color: #0891b2; font-size: 11.5px; font-weight: 600;
  list-style: none; display: inline-block; user-select: none; }
.aid-q-ctx > summary::-webkit-details-marker { display: none; }
.aid-q-ctx > summary:hover { text-decoration: underline; }
.aid-q-ctx[open] > summary { margin-bottom: 4px; }
.aid-q-fulltext { font-size: 12px; line-height: 1.75; color: #334155;
  background: rgba(8,145,178,0.06); border-left: 3px solid rgba(8,145,178,0.4);
  border-radius: 0 4px 4px 0; padding: 7px 10px; margin: 2px 0 4px;
  white-space: pre-wrap; word-break: break-word; max-height: 40vh; overflow-y: auto; }
html[data-theme="dark"] .exp-ai-diff .aid-q-pts,
html[data-theme="dark"] .exp-diff-modal .edm-pts { color: #cbd5e1; }
html[data-theme="dark"] .aid-q-aitag { color: #67e8f9; background: rgba(34,211,238,0.14); border-color: rgba(34,211,238,0.4); }
html[data-theme="dark"] .exp-ai-diff .aid-interp { border-top-color: rgba(34,211,238,0.35); }
html[data-theme="dark"] .exp-ai-diff .aid-interp > summary { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-diff .aid-q-date { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-diff .aid-q-who { color: #fbbf24; }
html[data-theme="dark"] .exp-ai-diff .aid-q-why { color: var(--c-dim); }
html[data-theme="dark"] .exp-ai-diff .aid-q-more { color: #94a3b8; }
html[data-theme="dark"] .aid-q-ctx > summary { color: #67e8f9; }
html[data-theme="dark"] .aid-q-fulltext { color: #cbd5e1;
  background: rgba(34,211,238,0.08); border-left-color: rgba(34,211,238,0.45); }

/* B1 質詢結構化缺失卡（2026-07-04 用戶「看不出委員該場質詢點出什麼缺失」）— 一眼可讀的 缺失/訴求/承諾/閃躲 */
.aid-def-card { margin: 4px 0 2px; padding: 7px 10px; border-left: 3px solid #ef4444;
  background: rgba(239,68,68,0.05); border-radius: 0 5px 5px 0; }
.aid-def-row { display: flex; gap: 6px; font-size: 12px; line-height: 1.6; margin: 1px 0; }
.aid-def-k { flex: 0 0 auto; min-width: 4.5em; font-weight: 700; color: #64748b; }
.aid-def-v { flex: 1 1 auto; color: #1e293b; word-break: break-word; }
.aid-def-row.is-issue .aid-def-v { font-weight: 600; color: #b91c1c; }
.aid-def-row.is-money .aid-def-v { color: #a16207; }
.aid-def-tags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.aid-def-tag { display: inline-block; font-size: 10.5px; font-weight: 700; border-radius: 4px;
  padding: 1px 6px; border: 1px solid transparent; }
.aid-def-tag.is-dodge { color: #92400e; background: rgba(245,158,11,0.14); border-color: rgba(245,158,11,0.4); }
.aid-def-tag.is-cut { color: #b91c1c; background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); }
html[data-theme="dark"] .aid-def-card { background: rgba(248,113,113,0.08); border-left-color: #f87171; }
html[data-theme="dark"] .aid-def-k { color: #94a3b8; }
html[data-theme="dark"] .aid-def-v { color: #e2e8f0; }
html[data-theme="dark"] .aid-def-row.is-issue .aid-def-v { color: #fca5a5; }
html[data-theme="dark"] .aid-def-row.is-money .aid-def-v { color: #fcd34d; }
html[data-theme="dark"] .aid-def-tag.is-dodge { color: #fcd34d; background: rgba(245,158,11,0.16); }
html[data-theme="dark"] .aid-def-tag.is-cut { color: #fca5a5; background: rgba(248,113,113,0.14); }

/* 🔍 監察院糾正 / 審計部決算審核（權威缺失；2026-06-05 用戶）— 暖橘調，與青色質詢區隔 */
.exp-ai-diff .aid-oversight { margin-top: 10px; border-top: 1px dashed #fb923c; padding-top: 8px; }
.exp-ai-diff .aid-oversight > summary { cursor: pointer; font-weight: 700; color: #c2410c;
  font-size: 12.5px; list-style: none; }
.exp-ai-diff .aid-oversight > summary::-webkit-details-marker { display: none; }
.exp-ai-diff .aid-o-list { margin: 8px 0 0; padding: 0; list-style: none; max-height: 46vh; overflow-y: auto; }
.exp-ai-diff .aid-o { padding: 7px 0; border-bottom: 1px dotted rgba(194,65,12,0.25); font-size: 12.5px; line-height: 1.55; }
.exp-ai-diff .aid-o-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.exp-ai-diff .aid-o-src-tag { color: #c2410c; font-weight: 700; }
.exp-ai-diff .aid-o-org { color: #9a3412; font-weight: 700; background: #ffedd5; padding: 0 6px; border-radius: 8px; }
.exp-ai-diff .aid-o-meta { color: #92400e; font-size: 11.5px; }
.exp-ai-diff .aid-o-src { color: #0891b2; font-size: 11.5px; text-decoration: underline; margin-left: auto; }
.exp-ai-diff .aid-o-why { color: #334155; }
html[data-theme="dark"] .exp-ai-diff .aid-oversight { border-top-color: rgba(251,146,60,0.4); }
html[data-theme="dark"] .exp-ai-diff .aid-oversight > summary { color: #fdba74; }
html[data-theme="dark"] .exp-ai-diff .aid-o-src-tag { color: #fdba74; }
html[data-theme="dark"] .exp-ai-diff .aid-o-org { color: #fed7aa; background: rgba(251,146,60,0.18); }
html[data-theme="dark"] .exp-ai-diff .aid-o-meta { color: #fbbf24; }
html[data-theme="dark"] .exp-ai-diff .aid-o-src { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-diff .aid-o-why { color: var(--c-dim); }

/* 📋 立法院預算中心評估報告（逐計畫專業評估；2026-06-22 用戶）— 紫調，與青色質詢/橘色監察區隔 */
.exp-ai-diff .aid-pbc { margin-top: 10px; border-top: 1px dashed #a78bfa; padding-top: 8px; }
.exp-ai-diff .aid-pbc > summary { cursor: pointer; font-weight: 700; color: #6d28d9;
  font-size: 12.5px; list-style: none; }
.exp-ai-diff .aid-pbc > summary::-webkit-details-marker { display: none; }
.exp-ai-diff .aid-p-list { margin: 8px 0 0; padding: 0; list-style: none; max-height: 46vh; overflow-y: auto; }
.exp-ai-diff .aid-p { padding: 7px 0; border-bottom: 1px dotted rgba(109,40,217,0.22); font-size: 12.5px; line-height: 1.55; }
.exp-ai-diff .aid-p-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.exp-ai-diff .aid-p-kind { color: #7c3aed; font-weight: 700; background: #ede9fe; padding: 0 6px; border-radius: 8px; font-size: 11px; }
.exp-ai-diff .aid-p-plan { color: #5b21b6; font-weight: 700; }
.exp-ai-diff .aid-p-why { color: #334155; }
/* 每則出處列（2026-07-12 用戶：報告標題＋發布日期＋原文連結）*/
.exp-ai-diff .aid-p-src { margin-top: 2px; font-size: 11px; color: #64748b; }
.exp-ai-diff .aid-p-src a { color: #7c3aed; text-decoration: underline; }
html[data-theme="dark"] .exp-ai-diff .aid-p-src { color: var(--c-muted); }
html[data-theme="dark"] .exp-ai-diff .aid-p-src a { color: #c4b5fd; }
html[data-theme="dark"] .exp-ai-diff .aid-pbc { border-top-color: rgba(167,139,250,0.4); }
html[data-theme="dark"] .exp-ai-diff .aid-pbc > summary { color: #c4b5fd; }
html[data-theme="dark"] .exp-ai-diff .aid-p-kind { color: #ddd6fe; background: rgba(167,139,250,0.18); }
html[data-theme="dark"] .exp-ai-diff .aid-p-plan { color: #c4b5fd; }
html[data-theme="dark"] .exp-ai-diff .aid-p-why { color: var(--c-dim); }
/* 彈窗內 PBC 列：類別 badge 用紫（複用 .edm-src 位置但 pbc 專屬色） */
.exp-diff-modal .edm-row .edm-src.is-pbc { color: #7c3aed; }

/* ⊕ 彈出比對 按鈕（2026-06-05 用戶：AI剖析上面加跳出小框功能）*/
.exp-ai-diff .aid-popout {
  margin-left: 10px; flex: 0 0 auto; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: #0e7490; background: rgba(8,145,178,0.10); border: 1px solid rgba(8,145,178,0.35);
  border-radius: 999px; padding: 2px 10px; cursor: pointer; line-height: 1.4;
}
.exp-ai-diff .aid-popout:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
html[data-theme="dark"] .exp-ai-diff .aid-popout {
  color: #67e8f9; background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.38);
}
html[data-theme="dark"] .exp-ai-diff .aid-popout:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }

/* 🤖 AI剖析 浮動比對小視窗（2026-06-05 用戶：跳到此筆後固定旁邊方便對照）*/
.exp-ai-float {
  position: fixed; top: 84px; right: 24px; width: 372px; max-width: calc(100vw - 40px);
  max-height: 76vh; z-index: 3000; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #ecfeff 0%, #e0fbff 100%);
  border: 1px solid #67e8f9; border-radius: 12px;
  box-shadow: 0 14px 44px rgba(8,52,68,0.28); overflow: hidden; resize: both;
}
.exp-ai-float .aif-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: grab;
  background: linear-gradient(180deg, #cffafe 0%, #a5f3fc 100%);
  border-bottom: 1px solid #67e8f9; user-select: none;
}
.exp-ai-float .aif-head:active { cursor: grabbing; }
.exp-ai-float .aif-head .aid-icon { font-size: 17px; }
.exp-ai-float .aif-title { font-size: 13px; font-weight: 800; color: #0e7490; flex: 1 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-ai-float .aid-delta { flex: 0 0 auto; font-size: 12px; font-weight: 700;
  padding: 1px 8px; border-radius: 10px; }
.exp-ai-float .aid-delta.aid-up { background: #fee2e2; color: #b91c1c; }
.exp-ai-float .aid-delta.aid-down { background: #dcfce7; color: #15803d; }
.exp-ai-float .aid-delta.aid-na { background: #e5e7eb; color: #6b7280; font-weight: 600; }
.exp-ai-float .aif-close {
  flex: 0 0 auto; border: none; background: rgba(8,145,178,0.14); color: #0e7490;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer; font-size: 14px;
  font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.exp-ai-float .aif-close:hover { background: #0891b2; color: #fff; }
.exp-ai-float .aif-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 14px 12px; }
/* 浮窗內重用 .exp-ai-diff 的 .aid-* 子樣式，但去掉它自身的卡片外框/底色 */
.exp-ai-float .aif-content {
  margin: 0; padding: 0; border: none; background: transparent; box-shadow: none;
  font-size: 13px; line-height: 1.7; color: #0e2a30;
}
.exp-ai-float .aif-content .aid-body { max-height: none; margin-top: 4px; }
.exp-ai-float .aif-content .aid-q-list { max-height: none; }
html[data-theme="dark"] .exp-ai-float {
  background: linear-gradient(180deg, #0d1b2a 0%, #0b1622 100%);
  border-color: rgba(34,211,238,0.42); box-shadow: 0 14px 44px rgba(0,0,0,0.55);
}
html[data-theme="dark"] .exp-ai-float .aif-head {
  background: rgba(34,211,238,0.12); border-bottom-color: rgba(34,211,238,0.40);
}
html[data-theme="dark"] .exp-ai-float .aif-title { color: #67e8f9; }
html[data-theme="dark"] .exp-ai-float .aif-content { color: var(--c-dim); }
html[data-theme="dark"] .exp-ai-float .aif-close { background: rgba(34,211,238,0.16); color: #67e8f9; }
html[data-theme="dark"] .exp-ai-float .aif-close:hover { background: #22d3ee; color: #0b1220; }
html[data-theme="dark"] .exp-ai-float .aid-delta.aid-up { background: rgba(248,113,113,0.18); color: #fca5a5; }
html[data-theme="dark"] .exp-ai-float .aid-delta.aid-down { background: rgba(74,222,128,0.18); color: #86efac; }
html[data-theme="dark"] .exp-ai-float .aid-delta.aid-na { background: rgba(148,163,184,0.18); color: #94a3b8; }
/* 列印時隱藏浮窗（只印提案單）*/
@media print { .exp-ai-float { display: none !important; } }

/* 🔎 「看全部 N 筆・檢索」按鈕（質詢/監察 summary 內，2026-06-21 用戶）*/
.exp-ai-diff .aid-seeall {
  margin-left: 10px; flex: 0 0 auto; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: #0e7490; background: rgba(8,145,178,0.10); border: 1px solid rgba(8,145,178,0.35);
  border-radius: 999px; padding: 2px 10px; cursor: pointer; line-height: 1.4;
}
.exp-ai-diff .aid-seeall:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
html[data-theme="dark"] .exp-ai-diff .aid-seeall {
  color: #67e8f9; background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.38);
}
html[data-theme="dark"] .exp-ai-diff .aid-seeall:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }

/* 🔎 質詢/監察「看全部 + 檢索 + 連到相關預算」小窗（2026-06-21 用戶）*/
.exp-diff-modal {
  position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center;
  background: rgba(8,30,40,0.42); padding: 24px;
}
.exp-diff-modal .edm-panel {
  display: flex; flex-direction: column; width: 760px; max-width: 100%; max-height: 86vh;
  background: linear-gradient(180deg, #ecfeff 0%, #f5feff 100%);
  border: 1px solid #67e8f9; border-radius: 14px; box-shadow: 0 18px 56px rgba(8,52,68,0.34); overflow: hidden;
}
.exp-diff-modal .edm-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  background: linear-gradient(180deg, #cffafe 0%, #a5f3fc 100%); border-bottom: 1px solid #67e8f9;
}
.exp-diff-modal .edm-title { font-size: 14px; font-weight: 800; color: #0e7490; flex: 1 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-diff-modal .edm-close {
  flex: 0 0 auto; border: none; background: rgba(8,145,178,0.14); color: #0e7490;
  width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 15px; font-weight: 700; line-height: 1;
}
.exp-diff-modal .edm-close:hover { background: #0891b2; color: #fff; }
.exp-diff-modal .edm-search { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; }
.exp-diff-modal .edm-q {
  flex: 1 1 auto; font-size: 13px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid #7dd3e8; background: #fff; color: #0e2a30; outline: none;
}
.exp-diff-modal .edm-q:focus { border-color: #0891b2; box-shadow: 0 0 0 3px rgba(8,145,178,0.16); }
.exp-diff-modal .edm-count { flex: 0 0 auto; font-size: 12px; }
.exp-diff-modal .edm-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 10px 8px; }
.exp-diff-modal .edm-loading, .exp-diff-modal .edm-empty { padding: 28px 12px; text-align: center; font-size: 13px; }
.exp-diff-modal .edm-failbar {
  margin: 4px 0 8px; padding: 8px 10px; border-radius: 7px; font-size: 12.5px;
  background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.4); color: #92400e;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.exp-diff-modal .edm-retry {
  cursor: pointer; border: 1px solid rgba(245,158,11,0.6); background: rgba(245,158,11,0.18);
  color: inherit; border-radius: 6px; padding: 3px 10px; font-size: 12px;
}
html[data-theme="dark"] .exp-diff-modal .edm-failbar { background: rgba(245,158,11,0.14); color: #fcd34d; }
.exp-diff-modal .edm-row {
  padding: 7px 8px; border-bottom: 1px dotted rgba(8,145,178,0.22);
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: start;
}
.exp-diff-modal .edm-main { font-size: 12.5px; line-height: 1.55; }
.exp-diff-modal .edm-date { color: #0891b2; font-weight: 600; margin-right: 6px; }
.exp-diff-modal .edm-who { color: #b45309; font-weight: 700; margin-right: 6px; }
.exp-diff-modal .edm-src { color: #c2410c; font-weight: 700; margin-right: 6px; }
.exp-diff-modal .edm-meta { color: #92400e; font-size: 11.5px; margin-right: 6px; }
.exp-diff-modal .edm-meta a { color: #0891b2; }
.exp-diff-modal .edm-why { color: #334155; }
.exp-diff-modal .edm-rel {
  grid-column: 2; align-self: center; flex: 0 0 auto; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: #0e7490; background: rgba(8,145,178,0.10); border: 1px solid rgba(8,145,178,0.32);
  border-radius: 999px; padding: 3px 10px; cursor: pointer; line-height: 1.3;
}
.exp-diff-modal .edm-rel:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
.exp-diff-modal .edm-rel-box { grid-column: 1 / -1; margin: 6px 0 2px; padding: 7px 10px;
  background: rgba(8,145,178,0.06); border: 1px solid rgba(8,145,178,0.2); border-radius: 9px; }
.exp-diff-modal .edm-rel-h, .exp-diff-modal .edm-rel-empty { font-size: 11.5px; margin-bottom: 4px; }
.exp-diff-modal .edm-rel-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
}
.exp-diff-modal .edm-rel-item:hover { background: rgba(8,145,178,0.12); }
.exp-diff-modal .edm-rel-name { font-weight: 600; color: #0e2a30; }
.exp-diff-modal .edm-rel-path { font-size: 11px; }
.exp-diff-modal .edm-rel-amt { margin-left: auto; color: #0891b2; font-weight: 600; white-space: nowrap; }
.exp-diff-modal .edm-foot { padding: 7px 16px 11px; font-size: 11px; border-top: 1px solid rgba(8,145,178,0.18); }
.exp-diff-modal .muted { color: #64748b; }
/* 夜色（守 dark-theme-rules：slate+cyan、禁 cyan 底白字）*/
html[data-theme="dark"] .exp-diff-modal { background: rgba(0,0,0,0.6); }
html[data-theme="dark"] .exp-diff-modal .edm-panel {
  background: linear-gradient(180deg, #0d1b2a 0%, #0b1622 100%);
  border-color: rgba(34,211,238,0.42); box-shadow: 0 18px 56px rgba(0,0,0,0.6);
}
html[data-theme="dark"] .exp-diff-modal .edm-head {
  background: rgba(34,211,238,0.12); border-bottom-color: rgba(34,211,238,0.40);
}
html[data-theme="dark"] .exp-diff-modal .edm-title { color: #67e8f9; }
html[data-theme="dark"] .exp-diff-modal .edm-close { background: rgba(34,211,238,0.16); color: #67e8f9; }
html[data-theme="dark"] .exp-diff-modal .edm-close:hover { background: #22d3ee; color: #0b1220; }
html[data-theme="dark"] .exp-diff-modal .edm-q { background: #0b1622; border-color: rgba(34,211,238,0.4); color: #cbd5e1; }
html[data-theme="dark"] .exp-diff-modal .edm-row { border-bottom-color: rgba(34,211,238,0.16); }
html[data-theme="dark"] .exp-diff-modal .edm-date { color: #67e8f9; }
html[data-theme="dark"] .exp-diff-modal .edm-who { color: #fbbf24; }
html[data-theme="dark"] .exp-diff-modal .edm-src { color: #fdba74; }
html[data-theme="dark"] .exp-diff-modal .edm-meta { color: #fbbf24; }
html[data-theme="dark"] .exp-diff-modal .edm-meta a { color: #67e8f9; }
html[data-theme="dark"] .exp-diff-modal .edm-why { color: var(--c-dim); }
html[data-theme="dark"] .exp-diff-modal .edm-rel {
  color: #67e8f9; background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.36);
}
html[data-theme="dark"] .exp-diff-modal .edm-rel:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }
html[data-theme="dark"] .exp-diff-modal .edm-rel-box { background: rgba(34,211,238,0.07); border-color: rgba(34,211,238,0.22); }
html[data-theme="dark"] .exp-diff-modal .edm-rel-item:hover { background: rgba(34,211,238,0.16); }
html[data-theme="dark"] .exp-diff-modal .edm-rel-name { color: #e2e8f0; }
html[data-theme="dark"] .exp-diff-modal .edm-rel-amt { color: #67e8f9; }
html[data-theme="dark"] .exp-diff-modal .muted { color: #94a3b8; }
@media print { .exp-diff-modal { display: none !important; } }

/* 🎙️ 官員承諾兌現追蹤卡（2026-06-05 用戶：AI 分析列官員近一年承諾 + 核實）*/
.exp-spin-card {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 8px;
  background: linear-gradient(180deg, #fef6ee 0%, #fde9d6 100%);
  border: 1px solid #f6c896; border-left: 5px solid #ea8a3c;
  font-size: 13px; line-height: 1.6; color: #3a2a18;
}
.exp-spin-card summary {
  cursor: pointer; font-weight: 700; color: #b4540e; padding: 4px 0;
  user-select: none; display: flex; align-items: center; gap: 8px; list-style: none;
}
.exp-spin-card summary::-webkit-details-marker { display: none; }
.exp-spin-card .spin-icon { font-size: 16px; }
.exp-spin-card .spin-title { font-size: 13.5px; }
.exp-spin-card .spin-count { margin-left: auto; font-size: 12px; font-weight: 700;
  background: #f3d2ad; color: #8a4513; padding: 1px 9px; border-radius: 10px; }
.exp-spin-card .spin-body { margin-top: 8px; max-height: 64vh; overflow-y: auto; }
.exp-spin-card .spin-disclaimer { font-size: 11px; color: #9a6b3c; line-height: 1.5;
  margin-bottom: 8px; font-style: italic; }
.exp-spin-card .spin-list { margin: 0; padding: 0; list-style: none; }
.exp-spin-card .spin-item { padding: 8px 0; border-bottom: 1px dotted rgba(180,84,14,0.25); }
.exp-spin-card .spin-item:last-child { border-bottom: none; }
.exp-spin-card .spin-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exp-spin-card .spin-stat { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.exp-spin-card .spin-stat.sp-hard { background: #7f1d1d; color: #fff5f5; }
.exp-spin-card .spin-stat.sp-warn { background: #fee2e2; color: #b91c1c; }
.exp-spin-card .spin-stat.sp-q    { background: #ffedd5; color: #c2410c; }
.exp-spin-card .spin-stat.sp-na   { background: #e5e7eb; color: #6b7280; }
.exp-spin-card .spin-stat.sp-ok   { background: #dcfce7; color: #15803d; }
.exp-spin-card .spin-cite { margin: 4px 0 1px; padding: 5px 8px; font-size: 11.5px; line-height: 1.5;
  background: rgba(127,29,29,0.07); border-left: 3px solid #b91c1c; border-radius: 4px; color: #7f1d1d; }
.exp-spin-card .spin-cite a { color: #b91c1c; font-weight: 700; }
.exp-spin-card .spin-cite-subj { margin-top: 2px; color: #6b2222; }
.exp-spin-card .spin-who { font-size: 12.5px; color: #5a3a1a; }
.exp-spin-card .spin-date { font-size: 11.5px; color: #9a6b3c; font-variant-numeric: tabular-nums; }
.exp-spin-card .spin-claim { margin: 4px 0 3px; font-size: 12.5px; line-height: 1.65; color: #2a1d10; }
.exp-spin-card .spin-basis { font-size: 11.5px; color: #8a5a2a; line-height: 1.5; }
.exp-spin-card .spin-kw { margin-top: 2px; font-size: 11px; color: #a07a4c; }
html[data-theme="dark"] .exp-spin-card {
  background: rgba(234,138,60,0.10); border-color: rgba(234,138,60,0.40);
  border-left-color: #ea8a3c; color: var(--c-dim);
}
html[data-theme="dark"] .exp-spin-card summary,
html[data-theme="dark"] .exp-spin-card .spin-title { color: #f3b87a; }
html[data-theme="dark"] .exp-spin-card .spin-count { background: rgba(234,138,60,0.22); color: #f3b87a; }
html[data-theme="dark"] .exp-spin-card .spin-disclaimer,
html[data-theme="dark"] .exp-spin-card .spin-kw { color: #c79a6a; }
html[data-theme="dark"] .exp-spin-card .spin-claim { color: var(--c-text); }
html[data-theme="dark"] .exp-spin-card .spin-basis { color: #d6a878; }
html[data-theme="dark"] .exp-spin-card .spin-who { color: #e8c49c; }
html[data-theme="dark"] .exp-spin-card .spin-item { border-bottom-color: rgba(234,138,60,0.22); }
html[data-theme="dark"] .exp-spin-card .spin-stat.sp-hard { background: #b91c1c; color: #fff5f5; }
html[data-theme="dark"] .exp-spin-card .spin-cite { background: rgba(248,113,113,0.12); border-left-color: #f87171; color: #fca5a5; }
html[data-theme="dark"] .exp-spin-card .spin-cite a { color: #fca5a5; }
html[data-theme="dark"] .exp-spin-card .spin-cite-subj { color: #e8a0a0; }
html[data-theme="dark"] .exp-spin-card .spin-stat.sp-warn { background: rgba(248,113,113,0.18); color: #fca5a5; }
html[data-theme="dark"] .exp-spin-card .spin-stat.sp-q { background: rgba(251,146,60,0.18); color: #fdba74; }
html[data-theme="dark"] .exp-spin-card .spin-stat.sp-na { background: rgba(148,163,184,0.18); color: #94a3b8; }
html[data-theme="dark"] .exp-spin-card .spin-stat.sp-ok { background: rgba(74,222,128,0.18); color: #86efac; }
@media print { .exp-spin-card { display: none !important; } }

.exp-min-intro summary {
  cursor: pointer;
  font-weight: 600;
  color: #713f12;
  padding: 4px 0;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.exp-min-intro summary:hover { color: #422006; }
.exp-min-intro .emi-icon { font-size: 18px; }
.exp-min-intro .emi-title { font-size: 14px; flex-shrink: 0; }
.exp-min-intro .emi-meta {
  font-weight: 400;
  font-size: 12px;
  color: #92400e;
  margin-left: auto;
}
.exp-min-intro[open] .emi-meta { color: #78350f; }
.emi-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #fde68a;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 8px;
}
.emi-h-chap {
  font-size: 16px;
  color: #7c2d12;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #d97706;
  font-weight: 700;
}
.emi-h-sec {
  font-size: 14.5px;
  color: #92400e;
  margin: 12px 0 6px;
  font-weight: 600;
}
.emi-li-cn {
  margin: 4px 0 4px 12px;
  color: #44403c;
}
.emi-li-num, .emi-li-dot {
  margin: 3px 0 3px 24px;
  color: #57534e;
  font-size: 13px;
}
.emi-p {
  margin: 6px 0;
  color: #292524;
}
/* dark mode */
html[data-theme="dark"] .exp-min-intro {
  background: linear-gradient(180deg, #1e1b2e 0%, #2a1f3d 100%);
  border-color: #a78bfa;
  border-left-color: #fbbf24;
  color: #e5e7eb;
}
html[data-theme="dark"] .exp-min-intro summary { color: #fde68a; }
html[data-theme="dark"] .exp-min-intro summary:hover { color: #fef3c7; }
html[data-theme="dark"] .emi-meta { color: #fcd34d; }
html[data-theme="dark"] .emi-body { border-top-color: #5b21b6; }
html[data-theme="dark"] .emi-h-chap { color: #fbbf24; border-bottom-color: #d97706; }
html[data-theme="dark"] .emi-h-sec { color: #fde68a; }
html[data-theme="dark"] .emi-li-cn { color: #d1d5db; }
html[data-theme="dark"] .emi-li-num, html[data-theme="dark"] .emi-li-dot { color: #9ca3af; }
html[data-theme="dark"] .emi-p { color: #e5e7eb; }
/* 隱藏 status-clean 模式時的 meta（與其他 status badge 一致） */
html.status-clean .exp-min-intro .emi-meta { display: none; }

/* v0.7.4 (2026-05-31) Dashboard reconcile section — 對齊主計總處 */
.dash-reconcile {
  background: linear-gradient(135deg, #fff8f0 0%, #fff3e0 100%);
  border: 1px solid #f5c97d;
}
.reconcile-grand {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px;
  margin: 14px 0 20px;
}
.rc-cell {
  background: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #f0d2a0;
}
.rc-lab { font-size: 12px; color: #888; margin-bottom: 4px; }
.rc-val { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.rc-val.rc-off { color: #4a4a4a; }
.rc-val.rc-our { color: #5b8def; }
.rc-val.rc-under { color: #c0392b; }
.rc-val.rc-over { color: #d4a017; }
.rc-sub { font-size: 13px; color: #888; margin-top: 4px; }
.rc-zs-title { font-size: 15px; margin: 14px 0 8px; color: #444; }
.rc-method {
  font-size: 12px; line-height: 1.6; margin: 0 0 10px;
  padding: 8px 11px; border-left: 3px solid #c9b06a;
  background: rgba(201,176,106,.08); border-radius: 4px;
}
html[data-theme="dark"] .rc-method {
  border-left-color: #b89a4e; background: rgba(184,154,78,.12);
}
.reconcile-table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px; background: #fff; border-radius: 8px; overflow: hidden;
}
.reconcile-table th {
  text-align: left; padding: 8px 12px;
  background: #f5e9d4; font-weight: 600;
  border-bottom: 1px solid #e0c890;
}
.reconcile-table td {
  padding: 8px 12px; border-bottom: 1px solid #f0f0f0;
  font-variant-numeric: tabular-nums;
}
.reconcile-table tr:last-child td { border-bottom: none; }
.rc-cell-ok { color: #4a9648; font-weight: 600; }
.rc-cell-warn { color: #d4a017; font-weight: 600; }
.rc-cell-bad { color: #c0392b; font-weight: 700; background: rgba(192, 57, 43, 0.05); }

/* R49+ (2026-05-31): intro_subsection 小黃卡 — 計畫/機關 node detail 上方 */
.intro-subsection-card {
  margin: 10px 0 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #fefce8 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-left: 4px solid #d97706;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.7;
  color: #292524;
}
.intro-subsection-card .iss-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #78350f;
  padding-bottom: 6px;
  border-bottom: 1px dashed #fcd34d;
  margin-bottom: 8px;
}
.intro-subsection-card .iss-icon { font-size: 14px; }
.intro-subsection-card .iss-title { font-size: 13.5px; flex: 0 1 auto; }
.intro-subsection-card .iss-meta {
  font-size: 11px;
  color: #92400e;
  font-weight: 400;
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}
.intro-subsection-card .iss-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #78350f;
  font-size: 14px;
  padding: 0 4px;
}
.intro-subsection-card .iss-body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   v0.7.4 (2026-05-31) Tesla-grade 夜色細緻化
   依用戶要求：每個按鈕/細項 polish 對齊 Tesla screen 美感
   原則：
     • 大膽留白、ultra-thin border、subtle gradient
     • Hover 加 glow 不加 scale（避免抖動）
     • Numbers tabular-nums + 大字重
     • 圓角統一 8px (大) / 999px (pill)
     • Transition 180ms ease（Tesla 標準步調）
   ============================================================ */

html[data-theme="dark"] {
  /* 升級色票 — 對齊 Tesla 黑灰漸層 */
  --t-bg-0: #060a12;          /* 最深空黑 (body) */
  --t-bg-1: #0d131f;          /* card / panel */
  --t-bg-2: #131a2a;          /* row hover / nested */
  --t-bg-3: #1c2438;          /* hover surface */
  --t-border-faint: rgba(255,255,255,0.06);   /* almost invisible divider */
  --t-border-soft: rgba(255,255,255,0.10);
  --t-border-mid: rgba(255,255,255,0.16);
  --t-text-hi: #f4f7fb;
  --t-text-mid: #c5cee0;
  --t-text-lo: #6b7689;
  --t-cyan: #22d3ee;
  --t-cyan-mute: rgba(34, 211, 238, 0.55);
  --t-glow-soft: 0 4px 16px rgba(0,0,0,0.4);
  --t-glow-cyan: 0 0 0 1px rgba(34,211,238,0.4), 0 4px 18px rgba(34,211,238,0.18);
  --t-ease: 180ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 20% 10%, rgba(34,211,238,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(167,139,250,0.025) 0%, transparent 50%),
    var(--t-bg-0) !important;
}

/* ---------- 共通：所有 pill / chip 統一 base ---------- */
html[data-theme="dark"] .mc-review-box,
html[data-theme="dark"] .mc-book-state,
html[data-theme="dark"] .mc-pdf-btn,
html[data-theme="dark"] .tn-review-box,
html[data-theme="dark"] .tn-bs-imported,
html[data-theme="dark"] .tn-bs-downloaded,
html[data-theme="dark"] .tn-bs-missing,
html[data-theme="dark"] .tn-pdf-btn,
html[data-theme="dark"] .ag-chip {
  border-radius: 999px !important;
  padding: 3px 10px !important;
  font-size: 11px !important;
  font-weight: 500;
  letter-spacing: 0.2px;
  border-width: 1px !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--t-ease), border-color var(--t-ease),
              color var(--t-ease), box-shadow var(--t-ease),
              transform var(--t-ease);
}

/* ---------- 已修好 / 標記已修好 (review checkbox) ---------- */
html[data-theme="dark"] .mc-review-box,
html[data-theme="dark"] .tn-review-box {
  background: rgba(251, 191, 36, 0.06) !important;
  color: #fcd34d !important;
  border: 1px solid rgba(251, 191, 36, 0.22) !important;
  cursor: pointer;
}
html[data-theme="dark"] .mc-review-box:hover,
html[data-theme="dark"] .tn-review-box:hover {
  background: rgba(251, 191, 36, 0.14) !important;
  border-color: rgba(251, 191, 36, 0.5) !important;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.15);
}
/* checked state (用戶勾過) — emerald accent */
html[data-theme="dark"] .min-cell.is-reviewed .mc-review-box,
html[data-theme="dark"] .tn.is-fund-reviewed .tn-review-box {
  background: rgba(52, 211, 153, 0.12) !important;
  color: #6ee7b7 !important;
  border-color: rgba(52, 211, 153, 0.4) !important;
}

/* ---------- 已完成 / 已下載 / 缺 / 已匯入 (book state) ---------- */
html[data-theme="dark"] .mc-bs-imported,
html[data-theme="dark"] .tn-bs-imported {
  background: linear-gradient(135deg, rgba(52,211,153,0.18) 0%, rgba(52,211,153,0.06) 100%) !important;
  color: #6ee7b7 !important;
  border: 1px solid rgba(52, 211, 153, 0.45) !important;
  box-shadow: inset 0 0 12px rgba(52, 211, 153, 0.04);
}
html[data-theme="dark"] .mc-bs-downloaded,
html[data-theme="dark"] .tn-bs-downloaded {
  background: linear-gradient(135deg, rgba(251,146,60,0.20) 0%, rgba(251,146,60,0.06) 100%) !important;
  color: #fdba74 !important;
  border: 1px solid rgba(251, 146, 60, 0.5) !important;
  animation: none !important;  /* 取消舊 pulse 動畫，改 subtle 靜態 glow */
  box-shadow: 0 0 14px rgba(251, 146, 60, 0.12);
}
html[data-theme="dark"] .mc-bs-missing,
html[data-theme="dark"] .tn-bs-missing {
  background: rgba(255, 255, 255, 0.04) !important;
  color: #94a3b8 !important;
  border: 1px solid var(--t-border-soft) !important;
}

/* ---------- PDF 按鈕 ---------- */
html[data-theme="dark"] .mc-pdf-btn,
html[data-theme="dark"] .tn-pdf-btn {
  background: rgba(34, 211, 238, 0.08) !important;
  color: #67e8f9 !important;
  border: 1px solid rgba(34, 211, 238, 0.32) !important;
  text-decoration: none;
  font-weight: 500;
}
html[data-theme="dark"] .mc-pdf-btn:hover,
html[data-theme="dark"] .tn-pdf-btn:hover {
  background: rgba(34, 211, 238, 0.18) !important;
  color: #a5f3fc !important;
  border-color: var(--t-cyan) !important;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.32);
  text-decoration: none;
}

/* ---------- ag-chip (fund row state badges 特收/作業/營業 etc) ---------- */
/* 在 fund table state column 顯示 — Tesla 風 pill (refined) */
html[data-theme="dark"] .ag-chip {
  font-size: 10.5px !important;
  padding: 2px 9px !important;
}
html[data-theme="dark"] .ag-chip.imported {
  background: linear-gradient(135deg, rgba(52,211,153,0.18) 0%, rgba(52,211,153,0.05) 100%);
  color: #6ee7b7; border-color: rgba(52, 211, 153, 0.45) !important;
}
html[data-theme="dark"] .ag-chip.downloaded {
  background: linear-gradient(135deg, rgba(251,146,60,0.20) 0%, rgba(251,146,60,0.05) 100%);
  color: #fdba74; border-color: rgba(251, 146, 60, 0.5) !important;
  box-shadow: 0 0 10px rgba(251, 146, 60, 0.10);
}
html[data-theme="dark"] .ag-chip.missing {
  background: rgba(251, 113, 133, 0.10);
  color: #fda4af; border-color: rgba(251, 113, 133, 0.45) !important;
}
html[data-theme="dark"] .ag-chip.deprecated {
  background: rgba(255,255,255,0.03); color: #6b7689;
  border-color: var(--t-border-soft) !important;
  text-decoration: line-through; opacity: 0.7;
}
html[data-theme="dark"] .ag-chip.not-published {
  background: rgba(167, 139, 250, 0.10); color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.4) !important;
}
html[data-theme="dark"] .ag-chip.unknown {
  background: rgba(148, 163, 184, 0.08); color: #94a3b8;
  border-color: var(--t-border-soft) !important;
}

/* ---------- fund_type chip ($ 特收 / ⚙ 作業 / 🏢 營業) on fund rows ---------- */
/* 這幾個 chip 通常套 .fund-type-* 或 .ft-chip-* 等 — 統一柔化 */
html[data-theme="dark"] .ft-chip,
html[data-theme="dark"] .fund-type-chip,
html[data-theme="dark"] .ft-card .ft-mark,
html[data-theme="dark"] [class*="fund-type-"][class*="chip"] {
  border-radius: 999px !important;
  padding: 3px 10px !important;
  font-size: 10.5px !important;
  font-weight: 600;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--t-border-soft);
  color: var(--t-text-mid);
  letter-spacing: 0.3px;
}

/* ---------- fund_status table rows: dark state colors ---------- */
html[data-theme="dark"] .tbl-funds .fund-row.state-missing {
  background: rgba(251, 113, 133, 0.04) !important;
}
html[data-theme="dark"] .tbl-funds .fund-row.state-downloaded {
  background: rgba(251, 146, 60, 0.04) !important;
}
html[data-theme="dark"] .tbl-funds .fund-row.state-imported {
  background: rgba(52, 211, 153, 0.03) !important;
}
html[data-theme="dark"] .tbl-funds .fund-row:hover {
  background: rgba(34, 211, 238, 0.06) !important;
}

/* ---------- ag-row (sub-agency rows in org tree) ---------- */
html[data-theme="dark"] .ag-row.ag-imported { border-left-color: #34d399 !important; }
html[data-theme="dark"] .ag-row.ag-imported .ag-name { color: #6ee7b7 !important; }
html[data-theme="dark"] .ag-row.ag-downloaded {
  background: rgba(251, 146, 60, 0.04) !important;
  border-left-color: #fb923c !important;
}
html[data-theme="dark"] .ag-row.ag-likely_missing {
  background: rgba(251, 113, 133, 0.04) !important;
  border-left-color: #fb7185 !important;
}
html[data-theme="dark"] .ag-row.ag-likely_missing .ag-name {
  color: #fda4af !important;
}
html[data-theme="dark"] .ag-row.ag-no_independent_pdf {
  color: #475569 !important; opacity: 0.7;
}
html[data-theme="dark"] .ag-row.ag-no_independent_pdf .ag-name {
  color: #475569 !important;
}

/* ---------- buttons (override base for Tesla feel) ---------- */
html[data-theme="dark"] .btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--t-text-mid);
  border: 1px solid var(--t-border-soft);
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all var(--t-ease);
}
html[data-theme="dark"] .btn:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.10);
  color: #a5f3fc;
  border-color: var(--t-cyan-mute);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.15);
}
html[data-theme="dark"] .btn:active:not(:disabled) {
  background: rgba(34, 211, 238, 0.18);
  transform: translateY(0.5px);
}
html[data-theme="dark"] .btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}
html[data-theme="dark"] .btn.primary {
  background: linear-gradient(180deg, #22d3ee 0%, #0891b2 100%);
  color: #0a0e17; font-weight: 700;
  border: 1px solid #22d3ee;
  box-shadow: 0 0 0 1px rgba(34,211,238,0.2),
              0 4px 12px rgba(34, 211, 238, 0.25);
}
html[data-theme="dark"] .btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #67e8f9 0%, #22d3ee 100%);
  box-shadow: 0 0 0 1px rgba(34,211,238,0.5),
              0 6px 20px rgba(34, 211, 238, 0.45);
  transform: translateY(-1px);
}
html[data-theme="dark"] .btn.ghost {
  background: transparent;
  color: var(--t-text-lo);
  border: 1px solid var(--t-border-faint);
}
html[data-theme="dark"] .btn.ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--t-text-mid);
  border-color: var(--t-border-soft);
}

/* small/mini buttons (basket actions etc) — slightly smaller pill */
html[data-theme="dark"] .btn.btn-mini,
html[data-theme="dark"] .btn-add {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 999px;
}

/* ---------- min-cell hover refinement (主介面 部會 cards) ---------- */
html[data-theme="dark"] .min-cell {
  background: var(--t-bg-1) !important;
  border: 1px solid var(--t-border-faint) !important;
  transition: all var(--t-ease);
}
html[data-theme="dark"] .min-cell:hover {
  background: var(--t-bg-2) !important;
  border-color: var(--t-border-mid) !important;
  transform: translateY(-1px);
  box-shadow: var(--t-glow-soft);
}
html[data-theme="dark"] .min-cell.imported:hover {
  border-color: var(--t-cyan-mute) !important;
  box-shadow: var(--t-glow-cyan);
}

/* ---------- inputs / select Tesla feel ---------- */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--t-bg-1) !important;
  border: 1px solid var(--t-border-faint) !important;
  color: var(--t-text-hi) !important;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all var(--t-ease);
}
html[data-theme="dark"] input:hover,
html[data-theme="dark"] select:hover {
  border-color: var(--t-border-soft) !important;
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  background: var(--t-bg-2) !important;
  border-color: var(--t-cyan) !important;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

/* search input — distinguished */
html[data-theme="dark"] #ws-q,
html[data-theme="dark"] .db4-search-input,
html[data-theme="dark"] .ms-search {
  font-size: 13px;
}

/* ---------- tn-row + tn-name 細緻化 ---------- */
html[data-theme="dark"] .tn-row-wrap {
  border-bottom: 1px solid var(--t-border-faint);
  transition: background var(--t-ease), box-shadow var(--t-ease);
}
html[data-theme="dark"] .tn-row-wrap:hover {
  background: rgba(34, 211, 238, 0.04);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.10);
}
html[data-theme="dark"] .tn-amt {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

/* ---------- 「— 千元」 N/A state — 統一柔灰 ---------- */
html[data-theme="dark"] .tn-amt:empty::before,
html[data-theme="dark"] .val .val-na {
  content: "—";
  color: var(--t-text-lo) !important;
  font-style: normal;
  opacity: 0.7;
}

/* ---------- topbar 細化 — 收緊 ---------- */
html[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, rgba(13, 19, 32, 0.95) 0%, rgba(10, 14, 23, 0.85) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--t-border-faint);
  box-shadow: 0 1px 0 rgba(34, 211, 238, 0.08);
}

/* ---------- details / summary collapsible 細化 ---------- */
html[data-theme="dark"] details > summary {
  cursor: pointer;
  transition: color var(--t-ease);
}
html[data-theme="dark"] details > summary:hover {
  color: #67e8f9;
}
html[data-theme="dark"] .ed-section {
  background: var(--t-bg-1);
  border: 1px solid var(--t-border-faint);
  border-radius: 8px;
}
html[data-theme="dark"] .ed-section[open] {
  border-color: var(--t-border-soft);
}

/* ============================================================
   v0.7.5 (2026-05-31) Dark-mode 按鈕 white-flash fix
   問題：hover / 點下去出現白花花亮閃
   原因：
     1. browser 預設 -webkit-tap-highlight-color (灰白)
     2. .btn.primary:hover gradient 用了 #67e8f9 太亮，dark 底襯托像白光
     3. :focus 預設 outline ring 在 dark 上很刺眼
     4. :active state 用 lighter color (反 Tesla 直覺：按下應該更暗)
   修法：
     • 所有 clickable: tap-highlight transparent
     • Hover/active 改往「更深 cyan」走，不往「更淺亮」走
     • Focus 用 thin glow ring 取代瀏覽器預設
   ============================================================ */

html[data-theme="dark"] button,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .mc-pdf-btn,
html[data-theme="dark"] .tn-pdf-btn,
html[data-theme="dark"] .mc-review-box,
html[data-theme="dark"] .tn-review-box,
html[data-theme="dark"] .mc-bs-imported,
html[data-theme="dark"] .mc-bs-downloaded,
html[data-theme="dark"] .mc-bs-missing,
html[data-theme="dark"] .tn-bs-imported,
html[data-theme="dark"] .tn-bs-downloaded,
html[data-theme="dark"] .tn-bs-missing,
html[data-theme="dark"] .min-cell,
html[data-theme="dark"] .navlink,
html[data-theme="dark"] .ml-tab,
html[data-theme="dark"] .ui-tg-btn,
html[data-theme="dark"] .fz-btn,
html[data-theme="dark"] details > summary,
html[data-theme="dark"] a {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* 取消所有 button/a 預設 :focus outline (太亮) 改自定 glow ring */
html[data-theme="dark"] button:focus,
html[data-theme="dark"] .btn:focus,
html[data-theme="dark"] a:focus,
html[data-theme="dark"] .navlink:focus,
html[data-theme="dark"] .ml-tab:focus {
  outline: none !important;
}
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] .btn:focus-visible,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] .navlink:focus-visible,
html[data-theme="dark"] .ml-tab:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.35),
              0 0 12px rgba(34, 211, 238, 0.18);
}

/* —— .btn.primary 修正 —— Tesla 直覺：press = 暗一階 / hover = 同色 +微 glow */
html[data-theme="dark"] .btn.primary {
  background: linear-gradient(180deg, #06b6d4 0%, #0e7490 100%) !important;
  color: #ecfeff !important;
  border-color: #0891b2 !important;
  box-shadow: 0 0 0 1px rgba(34,211,238,0.18),
              0 3px 10px rgba(34, 211, 238, 0.18) !important;
}
html[data-theme="dark"] .btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #0891b2 0%, #0e7490 100%) !important;
  color: #ecfeff !important;
  box-shadow: 0 0 0 1px rgba(34,211,238,0.35),
              0 4px 14px rgba(34, 211, 238, 0.28) !important;
  transform: none !important;
}
html[data-theme="dark"] .btn.primary:active:not(:disabled) {
  background: linear-gradient(180deg, #0e7490 0%, #155e75 100%) !important;
  box-shadow: 0 0 0 1px rgba(34,211,238,0.5),
              inset 0 1px 3px rgba(0,0,0,0.3) !important;
  transform: translateY(0.5px) !important;
}

/* —— .btn (default 非 primary) 修正 active = 更深，不更亮 —— */
html[data-theme="dark"] .btn:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.08) !important;   /* 從 0.10 改 0.08 — 更柔 */
  color: #a5f3fc !important;
  border-color: rgba(34, 211, 238, 0.35) !important;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.12) !important;  /* 從 14px/0.15 改 10px/0.12 */
}
html[data-theme="dark"] .btn:active:not(:disabled) {
  background: rgba(34, 211, 238, 0.04) !important;   /* 從 0.18 (亮) 改 0.04 (暗) */
  border-color: rgba(34, 211, 238, 0.5) !important;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.3) !important;  /* 內陰影 = 凹下感 */
  transform: translateY(0.5px) !important;
}

/* —— .btn.ghost 修正 —— */
html[data-theme="dark"] .btn.ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.03) !important;
  color: #cbd5e1 !important;
  border-color: rgba(255,255,255,0.12) !important;
  box-shadow: none !important;
}
html[data-theme="dark"] .btn.ghost:active:not(:disabled) {
  background: rgba(255,255,255,0.01) !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.25) !important;
}

/* —— PDF btn / state pills active state 統一改 inset shadow —— */
html[data-theme="dark"] .mc-pdf-btn:active,
html[data-theme="dark"] .tn-pdf-btn:active,
html[data-theme="dark"] .mc-review-box:active,
html[data-theme="dark"] .tn-review-box:active,
html[data-theme="dark"] .mc-bs-imported:active,
html[data-theme="dark"] .tn-bs-imported:active,
html[data-theme="dark"] .mc-bs-downloaded:active,
html[data-theme="dark"] .tn-bs-downloaded:active {
  background: rgba(0, 0, 0, 0.25) !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4),
              0 0 8px rgba(34, 211, 238, 0.15) !important;
  transform: translateY(0.5px) !important;
}

/* —— navlink / tabs active = 收緊不放亮 —— */
html[data-theme="dark"] .navlink:active,
html[data-theme="dark"] .ml-tab:active {
  background: rgba(34, 211, 238, 0.05) !important;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.3) !important;
}

/* —— min-cell click 修正：不要瀏覽器 default 灰白 selection —— */
html[data-theme="dark"] .min-cell:active {
  background: rgba(34, 211, 238, 0.04) !important;
  transform: translateY(0) !important;  /* 取消 hover translateY 防止抖 */
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.25) !important;
}

/* —— 取消所有 :focus-within 在 card 上的亮邊 (預設可能是黃/白) —— */
html[data-theme="dark"] .min-cell:focus-within {
  outline: none !important;
}

/* ============================================================
   v0.7.6 (2026-05-31) Dark-mode 透白漏底 fix
   問題：選取 (.is-selected) / 各 kind-* row 預設用 light-color
        background (#fff8f0/#fff5f5/#faf8ff/#d8e8ff/#eef4ff) → dark
        mode 沒 override → 整片白
   修法：override 對應 selectors 為 cyan-tinted dark backgrounds
   ============================================================ */

/* —— .tn-row hover / selected —— */
html[data-theme="dark"] .tn-row:hover {
  background: rgba(34, 211, 238, 0.06) !important;
}
html[data-theme="dark"] .tn-row.is-selected {
  background: rgba(34, 211, 238, 0.10) !important;
  box-shadow: inset 3px 0 0 #22d3ee !important;
}
html[data-theme="dark"] .tn-row .tn-cut-hint { color: #475569 !important; }
html[data-theme="dark"] .tn-row:hover .tn-cut-hint {
  color: #67e8f9 !important;
}

/* —— 各 kind-* row 左邊裝飾色條 + 底色重設 —— */
html[data-theme="dark"] .kind-主管 > .tn-row-wrap {
  border-left-color: #fbbf24 !important;
  background: rgba(251, 191, 36, 0.04) !important;
}
html[data-theme="dark"] .kind-機關 > .tn-row-wrap {
  border-left-color: #f472b6 !important;
  background: rgba(244, 114, 182, 0.04) !important;
}
html[data-theme="dark"] .kind-目 > .tn-row-wrap {
  border-left-color: #60a5fa !important;
  background: transparent !important;
}
html[data-theme="dark"] .kind-分支計畫 > .tn-row-wrap {
  border-left-color: #34d399 !important;
  background: transparent !important;
}
html[data-theme="dark"] .kind-用途別大類 > .tn-row-wrap {
  border-left-color: #a78bfa !important;
  background: rgba(167, 139, 250, 0.04) !important;
}
html[data-theme="dark"] .kind-用途別大類.expanded > .tn-row-wrap {
  background: rgba(167, 139, 250, 0.10) !important;
}
html[data-theme="dark"] .kind-用途別細項 > .tn-row-wrap {
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* —— is-match / has-descendant-match / is-active-match (search 結果) —— */
html[data-theme="dark"] .tn.is-match > .tn-row-wrap {
  background: rgba(251, 191, 36, 0.10) !important;
}
html[data-theme="dark"] .tn.has-descendant-match > .tn-row-wrap {
  background: rgba(251, 191, 36, 0.04) !important;
}
html[data-theme="dark"] .tn.is-active-match > .tn-row-wrap {
  background: rgba(34, 211, 238, 0.12) !important;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.4) !important;
}

/* —— text 顏色穩定（hover 也保持可讀） —— */
html[data-theme="dark"] .tn-row:hover .tn-name,
html[data-theme="dark"] .tn-row.is-selected .tn-name {
  color: var(--t-text-hi, #f4f7fb) !important;
}
html[data-theme="dark"] .tn-row:hover .tn-amt,
html[data-theme="dark"] .tn-row.is-selected .tn-amt {
  color: #cbd5e1 !important;
}

/* —— ref-tables details (通用代碼對照表) —— */
html[data-theme="dark"] .ref-tables details {
  background: var(--t-bg-1, #0d131f) !important;
  border: 1px solid var(--t-border-faint, rgba(255,255,255,0.06)) !important;
}

/* ============================================================
   v0.7.7 (2026-05-31) Dark-mode 部會 cards 金額 panel + chips fix
   問題：.mc-total / .mc-extra-fund / .mc-extra-admin 等用 light bg
        (rgba(255,255,255,0.55) / #fff7c8 / #ece5ff) hardcoded → dark
        mode 整片米白突兀，跟卡片不協調
   修法：dark override 改為 deep tinted glass + neon-ish accent
   ============================================================ */

html[data-theme="dark"] .min-cell .mc-total {
  background: rgba(34, 211, 238, 0.04) !important;
  border: 1px dashed rgba(34, 211, 238, 0.20) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
/* 4 大類 category-specific bg + border tint */
html[data-theme="dark"] .min-cell.cat-fu-yuan .mc-total {
  background: rgba(34, 211, 238, 0.05) !important;
  border-color: rgba(34, 211, 238, 0.28) !important;
}
html[data-theme="dark"] .min-cell.cat-bu .mc-total {
  background: rgba(167, 139, 250, 0.05) !important;
  border-color: rgba(167, 139, 250, 0.28) !important;
}
html[data-theme="dark"] .min-cell.cat-weiyuanhui .mc-total {
  background: rgba(251, 191, 36, 0.05) !important;
  border-color: rgba(251, 191, 36, 0.28) !important;
}
html[data-theme="dark"] .min-cell.cat-other .mc-total {
  background: rgba(148, 163, 184, 0.05) !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
}

/* 主數字色：dark theme 用 neon-rose（紅色在 dark 上太刺，改 rose 飽和度低） */
html[data-theme="dark"] .min-cell .mc-total-amt {
  color: #fb7185 !important;
  text-shadow: 0 0 12px rgba(251, 113, 133, 0.15);
}
html[data-theme="dark"] .min-cell .mc-total-sub {
  color: #94a3b8 !important;
}

/* 附帶數值 chip：基金 N 億 / 行政法人 N 億 / 補助 N 億 — 改半透明 deep */
html[data-theme="dark"] .min-cell .mc-total-sub .mc-extra-fund {
  background: rgba(251, 191, 36, 0.12) !important;
  color: #fcd34d !important;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  padding: 1px 8px;
}
html[data-theme="dark"] .min-cell .mc-total-sub .mc-extra-admin {
  background: rgba(167, 139, 250, 0.12) !important;
  color: #c4b5fd !important;
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: 999px;
  padding: 1px 8px;
}
html[data-theme="dark"] .min-cell .mc-total-sub .mc-extra-subsidy,
html[data-theme="dark"] .min-cell .mc-total-sub [class*="mc-extra-"] {
  background: rgba(34, 211, 238, 0.10);
  color: #67e8f9;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 999px;
  padding: 1px 8px;
}

/* mc-type chip (左下角「行政院部會」「獨立機關」) — 也是 light bg */
html[data-theme="dark"] .min-cell .mc-type {
  background: rgba(255, 255, 255, 0.04) !important;
  color: #94a3b8 !important;
  border-radius: 999px;
  padding: 1px 8px;
}

/* mc-branch-hint「🏛️ 含 N 附屬機關」chip */
html[data-theme="dark"] .min-cell .mc-branch-hint {
  background: rgba(167, 139, 250, 0.10) !important;
  color: #c4b5fd !important;
  border: 1px solid rgba(167, 139, 250, 0.28) !important;
  border-radius: 999px;
  padding: 1px 8px;
}

/* 司法院本院 / 部會主管總覽 等小 chip (司法院/考試院 card 中間) */
html[data-theme="dark"] .min-cell .mc-court-self,
html[data-theme="dark"] .min-cell .mc-overview-tag {
  background: rgba(255, 255, 255, 0.04) !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 4px;
}

/* 「✓ N 項」 / 「✓ N,XXX 項」status text — 已是 mc-status.ok 但顏色可能太鮮 */
html[data-theme="dark"] .min-cell .mc-status.ok {
  color: #34d399 !important;
}
html[data-theme="dark"] .min-cell .mc-status.pending {
  color: #fbbf24 !important;
}

/* v0.7.5 (2026-05-31) 🔒 鐵律 6 強化：ministry stub 灰階顯示 — 確保所有部會不消失 */
.tn.is-ministry-stub > .tn-row-wrap {
  background: repeating-linear-gradient(
    -45deg, #f9fafb, #f9fafb 6px, #eef2ff 6px, #eef2ff 12px
  );
  border-left: 2px dashed #818cf8 !important;
  opacity: 0.8;
}
.tn.is-ministry-stub > .tn-row-wrap .tn-name {
  color: #6366f1; font-style: italic;
}
.tn.is-ministry-stub > .tn-row-wrap .tn-amt {
  color: #a5b4fc; font-style: italic;
}
.tn.is-ministry-stub > .tn-row-wrap .tn-badge {
  background: #e0e7ff; color: #4338ca; border: 1px dashed #818cf8;
}
.tn-warn.ministry-stub {
  display: inline-block; color: #6366f1; font-size: 14px;
  margin-right: 4px; cursor: help;
}
/* 2026-07-31 stub 狀態直接標在金額欄（籌設中・尚未編列預算 / 預算書未匯入） */
.tn.is-ministry-stub > .tn-row-wrap .tn-amt.tn-amt-stubstatus {
  font-style: normal; font-size: 11px; font-weight: 600;
  color: #4338ca; background: #e0e7ff; border: 1px dashed #818cf8;
  border-radius: 10px; padding: 1px 8px; cursor: help; white-space: nowrap;
}
/* dark mode */
html[data-theme="dark"] .tn.is-ministry-stub > .tn-row-wrap {
  background: repeating-linear-gradient(
    -45deg, #1e1b4b, #1e1b4b 6px, #312e81 6px, #312e81 12px
  );
  border-left-color: #a78bfa !important;
}
html[data-theme="dark"] .tn.is-ministry-stub > .tn-row-wrap .tn-name { color: #c4b5fd; }
html[data-theme="dark"] .tn.is-ministry-stub > .tn-row-wrap .tn-amt { color: #818cf8; }
html[data-theme="dark"] .tn.is-ministry-stub > .tn-row-wrap .tn-badge {
  background: #312e81; color: #c4b5fd; border-color: #a78bfa;
}
html[data-theme="dark"] .tn-warn.ministry-stub { color: #a78bfa; }
html[data-theme="dark"] .tn.is-ministry-stub > .tn-row-wrap .tn-amt.tn-amt-stubstatus {
  color: #c4b5fd; background: #312e81; border-color: #a78bfa;
}

/* ============ D10 骨架模式 (2026-07-27)：非預設 dataset 書未匯入 → 整樹灰階＋「未匯入」 ============ */
.tn.is-skeleton > .tn-row-wrap {
  filter: grayscale(1);
  opacity: 0.62;
  border-left: 2px dashed #9ca3af !important;
}
.tn.is-skeleton > .tn-row-wrap .tn-name { color: #6b7280; }
.tn.is-skeleton > .tn-row-wrap .tn-amt.tn-amt-skel {
  color: #9ca3af; font-style: italic; font-size: 11px;
  border: 1px dashed #d1d5db; border-radius: 4px; padding: 0 5px;
}
html[data-theme="dark"] .tn.is-skeleton > .tn-row-wrap { opacity: 0.55; border-left-color: #6b7280 !important; }
html[data-theme="dark"] .tn.is-skeleton > .tn-row-wrap .tn-name { color: #9ca3af; }
html[data-theme="dark"] .tn.is-skeleton > .tn-row-wrap .tn-amt.tn-amt-skel { color: #6b7280; border-color: #4b5563; }
.exp-skel-banner {
  margin: 8px 0 10px; padding: 9px 12px; font-size: 13px; line-height: 1.6;
  color: #4b5563; background: repeating-linear-gradient(-45deg, #f9fafb, #f9fafb 8px, #f3f4f6 8px, #f3f4f6 16px);
  border: 1px dashed #9ca3af; border-radius: 8px;
}
html[data-theme="dark"] .exp-skel-banner {
  color: #d1d5db; border-color: #6b7280;
  background: repeating-linear-gradient(-45deg, #111827, #111827 8px, #1f2937 8px, #1f2937 16px);
}

/* ============ v0.8.0 (2026-06-01) 說明移到頁尾 — 作業儀表板撐大 ============ */

/* tree-wrap 高度提升：原 180px (頂部 + head desc + footnote 預留) → 140px (head 變短後) */
.exp-tree-wrap { max-height: calc(100vh - 140px); }

/* 頁尾說明區 — 上方留白與 grid 區隔 */
.exp-helpers {
  margin: 28px 0 12px;
  padding: 0;
  border-top: 1px solid var(--c-border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.exp-help-tips {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
}
.exp-help-tips summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--c-text);
  user-select: none;
  padding: 4px 0;
}
.exp-help-tips summary:hover { color: var(--c-accent); }
.exp-help-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--c-border);
}
.exp-help-body .exp-desc {
  margin: 6px 0;
  line-height: 1.7;
}
.exp-help-body .exp-footnote {
  margin: 6px 0 4px;
  font-size: 12.5px;
  color: var(--c-muted);
}
.exp-help-body .exp-fn-mark {
  color: var(--c-accent);
  font-weight: 700;
  margin-right: 4px;
}

/* dark mode */
html[data-theme="dark"] .exp-helpers { border-top-color: #2c3340; }
html[data-theme="dark"] .exp-help-tips { background: #1a1f2c; border-color: #2c3340; }
html[data-theme="dark"] .exp-help-body { border-top-color: #2c3340; }

/* ============================================================
   v0.7.3 (2026-06-02) 立方體切換 — 預算小幫手 ↔ 輿情小幫手
   ============================================================ */

/* perspective on html so .content (一面) 看起來像在轉的方塊 */
html.cube-prep { perspective: 1500px; overflow-x: hidden; }
html.cube-prep body { overflow-x: hidden; }

main.content {
  transform-origin: center center;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

main.content.cube-out-right,
main.content.cube-out-left,
main.content.cube-in-from-right,
main.content.cube-in-from-left,
main.content.cube-arriving {
  transition: transform 0.6s cubic-bezier(0.83, 0, 0.17, 1),
              opacity 0.6s cubic-bezier(0.83, 0, 0.17, 1);
}

/* 出場：往右轉 90° (相當於 cube 右面轉到面前) */
main.content.cube-out-right {
  transform: perspective(1500px) rotateY(-90deg) translateZ(0);
  opacity: 0.2;
}
/* 出場：往左轉 90° */
main.content.cube-out-left {
  transform: perspective(1500px) rotateY(90deg) translateZ(0);
  opacity: 0.2;
}
/* 進場起始：從右 (90°) 來 */
main.content.cube-in-from-right {
  transform: perspective(1500px) rotateY(90deg) translateZ(0);
  opacity: 0;
  transition: none;
}
/* 進場起始：從左 (-90°) 來 */
main.content.cube-in-from-left {
  transform: perspective(1500px) rotateY(-90deg) translateZ(0);
  opacity: 0;
  transition: none;
}
/* 進場結束：轉到 0° + 不透明 */
main.content.cube-arriving {
  transform: perspective(1500px) rotateY(0deg) translateZ(0);
  opacity: 1;
}

/* cube-fx-overlay 預留位（base.html 有 markup，目前以 main.content 自身為轉的方塊主體；
   日後若要 cube 連 header 一起轉可用 overlay 接管） */
.cube-fx-overlay { display: none; }

/* ui-cube-btn — topbar 切換 icon */
.ui-cube-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 16px;
  margin-left: 4px;
  border-radius: 6px;
  padding: 4px 8px;
  border: 1px solid var(--c-border, #ddd);
  background: var(--c-card, #fff);
  color: var(--c-text);
  transition: background 0.15s, transform 0.2s;
  cursor: pointer;
}
.ui-cube-btn:hover {
  background: linear-gradient(135deg, #ffe0e0, #fff5d4);
  transform: rotate(-12deg) scale(1.08);
}
html[data-theme="dark"] .ui-cube-btn {
  background: #1a1f2c;
  border-color: #2c3340;
}
html[data-theme="dark"] .ui-cube-btn:hover {
  background: linear-gradient(135deg, #3c1f24, #3a3a1a);
}

/* ============================================================
   品牌方塊 = 預算 ↔ 輿情 切換鈕（2026-06-16 用戶）
   hover：科技玻璃斜斜閃過；click：機械解構轉場（見 .mech-fx）
   ============================================================ */
.brand-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: 5px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  overflow: visible;          /* 讓 HUD 角括號 / 掃描線可探出 */
  isolation: isolate;
  transition: border-color .25s ease, box-shadow .25s ease, background .25s ease, transform .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.brand-switch:hover {
  border-color: rgba(56, 205, 255, .5);
  background: rgba(56, 205, 255, .05);
  box-shadow: 0 0 0 1px rgba(56, 205, 255, .22), 0 6px 22px rgba(56, 205, 255, .16);
}
.brand-switch:active { transform: scale(.98); }

/* ============================================================
   科技 glitch-morph 切換動畫（2026-06-16 用戶「生成一個科技感有動態的切換動畫」）
   靜置：白標題 + 兩側 HUD 角括號微亮呼吸。
   hover：標題色散 glitch 淡出 → 目的地名以 cyan 由上而下掃描湧現，
          掃描線掠過、角括號鎖定。兩名同為 5 字寬，4.0 不動只有名字在變。
   ============================================================ */
.bsw { position: relative; display: inline-block; line-height: 1; padding: 1px 0; }
.bsw-cur, .bsw-next {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-block;
}
.bsw-cur { position: relative; z-index: 1; transition: opacity .25s ease; }
.bsw-next {
  position: absolute;
  left: 0; top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  color: #7de7ff;
  text-shadow: 0 0 11px rgba(56, 205, 255, .75);
  opacity: 0;
  clip-path: inset(0 0 100% 0);
  pointer-events: none;
  transition: opacity .25s ease;
}
.brand-switch .ver { color: var(--c-accent); font-weight: 700; }

.brand-switch:hover .bsw-cur  { animation: bswOut .5s cubic-bezier(.5, .05, .2, 1) forwards; }
.brand-switch:hover .bsw-next { animation: bswIn .55s cubic-bezier(.5, .05, .2, 1) .05s forwards; }
@keyframes bswOut {
  0%   { opacity: 1; clip-path: inset(0 0 0 0); transform: translateX(0); text-shadow: none; }
  18%  { clip-path: inset(0 0 56% 0); transform: translateX(-2px);
         text-shadow: 2px 0 rgba(255, 40, 95, .85), -2px 0 rgba(0, 225, 255, .85); }
  36%  { clip-path: inset(54% 0 12% 0); transform: translateX(2px); }
  54%  { clip-path: inset(26% 0 42% 0); transform: translateX(-1px); opacity: .5; }
  72%  { opacity: .16; }
  100% { opacity: 0; clip-path: inset(0 0 0 0); transform: translateX(0); }
}
@keyframes bswIn {
  0%   { opacity: 0; clip-path: inset(0 0 100% 0); transform: translateY(-50%) translateX(0); }
  30%  { opacity: .45; clip-path: inset(0 0 58% 0); transform: translateY(-50%) translateX(2px); }
  54%  { opacity: .85; clip-path: inset(0 0 24% 0); transform: translateY(-50%) translateX(-2px);
         text-shadow: 2px 0 rgba(255, 40, 95, .65), -2px 0 rgba(0, 225, 255, .8), 0 0 10px rgba(56, 205, 255, .7); }
  100% { opacity: 1; clip-path: inset(0 0 0 0); transform: translateY(-50%) translateX(0);
         text-shadow: 0 0 12px rgba(56, 205, 255, .8); }
}

/* 掃描線：hover 時一道 cyan 線由上掠到下 */
.bsw-scan {
  position: absolute;
  left: -7px; right: -7px; top: 0;
  height: 2px;
  z-index: 2;
  background: linear-gradient(90deg, transparent, rgba(125, 226, 255, .95) 50%, transparent);
  box-shadow: 0 0 10px rgba(56, 205, 255, .9);
  opacity: 0;
  pointer-events: none;
}
.brand-switch:hover .bsw-scan { animation: bswScan .6s ease forwards; }
@keyframes bswScan {
  0%   { top: -3px; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* HUD 角括號（定位框）：靜置微亮呼吸；hover 鎖定收緊全亮 */
.bsw-bracket {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 17px;
  border: 2px solid rgba(125, 226, 255, .85);
  opacity: .26;
  z-index: 2;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2, 1.3, .4, 1), border-color .25s ease;
  animation: bswBreath 2.6s ease-in-out infinite;
}
.bsw-bl { left: -9px;  border-right: none; transform: translateY(-50%) translateX(5px); }
.bsw-br { right: -9px; border-left: none;  transform: translateY(-50%) translateX(-5px); }
.brand-switch:hover .bsw-bracket { opacity: 1; border-color: #9fe9ff; animation: none; }
.brand-switch:hover .bsw-bl,
.brand-switch:hover .bsw-br { transform: translateY(-50%) translateX(0); }
@keyframes bswBreath { 0%, 100% { opacity: .2; } 50% { opacity: .42; } }

@media (prefers-reduced-motion: reduce) {
  .brand-switch:hover .bsw-cur  { animation: none; opacity: 0; }
  .brand-switch:hover .bsw-next { animation: none; opacity: 1; clip-path: inset(0 0 0 0); }
  .brand-switch:hover .bsw-scan { animation: none; }
  .bsw-bracket { animation: none; }
}

html[data-theme="dark"] .brand-switch:hover {
  border-color: rgba(56, 225, 255, .55);
  background: rgba(56, 225, 255, .07);
  box-shadow: 0 0 0 1px rgba(56, 225, 255, .3), 0 6px 24px rgba(56, 225, 255, .2);
}

/* 坐進 dataset-supertabs 深色橫列的 compact 版（最左上角，與 115 預算同排）2026-06-16 用戶 */
.dataset-supertabs .brand-switch-strip {
  align-self: center;
  margin: 0 8px 0 -4px;
  padding: 4px 11px;
  border-radius: 9px;
  flex: 0 0 auto;
}
.dataset-supertabs .brand-switch-strip .bsw-cur,
.dataset-supertabs .brand-switch-strip .bsw-next {
  font-size: 15.5px;
  letter-spacing: .3px;
}
.dataset-supertabs .brand-switch-strip .bsw-cur { color: #f1f5f9; }
.dataset-supertabs .brand-switch-strip .ver { color: #fbbf24; }
.dataset-supertabs .brand-switch-strip:hover {
  border-color: rgba(120, 225, 255, .55);
  background: rgba(120, 225, 255, .1);
  box-shadow: 0 0 0 1px rgba(120, 225, 255, .3), 0 4px 16px rgba(56, 205, 255, .25);
}

/* ============================================================
   機械解構轉場 overlay（變形金剛／鋼鐵人風）2026-06-16 用戶
   橫向裝甲百葉交錯閉合蓋滿 + HUD 環/讀條/掃描線 → 退開揭示
   ============================================================ */
/* 抵達新頁第一幀的遮罩（head script 加 mech-incoming），避免內容閃現 */
html.mech-incoming::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9490;
  background: radial-gradient(circle at 50% 44%, #0b1626 0%, #060a12 78%);
  pointer-events: none;
}
.mech-fx {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
html.mech-active .mech-fx { opacity: 1; visibility: visible; }

/* 百葉容器：上下堆疊的裝甲橫條 */
.mech-slats {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.mech-slat {
  position: relative;
  flex: 1 1 0;
  transform: scaleX(0);
  transform-origin: left center;
  background:
    linear-gradient(90deg, rgba(56,225,255,.10), rgba(56,225,255,0) 18%, rgba(56,225,255,0) 82%, rgba(56,225,255,.10)),
    repeating-linear-gradient(115deg, rgba(255,255,255,.03) 0 2px, rgba(255,255,255,0) 2px 9px),
    linear-gradient(180deg, #0e1c30 0%, #0a1626 50%, #081120 100%);
  box-shadow:
    inset 0 1px 0 rgba(96, 230, 255, .45),
    inset 0 -1px 0 rgba(10, 20, 36, .9),
    inset 0 -2px 0 rgba(96, 230, 255, .18);
  will-change: transform;
}
/* 每條中央一道發亮接縫，機械咬合感 */
.mech-slat::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(96,230,255,.5) 20%, rgba(96,230,255,.5) 80%, transparent);
  opacity: .5;
}
/* 交錯咬合：奇數條從左、偶數條從右 */
.mech-slat:nth-child(odd)  { transform-origin: left center; }
.mech-slat:nth-child(even) { transform-origin: right center; }
/* 方向：往輿情(right)時左先咬；往預算(left)時右先咬 — 用 dir class 反轉 origin 主導側 */
html.mech-dir-left .mech-slat:nth-child(odd)  { transform-origin: right center; }
html.mech-dir-left .mech-slat:nth-child(even) { transform-origin: left center; }

/* 出場閉合：scaleX 0→1 交錯 stagger */
html.mech-closing .mech-slat {
  transform: scaleX(1);
  transition: transform .46s cubic-bezier(.16, .84, .26, 1);
  transition-delay: calc(var(--i) * .045s);
}
/* 進場預備：已蓋滿、無動畫 */
html.mech-prep .mech-slat { transform: scaleX(1); transition: none; }
/* 進場退開：scaleX 1→0 交錯 stagger（由中段往兩端，反序更像裝甲彈開）*/
html.mech-opening .mech-slat {
  transform: scaleX(0);
  transition: transform .5s cubic-bezier(.7, 0, .2, 1);
  transition-delay: calc((9 - var(--i)) * .04s);
}

/* 掃描網格 + 掃描線：閉合過程淡入 */
.mech-grid {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image:
    linear-gradient(rgba(56,225,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56,225,255,.07) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  transition: opacity .35s ease;
}
.mech-scan {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: repeating-linear-gradient(0deg,
    rgba(120,235,255,.05) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
  transition: opacity .35s ease;
}
html.mech-closing .mech-grid { opacity: .9; transition-delay: .12s; }
html.mech-closing .mech-scan { opacity: 1;  transition-delay: .12s; animation: mechScan 1.1s linear infinite; }
html.mech-opening .mech-grid,
html.mech-opening .mech-scan { opacity: 0; }
@keyframes mechScan { 0% { background-position-y: 0; } 100% { background-position-y: 18px; } }

/* HUD 核心：雙環 + 準星 + 讀條 */
.mech-core {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.6);
  width: 220px; height: 220px;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .3s ease, transform .4s cubic-bezier(.16, .84, .26, 1);
}
html.mech-closing .mech-core { opacity: 1; transform: translate(-50%, -50%) scale(1); transition-delay: .18s; }
html.mech-opening .mech-core { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
.mech-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background:
    conic-gradient(from 0deg, rgba(56,225,255,0) 0deg, rgba(56,225,255,.85) 70deg, rgba(56,225,255,0) 150deg, rgba(56,225,255,0) 180deg, rgba(56,225,255,.85) 250deg, rgba(56,225,255,0) 330deg) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: mechSpin 2.4s linear infinite;
}
.mech-ring-2 {
  inset: 26px;
  background:
    conic-gradient(from 180deg, rgba(120,235,255,0) 0deg, rgba(120,235,255,.7) 60deg, rgba(120,235,255,0) 120deg) border-box;
  animation: mechSpin 1.5s linear infinite reverse;
}
@keyframes mechSpin { to { transform: rotate(360deg); } }
.mech-reticle {
  position: absolute;
  width: 70px; height: 70px;
  border: 1px solid rgba(120,235,255,.55);
  border-radius: 4px;
  box-shadow: 0 0 14px rgba(56,225,255,.5), inset 0 0 10px rgba(56,225,255,.25);
}
.mech-reticle::before, .mech-reticle::after {
  content: "";
  position: absolute;
  background: rgba(160,240,255,.8);
}
.mech-reticle::before { left: 50%; top: -10px; bottom: -10px; width: 1px; transform: translateX(-50%); }
.mech-reticle::after  { top: 50%; left: -10px; right: -10px; height: 1px; transform: translateY(-50%); }
.mech-readout {
  position: absolute;
  bottom: -42px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  white-space: nowrap;
}
.mech-readout-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(120,235,255,.7);
  border: 1px solid rgba(120,235,255,.4);
  border-radius: 3px;
  padding: 1px 5px;
}
.mech-readout-text {
  font-size: 13px;
  letter-spacing: 3px;
  color: #bdeeff;
  text-shadow: 0 0 10px rgba(56,225,255,.6);
}
.mech-readout-text::after {
  content: "";
  display: inline-block;
  margin-left: 6px;
  width: 7px; height: 13px;
  vertical-align: -2px;
  background: rgba(160,240,255,.85);
  animation: mechBlink .7s steps(1) infinite;
}
@keyframes mechBlink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .mech-slat, .mech-core, .mech-ring, .mech-ring-2, .mech-scan { animation: none !important; }
  .mech-slat { transition-duration: .25s !important; transition-delay: 0s !important; }
}

/* ─────────────────────────────────────────────────────────────
   輿情小幫手 page styling
   ────────────────────────────────────────────────────────────*/
.sent-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 80px;
}
.sent-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  background: linear-gradient(135deg, #fff4f4, #fff9e8 65%, #f0fdf4);
  border-radius: 14px;
  border: 1px solid #fcd7d7;
  margin-bottom: 22px;
  box-shadow: 0 4px 14px rgba(220, 60, 80, 0.08);
}
.sent-hero h1 {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 0.5px;
  color: #c23044;
}
.sent-hero .sent-sub {
  color: #555;
  font-size: 13.5px;
  margin: 0;
}
.sent-hero .sent-date {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  border: 1px solid #f0d6d6;
  color: #555;
  white-space: nowrap;
}
.sent-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
}
@media (max-width: 900px) { .sent-grid { grid-template-columns: 1fr; } }

.sent-card {
  background: var(--c-card, #fff);
  border: 1px solid var(--c-border, #e2e2e2);
  border-radius: 12px;
  padding: 16px 18px;
}
.sent-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sent-topic {
  border-top: 1px solid var(--c-border, #eee);
  padding: 14px 0 12px;
}
.sent-topic:first-of-type { border-top: 0; padding-top: 4px; }
.sent-topic-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.sent-topic-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--c-text);
}
.sent-topic-rank {
  background: linear-gradient(135deg, #ff6b6b, #ff9c1a);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  padding: 2px 8px;
  font-weight: 700;
  white-space: nowrap;
}
.sent-topic-summary {
  margin: 4px 0 8px;
  line-height: 1.65;
  font-size: 13.5px;
  color: var(--c-text);
}
.sent-topic-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--c-muted, #888);
}
.sent-tag {
  background: rgba(60, 100, 200, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
  color: #345aa8;
  font-size: 11px;
}
.sent-sentiment {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.sent-sentiment.positive { background: #d4f5e0; color: #06813c; }
.sent-sentiment.negative { background: #fde2e4; color: #c1233a; }
.sent-sentiment.neutral { background: #eef2f6; color: #5a6a7a; }
.sent-sentiment.mixed { background: #fff1d4; color: #b07000; }

.sent-trends {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sent-trend {
  background: linear-gradient(135deg, #ffe7e7, #fff5d4);
  border: 1px solid #f4c8c8;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  color: #b1304a;
  cursor: default;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  transition: transform 0.15s;
}
.sent-trend:hover { transform: translateY(-2px); }
.sent-trend .sent-trend-vol {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 6px;
  padding: 1px 6px;
  color: #555;
  font-weight: 600;
}
.sent-mood {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--c-border, #ddd);
  font-size: 13px;
  color: var(--c-muted);
}
.sent-mood-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(to right, #c1233a, #f4a02d 50%, #06813c);
  position: relative;
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
}
.sent-mood-bar > .sent-mood-marker {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: #fff;
  border: 1.5px solid #333;
  transform: translateX(-50%);
}

.sent-loading {
  text-align: center;
  padding: 40px 10px;
  color: var(--c-muted);
}
.sent-empty {
  text-align: center;
  padding: 24px 10px;
  color: var(--c-muted);
  font-style: italic;
}

/* dark */
html[data-theme="dark"] .sent-hero {
  background: linear-gradient(135deg, #2a1a1a, #2a261a 65%, #1a2a23);
  border-color: #3c2a2a;
}
html[data-theme="dark"] .sent-hero h1 { color: #ffb3c0; }
html[data-theme="dark"] .sent-hero .sent-sub { color: #bbb; }
html[data-theme="dark"] .sent-hero .sent-date {
  background: rgba(0,0,0,0.3);
  border-color: #3c2a2a;
  color: #ccc;
}
html[data-theme="dark"] .sent-trend {
  background: linear-gradient(135deg, #3a1f24, #3a3318);
  border-color: #5a3f3f;
  color: #ffc0c8;
}
html[data-theme="dark"] .sent-tag {
  background: rgba(120, 160, 220, 0.18);
  color: #95b3e0;
}

/* 輿情小幫手 brand badge in topbar */
.year-badge.sent-badge {
  background: linear-gradient(135deg, #ffd2d2, #ffe7c8);
  color: #c23044;
  border: 1px solid #f3b3b3;
}
html[data-theme="dark"] .year-badge.sent-badge {
  background: linear-gradient(135deg, #3a1f24, #3a3318);
  color: #ffb3c0;
  border-color: #5a3f3f;
}

/* ============================================================
   輿情小幫手 v2 — 300字 + KMT立場 + 新聞連結 + FB modal
   ============================================================ */

.sent-card-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--c-muted, #888);
  margin-left: 6px;
}
.sent-refresh-btn {
  background: linear-gradient(135deg, #fff4e6, #ffe7e7);
  border: 1px solid #f3b3b3;
  color: #b1304a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.sent-refresh-btn:hover { transform: translateY(-1px); background: linear-gradient(135deg, #ffe7d0, #ffd0d0); }
.sent-refresh-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.sent-source-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--c-border, #ddd);
  font-size: 11.5px;
  color: var(--c-muted);
  line-height: 1.5;
}

/* topic blocks */
.sent-vol-pill {
  background: rgba(60, 100, 200, 0.08);
  color: #345aa8;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}
.sent-block {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.02);
  border-radius: 8px;
  border-left: 3px solid var(--c-border, #d8d8d8);
}
.sent-block-label {
  font-size: 12px;
  color: var(--c-muted);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.sent-300 {
  margin: 0;
  line-height: 1.78;
  font-size: 13.5px;
  color: var(--c-text);
  text-align: justify;
}
.sent-block-stance {
  background: linear-gradient(135deg, #fffdf0, #fff5e8);
  border-left-color: #d6a35a;
}
.sent-stance {
  margin: 0;
  line-height: 1.75;
  font-size: 13.5px;
  color: var(--c-text);
}
.sent-news-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
  font-size: 13px;
}
.sent-news-list li { margin-bottom: 4px; }
.sent-news-list a {
  color: #2c5fb8;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.sent-news-list a:hover { border-bottom-color: currentColor; }
.sent-news-src {
  margin-left: 6px;
  font-size: 11px;
  color: var(--c-muted);
  background: rgba(0,0,0,0.04);
  padding: 1px 6px;
  border-radius: 4px;
}

.sent-topic-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.sent-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--c-border, #d8d8d8);
  background: var(--c-card, #fff);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.sent-btn:hover { transform: translateY(-1px); }
.sent-btn.primary {
  background: linear-gradient(135deg, #1877f2, #2c5fb8);
  border-color: #1877f2;
  color: #fff;
}
.sent-btn.primary:hover { background: linear-gradient(135deg, #1670e3, #244e9c); }
.sent-btn.ghost {
  background: transparent;
  color: var(--c-muted);
}

/* ── FB modal ── */
.fb-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.fb-modal.open { display: flex; }
.fb-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
}
.fb-modal-box {
  position: relative;
  background: var(--c-card, #fff);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.32);
  width: min(640px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fbModalIn 0.25s cubic-bezier(0.2,0.9,0.32,1.2);
}
@keyframes fbModalIn {
  from { transform: translateY(20px) scale(0.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.fb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border, #ddd);
  background: linear-gradient(135deg, #1877f2, #2c5fb8);
  color: #fff;
}
.fb-modal-head h3 { margin: 0; font-size: 16px; letter-spacing: 0.5px; }
.fb-modal-close {
  background: rgba(255,255,255,0.15);
  border: 0;
  color: #fff;
  font-size: 18px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}
.fb-modal-close:hover { background: rgba(255,255,255,0.3); }

.fb-modal-meta {
  padding: 8px 18px;
  background: rgba(0,0,0,0.02);
  font-size: 12px;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border, #eee);
}
.fb-meta-engine {
  background: rgba(60,100,200,0.08);
  color: #345aa8;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.fb-modal-text {
  flex: 1;
  border: 0;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.75;
  font-family: inherit;
  background: var(--c-card, #fff);
  color: var(--c-text);
  resize: vertical;
  min-height: 240px;
  outline: none;
}
.fb-modal-actions {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--c-border, #eee);
  background: rgba(0,0,0,0.02);
}
.fb-modal-actions .sent-btn { flex: 0 0 auto; }
.fb-modal-foot {
  margin: 0;
  padding: 8px 18px 14px;
  font-size: 11.5px;
  color: var(--c-muted);
  text-align: center;
  background: rgba(0,0,0,0.02);
  border-top: 1px dashed var(--c-border, #eee);
}

/* dark */
html[data-theme="dark"] .sent-block {
  background: rgba(255,255,255,0.04);
  border-left-color: #404857;
}
html[data-theme="dark"] .sent-block-stance {
  background: linear-gradient(135deg, #2a2517, #2f261a);
  border-left-color: #c89149;
}
html[data-theme="dark"] .sent-news-list a { color: #95c4ff; }
html[data-theme="dark"] .sent-vol-pill {
  background: rgba(120,160,220,0.18);
  color: #95b3e0;
}
html[data-theme="dark"] .fb-modal-text { background: #1a1f2c; color: #e3e6ed; }
html[data-theme="dark"] .fb-modal-meta,
html[data-theme="dark"] .fb-modal-actions,
html[data-theme="dark"] .fb-modal-foot { background: #161a25; }
html[data-theme="dark"] .sent-refresh-btn {
  background: linear-gradient(135deg, #3a2117, #3a1f24);
  border-color: #5a3f3f;
  color: #ffc0c8;
}

/* ============================================================
   FB popup — small floating window (no backdrop, background stays usable)
   ============================================================ */
.fb-popup {
  position: fixed;
  width: 380px;
  max-width: calc(100vw - 16px);
  max-height: 70vh;
  background: var(--c-card, #fff);
  border-radius: 12px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.18);
  border: 1px solid var(--c-border, #ddd);
  display: none;
  flex-direction: column;
  z-index: 9999;
  /* default: right side, mid-height */
  right: 24px;
  bottom: 24px;
  animation: fbPopIn 0.18s cubic-bezier(0.2,0.9,0.32,1.2);
}
.fb-popup.open { display: flex; }
.fb-popup.dragging { transition: none; cursor: grabbing; }
@keyframes fbPopIn {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.fb-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #1877f2, #2c5fb8);
  color: #fff;
  border-radius: 12px 12px 0 0;
  cursor: grab;
  user-select: none;
}
.fb-popup-head:active { cursor: grabbing; }
.fb-popup-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.65);
}
.fb-popup-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.4px;
  flex: 1;
}
.fb-popup-close {
  background: rgba(255,255,255,0.18);
  border: 0;
  color: #fff;
  font-size: 14px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fb-popup-close:hover { background: rgba(255,255,255,0.32); }

.fb-popup-meta {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--c-muted, #888);
  border-bottom: 1px solid var(--c-border, #eee);
  background: rgba(0,0,0,0.02);
}
.fb-popup-text {
  flex: 1;
  border: 0;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  font-family: inherit;
  background: var(--c-card, #fff);
  color: var(--c-text);
  resize: none;
  min-height: 140px;
  max-height: 40vh;
  outline: none;
}
.fb-popup-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--c-border, #eee);
  background: rgba(0,0,0,0.02);
}
.fb-popup-actions .sent-btn {
  padding: 5px 10px;
  font-size: 12px;
}
.fb-popup-foot {
  margin: 0;
  padding: 6px 12px 8px;
  font-size: 10.5px;
  color: var(--c-muted);
  text-align: center;
  border-top: 1px dashed var(--c-border, #eee);
}

/* dark */
html[data-theme="dark"] .fb-popup-text { background: #1a1f2c; color: #e3e6ed; }
html[data-theme="dark"] .fb-popup-meta,
html[data-theme="dark"] .fb-popup-actions,
html[data-theme="dark"] .fb-popup-foot { background: #161a25; }

/* Hide the old fb-modal scaffold styles (keep CSS small) */
.fb-modal { display: none !important; }

/* updated-at chip */
.sent-updated-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--c-muted);
  background: rgba(0,0,0,0.03);
  padding: 4px 10px;
  border-radius: 999px;
  margin-right: 6px;
}
.sent-updated-chip.is-fresh { color: #06813c; background: rgba(6, 129, 60, 0.08); }
.sent-updated-chip.is-stale { color: #b1304a; background: rgba(177, 48, 74, 0.08); }
html[data-theme="dark"] .sent-updated-chip { background: rgba(255,255,255,0.06); }

/* ── 熱搜 tag row + 推薦相關預算 ── */
.sent-hot-tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
  font-size: 12px;
  color: var(--c-muted);
}
.sent-hot-tag {
  background: linear-gradient(135deg, #fff7e8, #ffe7e0);
  border: 1px solid #f0c8a8;
  color: #b1304a;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.12s;
}
.sent-hot-tag:hover { transform: translateY(-1px); }

.sent-block-budget {
  background: linear-gradient(135deg, #f3f8ff, #f8fbff);
  border-left-color: #3c64b8;
}
.sent-budget-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sent-budget-list li {
  margin: 4px 0;
}
.sent-budget-link {
  display: grid;
  grid-template-columns: minmax(70px, auto) 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  background: var(--c-card, #fff);
  border: 1px solid var(--c-border, #e2e2e2);
  border-radius: 6px;
  text-decoration: none;
  color: var(--c-text);
  font-size: 12.5px;
  transition: border-color 0.15s, transform 0.12s;
}
.sent-budget-link:hover {
  border-color: #3c64b8;
  transform: translateX(2px);
  box-shadow: 0 2px 6px rgba(60, 100, 184, 0.12);
}
.sent-budget-min {
  font-weight: 600;
  color: #3c64b8;
  font-size: 11.5px;
}
.sent-budget-name {
  color: var(--c-text);
}
.sent-budget-amt {
  color: #c23044;
  font-weight: 600;
  font-size: 11.5px;
  white-space: nowrap;
}
.sent-budget-kw {
  background: rgba(60,100,200,0.1);
  color: #345aa8;
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

html[data-theme="dark"] .sent-block-budget {
  background: linear-gradient(135deg, #1a2438, #1f2a3d);
  border-left-color: #5a8fc2;
}
html[data-theme="dark"] .sent-budget-link {
  background: #161a25;
  border-color: #2c3340;
}
html[data-theme="dark"] .sent-budget-link:hover {
  border-color: #5a8fc2;
}
html[data-theme="dark"] .sent-budget-min { color: #95c4ff; }
html[data-theme="dark"] .sent-budget-amt { color: #ff9aa0; }
html[data-theme="dark"] .sent-hot-tag {
  background: linear-gradient(135deg, #3a2117, #3a1f24);
  border-color: #5a3f3f;
  color: #ffc0c8;
}

/* ── LLM key chip + popup ── */
.sent-llm-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--c-muted);
  background: rgba(0,0,0,0.03);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--c-border, #d8d8d8);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.sent-llm-chip:hover { transform: translateY(-1px); }
.sent-llm-chip.is-on {
  background: rgba(60, 100, 200, 0.12);
  color: #345aa8;
  border: 1px solid #345aa8;
  border-style: solid;
}
html[data-theme="dark"] .sent-llm-chip { background: rgba(255,255,255,0.06); }
html[data-theme="dark"] .sent-llm-chip.is-on {
  background: rgba(120,160,220,0.18);
  color: #95b3e0;
  border-color: #5a8fc2;
}

.llm-popup { width: 400px; }
.llm-popup .fb-popup-head { background: linear-gradient(135deg, #6e3cb8, #9a3cb8); }
.llm-popup code {
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
html[data-theme="dark"] .llm-popup code { background: rgba(255,255,255,0.08); }

/* v0.8.2 (2026-06-02): 委員會 picker (select + suffix 並排) */
.committee-picker {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.committee-picker select {
  flex: 0 1 240px;
  padding: 5px 8px;
  border: 1px solid var(--c-border);
  border-radius: 5px;
  font-size: 13px;
  background: #fff;
}
.committee-picker .committee-suffix {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--c-border);
  border-radius: 5px;
  font-size: 13px;
  color: var(--c-muted);
}
.committee-picker .committee-suffix::placeholder { color: #aaa; font-size: 11.5px; }
html[data-theme="dark"] .committee-picker select,
html[data-theme="dark"] .committee-picker .committee-suffix {
  background: #1a1f2c; color: #d4d8e0; border-color: #2c3340;
}

/* ============================================================
   Dataset supertabs — 最頂層分類（2026-06-02）
   115/114/116 各自有獨立 4 頁 + 已修好標記 + 資料 + 儀表板
   ============================================================ */
.dataset-supertabs {
  display: flex;
  gap: 0;
  background: linear-gradient(180deg, #1f2937, #111827);
  border-bottom: 2px solid #fbbf24;
  padding: 0 16px;
  height: 38px;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: thin;
}
.ds-supertab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 22px;
  height: 100%;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-right: 1px solid rgba(255,255,255,0.07);
  transition: background 0.15s, color 0.15s, transform 0.15s;
  position: relative;
}
.ds-supertab:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.ds-supertab.active {
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  color: #1f2937;
  font-weight: 700;
}
.ds-supertab.active::after {
  /* 連接到下面 topbar 的視覺指示 */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: #fff;
}
.ds-supertab-year {
  font-size: 14.5px;
  font-weight: 800;
}
.ds-supertab-stage {
  font-size: 12px;
  opacity: 0.85;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
}
.ds-supertab.active .ds-supertab-stage {
  background: rgba(0,0,0,0.12);
}

/* 字級 / 主題 / 視覺 / 切換小幫手 — 移上來與年度 supertab 同排，靠右 (2026-06-05 用戶) */
.topstrip-tools {
  margin-left: auto;          /* 推到 supertab 條最右 */
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto; padding-left: 14px;
}
/* supertab 條恆為深色，工具列改淺色字 + 半透明底（不分原色/夜色）*/
.dataset-supertabs .font-zoom,
.dataset-supertabs .ui-toggles {
  margin-left: 0; background: rgba(255,255,255,0.10);
}
.dataset-supertabs .fz-btn,
.dataset-supertabs .ui-tg-btn { color: #e5e7eb; }
.dataset-supertabs .fz-level { color: #cbd5e1; }
.dataset-supertabs .fz-btn:hover,
.dataset-supertabs .ui-tg-btn:hover { background: rgba(255,255,255,0.18); }
.dataset-supertabs .fz-btn:active,
.dataset-supertabs .ui-tg-btn:active { background: rgba(255,255,255,0.28); }

/* dark mode — supertabs 本身已是 dark style，調 subtle 差異 */
html[data-theme="dark"] .dataset-supertabs {
  background: linear-gradient(180deg, #0f1419, #060709);
  border-bottom-color: #d97706;
}
html[data-theme="dark"] .ds-supertab { color: #a1a8b3; }
html[data-theme="dark"] .ds-supertab.active {
  background: linear-gradient(180deg, #d97706, #b45309);
  color: #fef3c7;
}

/* 隱藏舊的 .dataset-tabs (在 brand 內的小尺寸版本) — 若還有殘留 */
.brand .dataset-tabs { display: none; }

/* ============================================================================
   夜色 v2 — 對齊 reference (helpful-macaron) slate + cyan 配色 / 按鈕設計
   (2026-06-02)
   目標：① 統一色票到 reference 的 slate-900/800/700 + cyan 強調
        ② 修掉所有「淺色洩漏到夜色」的面板 / 卡片 / 徽章
        ③ 鐵則：任何 active / selected / highlighted 狀態都「看得清 + 點得開」
           —— 高亮一律 = 實心 cyan + 深色字（高對比）或 半透明 cyan tint + cyan 亮字 + cyan 邊
           —— 嚴禁 cyan 底 + 白字（過去 .lv-chip.is-active 的 bug = 高亮點不開）
   此區塊放在檔尾 → source order 最後，同特異度即覆蓋舊夜色規則。
   ============================================================================ */
html[data-theme="dark"] {
  /* —— reference slate + cyan 主色票 —— */
  --c-bg: #0f172a;            /* slate-900  頁底 */
  --c-panel: #1e293b;         /* slate-800  卡片 / 面板 */
  --c-panel-2: #243044;       /* slate-750  巢狀 / hover surface */
  --c-text: #e2e8f0;          /* slate-200  主文字 */
  --c-muted: #94a3b8;         /* slate-400  次文字 */
  --c-dim: #cbd5e1;           /* slate-300 */
  --c-border: #334155;        /* slate-700  邊框 */
  --c-border-soft: rgba(148,163,184,0.18);
  --c-accent: #22d3ee;        /* cyan-400  主強調 */
  --c-accent-bright: #67e8f9; /* cyan-300  亮字 / glow */
  --c-accent-deep: #06b6d4;   /* cyan-500 */
  --c-accent-dark: #0891b2;
  --c-on-accent: #08141c;     /* 放在 cyan 上的深色字（保證對比）*/
  --c-ok: #34d399;            /* emerald-400 */
  --c-warn: #fbbf24;          /* amber-400 */
  --c-danger: #fb7185;        /* rose-400 */
  --c-row-alt: #1a2436;
  /* —— 狀態徽章 token：夜色改半透明 tint + 亮字（取代淺色實心）—— */
  --st-green-bg: rgba(52,211,153,0.14);  --st-green-fg: #6ee7b7;
  --st-amber-bg: rgba(251,191,36,0.14);  --st-amber-fg: #fcd34d;
  --st-red-bg:   rgba(251,113,133,0.15); --st-red-fg:   #fda4af;  --st-red-bd: rgba(251,113,133,0.40);
  /* —— glow / shadow（reference card-shadow）—— */
  --glow-cyan: 0 0 0 1px rgba(34,211,238,0.40), 0 4px 18px rgba(34,211,238,0.18);
  --shadow-card: 0 4px 24px -8px rgba(0,0,0,0.55);
}
html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% 0%, rgba(34,211,238,0.05) 0%, transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(34,211,238,0.03) 0%, transparent 45%),
    var(--c-bg) !important;
}

/* ── 共通互動狀態鐵則（解「高亮點不開」）─────────────────────────────────
   任何 pill / chip / tab / 篩選鈕的 .active / .is-active：
   實心 cyan 底 + 深色字 + cyan glow，看得清也點得開。                       */
html[data-theme="dark"] .lv-chip,
html[data-theme="dark"] .tg-chip,
html[data-theme="dark"] .filter-chip,
html[data-theme="dark"] .seg-btn {
  background: #1b2740;
  border: 1px solid var(--c-border);
  color: var(--c-dim);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
html[data-theme="dark"] .lv-chip:hover,
html[data-theme="dark"] .tg-chip:hover,
html[data-theme="dark"] .filter-chip:hover,
html[data-theme="dark"] .seg-btn:hover {
  background: var(--c-panel-2);
  border-color: rgba(34,211,238,0.45);
  color: var(--c-accent-bright);
}
html[data-theme="dark"] .lv-chip.is-active,
html[data-theme="dark"] .tg-chip:has(input:checked),
html[data-theme="dark"] .filter-chip.is-active,
html[data-theme="dark"] .seg-btn.is-active {
  background: var(--c-accent);
  color: var(--c-on-accent) !important;
  border-color: var(--c-accent-bright);
  font-weight: 700;
  box-shadow: var(--glow-cyan);
}
html[data-theme="dark"] .lv-chip.is-active:hover {
  background: var(--c-accent-bright);
  color: var(--c-on-accent);
}

/* navlink active — cyan box 維持，但鎖定對比 */
html[data-theme="dark"] .navlink { color: var(--c-dim); }
html[data-theme="dark"] .navlink:hover { background: #1b2740; color: var(--c-accent-bright); }
html[data-theme="dark"] .navlink.active {
  background: rgba(34,211,238,0.14);
  color: var(--c-accent-bright);
  box-shadow: inset 0 0 0 1px rgba(34,211,238,0.55);
}
html[data-theme="dark"] .navlink.active:hover { background: rgba(34,211,238,0.22); color: #a5f3fc; }

/* dataset supertab — 把舊的橙色換成 cyan（off-palette 修正）*/
html[data-theme="dark"] .dataset-supertabs {
  background: linear-gradient(180deg, #111c2e, #0b1220);
  border-bottom: 1px solid rgba(34,211,238,0.30);
}
html[data-theme="dark"] .ds-supertab { color: var(--c-muted); }
html[data-theme="dark"] .ds-supertab:hover { color: var(--c-accent-bright); background: rgba(34,211,238,0.06); }
html[data-theme="dark"] .ds-supertab.active {
  background: linear-gradient(180deg, rgba(34,211,238,0.18), rgba(34,211,238,0.04));
  color: var(--c-accent-bright);
}
html[data-theme="dark"] .ds-supertab.active::after { background: var(--c-accent) !important; }
html[data-theme="dark"] .ds-supertab.active .ds-supertab-stage {
  background: var(--c-accent); color: var(--c-on-accent);
}
/* dataset-tabs segmented（brand 內若顯示）*/
html[data-theme="dark"] .ds-tab.active {
  background: var(--c-accent); color: var(--c-on-accent);
  box-shadow: 0 1px 6px rgba(34,211,238,0.4);
}

/* topbar / 字級&主題 toolbar */
html[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, #131f33 0%, #0d1726 100%);
  border-bottom: 1px solid rgba(34,211,238,0.16);
  box-shadow: 0 1px 0 rgba(34,211,238,0.12);
}
html[data-theme="dark"] .ui-toggles,
html[data-theme="dark"] .font-zoom { background: rgba(34,211,238,0.06); border: 1px solid var(--c-border-soft); }
html[data-theme="dark"] .ui-tg-btn:hover,
html[data-theme="dark"] .fz-btn:hover { background: rgba(34,211,238,0.16); color: var(--c-accent-bright); }
html[data-theme="dark"] .stats-badge { background: #1b2740; color: var(--c-muted); }
html[data-theme="dark"] .stats-badge.has-pending {
  background: var(--st-red-bg); color: var(--st-red-fg); border: 1px solid var(--st-red-bd);
}
html[data-theme="dark"] .year-badge { background: rgba(34,211,238,0.14); color: var(--c-accent-bright); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #16202f; color: var(--c-text); border: 1px solid var(--c-border);
}
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: var(--c-accent); outline: none; box-shadow: 0 0 0 2px rgba(34,211,238,0.18);
}
html[data-theme="dark"] .count-badge { background: #1b2740; color: var(--c-dim); border: 1px solid var(--c-border); }

/* ── 儀表板：KPI 卡 / 區塊 / 長條圖 / 對帳表（淺色洩漏修正）──────────── */
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .dash-section {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-card);
}
html[data-theme="dark"] .kpi-card:hover {
  box-shadow: 0 6px 22px -6px rgba(0,0,0,0.6), 0 0 0 1px rgba(34,211,238,0.25);
}
html[data-theme="dark"] .kpi-card .kpi-label,
html[data-theme="dark"] .kpi-card .kpi-sub,
html[data-theme="dark"] .dash-section .ds-desc { color: var(--c-muted); }
html[data-theme="dark"] .dash-section .ds-title { color: var(--c-text); }
html[data-theme="dark"] .kpi-gov  .kpi-amt { color: #7dd3fc; }
html[data-theme="dark"] .kpi-fund .kpi-amt { color: var(--c-warn); }
html[data-theme="dark"] .kpi-min  .kpi-amt { color: var(--c-ok); }
html[data-theme="dark"] .kpi-items .kpi-amt { color: var(--c-danger); }
html[data-theme="dark"] .kpi-card .kpi-tag { background: rgba(34,211,238,0.12); color: var(--c-accent-bright); }
html[data-theme="dark"] .bc-bar-wrap { background: #16202f; border: 1px solid var(--c-border-soft); }
html[data-theme="dark"] .bc-bar { background: linear-gradient(90deg, var(--c-accent-deep), var(--c-accent)); }
html[data-theme="dark"] .bc-amt { color: var(--c-dim); }
html[data-theme="dark"] .reconcile-table { background: var(--c-panel); }
html[data-theme="dark"] .reconcile-table th,
html[data-theme="dark"] th {
  background: #16202f !important; color: var(--c-dim); border-color: var(--c-border) !important;
}
html[data-theme="dark"] .reconcile-table td,
html[data-theme="dark"] .rc-cell { color: var(--c-text); border-color: var(--c-border-soft); }
html[data-theme="dark"] .rc-cell-ok   { color: var(--c-ok); }
html[data-theme="dark"] .rc-cell-warn { color: var(--c-warn); }
html[data-theme="dark"] .rc-cell-bad  { color: var(--c-danger); background: rgba(251,113,133,0.10); }

/* ── 後台（通用邏輯狀態）：表格 / 列 / 徽章（最多洩漏處）──────────────── */
html[data-theme="dark"] .reconcile-table tr,
html[data-theme="dark"] table.reconcile-table tr { background: transparent; }
html[data-theme="dark"] .td-group {
  background: var(--c-panel); border: 1px solid var(--c-border);
}
html[data-theme="dark"] .td-group[open] { border-color: rgba(34,211,238,0.35); }
html[data-theme="dark"] .td-group > summary { background: #16202f; color: var(--c-text); }
html[data-theme="dark"] .status-fold { background: var(--c-panel); border-color: var(--c-border); }
html[data-theme="dark"] .td-row { background: transparent; color: var(--c-text); border-color: var(--c-border-soft); }
html[data-theme="dark"] .td-row:hover { background: #1b2740; }
html[data-theme="dark"] .td-row.td-likely_missing {
  background: rgba(251,113,133,0.10); border-left: 3px solid var(--c-danger);
}
html[data-theme="dark"] .td-row.td-likely_missing .td-name { color: var(--st-red-fg); }
html[data-theme="dark"] .td-bar { background: #16202f; }
html[data-theme="dark"] .src-st.imported   { background: var(--st-green-bg); color: var(--st-green-fg); }
html[data-theme="dark"] .src-st.downloaded { background: var(--st-amber-bg); color: var(--st-amber-fg); }
html[data-theme="dark"] .src-st.none       { background: rgba(148,163,184,0.12); color: var(--c-muted); }
html[data-theme="dark"] .cnt.imp  { background: var(--st-green-bg); color: var(--st-green-fg); }
html[data-theme="dark"] .cnt.dl   { background: var(--st-amber-bg); color: var(--st-amber-fg); }
html[data-theme="dark"] .cnt.lm   { background: var(--st-red-bg); color: var(--st-red-fg); border-color: var(--st-red-bd); }
html[data-theme="dark"] .cnt.zero { opacity: 0.5; }
html[data-theme="dark"] .ag-chip.imported   { background: var(--st-green-bg); color: var(--st-green-fg); }
html[data-theme="dark"] .ag-chip.downloaded { background: var(--st-amber-bg); color: var(--st-amber-fg); }
html[data-theme="dark"] .ag-chip.missing    { background: var(--st-red-bg); color: var(--st-red-fg); border-color: var(--st-red-bd); }

/* ── 資料庫 / explorer：總覽 pill / fund 徽章 / 提案預覽 / legend ────────── */
html[data-theme="dark"] .dbov-pill-official { background: var(--st-amber-bg); color: var(--st-amber-fg); }
html[data-theme="dark"] .dbov-pill-our      { background: rgba(34,211,238,0.14); color: var(--c-accent-bright); }
html[data-theme="dark"] .dbov-pill-rank     { background: rgba(167,139,250,0.16); color: #c4b5fd; }
/* fund_type 徽章：淺色實心 → 半透明 tint + 亮字（夜色一致）*/
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-ent,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-ent {
  background: rgba(96,165,250,0.18); color: #93c5fd; border-color: rgba(96,165,250,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-ops,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-ops {
  background: rgba(52,211,153,0.18); color: #6ee7b7; border-color: rgba(52,211,153,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-sip,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-sip {
  background: rgba(251,191,36,0.18); color: #fcd34d; border-color: rgba(251,191,36,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-capital,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-capital {
  background: rgba(251,146,60,0.18); color: #fdba74; border-color: rgba(251,146,60,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-debt,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-debt {
  background: rgba(248,113,113,0.18); color: #fca5a5; border-color: rgba(248,113,113,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-trust,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-trust {
  background: rgba(167,139,250,0.18); color: #c4b5fd; border-color: rgba(167,139,250,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-admin,
html[data-theme="dark"] .exp-tree .badge-fund.fund-type-found,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-admin,
html[data-theme="dark"] .exp-tree .tn.is-fund-top .badge-fund.fund-type-found {
  background: rgba(148,163,184,0.18); color: #cbd5e1; border-color: rgba(148,163,184,0.5);
}
html[data-theme="dark"] .exp-tree .badge-fund {
  background: rgba(251,191,36,0.16); color: var(--c-warn); border-color: rgba(251,191,36,0.5);
}
/* fund-top header 列：刺眼螢光綠 → 深 slate + cyan 左槓（夜色 reference 風）*/
html[data-theme="dark"] .exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row {
  background: linear-gradient(90deg, rgba(34,211,238,0.16) 0%, rgba(34,211,238,0.04) 60%, transparent 100%);
  border-left: 4px solid var(--c-accent);
  color: var(--c-text);
}
html[data-theme="dark"] .exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-name { color: var(--c-accent-bright); }
html[data-theme="dark"] .exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-amt,
html[data-theme="dark"] .exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row .tn-code-prefix { color: var(--c-dim); }
html[data-theme="dark"] .exp-tree .tn.is-fund-top > .tn-row-wrap > .tn-row:hover {
  background: linear-gradient(90deg, rgba(34,211,238,0.24) 0%, rgba(34,211,238,0.06) 60%, transparent 100%);
}
html[data-theme="dark"] .exp-tree .tn.is-fund-row > .tn-row-wrap > .tn-row {
  background: linear-gradient(90deg, rgba(251,191,36,0.10) 0%, transparent 70%);
  border-left: 3px solid rgba(251,191,36,0.6);
}
html[data-theme="dark"] .is-fund-row .tn-badge.badge-目         { background: rgba(251,146,60,0.20); color: #fdba74; }
html[data-theme="dark"] .is-fund-row .tn-badge.badge-分支計畫   { background: rgba(45,212,191,0.18); color: #5eead4; }
html[data-theme="dark"] .is-fund-row .tn-badge.badge-用途別大類 { background: rgba(167,139,250,0.18); color: #c4b5fd; }
html[data-theme="dark"] .is-fund-row .tn-badge.badge-用途別,
html[data-theme="dark"] .is-fund-row .tn-badge.badge-用途別細項 { background: rgba(148,163,184,0.16); color: var(--c-dim); }
/* 選取的 tree row — 明確 cyan 高亮但點得開 */
html[data-theme="dark"] .tn-row-wrap.is-selected,
html[data-theme="dark"] .tn-row-wrap.selected,
html[data-theme="dark"] .tn.is-selected > .tn-row-wrap {
  background: rgba(34,211,238,0.12) !important;
  box-shadow: inset 3px 0 0 var(--c-accent);
}
/* 提案預覽 / legend 等殘留淺底 */
html[data-theme="dark"] .ed-proposal-preview {
  background: #16202f; border: 1px solid var(--c-border); color: var(--c-text);
}
/* 2026-06-17：.pp-mini 文字色 #333 / b #555 是 light 寫死，無夜色 override → 深灰字疊深底幾乎看不見
   （用戶「網頁版還是有」截圖底部「提案表會自動填」整段暗到讀不出）。補亮字 + 金額琥珀金。*/
html[data-theme="dark"] .pp-mini { color: #cbd5e1; }
html[data-theme="dark"] .pp-mini b { color: #94a3b8; }
html[data-theme="dark"] .pp-mini .pf-amt { color: #fcd34d; font-weight: 600; }
html[data-theme="dark"] .exp-fund-type-legend {
  background: var(--c-panel); border-color: var(--c-border); color: var(--c-muted);
}
html[data-theme="dark"] .exp-year { background: rgba(34,211,238,0.14); color: var(--c-accent-bright); }

/* ── 作業頁：提案籃 / 全域 basket（淺底修正）──────────────────────────── */
html[data-theme="dark"] .basket-global {
  background: var(--c-panel); border: 1px solid var(--c-border); box-shadow: var(--shadow-card);
}
html[data-theme="dark"] .basket-global .bg-row span { color: var(--c-muted); }
html[data-theme="dark"] .basket-global .bg-row input { background: #16202f; color: var(--c-text); border-color: var(--c-border); }

/* ── 主要按鈕（提案 / 動作）統一 reference cyan 風 ──────────────────────── */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] button.primary,
html[data-theme="dark"] .add-btn,
html[data-theme="dark"] .pdf-btn {
  background: rgba(34,211,238,0.14);
  color: var(--c-accent-bright);
  border: 1px solid rgba(34,211,238,0.5);
}
html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] button.primary:hover,
html[data-theme="dark"] .add-btn:hover,
html[data-theme="dark"] .pdf-btn:hover {
  background: var(--c-accent); color: var(--c-on-accent); box-shadow: var(--glow-cyan);
}

/* 內文金額 hl-amt：拿掉色塊（過去整段被高亮成 chip 不利閱讀）→ 只留亮字。
   .pb-rich = popup 版說明（popup.js 原本 inline #c0392b 暗紅低對比，改用此 class 統一琥珀金）*/
html[data-theme="dark"] .ed-rich .hl-amt,
html[data-theme="dark"] .pb-rich .hl-amt {
  background: transparent !important; padding: 0 !important; border-radius: 0;
  color: #fcd34d; font-weight: 600;
}
/* explorer 大標部會名：夜色被高特異度淺色規則蓋成近黑 → 補回 cyan 亮字（這個不明顯 fix）*/
html[data-theme="dark"] .explorer-head h2.exp-title .exp-ministry {
  color: var(--c-accent-bright);
  text-shadow: 0 0 10px rgba(34,211,238,0.35);
}
html[data-theme="dark"] .explorer-head h2.exp-title { color: #f1f5f9; }

/* toast / 提示 — reference 風（深底 + cyan 邊 + cyan 亮字）*/
html[data-theme="dark"] .toast,
html[data-theme="dark"] .ed-toast {
  background: var(--c-bg); border: 1px solid var(--c-accent); color: var(--c-accent-bright);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
/* —— 夜色 v2 補遺：剩餘淺底洩漏 —— */
html[data-theme="dark"] {
  --st-gray-bg: rgba(148,163,184,0.14); --st-gray-fg: #94a3b8;
}
html[data-theme="dark"] .rc-cell {
  background: #16202f; border: 1px solid var(--c-border);
}
html[data-theme="dark"] .rc-lab,
html[data-theme="dark"] .rc-sub { color: var(--c-muted); }
html[data-theme="dark"] .rc-val.rc-off { color: var(--c-dim); }
html[data-theme="dark"] .rc-val.rc-our { color: #7dd3fc; }
html[data-theme="dark"] .rc-val.rc-under { color: var(--c-danger); }
html[data-theme="dark"] .rc-val.rc-over  { color: var(--c-warn); }
html[data-theme="dark"] .cnt.mu { background: var(--st-gray-bg); color: var(--st-gray-fg); }
html[data-theme="dark"] #stats-badge.has-pending {
  background: var(--st-red-bg); color: var(--st-red-fg); border-color: var(--st-red-bd);
}
html[data-theme="dark"] #stats-badge.has-pending:hover { background: rgba(251,113,133,0.25); }
/* 參考表 / 預算書 / 基金表 striping → 夜色 */
html[data-theme="dark"] .tbl-ref tbody tr:nth-child(odd),
html[data-theme="dark"] .tbl-funds tbody tr:nth-child(odd) { background: var(--c-row-alt); }
html[data-theme="dark"] .tbl-ref tbody tr:hover,
html[data-theme="dark"] .tbl-funds tbody tr:hover,
html[data-theme="dark"] .tbl-books tbody tr:hover { background: #1b2740; }
html[data-theme="dark"] .tbl-ref th,
html[data-theme="dark"] .tbl-funds th,
html[data-theme="dark"] .tbl-books th { background: #16202f; color: var(--c-dim); }
html[data-theme="dark"] .tbl-ref td,
html[data-theme="dark"] .tbl-funds td,
html[data-theme="dark"] .tbl-books td { color: var(--c-text); border-color: var(--c-border-soft); }
/* 提案表 .pp-sheet = 模擬列印「紙張」，夜色下仍須維持白底黑字。
   問題：html[data-theme="dark"] input 規則把 .pp-num / .pp-proposer-input 染成 #1a1f2c
   深底 → 數字像被黑框蓋住（用戶截圖「黑底」）。這裡強制紙張內所有欄位回白底黑字。 */
html[data-theme="dark"] .pp-sheet { background: #fff !important; color: #000 !important; }
html[data-theme="dark"] .pp-sheet .pp-num,
html[data-theme="dark"] .pp-sheet .pp-proposer-input {
  background: transparent !important; color: #000 !important;
  border-color: #999 !important;
}
html[data-theme="dark"] .pp-sheet .pp-reason {
  background: #fff !important; color: #000 !important; border-color: #ccc !important;
}
html[data-theme="dark"] .pp-sheet .pp-num::placeholder,
html[data-theme="dark"] .pp-sheet .pp-proposer-input::placeholder,
html[data-theme="dark"] .pp-sheet .pp-reason::placeholder { color: #999 !important; }
html[data-theme="dark"] .pp-sheet .pp-num:focus,
html[data-theme="dark"] .pp-sheet .pp-proposer-input:focus { background: #f7fbff !important; }
html[data-theme="dark"] .pp-sheet .pp-reason:focus { background: #fbfdff !important; }
/* 夜色 v2 end ============================================================== */

/* ════════════════════════════════════════════════════════════════════════
   ⭐ 我的收藏（collections.js）— 2026-06-02
   star 按鈕 / 彈出選單 / 作業頁面板 / toast。用主題變數，淺/夜色自動套。
   ════════════════════════════════════════════════════════════════════════ */

/* —— detail panel 內「⭐ 加到我的收藏」按鈕（緊接 .ed-cut 下方）—— */
.bpc-star {
  display: block; width: 100%; margin-top: 8px;
  background: transparent; color: #b45309;
  border: 1px solid #f59e0b; border-radius: 8px;
  padding: 9px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.bpc-star:hover { background: rgba(245,158,11,0.12); }
html[data-theme="dark"] .bpc-star {
  color: #fcd34d; border-color: rgba(252,211,77,0.55); background: transparent;
}
html[data-theme="dark"] .bpc-star:hover { background: rgba(252,211,77,0.14); }

/* —— 彈出選單：選 / 新增分類 —— */
.bpc-picker {
  position: absolute; z-index: 9999; width: 240px;
  background: var(--c-panel); border: 1px solid var(--c-border);
  border-radius: 10px; box-shadow: 0 10px 32px rgba(0,0,0,0.22);
  padding: 8px; font-size: 13px;
}
html[data-theme="dark"] .bpc-picker {
  border-color: var(--c-accent); box-shadow: 0 10px 32px rgba(0,0,0,0.6);
}
.bpc-picker-head { font-weight: 700; padding: 4px 6px 8px; color: var(--c-text); }
.bpc-pick-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.bpc-pick-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: none; border-radius: 6px;
  padding: 8px 8px; color: var(--c-text); font-size: 13px;
}
.bpc-pick-row:hover:not(:disabled) { background: var(--c-row-alt, rgba(0,0,0,0.05)); }
.bpc-pick-row.has { color: var(--c-muted); cursor: default; }
.bpc-pick-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpc-pick-cnt { color: var(--c-muted); font-size: 11px; white-space: nowrap; }
.bpc-pick-empty, .bpc-pick-max { padding: 10px 8px; color: var(--c-muted); font-size: 12px; }
.bpc-pick-new { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--c-border); }
.bpc-new-input {
  flex: 1; min-width: 0; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 6px 8px; font-size: 13px; background: var(--c-panel); color: var(--c-text);
}
.bpc-new-btn {
  white-space: nowrap; background: var(--c-accent); color: #fff; border: none;
  border-radius: 6px; padding: 6px 8px; font-size: 12px; cursor: pointer;
}
.bpc-new-btn:hover { background: var(--c-accent-dark); }

/* —— 作業頁左側「我的收藏」面板 —— */
.ws-collections { font-size: 13px; }
.bpc-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.bpc-panel-head h2 { font-size: 17px; margin: 0; }
.bpc-total {
  display: inline-block; min-width: 20px; text-align: center;
  background: #f59e0b; color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 12px; font-weight: 700; margin-left: 4px;
}
.btn-mini { padding: 5px 9px; font-size: 12px; }
.bpc-new-cat-row { display: flex; gap: 6px; margin-bottom: 10px; }
.bpc-new-cat-input {
  flex: 1; min-width: 0; border: 1px solid var(--c-border); border-radius: 6px;
  padding: 6px 8px; font-size: 13px; background: var(--c-panel); color: var(--c-text);
}
.bpc-cats { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 200px); overflow: auto; }
.bpc-empty { color: var(--c-muted); font-size: 13px; line-height: 1.7; padding: 18px 8px; text-align: center; }
.bpc-cat { border: 1px solid var(--c-border); border-radius: 10px; overflow: hidden; background: var(--c-panel); }
.bpc-cat-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--c-row-alt, rgba(0,0,0,0.03)); border-bottom: 1px solid var(--c-border);
}
.bpc-cat-name { font-weight: 700; cursor: pointer; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpc-cat-name:hover { text-decoration: underline dotted; }
.bpc-cat-name-edit { flex: 1; min-width: 0; border: 1px solid var(--c-accent); border-radius: 5px; padding: 4px 6px; font-size: 13px; font-weight: 700; background: var(--c-panel); color: var(--c-text); }
.bpc-cat-cnt {
  background: var(--c-accent); color: #fff; border-radius: 9px;
  padding: 0 7px; font-size: 11px; font-weight: 700; min-width: 18px; text-align: center;
}
.bpc-cat-del { background: transparent; border: none; color: var(--c-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.bpc-cat-del:hover { background: rgba(239,68,68,0.15); color: var(--c-danger, #ef4444); }
.bpc-items { list-style: none; margin: 0; padding: 0; }
.bpc-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--c-border); }
.bpc-item:last-child { border-bottom: none; }
.bpc-item:hover { background: var(--c-row-alt, rgba(0,0,0,0.03)); }
.bpc-item-info { flex: 1; min-width: 0; }
.bpc-item-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bpc-item-meta { color: var(--c-muted); font-size: 11px; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1px; }
.bpc-item-meta b { color: var(--c-text); font-variant-numeric: tabular-nums; }
.bpc-item-empty { padding: 10px; color: var(--c-muted); font-size: 12px; font-style: italic; }
.bpc-item-acts { display: flex; gap: 2px; flex-shrink: 0; }
.bpc-item-acts button {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 4px 6px; font-size: 12px; cursor: pointer; color: var(--c-text); white-space: nowrap;
}
.bpc-act-note:hover { background: rgba(245,158,11,0.18); }
.bpc-act-note.has { color: #d97706; }
.bpc-act-jump:hover { background: rgba(59,130,246,0.15); }
.bpc-act-basket:hover { background: rgba(16,185,129,0.18); }
.bpc-act-rm:hover { background: rgba(239,68,68,0.15); color: var(--c-danger, #ef4444); }

/* —— 收藏項目「備註」（綁金鑰）—— */
.bpc-note-box { flex-basis: 100%; margin-top: 2px; }
.bpc-note-ta {
  width: 100%; box-sizing: border-box; min-height: 52px; resize: vertical;
  padding: 7px 9px; border: 1px solid var(--c-border); border-radius: 7px;
  background: var(--c-panel, #fff); color: var(--c-text);
  font-size: 12.5px; line-height: 1.5; font-family: inherit;
}
.bpc-note-ta:focus { outline: none; border-color: var(--c-accent, #f59e0b); }
.bpc-note-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; }
.bpc-note-hint { color: var(--c-muted); font-size: 11px; }
.bpc-note-preview {
  flex-basis: 100%; margin-top: 2px; padding: 6px 9px;
  background: rgba(245,158,11,0.08); border-left: 3px solid #f59e0b; border-radius: 0 6px 6px 0;
  color: var(--c-text); font-size: 12px; line-height: 1.5; white-space: pre-wrap;
  cursor: pointer; word-break: break-word;
}
.bpc-note-preview:hover { background: rgba(245,158,11,0.14); }
html[data-theme="dark"] .bpc-note-ta { background: #0d1422; }

/* —— toast —— */
.bpc-toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10000;
}
.bpc-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
html[data-theme="dark"] .bpc-toast { background: var(--c-bg); border: 1px solid var(--c-accent); color: var(--c-accent-bright); }

/* ── AI 案由佐證註解框（質詢小幫手）──────────────── */
.ai-note {
  margin: 6px 0 4px;
  padding: 8px 10px;
  background: #f4f8ff;
  border: 1px solid #cfe0ff;
  border-left: 3px solid #4a86ff;
  border-radius: 6px;
  font-size: 12px;
  color: #33415c;
}
.ai-note-local {
  display: inline-block;
  margin-bottom: 7px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(34, 211, 238, .14);
  color: #0e7490;
  border: 1px solid rgba(34, 211, 238, .45);
}
html[data-theme="dark"] .ai-note-local {
  background: rgba(56, 225, 255, .16);
  color: #7fe3ff;
  border-color: rgba(56, 225, 255, .5);
}
.ai-note-h { font-weight: 600; color: #1d4ed8; margin-bottom: 4px; }
.ai-note-list { margin: 0; padding-left: 16px; }
.ai-note-list li { margin: 2px 0; line-height: 1.5; }
.ai-note-id { color: #64748b; margin-left: 6px; }
.ai-note-sc { color: #94a3b8; margin-left: 6px; font-size: 11px; }
/* AI 生成中：案由欄載入 overlay（小圈圈 + 即時狀態 + 取消）*/
.ai-status-overlay {
  position: absolute; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.80); border-radius: 4px;
}
.ai-status-box {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: #fff;
  border: 1px solid #cfe0ff; border-radius: 999px;
  box-shadow: 0 3px 14px rgba(37,99,235,0.18);
  font-size: 13px; color: #1d4ed8; max-width: 92%;
}
.ai-spinner {
  width: 16px; height: 16px; flex-shrink: 0;
  border: 2px solid #d6e4ff; border-top-color: #2563eb;
  border-radius: 50%; animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-status-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-status-cancel {
  flex-shrink: 0; border: 1px solid #fca5a5; background: #fff; color: #b91c1c;
  border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.ai-status-cancel:hover { background: #fef2f2; }
.ai-note-empty { color: #64748b; font-size: 12px; line-height: 1.55; }
/* 🎛 R-P25 刪減切入方向備選面板（寫作前先選方向） */
.ai-pick-panel {
  margin: 6px 0 4px; padding: 10px 12px;
  background: #f6f9ff; border: 1px solid #cfe0ff; border-radius: 8px;
}
.ai-pick-h { font-size: 12.5px; font-weight: 700; color: #1d4ed8; margin-bottom: 2px; }
.ai-pick-note { font-size: 11px; color: #64748b; margin-bottom: 8px; }
.ai-pick-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-pick-date {
  display: inline-block; margin-right: 6px; font-size: 10.5px; font-weight: 700;
  color: #475569; background: #eef2f7; border-radius: 4px; padding: 1px 5px;
  white-space: nowrap;
}
.ai-pick-src { font-size: 11px; color: #94a3b8; }
.ai-pick-opt {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  padding: 7px 10px; margin-bottom: 6px; cursor: pointer; font-family: inherit;
  background: #fff; border: 1px solid #dbe6ff; border-radius: 6px;
}
.ai-pick-opt:hover { border-color: #2563eb; background: #eef4ff; }
.ai-pick-kind {
  flex-shrink: 0; font-size: 11px; font-weight: 700; color: #1d4ed8;
  background: #e3edff; border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.ai-pick-why { font-size: 12px; color: #334155; line-height: 1.5; }
.ai-pick-foot { display: flex; gap: 8px; margin-top: 2px; }
.ai-pick-auto, .ai-pick-cancel {
  border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.ai-pick-auto { border: 1px solid #cfe0ff; background: #fff; color: #1d4ed8; }
.ai-pick-auto:hover { background: #eef4ff; }
.ai-pick-cancel { border: 1px solid #fca5a5; background: #fff; color: #b91c1c; }
.ai-pick-cancel:hover { background: #fef2f2; }
html[data-theme="dark"] .ai-pick-panel { background: rgba(74,134,255,0.08); border-color: rgba(99,140,255,0.35); }
html[data-theme="dark"] .ai-pick-h { color: #93c5fd; }
html[data-theme="dark"] .ai-pick-opt { background: #16202f; border-color: rgba(99,140,255,0.3); }
html[data-theme="dark"] .ai-pick-opt:hover { background: rgba(74,134,255,0.15); border-color: #60a5fa; }
html[data-theme="dark"] .ai-pick-kind { background: rgba(74,134,255,0.2); color: #93c5fd; }
html[data-theme="dark"] .ai-pick-why { color: var(--c-dim); }
html[data-theme="dark"] .ai-pick-note { color: #64748b; }
html[data-theme="dark"] .ai-pick-date { background: rgba(148,163,184,0.15); color: #94a3b8; }
html[data-theme="dark"] .ai-pick-src { color: #5b6b82; }
html[data-theme="dark"] .ai-pick-auto { background: #16202f; color: #93c5fd; border-color: rgba(99,140,255,0.4); }
html[data-theme="dark"] .ai-pick-cancel { background: #16202f; }
html[data-theme="dark"] .ai-status-overlay { background: rgba(13,19,31,0.72); }
html[data-theme="dark"] .ai-status-box { background: #16202f; border-color: rgba(99,140,255,0.4); color: #93c5fd; }
html[data-theme="dark"] .ai-note-empty { color: var(--c-muted); }
.ai-note-top { line-height: 1.5; }
.ai-note-gist {
  margin: 2px 0 4px; padding: 3px 8px;
  background: #fff; border-left: 2px solid #93b4ff; border-radius: 4px;
  color: #1e293b; font-size: 12px; line-height: 1.55;
}
html[data-theme="dark"] .ai-note { background: rgba(74,134,255,0.10); border-color: rgba(99,140,255,0.35); color: var(--c-dim); }
html[data-theme="dark"] .ai-note-h { color: #93c5fd; }
html[data-theme="dark"] .ai-note-gist { background: rgba(255,255,255,0.04); border-left-color: #60a5fa; color: var(--c-text); }

/* 點開看當初質詢原文（前後約 500 字）+ 關鍵字 highlight（2026-06-05 用戶）*/
.ai-note-toggle {
  margin: 2px 0 0; padding: 2px 0; border: none; background: none; cursor: pointer;
  color: #1d4ed8; font-size: 11.5px; font-weight: 600; font-family: inherit;
}
.ai-note-toggle:hover { text-decoration: underline; }
.ai-note-ctx {
  margin: 5px 0 4px; padding: 7px 10px;
  background: #fff; border: 1px dashed #b8ccff; border-radius: 5px;
  color: #1e293b; font-size: 12px; line-height: 1.7;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.ai-note-ctx mark.ai-hl {
  background: #fde68a; color: #7c2d12; padding: 0 1px; border-radius: 2px; font-weight: 700;
}
html[data-theme="dark"] .ai-note-toggle { color: #93c5fd; }
html[data-theme="dark"] .ai-note-ctx { background: rgba(255,255,255,0.03); border-color: rgba(99,140,255,0.4); color: var(--c-text); }
html[data-theme="dark"] .ai-note-ctx mark.ai-hl { background: #b45309; color: #fff8e1; }

/* 詳全文連結（來源原文，如監察院糾正頁；2026-06-23 用戶） */
.ai-note-more { color: #1d4ed8; font-weight: 600; white-space: nowrap; }
.ai-note-more:hover { text-decoration: underline; }

/* 🔑 2026-06-23 用戶「關燈時這塊字看不清」：.pp-sheet 在夜色下刻意維持「白紙黑字」(8113，
   為列印擬真)，但內嵌的 .ai-note* 各自有「淺色字」夜色 override → 淺字落在白紙上＝看不見。
   解：白紙內的 AI 佐證一律沿用「淺色模式(深字白底)」配色，確保白紙上永遠可讀。 */
html[data-theme="dark"] .pp-sheet .ai-note {
  background: #f4f8ff; border-color: #cfe0ff; border-left-color: #4a86ff; color: #33415c;
}
html[data-theme="dark"] .pp-sheet .ai-note-h { color: #1d4ed8; }
html[data-theme="dark"] .pp-sheet .ai-note-gist { background: #fff; border-left-color: #93b4ff; color: #1e293b; }
html[data-theme="dark"] .pp-sheet .ai-note-ctx { background: #fff; border-color: #b8ccff; color: #1e293b; }
html[data-theme="dark"] .pp-sheet .ai-note-ctx mark.ai-hl { background: #fde68a; color: #7c2d12; }
html[data-theme="dark"] .pp-sheet .ai-note-toggle,
html[data-theme="dark"] .pp-sheet .ai-note-more { color: #1d4ed8; }
html[data-theme="dark"] .pp-sheet .ai-note-id { color: #64748b; }
html[data-theme="dark"] .pp-sheet .ai-note-sc { color: #94a3b8; }
html[data-theme="dark"] .pp-sheet .ai-note-empty { color: #64748b; }

/* ============ 115 vs 114 年度比對分析 (yoy.html) 2026-06-05 ============ */
.yoy-page { max-width: 1280px; margin: 0 auto; padding: 18px 20px 60px; }
.yoy-hero { text-align: center; padding: 26px 16px 20px; }
.yoy-eyebrow { font-size: 13px; letter-spacing: 2px; color: var(--c-muted); }
.yoy-title { font-size: 30px; margin: 6px 0 12px; color: var(--c-text); font-weight: 800; }
.yoy-grand { font-size: 15px; color: var(--c-text); }
.yoy-grand .yg-amt { font-weight: 800; font-size: 20px; color: var(--c-accent); }
.yoy-grand .yg-meta { color: var(--c-muted); font-size: 13px; margin-left: 8px; }
.yoy-sub { max-width: 760px; margin: 12px auto 0; font-size: 12.5px; color: var(--c-muted); line-height: 1.7; }

.yoy-controls { display: flex; gap: 12px; align-items: center; justify-content: center;
  margin: 22px 0 18px; flex-wrap: wrap; }
.yoy-search { padding: 9px 14px; border: 1px solid var(--c-border); border-radius: 999px;
  background: var(--c-panel); color: var(--c-text); font-size: 14px; width: 280px; max-width: 70vw; }
.yoy-sortbtns { display: inline-flex; gap: 4px; background: var(--c-panel);
  border: 1px solid var(--c-border); border-radius: 999px; padding: 3px; }
.yoy-sort { border: 0; background: transparent; color: var(--c-muted); padding: 6px 14px;
  border-radius: 999px; cursor: pointer; font-size: 13px; }
.yoy-sort.active { background: var(--c-accent); color: #fff; font-weight: 700; }

.yoy-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.yoy-empty { grid-column: 1/-1; text-align: center; color: var(--c-muted); padding: 60px 0; }

.yc { background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 14px;
  padding: 16px 16px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border-top: 3px solid var(--c-border); display: flex; flex-direction: column; }
.yc.is-up { border-top-color: var(--c-danger); }
.yc.is-down { border-top-color: var(--c-ok); }
.yc-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.yc-name { font-size: 17px; font-weight: 800; color: var(--c-text); margin: 0; }
.yc-pct { font-size: 16px; font-weight: 800; }
.yc-pct.is-up { color: var(--c-danger); }
.yc-pct.is-down { color: var(--c-ok); }
.yc-pct.is-new { color: var(--c-accent); font-size: 13px; }

.yc-bars { margin: 12px 0 8px; display: flex; flex-direction: column; gap: 5px; }
.yc-bar { height: 22px; border-radius: 5px; display: flex; align-items: center;
  padding: 0 8px; font-size: 11.5px; font-weight: 700; color: #fff; white-space: nowrap; min-width: 90px; }
.yc-bar-114 { background: #9aa3b2; }
.yc-bar-115 { background: var(--c-accent); }
.yc-bar-115.is-up { background: var(--c-danger); }
.yc-bar-115.is-down { background: var(--c-ok); }
.yc-noprior { font-size: 12px; color: var(--c-muted); padding: 2px 0; }
.yc-delta { font-size: 13px; color: var(--c-muted); margin-bottom: 8px; }
.yc-delta.is-up b { color: var(--c-danger); }
.yc-delta.is-down b { color: var(--c-ok); }

.yc-movers { list-style: none; margin: 4px 0 10px; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.mv { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; line-height: 1.4; }
.mv-ic { flex: 0 0 auto; font-size: 11px; }
.mv-nm { flex: 0 0 auto; color: var(--c-text); font-weight: 600; max-width: 40%; }
.mv-amt { color: var(--c-muted); font-size: 11.5px; }
.mv-up .mv-amt b { color: var(--c-danger); }
.mv-down .mv-amt b { color: var(--c-ok); }
.mv-new .mv-nm { color: var(--c-accent); }
.yc-nomovers { font-size: 12px; color: var(--c-muted); padding: 4px 0 10px; font-style: italic; }

.yc-ai { margin-top: auto; background: var(--c-row-alt); border-radius: 10px; padding: 11px 12px;
  border: 1px solid var(--c-border); }
.yc-ai-hd { font-size: 12px; font-weight: 800; color: var(--c-accent); margin-bottom: 5px; }
.yc-ai p { margin: 0; font-size: 12.8px; line-height: 1.75; color: var(--c-text); }
.yc-ai-empty { color: var(--c-muted); font-size: 12px; font-style: italic; }
html[data-theme="dark"] .yc-ai { background: rgba(255,255,255,.03); }
html[data-theme="dark"] .yc-bar-114 { background: #4a5568; }

/* ═══════════ 夜色 v3：基金/計畫敘述 narrative 配色統整（2026-06-17 用戶「配色不好看也不易閱讀」）═══════════
   問題：dark 只覆寫了少數 class，其餘 ex-li 左邊框(藍/綠/紅/紫)、ex-h-chap 藍漸層、ex-h-sec 淺藍底、
   hl-date/pct/ref 淺色 chip 全部沿用 light theme → 夜色下五顏六色刺眼難讀（違反 dark-theme-rules slate+cyan）。
   統一：金額=琥珀(唯一「錢」色)、百分比=teal、其餘=柔和亮字「無色塊」；結構強調一律 cyan 系，層級用深淺非換色。 */

/* 內文高亮：拿掉所有淺色 chip 背景，只留純色亮字（amounts 已是琥珀 #fcd34d 不動）*/
html[data-theme="dark"] .ed-rich .hl-date {
  background: transparent; color: #93c5fd; padding: 0; border-radius: 0;
}
html[data-theme="dark"] .ed-rich .hl-pct {
  background: transparent; color: #5eead4; padding: 0; border-radius: 0; font-weight: 600;
}
html[data-theme="dark"] .ed-rich .hl-ref {
  background: transparent; color: #a5b4cb; padding: 0; border-radius: 0;
}

/* 列表項：統一深底；左邊框收斂成「主層 cyan / 其餘暗 slate」，不再藍綠紅紫各一色 */
html[data-theme="dark"] .ed-rich .ex-li {
  background: rgba(148,163,184,0.05); border-left-color: #475569;
}
html[data-theme="dark"] .ed-rich .ex-li:hover { background: rgba(148,163,184,0.10); }
html[data-theme="dark"] .ed-rich .ex-li-paren { border-left-color: #64748b; }   /* (1) */
html[data-theme="dark"] .ed-rich .ex-li-num   { border-left-color: #64748b; }   /* 1.  */
html[data-theme="dark"] .ed-rich .ex-li-cn    { border-left-color: #22d3ee; }   /* 一、主層=cyan */
html[data-theme="dark"] .ed-rich .ex-li-cn-paren {                              /* (一) 子小標 */
  border-left-color: #38bdf8; background: rgba(34,211,238,0.06); color: #e2e8f0;
}
html[data-theme="dark"] .ed-rich .ex-li-angle {                                /* <1> 子項 */
  border-left-color: #3a4658; background: rgba(148,163,184,0.04);
}

/* 章大標「壹、」：藍實心漸層 → 深 cyan 半透明 + cyan 左槓 + 亮字（不再像彩色橫幅）*/
html[data-theme="dark"] .ed-rich .ex-h-chap {
  background: linear-gradient(to right, rgba(34,211,238,0.15), rgba(34,211,238,0.02));
  color: #d6f6ff; border-left: 4px solid #22d3ee; letter-spacing: .5px;
}
/* 節小標「一、」：淺藍底深藍字 → 透明 + cyan 左槓 + cyan 柔字 */
html[data-theme="dark"] .ed-rich .ex-h-sec {
  background: transparent; color: #7dd3fc; border-left-color: #22d3ee;
}
html[data-theme="dark"] .ed-rich .ex-h { color: #94a3b8; border-bottom-color: #334155; }

/* 長文章節收折＋目錄（2026-07-24）：同 cyan 系 */
html[data-theme="dark"] .ed-rich .ex-toc-chip { background: #1e293b; border-color: #334155; color: #7dd3fc; }
html[data-theme="dark"] .ed-rich .ex-toc-chip:hover { background: #273449; }
html[data-theme="dark"] .ed-rich .ex-chapd { border-color: #334155; }
html[data-theme="dark"] .ed-rich .ex-chapd[open] { border-color: rgba(34,211,238,0.4); }
html[data-theme="dark"] .ed-rich .ex-chapsum {
  background: linear-gradient(to right, rgba(34,211,238,0.15), rgba(34,211,238,0.02));
  color: #d6f6ff;
}
html[data-theme="dark"] .ed-rich .ex-chapd:not([open]) .ex-chapsum { background: #1e293b; color: #7dd3fc; }

/* 強調塊：兩者統一 cyan 系（budget 強、overview 柔），取代先前 cyan vs 紫/琥珀的衝突 */
html[data-theme="dark"] .ed-rich .ex-hi-budget {
  background: rgba(34,211,238,0.07); border-left: 3px solid #22d3ee;
}
html[data-theme="dark"] .ed-rich .ex-hi-overview {
  background: rgba(125,211,252,0.06); border-left: 3px solid #7dd3fc;
}

/* ═══════════ 夜色 v3：釘選 popup (.ml-popup / popup.js) 全套深色（2026-06-17 用戶「這個也是要修・顏色」）═══════════
   問題：popup 原本完全沒有夜色 override → 夜色下是「白底卡片 + 粉彩 badge + 暗紅金額(#c0392b)」浮在深色頁面上，
   突兀且暗紅在白底/深底都低對比。統一成 slate + cyan，金額用琥珀金(與內文 hl-amt 同系)。*/
html[data-theme="dark"] .ml-popup {
  background: var(--c-panel, #1e293b); border-color: var(--c-border, #334155);
  box-shadow: 0 10px 34px rgba(0,0,0,0.55);
}
html[data-theme="dark"] .ml-popup-head {
  background: linear-gradient(180deg, #1f2b3e 0%, #182336 100%);
  border-bottom-color: var(--c-border, #334155);
}
html[data-theme="dark"] .ml-popup-head::before { color: #5b6678; }
html[data-theme="dark"] .ml-popup-title { color: #f1f5f9; }
html[data-theme="dark"] .ml-popup-mini { background: rgba(255,255,255,0.06); color: #94a3b8; }
html[data-theme="dark"] .ml-popup-close,
html[data-theme="dark"] .ml-popup-pin { background: rgba(255,255,255,0.07); color: #cbd5e1; }
/* badge：粉彩 → 深色半透明 tint + 亮字（保留語意色相，收進夜色）*/
html[data-theme="dark"] .ml-popup-badge { background: rgba(148,163,184,0.16); color: #cbd5e1; }
html[data-theme="dark"] .ml-popup-badge.badge-主管,
html[data-theme="dark"] .ml-popup-badge.badge-機關 { background: rgba(251,191,36,0.16); color: #fcd34d; }
html[data-theme="dark"] .ml-popup-badge.badge-目 { background: rgba(251,191,36,0.13); color: #fde68a; }
html[data-theme="dark"] .ml-popup-badge.badge-分支計畫,
html[data-theme="dark"] .ml-popup-badge.badge-用途別大類 { background: rgba(34,211,238,0.15); color: #7dd3fc; }
html[data-theme="dark"] .ml-popup-badge.badge-用途別細項 { background: rgba(148,163,184,0.14); color: #cbd5e1; }
/* body + 內容 */
html[data-theme="dark"] .ml-popup-body { background: var(--c-bg, #0f172a); }
html[data-theme="dark"] .popup-body-inner { color: #cbd5e1; }
html[data-theme="dark"] .popup-body-inner .pb-amts,
html[data-theme="dark"] .popup-body-inner .pb-section {
  background: #16202f; border-color: var(--c-border, #334155);
}
html[data-theme="dark"] .popup-body-inner .pb-lab { color: #94a3b8; }
html[data-theme="dark"] .popup-body-inner .pb-cur { color: #fcd34d; }          /* 主金額：暗紅 → 琥珀金 */
html[data-theme="dark"] .popup-body-inner .pb-amt-sub { border-top-color: #2a3850; }
html[data-theme="dark"] .popup-body-inner .pb-amt-sub .pb-val { color: #94a3b8; }
html[data-theme="dark"] .popup-body-inner .pb-amt-sub .pb-val.up { color: #fca5a5; }   /* 增 */
html[data-theme="dark"] .popup-body-inner .pb-amt-sub .pb-val.down { color: #6ee7b7; } /* 減 */
html[data-theme="dark"] .popup-body-inner .pb-code { background: #131c29; color: #8b94a4; }
html[data-theme="dark"] .popup-body-inner .pb-meta dt { color: #94a3b8; }
html[data-theme="dark"] .popup-body-inner .pb-meta dd { color: #e2e8f0; }
html[data-theme="dark"] .popup-body-inner .pb-meta .pb-path { color: #aab4c4; }
html[data-theme="dark"] .popup-body-inner .pb-section h4 { color: #cbd5e1; }
html[data-theme="dark"] .popup-body-inner .pb-rich { color: #cbd5e1; }
html[data-theme="dark"] .popup-body-inner .pb-stub-tag { background: rgba(251,191,36,0.16); color: #fcd34d; }
html[data-theme="dark"] .popup-body-inner .pb-actions { border-top-color: var(--c-border, #334155); }

/* 夜色：stub 說明（整段引用）原本是淺色奶油底 #fff8e6 → 暗底上太突兀。
   改成半透明琥珀疊在 slate 上、暗琥珀左框、柔和米黃字（沿用 pb-stub-tag 風格，2026-06-23 用戶）*/
html[data-theme="dark"] .ed-explain-stub {
  background: rgba(251,191,36,0.07);
  border-left-color: rgba(251,191,36,0.5);
  color: #cdbb92;
}
html[data-theme="dark"] .ed-explain-stub .stub-badge { color: #f2cd6a; }

/* ── 造浪者全知輔助系統：左上角下拉切換小幫手（2026-06-22 用戶）──
   trigger 沿用 .brand-switch / .brand-switch-strip 的玻璃＋HUD 角括號＋cyan 發光風（之前的風格）；
   menu 用 position:fixed 由 JS 定位，避開 .dataset-supertabs 的 overflow 裁切（之前「點不開」主因）。 */
.brand-omni { position: relative; display: inline-flex; align-items: center; }
/* 🔑 trigger 是 <button>：必須清掉瀏覽器原生淺色底，否則白底＋白字＝看不見（2026-06-22 用戶回報） */
.brand-omni .bo-toggle {
  font-family: inherit; cursor: pointer; color: inherit;
  background: transparent; border: 1px solid transparent;
  -webkit-appearance: none; appearance: none;
}
.bo-line { display: inline-flex; align-items: center; gap: 8px; line-height: 1; white-space: nowrap; }
.bo-sys-name { font-size: 15px; font-weight: 700; color: #f1f5f9; letter-spacing: .4px; }
.bo-sep { color: rgba(255,255,255,.32); font-size: 13px; }
.bo-cur-mini { font-size: 13px; font-weight: 600; color: #7de7ff; text-shadow: 0 0 8px rgba(56,205,255,.5); }
.bo-caret { font-size: 10px; color: #9fe9ff; transition: transform .2s; }
.brand-omni.open .bo-caret { transform: rotate(180deg); }

.bo-menu {
  position: fixed; z-index: 4000; min-width: 256px; padding: 6px;
  background: var(--c-panel); border: 1px solid var(--c-border); border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,.28);
  opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.98); transform-origin: top left;
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
}
.brand-omni.open .bo-menu { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.bo-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 8px; color: var(--c-text); text-decoration: none; cursor: pointer;
}
.bo-item:hover { background: var(--c-row-alt); }
.bo-item.active { background: color-mix(in srgb, var(--c-accent) 14%, transparent); }
.bo-item-icon { font-size: 20px; width: 24px; text-align: center; flex: none; }
.bo-item-txt { display: flex; flex-direction: column; line-height: 1.25; }
.bo-item-name { font-size: 14px; font-weight: 700; color: var(--c-text); }
.bo-item-desc { font-size: 11.5px; color: var(--c-muted); }
.bo-item-dot { margin-left: auto; color: var(--c-accent); font-size: 10px; }
/* 「介面施作中」徽章：標在選單項名稱後（2026-07-01 用戶）*/
.bo-item-wip {
  display: inline-block; margin-left: 7px; padding: 1px 6px; vertical-align: middle;
  font-size: 10px; font-weight: 700; line-height: 1.5; letter-spacing: .3px; white-space: nowrap;
  color: #ffcf7a; background: rgba(255,176,64,.14);
  border: 1px solid rgba(255,176,64,.42); border-radius: 999px;
}
/* 「← 點此切換小幫手應用場景」提示：緊貼品牌切換鈕右側，一抹脈動吸睛（2026-07-01 用戶）*/
.bo-hint {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; flex: none;
  font-size: 12px; font-weight: 600; color: #7de7ff; letter-spacing: .3px; white-space: nowrap;
  text-shadow: 0 0 8px rgba(56,205,255,.45); pointer-events: none; user-select: none;
  animation: boHintPulse 2.2s ease-in-out infinite;
}
.bo-hint-arrow { font-size: 13px; animation: boHintNudge 1.3s ease-in-out infinite; }
@keyframes boHintPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes boHintNudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }
@media (prefers-reduced-motion: reduce){ .bo-hint, .bo-hint-arrow { animation: none; } }
@media (max-width: 680px){ .bo-sys-name{ font-size: 13px; } .bo-sep, .bo-cur-mini, .bo-hint{ display: none; } }

/* ===== 詳情面板分頁殼 edt-*（2026-07-11 用戶：分頁籤式重設計＋加寬絲滑動畫）===== */
/* 左右欄寬度過渡：只在程式調整時掛 .split-anim；拖曳分隔線期間一律關閉 */
.explorer-grid.split-anim { transition: grid-template-columns .38s cubic-bezier(.33, 0, .2, 1); }
body.is-resizing .explorer-grid { transition: none !important; }

/* 釘住頂列（badge＋名稱＋KPI＋⛶＋頁籤）：負 margin 吃掉 host padding，捲動時蓋住內容 */
.edt-sticky {
  position: sticky; top: -12px; z-index: 30;
  margin: -12px -12px 10px; padding: 10px 12px 0;
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  border-radius: 8px 8px 0 0;
}
.edt-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.edt-name {
  margin: 0; font-size: 15.5px; line-height: 1.35; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.edt-kpi { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.edt-kpi-amt { font-size: 12.5px; font-weight: 700; color: #0e7490; white-space: nowrap; }
.edt-kpi .aid-delta {
  font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 10px; white-space: nowrap;
}
.edt-kpi .aid-delta.aid-up { background: #fee2e2; color: #b91c1c; }
.edt-kpi .aid-delta.aid-down { background: #dcfce7; color: #15803d; }
.edt-kpi .aid-delta.aid-na { background: #e5e7eb; color: #6b7280; font-weight: 600; }
.edt-widen {
  flex: 0 0 auto; font-size: 11.5px; font-weight: 700; white-space: nowrap; cursor: pointer;
  padding: 3px 10px; border-radius: 999px;
  color: #0e7490; background: rgba(8,145,178,.08); border: 1px solid rgba(8,145,178,.35);
  transition: background .15s, color .15s, border-color .15s;
}
.edt-widen:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
.edt-widen.is-wide { background: #0891b2; color: #fff; border-color: #0891b2; }
.edt-sub { font-size: 11.5px; margin: 3px 0 0; padding-left: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edt-sub[hidden] { display: none; }

/* 頁籤列：有資料的籤才亮起、帶數量（2026-07-11 用戶：要做成很顯眼的頁籤） */
.edt-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 8px 0;
  margin: 8px -8px 0; border-bottom: 2px solid rgba(8,145,178,.25);
  background: linear-gradient(180deg, rgba(8,145,178,.05), rgba(8,145,178,.10));
  border-radius: 10px 10px 0 0;
}
.edt-tabs[hidden] { display: none; }
.edt-tab {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13.5px; font-weight: 750; padding: 8px 14px 7px;
  border-radius: 9px 9px 0 0; margin-bottom: -2px;
  color: #155e6e; background: rgba(255,255,255,.55);
  border: 1px solid rgba(8,145,178,.30); border-bottom: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.edt-tab:hover { background: #fff; border-color: #0891b2; color: #0e7490; }
.edt-tab.is-active {
  background: #0891b2; border-color: #0891b2; color: #fff;
  box-shadow: 0 -2px 10px rgba(8,145,178,.35), inset 0 -2px 0 #0891b2;
}
.edt-cnt {
  font-size: 11px; font-weight: 800; line-height: 1; padding: 3px 7px; border-radius: 999px;
  background: rgba(8,145,178,.16); color: #0e7490;
}
.edt-tab.is-active .edt-cnt { background: rgba(255,255,255,.28); color: #fff; }
.edt-cnt[hidden] { display: none; }
/* 🔒 個別頁籤 hidden 保險：.edt-tab 的 inline-flex 會蓋掉 UA 的 [hidden]→display:none，必須明寫 */
.edt-tab[hidden] { display: none !important; }
/* 空內容頁籤：常駐但灰階禁點（此層級無此內容） */
.edt-tab.is-disabled, .edt-tab:disabled {
  opacity: .45; cursor: not-allowed; pointer-events: auto;
  background: rgba(148,163,184,.15); border-color: rgba(148,163,184,.35); color: #64748b;
  box-shadow: none;
}
.edt-tab.is-disabled:hover, .edt-tab:disabled:hover {
  background: rgba(148,163,184,.15); border-color: rgba(148,163,184,.35); color: #64748b;
}

/* 分頁面板：一次只顯示一頁 */
.edt-panel { display: none; }
.edt-panel.is-active { display: block; }

/* 圖29：說明/計畫內容/預期成果 抬升進分頁後的內文容器 */
.edt-sect-body { padding: 12px 4px; }

/* 2026-07-24 用戶「太長的在總覽第一句就標明有另立頁籤」：總覽頂端可點提示 */
.ed-liftnote { display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; }
.ed-liftnote-chip {
  text-align: left; cursor: pointer; font-size: 12.5px;
  color: #0e7490; background: rgba(8,145,178,.07);
  border: 1px dashed rgba(8,145,178,.4); border-radius: 6px; padding: 5px 10px;
}
.ed-liftnote-chip:hover { background: rgba(8,145,178,.15); }
html[data-theme="dark"] .ed-liftnote-chip {
  color: #67e8f9; background: rgba(34,211,238,.06); border-color: rgba(34,211,238,.35);
}
html[data-theme="dark"] .ed-liftnote-chip:hover { background: rgba(34,211,238,.14); }
.edt-sect-title {
  margin: 0 0 10px; font-size: 14px; font-weight: 750; color: #0e7490;
  padding-bottom: 6px; border-bottom: 1px solid rgba(8,145,178,.22);
}

/* 質詢列 → 立法院公報 PDF 深連（#page= 直開該頁） */
.aid-gz {
  display: inline-block; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: #0e7490; background: rgba(8,145,178,.09); border: 1px solid rgba(8,145,178,.32);
  padding: 0 7px; border-radius: 999px; margin-left: 4px; text-decoration: none;
  transition: background .15s, color .15s;
}
.aid-gz:hover { background: #0891b2; color: #fff; border-color: #0891b2; text-decoration: none; }

/* 殼已有釘住頂列 → 隱藏卡片內重複的標題列（名稱/badge），meta 已移進 .edt-sub */
.edt-shell .ed-card .ed-head { display: none; }
/* 分頁內的 .exp-ai-diff 是普通容器（非 <details>），拿掉卡片外框以外的收合視覺 */
.edt-flat { margin-bottom: 12px; }
.edt-sec-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 700; color: #0e7490; padding: 2px 0 6px;
}
.edt-sec-head .aid-title { font-size: 13.5px; }
.edt-sec-head .aid-delta { margin-left: auto; font-size: 12.5px; font-weight: 700;
  padding: 1px 8px; border-radius: 10px; }

/* 總覽迷你摘要（前 3 筆）＋跳分頁晶片 */
.edt-mini-item { display: flex; align-items: baseline; gap: 8px; }
.edt-mini-amt { flex: 0 0 auto; white-space: nowrap; font-size: 12.5px; }
.edt-more {
  margin-left: 8px; font-size: 11.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
  color: #0891b2; background: rgba(8,145,178,.10); border: 1px solid rgba(8,145,178,.30);
  padding: 1px 8px; border-radius: 999px; transition: background .15s, color .15s;
}
.edt-more:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
.edt-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px;
  padding-top: 8px; border-top: 1px solid rgba(8,145,178,.18); }
.edt-chip {
  font-size: 11.5px; font-weight: 650; cursor: pointer; white-space: nowrap;
  color: #0e7490; background: rgba(8,145,178,.08); border: 1px solid rgba(8,145,178,.30);
  padding: 3px 10px; border-radius: 999px; transition: background .15s, color .15s;
}
.edt-chip:hover { background: #0891b2; color: #fff; border-color: #0891b2; }
.edt-ov-diff:empty, .edt-ov-iss:empty { display: none; }
.edt-ov-iss { margin-bottom: 10px; }

/* 深色主題 */
html[data-theme="dark"] .edt-sticky { background: #1a1f2c; border-bottom-color: #2c3340; }
html[data-theme="dark"] .edt-kpi-amt { color: #67e8f9; }
html[data-theme="dark"] .edt-kpi .aid-delta.aid-up { background: rgba(248,113,113,.18); color: #fca5a5; }
html[data-theme="dark"] .edt-kpi .aid-delta.aid-down { background: rgba(74,222,128,.18); color: #86efac; }
html[data-theme="dark"] .edt-kpi .aid-delta.aid-na { background: rgba(148,163,184,.18); color: #94a3b8; }
html[data-theme="dark"] .edt-widen { color: #67e8f9; background: rgba(34,211,238,.10); border-color: rgba(34,211,238,.38); }
html[data-theme="dark"] .edt-widen:hover,
html[data-theme="dark"] .edt-widen.is-wide { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }
html[data-theme="dark"] .edt-tabs { border-bottom-color: rgba(34,211,238,.35);
  background: linear-gradient(180deg, rgba(34,211,238,.05), rgba(34,211,238,.10)); }
html[data-theme="dark"] .edt-tab { color: #9adbe8; background: rgba(11,18,32,.45); border-color: rgba(34,211,238,.30); }
html[data-theme="dark"] .edt-tab:hover { background: #101826; border-color: #22d3ee; color: #67e8f9; }
html[data-theme="dark"] .edt-tab.is-active { background: #22d3ee; border-color: #22d3ee; color: #0b1220;
  box-shadow: 0 -2px 10px rgba(34,211,238,.35), inset 0 -2px 0 #22d3ee; }
html[data-theme="dark"] .edt-sect-title { color: #67e8f9; border-bottom-color: rgba(34,211,238,.30); }
html[data-theme="dark"] .aid-gz { color: #67e8f9; background: rgba(34,211,238,.10); border-color: rgba(34,211,238,.38); }
html[data-theme="dark"] .aid-gz:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }
html[data-theme="dark"] .edt-cnt { background: rgba(34,211,238,.16); color: #67e8f9; }
html[data-theme="dark"] .edt-tab.is-active .edt-cnt { background: rgba(11,18,32,.28); color: #0b1220; }
html[data-theme="dark"] .edt-tab.is-disabled, html[data-theme="dark"] .edt-tab:disabled {
  background: rgba(71,85,105,.25); border-color: rgba(100,116,139,.35); color: #64748b;
}
html[data-theme="dark"] .edt-tab.is-disabled:hover, html[data-theme="dark"] .edt-tab:disabled:hover {
  background: rgba(71,85,105,.25); border-color: rgba(100,116,139,.35); color: #64748b;
}
html[data-theme="dark"] .edt-sec-head { color: #67e8f9; }
html[data-theme="dark"] .edt-more,
html[data-theme="dark"] .edt-chip { color: #67e8f9; background: rgba(34,211,238,.12); border-color: rgba(34,211,238,.38); }
html[data-theme="dark"] .edt-more:hover,
html[data-theme="dark"] .edt-chip:hover { background: #22d3ee; color: #0b1220; border-color: #22d3ee; }
html[data-theme="dark"] .edt-chips { border-top-color: rgba(34,211,238,.30); }
@media (prefers-reduced-motion: reduce) { .explorer-grid.split-anim { transition: none; } }

/* ===== v0.7.9 (2026-07-11 用戶): 加寬詳情 → 左樹「精簡列」模式 =====
   優先序：計劃名稱 → 位階(三角形顏色) → 預算數 → 款項目節(藏)。
   徽章 pill（大類等）隱藏，層級改由展開三角形的顏色表達（沿用各級徽章原色系）。 */
.explorer-grid.is-exp-wide .tn-badge,
.explorer-grid.is-exp-wide .tn-code-prefix,
.explorer-grid.is-exp-wide .tn-diff { display: none; }
.explorer-grid.is-exp-wide .tn-row {
  grid-template-columns: 1fr max-content 12px;   /* 名稱吃滿 → 金額(不折行) → 箭頭 */
  gap: 6px; padding: 5px 6px;
}
.explorer-grid.is-exp-wide .tn-amt { font-size: 12px; }
.explorer-grid.is-exp-wide .tn-toggle { font-size: 11px; font-weight: 700; }
/* 層級 → 三角形顏色（亮色＝各級左側色條同色系） */
.explorer-grid.is-exp-wide .kind-主管 > .tn-row-wrap > .tn-toggle,
.explorer-grid.is-exp-wide .kind-款   > .tn-row-wrap > .tn-toggle { color: #ff8a00; }
.explorer-grid.is-exp-wide .kind-機關 > .tn-row-wrap > .tn-toggle,
.explorer-grid.is-exp-wide .kind-項   > .tn-row-wrap > .tn-toggle { color: #d04040; }
.explorer-grid.is-exp-wide .kind-目   > .tn-row-wrap > .tn-toggle { color: #1f4e8a; }
.explorer-grid.is-exp-wide .kind-分支計畫 > .tn-row-wrap > .tn-toggle { color: #2f6a1d; }
.explorer-grid.is-exp-wide .kind-用途別大類 > .tn-row-wrap > .tn-toggle { color: #5b3d99; }
.explorer-grid.is-exp-wide .kind-用途別     > .tn-row-wrap > .tn-toggle,
.explorer-grid.is-exp-wide .kind-用途別細項 > .tn-row-wrap > .tn-toggle { color: #b57909; }
.explorer-grid.is-exp-wide .kind-細目 > .tn-row-wrap > .tn-toggle,
.explorer-grid.is-exp-wide .kind-節   > .tn-row-wrap > .tn-toggle { color: #0b5b54; }
/* 深色主題 → 沿用 neon 徽章同色 */
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-主管 > .tn-row-wrap > .tn-toggle,
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-款   > .tn-row-wrap > .tn-toggle { color: #22d3ee; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-機關 > .tn-row-wrap > .tn-toggle,
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-項   > .tn-row-wrap > .tn-toggle { color: #a78bfa; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-目   > .tn-row-wrap > .tn-toggle { color: #60a5fa; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-分支計畫 > .tn-row-wrap > .tn-toggle { color: #34d399; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-用途別大類 > .tn-row-wrap > .tn-toggle { color: #f472b6; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-用途別     > .tn-row-wrap > .tn-toggle,
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-用途別細項 > .tn-row-wrap > .tn-toggle { color: #fcd34d; }
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-細目 > .tn-row-wrap > .tn-toggle,
html[data-theme="dark"] .explorer-grid.is-exp-wide .kind-節   > .tn-row-wrap > .tn-toggle { color: #5eead4; }

/* ============================================================
   📱 v0.8.0 行動版收斂（2026-07-11 /m 行動殼上線配套）
   /m 生成頁籤連到的桌面作業頁在手機上的最小適配：
   頂列 supertab 條換行不擠掉工具鈕、資料庫工具列搜尋框滿寬、三欄卡片改單欄。
   ============================================================ */
@media (max-width: 640px) {
  .dataset-supertabs { flex-wrap: wrap; height: auto; padding: 0 8px; }
  .ds-supertab { height: 34px; padding: 0 12px; font-size: 12.5px; }
  .topstrip-tools { padding: 4px 0 4px 8px; }
  .db4-toolbar input[type="search"] { min-width: 0; width: 100%; max-width: none; }
  .dbov-cards-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   逐筆預算跨年折線圖（explorer 詳情卡 .ed-amts 下方；2026-07-11 用戶）
   雙線：預算（實線·主色）＋決算（虛線·對比色）。手刻 inline SVG、viewBox 響應式。
   深淺色皆走 --c-* 變數 → 主題切換自動可讀。
   ============================================================ */
.ed-hist-chart {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--c-border);
}
.eh-title { font-size: 13px; font-weight: 700; color: var(--c-text); margin-bottom: 6px; }
.eh-legend { display: flex; gap: 16px; font-size: 12px; color: var(--c-muted); margin-bottom: 4px; }
.eh-leg { display: inline-flex; align-items: center; gap: 5px; }
.eh-svg-wrap { width: 100%; overflow-x: auto; }
.eh-svg { width: 100%; height: auto; display: block; }
.eh-warn { font-size: 11px; color: var(--c-warn); margin-top: 6px; line-height: 1.5; }
.eh-warn-note { opacity: .85; margin-top: 2px; }
.eh-cut-soft { font-weight: 500; color: var(--c-muted, #6b7280); }
html[data-theme="dark"] .eh-cut-soft { color: #9ca3af; }

.eh-line-budget { fill: none; stroke: var(--c-accent); stroke-width: 2.2; }
/* 法定預算線（2026-07-13 三線版）：綠系，與主色預算案/警示色決算區隔 */
.eh-line-legal  { fill: none; stroke: #059669; stroke-width: 2.2; }
.eh-line-final  { fill: none; stroke: var(--c-warn);   stroke-width: 2.2; stroke-dasharray: 6 4; }

.eh-dot { stroke-width: 2; }
.eh-dot-budget { stroke: var(--c-accent); }
.eh-dot-legal  { stroke: #059669; }
.eh-dot-final  { stroke: var(--c-warn); }
.eh-dot-solid.eh-dot-budget { fill: var(--c-accent); }
.eh-dot-solid.eh-dot-legal  { fill: #059669; }
.eh-dot-solid.eh-dot-final  { fill: var(--c-warn); }
.eh-dot-hollow { fill: var(--c-surface); }

.eh-grid { stroke: var(--c-border); stroke-width: 1; }
.eh-axis { stroke: var(--c-muted); stroke-width: 1; }
.eh-lbl { fill: var(--c-muted); font-size: 11px; }
/* 資料點直標數字：白描邊墊底讓數字壓在格線/折線上仍可讀 */
.eh-ptlbl { font-size: 11px; font-weight: 600; paint-order: stroke;
            stroke: var(--c-surface); stroke-width: 3px; }
.eh-ptlbl-budget { fill: var(--c-accent); }
.eh-ptlbl-legal  { fill: #059669; }
.eh-ptlbl-final  { fill: var(--c-warn); }
html[data-theme="dark"] .eh-line-legal, html[data-theme="dark"] .eh-dot-legal { stroke: #34d399; }
html[data-theme="dark"] .eh-dot-solid.eh-dot-legal { fill: #34d399; }
html[data-theme="dark"] .eh-ptlbl-legal { fill: #34d399; }
/* 立院審議落差標註（案→法定 刪減/增列） */
.eh-cut { font-size: 11.5px; font-weight: 600; color: #b45309; margin-top: 6px; }
html[data-theme="dark"] .eh-cut { color: #fbbf24; }

/* 2026-09-24 年份小窗：滑到年份 → 該年三線數字＋來源＋補充；感應帶透明、命中年份淡底 */
.eh-svg-wrap { position: relative; }
.eh-hint { color: var(--c-muted); font-weight: 400; opacity: .8; margin-left: auto; }
.eh-hit { fill: transparent; cursor: pointer; }
.eh-hit:hover, .eh-hit.eh-hl { fill: rgba(120,120,120,.09); }
.eh-lbl-x.eh-hl { fill: var(--c-text); font-weight: 700; }
.eh-dot.eh-hl { stroke-width: 3; }
.eh-tip {
  position: absolute; top: 4px; z-index: 6; min-width: 210px; max-width: 280px;
  background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 8px 10px;
  font-size: 12px; line-height: 1.45; pointer-events: none;
}
.eh-tip-h { font-weight: 700; margin-bottom: 4px; }
.eh-tip-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.eh-tip-na { opacity: .5; }
.eh-tip-k { font-weight: 600; white-space: nowrap; }
.eh-tip-prop  { color: var(--c-accent); }
.eh-tip-legal { color: #059669; }
.eh-tip-final { color: var(--c-warn); }
html[data-theme="dark"] .eh-tip-legal { color: #34d399; }
.eh-tip-v { text-align: right; font-variant-numeric: tabular-nums; }
.eh-tip-v small { display: block; font-size: 10px; color: var(--c-muted); }
.eh-tip-src { font-size: 10.5px; color: var(--c-muted); margin: -1px 0 4px; }
.eh-tip-sup { margin-top: 4px; padding-top: 5px; border-top: 1px dashed var(--c-border); font-size: 11.5px; }

/* 🖨 列印：SVG 用 viewBox（無螢幕 px 幾何）；只確保不被 overflow 裁切 */
@media print {
  .eh-svg-wrap { overflow: visible !important; }
  .ed-hist-chart { break-inside: avoid; }
  .eh-tip, .eh-hit, .eh-hint { display: none !important; }
}
/* build-marker: taipai-tabs-20260724 */

/* 2026-07-27 explorer 樹載入占位（修「款點進項先一片空白」）：renderTree 首次渲染時整個清掉 */
.exp-tree-loading {
  list-style: none; display: flex; align-items: center; gap: .55rem;
  padding: 1.6rem .9rem; color: #6b7280; font-size: .92rem;
}
.exp-load-spin {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto;
  border: 2.5px solid #d1d5db; border-top-color: #2563eb;
  animation: exp-load-rot .8s linear infinite;
}
@keyframes exp-load-rot { to { transform: rotate(360deg); } }
html[data-theme="dark"] .exp-tree-loading { color: #9ca3af; }
html[data-theme="dark"] .exp-load-spin { border-color: #374151; border-top-color: #60a5fa; }

/* ── IC 質詢卡（2026-08-27 用戶「排版跟設計也可以用我官網的方式」）──────────────────────────────
   移植廖偉翔官網「重點質詢」卡：黑白、等寬小標、細線分隔、決定性編號（01/02）、原話用「」襯線粗體。
   語意：<details.iqc> 標題列（日期/委員會｜標題＋chips｜＋）→ 展開 grid 兩欄（摘要/要求/指正缺失/回應/原話/後續/頁碼）。 */
.iqc { --iqc-fg: #111; --iqc-muted: #6b6b6b; --iqc-line: #e3e0da; --iqc-card: #f7f5f1; --iqc-inv-bg: #111; --iqc-inv-fg: #fff;
  --iqc-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; --iqc-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  margin: 6px 0 4px; border: 1px solid var(--iqc-line); border-radius: 6px; background: #fff; color: var(--iqc-fg);
  transition: background .3s; overflow: hidden; }
.iqc:hover, .iqc[open] { background: var(--iqc-card); }
.iqc > summary { list-style: none; display: grid; grid-template-columns: 96px 1fr 28px; gap: 8px 16px; padding: 12px 14px;
  align-items: start; cursor: pointer; user-select: none; }
.iqc > summary::-webkit-details-marker { display: none; }
.iqc .iqc-d { font-family: var(--iqc-mono); font-size: .8rem; line-height: 1.5; color: var(--iqc-fg); }
.iqc .iqc-d small { display: block; font-size: .68rem; color: var(--iqc-muted); letter-spacing: .04em; white-space: normal; }
.iqc .iqc-t { font-weight: 700; font-size: 1rem; line-height: 1.5; margin: 0 0 6px; color: var(--iqc-fg); }
.iqc .iqc-m { display: flex; flex-wrap: wrap; gap: 5px; font-size: .74rem; color: var(--iqc-muted); }
.iqc .iqc-m span { border: 1px solid var(--iqc-line); border-radius: 999px; padding: 1px 9px; line-height: 1.6; }
.iqc .iqc-m span.iqc-hi { border-color: var(--iqc-fg); color: var(--iqc-fg); }
.iqc .iqc-pl { width: 26px; height: 26px; border: 1px solid var(--iqc-fg); border-radius: 50%; display: grid; place-items: center;
  font-size: 1.05rem; line-height: 1; transition: transform .35s cubic-bezier(.2,.7,.2,1), background .25s, color .25s; justify-self: end; margin-top: 2px; }
.iqc[open] .iqc-pl { transform: rotate(45deg); background: var(--iqc-inv-bg); color: var(--iqc-inv-fg); }
.iqc .iqc-bd { padding: 0 14px 18px 126px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 32px; }
.iqc .iqc-full { grid-column: 1 / -1; }
.iqc .iqc-lab { font-family: var(--iqc-mono); font-size: .68rem; letter-spacing: .14em; color: var(--iqc-muted); margin-bottom: 6px; text-transform: uppercase; }
.iqc .iqc-sum { font-size: .95rem; line-height: 1.8; max-width: 42em; margin: 0; color: var(--iqc-fg); }
.iqc ol.iqc-ls { counter-reset: n; margin: 0; padding: 0; list-style: none; }
.iqc ol.iqc-ls li { position: relative; padding: 6px 0 6px 28px; border-top: 1px solid var(--iqc-line); font-size: .88rem; line-height: 1.55; counter-increment: n; }
.iqc ol.iqc-ls li::before { content: counter(n, decimal-leading-zero); position: absolute; left: 0; top: 8px;
  font-family: var(--iqc-mono); font-size: .68rem; color: var(--iqc-muted); }
.iqc .iqc-rep { border-left: 2px solid var(--iqc-fg); padding-left: 12px; font-size: .88rem; line-height: 1.6; color: var(--iqc-muted); }
.iqc .iqc-qt { font-family: var(--iqc-serif); font-weight: 700; font-size: 1rem; line-height: 1.6; }
.iqc .iqc-qt p { padding: 4px 0; margin: 0; }
.iqc .iqc-qt p::before { content: "「"; } .iqc .iqc-qt p::after { content: "」"; }
.iqc ol.iqc-fu { margin: 0; padding: 0; list-style: none; }
.iqc ol.iqc-fu li { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; padding: 7px 0; border-top: 1px solid var(--iqc-line); font-size: .86rem; align-items: baseline; }
.iqc ol.iqc-fu li b { font-family: var(--iqc-mono); font-weight: 500; font-size: .74rem; color: var(--iqc-muted); }
.iqc ol.iqc-fu li a { font-size: .74rem; border: 1px solid var(--iqc-line); border-radius: 999px; padding: 2px 10px; white-space: nowrap; color: var(--iqc-muted); text-decoration: none; }
.iqc ol.iqc-fu li a:hover { border-color: var(--iqc-fg); color: var(--iqc-fg); }
.iqc .iqc-ft { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .76rem; color: var(--iqc-muted); }
.iqc .iqc-ft a { border: 1px solid var(--iqc-fg); border-radius: 999px; padding: 3px 11px; color: var(--iqc-fg); text-decoration: none; transition: background .25s, color .25s; }
.iqc .iqc-ft a:hover { background: var(--iqc-inv-bg); color: var(--iqc-inv-fg); }
.iqc .iqc-gz { display: inline-block; font-family: var(--iqc-mono); font-size: .66rem; letter-spacing: .06em; color: var(--iqc-muted); border: 1px solid var(--iqc-line); padding: 2px 8px; border-radius: 4px; }
.iqc .iqc-vf { margin-left: auto; font-size: .7rem; color: #15803d; }
.iqc.iqc-sm > summary { grid-template-columns: 84px 1fr 24px; padding: 10px 12px; }
.iqc.iqc-sm .iqc-t { font-size: .92rem; }
.iqc.iqc-sm .iqc-bd { padding-left: 12px; grid-template-columns: 1fr; gap: 12px; }
.aid-q.has-iqc .aid-q-ctx { margin-left: 2px; }
@media (max-width: 760px) {
  .iqc > summary { grid-template-columns: 1fr 26px; gap: 6px 10px; }
  .iqc .iqc-d { grid-column: 1 / -1; }
  .iqc .iqc-bd { padding-left: 14px; grid-template-columns: 1fr; }
  .iqc ol.iqc-fu li { grid-template-columns: 1fr; gap: 3px; }
}
html[data-theme="dark"] .iqc { --iqc-fg: #f5f2ee; --iqc-muted: #a3a3a3; --iqc-line: #3a3a3a; --iqc-card: #1c1c1c; --iqc-inv-bg: #f5f2ee; --iqc-inv-fg: #111;
  background: #151515; }
html[data-theme="dark"] .iqc .iqc-vf { color: #4ade80; }
@media print { .iqc { break-inside: avoid; } .iqc[open] .iqc-bd { display: grid; } }
/* IC-C 點開才做：✨ 生成質詢卡 按鈕 */
.aid-icgen { display: inline-block; font-size: 11px; font-weight: 700; white-space: nowrap; cursor: pointer;
  color: #6d28d9; background: rgba(124,58,237,.08); border: 1px solid rgba(124,58,237,.35); padding: 0 8px;
  border-radius: 999px; margin-left: 4px; line-height: 1.7; transition: background .15s, color .15s; }
.aid-icgen:hover:not(:disabled) { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.aid-icgen:disabled { cursor: progress; opacity: .8; }
.aid-icgen-msg { font-size: 11px; color: #b91c1c; margin-left: 6px; }
html[data-theme="dark"] .aid-icgen { color: #c4b5fd; background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.4); }
