/* ============================================================
   小夕账本 v3.0 · iCost 风格（iOS 原生设计语言）
   - 浅灰底 #F5F5F7 · 白色大圆角卡片
   - 支出珊瑚红 #EF655D · 收入亮绿 #2BCB72 · 选中蓝 #1677E8
   - 新增按钮黄色 #FFB71B · 悬浮胶囊毛玻璃底部导航
   - 日期组 = 灰底标题 + 白色圆角容器包住当日交易
   - 行内 inset 分隔线（从内容左缘开始，不贯穿）
   ============================================================ */
:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --ink: #111111;
  --ink-2: #3C3C43;
  --ink-3: #8E8E93;
  --line: #E5E5E7;
  --tint: #1677E8;
  --tint-soft: #E7F0FE;
  --income: #2BCB72;
  --income-soft: #E4F9EC;
  --expense: #EF655D;
  --expense-soft: #FDEBEA;
  --transfer: #4E8EF7;
  --transfer-soft: #E8F0FE;
  --amber: #FFB71B;
  --amber-soft: #FDF3E3;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --radius-card: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Display", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", sans-serif;
  --num: -apple-system, "SF Pro Display", "SF Pro SC", "DIN Alternate", "PingFang SC", sans-serif;
}
[data-theme="dark"] {
  --bg: #000000;
  --card: #1C1C1E;
  --ink: #FFFFFF;
  --ink-2: #98989F;
  --ink-3: #636366;
  --line: #38383A;
  --tint-soft: #1E3557;
  --income-soft: #14311F;
  --expense-soft: #3A1F1E;
  --transfer-soft: #152436;
  --amber-soft: #33290F;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 4px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 修复：CSS display 覆盖 HTML hidden 属性，导致该隐藏的行显示出来 */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 84px);
  position: relative;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input, select { font-family: inherit; color: inherit; }
.muted { color: var(--ink-3); font-size: 13px; }
.link { color: var(--tint); text-decoration: none; font-size: 13px; font-weight: 600; }

/* ---------- 视图切换 ---------- */
.view { display: none; }
.view.active { display: block; animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 顶栏（大标题） ---------- */
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 4px 8px;
}
.topbar h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.topbar p { margin-top: 2px; }
.top-actions { display: flex; gap: 10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); color: var(--ink-2);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: transform .15s ease, color .2s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 月份条（iOS 工具栏） ---------- */
.month-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 14px;
}
.month-nav {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: var(--tint); box-shadow: var(--shadow-sm);
}
.month-nav svg { width: 19px; height: 19px; }
.month-label {
  font-size: 20px; font-weight: 700; letter-spacing: 0.01em;
  color: var(--ink-2); text-align: center;
}
.month-right { min-width: 40px; }

