/**
 * 主题色 + 深色模式
 * - html[data-theme]：强调色（绿/蓝/紫/橙/青/灰/黑金/红木）
 * - html[data-scheme="dark"]：深色表面（可与强调色叠加）
 * - blackgold / rosewood：整套皮肤（黑金墨底鎏金；红木暖色+木纹）
 */
:root,
html[data-theme="green"] {
    --ui-primary: #00b96b;
    --ui-primary-hover: #009a58;
    --ui-primary-soft: #e8f8f0;
    --ui-accent: #00b96b;
}

html[data-theme="blue"] {
    --ui-primary: #2563eb;
    --ui-primary-hover: #1d4ed8;
    --ui-primary-soft: #eff6ff;
    --ui-accent: #3b82f6;
}

html[data-theme="purple"] {
    --ui-primary: #7c3aed;
    --ui-primary-hover: #6d28d9;
    --ui-primary-soft: #f5f3ff;
    --ui-accent: #8b5cf6;
}

html[data-theme="orange"] {
    --ui-primary: #f59e0b;
    --ui-primary-hover: #d97706;
    --ui-primary-soft: #fffbeb;
    --ui-accent: #fbbf24;
}

html[data-theme="cyan"] {
    --ui-primary: #0891b2;
    --ui-primary-hover: #0e7490;
    --ui-primary-soft: #ecfeff;
    --ui-accent: #06b6d4;
}

html[data-theme="slate"] {
    --ui-primary: #475569;
    --ui-primary-hover: #334155;
    --ui-primary-soft: #f1f5f9;
    --ui-accent: #64748b;
}

/* —— 至臻黑金：墨黑底 + 鎏金强调 —— */
html[data-theme="blackgold"] {
    color-scheme: dark;
    --ui-primary: #d4af37;
    --ui-primary-hover: #f0d78c;
    --ui-primary-soft: rgba(212, 175, 55, 0.16);
    --ui-accent: #e8c547;
    --ui-bg: #0a0a0c;
    --ui-surface: #141416;
    --ui-surface-muted: #101012;
    --ui-border: #2a2a2e;
    --ui-border-strong: #3d3d44;
    --ui-text: #f3efe6;
    --ui-text-secondary: #c9c0ae;
    --ui-text-muted: #8f8878;
    --ui-sidebar-bg: #0e0e10;
    --ui-header-bg: #121214;
    --ui-glass-dark: #121214;
    --ui-glass-dark-strong: #121214;
    --ui-glass-border: #2a2a2e;
    --ui-glass-highlight: #1a1a1e;
    --ui-nav-text: #f3efe6;
    --ui-nav-text-secondary: #c9c0ae;
    --ui-nav-text-muted: #8f8878;
    --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 4px 18px rgba(0, 0, 0, 0.4);
    --ui-shadow-md: 0 4px 18px rgba(0, 0, 0, 0.5);
    --ui-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    --ui-row-stripe: #101012;
    --ui-row-hover: rgba(212, 175, 55, 0.12);
    --amt-principal: #e8c547;
    --amt-interest: #c9a227;
    --amt-in: #d4af37;
}

/* —— 东方红木：暖木色 + 纹理（纹理见下方 body/sidebar） —— */
html[data-theme="rosewood"] {
    --ui-primary: #8b2e2e;
    --ui-primary-hover: #6e2222;
    --ui-primary-soft: #f3e6e0;
    --ui-accent: #a3483c;
    --ui-bg: #f3ebe3;
    --ui-surface: #faf5f0;
    --ui-surface-muted: #f0e6dc;
    --ui-border: #e0d0c2;
    --ui-border-strong: #cbb5a4;
    --ui-text: #3a241c;
    --ui-text-secondary: #6b4a3c;
    --ui-text-muted: #9a7766;
    --ui-sidebar-bg: #5a2a22;
    --ui-header-bg: #f7f0e9;
    --ui-glass-dark: #5a2a22;
    --ui-glass-dark-strong: #4a221c;
    --ui-glass-border: #7a4034;
    --ui-glass-highlight: #6a342a;
    --ui-nav-text: #3a241c;
    --ui-nav-text-secondary: #6b4a3c;
    --ui-nav-text-muted: #9a7766;
    --ui-shadow: 0 1px 2px rgba(90, 42, 34, 0.08), 0 4px 16px rgba(90, 42, 34, 0.1);
    --ui-shadow-md: 0 4px 16px rgba(90, 42, 34, 0.14);
    --ui-shadow-lg: 0 10px 28px rgba(90, 42, 34, 0.16);
    --ui-row-stripe: #f5ede5;
    --ui-row-hover: rgba(139, 46, 46, 0.08);
    --amt-principal: #8b2e2e;
    --amt-interest: #a3483c;
    --amt-in: #8b2e2e;
}

