﻿:root {
    --bg: #f4f5f7;
    --bg-soft: #fff7f0;
    --bg-soft-2: #f2ede7;
    --card: #ffffff;
    --card-soft: #fffafa;
    --border: #e6e7eb;
    --border-soft: #ececef;
    --text: #1f2328;
    --sub: #6b7280;
    --sub-2: #8a8f98;
    --red: #e53935;
    --red-dark: #cc2f2b;
    --red-soft: #ffebe9;
    --red-line: #ffd6d2;
    --green: #16a34a;
    --green-soft: #eefbf2;
    --orange: #f59e0b;
    --orange-soft: #fff7e8;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --cyan: #06b6d4;
    --shadow: 0 8px 24px rgba(20, 24, 32, 0.06);
    --shadow-soft: 0 4px 14px rgba(20, 24, 32, 0.04);
    --radius: 4px;
    --radius-sm: 4px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, rgba(255, 164, 122, 0.28), transparent 34%), linear-gradient(180deg, #fff7f0 0%, var(--bg) 32%, #f2ede7 100%);
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

a {
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
    font: inherit;
}

.wrap {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 12px 12px 18px;
}

/* 顶部主卡 */
.hero {
    margin-bottom: 14px;
}

.hero-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hero-top {
    background: linear-gradient(135deg, #f44336, #e53935);
    border-radius: var(--radius);
    padding: 14px;
    color: #fff;
    box-shadow: var(--shadow);
}

.hero-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.hero-kicker {
    font-size: 12px;
    opacity: .92;
    margin-bottom: 6px;
}

.hero-main-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.2;
}

.hero-subtitle {
    margin-top: 6px;
    font-size: 12px;
    opacity: .92;
    line-height: 1.5;
}

.stats-hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.hero-stat {
    background: rgba(255,255,255,.16);
    padding: 9px 8px;
    border-radius: var(--radius);
    text-align: center;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.hero-stat .k {
    display: block;
    font-size: 11px;
    line-height: 1.2;
    opacity: .92;
}

.hero-stat .v {
    display: block;
    margin-top: 4px;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.15;
}

/* 筛选白卡 */
.filter-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.filter-label {
    font-size: 12px;
    color: var(--sub);
    font-weight: 700;
    line-height: 1.2;
}

/* 模式 tab */
.mode-tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: var(--radius);
    background: #f6f7f9;
    border: 1px solid var(--border);
}

.mode-tab {
    appearance: none;
    border: 0;
    height: 36px;
    padding: 0 6px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--sub);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: .18s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mode-tab:hover {
    background: #ffffff;
    color: var(--text);
}

.mode-tab.active {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 10px rgba(229, 57, 53, .18);
}

.mode-tab:focus-visible,
.level-range:focus-visible,
.action-btn:focus-visible,
.export-close:focus-visible,
.wechat-input:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(229,57,53,.15);
}

/* 档位 range */
.level-range-wrap {
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fafafb;
}

.level-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    margin: 2px 0 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #ffd2ce, #ff8b84);
    outline: none;
}

.level-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--red);
    box-shadow: 0 4px 10px rgba(229,57,53,.22);
    cursor: pointer;
}

.level-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--red);
    box-shadow: 0 4px 10px rgba(229,57,53,.22);
    cursor: pointer;
}

.level-scale {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #9aa0a6;
}

.level-scale span {
    transition: .18s ease;
}

.level-scale span.active {
    color: var(--red);
}

/* 按钮区 */
.common-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-btn {
    appearance: none;
    height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: .18s ease;
}

.action-btn:hover {
    background: #f8f9fb;
}

.action-btn.primary {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.action-btn.primary:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}

