/* ═══════════════════════════════════════════════════
   SweetLedger — Premium Design System v2.0
   目标：媲美随手记、鲨鱼记账等顶级 App 的视觉质感
   ═══════════════════════════════════════════════════ */

/* ── Google Fonts 降级方案：已在 HTML 中引入 ── */

/* ════════════════ 设计令牌 (Design Tokens) ════════════════ */
:root {
  --radius-xs:  8px;
  --radius-sm:  12px;
  --radius-md:  18px;
  --radius-lg:  24px;
  --radius-xl:  32px;
  --radius-full: 100px;

  --transition-fast:   all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: all 0.42s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  --shadow-xs:  0 1px 4px rgba(0,0,0,0.04);
  --shadow-sm:  0 2px 12px rgba(0,0,0,0.05);
  --shadow-md:  0 6px 20px rgba(0,0,0,0.08);
  --shadow-lg:  0 12px 36px rgba(0,0,0,0.12);

  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-body:    'Noto Sans SC',      -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;

  --color-income:  #2AC87A;
  --color-expense: #FF5272;
  --color-white:   #FFFFFF;
}

/* ════════════════ 主题系统 (Themes) ════════════════ */

/* ① 蜜桃甜粉 */
.theme-pink {
  --primary:        #F2607A;
  --primary-dark:   #D94360;
  --primary-mid:    #F8899A;
  --primary-light:  #FFF0F2;
  --primary-ghost:  rgba(242,96,122,0.10);

  --bg-app:         #FBF4F5;
  --bg-card:        #FFFFFF;
  --bg-surface:     #FFF8F9;

  --text-primary:   #2D1A1E;
  --text-secondary: #7A5962;
  --text-muted:     #B8959B;
  --text-inverse:   #FFFFFF;

  --border:         rgba(242,96,122,0.12);
  --border-strong:  rgba(242,96,122,0.22);
  --divider:        rgba(0,0,0,0.055);

  --grad-hero:   linear-gradient(145deg, #FF8FA0 0%, #F2607A 55%, #D94360 100%);
  --grad-subtle: linear-gradient(135deg, #FFF0F2 0%, #FFE6EA 100%);
  --shadow-brand: 0 8px 24px rgba(242,96,122,0.28);
}

/* ② 青柠抹茶 */
.theme-green {
  --primary:        #3D9E72;
  --primary-dark:   #2A7D57;
  --primary-mid:    #6ABB94;
  --primary-light:  #EEF9F4;
  --primary-ghost:  rgba(61,158,114,0.10);

  --bg-app:         #F2FAF6;
  --bg-card:        #FFFFFF;
  --bg-surface:     #F7FCF9;

  --text-primary:   #1A2D24;
  --text-secondary: #4A7062;
  --text-muted:     #8FB5A2;
  --text-inverse:   #FFFFFF;

  --border:         rgba(61,158,114,0.12);
  --border-strong:  rgba(61,158,114,0.22);
  --divider:        rgba(0,0,0,0.055);

  --grad-hero:   linear-gradient(145deg, #72C49A 0%, #3D9E72 55%, #2A7D57 100%);
  --grad-subtle: linear-gradient(135deg, #EEF9F4 0%, #DCF2E8 100%);
  --shadow-brand: 0 8px 24px rgba(61,158,114,0.28);
}

/* ③ 燕麦暖奶 */
.theme-cream {
  --primary:        #B07D5A;
  --primary-dark:   #8E6044;
  --primary-mid:    #CBA07E;
  --primary-light:  #FAF4EE;
  --primary-ghost:  rgba(176,125,90,0.10);

  --bg-app:         #F9F5F0;
  --bg-card:        #FFFFFF;
  --bg-surface:     #FBF8F4;

  --text-primary:   #2E1F12;
  --text-secondary: #6B4E38;
  --text-muted:     #B09988;
  --text-inverse:   #FFFFFF;

  --border:         rgba(176,125,90,0.13);
  --border-strong:  rgba(176,125,90,0.24);
  --divider:        rgba(0,0,0,0.055);

  --grad-hero:   linear-gradient(145deg, #D4A880 0%, #B07D5A 55%, #8E6044 100%);
  --grad-subtle: linear-gradient(135deg, #FAF4EE 0%, #F2E8DA 100%);
  --shadow-brand: 0 8px 24px rgba(176,125,90,0.28);
}

/* ④ 深邃星空 */
.theme-dark {
  --primary:        #FF7B93;
  --primary-dark:   #FF9EAC;
  --primary-mid:    #FF9EAC;
  --primary-light:  #2D1E22;
  --primary-ghost:  rgba(255,123,147,0.12);

  --bg-app:         #111010;
  --bg-card:        #1C1A1B;
  --bg-surface:     #222020;

  --text-primary:   #F5EDEF;
  --text-secondary: #A08890;
  --text-muted:     #6A5860;
  --text-inverse:   #FFFFFF;

  --border:         rgba(255,255,255,0.07);
  --border-strong:  rgba(255,255,255,0.13);
  --divider:        rgba(255,255,255,0.06);

  --grad-hero:   linear-gradient(145deg, #FF9EAC 0%, #FF7B93 55%, #E05570 100%);
  --grad-subtle: linear-gradient(135deg, #2D1E22 0%, #231719 100%);
  --shadow-brand: 0 8px 24px rgba(255,123,147,0.20);

  --shadow-sm: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.45);
}

/* ════════════════ 基础重置 (Reset) ════════════════ */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-primary);
  overflow: hidden;
  position: fixed;
  width: 100%; height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
}

/* ════════════════ 应用容器 (App Container) ════════════════ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg-app);
  position: relative;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  transition: background 0.35s ease;
}

/* ════════════════ 顶部头部区域 (Header) ════════════════ */
.app-header {
  padding: calc(16px + env(safe-area-inset-top)) 20px 0;
  background: var(--bg-app);
  transition: background 0.35s ease;
  z-index: 10;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.greeting {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1px;
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: var(--transition-fast);
}
.month-selector:active {
  transform: scale(0.96);
  background: var(--primary-light);
}
.chevron-icon { color: var(--text-muted); flex-shrink: 0; }

/* ── 预算英雄卡片 (Hero Budget Card) ── */
.budget-card {
  background: var(--grad-hero);
  border-radius: var(--radius-xl);
  padding: 22px 22px 18px;
  color: var(--color-white);
  box-shadow: var(--shadow-brand);
  position: relative;
  overflow: hidden;
  margin-bottom: 2px;
}

/* 装饰圆 */
.budget-card::before,
.budget-card::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.budget-card::before {
  width: 180px; height: 180px;
  top: -60px; right: -50px;
  background: rgba(255,255,255,0.10);
}
.budget-card::after {
  width: 100px; height: 100px;
  bottom: -30px; left: 20px;
  background: rgba(255,255,255,0.06);
}

.budget-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.budget-item { display: flex; flex-direction: column; gap: 3px; }

.budget-divider {
  width: 1px; height: 44px;
  background: rgba(255,255,255,0.2);
  align-self: center;
}

.budget-item .label {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.80;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.budget-item .amount {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.8px;
}

.budget-progress-container {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.budget-progress-bar {
  height: 5px;
  background: rgba(255,255,255,0.22);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.92);
  border-radius: 10px;
  width: 0%;
  transition: width 0.9s cubic-bezier(0.175,0.885,0.32,1);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}

/* ════════════════ 主内容区域 (Content) ════════════════ */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.app-content::-webkit-scrollbar { display: none; }

.tab-section {
  display: none;
  flex-direction: column;
  gap: 0;
  padding-bottom: 30px;
  animation: tabIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}
.tab-section.active { display: flex; }

@keyframes tabIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 通用 Section Header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 4px 12px;
}

.section-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.subsection-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* ── 筛选胶囊 ── */
.filter-pills { display: flex; gap: 6px; }

.filter-pill {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--color-white);
  font-weight: 700;
  box-shadow: var(--shadow-brand);
}

/* ════════════════ 明细列表 (Transaction List) ════════════════ */
.transactions-list-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.day-group { display: flex; flex-direction: column; gap: 8px; }

.day-header {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.day-list {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.transaction-item {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--divider);
  position: relative;
  overflow: hidden;
  transition: background 0.18s ease;
  touch-action: pan-y;
  user-select: none;
  cursor: pointer;
}
.transaction-item:last-child { border-bottom: none; }
.transaction-item:active { background: var(--primary-ghost); }

.item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.item-icon-box {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: var(--transition-spring);
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.payer-tag {
  background: var(--primary-ghost);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.item-right {
  display: flex;
  align-items: center;
  padding-left: 8px;
}

.item-amount {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -0.3px;
}
.amount-out { color: var(--text-primary); }
.amount-in  { color: var(--color-income); }

/* 滑动删除按钮 */
.delete-btn-reveal {
  position: absolute;
  top: 0; right: -72px;
  width: 72px; height: 100%;
  background: var(--color-expense);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.25s ease;
}
.transaction-item.swipe-left { transform: translateX(-72px); }
.transaction-item.swipe-left .delete-btn-reveal { transform: translateX(-72px); }

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 50px;
  margin-bottom: 14px;
  animation: floatIcon 3s ease-in-out infinite;
}
@keyframes floatIcon {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.empty-state p { font-size: 13px; font-weight: 500; line-height: 1.6; }

/* ════════════════ 统计页 (Stats) ════════════════ */
.stats-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.chart-container {
  position: relative;
  width: 168px; height: 168px;
}

.donut-chart {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.08));
}

.chart-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.center-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.center-val {
  font-size: 19px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.legend-color {
  width: 9px; height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* 排行榜 */
.leaderboard-section { margin-top: 4px; }

.leaderboard-container { display: flex; flex-direction: column; gap: 10px; }

.leaderboard-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
}
.leader-label-box { display: flex; align-items: center; gap: 8px; }
.leader-amount { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.3px; }

.leader-bar-bg {
  height: 7px;
  background: var(--primary-light);
  border-radius: 10px;
  overflow: hidden;
}

.leader-bar-fill {
  height: 100%;
  background: var(--grad-hero);
  border-radius: 10px;
  width: 0%;
  transition: width 0.9s cubic-bezier(0.175, 0.885, 0.32, 1);
}

/* ════════════════ 心愿页 (Wishes) ════════════════ */
.add-wish-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--primary);
  color: var(--color-white);
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: var(--transition-fast);
}
.add-wish-btn:active { transform: scale(0.93); }

/* 爱意小金库卡片 */
.piggy-bank-card {
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.piggy-info { display: flex; align-items: center; gap: 12px; }
.piggy-icon { font-size: 30px; }
.piggy-details { display: flex; flex-direction: column; gap: 2px; }
.piggy-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.piggy-desc  { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.piggy-balance {
  font-size: 22px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--primary-dark);
  letter-spacing: -0.5px;
}

/* 心愿卡片 */
.wishes-list { display: flex; flex-direction: column; gap: 12px; }

.wish-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.wish-card.completed { opacity: 0.6; }

.wish-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--grad-hero);
  border-radius: 4px 0 0 4px;
}

.wish-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wish-left { display: flex; align-items: center; gap: 12px; }

.wish-icon-box {
  width: 46px; height: 46px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.wish-text { display: flex; flex-direction: column; gap: 3px; }

.wish-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.wish-card.completed .wish-title { text-decoration: line-through; }

.wish-budget { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.wish-check-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: var(--transition-spring);
  flex-shrink: 0;
}
.wish-card.completed .wish-check-btn {
  background: var(--color-income);
  border-color: var(--color-income);
  color: white;
}

.wish-delete-btn {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: opacity 0.2s ease;
}
.wish-card:hover .wish-delete-btn { opacity: 1; }

/* ════════════════ 设置页 (Settings) ════════════════ */
.settings-group { margin-bottom: 22px; }

.settings-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 6px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* 主题选择器 */
.theme-selector-card {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 8px;
  gap: 8px;
}

.theme-option {
  border: none;
  background: none;
  padding: 13px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-primary);
  transition: var(--transition-fast);
}
.theme-option:active { transform: scale(0.94); }

.theme-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.theme-btn-pink  .theme-dot { background: #F2607A; }
.theme-btn-green .theme-dot { background: #3D9E72; }
.theme-btn-cream .theme-dot { background: #B07D5A; }
.theme-btn-dark  .theme-dot { background: #FF7B93; }

.theme-btn-pink.active  { background: rgba(242,96,122,0.10); }
.theme-btn-green.active { background: rgba(61,158,114,0.10); }
.theme-btn-cream.active { background: rgba(176,125,90,0.10); }
.theme-btn-dark.active  { background: rgba(255,123,147,0.10); }

/* 预算输入 */
.single-input-card { padding: 14px 18px; }

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.setting-row > span { font-size: 14px; font-weight: 700; }

.budget-input-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-width: 140px;
}
.currency-symbol {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-right: 4px;
}
.budget-input-wrapper input {
  border: none;
  background: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  width: 100%;
  outline: none;
}

/* 操作列表 */
.actions-card { display: flex; flex-direction: column; }

.setting-action-btn {
  border: none;
  background: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.16s ease;
  width: 100%;
}
.setting-action-btn:last-child { border-bottom: none; }
.setting-action-btn:active { background: var(--primary-ghost); }
.setting-action-btn svg { color: var(--text-muted); }
.setting-action-btn.danger { color: var(--color-expense); }
.setting-action-btn.danger svg { color: var(--color-expense); }

.app-info {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 30px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}

/* ════════════════ 底部导航栏 (Bottom Nav) ════════════════ */
.bottom-nav {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  height: calc(68px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border-top: 1px solid var(--divider);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 10px;
  z-index: 100;
  transition: background 0.35s ease, border-color 0.35s ease;
}
.theme-dark .bottom-nav {
  background: rgba(28,26,27,0.88);
}

.nav-item {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  cursor: pointer;
  min-width: 48px;
  padding: 0 4px;
  transition: var(--transition-smooth);
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  transition: var(--transition-spring);
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  transition: var(--transition-smooth);
  letter-spacing: 0.2px;
}

.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon {
  background: var(--primary-ghost);
  transform: translateY(-1px);
}

/* 中央 + 按钮 */
.nav-add-btn {
  border: none;
  background: none;
  position: relative;
  top: -20px;
  width: 56px; height: 56px;
  cursor: pointer;
  z-index: 110;
  flex-shrink: 0;
}

.add-btn-inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--grad-hero);
  box-shadow: var(--shadow-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: var(--transition-spring);
}
.nav-add-btn:active .add-btn-inner {
  transform: scale(0.88) rotate(45deg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ════════════════ 底部弹窗 (Bottom Sheet) ════════════════ */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.38);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bottom-sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-width: 430px;
  background: var(--bg-app);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -4px 32px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  max-height: 92%;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.15, 0.85, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-sheet-overlay.active .bottom-sheet {
  transform: translateY(0);
}

/* Sheet Header */
.sheet-header {
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 10px 20px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sheet-drag-handle {
  width: 38px; height: 4px;
  background: var(--border-strong);
  border-radius: 10px;
  margin-bottom: 14px;
}

.sheet-title-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sheet-cancel-btn {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.sheet-save-btn {
  border: none;
  background: none;
  font-size: 15px;
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
  padding: 2px 0;
}

/* 支出/收入 Segmented Control */
.type-segmented-control {
  display: flex;
  background: var(--bg-app);
  padding: 3px;
  border-radius: var(--radius-sm);
  width: 100%;
  margin-bottom: 14px;
}

.control-segment {
  flex: 1;
  border: none;
  background: none;
  padding: 8px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.control-segment.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* 金额展示面板 */
.amount-display-panel {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
}

.selected-category-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}

.amount-number-wrapper {
  display: flex;
  align-items: baseline;
  color: var(--text-primary);
  gap: 2px;
}
.amount-number-wrapper .currency-symbol {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
}
.amount-val-display {
  font-size: 38px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: -1.5px;
  line-height: 1;
}

/* Sheet Body */
.sheet-body {
  overflow-y: auto;
  padding: 20px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar { display: none; }

/* ── 分类滑动条 (Category Scroll Row) ── */
.category-grid-container {
  /* 负边距延伸到 sheet 两侧，形成全宽滚动 */
  margin: 0 -16px;
}

.category-grid {
  display: none;
  flex-direction: row;
  flex-wrap: nowrap; /* 显式禁止折行，防止旧版 Safari 折行重叠 */
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 16px 8px;
}
.category-grid::-webkit-scrollbar { display: none; }

.category-grid.active {
  display: flex;
  animation: fadeIn 0.25s ease;
}

.category-item {
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  /* 固定宽度，足够好点 */
  width: 76px;
  min-width: 76px;
  height: 80px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  scroll-snap-align: start;
  flex-shrink: 0;
  transition: var(--transition-spring);
}
.category-item .cat-icon {
  font-size: 26px;
  transition: var(--transition-spring);
  line-height: 1;
}
.category-item .cat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.category-item:active { transform: scale(0.9); }

.category-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-ghost);
}
.category-item.active .cat-icon { transform: scale(1.12); }
.category-item.active .cat-label { color: var(--primary-dark); font-weight: 800; }

/* ── 买单人选择（独立全宽卡片） ── */
.payer-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.payer-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.payer-segments {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
}

.payer-btn {
  border: 1.5px solid var(--border);
  background: var(--bg-app);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 12px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  white-space: nowrap;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.2;
  flex-direction: column;
}
.payer-btn .payer-emoji { font-size: 18px; }
.payer-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* ── 表单输入组（备注 + 日期） ── */
.form-row-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 18px;
}
.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
}
.form-row.text-row {
  border-bottom: 1px solid var(--divider);
  padding: 16px 0;
  min-height: 56px;
}
.form-row.text-row:last-child { border-bottom: none; }
.row-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-right: 12px;
}

.form-row input[type="text"],
.form-row input[type="date"],
.form-row input[type="number"] {
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  outline: none;
  font-family: inherit;
  width: 100%;
  min-height: 24px;
}
.form-row input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ── 数字小键盘 (Custom Keypad) ── */
.custom-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px 12px;
  border-radius: var(--radius-xl);
  margin-top: 6px;
}

.key-btn {
  border: none;
  background: var(--bg-app);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 15px 0;
  font-size: 19px;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--transition-fast);
  letter-spacing: -0.3px;
}
.key-btn:active {
  transform: scale(0.88);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.action-key {
  font-size: 12px;
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-dark .action-key { background: rgba(255,255,255,0.05); }

.confirm-key {
  grid-row: span 2;
  background: var(--grad-hero);
  color: var(--color-white);
  box-shadow: var(--shadow-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.confirm-key:active { opacity: 0.85; transform: scale(0.92); }

/* ════════════════ 弹出模态框 (Modals) ════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.38);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.22s ease;
}

.select-modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  padding: 24px 20px;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalUp 0.3s cubic-bezier(0.15, 0.85, 0.3, 1) both;
}

@keyframes modalUp {
  from { transform: translateY(24px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.3px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.month-modal-btn {
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-primary);
  padding: 11px 0;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--transition-fast);
}
.month-modal-btn:active { transform: scale(0.93); }
.month-modal-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.modal-close-btn {
  border: none;
  background: var(--bg-app);
  color: var(--text-muted);
  padding: 12px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

/* 数据备份模态框 */
.data-modal { max-width: 400px; }
.data-modal-tip { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.data-modal-textarea {
  width: 100%;
  height: 110px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: monospace;
  font-size: 11px;
  color: var(--text-primary);
  resize: none;
  outline: none;
}
.modal-actions-row { display: flex; gap: 10px; }
.modal-btn {
  flex: 1;
  border: none;
  background: var(--primary);
  color: white;
  padding: 13px 0;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-btn:active { opacity: 0.85; }
.modal-btn.cancel-btn {
  background: var(--bg-app);
  color: var(--text-muted);
}

/* ════════════════ 通用动画 (Animations) ════════════════ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