/* 红木侧栏深色木纹：局部覆盖导航字色 */
html[data-theme="rosewood"] .sidebar {
    --ui-nav-text: #f8efe8;
    --ui-nav-text-secondary: #e8d5c8;
    --ui-nav-text-muted: #c9a994;
    --ui-nav-text-active: #f0d2a8;
    --ui-primary-soft: rgba(240, 210, 168, 0.16);
}

/* 黑金：深色外观叠加时略提亮金字 */
html[data-scheme="dark"][data-theme="blackgold"],
html[data-theme="blackgold"] {
    --ui-primary-soft: rgba(212, 175, 55, 0.18);
}

html[data-scheme="dark"][data-theme="rosewood"] {
    --ui-primary: #c96a5c;
    --ui-primary-hover: #e08a7c;
    --ui-primary-soft: rgba(201, 106, 92, 0.2);
    --ui-accent: #c96a5c;
    --ui-row-hover: rgba(201, 106, 92, 0.14);
    --ui-bg: #1a1210;
    --ui-surface: #241816;
    --ui-surface-muted: #1e1412;
    --ui-border: #3d2a24;
    --ui-border-strong: #524038;
    --ui-text: #f3e8e0;
    --ui-text-secondary: #d4b8a8;
    --ui-text-muted: #a88878;
    --ui-sidebar-bg: #2a1814;
    --ui-header-bg: #221614;
    --ui-nav-text: #f3e8e0;
    --ui-nav-text-secondary: #d4b8a8;
    --ui-nav-text-muted: #a88878;
}