/* ---------- 余额大卡（账本页预算卡） ---------- */
.balance-card {
  border-radius: var(--radius-card);
  padding: 24px 22px 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  position: relative;
}
.balance-label {
  font-size: 14px; font-weight: 700; color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
}
.balance-label::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: var(--expense); flex-shrink: 0;
}
.balance-amount {
  font-family: var(--num);
  font-size: 34px; font-weight: 800; letter-spacing: -0.02em;
  margin-top: 6px; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.balance-ring { margin-top: 14px; display: flex; gap: 10px; }
.ring-item {
  flex: 1; background: var(--bg); border-radius: var(--radius-md);
  padding: 10px 12px;
}
.ring-item .r-label { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.ring-item .r-val {
  font-family: var(--num); font-size: 15px; font-weight: 700;
  margin-top: 2px; font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ring-item .r-val.expense { color: var(--expense); }
.ring-item .r-val.income { color: var(--income); }

/* ---------- 下拉刷新 ---------- */
.tx-scroll { position: relative; }
.pull-hint {
  text-align: center; font-size: 12px; color: var(--ink-3);
  padding: 6px 0; height: 30px; line-height: 30px;
  transition: opacity .2s; opacity: 0;
}
.pull-hint.show { opacity: 1; }
.pull-hint.pulling { color: var(--tint); font-weight: 600; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 20px; margin-top: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.small-head { font-size: 17px; font-weight: 700; margin-bottom: 10px; }

/* ---------- 侧滑操作（iOS swipe actions） ---------- */
.swipe-wrap { position: relative; overflow: hidden; touch-action: pan-y; }
.swipe-actions {
  position: absolute; top: 0; right: 0; bottom: 0;
  display: flex; align-items: stretch;
}
.swipe-action {
  width: 72px; color: #fff; font-size: 13px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.swipe-action svg { width: 20px; height: 20px; }
.swipe-action.edit { background: #8E8E93; }
.swipe-action.delete { background: #FF3B30; }
.swipe-content {
  position: relative; background: var(--card);
  transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}
.swipe-wrap.open .swipe-content { transform: translateX(-144px); }
/* 交易列表里的侧滑行 */
.tx-list li.swipe-wrap { padding: 0; border-bottom: none; }
.tx-list li.swipe-wrap .swipe-content {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.tx-list li.swipe-wrap:last-child .swipe-content { border-bottom: none; }
/* 账户列表里的侧滑行 */
.acct-list .swipe-wrap { border-bottom: 1px solid var(--line); }
.acct-list .swipe-wrap:last-child { border-bottom: none; }
.acct-list .swipe-wrap .swipe-content { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }

/* ---------- 交易列表（iOS 分组） ---------- */
.tx-list { list-style: none; }
.tx-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}
.tx-list li:last-child { border-bottom: none; }
.tx-ico {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
}
.tx-ico svg { width: 18px; height: 18px; stroke: currentColor; }
.tx-main { flex: 1; min-width: 0; }
.tx-desc { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amt { font-family: var(--num); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; }
.tx-amt.expense { color: var(--expense); }
.tx-amt.income { color: var(--income); }
.tx-amt.transfer { color: var(--transfer); }
.tx-acct { font-size: 11px; color: var(--ink-3); margin-top: 1px; display: block; }
.tx-date-group {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 6px 8px; font-size: 14px; color: var(--ink-3);
  font-weight: 700; letter-spacing: 0.01em;
}
.tx-date-group:first-child { padding-top: 8px; }
.tx-date-group .date-sum { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.date-group { margin-bottom: 12px; }
.date-group:last-child { margin-bottom: 4px; }
/* 白色圆角容器包住当日交易 */
.date-group > .tx-date-group { cursor: pointer; user-select: none; padding-left: 6px; padding-right: 6px; }
.date-group > .tx-date-group:active { opacity: .6; }
.date-group > .tx-list {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.date-group.collapsed > .tx-list { display: none; }
.date-group .chev { transition: transform .2s; color: var(--ink-3); width: 15px; height: 15px; flex-shrink: 0; }
.date-group.collapsed .chev { transform: rotate(-90deg); }

/* ---------- 交易页 ---------- */
.seg {
  display: flex; gap: 4px; background: var(--bg);
  border-radius: 14px; padding: 4px;
  box-shadow: inset 0 0 0 0.5px var(--line);
}
.seg.wide { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 4px; }
.seg-btn {
  padding: 9px 12px; border-radius: 11px; font-size: 14px; font-weight: 600;
  color: var(--ink-3); transition: all .2s;
}
.seg.wide .seg-btn { padding: 10px 0; text-align: center; }
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.page-list { margin-top: 2px; }
.ghost-btn {
  width: 100%; padding: 14px; border-radius: var(--radius-md); margin-top: 14px;
  background: var(--card); color: var(--tint); font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.ghost-btn:active { transform: scale(0.98); }

/* ---------- 资产页（iOS 分组列表） ---------- */
.net-card {
  border-radius: var(--radius-card); padding: 24px 22px 20px;
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  margin-bottom: 16px;
}
.net-label { font-size: 14px; font-weight: 700; color: var(--ink-3); }
.net-amount {
  font-family: var(--num); font-size: 34px; font-weight: 800;
  margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  color: var(--ink);
}
.net-sub { display: flex; gap: 24px; margin-top: 16px; font-size: 13px; color: var(--ink-3); }
.net-sub b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.group-title {
  font-size: 14px; font-weight: 700; color: var(--ink-3);
  padding: 18px 6px 8px; letter-spacing: 0.01em;
}
.group-title:first-of-type { padding-top: 4px; }
.acct-new-wrap { margin: 4px 0 8px; }
.acct-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 0;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
/* 账户列表做成 iOS inset 分组（一个白卡，圆角只在首尾） */
.acct-list { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 4px; }
.acct-list .acct-row:last-child { border-bottom: none; }
.acct-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.acct-ico svg { width: 18px; height: 18px; }
.acct-main { flex: 1; min-width: 0; }
.acct-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.acct-bal { font-family: var(--num); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.acct-bal.neg { color: var(--expense); }

/* ---------- 记账页（全屏，iCost 式） ---------- */
.add-view {
  position: fixed; inset: 0; z-index: 60;
  height: 100%; max-height: 100%;
  background: var(--bg);
  display: none !important; flex-direction: column;
  overflow: hidden;
  animation: addViewIn .3s cubic-bezier(0.16, 1, 0.3, 1);
}
.add-view.active { display: flex !important; }
@keyframes addViewIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.add-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 8px;
  flex-shrink: 0;
}
.add-topbar .icon-btn { flex-shrink: 0; }
.add-types { flex: 1; }
.add-acct-btn {
  flex-shrink: 0; font-size: 14px; font-weight: 600; color: var(--tint);
  padding: 8px 4px;
}
/* 分类滚动区（5 列） */
.add-cat-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 6px 14px 12px;
  -webkit-overflow-scrolling: touch;
}
.add-cat-grid { grid-template-columns: repeat(5, 1fr); gap: 14px 4px; }
.add-cat-grid .cat-item { padding: 6px 2px; }
.add-cat-grid .cat-item .cat-ico { width: 52px; height: 52px; border-radius: 50%; }
.add-cat-grid .cat-item .cat-ico svg { width: 24px; height: 24px; }
.add-cat-grid .cat-item span { font-size: 12px; }
/* 快捷 chips */
.quick-chips {
  display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
  flex-shrink: 0;
  padding: 8px 14px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border-radius: 18px;
  padding: 7px 12px; font-size: 13px; font-weight: 500;
  color: var(--ink-2); box-shadow: var(--shadow-sm);
  transition: transform .15s cubic-bezier(0.16,1,0.3,1), background .2s;
}
.chip:active { transform: scale(0.95); }
.chip.active { background: var(--tint); color: #fff; }
.chip svg { width: 16px; height: 16px; }
.chip-settings { padding: 7px 9px; }
/* 金额条 */
.add-amount-bar {
  display: flex; align-items: center; gap: 6px;
  background: var(--card);
  padding: 14px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
}
.add-amount-bar .currency { font-size: 26px; font-weight: 700; color: var(--expense); }
.amount-display {
  font-family: var(--num); font-size: 38px; font-weight: 800;
  color: var(--expense); font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.add-desc {
  flex: 1; text-align: right; font-size: 13px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.desc-expand {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2);
  background: var(--bg); flex-shrink: 0;
}
.desc-expand svg { width: 16px; height: 16px; }
/* 详情展开区 */
.add-detail {
  background: var(--card); padding: 4px 18px 12px;
  flex-shrink: 0; border-top: 1px solid var(--line);
  max-height: 40vh; overflow-y: auto;
}
/* 数字键盘 */
.num-keyboard {
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(env(safe-area-inset-bottom) + 6px);
}
.key-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; }
.key {
  min-height: 52px;
  font-family: var(--num); font-size: 24px; font-weight: 500;
  color: var(--ink); background: var(--card);
  display: grid; place-items: center;
  transition: background .12s ease, transform .12s cubic-bezier(0.16,1,0.3,1);
  border-radius: 2px;
}
.key:active { background: var(--bg); transform: scale(0.96); }
.key svg { width: 22px; height: 22px; }
.key-del { color: var(--ink-2); }
.key-save-more {
  font-size: 12px; font-weight: 600; color: var(--tint);
}
.key-empty { pointer-events: none; }
.key-done {
  font-size: 15px; font-weight: 700; color: #fff;
  background: var(--expense);
}
.key-done:active { background: var(--expense); opacity: .85; }
.add-view .save-msg { flex-shrink: 0; background: var(--bg); margin: 0; padding: 4px 0; }

/* ---------- 记账页 ---------- */
.type-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--bg); border-radius: 14px; padding: 4px;
  box-shadow: inset 0 0 0 0.5px var(--line);
}
.type-btn { padding: 11px; border-radius: 11px; font-size: 15px; font-weight: 600; color: var(--ink-3); transition: all .2s; }
.type-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.amount-row { display: flex; align-items: center; gap: 6px; margin: 16px 0 4px; }
.currency { font-size: 30px; font-weight: 700; color: var(--ink-2); }
.amount-input {
  flex: 1; border: none; outline: none; background: none;
  font-family: var(--num); font-size: 44px; font-weight: 800;
  color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.amount-input::placeholder { color: var(--ink-3); opacity: .5; }
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 4px; margin: 16px 0 4px; }
.add-cat-grid.category-grid {
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 14px 4px !important;
  margin: 6px 0 4px !important;
}
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 8px 4px; border-radius: var(--radius-md); transition: background .15s;
}
.cat-item .cat-ico {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; transition: transform .15s;
}
.cat-item .cat-ico svg { width: 22px; height: 22px; }
.cat-item span { font-size: 12px; color: var(--ink-2); }
.cat-item.active { background: var(--tint-soft); }
.cat-item.active .cat-ico { transform: scale(1.05); }
.cat-item.active span { color: var(--tint); font-weight: 600; }
.form-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-row label { font-size: 15px; color: var(--ink-2); width: 64px; flex-shrink: 0; }
.form-row input, .form-row select {
  flex: 1; border: none; outline: none; background: var(--bg);
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 15px;
  appearance: none; -webkit-appearance: none;
}
.primary-btn {
  width: 100%; margin-top: 18px; padding: 15px;
  border-radius: var(--radius-md); background: var(--tint); color: #fff;
  font-size: 16px; font-weight: 700; letter-spacing: 0.02em;
  box-shadow: 0 6px 16px rgba(22, 119, 232, 0.3);
  transition: transform .15s, opacity .2s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: .5; }
.save-msg { text-align: center; margin-top: 12px; font-size: 13px; min-height: 18px; }
.save-msg.ok { color: var(--income); }
.save-msg.err { color: var(--expense); }

/* ---------- 统计页 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-tile { background: var(--bg); border-radius: var(--radius-md); padding: 12px 14px; }
.tile-label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-3); }
.tile-label::after { content: "›"; color: var(--ink-3); opacity: .6; }
.tile-val {
  display: block; font-family: var(--num); font-size: 19px; font-weight: 800;
  margin-top: 4px; font-variant-numeric: tabular-nums; color: var(--ink);
}
.tile-val.expense { color: var(--expense); }
.tile-val.income { color: var(--income); }
.chart-box { width: 100%; height: 150px; }
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-svg .grid-line { stroke: var(--line); stroke-dasharray: 2 4; }
.chart-svg .axis-label { fill: var(--ink-3); font-size: 9px; font-family: var(--font); }
.chart-svg .chart-area { fill: rgba(239, 101, 93, 0.12); }
.chart-svg .chart-line { stroke: var(--expense); stroke-width: 1.8; fill: none; stroke-linecap: round; }
.chart-svg .chart-dot { fill: var(--card); stroke: var(--expense); stroke-width: 1.6; }
.chart-svg .chart-dot.mint { stroke: var(--income); }
.chart-svg .chart-line.mint { stroke: var(--income); }
.chart-svg .chart-area.mint { fill: rgba(43, 203, 114, 0.12); }

/* ---------- 环形图 ---------- */
.donut-wrap { position: relative; width: 190px; margin: 8px auto 18px; }
.donut { width: 100%; height: auto; transform: rotate(-90deg); display: block; }
.donut circle { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dasharray .8s cubic-bezier(.22,1,.36,1); }
.donut .track { stroke: var(--line); }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-total { font-family: var(--num); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.donut-label { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ---------- 分类图例 ---------- */
.legend-list { list-style: none; }
.legend-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.legend-list li:last-child { border-bottom: none; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; font-size: 15px; font-weight: 500; }
.legend-val { font-family: var(--num); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.legend-pct { width: 46px; text-align: right; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 设置页（iOS 分组列表） ---------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; }
.setting-row > span:first-child { font-size: 16px; font-weight: 500; }
.setting-link {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--line); text-align: left;
  font-size: 16px; font-weight: 500; color: var(--ink);
  transition: opacity .15s;
}
.setting-link:last-child { border-bottom: none; }
.setting-link:active { opacity: .6; }
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 20px; background: var(--line);
  transition: background .25s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; width: 27px; height: 27px; border-radius: 50%;
  left: 2px; top: 2px; background: #fff; transition: transform .25s;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .slider { background: #34C759; }
.switch input:checked + .slider::before { transform: translateX(20px); }
.about-text { font-size: 13px; color: var(--ink-2); line-height: 1.7; }

/* ---------- 首次配置页 ---------- */
.setup-wrap { padding-top: 90px; text-align: center; }
.setup-logo {
  width: 78px; height: 78px; border-radius: 24px; margin: 0 auto 18px;
  background: var(--tint); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(22, 119, 232, 0.3);
}
.setup-logo svg { width: 38px; height: 38px; }
.setup-wrap h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.setup-sub { color: var(--ink-3); font-size: 14px; margin-top: 5px; }
.setup-card { text-align: left; margin-top: 24px; }
.setup-card .form-row:first-child { border-top: none; margin-top: 4px; padding-top: 4px; }
.setup-card .primary-btn { margin-top: 22px; }

/* ---------- 底部导航（iOS 悬浮胶囊毛玻璃） ---------- */
.tabbar {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 36px); max-width: 444px;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom) - 20px);
  min-height: 58px;
  padding: 5px 8px;
  background: rgba(248, 248, 250, 0.82);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 30px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 50;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
[data-theme="dark"] .tabbar {
  background: rgba(28, 28, 30, 0.82);
  border-color: rgba(255, 255, 255, 0.08);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-2); border-radius: 22px;
  transition: color .2s, background .2s;
}
.tab svg { width: 23px; height: 23px; }
.tab span { font-size: 10px; font-weight: 600; }
.tab.active { color: var(--tint); background: rgba(22, 119, 232, 0.10); }
.tab-add { color: var(--ink-2); }
.tab-add svg {
  width: 32px; height: 32px; margin-top: -4px;
  background: var(--amber); color: #fff; border-radius: 50%;
  padding: 6px; box-shadow: 0 4px 12px rgba(255, 183, 27, 0.45);
}

/* ---------- 弹层 (sheet) ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4);
  z-index: 90; backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px;
  background: rgba(248, 248, 250, 0.94);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
  border-radius: 28px 28px 0 0;
  z-index: 100; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 24px);
  max-height: 88vh; overflow-y: auto;
  animation: sheetUp .3s cubic-bezier(.22,1,.36,1);
}
[data-theme="dark"] .sheet { background: rgba(28, 28, 30, 0.94); }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-grabber {
  width: 38px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.15);
  margin: 0 auto 12px;
}
[data-theme="dark"] .sheet-grabber { background: rgba(255, 255, 255, 0.25); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { font-size: 17px; font-weight: 700; }
.sheet-close {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2);
  background: var(--bg);
}
.sheet-close svg { width: 17px; height: 17px; }
.sheet-body .type-switch { margin-bottom: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .primary-btn { flex: 2; margin-top: 0; }
.danger-btn {
  flex: 1; padding: 15px; border-radius: var(--radius-md);
  background: var(--expense-soft); color: var(--expense);
  font-size: 15px; font-weight: 700;
  transition: transform .15s, opacity .2s;
}
.danger-btn:active { transform: scale(0.97); }
.danger-btn:disabled { opacity: .5; }
.acct-info { font-size: 12.5px; color: var(--ink-3); margin-top: 12px; line-height: 1.7; }

/* ---------- iOS 选择器 ---------- */
.picker-btn {
  flex: 1; text-align: left; border-radius: var(--radius-sm);
  background: var(--bg); padding: 11px 14px; font-size: 15px;
  color: var(--ink-3); font-weight: 500;
  transition: color .2s ease, background .2s ease, transform .15s cubic-bezier(0.16,1,0.3,1);
}
.picker-btn.picked { color: var(--ink); font-weight: 600; }
.picker-btn:active { transform: scale(0.97); }
.picker-sheet { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
.picker-list { list-style: none; background: var(--card); border-radius: var(--radius-lg); overflow: hidden; }
.picker-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.picker-item:last-child { border-bottom: none; }
.picker-item.selected { background: var(--tint-soft); }
.picker-ico {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
}
.picker-ico svg { width: 17px; height: 17px; }
.picker-name { flex: 1; font-size: 16px; font-weight: 500; color: var(--ink); }
.picker-check { width: 20px; height: 20px; color: var(--tint); flex-shrink: 0; }

/* ---------- 分类管理 ---------- */
.cat-list-title {
  font-size: 13px; font-weight: 700; color: var(--ink-3);
  padding: 18px 6px 8px; letter-spacing: 0.01em;
}
.cat-manage-list {
  list-style: none; background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
  max-height: 46vh; overflow-y: auto;
}
.cat-manage-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.cat-manage-list li:last-child { border-bottom: none; }
.cat-m-ico {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
}
.cat-m-ico svg { width: 17px; height: 17px; }
.cat-m-name { flex: 1; font-size: 15px; font-weight: 600; }
.cat-m-count { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cat-m-edit {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2); background: var(--bg);
}
.cat-m-edit svg { width: 15px; height: 15px; }
.icon-picker {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  flex: 1; max-height: 190px; overflow-y: auto;
}
.icon-pick {
  aspect-ratio: 1; border-radius: 12px; background: var(--bg);
  display: grid; place-items: center; color: var(--ink-2);
  transition: all .15s; border: 2px solid transparent;
}
.icon-pick svg { width: 20px; height: 20px; }
.icon-pick.active { border-color: var(--tint); background: var(--tint-soft); color: var(--tint); }
.icon-pick-row { align-items: flex-start; }
.icon-pick-row label { padding-top: 8px; }

/* ---------- 加载与空态 ---------- */
.loading, .empty {
  text-align: center; color: var(--ink-3); font-size: 13px;
  padding: 26px 0;
}
.footnote { text-align: center; font-size: 11px; color: var(--ink-3); margin-top: 18px; opacity: .8; }

/* ---------- 桌面端自适应 (≥768px) ---------- */
@media (min-width: 768px) {
  body { background: linear-gradient(180deg, #ECEEF1 0%, var(--bg) 300px); }
  #app { max-width: 640px; padding: 0 24px calc(var(--tabbar-h) + 32px); }
  .topbar { padding-top: 32px; }
  .topbar h1 { font-size: 34px; }
  .balance-card, .net-card { padding: 28px 28px 24px; }
  .balance-amount, .net-amount { font-size: 46px; }
  #accounts-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  #accounts-groups .group-title { grid-column: 1 / -1; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .tabbar { bottom: 22px; }
  .sheet { max-width: 560px; border-radius: 28px; bottom: auto; top: 50%; transform: translate(-50%, -50%); animation: sheetCenter .3s cubic-bezier(.22,1,.36,1); max-height: 86vh; }
  @keyframes sheetCenter { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%); } }
}

/* ---------- 无障碍焦点 ---------- */
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }

/* ============================================================
   iOS 动效（animate.md 规范：150-300ms 快速反馈，
   自然减速 cubic-bezier(0.16,1,0.3,1)，prefers-reduced-motion 降级）
   ============================================================ */
/* 按压反馈 */
button, .tab, .acct-row, .tx-row, .picker-item, .cat-item, .setting-link {
  transition: transform .15s cubic-bezier(0.16, 1, 0.3, 1), opacity .15s ease, background .2s ease;
}
button:active, .tab:active, .acct-row:active, .tx-row:active, .picker-item:active, .cat-item:active, .setting-link:active {
  transform: scale(0.97);
  opacity: .85;
}

/* 视图切换（iOS 推入式淡入） */
.view.active { animation: viewIn .3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes viewIn {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

/* sheet 弹起（iOS 上滑） */
.sheet { animation: sheetUp .38s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes sheetUp {
  from { transform: translate(-50%, 100%); }
  to { transform: translate(-50%, 0); }
}
.sheet-mask { animation: maskIn .25s ease; }
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 768px) {
  .sheet { animation: sheetCenter .32s cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes sheetCenter { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%); } }
}

/* 列表项错峰进场（仅首次渲染，总延迟封顶） */
.date-group { animation: listIn .3s cubic-bezier(0.16, 1, 0.3, 1) backwards; }
.date-group:nth-child(1) { animation-delay: .02s; }
.date-group:nth-child(2) { animation-delay: .05s; }
.date-group:nth-child(3) { animation-delay: .08s; }
.date-group:nth-child(4) { animation-delay: .11s; }
.date-group:nth-child(5) { animation-delay: .14s; }
.date-group:nth-child(n+6) { animation-delay: .17s; }
@keyframes listIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* picker 选中项勾选动画 */
.picker-item .picker-check { animation: checkPop .3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes checkPop {
  from { transform: scale(.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 数字滚动感（金额变化轻微上移） */
.balance-amount, .net-amount { transition: opacity .2s ease; }
.balance-amount.pulse, .net-amount.pulse { animation: numPulse .4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes numPulse {
  0% { opacity: .3; transform: translateY(4px); }
  100% { opacity: 1; transform: none; }
}

/* tab 图标切换弹跳 */
.tab.active svg { animation: tabPop .3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes tabPop {
  0% { transform: scale(.8); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* 下拉刷新提示 */
.pull-hint { transition: opacity .2s ease, color .2s ease; }

/* 尊重系统减少动态偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .view.active { animation: none; }
  .sheet { animation: none; }
}
