/* 家庭资产 · 账本式排版：白纸、细线、无卡片。数字用系统字体的等宽数字特性，不用 mono。 */
:root {
    color-scheme: light;
    --paper: #ffffff;
    --ink: #1f1d1a;        /* 墨 */
    --ink-2: #5f5a52;
    --ink-3: #9a958c;
    --rule: #e3e0da;       /* 账本横线 */
    --rule-2: #f1efea;
    --up: #c0392b;         /* 涨，红 */
    --down: #2e7d4f;       /* 跌，绿 */
    --sans: -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--sans); background: var(--paper); color: var(--ink);
    font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}
.page { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 0; }
.page > * { min-width: 0; max-width: 100%; }
.stat-grid > * { min-width: 0; }
a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--up); } .neg { color: var(--down); } .muted { color: var(--ink-3); }
[hidden] { display: none !important; }

/* 桌面：左宽右窄，表格通栏 */
@media (min-width: 1000px) {
    .page { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); column-gap: 56px; row-gap: 0; align-items: start;
            grid-template-areas: "top top" "hero alloc" "chart change" "table table" "foot foot"; }
    .topbar { grid-area: top; } .area-hero { grid-area: hero; } .area-alloc { grid-area: alloc; }
    .area-chart { grid-area: chart; } .area-change { grid-area: change; } .area-table { grid-area: table; } .area-foot { grid-area: foot; }
    .chart-wrap { height: 320px; }
}

/* 顶栏 */
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--ink); margin-bottom: 26px; }
.brand { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; min-width: 0; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { color: var(--ink-2); font-size: 13px; }
.btn { border: 1px solid var(--rule); background: transparent; color: var(--ink); padding: 5px 12px; border-radius: 3px; font-size: 13px; cursor: pointer; font-family: inherit; }

/* 主数字 */
.hero-band { padding: 0 0 26px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.hero-top { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; align-items: flex-end; }
.caps-gold { font-size: 13px; color: var(--ink-2); }
.hero-tag { margin-left: 6px; color: var(--ink-3); font-size: 12px; }
.hero-num { font-size: 44px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.1; margin: 6px 0 10px; color: var(--ink); }
@media (min-width: 768px) { .hero-num { font-size: 52px; } }
.hero-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero-hint { color: var(--ink-3); font-size: 12px; }
.pill { font-size: 14px; }
.pill-pos { color: var(--up); } .pill-neg { color: var(--down); } .pill-flat { color: var(--ink-3); }

.goal { min-width: 240px; flex: 0 1 300px; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.goal-head .caps-gold { font-size: 12px; }
.goal-pct { font-weight: 500; font-size: 15px; color: var(--ink); }
.progress-track { height: 3px; background: var(--rule); position: relative; }
.progress-fill { height: 100%; width: 0; background: var(--ink); transition: width 0.4s ease; }
.goal-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--ink-3); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; margin-top: 24px; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { border-left: 1px solid var(--rule); padding-left: 12px; }
.stat-lab { font-size: 12px; color: var(--ink-3); }
.stat-val { font-weight: 500; font-size: 17px; margin-top: 2px; }
.stat-val.neg { color: var(--ink); }
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

/* 分区 */
.card { min-width: 0; padding: 0 0 26px; margin-bottom: 26px; border-bottom: 1px solid var(--rule); }
.area-table, .area-change { border-bottom: 0; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 0 0 10px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-meta { font-size: 12px; color: var(--ink-3); }
.chart-wrap { position: relative; height: 260px; padding: 4px 0 0; min-width: 0; }
@media (max-width: 640px) { .chart-wrap { height: 220px; } }

.alloc-list { padding: 0; }
.alloc-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule-2); gap: 12px; }
.alloc-row:last-child { border-bottom: 0; }
.alloc-name { display: flex; align-items: baseline; gap: 8px; }
.dot { display: none; }
.alloc-sub { font-size: 12px; color: var(--ink-3); }
.alloc-right { text-align: right; }
.alloc-amt { font-weight: 500; }
.alloc-pct { font-size: 12px; color: var(--ink-3); }
.bar { display: none; }

/* 四桶明细弹层：桌面悬停、手机点开 */
.alloc-row.has-pop { position: relative; cursor: default; }
.alloc-row.has-pop > div:first-child > .alloc-name > span:nth-child(2) { border-bottom: 1px dotted var(--ink-3); }
.pop { display: none; position: absolute; right: 0; top: calc(100% - 2px); z-index: 10; min-width: 260px; max-width: 360px;
       background: var(--paper); border: 1px solid var(--rule); box-shadow: 0 8px 24px rgba(31,29,26,0.12); padding: 8px 12px; font-size: 13px; }
.alloc-row.has-pop:hover .pop, .alloc-row.open .pop { display: block; }
@media (hover: none) { .alloc-row.has-pop:hover .pop { display: none; } .alloc-row.open .pop { display: block; } }
.pop-row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border-bottom: 1px solid var(--rule-2); }
.pop-row:last-child { border-bottom: 0; }
.pop-row .n { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-row .v { white-space: nowrap; }
.pop-p { font-size: 12px; margin-left: 6px; }
.pop-sum { border-top: 1px solid var(--rule); margin-top: 2px; padding-top: 6px; }
.pop-sum .n { color: var(--ink-3); font-size: 12px; }
.pop-empty { color: var(--ink-3); font-size: 12px; padding: 2px 0; }

/* 月度表 */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 400; font-size: 12px; color: var(--ink-3); padding: 6px 10px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: #faf9f6; }
.r { text-align: right !important; }
@media (max-width: 640px) { .hide-sm { display: none; } }
.tag { font-size: 12px; color: var(--ink-3); margin-left: 6px; }
.tag::before { content: '('; } .tag::after { content: ')'; }
.tag + .tag { margin-left: 2px; }
.tag-warn { color: var(--ink-2); }
.empty { padding: 32px 0; color: var(--ink-3); }
.foot { color: var(--ink-3); font-size: 12px; padding-top: 20px; border-top: 1px solid var(--rule); margin-top: 8px; }

/* 月份详情 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(31,29,26,0.4); display: none; align-items: flex-start; justify-content: center; padding: 32px 12px; overflow-y: auto; }
.overlay.active { display: flex; }
.overlay-card { width: 100%; max-width: 720px; background: var(--paper); border-radius: 4px; box-shadow: 0 24px 60px rgba(0,0,0,0.18); padding: 22px 26px 26px; }
.overlay-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.overlay-h .tag { margin-left: 8px; }
.dt-section { margin-top: 18px; }
.dt-section h4 { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.dt-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; }
@media (min-width: 640px) { .dt-grid { grid-template-columns: repeat(4, 1fr); } }
.dt-cell { border-left: 1px solid var(--rule); padding-left: 10px; }
.dt-cell .lab { font-size: 12px; color: var(--ink-3); }
.dt-cell .val { font-weight: 500; margin-top: 2px; }
.h-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--rule-2); font-size: 13px; gap: 12px; }
.h-row:last-child { border-bottom: 0; }
.h-row .n { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-row .v { white-space: nowrap; }
.h-group { display: flex; justify-content: space-between; margin: 14px 0 4px; font-weight: 600; }
.note { color: var(--ink-2); font-size: 13px; border-left: 2px solid var(--rule); padding: 4px 12px; }
