/* === 外觀_深色模式.css (V10 Fixed - Dark Mode Enhanced) === */
/* 職責:深色模式專用樣式 + 視覺優化 */
/* 依賴:必須在 外觀_視覺風格.css 之後載入 */

/* === CSS 變數系統 === */
:root {
    /* Light Mode (預設值) */
    --bg-primary: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 100%);
    --bg-card: #ffffff;
    --bg-card-hover: linear-gradient(135deg, #ffffff, #f8fafc);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border-primary: rgba(226, 232, 240, 0.8);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08), 0 12px 28px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.10), 0 16px 32px rgba(0, 0, 0, 0.06);
    --accent-blue: #1d4ed8;
    --accent-emerald: #059669;
    --accent-rose: #e11d48;
}

/* === Dark Mode (Obsidian Fixed - Enhanced Contrast) === */
[data-theme="dark"] {
    /* 背景：深黑藍 */
    --bg-primary: linear-gradient(135deg, #0a0e1a 0%, #0f1419 100%);
    
    /* 卡片：深灰藍（加強對比） */
    --bg-card: #1e293b;  /* Slate-900 - 統一使用 */
    --bg-card-hover: linear-gradient(135deg, #1e293b, #334155);
    
    /* 文字：高對比白色系統 */
    --text-primary: #f1f5f9;   /* Slate-100 */
    --text-secondary: #cbd5e1; /* Slate-300 */
    --text-tertiary: #94a3b8;  /* Slate-400 */
    
    /* 邊框：半透明白色（加強可見度） */
    --border-primary: rgba(148, 163, 184, 0.25);  /* 從 0.12 提升到 0.25 */
    
    /* 陰影：深色強化 */
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.6), 0 16px 40px rgba(0, 0, 0, 0.4);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.7), 0 20px 48px rgba(0, 0, 0, 0.5);
    
    /* 強調色：高飽和度 */
    --accent-blue: #60a5fa;
    --accent-emerald: #00d4aa;
    --accent-rose: #fb7185;
    --accent-amber: #ffa500;
}

/* === 全域覆寫 (使用 CSS 變數) === */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s;
}

/* === 卡片系統 === */
.glass-card,
.card-elevated,
.collapse-shell,
.diagram-card,
.kpi-card,
.stack-group {
    background: var(--bg-card);
    border-color: var(--border-primary);
    box-shadow: var(--shadow-card);
    transition: all 0.3s;
}

.glass-card:hover,
.card-elevated:hover,
.kpi-card:hover {
    box-shadow: var(--shadow-card-hover);
}

/* Diagram Card 特殊背景 */
[data-theme="dark"] .diagram-card {
    background: linear-gradient(135deg, #0f1419 0%, #141a22 100%);
}

/* === Typography === */
.label-text,
.kpi-value-primary,
.kpi-value-secondary,
.matrix-table td {
    color: var(--text-primary);
}

.sub-label,
.kpi-title-zh,
.kpi-footer-text,
.matrix-table th,
.group-hint {
    color: var(--text-secondary);
}

.kpi-title-en,
.kpi-label-sm,
.kpi-unit-primary,
.kpi-unit-secondary {
    color: var(--text-tertiary);
}

/* === 深色模式專用:顏色覆寫 === */
[data-theme="dark"] .text-rose-500 {
    color: var(--accent-rose);
}

[data-theme="dark"] .status-ok {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 8px var(--accent-emerald);
}

[data-theme="dark"] .status-pill.safe {
    background-color: rgba(0, 212, 170, 0.15);
    color: var(--accent-emerald);
    border-color: rgba(0, 212, 170, 0.3);
}

/* === 深色模式:輸入框 (加強對比) === */
[data-theme="dark"] input.editable,
[data-theme="dark"] input.editable-clean,
[data-theme="dark"] input.editable-sm {
    background-color: rgba(51, 65, 85, 0.5) !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
    color: #f1f5f9 !important;
}

[data-theme="dark"] input.editable:focus,
[data-theme="dark"] input.editable-clean:focus {
    background-color: rgba(51, 65, 85, 0.6);
    border-color: #60a5fa;
    color: #93c5fd;
}

/* === 深色模式:Command Bar (加強對比) === */
[data-theme="dark"] .command-bar {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(16px);
}

[data-theme="dark"] .cmd-btn {
    background: rgba(51, 65, 85, 0.6);
    border-color: rgba(148, 163, 184, 0.35);
    color: #cbd5e1;
}

[data-theme="dark"] .cmd-btn:hover {
    background: rgba(71, 85, 105, 0.8);
    border-color: rgba(96, 165, 250, 0.5);
}

[data-theme="dark"] .cmd-pill {
    background: rgba(51, 65, 85, 0.5);
    border-color: rgba(148, 163, 184, 0.3);
}

[data-theme="dark"] .btn-stress {
    background: rgba(51, 65, 85, 0.5);
    border-color: rgba(148, 163, 184, 0.3);
    color: #cbd5e1;
}

[data-theme="dark"] .btn-stress:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #60a5fa;
    color: #93c5fd;
}

