/* ============================================================
   账本 v3 · 视觉体系
   设计要点：侧栏分组导航 / 卡片层次 / 数据优先 / 深浅双主题
   / 收支配色可对调 / 隐私模式 / 移动端底部标签栏 / 减弱动效
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: #e5eaf2;
  --line-soft: #f0f3f8;
  --track: #e9edf4;

  --text: #151b26;
  --text-2: #44506a;
  --muted: #8a95a8;

  --brand: #4a63e7;
  --brand-2: #7b8cff;
  --brand-soft: #eef1ff;
  --brand-ink: #3549c4;

  /* 默认：支出红、收入绿（记账 App 通行习惯） */
  --income: #0f9d6e;
  --expense: #e05257;
  --income-soft: #e7f7f0;
  --expense-soft: #fdeeee;

  --danger: #d92d20;
  --warn: #dd8a12;
  --ok: #0f9d6e;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 30, 55, .04), 0 8px 28px rgba(20, 30, 55, .045);
  --shadow-hover: 0 2px 6px rgba(20, 30, 55, .06), 0 14px 36px rgba(20, 30, 55, .09);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}
/* 收支配色对调（设置里可切换，兼容旧的「收入红 / 支出绿」习惯） */
body[data-money="reverse"] {
  --income: #d9464b;
  --expense: #0f9d6e;
  --income-soft: #fdeeee;
  --expense-soft: #e7f7f0;
}
body[data-theme="dark"] {
  --bg: #0e131c;
  --surface: #171e2a;
  --surface-2: #1d2634;
  --surface-3: #253043;
  --line: #2b3648;
  --line-soft: #222c3c;
  --track: #283345;
  --text: #e9eef7;
  --text-2: #b9c4d6;
  --muted: #8492a8;
  --brand: #8395ff;
  --brand-2: #a5b2ff;
  --brand-soft: #232b4d;
  --brand-ink: #a8b5ff;
  --income: #4fd6a0;
  --expense: #ff8489;
  --income-soft: #14362c;
  --expense-soft: #3b2025;
  --danger: #ff8f86;
  --warn: #f0be62;
  --ok: #4fd6a0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 10px 28px rgba(0, 0, 0, .18);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, .26), 0 16px 38px rgba(0, 0, 0, .3);
}
body[data-theme="dark"][data-money="reverse"] {
  --income: #ff8489;
  --expense: #4fd6a0;
  --income-soft: #3b2025;
  --expense-soft: #14362c;
}

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; }
::selection { background: var(--brand-soft); color: var(--brand-ink); }

