/* ============================================================
   REDESIGN 2026-11：儀表板／分析／帳目 Hero／藍圖總覽
   只用 main.css 定義的 token，主題切換自動套用
   ============================================================ */

/* 共用：小圖例點、資訊提示（說明收合） */
.lg-dot, .hb-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; flex-shrink: 0; }
.info-tip { position: relative; }
.info-tip > summary {
  list-style: none; cursor: pointer; width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 600; color: var(--text3-on-bg-surface);
  border: 0.5px solid var(--border2); user-select: none;
}
.info-tip > summary::-webkit-details-marker { display: none; }
.info-tip[open] > summary { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.info-tip-body {
  position: absolute; left: 0; top: 26px; z-index: 20; width: 250px;
  background: var(--bg-surface); color: var(--text-on-bg-surface);
  border: 0.5px solid var(--border2); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px 12px;
  font-size: 0.75rem; line-height: 1.8; animation: pop-in .15s ease-out;
  max-width: calc(100vw - 24px); overflow-y: auto;
}
/* 下面放不下時往上長（ui.js placePopover） */
.info-tip-body.is-up, .pop-body.is-up { top: auto; bottom: calc(100% + 6px); }
.home-tl-head .info-tip-body { left: auto; right: 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.link-btn { background: none; border: none; color: var(--accent); font-size: 0.75rem; font-weight: 500; cursor: pointer; padding: 4px 0; font-family: inherit; }

@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ── HOME：Hero ── */
.home-hero {
  position: relative; cursor: pointer;
  background: var(--primary); color: var(--on-primary, var(--bg-base));
  border-radius: 20px; padding: 18px 18px 14px; margin-bottom: 10px;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--primary) 70%, transparent);
  animation: rise .45s cubic-bezier(.2,.8,.2,1) both;
}
/* 右上角的光暈：另外包一層裁切，Hero 本身不裁切，計算方式的氣泡才能超出卡片 */
.hero-glow { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.hero-glow::before {
  content: ""; position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22), rgba(255,255,255,0) 70%); pointer-events: none;
}
.home-hero.is-over { background: var(--red-mid); --on-primary: #ffffff; }
.hero-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hero-label { font-size: 0.8125rem; font-weight: 600; opacity: .9; }
.hero-range { font-size: 0.6875rem; opacity: .75; white-space: nowrap; }
.hero-amount { font-size: 2.5rem; font-weight: 800; letter-spacing: -1px; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero-sub { font-size: 0.75rem; opacity: .85; margin-bottom: 14px; }
.hero-sub b { font-weight: 700; }
/* 接下來 收… 支…：兩格各自輪播（home.js _startHeroTicker），新的一筆從下面滑上來；不標收／支，靠 +／− 和顏色分 */
.hero-next { display: flex; align-items: center; gap: 14px; min-width: 0; }
.hero-next .hn-k { flex-shrink: 0; margin-right: -14px; } /* 「接下來｜」直接接第一筆，不留間距 */
.hn-bar { opacity: .5; margin: 0 2px; }
/* 每格寬度跟著內容（最長那筆），不再左右各佔一半；空間不夠時一起縮 */
.hn-slot { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; }
.hn-d { opacity: .8; margin-right: 4px; }
/* 收綠支紅：跟 Hero 上的文字色混色，深淺主色上都看得清楚；超支（紅底）時不上色 */
.hn-pos { color: color-mix(in srgb, var(--green-mid) 55%, var(--on-primary, #fff)); }
.hn-neg { color: color-mix(in srgb, var(--red-mid) 55%, var(--on-primary, #fff)); }
.home-hero.is-over :is(.hn-pos, .hn-neg) { color: inherit; }
/* 所有項目疊在同一格（grid 1/1）：寬度取最寬的，最小可縮到 0 再用「…」 */
.hn-vp { display: grid; grid-template-columns: minmax(0, max-content); min-width: 0; height: 1.5em; overflow: hidden; }
.hn-item { grid-area: 1 / 1; min-width: 0; line-height: 1.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hn-sz { visibility: hidden; }
.hn-item.is-done { opacity: .6; } /* 這個月日期已過的 */
.hn-in { animation: hn-in .45s cubic-bezier(.2,.8,.2,1) both; }
.hn-out { animation: hn-out .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes hn-in { from { transform: translateY(100%); opacity: 0; } to { transform: none; } }
@keyframes hn-out { from { transform: none; } to { transform: translateY(-100%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hn-in, .hn-out { animation: none; } }
.hero-note { display: inline-block; font-size: 0.625rem; font-weight: 600; padding: 1px 8px; margin-bottom: 4px; border-radius: 8px; background: color-mix(in srgb, var(--on-primary, var(--bg-base)) 18%, transparent); }
/* 計算方式：右上小按鈕＋展開面板 */
.hero-top-r { display: inline-flex; align-items: center; gap: 6px; }
/* 計算方式的氣泡（.pop / .opt-btn 共用樣式在下面藍圖總覽那段） */
/* 卡片有淡入動畫（transform）會各自成為一層，後面的 KPI 卡會蓋住氣泡：有氣泡的卡片整張墊高 */
.home-hero, .bucket-overview { z-index: 3; }
.hero-pop .pop-body { left: auto; right: -6px; width: 280px; cursor: default; }
.hero-opts-title { font-size: 0.75rem; font-weight: 700; color: var(--title-on-bg-surface); margin-bottom: 4px; }
.hero-opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 0.5px solid var(--border); cursor: pointer; }
.hero-opt-row > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-opt-row b { font-size: 0.8125rem; font-weight: 600; }
.hero-opt-row small { font-size: 0.6875rem; color: var(--text3-on-bg-surface); }
.hero-opts-note { font-size: 0.6875rem; color: var(--text3-on-bg-surface); line-height: 1.6; padding-top: 6px; border-top: 0.5px solid var(--border); }
.hero-bar { position: relative; display: flex; height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--on-primary, var(--bg-base)) 22%, transparent); }
.hero-bar .hb-seg { height: 100%; transform-origin: left; animation: grow-x .7s cubic-bezier(.2,.8,.2,1) both; }
.hero-bar .hb-seg:first-child { border-radius: 6px 0 0 6px; }
.hb-fixed  { background: color-mix(in srgb, var(--on-primary, var(--bg-base)) 45%, transparent); }
.hb-exp    { background: color-mix(in srgb, var(--on-primary, var(--bg-base)) 70%, transparent); }
.hb-bucket { background: var(--on-primary, var(--bg-base)); }
.hero-bar .hb-exp { animation-delay: .08s; }
.hero-bar .hb-bucket { animation-delay: .16s; }
.hb-today { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--on-primary, var(--bg-base)); box-shadow: 0 0 0 2px var(--primary); }
.home-hero.is-over .hb-today { box-shadow: 0 0 0 2px var(--red-mid); }
.hero-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.6875rem; margin-top: 10px; opacity: .9; }
.hero-legend span { display: inline-flex; align-items: center; }
.hero-legend .hb-dot { border-radius: 50%; }
.hero-legend-income { margin-left: auto; font-weight: 600; }

/* ── HOME：KPI ── */
.home-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--bg-surface); border: 0.5px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px; cursor: pointer; font-family: inherit; color: inherit; min-width: 0;
  animation: rise .45s .06s cubic-bezier(.2,.8,.2,1) both; transition: transform .12s;
}
.kpi:active { transform: scale(.97); }
.kpi-label { font-size: 0.625rem; font-weight: 600; color: var(--text3-on-bg-surface); letter-spacing: .04em; }
/* 藍圖完成度有套用藍圖頁的篩選時，標題後面綴一個小篩選圖示 */
.kpi-filtered { display: inline-flex; vertical-align: -1px; margin-left: 3px; }
.kpi-filtered svg { width: 10px; height: 10px; }
.kpi-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 4px; }
.kpi-val { font-size: 1.0625rem; font-weight: 700; color: var(--title-on-bg-surface); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-val.neg { color: var(--red-mid); }
.kpi-sub { font-size: 0.625rem; color: var(--text3-on-bg-surface); }
.kpi-ellipsis { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-ring { width: 22px; height: 22px; flex-shrink: 0; }
.kpi-ring-track { fill: none; stroke: var(--bg-surface2); stroke-width: 5; }
.kpi-ring-fill { fill: none; stroke: var(--chart-bucket); stroke-width: 5; stroke-linecap: round; }

/* ── HOME：卡片 ── */
.home-card { background: var(--bg-surface); border: 0.5px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 10px; animation: rise .45s .12s cubic-bezier(.2,.8,.2,1) both; }
.home-section-title { font-size: 0.8125rem; font-weight: 700; color: var(--title-on-bg-surface); }

/* ── HOME：時間軸 ── */
.home-tl-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.home-timeline { overflow-x: auto; overflow-y: hidden; margin: 0 -14px; padding: 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.home-timeline::-webkit-scrollbar { display: none; }
@media (hover: hover) and (pointer: fine) { .home-timeline { cursor: grab; } .home-timeline.dragging { cursor: grabbing; user-select: none; } .home-timeline.dragging .tl-hit { cursor: grabbing; } }
.tl-svg { display: block; }
.tl-k-income { border: 1.5px dashed var(--text3-on-bg-surface); background: transparent; }
.tl-k-fixed { background: var(--chart-fixed); }
.tl-k-exp { background: var(--chart-exp); }
.tl-k-bucket { background: var(--chart-bucket); }
.tl-fixed { fill: var(--chart-fixed); }
.tl-exp { fill: var(--chart-exp); }
.tl-bucket { fill: var(--chart-bucket); }
.hb-line { display: inline-block; width: 14px; height: 2px; background: var(--accent); vertical-align: middle; margin-right: 5px; border-radius: 1px; }
.tl-band-now { fill: var(--accent-bg); }
.tl-sel { fill: none; stroke: var(--accent); stroke-width: 1.5; transition: x .25s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.tl-base { stroke: var(--border2); stroke-width: 1; }
.tl-zero { stroke: var(--red-mid); stroke-width: 1; stroke-dasharray: 2 3; opacity: .5; }
.tl-income { fill: none; stroke: var(--text3-on-bg-surface); stroke-width: 1; stroke-dasharray: 3 2; opacity: .7; }
.tl-col { transform-box: fill-box; transform-origin: bottom; animation: grow-y .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: var(--d); }
.tl-col.is-past { opacity: .78; }
.tl-col.is-future .tl-seg { opacity: .38; }
.tl-col.is-future .tl-income { opacity: .35; }
.tl-line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 4000; stroke-dashoffset: 4000; animation: draw 1.4s .2s ease-out forwards; }
.tl-line.is-future { stroke-width: 1.6; opacity: .45; }
.tl-dot { fill: var(--bg-surface); stroke: var(--accent); stroke-width: 1.6; }
.tl-dot.neg { stroke: var(--red-mid); }
.tl-label { font-size: 0.6875rem; text-anchor: middle; fill: var(--text3-on-bg-surface); }
.tl-label.is-now { fill: var(--accent); font-weight: 700; }
.tl-year { font-size: 0.5625rem; text-anchor: middle; fill: var(--text3-on-bg-surface); opacity: .8; }
.tl-flag path { fill: var(--chart-exp); stroke: var(--chart-exp); stroke-width: 1.4; stroke-linejoin: round; }
.tl-sticker { fill: var(--accent); }
.tl-hit { fill: transparent; cursor: pointer; }

/* 時間軸：回到本月鈕、左右懸浮箭頭 */
.tl-today-btn {
  margin-left: auto; margin-right: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px 3px 8px; border-radius: 999px; border: none; cursor: pointer; font-family: inherit;
  font-size: 0.75rem; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); transition: opacity .15s;
}
.tl-today-btn.is-current { opacity: .4; cursor: default; }
.tl-scroller { position: relative; }
.tl-arrow {
  position: absolute; top: 42%; transform: translateY(-50%); z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; display: none; align-items: center; justify-content: center;
  border: 0.5px solid var(--border2); background: var(--bg-surface); color: var(--accent); cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,.14); transition: opacity .15s, transform .12s;
}
.tl-arrow.prev { left: -6px; }
.tl-arrow.next { right: -6px; }
.tl-arrow:hover:not(:disabled) { background: var(--accent-bg); }
.tl-arrow:active:not(:disabled) { transform: translateY(-50%) scale(.92); }
.tl-arrow:disabled { opacity: 0; pointer-events: none; }
/* 有滑鼠的裝置才顯示（手機用手指滑就好，按鈕會擋到柱子） */
@media (hover: hover) and (pointer: fine) { .tl-arrow { display: inline-flex; } }
.home-tl-detail { border-top: 0.5px solid var(--border); margin-top: 6px; padding-top: 12px; touch-action: pan-y; }
.home-tl-detail.tld-in-next { animation: tld-in-next .26s cubic-bezier(.2,.8,.2,1); }
.home-tl-detail.tld-in-prev { animation: tld-in-prev .26s cubic-bezier(.2,.8,.2,1); }
@keyframes tld-in-next { from { transform: translateX(36px); opacity: 0; } }
@keyframes tld-in-prev { from { transform: translateX(-36px); opacity: 0; } }
/* 時間軸可以往左右捲時，兩側淡出提示還有內容 */
.home-timeline.can-left  { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px); mask-image: linear-gradient(to right, transparent, #000 28px); }
.home-timeline.can-right { -webkit-mask-image: linear-gradient(to left, transparent, #000 28px); mask-image: linear-gradient(to left, transparent, #000 28px); }
.home-timeline.can-left.can-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.tld-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tld-title { font-size: 0.9375rem; font-weight: 700; color: var(--title-on-bg-surface); display: inline-flex; align-items: center; gap: 6px; }
.tld-sticker { display: inline-flex; width: 14px; height: 14px; color: var(--accent); }
.tld-sticker svg { width: 100%; height: 100%; }
.tld-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tld-grid > div { display: flex; flex-direction: column; gap: 1px; }
.tld-k { font-size: 0.625rem; color: var(--text3-on-bg-surface); }
.tld-v { font-size: 0.875rem; font-weight: 700; color: var(--text-on-bg-surface); font-variant-numeric: tabular-nums; }
.tld-v.pos { color: var(--green-pos-mid); }
.tld-v.neg { color: var(--red-mid); }
.tld-goals { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tld-goal { font-size: 0.75rem; font-weight: 600; background: var(--label-goal-bg); color: var(--title-on-label-goal-bg); border-radius: 12px; padding: 3px 10px; }
.tld-actions { display: flex; gap: 8px; margin-top: 12px; }
.tld-btn { flex: 1; padding: 9px 0; border-radius: var(--r-sm); border: 0.5px solid var(--border2); background: var(--bg-surface3); color: var(--text2-on-bg-surface3); font-size: 0.8125rem; font-family: inherit; cursor: pointer; }
.tld-btn.primary { flex: 2; background: var(--accent-bg); border-color: transparent; color: var(--accent); font-weight: 600; }

/* ── HOME：本月消費 ── */
.hi-head { display: flex; align-items: center; justify-content: space-between; }
.hi-total { font-size: 1.375rem; font-weight: 800; color: var(--title-on-bg-surface); margin: 4px 0 10px; display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.hi-diff { font-size: 0.6875rem; font-weight: 600; }
.hi-diff.up { color: var(--red-mid); }
.hi-diff.down { color: var(--green-pos-mid); }
.hi-list { display: flex; flex-direction: column; gap: 9px; }
.hi-row { display: flex; align-items: center; gap: 8px; }
.hi-icon { display: flex; width: 16px; height: 16px; }
.hi-name { font-size: 0.8125rem; width: 48px; flex-shrink: 0; color: var(--text-on-bg-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-bar { flex: 1; height: 8px; background: var(--bg-surface2); border-radius: 4px; overflow: hidden; }
.hi-bar span { display: block; height: 100%; border-radius: 4px; transform-origin: left; animation: grow-x .7s cubic-bezier(.2,.8,.2,1) both; }
.hi-amt { font-size: 0.75rem; font-weight: 600; width: 56px; text-align: right; color: var(--text-on-bg-surface); }
.hi-empty { font-size: 0.8125rem; color: var(--text3-on-bg-surface); padding: 14px 0 4px; }

/* 主頁快速記帳：右下角浮動膠囊鈕，不擋內容 */
.home-quick-btn-wrap { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; pointer-events: none; z-index: 90; }
.home-quick-btn {
  pointer-events: auto; width: auto; margin-left: auto; margin-right: 16px; display: flex; align-items: center; gap: 6px;
  padding: 13px 18px; background: var(--primary); color: var(--on-primary, var(--bg-base)); border: none; border-radius: 28px;
  font-size: 0.875rem; font-weight: 700; font-family: inherit; cursor: pointer;
  box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--primary) 80%, transparent), 0 2px 6px rgba(0,0,0,.12);
  transition: transform .12s;
}
.home-quick-btn:active { transform: scale(.95); }

/* ── LEDGER：Hero ── */
.ledger-hero { background: var(--bg-surface); border: 0.5px solid var(--border); border-radius: 16px; padding: 14px 16px 10px; margin-bottom: 12px; }
.lh-top { display: flex; justify-content: space-between; align-items: baseline; }
.lh-label { font-size: 0.75rem; font-weight: 600; color: var(--text2-on-bg-surface); }
.lh-cum { font-size: 0.6875rem; color: var(--text3-on-bg-surface); }
.lh-amount { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; color: var(--green-pos-mid); font-variant-numeric: tabular-nums; line-height: 1.2; margin: 2px 0 10px; }
.lh-amount.neg { color: var(--red-mid); }
.lh-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--bg-surface2); gap: 2px; }
.lh-bar span { height: 100%; transform-origin: left; animation: grow-x .6s cubic-bezier(.2,.8,.2,1) both; }
.lh-eq { font-size: 0.6875rem; color: var(--text3-on-bg-surface); margin-top: 8px; }
.lh-details { margin-top: 8px; }
.lh-details > summary { font-size: 0.75rem; }
.lh-details .balance-footer { border: none; padding: 8px 0 4px; margin: 0; background: none; }
.bal-row .val.pos { color: var(--green-pos); }
.bal-row .val.neg { color: var(--red); }
.ledger-title { display: inline-flex; align-items: center; }
.ledger-title .lg-dot { border-radius: 50%; margin-right: 8px; }
.ledger-tag { font-size: 0.6875rem; font-weight: 400; color: var(--text3-on-bg-surface); margin-left: 8px; }
.add-line.subtle { color: var(--text3-on-bg-surface); font-size: 0.75rem; padding: 8px; }

/* ── BUCKETS：總覽 ── */
.bucket-overview { position: relative; display: flex; align-items: center; gap: 16px; background: var(--bg-surface); border: 0.5px solid var(--border); border-radius: 16px; padding: 14px 16px; margin: 12px 0 18px; }
.bo-ring { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.bo-ring svg { width: 100%; height: 100%; }
.bo-track { fill: none; stroke: var(--bg-surface2); stroke-width: 4; }
.bo-fill { fill: none; stroke: var(--chart-bucket); stroke-width: 4; stroke-linecap: round; }
.bo-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.9375rem; font-weight: 800; color: var(--title-on-bg-surface); }
.bo-label { font-size: 0.6875rem; color: var(--text3-on-bg-surface); font-weight: 600; }
.bo-val { font-size: 1.5rem; font-weight: 800; color: var(--title-on-bg-surface); font-variant-numeric: tabular-nums; }
.bo-sub { font-size: 0.75rem; color: var(--text2-on-bg-surface); }
.bo-note { font-size: 0.6875rem; color: var(--text3-on-bg-surface); margin-top: 2px; }
.bo-note[hidden] { display: none; }
/* 總覽卡片右上角的漏斗 */
.bo-filter { position: absolute; top: 8px; right: 8px; }
/* 設定／篩選按鈕（共用）：滑過變底色，打開時主題色＋氣泡 */
.opt-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; color: var(--text3-on-bg-surface); border: 0.5px solid transparent; transition: background .15s; }
.opt-btn:hover { background: var(--bg-surface2); }
.pop[open] > .opt-btn { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
/* 在主色的 Hero 上：滑過半透明底，打開時反白（主題色底上的主題色看不到） */
.home-hero .opt-btn { width: 26px; height: 26px; margin: -6px -6px -6px 0; color: inherit; opacity: .8; }
.home-hero .opt-btn:hover { opacity: 1; background: color-mix(in srgb, var(--on-primary, var(--bg-base)) 18%, transparent); }
.home-hero .pop[open] > .opt-btn { opacity: 1; background: var(--on-primary, var(--bg-base)); color: var(--primary); border-color: transparent; }
.home-hero.is-over .pop[open] > .opt-btn { color: var(--red-mid); }
.pop-body.no-anim { animation: none; }
.bo-funnel .pop-body { left: auto; right: 0; }
.bo-filter[hidden] { display: none; }
/* 藍圖總覽的漏斗篩選：展開面板（buckets.js _bucketFilterHtml） */
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-body {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: 240px; max-width: calc(100vw - 24px);
  background: var(--bg-surface); color: var(--text-on-bg-surface);
  border: 0.5px solid var(--border2); border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px 12px; text-align: left;
  font-size: 0.75rem; animation: pop-in .15s ease-out;
}
.bf-group + .bf-group { margin-top: 10px; }
.bf-title { font-size: 0.6875rem; font-weight: 600; color: var(--text3-on-bg-surface); margin-bottom: 4px; }
.bf-opts { display: flex; gap: 14px; }
.bf-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; cursor: pointer; user-select: none; }
.bf-opt input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.bf-opt.is-locked { opacity: .6; cursor: default; }
.bf-foot { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 6px; border-top: 0.5px solid var(--border); }
.bf-foot[hidden] { display: none; }
.bucket-group-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 10px; }

/* ── ANALYSIS ── */
.an-card { background: var(--bg-surface); border: 0.5px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.an-card-title { font-size: 0.8125rem; font-weight: 700; color: var(--title-on-bg-surface); display: flex; align-items: baseline; gap: 8px; }
.an-card-hint { font-size: 0.6875rem; font-weight: 400; color: var(--text3-on-bg-surface); }
.an-summary { background: var(--primary); color: var(--on-primary, var(--bg-base)); border: none; }
.an-sum-head { display: flex; justify-content: space-between; align-items: center; }
.an-sum-label { font-size: 0.75rem; font-weight: 600; opacity: .9; }
.an-sum-big { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.an-sum-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.an-sum-row > div { display: flex; flex-direction: column; }
.an-k { font-size: 0.625rem; opacity: .75; }
.an-v { font-size: 0.9375rem; font-weight: 700; }
.an-donut-wrap { position: relative; width: 150px; height: 150px; margin: 14px auto 16px; }
.an-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.an-total-label { font-size: 0.625rem; color: var(--text3-on-bg-surface); }
.an-total-val { font-size: 0.9375rem; font-weight: 800; color: var(--title-on-bg-surface); }
.an-cat-list { display: flex; flex-direction: column; }
.an-cat-item { border-radius: var(--r-sm); }
.an-cat-item.open { background: var(--bg-surface3); }
.an-cat-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 6px; background: none; border: none; font-family: inherit; color: var(--text-on-bg-surface); cursor: pointer; text-align: left; }
.an-cat-icon { width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.an-cat-name { font-size: 0.8125rem; flex-shrink: 0; width: 48px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-cat-bar-wrap { flex: 1; height: 6px; background: var(--bg-surface2); border-radius: 3px; overflow: hidden; }
.an-cat-bar-fill { display: block; height: 100%; border-radius: 3px; transform-origin: left; animation: grow-x .6s cubic-bezier(.2,.8,.2,1) both; }
.an-cat-pct { font-size: 0.6875rem; color: var(--text3-on-bg-surface); width: 30px; text-align: right; flex-shrink: 0; }
.an-cat-amt { font-size: 0.75rem; font-weight: 700; width: 56px; text-align: right; flex-shrink: 0; }
.an-cat-detail { padding: 0 6px 8px 30px; animation: rise .2s ease-out; }
.an-cd-row { display: flex; gap: 8px; font-size: 0.75rem; padding: 4px 0; border-top: 0.5px solid var(--border); color: var(--text2-on-bg-surface); }
.an-cd-date { width: 40px; flex-shrink: 0; color: var(--text3-on-bg-surface); }
.an-cd-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-on-bg-surface); }
.an-cd-amt { font-weight: 600; }
.an-cd-more { font-size: 0.6875rem; color: var(--text3-on-bg-surface); padding-top: 4px; }
.an-empty { text-align: center; padding: 28px 0 12px; font-size: 0.8125rem; color: var(--text3-on-bg-surface); }
.tr-svg { width: 100%; height: auto; display: block; margin-top: 10px; }
.tr-base { stroke: var(--border2); }
.tr-bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y .55s cubic-bezier(.2,.8,.2,1) both; }
.tr-inc { fill: var(--green-pos-mid); }
.tr-out { fill: var(--chart-exp); }
.tr-bar.is-future { opacity: .4; }
.tr-net { fill: none; stroke: var(--title-on-bg-surface); stroke-width: 1.4; stroke-dasharray: 3 3; opacity: .55; }
.tr-dot { fill: var(--bg-surface); stroke: var(--title-on-bg-surface); stroke-width: 1.4; }
.tr-dot.neg { stroke: var(--red-mid); }
.tr-label { font-size: 0.5625rem; text-anchor: middle; fill: var(--text3-on-bg-surface); }
.tr-sel { fill: var(--accent-bg); }
.tr-hit { fill: transparent; cursor: pointer; }
.tr-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 0.75rem; color: var(--text-on-bg-surface); margin-top: 6px; min-height: 22px; }
.tr-caption span { display: inline-flex; align-items: center; }
.tr-legend { color: var(--text3-on-bg-surface); font-size: 0.6875rem; }
.tr-k-inc { background: var(--green-pos-mid); }
.tr-k-out { background: var(--chart-exp); }
.tr-k-net { background: transparent; border: 1.4px solid var(--title-on-bg-surface); border-radius: 50%; }
.an-item-group-label { font-size: 0.6875rem; font-weight: 600; color: var(--text3-on-bg-surface); margin: 12px 0 4px; }

@media (prefers-reduced-motion: reduce) {
  .home-hero, .kpi, .home-card, .tl-col, .hero-bar .hb-seg, .hi-bar span, .lh-bar span, .tr-bar, .an-cat-bar-fill { animation: none; }
  .tl-line { animation: none; stroke-dashoffset: 0; }
}

/* ── 每月帳目：本月調整標籤、日期分組、階段標籤 ── */
.ledger-adj-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px; font-size: 0.625rem; font-weight: 600; vertical-align: 1px; background: var(--accent-bg); color: var(--accent); }
.line-edit { font-size: 0.6875rem; color: var(--text3-on-bg-surface); display: inline-flex; }
.line-sub { margin-left: 0; }
.ledger-date-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 14px 4px; font-size: 0.75rem; font-weight: 700; color: var(--text2-on-bg-surface2);
  background: var(--bg-surface2); border-bottom: 0.5px solid var(--border);
}
.ledger-date-head small { font-weight: 400; margin-left: 6px; color: var(--text3-on-bg-surface2); }
.ledger-date-head .number-mask { font-weight: 600; }
.lh-label { display: inline-flex; align-items: center; gap: 8px; }
.lh-label .phase-pill { font-size: 0.625rem; padding: 1px 8px; }

/* ── 行事曆：右欄空狀態、當天消費可點 ── */
.cal-ev-empty { font-size: 0.8125rem; color: var(--text2-on-bg-base); padding: 18px 4px; line-height: 1.7; }
.cal-ev-empty small { color: var(--text3-on-bg-base); }

/* ── 帳目分析：分類走勢、固定收支與藍圖比較 ── */
.an-title-row { justify-content: space-between; align-items: center; flex-wrap: wrap; row-gap: 6px; }
.an-title-row .link-btn { font-size: 0.75rem; }
.tr-avg { stroke: var(--title-on-bg-surface); stroke-width: 1; stroke-dasharray: 4 3; opacity: .45; }
.an-cat-item.open .an-cat-row { font-weight: 700; }
.fx-mode .an-period-btn { padding: 4px 10px; font-size: 0.6875rem; }
.fx-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 6px; border: none; border-radius: var(--r-sm);
  background: none; font-family: inherit; color: var(--text-on-bg-surface); cursor: pointer; text-align: left;
}
.fx-row:hover { background: var(--bg-surface2); }
.fx-row.is-total .fx-name { font-weight: 700; }
.fx-check { width: 16px; height: 16px; flex-shrink: 0; border-radius: 4px; border: 1.5px solid var(--border2); position: relative; }
.fx-row.on .fx-check::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.fx-name { flex: 1; min-width: 0; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-val { font-size: 0.75rem; font-weight: 600; color: var(--text2-on-bg-surface); }
.fx-grid { stroke: var(--border); stroke-width: 1; }
.fx-axis { font-size: 8px; text-anchor: end; fill: var(--text3-on-bg-surface); }
.fx-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.fx-dot { fill: var(--bg-surface); stroke-width: 1.6; }
.fx-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 0.75rem; color: var(--text-on-bg-surface); margin-top: 6px; }
.fx-legend span { display: inline-flex; align-items: center; }
.fx-legend small { color: var(--text3-on-bg-surface); margin-left: 2px; }

/* ── 帳目分析入口：主頁卡片 ── */
.home-an-link {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 10px; padding: 12px 14px;
  border: 0.5px solid var(--border); border-radius: 16px; background: var(--bg-surface); cursor: pointer;
  font-family: inherit; text-align: left; color: var(--text-on-bg-surface); animation: rise .45s .1s cubic-bezier(.2,.8,.2,1) both;
}
.home-an-link:hover { border-color: var(--accent); }
.home-an-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-bg); color: var(--accent); }
.home-an-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.home-an-text b { font-size: 0.875rem; color: var(--title-on-bg-surface); }
.home-an-text small { font-size: 0.6875rem; color: var(--text3-on-bg-surface); }
.home-an-go { color: var(--accent); font-weight: 700; }
.lh-eq-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ── 旅遊帳本（trip.js） ── */
.trip-card { padding: 14px 16px; margin-bottom: 12px; }
.trip-card .home-section-title { display: block; margin-bottom: 8px; }
.trip-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 0; font-size: 0.8125rem; color: var(--text-on-bg-surface); border-bottom: 0.5px solid var(--border); }
.trip-row:last-of-type { border-bottom: none; }
.trip-row small { display: block; font-size: 0.6875rem; color: var(--text3-on-bg-surface); text-align: right; }
.trip-row span > small { display: inline; margin-left: 6px; }
.trip-empty { font-size: 0.75rem; color: var(--text3-on-bg-surface); line-height: 1.6; padding: 4px 0; }
.trip-cat { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 8px; padding: 5px 0; font-size: 0.8125rem; color: var(--text-on-bg-surface); }
.trip-cat-name { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; }
.trip-cat-name svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); }
.trip-cat-bar { height: 8px; border-radius: 4px; background: var(--bg-surface2); overflow: hidden; }
.trip-cat-bar i { display: block; height: 100%; border-radius: 4px; background: var(--chart-exp); }
.trip-cat-amt { font-variant-numeric: tabular-nums; }
.trip-members { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 0.6875rem; color: var(--text3-on-bg-surface); }
.trip-actions { display: flex; gap: 8px; margin-top: 10px; }
.trip-actions .action-btn { padding: 9px 0; font-size: 0.8125rem; }
.trip-warn, .trip-hint-btn { display: block; width: 100%; text-align: left; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--r-md); font-size: 0.75rem; font-family: inherit; cursor: pointer; }
.trip-warn { background: var(--red-bg); color: var(--red); border: 0.5px solid var(--red-mid); }
.trip-hint-btn { background: var(--bg-surface); color: var(--text2-on-bg-surface); border: 0.5px dashed var(--border2); }
.trip-settings-btn { width: 100%; padding: 11px 0; margin: 4px 0 96px; font-size: 0.8125rem; }
#trip-days { padding-bottom: 96px; }
.trip-entry-title { font-size: 0.9375rem; font-weight: 600; color: var(--title-on-bg-surface); }
.trip-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trip-form-hint { font-size: 0.6875rem; color: var(--text3-on-bg-surface); line-height: 1.6; margin-top: 6px; }
.ts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ts-row .form-input { flex: 1; min-width: 0; }
.ts-cur { font-size: 0.8125rem; color: var(--text-on-bg-surface); min-width: 4.5em; }
.ts-eq { font-size: 0.75rem; color: var(--text3-on-bg-surface); white-space: nowrap; }
.ts-row .ts-rate { flex: 0 1 96px; text-align: right; }
.ts-del { background: none; border: none; color: var(--text3-on-bg-surface); font-size: 1.125rem; cursor: pointer; padding: 2px 6px; }
/* 藍圖頁的旅遊引導 */
.trip-guide { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin: 0 0 6px; padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-bg); border: 1px solid var(--accent); color: var(--accent); font-family: inherit; cursor: pointer; }
.trip-guide-icon svg { width: 26px; height: 26px; display: block; }
.trip-guide-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trip-guide-text b { font-size: 0.875rem; }
.trip-guide-text small { font-size: 0.6875rem; opacity: .8; line-height: 1.5; }
.trip-guide-go { font-size: 1.25rem; opacity: .7; }
.bucket-trip-line { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 2px; }
.bucket-trip-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); background: none; border: 0.5px dashed var(--accent); color: var(--accent); font-size: 0.75rem; font-family: inherit; cursor: pointer; text-align: left; }
.bucket-trip-btn.on { border-style: solid; background: var(--accent-bg); }
.bucket-trip-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.bucket-trip-btn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 財務分析：最上面的分析方式分頁 ── */
.an-modes { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 0.5px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.an-modes::-webkit-scrollbar { display: none; }
.an-mode-btn {
  flex-shrink: 0; padding: 8px 12px 9px; border: none; background: none; font-family: inherit; font-size: 0.8125rem; font-weight: 600;
  color: var(--text3-on-bg-base); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -0.5px;
}
.an-mode-btn:hover { color: var(--text-on-bg-base); }
.an-mode-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.an-shared-nav[hidden] { display: none; }
.analysis-body.is-single { display: block; max-width: 760px; margin: 0 auto; }

/* ── 財務分析：跳到當月帳目、歷史最高／最低 ── */
.an-sum-link { background: none; border: none; padding: 2px 0; margin-right: 2px; /* 中文字左邊自帶約 2px 字距，右邊的 › 沒有：補回來讓左右看起來等距 */ font: inherit; font-size: 0.75rem; font-weight: 600; color: inherit; opacity: .9; cursor: pointer; }
.an-sum-link:hover { opacity: 1; text-decoration: underline; }
.tr-caption .an-goto, .fx-legend .an-goto { margin-left: auto; }
.rec-tabs { margin: 10px 0 2px; overflow-x: auto; scrollbar-width: none; }
.rec-tabs::-webkit-scrollbar { display: none; }
.rec-tabs .an-period-btn { flex: 1 0 auto; padding: 5px 12px; white-space: nowrap; }
.rec-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 0.5px solid var(--border); }
.an-item-group-label + .rec-row { border-top: none; }
.rec-name { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; }
.rec-name .an-cat-icon, .rec-name .line-icon-wrap { flex-shrink: 0; }
.rec-title { font-size: 0.8125rem; font-weight: 600; color: var(--text-on-bg-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.rec-name small { flex-basis: 100%; font-size: 0.6875rem; color: var(--text3-on-bg-surface); line-height: 1.5; }
.rec-cells { display: flex; gap: 6px; flex-shrink: 0; }
.rec-cell {
  display: flex; flex-direction: column; align-items: flex-end; min-width: 76px; max-width: 120px; padding: 4px 8px;
  border: none; border-radius: var(--r-sm); background: var(--bg-surface2); font-family: inherit; cursor: pointer; text-align: right;
}
.rec-cell:hover { background: var(--accent-bg); }
.rec-k { font-size: 0.625rem; color: var(--text3-on-bg-surface); }
.rec-cell b { font-size: 0.8125rem; color: var(--title-on-bg-surface); font-variant-numeric: tabular-nums; }
.rec-cell.hi b { color: var(--accent); }
.rec-cell small { font-size: 0.625rem; color: var(--text2-on-bg-surface); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-foot { margin-top: 10px; line-height: 1.6; }
