/* 记账本 · 样式 */
:root {
  --bg: #f2f5f3;
  --bg2: #e9eeeb;
  --card: #ffffff;
  --text: #0f1a16;
  --sub: #6c7b75;
  --line: rgba(15, 26, 22, 0.07);
  --line2: rgba(15, 26, 22, 0.12);
  --brand: #12b886;
  --brand-d: #0b9c70;
  --exp: #e4615a;
  --inc: #10a46e;
  --sav: #3b77f2;
  --key: #f3f6f5;
  --shadow: 0 1px 2px rgba(15, 26, 22, 0.04), 0 10px 28px -18px rgba(15, 26, 22, 0.25);
  --r: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1110;
    --bg2: #121917;
    --card: #171e1b;
    --text: #edf3f0;
    --sub: #8b9a95;
    --line: rgba(255, 255, 255, 0.08);
    --line2: rgba(255, 255, 255, 0.14);
    --key: #212926;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -18px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

input, button, textarea, select { font-family: inherit; font-size: 17px; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.app { min-height: 100vh; min-height: 100dvh; }

.view {
  padding: calc(var(--safe-t) + 10px) 16px calc(96px + var(--safe-b));
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- 顶栏 ---------- */
.hd { padding: 6px 2px 12px; }
.hd-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hd-title { font-size: 29px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.15; }
.hd-sub { font-size: 13px; color: var(--sub); margin-top: 3px; }
.add-btn {
  width: 40px; height: 40px; border-radius: 14px; flex: 0 0 auto;
  background: var(--brand); color: #fff; font-size: 26px; font-weight: 300;
  line-height: 36px; text-align: center;
  box-shadow: 0 6px 16px -6px rgba(18, 184, 134, 0.7);
}
.add-btn:active { transform: scale(0.94); }
.back {
  width: 36px; height: 36px; border-radius: 12px; background: var(--card);
  display: flex; align-items: center; justify-content: center; color: var(--text);
  border: 1px solid var(--line); margin-bottom: 10px;
}

/* ---------- 月份切换 ---------- */
.mbar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 2px 0 14px;
}
.mbtn {
  width: 38px; height: 38px; border-radius: 12px; color: var(--sub);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: transparent;
}
.mbtn:active { background: var(--bg2); }
.mlabel { display: flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 600; min-width: 132px; justify-content: center; }
.now-tag {
  font-size: 10px; font-weight: 600; color: var(--brand);
  background: rgba(18, 184, 134, 0.12); padding: 2px 6px; border-radius: 6px;
}

/* ---------- 主卡 ---------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 26px; padding: 22px 22px 20px;
  color: #fff;
  background: linear-gradient(150deg, #16453a 0%, #103329 48%, #0b241d 100%);
  box-shadow: 0 22px 44px -30px rgba(8, 52, 40, 0.95);
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -110px; width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(30, 214, 160, 0.38) 0%, rgba(30, 214, 160, 0) 68%);
}
.hero-label { font-size: 13px; color: rgba(255, 255, 255, 0.62); letter-spacing: 0.2px; }
.hero-amt {
  margin-top: 6px; font-size: 42px; font-weight: 700; letter-spacing: -1.4px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
  display: flex; align-items: baseline; gap: 3px;
}
.hero-amt .cur { font-size: 22px; font-weight: 600; opacity: 0.75; letter-spacing: 0; }
.hero-stats {
  margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.12);
  position: relative; z-index: 1;
}
.hero-stats div { display: flex; flex-direction: column; gap: 3px; }
.hero-stats span { font-size: 11px; color: rgba(255, 255, 255, 0.55); }
.hero-stats b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--r); padding: 16px;
  box-shadow: var(--shadow); margin-top: 14px;
}
.card-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 600; letter-spacing: 0.1px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.link { color: var(--brand); font-size: 13px; font-weight: 500; }

/* ---------- 进度条 ---------- */
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); transition: width 0.35s ease; }
.bar.thick { height: 9px; }
.bar.over > i { background: var(--exp); }