/* 列表区域 */
.list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.year-group {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.year-header {
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    background: linear-gradient(180deg, #fff8f8 0%, #fff1f0 100%);
    border-bottom: 1px solid #f1d8d6;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.plan-table {
    width: 100%;
    min-width: 320px;
    border-collapse: separate;
    border-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.plan-table thead th {
    text-align: left;
    font-size: 12px;
    color: var(--sub);
    font-weight: 700;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: #fcfcfd;
    white-space: nowrap;
}

.plan-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f0f1f3;
    font-size: 13px;
    color: var(--text);
    vertical-align: middle;
    line-height: 1.5;
    background: #fff;
}

.plan-table tbody tr:last-child td {
    border-bottom: 0;
}

/* 日期 */
.td-date {
    width: 72px;
    white-space: nowrap;
    color: var(--sub);
    font-weight: 700;
}

/* 分析 */
.td-forecast {
    min-width: 120px;
    font-weight: 800;
    color: var(--text);
    word-break: break-word;
}

/* 千元输出 */
.td-income {
    width: 92px;
    white-space: nowrap;
    font-weight: 800;
}

.td-income.positive {
    color: var(--red);
}

.td-income.neutral {
    color: var(--text);
}

.td-income.pending {
    color: var(--sub-2);
}

/* 状态 */
.td-status {
    width: 74px;
    white-space: nowrap;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.hit {
    border-color: #f3b7b1;
    background: var(--red-soft);
    color: var(--red);
}

.status-pill.miss {
    border-color: #e5e7eb;
    background: #f7f7f8;
    color: #6b7280;
}

.status-pill.pending {
    border-color: #f7ddb1;
    background: #fff5df;
    color: #b76e00;
}

/* 行状态 */
.plan-row-hit .td-forecast,
.plan-row-hit .td-income {
    color: var(--red);
    background: rgba(201, 75, 70, 0.2);
}

.plan-row-hit .td-date {
    color: #c94b46;
    background: rgba(201, 75, 70, 0.2);
}
.plan-row-hit .td-status {
    background: rgba(201, 75, 70, 0.2);
}

.plan-row-miss td {
    color: #8a8f98;
    font-weight:normal!important;
}

.plan-row-miss .td-forecast,
.plan-row-miss .td-date,
.plan-row-miss .td-income {
    color: #8a8f98;
    background: rgba(138, 143, 152,0.2);
}
.plan-row-miss .td-status {
    background: rgba(138, 143, 152,0.2);
}

.plan-row-pending td {
    background: #fffefb;
}

/* 空态 */
.empty {
    text-align: center;
    color: var(--sub);
    font-size: 13px;
    padding: 18px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,.72);
}

/* 页脚 */
.site-footer {
    margin-top: 22px;
    padding: 16px 10px 20px;
    text-align: center;
    font-size: 12px;
    color: var(--sub);
}

.law-note {
    margin-bottom: 10px;
    color: var(--red);
    font-weight: 700;
}

.footer-inner {
    max-width: 760px;
    margin: 0 auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.8;
}

.footer-links a {
    color: var(--sub);
    padding: 2px 4px;
}

.footer-links a:hover {
    color: var(--text);
}

.footer-links .sep {
    color: #c4c7cc;
}

.footer-meta {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.6;
}

.footer-meta .slogan {
    margin-top: 2px;
    color: var(--sub-2);
}

/* 导出弹窗 */
.export-modal {
    position: fixed;
    inset: 0;
    z-index: 10020;
}

.export-mask {
    position: absolute;
    inset: 0;
    background: rgba(31,35,40,.22);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.export-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 20px));
    max-height: calc(100vh - 20px);
    overflow: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 18px 48px rgba(20,24,32,.12);
}

.export-header,
.export-footer {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.export-header {
    border-bottom: 1px solid var(--border);
}

.export-footer {
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.export-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}

.export-close {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--sub);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.export-body {
    padding: 16px;
}

.export-section + .export-section {
    margin-top: 18px;
}

.export-label {
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.template-item {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    transition: .18s ease;
}

.template-item:hover {
    border-color: #e7c8c5;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(229,57,53,.06);
}

.template-item.active {
    border-color: #f0bab5;
    box-shadow: 0 0 0 1px rgba(229,57,53,.08), 0 8px 18px rgba(229,57,53,.08);
    background: #fff8f8;
}

.template-thumb {
    width: 100%;
    aspect-ratio: 9 / 16;
    object-fit: cover;
    display: block;
    border-radius: var(--radius);
    background: #f7f7f8;
}

.template-name {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.wechat-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    outline: none;
    font-size: 14px;
}

.wechat-input::placeholder {
    color: #a0a6ad;
}

.export-tip {
    font-size: 12px;
    line-height: 1.7;
    color: var(--sub);
}

.poster-sandbox {
    position: fixed;
    left: -20000px;
    top: 0;
    width: 1080px;
    min-height: 10px;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    background: #fff;
}

.poster-render-root {
    width: 1080px;
    background: #fff;
    overflow: hidden;
}

.poster-qrcode-img {
    display: block;
    width: 100%;
    height: 100%;
}

/* 返回顶部 */
#backToTop {
    position: fixed;
    right: 18px;
    bottom: 24px;
    width: 42px;
    height: 42px;
    line-height: 42px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    background: #fff;
    border: 1px solid #f0d2cf;
    color: var(--red);
    box-shadow: 0 8px 20px rgba(20,24,32,.10);
    font-size: 18px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

#backToTop.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* 旧样式兼容隐藏 */
.summary-panel,
.summary-panel-compact,
.panel-title,
.query-panel,
.tag,
.match,
.recommend,
.badge,
.forecast {
    /* 当前版本主列表不再使用这些旧卡片结构 */
}

/* 响应式 */
@media (min-width: 721px) {
    .wrap {
        padding: 16px 16px 22px;
    }
}

@media (max-width: 680px) {
    .mode-tabbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .wrap {
        padding: 10px 10px 16px;
    }

    .hero-top {
        padding: 12px;
    }

    .hero-main-title {
        font-size: 18px;
    }

    .stats-hero {
        gap: 6px;
    }

    .hero-stat {
        padding: 8px 6px;
    }

    .hero-stat .k {
        font-size: 10px;
    }

    .hero-stat .v {
        font-size: 14px;
    }

    .filter-card {
        padding: 10px;
        gap: 10px;
    }

    .mode-tabbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .mode-tab {
        height: 34px;
        font-size: 12px;
    }

    .plan-table {
        min-width: 300px;
    }

    .plan-table thead th,
    .plan-table tbody td {
        padding: 10px 10px;
    }

    .td-date {
        width: 64px;
        font-size: 12px;
    }

    .td-income {
        width: 80px;
    }

    .status-pill {
        min-width: 50px;
        height: 24px;
        padding: 0 8px;
        font-size: 11px;
    }

    .export-panel {
        width: calc(100vw - 14px);
    }

    .template-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