/* === 深色模式:隱私遮罩 === */
[data-theme="dark"] .privacy-blur {
    background: linear-gradient(180deg, rgba(51,65,85,0.95), rgba(71,85,105,0.95)) !important;
}

/* === 深色模式:Collapse 區塊 === */
[data-theme="dark"] .collapse-summary {
    background: linear-gradient(120deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .section-header {
    background: linear-gradient(120deg, #0f172a 0%, #1e293b 100%);
}

/* === 深色模式:表格 (加強框線對比) === */
[data-theme="dark"] .matrix-current {
    background-color: rgba(96, 165, 250, 0.15);
    color: var(--accent-blue);
}

[data-theme="dark"] .matrix-table tbody tr:nth-child(odd) td {
    background-color: rgba(51, 65, 85, 0.3);
}

[data-theme="dark"] .matrix-table tbody tr:hover td {
    background-color: rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .matrix-table th,
[data-theme="dark"] .matrix-table td {
    border-color: rgba(148, 163, 184, 0.3) !important;
}

/* === 深色模式:Row Layout === */
[data-theme="dark"] .row-layout {
    border-bottom-color: rgba(148, 163, 184, 0.25);
}

[data-theme="dark"] .row-layout:hover {
    background-color: rgba(51, 65, 85, 0.3);
}

/* === 深色模式:邊框與分隔線 (加強可見度) === */
[data-theme="dark"] .diagram-divider {
    background: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .kpi-footer {
    border-top-color: rgba(148, 163, 184, 0.15);
}

[data-theme="dark"] .kpi-divider {
    background: rgba(148, 163, 184, 0.2);
}

/* === 深色模式:通用邊框加強 === */
[data-theme="dark"] .border-slate-100,
[data-theme="dark"] .border-slate-200,
[data-theme="dark"] .border-gray-100,
[data-theme="dark"] .border-gray-200 {
    border-color: rgba(148, 163, 184, 0.25) !important;
}

/* === V10 Beauty 優化 === */

/* 優化 #1: KPI 卡片內部留白增加 */
.kpi-card {
    padding: 28px;
}

/* 優化 #2: 主數字字重加強 */
.kpi-value-primary {
    font-weight: 900;
    letter-spacing: -0.05em;
}

.kpi-value-secondary {
    font-weight: 900;
    letter-spacing: -0.04em;
    font-size: clamp(28px, 2.8vw, 38px);
}

/* 優化 #4: 顏色飽和度提升 */
.text-rose-500 {
    color: #e11d48;
}

.status-ok {
    background-color: #059669;
}

/* 優化 #5: Hover 效果平滑化 */
.kpi-card,
.glass-card,
.card-elevated,
.collapse-shell,
.diagram-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 優化 #6: 深色模式 Toast */
[data-theme="dark"] .toast {
    background: #1e293b;
    color: #f1f5f9;
    border-left-color: var(--accent-emerald);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.4);
}

/* === 響應式優化 === */
@media (max-width: 640px) {
    .kpi-card {
        padding: 20px;
    }
}

/* === Scrollbar 深色模式 === */
[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569;
    border-color: #1e293b;
}

[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

/* === V10 深色模式 KPI 完整修復 === */

/* KPI 卡片對比加強 */
[data-theme="dark"] .kpi-card {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

/* KPI 1 進度條 */
[data-theme="dark"] .kpi-progress-track {
    background: rgba(148, 163, 184, 0.15);
}

[data-theme="dark"] .kpi-progress-bar {
    background: linear-gradient(90deg, #00d4aa, #00b894);
}

[data-theme="dark"] .kpi-progress-marker {
    background: #00d4aa;
    border-color: #1e293b;
    box-shadow: 0 0 12px #00d4aa;
}

/* KPI 1 右上角百分比 */
[data-theme="dark"] .kpi-progress-percent {
    color: #00d4aa !important;
}

/* KPI 2 標籤 */
[data-theme="dark"] .kpi-label-sm {
    color: #cbd5e1 !important;
}

/* KPI 3 狀態標籤 */
[data-theme="dark"] .kpi-status-label {
    color: #ffa500 !important;
}

/* 所有 KPI 標題統一 */
[data-theme="dark"] .kpi-title-zh,
[data-theme="dark"] .kpi-title-zh-large {
    color: #ffffff !important;
    font-weight: 900;
}

/* KPI 數字顏色：統一紫色 (Doctor 指定) */
[data-theme="dark"] .kpi-value-mega,
[data-theme="dark"] .kpi-value-primary {
    color: #c084fc !important; /* 紫色統一 */
}

/* KPI 2 數字：保持紫色 */
[data-theme="dark"] .kpi-value-secondary {
    color: #c084fc !important; /* 改為紫色統一 */
}

/* KPI 單位顏色 */
[data-theme="dark"] .kpi-unit-primary,
[data-theme="dark"] .kpi-unit-secondary {
    color: rgba(255, 165, 0, 0.6);
}

/* Footer 文字加強 */
[data-theme="dark"] .kpi-footer-text {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .kpi-footer-text .privacy-target {
    color: #e2e8f0 !important;
    font-weight: 900;
}

/* 確保所有數字在深色模式下可見 */
[data-theme="dark"] .privacy-target {
    color: inherit;
}

/* Timeline dots */
[data-theme="dark"] .bg-slate-400 {
    background-color: #64748b !important;
}

[data-theme="dark"] .bg-red-400 {
    background-color: #f87171 !important;
}

[data-theme="dark"] .bg-blue-500 {
    background-color: #3b82f6 !important;
}

[data-theme="dark"] .bg-emerald-500 {
    background-color: #00d4aa !important;
}

/* H1/H2/H3/H4 */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: #ffffff;
}

/* Select 下拉選單 (加強對比) */
[data-theme="dark"] select {
    background-color: rgba(51, 65, 85, 0.6) !important;
    color: #cbd5e1 !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
}

[data-theme="dark"] select:focus {
    border-color: #60a5fa;
}

/* Tip */
[data-theme="dark"] .tip {
    background: #60a5fa;
}

[data-theme="dark"] .tip:hover::after {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 按鈕 */
[data-theme="dark"] .btn-reset {
    background: linear-gradient(to bottom, #334155, #1e293b);
    border-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .btn-reset:hover {
    background: linear-gradient(to bottom, #475569, #334155);
}

/* === 白底卡片修正 (移除光斑) === */

/* 通用白色背景覆寫 */
[data-theme="dark"] .bg-white {
    background: rgba(30, 41, 59, 0.6) !important;
}

/* 市場溫度計小卡片 */
[data-theme="dark"] .glass-card.bg-white,
[data-theme="dark"] [class*="market-mini-card"] {
    background: rgba(30, 41, 59, 0.6) !important;
    border-color: rgba(148, 163, 184, 0.25);
}

/* 股票現值欄位 */
[data-theme="dark"] input[readonly].bg-white,
[data-theme="dark"] .stock-value-display {
    background: rgba(71, 85, 105, 0.3) !important;
    color: #f1f5f9;
    border-color: rgba(148, 163, 184, 0.2);
}

/* === 淡色背景修正 (移除突兀) === */

/* 淡綠色背景 */
[data-theme="dark"] .bg-emerald-50,
[data-theme="dark"] .bg-emerald-50\/50,
[data-theme="dark"] .bg-green-50,
[data-theme="dark"] .bg-green-50\/50 {
    background: rgba(16, 185, 129, 0.1) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

/* 淡黃色背景 */
[data-theme="dark"] .bg-yellow-50,
[data-theme="dark"] .bg-yellow-50\/50,
[data-theme="dark"] .bg-amber-50,
[data-theme="dark"] .bg-amber-50\/50 {
    background: rgba(245, 158, 11, 0.1) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

/* 淡紅色背景 */
[data-theme="dark"] .bg-red-50,
[data-theme="dark"] .bg-red-50\/50,
[data-theme="dark"] .bg-rose-50,
[data-theme="dark"] .bg-rose-50\/50 {
    background: rgba(251, 113, 133, 0.1) !important;
    border-color: rgba(251, 113, 133, 0.3) !important;
}

/* 淡藍色背景 */
[data-theme="dark"] .bg-blue-50,
[data-theme="dark"] .bg-blue-50\/50 {
    background: rgba(59, 130, 246, 0.1) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

/* 淡灰色背景 */
[data-theme="dark"] .bg-slate-50,
[data-theme="dark"] .bg-slate-50\/50,
[data-theme="dark"] .bg-slate-50\/60 {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

/* 漸變背景調整透明度 */
[data-theme="dark"] .bg-gradient-to-r {
    opacity: 0.9;
}

/* === 股票代碼顏色修正 (解決遮蔽) === */

/* 美股 ETF - 亮藍色 */
[data-theme="dark"] .stock-code-us,
[data-theme="dark"] [data-ticker^="IVV"],
[data-theme="dark"] [data-ticker^="QQQM"],
[data-theme="dark"] [data-ticker^="VXUS"] {
    color: #60a5fa !important;
}

/* 台股股票型 ETF - 紫色 */
[data-theme="dark"] .stock-code-tw-equity,
[data-theme="dark"] [data-ticker="0050"],
[data-theme="dark"] [data-ticker="00646"],
[data-theme="dark"] [data-ticker="00922"] {
    color: #a78bfa !important;
}

/* 台股債券型 ETF - 綠色 */
[data-theme="dark"] .stock-code-tw-bond,
[data-theme="dark"] [data-ticker="00937B"],
[data-theme="dark"] [data-ticker="00933B"] {
    color: #34d399 !important;
}

/* === 文字對比修正 === */

/* 深色文字改為亮色 */
[data-theme="dark"] .text-slate-700,
[data-theme="dark"] .text-slate-800,
[data-theme="dark"] .text-slate-900,
[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .text-gray-900 {
    color: #f1f5f9 !important;
}

/* 中灰文字改為可見灰 */
[data-theme="dark"] .text-slate-600,
[data-theme="dark"] .text-gray-600 {
    color: #cbd5e1 !important;
}

/* 次要文字改為中灰 */
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-gray-500 {
    color: #94a3b8 !important;
}

/* 說明文字保持可見 */
[data-theme="dark"] .text-slate-400,
[data-theme="dark"] .text-gray-400 {
    color: #94a3b8 !important;
}

/* 標籤文字統一改亮灰 */
[data-theme="dark"] .label-text,
[data-theme="dark"] .sub-label {
    color: #cbd5e1 !important;
}

/* === ROI Tags === */
[data-theme="dark"] .roi-pos {
    background-color: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
    border-color: rgba(0, 212, 170, 0.3);
}

[data-theme="dark"] .roi-neg {
    background-color: rgba(251, 113, 133, 0.15);
    color: #fb7185;
    border-color: rgba(251, 113, 133, 0.3);
}

[data-theme="dark"] .roi-neutral {
    background-color: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.3);
}

/* === Timeline === */
[data-theme="dark"] .cashflow-timeline {
    border-left-color: rgba(71, 85, 105, 0.5);
}

[data-theme="dark"] .tl-dot {
    background: #1e293b;
    border-color: #ffffff !important;
}

/* === 文字選取 === */
[data-theme="dark"] ::selection {
    background: rgba(96, 165, 250, 0.3);
    color: #ffffff;
}

/* === Focus Ring === */
[data-theme="dark"] *:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* === 狀態標籤優化 === */

/* OK/Safe 標籤 - 邊框樣式 */
[data-theme="dark"] .status-ok-badge,
[data-theme="dark"] .inline-flex.bg-emerald-50 {
    background: rgba(16, 185, 129, 0.15) !important;
    border: 1.5px solid rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
}

/* 警示標籤 */
[data-theme="dark"] .inline-flex.bg-amber-50 {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

/* 危險標籤 */
[data-theme="dark"] .inline-flex.bg-rose-50 {
    background: rgba(251, 113, 133, 0.15) !important;
    color: #fb7185 !important;
    border-color: rgba(251, 113, 133, 0.3) !important;
}

/* === Collapse Shell === */
[data-theme="dark"] .collapse-shell {
    background: #1e293b !important;
    border-color: rgba(148, 163, 184, 0.25) !important;
}

/* === 特定卡片類型 === */
[data-theme="dark"] .stack-group {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.25);
}

/* === 現金雷達卡片特定樣式 === */

/* 股利卡片容器 */
[data-theme="dark"] .group.relative.overflow-hidden {
    background: rgba(30, 41, 59, 0.6) !important;
}

/* 頂部進度條 */
[data-theme="dark"] .absolute.top-0.left-0 {
    opacity: 1;
}

/* 圓點指示器 */
[data-theme="dark"] .h-2.w-2.rounded-full {
    opacity: 1;
}

/* 數字顯示框 */
[data-theme="dark"] .rounded-2xl.bg-slate-50 {
    background: rgba(51, 65, 85, 0.4) !important;
    border-color: rgba(148, 163, 184, 0.25) !important;
}

/* 54C 輸入框 */
[data-theme="dark"] input[type="number"].bg-slate-50 {
    background-color: rgba(51, 65, 85, 0.5) !important;
    color: #f1f5f9 !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
}

[data-theme="dark"] input[type="number"].bg-slate-50:hover {
    background-color: rgba(51, 65, 85, 0.6) !important;
}

/* === 確保重要文字可見 === */

/* 股票名稱 */
[data-theme="dark"] .text-2xl.font-black,
[data-theme="dark"] .text-3xl.font-black {
    color: #f1f5f9 !important;
}

/* 金額數字 */
[data-theme="dark"] .font-black.text-slate-900,
[data-theme="dark"] .font-black.text-slate-800 {
    color: #f1f5f9 !important;
}

/* 次要說明 */
[data-theme="dark"] .text-slate-400,
[data-theme="dark"] .text-slate-500,
[data-theme="dark"] .text-slate-600 {
    color: #94a3b8 !important;
}

/* === 🎯 Doctor 最終修正 (2026-01-03 21:30) === */

/* 問題 1: KPI 數字統一紫色 - 已在上方修正 */

/* 問題 2: 基本生活費總額改白色 */
/* 基本生活費總額標籤 */
[data-theme="dark"] .bg-slate-50 .label-text.text-slate-600 {
    color: #ffffff !important;
}

/* 基本生活費總額數字 */
[data-theme="dark"] #out_basic_living_total {
    color: #ffffff !important;
}

/* 問題 3: 基本生活費差額改亮綠色 (統一跟公式修正) */
[data-theme="dark"] .bg-emerald-50 .text-emerald-800 {
    color: #34d399 !important; /* 改為跟 text-emerald-600 一樣的亮綠 */
}

/* 問題 4: 風險雷達所有綠色文字統一改亮綠 */
[data-theme="dark"] .text-emerald-500,
[data-theme="dark"] .text-emerald-600,
[data-theme="dark"] .text-emerald-700,
[data-theme="dark"] .text-emerald-800,
[data-theme="dark"] .text-emerald-900,
[data-theme="dark"] .text-green-500,
[data-theme="dark"] .text-green-600,
[data-theme="dark"] .text-green-700,
[data-theme="dark"] .text-green-800 {
    color: #34d399 !important; /* 統一亮綠 */
}

/* === 🔧 Doctor 指定修正 (2026-01-03) - Tailwind Classes 覆寫 === */

/* ========== 問題 1: Kai & Nina 資產區 ========== */

/* 外框淡藍漸變 → 深色 */
[data-theme="dark"] .from-blue-50 {
    --tw-gradient-from: #1e293b !important;
}

[data-theme="dark"] .to-white {
    --tw-gradient-to: #1e293b !important;
}

[data-theme="dark"] .bg-gradient-to-br.from-blue-50 {
    background: #1e293b !important;
}

/* 標題區塊淡藍背景 → 深色透明 */
[data-theme="dark"] .bg-blue-100\/50 {
    background-color: rgba(59, 130, 246, 0.1) !important;
}

/* 淡黃定存區塊 → 深色透明 */
[data-theme="dark"] .bg-yellow-50\/50 {
    background-color: rgba(245, 158, 11, 0.08) !important;
}

/* Kai 定投區塊背景 */
[data-theme="dark"] .bg-blue-50\/30 {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

/* Nina 定投區塊背景 */
[data-theme="dark"] .bg-pink-50\/30 {
    background-color: rgba(236, 72, 153, 0.08) !important;
}

/* 股票卡片內背景 */
[data-theme="dark"] .bg-slate-50\/50 {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

/* ========== 問題 2: Alba 資產區 ========== */

/* 外框淡橘漸變 → 深色 */
[data-theme="dark"] .from-orange-50 {
    --tw-gradient-from: #1e293b !important;
}

[data-theme="dark"] .bg-gradient-to-br.from-orange-50 {
    background: #1e293b !important;
}

/* 標題區塊淡橘背景 → 深色透明 */
[data-theme="dark"] .bg-orange-100\/50 {
    background-color: rgba(245, 158, 11, 0.1) !important;
}

/* Alba 定投區塊背景 */
[data-theme="dark"] .bg-orange-50\/30 {
    background-color: rgba(245, 158, 11, 0.08) !important;
}

/* ========== 問題 3: 股票代碼顏色 ========== */

/* 美股藍色代碼 → 亮藍 */
[data-theme="dark"] .text-blue-800 {
    color: #60a5fa !important;
}

/* Nina 粉色代碼 → 亮粉 */
[data-theme="dark"] .text-pink-800 {
    color: #f9a8d4 !important;
}

/* 台股深灰代碼 → 紫色 */
[data-theme="dark"] .text-slate-700 {
    color: #a78bfa !important;
}

/* ========== 問題 4: 稅務區塊灰色背景 ========== */

/* 收入與所得、免稅額區塊白底 → 深色透明 */
[data-theme="dark"] .bg-white\/50 {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .bg-white\/80 {
    background-color: rgba(51, 65, 85, 0.6) !important;
}

/* 基本生活費淡綠背景保持（已在前面處理） */

/* ========== 問題 5: 風險雷達綠色文字 ========== */

/* 綠色標題 → 亮綠 (加強優先級) */
[data-theme="dark"] .text-emerald-600,
[data-theme="dark"] #risk-radar-list .text-emerald-600,
[data-theme="dark"] [id*="risk"] .text-emerald-600 {
    color: #34d399 !important;
}

[data-theme="dark"] .text-green-600,
[data-theme="dark"] #risk-radar-list .text-green-600 {
    color: #34d399 !important;
}

/* ========== 問題 6: 系統狀態淡綠背景 ========== */

/* 燈泡圓圈淡綠底 → 深綠透明 */
[data-theme="dark"] .bg-green-100 {
    background-color: rgba(16, 185, 129, 0.12) !important;
}

/* ========== 通用淡色背景覆寫 ========== */

/* 所有淡藍背景 */
[data-theme="dark"] .bg-blue-50 {
    background-color: rgba(59, 130, 246, 0.08) !important;
}

/* 所有淡粉背景 */
[data-theme="dark"] .bg-pink-50 {
    background-color: rgba(236, 72, 153, 0.08) !important;
}

/* 所有淡橘背景 */
[data-theme="dark"] .bg-orange-50 {
    background-color: rgba(245, 158, 11, 0.08) !important;
}

/* 所有淡黃背景 */
[data-theme="dark"] .bg-yellow-50 {
    background-color: rgba(245, 158, 11, 0.08) !important;
}

/* 所有淡灰背景 */
[data-theme="dark"] .bg-slate-50 {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

/* ========== 邊框顏色加強 ========== */

[data-theme="dark"] .border-blue-100,
[data-theme="dark"] .border-blue-200 {
    border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-theme="dark"] .border-pink-100,
[data-theme="dark"] .border-pink-200 {
    border-color: rgba(236, 72, 153, 0.3) !important;
}

[data-theme="dark"] .border-orange-100,
[data-theme="dark"] .border-orange-200 {
    border-color: rgba(245, 158, 11, 0.3) !important;
}

[data-theme="dark"] .border-slate-100,
[data-theme="dark"] .border-slate-200 {
    border-color: rgba(148, 163, 184, 0.25) !important;
}

/* ========== 次要文字顏色加強 ========== */

[data-theme="dark"] .text-blue-500,
[data-theme="dark"] .text-blue-600 {
    color: #60a5fa !important;
}

[data-theme="dark"] .text-pink-500,
[data-theme="dark"] .text-pink-600 {
    color: #f9a8d4 !important;
}

[data-theme="dark"] .text-orange-600,
[data-theme="dark"] .text-orange-800 {
    color: #fb923c !important;
}

[data-theme="dark"] .text-yellow-600 {
    color: #fbbf24 !important;
}

/* === 🔧 Doctor 指定修正 (2026-01-03) === */

/* 問題 1: KAI/NINA 資產區底色修正 */
[data-theme="dark"] [class*="A. Kai & Nina"] {
    background: #1e293b !important;
}

/* Kai & Nina 外框強制深色 */
[data-theme="dark"] .diagram-card[style*="background"],
[data-theme="dark"] .card-elevated[style*="background"] {
    background: #1e293b !important;
}

/* 定存區塊淡黃背景 → 深色透明 */
[data-theme="dark"] .bg-yellow-50.bg-opacity-50,
[data-theme="dark"] [style*="background: #fffbeb"],
[data-theme="dark"] [style*="background:#fffbeb"],
[data-theme="dark"] [style*="background-color: #fffbeb"],
[data-theme="dark"] [style*="background-color:#fffbeb"] {
    background: rgba(245, 158, 11, 0.08) !important;
    background-color: rgba(245, 158, 11, 0.08) !important;
}

/* 問題 2: ALBA 資產米黃外框修正 */
[data-theme="dark"] [class*="B. Alba"],
[data-theme="dark"] [style*="background: #fef3c7"],
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background-color: #fef3c7"],
[data-theme="dark"] [style*="background-color:#fef3c7"] {
    background: #1e293b !important;
    background-color: #1e293b !important;
}

/* 問題 3: 稅務區塊灰色背景修正 */

/* 收入與所得區塊 */
[data-theme="dark"] [style*="background-color: #9ca3af"],
[data-theme="dark"] [style*="background-color:#9ca3af"],
[data-theme="dark"] [style*="background: #9ca3af"],
[data-theme="dark"] [style*="background:#9ca3af"] {
    background: rgba(51, 65, 85, 0.5) !important;
    background-color: rgba(51, 65, 85, 0.5) !important;
}

/* 免稅額與扣除額區塊 */
[data-theme="dark"] [style*="background-color: #94a3b8"],
[data-theme="dark"] [style*="background-color:#94a3b8"],
[data-theme="dark"] [style*="background: #94a3b8"],
[data-theme="dark"] [style*="background:#94a3b8"],
[data-theme="dark"] .bg-slate-400 {
    background: rgba(51, 65, 85, 0.5) !important;
    background-color: rgba(51, 65, 85, 0.5) !important;
}

/* 區塊內文字確保可見 */
[data-theme="dark"] [style*="background-color: #9ca3af"] *,
[data-theme="dark"] [style*="background-color: #94a3b8"] * {
    color: #f1f5f9 !important;
}

/* 問題 4: 事件雷達綠色文字修正 */

/* 綠色標題文字改為亮綠 */
[data-theme="dark"] .text-emerald-600,
[data-theme="dark"] .text-green-600,
[data-theme="dark"] [style*="color: #059669"],
[data-theme="dark"] [style*="color:#059669"],
[data-theme="dark"] [style*="color: #10b981"],
[data-theme="dark"] [style*="color:#10b981"] {
    color: #34d399 !important; /* Emerald-400 高對比 */
}

/* 事件雷達卡片內所有文字 */
[data-theme="dark"] [class*="年度風險與關鍵事件雷達"] .text-emerald-600,
[data-theme="dark"] [class*="Risk & Events"] .text-emerald-600 {
    color: #6ee7b7 !important; /* Emerald-300 更亮 */
}

/* 問題 5: 系統狀態淡綠背景修正 */

/* 系統狀態卡片背景 */
[data-theme="dark"] [style*="background-color: #d1fae5"],
[data-theme="dark"] [style*="background-color:#d1fae5"],
[data-theme="dark"] [style*="background: #d1fae5"],
[data-theme="dark"] [style*="background:#d1fae5"],
[data-theme="dark"] .bg-emerald-100 {
    background: rgba(16, 185, 129, 0.12) !important;
    background-color: rgba(16, 185, 129, 0.12) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

/* 系統狀態內文字改為亮色 */
[data-theme="dark"] [style*="background-color: #d1fae5"] *,
[data-theme="dark"] .bg-emerald-100 * {
    color: #f1f5f9 !important;
}

/* 系統狀態綠色標題 */
[data-theme="dark"] [style*="background-color: #d1fae5"] .text-emerald-600,
[data-theme="dark"] .bg-emerald-100 .text-emerald-600 {
    color: #34d399 !important;
}

/* === 通用 inline style 覆寫加強 === */

/* 所有淡色背景強制轉換 */
[data-theme="dark"] [style*="background-color: rgb(254, 243, 199)"],
[data-theme="dark"] [style*="background-color: rgb(255, 251, 235)"],
[data-theme="dark"] [style*="background-color: rgb(220, 252, 231)"],
[data-theme="dark"] [style*="background-color: rgb(209, 250, 229)"],
[data-theme="dark"] [style*="background-color: rgb(254, 249, 195)"] {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

/* 確保深色模式下所有灰色區塊可讀 */
[data-theme="dark"] .bg-gray-100,
[data-theme="dark"] .bg-gray-200,
[data-theme="dark"] .bg-gray-300 {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

/* === 🎯 特定 HTML 結構修正 === */

/* Kai 定投框 - 強制深色 */
[data-theme="dark"] [style*="border: 2px solid rgb(147, 197, 253)"] {
    background: rgba(30, 41, 59, 0.6) !important;
    border-color: rgba(59, 130, 246, 0.4) !important;
}

/* Nina 定投框 - 強制深色 */
[data-theme="dark"] [style*="border: 2px solid rgb(251, 207, 232)"] {
    background: rgba(30, 41, 59, 0.6) !important;
    border-color: rgba(236, 72, 153, 0.4) !important;
}

/* Alba 定投框 - 強制深色 */
[data-theme="dark"] [style*="border: 2px solid rgb(253, 230, 138)"] {
    background: rgba(30, 41, 59, 0.6) !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
}

/* === 🎯 退休規劃紫色數字修正 (2026-01-04) === */

/* 1. 提領率 select 下拉選單 */
[data-theme="dark"] #plan_withdraw_rate_preset {
    color: #f1f5f9 !important;
}

/* 2. 現況/目標 (月領) 數值顯示 */
[data-theme="dark"] .kpi-value-secondary.text-slate-700,
[data-theme="dark"] #display-passive-income-now,
[data-theme="dark"] #display-plan-monthly {
    color: #f1f5f9 !important;
}

/* 3. 免稅額與幼兒學前扣除的輸入框 */
[data-theme="dark"] #in_exempt_under70_cnt,
[data-theme="dark"] #in_exempt_over70_cnt,
[data-theme="dark"] #in_preschool_cnt {
    color: #f1f5f9 !important;
}

/* 4. 設定目標年份 */
[data-theme="dark"] #targetYear {
    color: #f1f5f9 !important;
    background-color: rgba(51, 65, 85, 0.5) !important;
}

/* 5. 通用：所有 text-indigo-600 在深色模式改為白色 */
[data-theme="dark"] .text-indigo-600 {
    color: #f1f5f9 !important;
}
