/*
 * 首页整页主题变量。
 * 该文件只影响被 JS 标记为首页的区域，不改变接口或业务 DOM。
 */
html[data-mgt-home-v2="1"] {
    --mgh-page-bg: #eef4ff;
    --mgh-frame-bg: #182443;
    --mgh-frame-border: rgba(128, 155, 210, 0.22);
    --mgh-header-bg: linear-gradient(135deg, #f9fbff 0%, #e8f2ff 100%);
    --mgh-section-bg: rgba(255, 255, 255, 0.96);
    --mgh-card-bg: linear-gradient(145deg, #edf5ff 0%, #dceaff 100%);
    --mgh-card-strong: linear-gradient(135deg, #4f5fff 0%, #7355ee 100%);
    --mgh-card-accent: linear-gradient(135deg, #1e88e5 0%, #00a7b5 100%);
    --mgh-card-warm: linear-gradient(135deg, #e7a92c 0%, #be6c1a 100%);
    --mgh-text: #14213d;
    --mgh-muted: #72809c;
    --mgh-title: #111b34;
    --mgh-border: rgba(103, 132, 185, 0.22);
    --mgh-shadow: 0 18px 45px rgba(28, 48, 88, 0.15);
    --mgh-glow: rgba(88, 104, 255, 0.18);
    --mgh-icon-bg: #ffffff;
    --mgh-button-bg: linear-gradient(135deg, #5f53ff, #2678ff);
    --mgh-button-text: #ffffff;
}

html[data-mgt-home-v2="1"][data-merchant-theme="midnight"] {
    --mgh-page-bg: #061225;
    --mgh-frame-bg: #071a35;
    --mgh-frame-border: rgba(84, 124, 198, 0.28);
    --mgh-header-bg: linear-gradient(135deg, #102746 0%, #173968 100%);
    --mgh-section-bg: rgba(12, 31, 59, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #17345d 0%, #10294c 100%);
    --mgh-card-strong: linear-gradient(135deg, #315ff4 0%, #3147b8 100%);
    --mgh-card-accent: linear-gradient(135deg, #0d7f93 0%, #0ab5c4 100%);
    --mgh-card-warm: linear-gradient(135deg, #bb7921 0%, #6d4310 100%);
    --mgh-text: #f4f7ff;
    --mgh-muted: #9cafce;
    --mgh-title: #ffffff;
    --mgh-border: rgba(107, 146, 211, 0.22);
    --mgh-shadow: 0 20px 55px rgba(0, 0, 0, 0.34);
    --mgh-glow: rgba(71, 111, 255, 0.25);
    --mgh-icon-bg: #f6f8ff;
    --mgh-button-bg: linear-gradient(135deg, #4e77ff, #2740c9);
}

html[data-mgt-home-v2="1"][data-merchant-theme="violet"] {
    --mgh-page-bg: #140d28;
    --mgh-frame-bg: #1c1237;
    --mgh-frame-border: rgba(172, 106, 237, 0.28);
    --mgh-header-bg: linear-gradient(135deg, #2a194e 0%, #462064 100%);
    --mgh-section-bg: rgba(35, 22, 65, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #39235f 0%, #261a4a 100%);
    --mgh-card-strong: linear-gradient(135deg, #7a42ff 0%, #a83bcb 100%);
    --mgh-card-accent: linear-gradient(135deg, #4952d9 0%, #8c3bc3 100%);
    --mgh-card-warm: linear-gradient(135deg, #d67bca 0%, #8d376f 100%);
    --mgh-text: #fff7ff;
    --mgh-muted: #c6acd9;
    --mgh-title: #ffffff;
    --mgh-border: rgba(207, 154, 255, 0.20);
    --mgh-shadow: 0 20px 58px rgba(4, 0, 12, 0.38);
    --mgh-glow: rgba(165, 80, 255, 0.27);
    --mgh-icon-bg: #fff8ff;
    --mgh-button-bg: linear-gradient(135deg, #7b45ff, #c23cc1);
}

html[data-mgt-home-v2="1"][data-merchant-theme="ocean"] {
    --mgh-page-bg: #052f38;
    --mgh-frame-bg: #06414a;
    --mgh-frame-border: rgba(77, 214, 225, 0.25);
    --mgh-header-bg: linear-gradient(135deg, #0b6872 0%, #08798c 100%);
    --mgh-section-bg: rgba(6, 77, 87, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #0d6c78 0%, #075761 100%);
    --mgh-card-strong: linear-gradient(135deg, #00a3b6 0%, #0875a1 100%);
    --mgh-card-accent: linear-gradient(135deg, #00a986 0%, #078f96 100%);
    --mgh-card-warm: linear-gradient(135deg, #d2a328 0%, #8a6821 100%);
    --mgh-text: #effeff;
    --mgh-muted: #a4dce1;
    --mgh-title: #ffffff;
    --mgh-border: rgba(106, 226, 234, 0.20);
    --mgh-shadow: 0 20px 55px rgba(0, 21, 27, 0.40);
    --mgh-glow: rgba(0, 209, 223, 0.22);
    --mgh-icon-bg: #ecffff;
    --mgh-button-bg: linear-gradient(135deg, #00b7c7, #08788c);
}

html[data-mgt-home-v2="1"][data-merchant-theme="emerald"] {
    --mgh-page-bg: #eaf8f2;
    --mgh-frame-bg: #06483b;
    --mgh-frame-border: rgba(17, 153, 112, 0.22);
    --mgh-header-bg: linear-gradient(135deg, #f8fffc 0%, #e1f8ef 100%);
    --mgh-section-bg: rgba(255, 255, 255, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #ebfaf4 0%, #d4f2e6 100%);
    --mgh-card-strong: linear-gradient(135deg, #0c9c72 0%, #08715d 100%);
    --mgh-card-accent: linear-gradient(135deg, #14b88a 0%, #0798a3 100%);
    --mgh-card-warm: linear-gradient(135deg, #e3ac35 0%, #ae7225 100%);
    --mgh-text: #12342b;
    --mgh-muted: #668b80;
    --mgh-title: #0f2f27;
    --mgh-border: rgba(37, 148, 113, 0.18);
    --mgh-shadow: 0 18px 45px rgba(22, 92, 71, 0.15);
    --mgh-glow: rgba(21, 176, 126, 0.19);
    --mgh-icon-bg: #ffffff;
    --mgh-button-bg: linear-gradient(135deg, #11a878, #087a64);
}

html[data-mgt-home-v2="1"][data-merchant-theme="sunset"] {
    --mgh-page-bg: #fff2ec;
    --mgh-frame-bg: #5c251c;
    --mgh-frame-border: rgba(218, 98, 70, 0.22);
    --mgh-header-bg: linear-gradient(135deg, #fffaf7 0%, #ffe7dc 100%);
    --mgh-section-bg: rgba(255, 255, 255, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #fff3ec 0%, #ffdfd3 100%);
    --mgh-card-strong: linear-gradient(135deg, #f25b4c 0%, #ca3c52 100%);
    --mgh-card-accent: linear-gradient(135deg, #f17c3e 0%, #ef4f68 100%);
    --mgh-card-warm: linear-gradient(135deg, #ef9d22 0%, #cc581d 100%);
    --mgh-text: #45241f;
    --mgh-muted: #987068;
    --mgh-title: #3d1d19;
    --mgh-border: rgba(210, 95, 67, 0.18);
    --mgh-shadow: 0 18px 45px rgba(112, 52, 38, 0.15);
    --mgh-glow: rgba(244, 102, 74, 0.18);
    --mgh-icon-bg: #ffffff;
    --mgh-button-bg: linear-gradient(135deg, #f2604d, #d83c54);
}

html[data-mgt-home-v2="1"][data-merchant-theme="graphite"] {
    --mgh-page-bg: #111419;
    --mgh-frame-bg: #171b21;
    --mgh-frame-border: rgba(171, 181, 197, 0.18);
    --mgh-header-bg: linear-gradient(135deg, #282d36 0%, #353d49 100%);
    --mgh-section-bg: rgba(31, 36, 44, 0.98);
    --mgh-card-bg: linear-gradient(145deg, #313843 0%, #252b34 100%);
    --mgh-card-strong: linear-gradient(135deg, #4b5563 0%, #252b34 100%);
    --mgh-card-accent: linear-gradient(135deg, #657181 0%, #3b4654 100%);
    --mgh-card-warm: linear-gradient(135deg, #9d7a32 0%, #554523 100%);
    --mgh-text: #f5f7fa;
    --mgh-muted: #b3bcc8;
    --mgh-title: #ffffff;
    --mgh-border: rgba(187, 198, 214, 0.15);
    --mgh-shadow: 0 20px 55px rgba(0, 0, 0, 0.40);
    --mgh-glow: rgba(170, 183, 201, 0.12);
    --mgh-icon-bg: #f5f6f8;
    --mgh-button-bg: linear-gradient(135deg, #616c7a, #343c47);
}

html[data-mgt-home-v2="1"][data-merchant-theme="ice"] {
    --mgh-page-bg: #f4f7fd;
    --mgh-frame-bg: #192342;
    --mgh-frame-border: rgba(134, 158, 208, 0.22);
    --mgh-header-bg: linear-gradient(135deg, #ffffff 0%, #e7f2ff 100%);
    --mgh-section-bg: rgba(255, 255, 255, 0.98);
    --mgh-card-bg: linear-gradient(145deg, #eef6ff 0%, #dbe9ff 100%);
    --mgh-card-strong: linear-gradient(135deg, #5c55f1 0%, #3c7bea 100%);
    --mgh-card-accent: linear-gradient(135deg, #3a91e8 0%, #1bb4c9 100%);
    --mgh-card-warm: linear-gradient(135deg, #eab839 0%, #cb7f26 100%);
    --mgh-text: #15213c;
    --mgh-muted: #71809d;
    --mgh-title: #111a34;
    --mgh-border: rgba(106, 138, 193, 0.20);
    --mgh-shadow: 0 18px 45px rgba(42, 67, 112, 0.14);
    --mgh-glow: rgba(75, 112, 227, 0.17);
    --mgh-icon-bg: #ffffff;
    --mgh-button-bg: linear-gradient(135deg, #6554f4, #3679ee);
}

html[data-mgt-home-v2="1"][data-merchant-theme="sakura"] {
    --mgh-page-bg: #fff1f7;
    --mgh-frame-bg: #54243a;
    --mgh-frame-border: rgba(222, 112, 161, 0.22);
    --mgh-header-bg: linear-gradient(135deg, #fffafd 0%, #ffe4f0 100%);
    --mgh-section-bg: rgba(255, 255, 255, 0.97);
    --mgh-card-bg: linear-gradient(145deg, #fff2f8 0%, #ffddeb 100%);
    --mgh-card-strong: linear-gradient(135deg, #d85891 0%, #a83f77 100%);
    --mgh-card-accent: linear-gradient(135deg, #d66d9d 0%, #a858a4 100%);
    --mgh-card-warm: linear-gradient(135deg, #e7a447 0%, #c46c54 100%);
    --mgh-text: #442335;
    --mgh-muted: #946b7d;
    --mgh-title: #3a1e2d;
    --mgh-border: rgba(213, 95, 146, 0.18);
    --mgh-shadow: 0 18px 45px rgba(116, 50, 81, 0.15);
    --mgh-glow: rgba(216, 88, 145, 0.18);
    --mgh-icon-bg: #ffffff;
    --mgh-button-bg: linear-gradient(135deg, #d95590, #ac3e77);
}

/* 整个首页背景和应用容器 */
html[data-mgt-home-v2="1"] body,
html[data-mgt-home-v2="1"] body > #app,
html[data-mgt-home-v2="1"] #app {
    color: var(--mgh-text) !important;
    background:
        radial-gradient(
            circle at 15% 10%,
            var(--mgh-glow),
            transparent 31%
        ),
        radial-gradient(
            circle at 86% 18%,
            var(--mgh-glow),
            transparent 28%
        ),
        var(--mgh-page-bg) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-shell-v2 {
    position: relative;
    color: var(--mgh-text) !important;
    border-color: var(--mgh-frame-border) !important;
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--mgh-frame-bg) 96%, transparent),
            var(--mgh-frame-bg)
        ) !important;
    box-shadow: var(--mgh-shadow) !important;
    transition:
        background 0.22s ease,
        color 0.22s ease,
        box-shadow 0.22s ease;
}

html[data-mgt-home-v2="1"] .mgt-home-header-v2 {
    color: var(--mgh-title) !important;
    border-color: var(--mgh-border) !important;
    background: var(--mgh-header-bg) !important;
    box-shadow: 0 10px 25px rgba(12, 24, 54, 0.09) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-section-v2 {
    color: var(--mgh-text) !important;
    border-color: var(--mgh-border) !important;
    background: var(--mgh-section-bg) !important;
    box-shadow: 0 10px 28px rgba(13, 28, 57, 0.10) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-section-v2 :is(
    h1, h2, h3, h4, h5, h6,
    strong, b,
    [class*="title"]
) {
    color: var(--mgh-title) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-section-v2 :is(
    small,
    [class*="desc"],
    [class*="sub"],
    [class*="hint"],
    [class*="label"]
) {
    color: var(--mgh-muted) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-primary-v2 {
    color: #ffffff !important;
    border-color: color-mix(in srgb, var(--mgh-border) 80%, transparent) !important;
    background: var(--mgh-card-strong) !important;
    box-shadow: 0 12px 28px var(--mgh-glow) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-primary-v2:nth-of-type(2n) {
    background: var(--mgh-card-accent) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-primary-v2:nth-of-type(3n) {
    background: var(--mgh-card-warm) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-primary-v2,
html[data-mgt-home-v2="1"] .mgt-home-primary-v2 * {
    color: #ffffff !important;
}

html[data-mgt-home-v2="1"] .mgt-home-stat-v2,
html[data-mgt-home-v2="1"] .mgt-home-action-v2 {
    color: var(--mgh-text) !important;
    border-color: var(--mgh-border) !important;
    background: var(--mgh-card-bg) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 7px 18px rgba(20, 38, 76, 0.08) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-action-v2 {
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease !important;
}

html[data-mgt-home-v2="1"] .mgt-home-action-v2:active {
    transform: scale(0.985) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-action-v2 :is(
    img,
    svg,
    i,
    [class*="icon"]
) {
    color: var(--mgh-text) !important;
    background-color: var(--mgh-icon-bg) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-chart-v2 {
    color: var(--mgh-text) !important;
    border-color: var(--mgh-border) !important;
    background: var(--mgh-section-bg) !important;
    box-shadow: 0 12px 30px rgba(14, 30, 60, 0.10) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-chart-v2 canvas {
    filter:
        saturate(1.08)
        contrast(1.02);
}

html[data-mgt-home-v2="1"] .mgt-home-shell-v2 :is(
    button,
    .btn,
    [class*="button"]
) {
    border-color: var(--mgh-border) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-shell-v2 :is(
    button,
    .btn,
    [class*="button"]
).mgt-home-accent-button-v2 {
    color: var(--mgh-button-text) !important;
    background: var(--mgh-button-bg) !important;
}

html[data-mgt-home-v2="1"] .mgt-home-shell-v2 :is(
    input,
    select,
    textarea
) {
    color: var(--mgh-text) !important;
    border-color: var(--mgh-border) !important;
    background: var(--mgh-section-bg) !important;
}

/* 保证各类首页文字不会继续使用旧主题深色 */
html[data-mgt-home-v2="1"] .mgt-home-shell-v2 :is(
    p, span, em, label, li, dt, dd
) {
    border-color: var(--mgh-border);
}

/* 移动端首页整体 */
@media (max-width: 760px) {
    html[data-mgt-home-v2="1"] .mgt-home-shell-v2 {
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    html[data-mgt-home-v2="1"] .mgt-home-section-v2,
    html[data-mgt-home-v2="1"] .mgt-home-header-v2,
    html[data-mgt-home-v2="1"] .mgt-home-chart-v2 {
        border-radius: 16px !important;
    }

    html[data-mgt-home-v2="1"] .mgt-home-primary-v2,
    html[data-mgt-home-v2="1"] .mgt-home-stat-v2,
    html[data-mgt-home-v2="1"] .mgt-home-action-v2 {
        border-radius: 13px !important;
    }
}