/* 红木纹理：侧栏 / 顶栏 / 登录左栏 */
html[data-theme="rosewood"] .sidebar,
html[data-theme="rosewood"] body.ui-auth--split .auth-visual {
    background-color: var(--ui-sidebar-bg);
    background-image:
        repeating-linear-gradient(
            92deg,
            transparent 0 2px,
            rgba(0, 0, 0, 0.045) 2px 3px,
            transparent 3px 7px,
            rgba(255, 220, 180, 0.04) 7px 8px
        ),
        repeating-linear-gradient(
            0deg,
            transparent 0 11px,
            rgba(0, 0, 0, 0.035) 11px 12px
        ),
        linear-gradient(
            165deg,
            #6a3228 0%,
            #5a2a22 40%,
            #4a221c 72%,
            #5c2c24 100%
        );
}
html[data-theme="rosewood"] .header {
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0 3px,
            rgba(139, 46, 46, 0.04) 3px 4px
        ),
        linear-gradient(180deg, var(--ui-header-bg), color-mix(in srgb, var(--ui-header-bg) 92%, #8b2e2e));
}
html[data-theme="rosewood"] body.ui-auth--split .auth-visual__brand-en {
    color: #f0d2a8;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
html[data-theme="rosewood"] body.ui-auth--split .auth-visual__brand-zh {
    color: #e8d0c0;
}

/* 黑金点缀：顶栏细金线 + 侧栏微光 */
html[data-theme="blackgold"] .header {
    border-bottom-color: color-mix(in srgb, #d4af37 35%, #2a2a2e);
    box-shadow: 0 1px 0 rgba(212, 175, 55, 0.12), 0 4px 16px rgba(0, 0, 0, 0.45);
}
html[data-theme="blackgold"] .sidebar {
    background:
        radial-gradient(ellipse 80% 40% at 50% 0%, rgba(212, 175, 55, 0.08), transparent 55%),
        var(--ui-sidebar-bg);
    border-right-color: color-mix(in srgb, #d4af37 18%, #2a2a2e);
}
html[data-theme="blackgold"] .menu-item.active > a,
html[data-theme="blackgold"] .menu-item.open > a {
    box-shadow: inset 3px 0 0 #d4af37;
}
html[data-theme="blackgold"] body.ui-auth--split .auth-visual {
    background:
        radial-gradient(ellipse 55% 45% at 72% 38%, rgba(212, 175, 55, 0.22), transparent 60%),
        radial-gradient(ellipse 40% 35% at 28% 70%, rgba(212, 175, 55, 0.1), transparent 55%),
        linear-gradient(165deg, #0c0c0e 0%, #121214 45%, #0a0a0c 100%);
}
html[data-theme="blackgold"] body.ui-auth--split .auth-panel {
    background: #141416;
    color: #f3efe6;
}
html[data-theme="blackgold"] body.ui-auth--split .auth-visual__brand-en {
    color: #d4af37;
}

/* —— 深色模式：表面/文字/边框（强调色仍由 data-theme 决定） —— */
html[data-scheme="dark"] {
    color-scheme: dark;
    --ui-bg: #0f1419;
    --ui-surface: #1a2332;
    --ui-surface-muted: #151c27;
    --ui-border: #2a3544;
    --ui-border-strong: #3a4656;
    --ui-text: #e8edf4;
    --ui-text-secondary: #b0bac8;
    --ui-text-muted: #8490a1;
    --ui-success-soft: rgba(0, 185, 107, 0.16);
    --ui-warning-soft: rgba(230, 162, 60, 0.16);
    --ui-danger-soft: rgba(245, 108, 108, 0.16);
    --ui-interest-soft: rgba(124, 58, 237, 0.18);
    --ui-sidebar-bg: #141b26;
    --ui-header-bg: #141b26;
    --ui-glass-dark: #141b26;
    --ui-glass-dark-strong: #141b26;
    --ui-glass-border: #2a3544;
    --ui-glass-highlight: #1a2332;
    --ui-nav-text: #e8edf4;
    --ui-nav-text-secondary: #b0bac8;
    --ui-nav-text-muted: #8490a1;
    --ui-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.28);
    --ui-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --ui-shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.45);
    --ui-row-stripe: #151c27;
    --amt-default: #e8edf4;
    --amt-principal: #34d399;
    --amt-distributable: #2dd4bf;
    --amt-interest: #a78bfa;
    --amt-investor: #818cf8;
    --amt-operation: #60a5fa;
    --amt-fee: #fbbf24;
    --amt-service: #22d3ee;
    --amt-late: #fb923c;
    --amt-commission: #f87171;
    --amt-sales: #fb7185;
    --amt-svc-comm: #f472b6;
    --amt-withdrawable: #fb923c;
    --amt-in: #34d399;
    --amt-out: #f87171;
    --amt-warn: #fbbf24;
}

/* 深色下各强调色的 soft 底 */
html[data-scheme="dark"][data-theme="green"],
html[data-scheme="dark"]:not([data-theme]) {
    --ui-primary-soft: rgba(0, 185, 107, 0.18);
    --ui-row-hover: rgba(0, 185, 107, 0.14);
}
html[data-scheme="dark"][data-theme="blue"] {
    --ui-primary-soft: rgba(37, 99, 235, 0.22);
    --ui-row-hover: rgba(37, 99, 235, 0.16);
}
html[data-scheme="dark"][data-theme="purple"] {
    --ui-primary-soft: rgba(124, 58, 237, 0.22);
    --ui-row-hover: rgba(124, 58, 237, 0.16);
}
html[data-scheme="dark"][data-theme="orange"] {
    --ui-primary-soft: rgba(245, 158, 11, 0.2);
    --ui-row-hover: rgba(245, 158, 11, 0.14);
}
html[data-scheme="dark"][data-theme="cyan"] {
    --ui-primary-soft: rgba(8, 145, 178, 0.22);
    --ui-row-hover: rgba(8, 145, 178, 0.16);
}
html[data-scheme="dark"][data-theme="slate"] {
    --ui-primary: #94a3b8;
    --ui-primary-hover: #cbd5e1;
    --ui-primary-soft: rgba(148, 163, 184, 0.18);
    --ui-accent: #94a3b8;
    --ui-row-hover: rgba(148, 163, 184, 0.12);
}
html[data-scheme="dark"][data-theme="blackgold"] {
    --ui-primary: #e8c547;
    --ui-primary-hover: #f5dfa0;
    --ui-primary-soft: rgba(232, 197, 71, 0.2);
    --ui-accent: #e8c547;
    --ui-row-hover: rgba(232, 197, 71, 0.14);
}
html[data-scheme="dark"][data-theme="rosewood"] {
    --ui-primary-soft: rgba(201, 106, 92, 0.22);
}

/* 深色：搜索卡/提示条等硬编码浅色覆盖 */
html[data-scheme="dark"] .ui-card--filter {
    border-color: var(--ui-border);
    background: linear-gradient(180deg, #1a2332 0%, #151c27 100%);
}
html[data-scheme="dark"] .ui-alert--info {
    background: rgba(37, 99, 235, 0.16);
    border-color: rgba(96, 165, 250, 0.35);
    color: #93c5fd;
}
html[data-scheme="dark"] .ui-alert--warning {
    background: rgba(230, 162, 60, 0.16);
    border-color: rgba(251, 191, 36, 0.35);
    color: #fcd34d;
}
html[data-scheme="dark"] .ui-alert--error {
    background: rgba(245, 108, 108, 0.16);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fca5a5;
}
html[data-scheme="dark"] .ui-alert--success {
    background: rgba(0, 185, 107, 0.16);
    border-color: rgba(52, 211, 153, 0.35);
    color: #6ee7b7;
}
html[data-scheme="dark"] .ui-theme-swatch.is-active {
    box-shadow: 0 0 0 2px var(--ui-surface), 0 0 0 4px var(--ui-primary);
}
html[data-scheme="dark"] .ui-empty {
    background: var(--ui-surface-muted);
    border-color: var(--ui-border-strong);
}
html[data-scheme="dark"] .header {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
html[data-scheme="dark"] .ui-btn--ghost {
    background: var(--ui-surface);
    border-color: var(--ui-border-strong);
    color: var(--ui-text-secondary);
}
html[data-scheme="dark"] .ui-btn--ghost:hover {
    background: var(--ui-surface-muted);
    color: var(--ui-text);
}
html[data-scheme="dark"] .ui-badge--muted {
    background: #243044;
    color: var(--ui-text-muted);
}