/* ---------- 分类行 ---------- */
.cat { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.cat + .cat { border-top: 1px solid var(--line); }
.cat-ic {
  width: 42px; height: 42px; border-radius: 14px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.cat-main { flex: 1 1 auto; min-width: 0; }
.cat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat-name { font-size: 15px; font-weight: 500; }
.cat-amt { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-amt span { font-size: 11px; color: var(--sub); font-weight: 400; }
.cat-bot { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: 11.5px; color: var(--sub); }
.cat-bot .good { color: var(--brand); }
.cat-bot .bad { color: var(--exp); }

/* ---------- 记录 ---------- */
.daygroup { margin-top: 12px; }
.day-hd { display: flex; justify-content: space-between; font-size: 12px; color: var(--sub); padding: 4px 2px 6px; }
.day-hd b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.rec { display: flex; align-items: center; gap: 11px; padding: 10px 0; }
.rec + .rec { border-top: 1px solid var(--line); }
.rec-ic { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto; }
.rec-main { flex: 1 1 auto; min-width: 0; }
.rec-t { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-s { font-size: 11.5px; color: var(--sub); margin-top: 1px; }
.rec-a { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
.rec-a.inc { color: var(--inc); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--sub); font-size: 13px; padding: 26px 10px 18px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: 0.8; }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: flex-start;
  padding: 8px 6px calc(6px + var(--safe-b));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .tabbar { background: rgba(18, 24, 22, 0.86); }
}
.tab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--sub); font-size: 10.5px; padding: 2px 0; transition: color 0.15s;
}
.tab svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--brand); }
.tab.on svg { stroke-width: 2; }

/* ---------- 弹层 ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.overlay.on { pointer-events: auto; }
.scrim {
  position: absolute; inset: 0; background: rgba(6, 14, 11, 0.38);
  opacity: 0; transition: opacity 0.25s;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.overlay.on .scrim { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(16px + var(--safe-b));
  max-height: 94dvh; overflow-y: auto;
  transform: translateY(102%); transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.4);
}
.overlay.on .sheet { transform: translateY(0); }
.handle { width: 38px; height: 5px; border-radius: 99px; background: var(--line2); margin: 4px auto 12px; }
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; margin-bottom: 12px; }

/* ---------- 分段控件 ---------- */
.seg { display: flex; background: var(--key); border-radius: 13px; padding: 3px; gap: 2px; }
.seg-i { flex: 1; text-align: center; padding: 8px 0; border-radius: 10px; font-size: 13.5px; color: var(--sub); font-weight: 500; transition: all 0.18s; }
.seg-i.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

/* ---------- 金额 ---------- */
.amount { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 16px 0 8px; }
.amount .cur { font-size: 22px; color: var(--sub); font-weight: 500; }
.amount b { font-size: 40px; font-weight: 700; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; }