/* ---------------- 布局骨架 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 20;
}
.side-brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px;
  color: var(--text); font-size: 15.5px; font-weight: 700; letter-spacing: -.2px;
}
.side-brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: none; border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(74, 99, 231, .28);
}
.brand-mark svg { width: 18px; height: 18px; }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav-group { margin-top: 14px; }
.nav-group > span {
  display: block; padding: 0 10px 6px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; color: var(--muted); text-transform: uppercase;
}
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; margin: 2px 0;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.side-nav a svg { width: 17px; height: 17px; flex: none; opacity: .72; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.side-nav a.on svg { opacity: 1; }
.side-nav a .badge {
  margin-left: auto; background: var(--surface-3); color: var(--muted);
  font-size: 10.5px; padding: 1px 6px; border-radius: 20px; font-weight: 600;
}
.side-nav a.on .badge { background: var(--surface); color: var(--brand-ink); }
.side-foot { border-top: 1px solid var(--line-soft); padding: 10px 14px 14px; }
.side-foot .side-meta { font-size: 11px; color: var(--muted); padding: 2px 4px 9px; line-height: 1.5; }
.side-tools { display: flex; gap: 6px; }
.side-tools button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2);
  border-radius: 8px; padding: 7px 4px; cursor: pointer; font-size: 11.5px;
}
.side-tools button:hover { border-color: var(--brand); color: var(--brand); }
.side-tools svg { width: 14px; height: 14px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex: none; background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 26px;
  position: sticky; top: 0; z-index: 15;
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--surface); }
}
.top-title { font-size: 15px; font-weight: 650; white-space: nowrap; }
.top-title small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.top-search { margin-left: auto; position: relative; width: 220px; }
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.top-search input {
  width: 100%; margin: 0; padding: 7px 10px 7px 33px; min-height: 34px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; color: var(--text);
}
.top-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-icon {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.top-icon:hover { color: var(--brand); border-color: var(--brand); }
.top-icon svg { width: 16px; height: 16px; }
.top-icon.active { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.btn-add {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  background: var(--brand); color: #fff !important; font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(74, 99, 231, .22);
}
.btn-add:hover { text-decoration: none; opacity: .92; transform: translateY(-1px); }
.btn-add svg { width: 15px; height: 15px; }
.wrap { width: 100%; max-width: 1220px; margin: 0 auto; padding: 0 26px; }
main.wrap { padding-top: 24px; padding-bottom: 44px; }
.foot { color: var(--muted); font-size: 11.5px; padding: 0 26px 22px; text-align: center; }
.mobile-nav { display: none; }

/* ---------------- 通用元素 ---------------- */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin: 2px 0 18px; }
h2 { font-size: 14.5px; font-weight: 650; margin: 0 0 14px; letter-spacing: -.1px; }
h2.mt { margin-top: 24px; }
h3 { font-size: 13px; font-weight: 650; margin: 0 0 10px; }
.sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; line-height: 1.65; }
.hint-inline { margin-left: 8px; font-size: 12px; }
.top-hint { margin: -6px 0 16px; }
.empty { color: var(--muted); margin: 4px 0; font-size: 13px; }
code, kbd {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; font-size: 11.5px; font-family: Consolas, Monaco, monospace;
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card.hoverable:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .hint { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }
.cards .card { margin: 0; }
.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ''; position: absolute; right: -22px; top: -22px; width: 74px; height: 74px;
  border-radius: 50%; background: var(--surface-2); opacity: .7;
}
.stat > * { position: relative; z-index: 1; }
.stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; font-weight: 500; }
.stat strong { display: block; font-size: 23px; font-weight: 700; letter-spacing: -.7px; line-height: 1.25; }
.stat small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 7px; }
.stat .trend { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 7px; border-radius: 20px; font-weight: 600; }
.trend.up { background: var(--expense-soft); color: var(--expense); }
.trend.down { background: var(--income-soft); color: var(--income); }
.trend.flat { background: var(--surface-3); color: var(--muted); }
.in { color: var(--income); }
.out { color: var(--expense); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.dim { opacity: .5; }
.mono-num { font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-between h2 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* 隐私模式：模糊所有金额文本 */
body[data-privacy="on"] .privacy { filter: blur(7px); user-select: none; pointer-events: none; transition: filter .18s ease; }

/* Hero 卡：本月结余 / 净资产 */
.hero {
  position: relative; overflow: hidden; color: #fff; border: 0;
  background: linear-gradient(122deg, #3f57d8 0%, #5b6ff0 48%, #8a7bf6 100%);
  padding: 24px 26px; margin-bottom: 18px;
}
body[data-theme="dark"] .hero { background: linear-gradient(122deg, #2b3a86 0%, #3c4da8 48%, #5b4b9c 100%); }
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .09);
}
.hero::before { width: 240px; height: 240px; right: -60px; top: -130px; }
.hero::after { width: 150px; height: 150px; right: 110px; bottom: -110px; }
.hero > * { position: relative; z-index: 1; }
.hero .hero-label { font-size: 12px; opacity: .82; letter-spacing: .04em; }
.hero .hero-value { font-size: 34px; font-weight: 700; letter-spacing: -1.2px; margin: 4px 0 6px; line-height: 1.2; }
.hero .hero-sub { font-size: 12px; opacity: .86; }
.hero-stats { display: flex; gap: 30px; margin-top: 20px; flex-wrap: wrap; }
.hero-stats div span { display: block; font-size: 11px; opacity: .75; }
.hero-stats div b { font-size: 16px; font-weight: 650; letter-spacing: -.3px; }
.hero-badge {
  position: absolute; right: 24px; top: 22px; z-index: 1;
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 20px; padding: 4px 12px; font-size: 11.5px; backdrop-filter: blur(4px);
}

/* ---------------- 表单 ---------------- */
label { display: block; font-size: 12px; color: var(--text-2); font-weight: 500; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 13.5px; min-height: 38px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
textarea { min-height: 76px; resize: vertical; }
input::placeholder { color: var(--muted); opacity: .8; }
input[type="checkbox"], input[type="radio"] {
  display: inline-block; width: auto; min-height: 0; margin: 0; vertical-align: middle; accent-color: var(--brand);
}
input[type="color"] { padding: 3px; height: 38px; cursor: pointer; }
input[type="file"] { padding: 7px; background: var(--surface-2); font-size: 12px; }
input[type="month"] { width: 148px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid .wide { grid-column: 1 / -1; }
.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filters label { min-width: 120px; flex: 1; }
.filter-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form label { max-width: 160px; }
.form-actions { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer; min-height: 38px; white-space: nowrap;
  transition: all .16s ease;
}
.btn:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(74, 99, 231, .2); }
.btn.primary:hover { opacity: .9; color: #fff; background: var(--brand); }
.btn.ghost { color: var(--brand); background: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--expense-soft); border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 12px; }
.btn.full { width: 100%; margin-top: 16px; }
.link, button.link {
  background: none; border: 0; padding: 0; color: var(--brand);
  cursor: pointer; font: inherit; font-size: 12.5px;
}
.link.danger, button.link.danger { color: var(--danger); }
.sp { margin-left: 9px; }
.inline { display: inline; margin: 0 0 0 9px; }
.inline.mt { display: inline-block; margin-top: 12px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; font-size: 11.5px; letter-spacing: .02em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: var(--surface-2); }
td input[type="text"] { margin-top: 0; min-height: 32px; padding: 5px 8px; }
.note-col { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck { width: 34px; }
.sumline { color: var(--text-2); margin: 0 0 14px; font-size: 12.5px; }
.sumline b { color: var(--text); }

/* 消息 */
.flash {
  display: flex; align-items: center; gap: 8px;
  background: var(--income-soft); border: 1px solid var(--line);
  color: var(--text); padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px;
  animation: slideIn .28s ease both;
}
.flash.warn { background: var(--surface-2); border-color: var(--warn); }
.errors { background: var(--expense-soft); border: 1px solid var(--danger); color: var(--danger); padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px; }
.errors ul { margin: 0; padding-left: 18px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.pager a { padding: 6px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; }
.pager a:hover { text-decoration: none; border-color: var(--brand); }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager-info { color: var(--muted); font-size: 12px; margin-left: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col > .card { margin-bottom: 18px; }
.month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.month-form { display: flex; margin: 0; }
.month-form input { width: 148px; margin: 0; }
.tabs { display: inline-flex; gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.tabs a { padding: 6px 16px; border-radius: 7px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tabs a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.tabs a:hover { text-decoration: none; color: var(--brand); }

/* ---------------- 图表 ---------------- */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; flex: none; }
.donut-bg { stroke: var(--track); }
.donut-seg { transition: stroke-width .2s ease; }
.donut-seg:hover { stroke-width: 23; }
.donut-t1 { fill: var(--muted); font-size: 10.5px; }
.donut-t2 { fill: var(--text); font-size: 16px; font-weight: 700; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.legend i, .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--brand); flex: none; }
.dot { margin-right: 6px; border-radius: 50%; }
.legend span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 650; }
.legend em { font-style: normal; color: var(--muted); width: 42px; text-align: right; font-size: 11.5px; }
.chart-wrap { width: 100%; overflow: hidden; }
.columns { width: 100%; height: auto; }
.axis { fill: var(--muted); font-size: 10px; }
.axis-line { stroke: var(--line); }
.grid-line { stroke: var(--line-soft); stroke-dasharray: 3 4; }
.bar-income { fill: var(--income); }
.bar-expense { fill: var(--expense); }
.area-income { fill: var(--income); opacity: .12; }
.area-expense { fill: var(--expense); opacity: .12; }
.line-income { fill: none; stroke: var(--income); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.line-expense { fill: none; stroke: var(--expense); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-name { width: 88px; flex: none; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 10px; background: var(--track); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; background: var(--brand); transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.bar-val { width: 96px; text-align: right; flex: none; font-size: 12.5px; font-weight: 550; }
.bar-pct { width: 46px; text-align: right; flex: none; font-size: 11.5px; color: var(--muted); }
.mini-track { display: block; height: 7px; background: var(--track); border-radius: 5px; overflow: hidden; min-width: 80px; }
.mini-track span { display: block; height: 100%; border-radius: 5px; }
.progress { height: 9px; background: var(--track); border-radius: 6px; overflow: hidden; margin: 9px 0; }
.progress-fill { display: block; height: 100%; border-radius: 6px; background: var(--income); transition: width .5s cubic-bezier(.22, 1, .36, 1); }
.progress-fill.warn { background: var(--warn); }
.progress-fill.over { background: var(--danger); }
.progress-fill.none { background: var(--track); }
.out-bg { background: var(--expense); }
.in-bg { background: var(--income); }
.budget-figs { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.budget-figs strong { font-size: 21px; font-weight: 700; }
.budget-figs span { color: var(--muted); }
.budget-figs b { margin-left: auto; font-size: 13.5px; }
.budget-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.budget-row:last-child { border-bottom: 0; }
.budget-row em { font-style: normal; color: var(--muted); margin-left: 8px; }
.budget-total { max-width: 320px; margin-bottom: 8px; }
.kv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kv-grid div { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 11px 13px; }
.kv-grid span { display: block; color: var(--muted); font-size: 11.5px; }
.kv-grid b { display: block; font-size: 14px; margin-top: 3px; font-weight: 650; }
.weekday-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 18px; }
.wd-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.wd-val { font-size: 10px; color: var(--muted); white-space: nowrap; }
.wd-bar { width: 60%; max-width: 28px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-radius: 5px 5px 0 0; margin-top: 4px; min-height: 2px; transition: height .5s ease; }
.wd-name { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* 洞察 / 提示条目 */
.insight-list { display: grid; gap: 10px; }
.insight {
  display: flex; align-items: flex-start; gap: 11px; padding: 11px 13px;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  font-size: 12.8px; line-height: 1.6;
}
.insight .ico {
  width: 27px; height: 27px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
}
.insight .ico svg { width: 14px; height: 14px; }
.insight.warn .ico { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }
.insight.good .ico { background: var(--income-soft); color: var(--income); }
.insight b { font-weight: 650; }
.insight small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.streak {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--brand-soft), var(--surface-2)); margin-bottom: 14px;
}
.streak .num { font-size: 27px; font-weight: 750; color: var(--brand-ink); line-height: 1; }
.streak .txt { font-size: 12.5px; color: var(--text-2); }

/* 日历热力图 */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  min-height: 78px; border: 1px solid var(--line-soft); border-radius: 10px; padding: 7px 8px;
  background: var(--surface); display: flex; flex-direction: column; gap: 2px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
a.cal-cell:hover { text-decoration: none; border-color: var(--brand); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.cal-cell.blank { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.cal-cell .d { font-size: 11.5px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.cal-cell .d i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.cal-cell .v { font-size: 12px; font-weight: 650; line-height: 1.35; }
.cal-cell .v.out { color: var(--expense); }
.cal-cell .v.in { color: var(--income); }
.cal-cell .cnt { font-size: 10.5px; color: var(--muted); margin-top: auto; }
.cal-cell.h1 { background: var(--surface-2); }
.cal-cell.h2 { background: var(--surface-3); }
.cal-cell.h3 { background: var(--surface-3); }
.cal-cell.h4 { background: var(--surface-3); }
.cal-cell.h1 { background: color-mix(in srgb, var(--expense) 8%, var(--surface)); }
.cal-cell.h2 { background: color-mix(in srgb, var(--expense) 16%, var(--surface)); }
.cal-cell.h3 { background: color-mix(in srgb, var(--expense) 26%, var(--surface)); }
.cal-cell.h4 { background: color-mix(in srgb, var(--expense) 38%, var(--surface)); }
.cal-legend { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.cal-legend i { width: 15px; height: 15px; border-radius: 4px; display: inline-block; }

/* 目标进度环 */
.goal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.goal-card { position: relative; }
.goal-ring { width: 92px; height: 92px; flex: none; }
.goal-ring .ring-bg { stroke: var(--track); }
.goal-ring .ring-fg { stroke: var(--brand); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.goal-ring .ring-txt { fill: var(--text); font-size: 17px; font-weight: 700; text-anchor: middle; }
.goal-top { display: flex; align-items: center; gap: 14px; }
.goal-top h3 { font-size: 14px; margin: 0 0 3px; }
.goal-top p { margin: 0; color: var(--muted); font-size: 11.5px; }
.goal-figs { display: flex; align-items: baseline; gap: 6px; margin-top: 3px; }
.goal-figs b { font-size: 17px; font-weight: 700; }
.goal-figs span { color: var(--muted); font-size: 12px; }
.goal-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* 周期账 / 规则 */
.rule-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.rule-row:last-child { border-bottom: 0; }
.rule-row .rname { font-weight: 600; font-size: 13px; }
.rule-row .rmeta { color: var(--muted); font-size: 11.5px; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); font-weight: 550; }
.pill.on { background: var(--income-soft); color: var(--income); }
.pill.off { background: var(--surface-3); color: var(--muted); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }

/* 标签 / chips / 导出 */
.tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); border-radius: 5px; padding: 0 6px; font-size: 10.5px; margin: 1px 3px 1px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); border-radius: 20px; padding: 5px 12px; font-size: 12px; cursor: pointer; font-family: inherit; transition: all .16s ease; }
.chip:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; background: var(--brand-soft); }
.chip.tpl { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.export-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.export-item { display: block; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 13px 15px; transition: all .16s ease; }
.export-item:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.export-item b { display: block; font-size: 13px; color: var(--text); }
.export-item span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 3px; line-height: 1.5; }
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }
.danger-zone label { max-width: 320px; }

/* 登录页 */
.login-body { background: radial-gradient(900px 500px at 18% -10%, #dfe6ff 0%, transparent 60%), radial-gradient(700px 420px at 100% 100%, #e5dfff 0%, transparent 58%), var(--bg); }
body[data-theme="dark"].login-body { background: radial-gradient(900px 500px at 18% -10%, #22305e 0%, transparent 60%), radial-gradient(700px 420px at 100% 100%, #352b5c 0%, transparent 58%), var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; margin: 0; box-shadow: var(--shadow-hover); }
.login-card .brand-mark { width: 42px; height: 42px; border-radius: 12px; margin-bottom: 18px; }
.login-card .brand-mark svg { width: 22px; height: 22px; }
.login-card h1 { margin: 0 0 3px; font-size: 21px; }
.login-card label { margin-bottom: 14px; margin-top: 20px; }
.login-card .hint { font-size: 11.5px; }

/* 空状态 */
.empty-state { text-align: center; padding: 26px 12px; color: var(--muted); }
.empty-state svg { width: 46px; height: 46px; opacity: .45; margin-bottom: 8px; }
.empty-state p { margin: 4px 0; font-size: 13px; }

/* 动效 */
.card, .stat { animation: fadeUp .32s ease both; }
.cards .card:nth-child(2) { animation-delay: .04s; }
.cards .card:nth-child(3) { animation-delay: .08s; }
.cards .card:nth-child(4) { animation-delay: .12s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .goal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { padding: 0 16px; }
  .wrap { padding: 0 16px; }
  .foot { padding: 0 16px 92px; }
  main.wrap { padding-bottom: 24px; }
  .two-col { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around;
    box-shadow: 0 -4px 20px rgba(20, 30, 55, .07);
  }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; padding: 4px 8px; border-radius: 8px; min-width: 54px; }
  .mobile-nav a svg { width: 19px; height: 19px; }
  .mobile-nav a.on { color: var(--brand); background: var(--brand-soft); }
  .mobile-nav a:hover { text-decoration: none; }
  .top-search { width: 160px; }
}
@media (max-width: 680px) {
  .cards, .cards-3, .cards-4, .grid, .grid-2, .grid-4, .kv-grid, .export-grid, .goal-grid { grid-template-columns: repeat(2, 1fr); }
  .cards .stat strong { font-size: 18px; }
  .stat small { font-size: 11px; }
  .top-title { font-size: 13.5px; }
  .top-title small { display: none; }
  .top-search { display: none; }
  .btn-add span { display: none; }
  .btn-add { padding: 8px 10px; }
  .hero { padding: 20px; }
  .hero .hero-value { font-size: 28px; }
  .hero-stats { gap: 18px; }
  .bar-name { width: 62px; }
  .bar-val { width: 82px; font-size: 11.5px; }
  .bar-pct { display: none; }
  .card { padding: 15px; border-radius: 12px; }
  .filters label { min-width: 45%; }
  .donut { width: 138px; height: 138px; }
  .legend { min-width: 100%; }
  .budget-figs b { margin-left: 0; }
  .cal-grid, .cal-head { gap: 3px; }
  .cal-cell { min-height: 58px; padding: 4px 5px; border-radius: 7px; }
  .cal-cell .v { font-size: 10px; }
  .cal-cell .cnt { display: none; }
  .cal-cell .d { font-size: 10px; }
  h1 { font-size: 19px; }
  .insight { font-size: 12px; }
}
