/* ===== 全局重置 & 变量 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f8;
  --bg2: #ffffff;
  --bg3: #f5f6fa;
  --border: #e2e6f0;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --accent: #6c63ff;
  --accent2: #00b894;
  --danger: #e53e5a;
  --warning: #f59e0b;
  --info: #3b82f6;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 16px rgba(108,99,255,0.08), 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

html {
  font-size: 15px;
  overflow-x: hidden;
  width: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 20px;
}

.sync-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 20px;
  transition: color 0.3s ease;
}

.topbar-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: var(--transition);
  white-space: nowrap;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent); color: #fff; font-weight: 600; }

.edit-data-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.edit-data-btn:hover { color: var(--text); border-color: var(--accent); }
.edit-data-btn-secondary { opacity: 0.6; font-size: 0.75rem; padding: 6px 10px; }
.edit-data-btn-secondary:hover { opacity: 1; }

/* ===== 主内容 ===== */
.main-content { padding: 24px; max-width: 1400px; margin: 0 auto; width: 100%; }

.page { display: none; }
.page.active { display: block; }

/* ===== 汇总横幅 ===== */
.summary-banner {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #6c63ff 0%, #a78bfa 100%);
  border: none;
  border-radius: var(--radius);
  padding: 20px 32px;
  margin-bottom: 28px;
  gap: 0;
  box-shadow: 0 4px 24px rgba(108,99,255,0.3);
}

.summary-item {
  flex: 1;
  text-align: center;
}

.summary-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.summary-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
}
.summary-value.danger { color: #ffd6de; }
.summary-value.warning { color: #ffe8b0; }
.summary-value.info { color: #bfdbfe; }
.summary-value.success { color: #a7f3d0; }

.summary-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
  line-height: 1.3;
}

.summary-divider {
  width: 1px;
  height: 48px;
  background: rgba(255,255,255,0.25);
  margin: 0 8px;
}

/* ===== 区块标题 ===== */
.section-title {
font-size: 1rem;
font-weight: 600;
color: var(--text);
margin-bottom: 16px;
padding-left: 12px;
border-left: 3px solid var(--accent);
}

/* 可折叠区块 */
.section-title.collapsible {
cursor: pointer;
user-select: none;
display: flex;
align-items: center;
justify-content: space-between;
padding-right: 12px;
transition: margin-bottom var(--transition);
}
.section-title.collapsible:active {
opacity: 0.7;
}
.section-title.collapsible.collapsed {
margin-bottom: 12px;
}
.collapse-arrow {
font-size: 0.75rem;
color: var(--text-muted);
transition: transform 0.3s ease;
}
.section-title.collapsible:not(.collapsed) .collapse-arrow {
transform: rotate(180deg);
}
.section-body {
overflow: hidden;
transition: max-height 0.35s ease, opacity 0.25s ease;
max-height: 2000px;
opacity: 1;
}
.section-body.collapsed {
max-height: 0;
opacity: 0;
margin-bottom: 0 !important;
}

/* ===== 银行卡片 ===== */
.bank-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.bank-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.bank-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--bank-color, var(--accent));
}
.bank-card:hover {
  border-color: var(--bank-color, var(--accent));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.bank-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.bank-icon { font-size: 1.4rem; }

.bank-name {
  font-size: 1rem;
  font-weight: 600;
}

.bank-total {
  margin-left: auto;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--danger);
}

/* ===== DAILY_UX_V1：五入口日常信息架构 ===== */
.section-subtitle,
.trend-note {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.repayment-page-intro {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.daily-risk-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.daily-risk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
}
.daily-risk-item strong { font-size: 1.35rem; }
.daily-risk-item.warning { border-color: var(--warning); color: var(--warning); }
.daily-risk-item.critical { border-color: var(--danger); color: var(--danger); }

.repayment-priority {
  min-width: 30px;
  padding: 2px 6px;
  border-radius: 5px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg3);
}
.priority-p0 { border-left: 4px solid var(--danger); }
.priority-p1 { border-left: 4px solid var(--warning); }
.priority-p2 { border-left: 4px solid var(--info); }
.repayment-facts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; font-size: 0.78rem; }
.repayment-facts span { color: var(--text-muted); }
.repayment-facts strong { color: var(--text); }
.account-status { color: var(--success); font-size: 0.72rem; margin-left: auto; }
.account-status.warning { color: var(--warning); }
.account-status.danger { color: var(--danger); }

.financial-stage-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.financial-stage-name { margin-top: 4px; color: var(--accent2); font-weight: 600; }
.financial-stage-note { color: var(--text-muted); font-size: 0.82rem; text-align: right; }
.daily-trend-card { margin-bottom: 12px; }
.trend-note { margin: -2px 4px 20px; }

@media (max-width: 700px) {
  .daily-risk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .repayment-page-intro,
  .financial-stage-compact { align-items: flex-start; flex-direction: column; }
  .financial-stage-note { text-align: left; }
  .repayment-facts { justify-content: flex-start; }
}