/* ---------- 分类选择 ---------- */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 6px; margin: 0 -18px; padding-left: 18px; padding-right: 18px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: 0 0 auto; width: 62px; padding: 8px 0 7px; border-radius: 14px;
  background: var(--key); display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1.5px solid transparent; transition: all 0.15s;
}
.cat-chip .e { font-size: 20px; line-height: 1.2; }
.cat-chip .n { font-size: 10.5px; color: var(--sub); max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-chip.on { border-color: var(--brand); background: rgba(18, 184, 134, 0.1); }
.cat-chip.on .n { color: var(--brand); font-weight: 600; }
.cat-chip.add { justify-content: center; color: var(--brand); font-size: 22px; }

/* ---------- 输入框 ---------- */
.field { margin-top: 10px; }
.field input {
  width: 100%; border: 0; background: var(--key); border-radius: 13px;
  padding: 12px 14px; font-size: 16px; outline: none; color: var(--text);
}
.field input::placeholder { color: var(--sub); opacity: 0.7; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* ---------- 键盘 ---------- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.key {
  height: 50px; border-radius: 14px; background: var(--key);
  font-size: 22px; font-weight: 500; display: flex; align-items: center; justify-content: center;
  transition: background 0.1s; font-variant-numeric: tabular-nums;
}
.key:active { background: var(--line2); }
.key.del { font-size: 19px; }
.primary {
  width: 100%; height: 52px; border-radius: 16px; margin-top: 10px;
  background: linear-gradient(180deg, #16c48f, #0fae7d); color: #fff;
  font-size: 17px; font-weight: 600; letter-spacing: 0.3px;
  box-shadow: 0 10px 24px -12px rgba(18, 184, 134, 0.9);
}
.primary:active { transform: scale(0.985); opacity: 0.95; }
.primary.ghost { background: var(--key); color: var(--exp); box-shadow: none; }
.scanline { margin-top: 2px; text-align: center; }
.chipbtn {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: 99px;
  background: rgba(18, 184, 134, 0.1); color: var(--brand); font-size: 12.5px; font-weight: 500;
}

/* ---------- 分类管理 ---------- */
.cm-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.cm-row + .cm-row { border-top: 1px solid var(--line); }
.cm-ic { width: 42px; height: 42px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 21px; flex: 0 0 auto; }
.cm-main { flex: 1; min-width: 0; }
.cm-t { font-size: 15px; font-weight: 500; }
.cm-s { font-size: 11.5px; color: var(--sub); margin-top: 2px; }
.chev { color: var(--sub); opacity: 0.55; font-size: 18px; }
.addrow { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 0 4px; color: var(--brand); font-size: 14.5px; font-weight: 500; border-top: 1px solid var(--line); margin-top: 4px; }

/* ---------- 图标选择 ---------- */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-cell { aspect-ratio: 1; border-radius: 11px; background: var(--key); display: flex; align-items: center; justify-content: center; font-size: 18px; border: 1.5px solid transparent; }
.emoji-cell.on { border-color: var(--brand); background: rgba(18, 184, 134, 0.1); }
.color-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.color-cell { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid transparent; }
.color-cell.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--card) inset; }
.label { font-size: 12px; color: var(--sub); margin: 14px 2px 6px; font-weight: 500; }

/* ---------- 说明页 ---------- */
.step { display: flex; gap: 12px; padding: 12px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step-n {
  width: 24px; height: 24px; border-radius: 8px; background: rgba(18, 184, 134, 0.12);
  color: var(--brand); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; margin-top: 1px;
}
.step-b { flex: 1; font-size: 14px; line-height: 1.55; }
.step-b b { font-weight: 600; }
.step-b code {
  background: var(--key); border-radius: 6px; padding: 1px 6px; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all;
}
.tip { font-size: 12px; color: var(--sub); line-height: 1.6; margin-top: 8px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translate(-50%, 12px);
  background: rgba(15, 26, 22, 0.92); color: #fff; font-size: 13px; padding: 10px 16px;
  border-radius: 12px; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 90;
  max-width: 84vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 小结条 ---------- */
.stat3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat3 > div { background: var(--card); border-radius: 16px; padding: 12px 12px 11px; box-shadow: var(--shadow); }
.stat3 span { font-size: 11px; color: var(--sub); }
.stat3 b { display: block; font-size: 17px; font-weight: 650; margin-top: 3px; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }

.big-num { font-size: 38px; font-weight: 700; letter-spacing: -1.2px; font-variant-numeric: tabular-nums; }
.sav-card {
  border-radius: 26px; padding: 22px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(150deg, #2f6ff0 0%, #2358d6 55%, #1a46b4 100%);
  box-shadow: 0 22px 44px -30px rgba(30, 70, 190, 0.9);
}
.sav-card::after {
  content: ""; position: absolute; right: -60px; bottom: -90px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 70%);
}
.sav-label { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.sav-amt { margin-top: 6px; font-size: 40px; font-weight: 700; letter-spacing: -1.3px; font-variant-numeric: tabular-nums; }
.sav-sub { margin-top: 12px; display: flex; gap: 18px; font-size: 12px; color: rgba(255, 255, 255, 0.75); position: relative; z-index: 1; }
.sav-sub b { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }

.btnrow { display: flex; gap: 10px; margin-top: 14px; }
.btnrow .primary { margin-top: 0; }
.btn2 {
  flex: 1; height: 48px; border-radius: 15px; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn2.solid { background: linear-gradient(180deg, #16c48f, #0fae7d); color: #fff; }
.btn2.plain { background: var(--card); color: var(--text); border: 1px solid var(--line2); }

.list-plain { margin-top: 4px; }
.sep { height: 12px; }

/* ---------- 年度视图 ---------- */
.mbar { justify-content: space-between; }
.mspacer { width: 74px; flex: 0 0 auto; }
.mnav { display: flex; align-items: center; justify-content: center; gap: 0; flex: 1 1 auto; min-width: 0; }
.seg-mini { padding: 2px; }
.seg-mini .seg-i { padding: 6px 0; font-size: 12px; border-radius: 8px; }
.chart { display: flex; align-items: flex-end; gap: 5px; height: 116px; margin-top: 10px; }
.chart .col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.chart .cbar { width: 100%; border-radius: 5px; background: rgba(18, 184, 134, 0.26); min-height: 3px; transition: height 0.3s ease; }
.chart .cbar.on { background: var(--brand); }
.chart .col span { font-size: 9px; color: var(--sub); line-height: 1; }
.mrow { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; font-size: 14px; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mrow .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.mrow .sub { font-size: 11px; color: var(--sub); font-weight: 400; margin-left: 7px; }

/* ---------- 支出页两列 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.bcard { background: var(--card); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); }
.bcard .top { display: flex; align-items: center; justify-content: space-between; }
.bcard .pct { font-size: 11px; color: var(--sub); font-variant-numeric: tabular-nums; }
.bcard .name { font-size: 13px; color: var(--sub); margin-top: 9px; }
.bcard .num { font-size: 21px; font-weight: 650; letter-spacing: -0.6px; margin-top: 1px; font-variant-numeric: tabular-nums; }
.bcard .meta { font-size: 11px; color: var(--sub); margin-top: 7px; display: flex; justify-content: space-between; gap: 6px; }
.bcard .meta .good { color: var(--brand); }
.bcard .meta .bad { color: var(--exp); }
.cat-ic.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }
