/* 轻记账样式 v3：精修现代风，移动端优先（保留全部 DOM 契约类名，勿改） */

/* ===== 设计令牌 ===== */
:root {
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-tint: #f0fdfa;
  --income: #059669;
  --income-tint: #d1fae5;
  --expense: #e11d48;
  --expense-tint: #ffe4e6;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --line: #e2e8f0;
  --sh-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --sh-2: 0 4px 12px rgba(15,23,42,.07);
  --sh-hero: 0 12px 28px rgba(13,148,136,.28);
  --r-lg: 20px;
  --r-md: 14px;
  --r-full: 999px;
  --page-x: 16px;
  --card-x: 16px;
  --gap: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ===== 全局基础 ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; background: var(--bg); }
.screen { display: none; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(96px + var(--safe-bottom)); }
.screen.active { display: block; }

/* 数字等宽 */
.hero-amount, .hero-cell .v, .summary-card .amount, .record-item .amount,
.stat-box .value, .date-header .total, .list-total, .pie-legend .pct,
input[type="date"], input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* 统一按压反馈 */
.btn, .icon-btn, .category-chip, .filter-chip, .nav-item, .menu-item,
.type-toggle button, .sort-toggle, .period-tabs button, .nav-add,
.record-item .actions .icon-btn, .ai-auto {
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease, color .15s ease, border-color .15s ease;
}
.btn:active, .category-chip:active, .filter-chip:active, .nav-item:active,
.type-toggle button:active, .sort-toggle:active, .period-tabs button:active,
.menu-item:active { transform: scale(.97); }

/* ===== 登录页 ===== */
#loginScreen {
  position: fixed; inset: 0; z-index: 1000; overflow: hidden;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-strong) 60%, #115e59 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
}
#loginScreen::before {
  content: ''; position: absolute; right: -80px; top: -100px; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255,255,255,.07);
}
#loginScreen::after {
  content: ''; position: absolute; left: -70px; bottom: -90px; width: 220px; height: 220px;
  border-radius: 50%; background: rgba(255,255,255,.06);
}
#loginScreen .logo {
  width: 88px; height: 88px; border-radius: 26px; background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center; font-size: 46px; color: #fff;
  backdrop-filter: blur(10px); margin-bottom: 22px; box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
#loginScreen h1 { color: #fff; margin: 0 0 8px; font-size: 27px; letter-spacing: 1px; font-weight: 700; }
#loginScreen p { color: rgba(255,255,255,0.85); margin: 0 0 36px; font-size: 15px; }
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 360px; background: var(--surface); border-radius: var(--r-lg); padding: 26px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.22);
}
.login-card label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.login-card input {
  width: 100%; height: 52px; padding: 0 16px; font-size: 18px; border: 1px solid var(--line);
  border-radius: var(--r-md); outline: none;
  transition: border-color .2s, box-shadow .2s;
  text-align: center; letter-spacing: 6px; font-variant-numeric: tabular-nums;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.login-card .hint { font-size: 12px; color: var(--ink-3); margin-top: 10px; text-align: center; }
.login-card .error { color: var(--expense); font-size: 13px; margin-top: 10px; text-align: center; min-height: 20px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--r-md); padding: 14px 20px; font-size: 16px;
  font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #fff; width: 100%; margin-top: 20px; box-shadow: 0 4px 12px rgba(13,148,136,.25); }
.btn-primary:active { transform: scale(.97); box-shadow: 0 2px 6px rgba(13,148,136,.25); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:active { background: var(--bg); }
.btn-danger { background: var(--expense-tint); color: var(--expense); }
.btn-success { background: var(--income-tint); color: #065f46; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-sm { padding: 10px 16px; font-size: 14px; width: auto; margin-top: 0; }

/* ===== 顶栏 ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.14);
  padding: calc(12px + var(--safe-top)) var(--page-x) 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-header h1 {
  font-size: 18px; margin: 0; display: flex; align-items: center; gap: 10px; color: #fff;
  letter-spacing: .5px; font-weight: 700;
}
.app-header h1 > span {
  width: 30px; height: 30px; border-radius: 10px; background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,.22);
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  font-weight: 700;
}
.app-header .actions { display: flex; gap: 8px; }
.app-header .icon-btn { background: rgba(255,255,255,0.16); color: #fff; border: 1px solid rgba(255,255,255,.18); }
.app-header .icon-btn:active { background: rgba(255,255,255,0.3); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer;
  color: var(--ink-2);
}
.icon-btn svg { display: block; }
.icon-btn:active { background: var(--line); }

/* ===== 记账页 hero 汇总卡 ===== */
.hero {
  position: relative; overflow: hidden; margin: var(--gap) var(--page-x) 16px; padding: 20px;
  border-radius: var(--r-lg); color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 62%, #115e59 100%);
  box-shadow: var(--sh-hero);
}
.hero::after {
  content: ''; position: absolute; right: -34px; top: -44px; width: 150px; height: 150px;
  border-radius: 50%; background: rgba(255,255,255,0.07);
}
.hero::before {
  content: ''; position: absolute; right: 30px; bottom: -60px; width: 110px; height: 110px;
  border-radius: 50%; background: rgba(255,255,255,0.05);
}
.hero-label { font-size: 12px; opacity: .85; letter-spacing: .5px; }
.hero-amount {
  font-size: clamp(28px, 8vw, 34px); font-weight: 800; letter-spacing: .5px; margin: 4px 0 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; z-index: 1; }
.hero-cell {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,.14);
  border-radius: var(--r-md);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 2px;
}
.hero-cell .k { font-size: 11px; opacity: .8; }
.hero-cell .v { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-cell .v.income { color: #6ee7b7; }
.hero-cell .v.expense { color: #fda4af; }

/* ===== 智能记账卡 ===== */
.ai-card {
  background: var(--primary-tint); border: 1px dashed rgba(13,148,136,.35);
  border-radius: var(--r-md); padding: 12px; margin-bottom: 4px;
}
.ai-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; margin-bottom: 10px; }
.ai-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; color: var(--primary-strong); }
.ai-auto { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 400; color: var(--ink-2); cursor: pointer; user-select: none; min-height: 40px; padding: 0 2px; }
.ai-auto input { width: auto; margin: 0; accent-color: var(--primary); }
.ai-card textarea {
  width: 100%; border: 1.5px dashed var(--line); border-radius: var(--r-md);
  background: var(--surface); padding: 10px 12px; font-size: 15px; font-family: inherit;
  line-height: 1.5; resize: none; outline: none; transition: border-color .2s;
}
.ai-card textarea:focus { border-style: solid; border-color: var(--primary); }
.ai-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ai-hint { font-size: 12px; color: var(--ink-3); }

/* ===== 统计页三卡 ===== */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: var(--gap) var(--page-x) 16px; }
.summary-card {
  background: var(--surface); border-radius: var(--r-md); padding: 14px 10px;
  text-align: center; box-shadow: var(--sh-1);
}
.summary-card .label { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.summary-card .amount { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-card.income .amount { color: var(--income); }
.summary-card.expense .amount { color: var(--expense); }
.summary-card.balance .amount { color: var(--primary-strong); }

.section-title { font-size: 16px; font-weight: 700; padding: 0 var(--page-x); margin: 8px 0 12px; display: flex; align-items: center; justify-content: space-between; }

/* ===== 表单卡与控件 ===== */
.form-card {
  background: var(--surface); margin: 0 var(--page-x) 16px; border-radius: var(--r-lg);
  padding: var(--card-x); box-shadow: var(--sh-1);
}
.form-card > .btn-primary { margin-top: 16px; }

/* 支出/收入切换（segmented） */
.type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg);
  padding: 4px; border-radius: var(--r-md); margin-bottom: 16px;
  box-shadow: inset 0 1px 2px rgba(15,23,42,.05);
}
.type-toggle button {
  border: none; background: transparent; padding: 11px 10px; min-height: 44px;
  border-radius: 10px;
  font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.type-toggle button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(15,23,42,.1); }
.type-toggle button.income.active { color: var(--income); }
.type-toggle button.expense.active { color: var(--expense); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface); outline: none; font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.form-group textarea { min-height: auto; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint);
}
.form-group .input-wrap { position: relative; }
.form-group .prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 18px; font-weight: 700; color: var(--ink-3);
}
.form-group input.with-prefix { padding-left: 34px; font-size: 18px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 分类格子 */
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.category-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 64px; padding: 10px 4px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid transparent; background: var(--bg);
}
.category-chip .emoji { font-size: 24px; line-height: 1; transition: transform .15s ease; }
.category-chip .name { font-size: 12px; color: var(--ink-2); }
.category-chip.selected { background: var(--primary-tint); border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.category-chip.selected .emoji { transform: scale(1.1); }
.category-chip.selected .name { color: var(--primary-strong); font-weight: 600; }

/* ===== 账单列表 ===== */
.record-list { padding: 0 var(--page-x); }
.record-group { margin-bottom: 16px; }
.record-group .date-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 4px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px;
}
.record-group .date-header .total { font-weight: 600; }
.record-item {
  background: var(--surface); border-radius: var(--r-md); padding: 10px 14px; min-height: 66px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.record-item .icon {
  width: 46px; height: 46px; border-radius: var(--r-md); background: var(--bg);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.record-item .info { flex: 1; min-width: 0; }
.record-item .title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-item .meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.record-item .amount { font-size: 17px; font-weight: 700; white-space: nowrap; }
.record-item .amount.income { color: var(--income); }
.record-item .amount.expense { color: var(--expense); }
/* 操作按钮常显（触屏无 hover） */
.record-item .actions { display: flex; gap: 6px; opacity: 1; }
.record-item .actions .icon-btn { width: 36px; height: 36px; font-size: 15px; background: var(--bg); }
.record-item .actions .icon-btn:active { background: var(--line); transform: scale(.92); }

.empty-state { text-align: center; padding: 48px 24px; color: var(--ink-3); }
.empty-state .emoji { font-size: 56px; margin-bottom: 12px; }
.empty-state p { margin: 0; }

/* ===== 统计页 ===== */
.chart-card {
  background: var(--surface); margin: 0 var(--page-x) 16px; border-radius: var(--r-lg);
  padding: var(--card-x); box-shadow: var(--sh-1);
}
.chart-card h3 { margin: 0 0 14px; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.period-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 0 var(--page-x); }
.period-tabs button {
  flex: 1; padding: 9px; min-height: 40px; border: none; background: var(--surface);
  border-radius: var(--r-full); font-size: 14px; color: var(--ink-2); cursor: pointer;
  box-shadow: var(--sh-1);
}
.period-tabs button.active { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(13,148,136,.3); }
.pie-wrap { display: flex; align-items: center; gap: 16px; }
.pie-svg { width: 150px; height: 150px; flex-shrink: 0; }
.pie-legend { flex: 1; font-size: 13px; min-width: 0; }
.pie-legend .item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pie-legend .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pie-legend .pct { margin-left: auto; font-weight: 600; flex-shrink: 0; }
.bar-canvas { width: 100%; height: 200px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 var(--page-x) 16px; }
.stat-box { background: var(--surface); border-radius: var(--r-md); padding: 14px; box-shadow: var(--sh-1); }
.stat-box .label { font-size: 12px; color: var(--ink-2); }
.stat-box .value { font-size: 18px; font-weight: 700; margin-top: 4px; }

/* ===== 我的（菜单列表） ===== */
.menu-list { background: var(--surface); margin: 0 var(--page-x) 16px; border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1); }
#tab-profile > .menu-list:first-child { margin-top: var(--gap); }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-item .icon {
  width: 34px; height: 34px; border-radius: 10px; background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.menu-item .label { font-size: 15px; }
.menu-item .right { color: var(--ink-3); font-size: 16px; flex-shrink: 0; }

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: rgba(255,255,255,0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 0 calc(6px + var(--safe-bottom)); z-index: 200;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; padding: 6px 0; color: var(--ink-3); font-size: 11px; cursor: pointer;
  border: none; background: transparent; position: relative;
}
.nav-item .icon { font-size: 21px; line-height: 1.2; }
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-item.active::after {
  content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.nav-add {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 8px 18px rgba(13,148,136,.35);
  border: 4px solid var(--bg);
  cursor: pointer;
}
.nav-add svg { display: block; }
.nav-add:active { transform: scale(.92); }

/* ===== 底部弹层 ===== */
.modal {
  position: fixed; inset: 0; z-index: 300; display: none; align-items: flex-end;
  background: rgba(15,23,42,.45); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.modal.show { display: flex; animation: modal-fade .25s ease; }
.modal-content {
  width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  max-height: 90vh; max-height: 92dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: sheet-up .3s cubic-bezier(.32,.72,0,1);
  padding-bottom: calc(20px + var(--safe-bottom));
}
.sheet-handle { width: 44px; height: 4px; border-radius: var(--r-full); background: var(--line); margin: 10px auto 0; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--card-x); border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: var(--card-x); }
.modal-footer { padding: 12px var(--card-x); display: flex; gap: 10px; }
.modal-footer .btn { flex: 1; margin: 0; }

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ===== 分类管理行 ===== */
.cat-list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.cat-list-item:last-child { border-bottom: none; }
.cat-list-item .left { display: flex; align-items: center; gap: 12px; }
.cat-list-item .emoji { font-size: 24px; }
.cat-list-item .name { font-size: 15px; }
.cat-list-item .type-tag { font-size: 11px; padding: 2px 8px; border-radius: var(--r-full); background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.cat-list-item .item-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.cat-list-item .item-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.cat-list-item .btn { padding: 8px 12px; font-size: 13px; margin: 0; border-radius: 10px; }
.cat-edit-fields { display: flex; gap: 8px; flex: 1; min-width: 0; align-items: center; }
.cat-edit-fields input, .cat-edit-fields select {
  padding: 8px 10px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); outline: none; min-height: 40px; min-width: 0;
}
.cat-edit-fields input:focus, .cat-edit-fields select:focus { border-color: var(--primary); }
.cat-edit-fields input.edit-name { flex: 1; }
.cat-edit-fields input.edit-icon { width: 52px; text-align: center; }
.cat-edit-fields select { width: 72px; }

#addCategoryBtn { margin-top: 4px; margin-bottom: 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: calc(var(--safe-top) + 72px); left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: rgba(15,23,42,.92); color: #fff; padding: 11px 20px; border-radius: var(--r-full);
  font-size: 14px; z-index: 500; opacity: 0; transition: all .25s ease; pointer-events: none;
  max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(15,23,42,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 账单筛选 ===== */
.filter-bar {
  display: flex; gap: 8px; padding: 0 var(--page-x) var(--gap);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
#billCategoryFilters { padding-top: 0; }
.filter-chip {
  flex-shrink: 0; padding: 9px 16px; min-height: 40px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
  cursor: pointer;
}
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(13,148,136,.3); }

.date-range { display: flex; align-items: center; gap: 8px; padding: var(--gap) var(--page-x) var(--gap); }
.date-range span { color: var(--ink-3); font-size: 13px; flex-shrink: 0; }
.date-range input {
  flex: 1; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md); font-size: 14px; background: var(--surface);
  outline: none;
}
.date-range input:focus { border-color: var(--primary); }

.search-bar { display: flex; padding: 0 var(--page-x) var(--gap); }
.search-bar input {
  flex: 1; padding: 10px 16px; font-size: 15px; border: 1px solid var(--line);
  border-radius: var(--r-full); background: var(--surface); outline: none; min-height: 44px;
  transition: border-color .2s, box-shadow .2s;
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

.sort-bar { display: flex; gap: 8px; padding: 0 var(--page-x) var(--gap); align-items: center; }
.sort-toggle {
  padding: 9px 16px; border-radius: var(--r-full); background: var(--surface);
  border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
  cursor: pointer; min-height: 40px;
}
.sort-toggle:active { background: var(--bg); }

.load-sentinel { height: 1px; }
.loading-more { text-align: center; font-size: 13px; color: var(--ink-3); padding: 8px 0 16px; }
.list-total { text-align: center; font-size: 13px; color: var(--ink-3); padding: 8px 0 16px; }

/* ===== 工具类 ===== */
.hidden { display: none !important; }

/* ===== 动画偏好 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== 窄屏降档（≤360px：iPhone SE 等） ===== */
@media (max-width: 360px) {
  :root { --page-x: 12px; --card-x: 12px; --gap: 10px; }
  .category-grid { gap: 8px; }
  .category-chip { min-height: 60px; }
  .category-chip .emoji { font-size: 22px; }
  .hero-amount { font-size: 28px; }
  .pie-svg { width: 120px; height: 120px; }
  .summary-card .amount { font-size: 14px; }
  .record-item .actions .icon-btn { width: 32px; height: 32px; font-size: 14px; }
  .nav-item { font-size: 10px; }
}

/* ===== 桌面窄列 ===== */
@media (min-width: 520px) {
  #app { box-shadow: 0 0 40px rgba(15,23,42,.08); }
}

/* ===== 错误抖动 ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake .3s ease; }