.bank-estimated-payable {
  margin: -8px 0 12px;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.bank-accounts { display: flex; flex-direction: column; gap: 10px; }

.account-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

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

.account-name {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.account-amount {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--warning);
}

.account-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.account-meta span { display: flex; align-items: center; gap: 3px; }

/* 信用额度进度条 */
.credit-bar {
  margin-top: 8px;
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.credit-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
  transition: width 0.6s ease;
}

/* 还款日标签 */
.due-badge {
  display: inline-block;
  background: rgba(108,99,255,0.1);
  color: var(--accent);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 600;
}
.due-badge.urgent {
  background: rgba(229,62,90,0.1);
  color: var(--danger);
  border-color: rgba(229,62,90,0.25);
}

/* ===== 图表区 ===== */
.charts-row {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 还款日历 ===== */
.calendar-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 32px;
}

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

.calendar-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-month {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.calendar-nav { display: flex; gap: 6px; }
.calendar-nav button {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.calendar-nav button:hover { border-color: var(--accent); color: var(--accent); }

.calendar-today-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}
.calendar-today-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

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

.calendar-weekday {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 0 6px;
  font-weight: 600;
}
.calendar-weekday:first-child { color: #ff6b6b; }
.calendar-weekday:last-child  { color: #4dabf7; }

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border-radius: 8px;
  font-size: 0.72rem;
  position: relative;
  cursor: default;
  transition: var(--transition);
  min-height: 52px;
  padding: 5px 2px 4px;
  box-sizing: border-box;
}

.calendar-day.empty { background: transparent; pointer-events: none; }

.calendar-day.has-due {
  background: rgba(229,62,90,0.06);
  cursor: pointer;
}
.calendar-day.has-due:active {
  background: rgba(229,62,90,0.16);
  transform: scale(0.96);
}

/* 日期数字圆圈 */
.day-num {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  flex-shrink: 0;
  color: var(--text);
}

.calendar-day.today .day-num {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* 周末颜色 */
.calendar-day.is-sun .day-num { color: #ff6b6b; }
.calendar-day.is-sat .day-num { color: #4dabf7; }
.calendar-day.today .day-num  { color: #fff; }

/* 还款金额行 */
.day-amounts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 2px;
  width: 100%;
}

.day-amount-item {
  font-size: 0.62rem;
  font-weight: 600;
  color: #e53e5a;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.day-amount-total {
  font-size: 0.65rem;
  font-weight: 700;
  color: #e53e5a;
  line-height: 1.2;
  text-align: center;
}

/* 日历底部详情抽屉 */
.calendar-drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
}
.calendar-drawer-mask.open { display: block; }

.calendar-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  max-height: 70vh;
  overflow-y: auto;
}
.calendar-drawer.open { transform: translateY(0); }

.calendar-drawer-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.calendar-drawer-title {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 20px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.calendar-drawer-list {
  padding: 8px 16px 16px;
}

.calendar-drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.calendar-drawer-item:last-child { border-bottom: none; }

.calendar-drawer-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-drawer-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-drawer-bank {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.calendar-drawer-type {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.calendar-drawer-amount {
  font-size: 1rem;
  font-weight: 700;
  color: #e53e5a;
}

.calendar-drawer-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(229,62,90,0.06);
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
}
.calendar-drawer-total-amt { color: #e53e5a; font-size: 1.05rem; }

/* ===== 分期追踪 ===== */
.installment-bank-group { margin-bottom: 28px; }

.installment-bank-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.installment-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.installment-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.inst-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.inst-name { font-weight: 600; font-size: 0.9rem; }
.inst-status {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0,212,170,0.15);
  color: var(--accent2);
  border: 1px solid rgba(0,212,170,0.3);
}

.inst-progress-wrap { margin-bottom: 10px; }
.inst-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.inst-progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.inst-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.6s ease;
}

.inst-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.78rem;
}
.inst-meta-item { display: flex; flex-direction: column; gap: 2px; }
.inst-meta-label { color: var(--text-muted); }
.inst-meta-value { font-weight: 600; }

.inst-expand-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.inst-detail-panel {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.inst-detail-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.inst-schedule {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.inst-period-row {
  display: grid;
  grid-template-columns: 16px 44px 90px 1fr 1fr;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 5px 6px;
  border-radius: 6px;
}

.inst-period-past {
  color: var(--text-muted);
  background: transparent;
}

.inst-period-current {
  color: var(--primary);
  background: rgba(108, 99, 255, 0.08);
  font-weight: 600;
}

.inst-period-future {
  color: var(--text);
}

.inst-period-dot {
  font-size: 0.6rem;
  text-align: center;
}

.inst-period-past .inst-period-dot { color: var(--text-muted); }
.inst-period-current .inst-period-dot { color: var(--primary); }
.inst-period-future .inst-period-dot { color: var(--border); }

/* ===== 时间线 ===== */
.timeline {
  position: relative;
  padding-left: 32px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 12px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}
.timeline-dot {
  position: absolute;
  left: -26px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bg2);
  background: var(--accent);
}
.timeline-dot.done { background: var(--success); }
.timeline-dot.soon { background: var(--warning); }

.timeline-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.timeline-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.timeline-title { font-weight: 600; margin-bottom: 8px; }
.tl-note { font-size: 0.72rem; font-weight: 400; color: var(--warning); background: rgba(255,169,77,0.12); padding: 2px 7px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.timeline-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.timeline-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.timeline-meta {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== What-if ===== */
.whatif-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.whatif-controls {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.whatif-result {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-placeholder { color: var(--text-muted); font-size: 0.9rem; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.result-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.result-item-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; }
.result-item-value { font-size: 1.3rem; font-weight: 700; }
.result-item-value.good { color: var(--success); }
.result-item-value.bad { color: var(--danger); }
.result-item-value.neutral { color: var(--info); }

.result-comparison {
  grid-column: 1 / -1;
  background: rgba(0,184,148,0.07);
  border: 1px solid rgba(0,184,148,0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.88rem;
  line-height: 1.8;
}

/* ===== 消费记录 ===== */
.expense-container {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.form-row { display: flex; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; margin-bottom: 12px; }
.form-group label { font-size: 0.78rem; color: var(--text-muted); }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
select,
textarea {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.875rem;
  width: 100%;
  transition: var(--transition);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.15);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}
.btn-primary:hover { background: #5a52e0; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { color: var(--text); border-color: var(--accent); }

.expense-stats { display: flex; flex-direction: column; gap: 12px; }

.expense-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.expense-stat-row:last-of-type { border-bottom: none; }

.expense-filter {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.expense-filter input { width: auto; }

.expense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.expense-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg2);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.expense-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.expense-table tr:hover td { background: var(--bg2); }

.del-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.6;
  transition: var(--transition);
}
.del-btn:hover { opacity: 1; }

/* ===== 弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,30,60,0.35);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 700px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(108,99,255,0.15), 0 4px 24px rgba(0,0,0,0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body { flex: 1; overflow: auto; padding: 16px 20px; }

.modal-tip {
  font-size: 0.8rem;
  color: var(--warning);
  margin-bottom: 12px;
}

#dataEditor {
  width: 100%;
  height: 400px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  resize: vertical;
  background: #f8f9fc;
  border-color: var(--border);
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn-primary { width: auto; }

/* ===== 快速更新余额弹窗 ===== */
.modal-wide { max-width: 640px; max-height: 80vh; }

.qu-bank-group {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qu-bank-title {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.qu-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.qu-row:last-child { border-bottom: none; }
.qu-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 600;
}
.qu-type {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 400;
}
.qu-inputs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.qu-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}
.qu-field-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.qu-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 0.9rem;
  width: 100%;
  transition: var(--transition);
}
.qu-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg3);
}

/* ===== 本月消费概览 ===== */
.expense-overview-wrap {
  margin-bottom: 24px;
}
.exp-overview-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
}
.exp-overview-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.exp-ov-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.exp-ov-amount {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.exp-ov-refund {
  font-size: 0.8rem;
  color: var(--success, #00d4aa);
  background: rgba(0, 212, 170, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}
.exp-overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.exp-ov-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: var(--transition);
}
.exp-ov-card:hover { border-color: var(--accent); }
.exp-ov-card-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.exp-ov-card-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.exp-ov-card-refund {
  font-size: 0.72rem;
  color: var(--success, #00d4aa);
  font-weight: 400;
}
.exp-ov-card-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.exp-ov-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}
.exp-ov-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.exp-ov-bar-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ===== 账单状态面板 ===== */
.billing-status-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.billing-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: var(--transition);
}
.billing-card:hover { border-color: var(--accent); }
.billing-card-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--text);
}
.billing-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}
.billing-label { color: var(--text-muted); }
.billing-value { font-weight: 600; color: var(--warning); }
.billing-value.urgent { color: var(--danger); }
.billing-card-row { cursor: default; user-select: none; }
.billing-toggle {
  display: inline-block;
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 4px;
  transition: transform 0.2s ease;
  vertical-align: middle;
}
.billing-detail {
  max-height: 0;
  overflow: hidden;
  background: var(--bg);
  border-radius: 6px;
  margin: 0;
  transition: max-height 0.3s ease, margin 0.2s ease;
}
.billing-detail.open {
  max-height: 2400px;
  margin: 2px 0 6px;
  overflow-y: auto;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1d2e;
  border: none;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 9999;
  white-space: pre-line;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toast.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 套现标红 ===== */
.cash-advance-row { background: rgba(229, 62, 90, 0.05); }
.bill-tag {
  display: inline-block;
  font-size: 0.68rem;
  background: rgba(77, 171, 247, 0.15);
  color: var(--info);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== 底部导航栏（移动端专用） ===== */
.bottom-nav {
  display: none; /* 桌面隐藏 */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 4px;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-btn.active { color: var(--accent); }
.bottom-nav-btn:active { transform: scale(0.92); }

.bnav-icon { font-size: 1.3rem; line-height: 1; }
.bnav-label { font-size: 0.65rem; font-weight: 500; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
  .whatif-container { grid-template-columns: 1fr; }
  .expense-container { grid-template-columns: 1fr; }
  .summary-banner { flex-wrap: wrap; gap: 16px; }
  .summary-divider { display: none; }
  .topbar-nav { gap: 2px; }
  .nav-btn { padding: 6px 10px; font-size: 0.8rem; }
}

@media (max-width: 600px) {
  /* 显示底部导航，隐藏顶部导航 */
  .bottom-nav { display: flex; }
  .topbar-nav { display: none; }
  .edit-data-btn { display: none; }

  /* 主内容留出底部导航空间 */
  .main-content {
    padding: 12px 12px calc(70px + env(safe-area-inset-bottom));
  }
  .topbar { padding: 0 16px; height: 52px; }
  .logo { font-size: 0.95rem; }
  .last-updated { display: none; }

  /* 卡片单列 */
  .bank-cards { grid-template-columns: 1fr; }
  .installment-cards { grid-template-columns: 1fr; }

  /* 汇总横幅：2列网格 */
  .summary-banner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px;
  }
  .summary-item { text-align: left; }
  .summary-value { font-size: 1.2rem; }

  /* 日历移动端 */
  .calendar-day { min-height: 46px; padding: 4px 1px 3px; }
  .day-num { width: 22px; height: 22px; font-size: 0.75rem; }
  .day-amount-item { font-size: 0.58rem; }
  .day-amount-total { font-size: 0.6rem; }

  /* 表格横向滚动 */
  .expense-list-wrap { overflow-x: auto; }
  .expense-table { min-width: 500px; }

  /* 弹窗全屏 */
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius) var(--radius) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }
  .modal-overlay { align-items: flex-end; }

  /* 触摸优化：加大点击区域 */
  .nav-btn, .btn-primary, .btn-secondary {
    min-height: 44px;
  }
  input, select { min-height: 44px; font-size: 16px; /* 防止 iOS 自动缩放 */ }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page.active { animation: fadeIn 0.25s ease; }

.bank-card, .installment-card, .timeline-card {
  animation: fadeIn 0.3s ease both;
}

/* ===== AI 识别卡片 ===== */
.ai-recognize-card {
  margin-bottom: 20px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #f8f7ff 0%, #f0eeff 100%);
  border: 1px solid #ddd8ff;
  position: relative;
  overflow: hidden;
}
.ai-recognize-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.ai-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ai-icon { font-size: 20px; }
.ai-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.ai-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
  flex: 1;
}
.ai-clear-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 3px 10px;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.ai-clear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 对话气泡区 */
.ai-chat-history {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  padding-right: 2px;
}
.ai-chat-history:empty { display: none; }
.ai-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.ai-bubble-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.ai-bubble-ai {
align-self: flex-start;
background: #f5f6fa;
border: 1px solid var(--border);
border-bottom-left-radius: 4px;
color: var(--text);
}
/* Markdown 回复气泡 */
.ai-bubble-markdown { line-height: 1.7; padding: 0 !important; overflow: hidden; }
.ai-md-body {
  width: 100%;
  max-height: 65vh;
  overflow-y: auto;
  padding: 12px 14px;
  box-sizing: border-box;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ai-md-body::-webkit-scrollbar { width: 4px; }
.ai-md-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
/* 内容不足 420px 时不显示滚动条 */
.ai-md-body.short { max-height: none; overflow-y: visible; }
.ai-md-h1 { font-size: 1.1em; font-weight: 700; margin: 10px 0 4px; color: var(--accent); }
.ai-md-h2 { font-size: 1.05em; font-weight: 700; margin: 8px 0 4px; color: var(--accent); }
.ai-md-h3 { font-size: 0.97em; font-weight: 700; margin: 8px 0 3px; color: var(--text); border-left: 3px solid var(--accent); padding-left: 8px; }
.ai-md-li { padding: 2px 0 2px 16px; position: relative; }
.ai-md-li::before { content: '•'; position: absolute; left: 4px; color: var(--accent); }
.ai-md-gap { height: 8px; }
.ai-bubble-markdown strong { color: var(--warning); font-weight: 600; }
.ai-bubble-img {
  max-width: 140px;
  max-height: 100px;
  border-radius: 6px;
  object-fit: cover;
}
/* AI 解析结果卡片 */
.ai-intent-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0,212,170,0.12);
  color: var(--accent);
  margin-bottom: 6px;
}
.ai-parsed-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-parsed-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.ai-parsed-row span { color: var(--text-muted); white-space: nowrap; }
.ai-parsed-row strong { color: var(--text); }
.ai-bubble-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 5px;
}
.ai-confirm-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.ai-confirm-btn:hover { opacity: 0.85; }
.ai-batch-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ai-batch-actions .ai-confirm-btn {
  flex: 1;
  margin-top: 0;
}
.ai-skip-btn {
  flex: 0 0 auto;
  padding: 10px 16px;
  background: #f5f6fa;
  border: 1px solid #e2e6f0;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}
.ai-skip-btn:hover { background: #e9ecf5; color: var(--text); }
.ai-batch-done .ai-intent-tag { opacity: 0.7; }
.ai-batch-done .ai-parsed-card { opacity: 0.6; }
.ai-dup-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #856404;
  line-height: 1.4;
}
.ai-dup-card {
  border-color: #ffc107 !important;
  background: #fffbeb;
}
.ai-edit-btn {
  flex: 0 0 auto;
  padding: 10px 16px;
  background: #f0f4ff;
  border: 1.5px solid #d0d8f0;
  border-radius: 10px;
  color: #4a6cf7;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.ai-edit-btn:hover { background: #dce4ff; }
.ai-preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  align-items: center;
}
.ai-img-thumb-wrap {
  position: relative;
  width: 60px;
  height: 60px;
}
.ai-img-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--border);
}
.ai-img-thumb-wrap .ai-remove-img {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ai-clear-all-img {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.ai-clear-all-img:hover { color: var(--danger); border-color: var(--danger); }
.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-textarea {
  flex: 1;
  background: #f5f6fa;
  border: 1.5px solid #e2e6f0;
  border-radius: 22px;
  color: var(--text);
  font-size: 15px;
  padding: 10px 16px;
  resize: none;
  line-height: 1.5;
  transition: border-color var(--transition), background var(--transition);
  font-family: inherit;
  max-height: 120px;
  overflow-y: auto;
}
.ai-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}
.ai-textarea::placeholder { color: #adb5bd; }
.ai-img-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f6fa;
  border: 1.5px solid #e2e6f0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.ai-img-btn:hover {
  background: rgba(108,99,255,0.2);
  border-color: var(--accent);
}
/* 语音按钮 */
.ai-voice-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f6fa;
  border: 1.5px solid #e2e6f0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 17px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
  color: var(--text);
}
.ai-voice-btn:hover { background: rgba(108,99,255,0.2); border-color: var(--accent); }
.ai-voice-btn.listening {
  background: rgba(255,77,109,0.25);
  border-color: var(--danger);
  animation: voicePulse 1s infinite;
}
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,77,109,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(255,77,109,0); }
}
/* 发送按钮：圆形大按钮 */
.ai-send-btn {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(108,99,255,0.45);
}
.ai-send-btn:hover { background: #5a52e0; transform: scale(1.08); box-shadow: 0 4px 18px rgba(108,99,255,0.6); }
.ai-send-btn:active { transform: scale(0.94); }
.ai-send-btn:disabled { background: rgba(255,255,255,0.12); box-shadow: none; cursor: not-allowed; transform: none; }
.ai-send-btn.loading { animation: aiPulse 1s infinite; }
@keyframes aiPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.ai-preview-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-preview-row img {
  max-height: 80px;
  max-width: 160px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
}
.ai-remove-img {
  background: var(--danger);
  border: none;
  border-radius: 50%;
  color: #fff;
  width: 22px;
  height: 22px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-status {
  margin-top: 10px;
  font-size: 13px;
  min-height: 20px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.ai-status.success { color: var(--success); }
.ai-status.error { color: var(--danger); }
.ai-status.loading { color: var(--accent); }

/* ===== AI 流式打点动画 ===== */
.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.ai-typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: ai-dot-bounce 1.2s infinite ease-in-out;
}
.ai-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ===== 消费记录操作按钮 ===== */
.action-btns {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.edit-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1.4;
}
.edit-btn:hover { border-color: var(--accent); color: var(--accent); }
.refund-btn {
  background: none;
  border: 1px solid var(--accent2);
  border-radius: 6px;
  color: var(--accent2);
  font-size: 14px;
  padding: 2px 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  line-height: 1.4;
}
.refund-btn:hover {
  background: var(--accent2);
  color: #000;
}
/* 退款行（负金额）样式 */
tr.refund-row td { opacity: 0.75; }
tr.refund-row td:nth-child(3) { color: var(--success) !important; }

/* ===== 钱包余额面板 ===== */
.wallet-edit-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: var(--transition);
}
.wallet-edit-btn:hover { background: var(--accent); color: #000; }

.wallet-panel { margin-bottom: 8px; }

.wallet-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.wallet-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 110px;
  text-align: center;
  transition: var(--transition);
}
.wallet-card:hover { border-color: var(--accent); }
.wallet-card-icon { font-size: 1.4rem; margin-bottom: 4px; }
.wallet-card-name { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 4px; }
.wallet-card-balance { font-size: 1.05rem; font-weight: 700; color: var(--text); }

.wallet-cover-tip {
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.wallet-cover-tip.ok   { background: rgba(16,185,129,0.08); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.wallet-cover-tip.warn { background: rgba(245,158,11,0.08); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }

.wallet-edit-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.wallet-edit-form { display: flex; flex-direction: column; gap: 10px; }
.wallet-edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wallet-edit-label {
  width: 100px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.wallet-edit-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.9rem;
}
.wallet-edit-input:focus { outline: none; border-color: var(--accent); }
.wallet-edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.wallet-edit-actions .btn-save {
  flex: 1;
  padding: 10px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.wallet-edit-actions .btn-cancel {
  padding: 10px 16px;
  background: var(--bg3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

/* ===== AI 全屏页 ===== */
.page-ai {
  display: none;
  flex-direction: column;
  height: calc(100vh - 60px); /* 减去顶部导航高度 */
  padding: 0 !important;
  max-width: 100% !important;
  position: relative;
}
.page-ai.active { display: flex; }

.ai-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.ai-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
}
.ai-page-icon { font-size: 1.4rem; }
.ai-page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 全屏对话历史区 */
.ai-chat-history-full {
  flex: 1;
  max-height: none !important;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 欢迎屏 */
.ai-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 20px;
  text-align: center;
  flex: 1;
}
.ai-welcome-icon { font-size: 3rem; }
.ai-welcome-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.ai-welcome-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  width: 100%;
}
.ai-tip-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.ai-tip-item:hover { border-color: var(--accent); color: var(--text); }

/* 输入栏固定底部 */
.ai-input-bar {
  flex-shrink: 0;
  padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.95);
  border-top: 1px solid #e2e6f0;
  backdrop-filter: blur(16px);
}
.ai-input-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
}

/* 气泡最大宽度限制（全屏模式） */
.ai-chat-history-full .ai-bubble {
  max-width: 680px;
}
.ai-chat-history-full .ai-bubble-user { align-self: flex-end; }
.ai-chat-history-full .ai-bubble-ai  { align-self: flex-start; }

/* ===== What-if 抽屉 ===== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,30,60,0.3);
  z-index: 300;
  display: none;
  backdrop-filter: blur(4px);
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(520px, 95vw);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 301;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(108,99,255,0.12);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* What-if 抽屉内布局 */
.whatif-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.whatif-controls {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.whatif-result {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* What-if 入口按钮（银行卡片内） */
.whatif-entry-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}
.whatif-entry-btn:hover {
  background: rgba(108,99,255,0.2);
  border-color: var(--accent);
}

/* ===== 消费分析页 ===== */
.btn-add-expense {
background: linear-gradient(135deg, var(--accent), #a78bfa);
color: #fff;
border: none;
border-radius: 20px;
padding: 6px 16px;
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
transition: var(--transition);
white-space: nowrap;
}
.btn-add-expense:hover { opacity: 0.85; transform: translateY(-1px); }

.pie-empty-placeholder {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
min-height: 160px;
color: var(--text-muted);
font-size: 0.9rem;
}

.analysis-header {
display: flex;
align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.analysis-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-nav-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.month-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.analysis-month-label {
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 90px;
  text-align: center;
}

/* 总计卡片 */
.analysis-totals {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.analysis-total-card {
  flex: 1;
  min-width: 120px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.atc-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; }
.atc-value { font-size: 1.4rem; font-weight: 700; }
.atc-sub { font-size: 0.75rem; color: var(--success, #00d4aa); margin-top: 4px; }

/* 分析图表行 */
.analysis-charts-row {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-wrap-sm { height: 220px; }

/* 分类排行 */
.analysis-rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.analysis-rank-row:last-child { border-bottom: none; }
.analysis-rank-label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 90px;
  flex-shrink: 0;
}
.analysis-rank-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.analysis-rank-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.analysis-rank-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.analysis-rank-amount {
  width: 70px;
  text-align: right;
  font-weight: 600;
  color: var(--warning);
  flex-shrink: 0;
}
.analysis-rank-pct {
  width: 44px;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* 支付方式分布 */
.payment-dist-list {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.payment-dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}
.payment-dist-name {
  width: 100px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.payment-dist-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.payment-dist-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}
.payment-dist-amount {
  width: 70px;
  text-align: right;
  font-weight: 600;
  flex-shrink: 0;
}
.payment-dist-pct {
  width: 44px;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* AI 分析结果 */
.ai-analysis-result {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  min-height: 80px;
}
.ai-analysis-placeholder { color: var(--text-muted); font-size: 0.88rem; }
.ai-analysis-loading { color: var(--accent); font-size: 0.88rem; }
.ai-analysis-text { font-size: 0.9rem; line-height: 1.8; color: var(--text); }
.ai-analysis-error { color: var(--danger); font-size: 0.88rem; }

/* ===== 底部导航 AI 中央按钮 ===== */
.bnav-ai-center {
  position: relative;
}
.bnav-ai-icon {
  font-size: 1.5rem !important;
  background: var(--accent);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin-top: -10px;
  box-shadow: 0 4px 16px rgba(108,99,255,0.5);
  transition: var(--transition);
}
.bnav-ai-center.active .bnav-ai-icon {
  background: #5a52e0;
  box-shadow: 0 4px 20px rgba(108,99,255,0.7);
}
.bnav-ai-center .bnav-label { color: var(--accent); font-weight: 600; }

/* ===== AI 导航按钮（顶部）===== */
.nav-btn-ai {
  background: rgba(108,99,255,0.15) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(108,99,255,0.3);
}
.nav-btn-ai:hover, .nav-btn-ai.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent);
}

/* ===== 移动端 AI 页适配 ===== */
@media (max-width: 600px) {
  .page-ai {
    height: calc(100vh - 52px - 70px - env(safe-area-inset-bottom));
  }
  .ai-chat-history-full { padding: 12px; }
  .ai-input-bar { padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .analysis-charts-row { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}

/* ===== 下拉刷新指示器 ===== */
#pullRefreshIndicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
  pointer-events: none;
  box-shadow: 0 2px 12px rgba(108,99,255,0.08);
}
#pullRefreshIndicator.visible {
  transform: translateY(0);
}
#pullRefreshIndicator.refreshing {
  transform: translateY(0);
}
.pull-refresh-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.pull-refresh-arrow {
  font-size: 18px;
  transition: transform 0.2s ease;
  display: inline-block;
}
.pull-refresh-arrow.ready {
  transform: rotate(180deg);
}

/* ===== 回到顶部按钮 ===== */
#backToTopBtn {
  position: fixed;
  right: 20px;
  bottom: 90px; /* 底部导航栏上方 */
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(108,99,255,0.5);
  opacity: 0;
  transform: translateY(16px) scale(0.85);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 500;
}
#backToTopBtn.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
#backToTopBtn:active {
  transform: scale(0.92);
}

/* ===== 新功能样式 ===== */

/* 通用面板 */
.feature-panel {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.empty-tip {
  text-align: center;
  color: #8892b0;
  padding: 20px;
  font-size: 0.9rem;
}

/* 还款计划列表 */
.repayment-plan-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.repayment-plan-item:last-child { border-bottom: none; }

.plan-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.plan-icon { font-size: 1.4rem; }
.plan-bank { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.plan-account { font-size: 0.75rem; color: #8892b0; margin-top: 2px; }

.plan-right { text-align: right; }
.plan-amount { font-weight: 700; font-size: 1rem; color: var(--text); }
.plan-due { font-size: 0.75rem; color: #8892b0; margin-top: 2px; }

.plan-paid { opacity: 0.5; }
.plan-paid .plan-amount { color: #00d4aa; }
.plan-overdue { border-left: 3px solid #ff4d6d; padding-left: 12px; }
.plan-urgent .plan-due { color: #ff4d6d; font-weight: 600; }
.plan-pay-btn { margin-top: 4px; padding: 3px 10px; font-size: 11px; border: 1px solid #4caf50; color: #4caf50; background: #f0fff0; border-radius: 12px; cursor: pointer; transition: all .2s; }
.plan-pay-btn:hover { background: #4caf50; color: #fff; }
.plan-paid .plan-pay-btn { display: none; }

/* 大额到期预警 */
.large-due-card {
  background: linear-gradient(135deg, rgba(255,77,109,0.08), rgba(255,169,77,0.05));
  border: 1px solid rgba(255,77,109,0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.large-due-card.critical {
  border-color: #ff4d6d;
  background: linear-gradient(135deg, rgba(255,77,109,0.12), rgba(255,77,109,0.05));
}
.large-due-card.warning {
  border-color: #ffa94d;
  background: linear-gradient(135deg, rgba(255,169,77,0.1), rgba(255,169,77,0.03));
}
.large-due-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.large-due-icon { font-size: 1.2rem; }
.large-due-title { font-weight: 600; color: var(--text); }
.large-due-amount {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ff4d6d;
  margin-bottom: 8px;
}
.large-due-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #8892b0;
  margin-bottom: 8px;
}
.large-due-countdown { color: #ff4d6d; font-weight: 600; }
.large-due-tip {
  font-size: 0.8rem;
  color: #ffa94d;
  padding: 8px 12px;
  background: rgba(255,169,77,0.08);
  border-radius: 8px;
}

/* 进度条 */
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #8892b0;
  margin-bottom: 8px;
}
.progress-bar-wrap {
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6c63ff, #00d4aa);
  border-radius: 5px;
  transition: width 0.5s ease;
}
.progress-pct {
  text-align: center;
  font-size: 0.8rem;
  color: #00d4aa;
  font-weight: 600;
}

/* 消费预算 */
.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.budget-title { font-weight: 600; color: var(--text); }
.budget-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
}
.budget-edit-btn:hover { opacity: 1; }
.budget-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.budget-label { font-size: 0.75rem; color: #8892b0; }
.budget-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.budget-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #8892b0;
  margin-top: 6px;
}

/* 收支平衡 */
.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.balance-item {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}
.balance-item-label { font-size: 0.75rem; color: #8892b0; margin-bottom: 4px; }
.balance-item-value { font-size: 1.1rem; font-weight: 700; }
.balance-item.income .balance-item-value { color: #00d4aa; }
.balance-item.expense .balance-item-value { color: #ffa94d; }
.balance-item.positive .balance-item-value { color: #00d4aa; }
.balance-item.negative .balance-item-value { color: #ff4d6d; }

.balance-warning {
  padding: 12px;
  background: rgba(255,169,77,0.08);
  border: 1px solid rgba(255,169,77,0.3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: #ffa94d;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.balance-feasible { font-weight: 600; }
.balance-feasible.ok { color: #00d4aa; }
.balance-feasible.danger { color: #ff4d6d; }

/* 提前还款计算器 */
.prepay-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.prepay-form .form-group { flex: 1; min-width: 150px; }
.prepay-form .btn-primary { align-self: flex-end; }

.prepay-result-card {
  background: rgba(108,99,255,0.05);
  border: 1px solid rgba(108,99,255,0.2);
  border-radius: 8px;
  padding: 16px;
}
.prepay-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.prepay-result-row:last-child { border-bottom: none; }

.result-placeholder {
  text-align: center;
  color: #8892b0;
  padding: 16px;
  font-size: 0.85rem;
}

/* ===== 还款记录日志 ===== */
.repay-log-list {
  max-height: 300px;
  overflow-y: auto;
}
.repay-log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.repay-log-item:last-child { border-bottom: none; }
.repay-log-date { color: #8892b0; min-width: 100px; }
.repay-log-name { flex: 1; margin: 0 8px; }
.repay-log-amount { color: #00d4aa; font-weight: 600; }

/* ===== 还款优先级 ===== */
.priority-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.priority-tab {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.priority-tab.active {
  background: rgba(108,99,255,0.15);
  border-color: #6c63ff;
  color: #6c63ff;
}
.priority-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.priority-item:last-child { border-bottom: none; }
.priority-first {
  background: rgba(108,99,255,0.08);
  border-radius: 8px;
  border: 1px solid rgba(108,99,255,0.2);
}
.priority-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}
.priority-first .priority-rank {
  background: #6c63ff;
  color: #fff;
}
.priority-name { flex: 1; }
.priority-rate { color: #ffa94d; min-width: 60px; text-align: right; }
.priority-balance { color: #8892b0; min-width: 80px; text-align: right; }
.priority-tip {
  margin-top: 12px;
  padding: 10px;
  background: rgba(108,99,255,0.05);
  border-radius: 8px;
  font-size: 0.8rem;
  color: #8892b0;
  line-height: 1.5;
}

/* ===== 年度还款日历 ===== */
#yearlyCalendarPanel {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.yearly-calendar {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 160px;
  padding: 12px 0;
  min-width: 600px;
}
.yearly-month {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.yearly-month-label {
  font-size: 0.7rem;
  color: #8892b0;
}
.yearly-bar-wrap {
  flex: 1;
  width: 100%;
  max-width: 28px;
  background: rgba(108,99,255,0.1);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.yearly-bar {
  width: 100%;
  background: linear-gradient(to top, #6c63ff, #a78bfa);
  border-radius: 4px;
  min-height: 4px;
  transition: height 0.3s;
}
.yearly-high .yearly-bar {
  background: linear-gradient(to top, #ff4d6d, #ffa94d);
}
.yearly-amount {
  font-size: 0.7rem;
  color: var(--text);
  font-weight: 600;
}
.yearly-high .yearly-amount { color: #ff4d6d; }

/* ===== 收入管理 ===== */
.income-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.income-list {
  border-top: 1px solid var(--border);
}
.income-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.income-item:last-child { border-bottom: none; }
.income-amount { color: #00d4aa; font-weight: 600; }

/* ===== 模块设置弹窗 ===== */
.module-settings-list {
  max-height: 400px;
  overflow-y: auto;
}
.module-setting-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.module-setting-item:last-child { border-bottom: none; }
.module-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.module-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #6c63ff;
}

/* ===== 深色模式（仅在 html.dark-mode 时生效）===== */
html.dark-mode {
  --bg: #0a0e1a;
  --bg2: #141825;
  --bg3: #1a1f30;
  --border: rgba(46,50,80,0.8);
  --text: #e6e8f0;
  --text-muted: #8892b0;
}
html.dark-mode body {
  background: var(--bg);
  color: var(--text);
}
html.dark-mode .topbar {
  background: var(--bg2);
  border-bottom-color: var(--border);
}
html.dark-mode .summary-banner {
  background: var(--bg2);
  border-color: var(--border);
}
html.dark-mode .feature-panel,
html.dark-mode .chart-card,
html.dark-mode .wallet-panel,
html.dark-mode .billing-status-wrap,
html.dark-mode .expense-overview-wrap {
  background: var(--bg2);
  border-color: var(--border);
}
html.dark-mode .bank-card {
  background: var(--bg2);
  border-color: var(--border);
}
html.dark-mode .modal {
  background: var(--bg2);
  border-color: var(--border);
}
html.dark-mode .nav-btn,
html.dark-mode .bottom-nav-btn {
  color: var(--text-muted);
}
html.dark-mode .section-title {
  color: var(--text);
}
html.dark-mode .summary-label {
  color: var(--text-muted);
}
html.dark-mode .bottom-nav {
  background: var(--bg2);
  border-top-color: var(--border);
}
html.dark-mode .calendar-wrap {
  background: var(--bg2);
  border-color: var(--border);
}
html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}
html.dark-mode .expense-table th {
  background: var(--bg3);
  color: var(--text-muted);
}
html.dark-mode .expense-table td {
  border-color: var(--border);
}
html.dark-mode .toast {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--border);
}
html.dark-mode .edit-data-btn {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}
html.dark-mode .btn-primary {
  background: #6c63ff;
}
html.dark-mode .drawer,
html.dark-mode .calendar-drawer {
  background: var(--bg2);
}

/* ===== AUTH-001：单用户登录 Gate ===== */
body.auth-pending,
body.auth-required {
  background: linear-gradient(145deg, #eef1ff 0%, #f6f7fb 50%, #ecfbf7 100%);
}

body.auth-pending > :not(#authScreen):not(script),
body.auth-required > :not(#authScreen):not(script) {
  display: none !important;
}

.auth-screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.auth-pending .auth-screen,
body.auth-required .auth-screen {
  display: flex;
}

.auth-card {
  width: min(100%, 390px);
  padding: 32px;
  border: 1px solid rgba(108, 99, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 60px rgba(35, 42, 88, 0.12);
}

.auth-mark {
  display: flex;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(108, 99, 255, 0.10);
  font-size: 1.35rem;
}

.auth-card h1 {
  font-size: 1.45rem;
  line-height: 1.3;
}

.auth-subtitle {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.auth-screen.is-pending .auth-form {
  display: none;
}

.auth-form label {
  margin-top: 4px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.10);
}

.auth-login-btn {
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.auth-login-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-message {
  min-height: 22px;
  color: var(--danger);
  font-size: 0.8rem;
  line-height: 1.45;
}

.auth-message.info {
  color: var(--text-muted);
}

.auth-logout-btn {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg3);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  white-space: nowrap;
}

.auth-logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

@media (max-width: 600px) {
  .auth-screen { padding: 18px; }
  .auth-card { padding: 26px 22px; }
  .topbar-left { gap: 8px; }
  .sync-status { display: none; }
}

/* ===== V2 财务翻身路径 ===== */
.financial-path-panel {
  margin: 20px 0;
  padding: 20px;
  border: 1px solid rgba(0, 212, 170, 0.28);
  background: linear-gradient(135deg, rgba(108, 99, 255, 0.08), rgba(0, 212, 170, 0.06));
}
.financial-path-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.financial-path-title { font-size: 1.05rem; font-weight: 700; }
.financial-path-subtitle { margin-top: 4px; color: var(--text-muted); font-size: 0.78rem; }
.scenario-badge {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  color: #00d4aa;
  background: rgba(0, 212, 170, 0.10);
  border: 1px solid rgba(0, 212, 170, 0.25);
  font-size: 0.72rem;
}
.financial-path-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.path-metric {
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.path-metric span { display: block; color: var(--text-muted); font-size: 0.72rem; margin-bottom: 5px; }
.path-metric strong { font-size: 1rem; }
.financial-path-chart { height: 250px; margin: 8px 0 18px; }
.financial-phases {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.financial-phase {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.financial-phase.active { border-color: rgba(255, 169, 77, 0.45); }
.financial-phase.ready { border-color: rgba(0, 212, 170, 0.35); }
.financial-phase.locked { opacity: 0.72; }
.phase-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.financial-phase.active .phase-index { background: rgba(255, 169, 77, 0.16); color: #ffa94d; }
.financial-phase.ready .phase-index { background: rgba(0, 212, 170, 0.14); color: #00d4aa; }
.financial-phase strong { display: block; font-size: 0.84rem; margin-bottom: 4px; }
.financial-phase small { display: block; color: var(--text-muted); line-height: 1.45; }
.financial-path-note {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .financial-path-panel { padding: 16px; }
  .financial-path-header { flex-direction: column; }
  .financial-path-metrics,
  .financial-phases { grid-template-columns: 1fr; }
  .financial-path-chart { height: 220px; }
}
