/* 家庭账本 · 移动端卡片风格 */

:root {
  --accent: #E60044;
  --accent-dark: #C4003A;
  --accent-soft: #FFF1F4;
  --green: #00875A;
  --green-dot: #00B578;
  --blue: #2F6BD8;
  --blue-dot: #3B7CFF;
  --orange: #E07A00;
  --gray-dot: #C7C7CC;
  --bg: #F6F7F9;
  --card: #FFFFFF;
  --line: #EDEDF0;
  --text: #17181A;
  --text-2: #66666B;
  --r-card: 16px;
  --r-comp: 12px;
  --r-pill: 999px;
  --shadow-card: 0 1px 2px rgba(23, 24, 26, .04), 0 8px 24px rgba(23, 24, 26, .05);
  --shadow-fab: 0 6px 16px rgba(230, 0, 68, .28), 0 2px 6px rgba(230, 0, 68, .2);
  --ease: cubic-bezier(.34, 1.56, .64, 1);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button { font-family: inherit; }

/* ==================== 登录页 ==================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #FFE8ED 0%, var(--bg) 60%);
}

.login-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.login-card h1 { margin: 0 0 8px; font-size: 20px; font-weight: 700; }

.login-hint { font-size: 13px; color: var(--text-2); margin: 0 0 20px; }
.login-hint strong { color: var(--accent); }

.token-form { display: flex; flex-direction: column; gap: 12px; }

.token-input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-comp);
  padding: 0 12px;
  font-size: 14px;
  background: #FAFAFC;
  color: var(--text);
}

.token-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230, 0, 68, .1); }

.login-error { color: var(--accent); font-size: 14px; }
.login-error p { margin: 0 0 16px; }
.login-loading { color: var(--text-2); font-size: 14px; margin-top: 16px; }

/* ==================== 主框架 ==================== */

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, #FFE8ED 0%, rgba(255, 232, 237, .86) 70%, rgba(246, 247, 249, 0) 100%);
  backdrop-filter: blur(8px);
}

.back-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  flex: none;
}

.back-btn:active { transform: scale(.92); background: #F2F3F5; }

.header-title { font-size: 20px; font-weight: 700; letter-spacing: .01em; text-align: left; flex: 1; }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.user-chip {
  background: var(--card);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  box-shadow: var(--shadow-card);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text-2);
  font-size: 15px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
}

.icon-btn:active { transform: scale(.92); }

.content { padding: 4px 0 8px; }
.page { padding-top: 8px; animation: pageIn .24s ease; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 卡片 ==================== */

.card {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin: 0 16px 12px;
}

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

.section-head h3 { margin: 0; font-size: 16px; font-weight: 700; }

.head-link { font-size: 13px; color: var(--text-2); cursor: pointer; }
.head-link:active { color: var(--accent); }

/* ==================== 快捷入口 ==================== */

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

.quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  cursor: pointer;
  min-height: 64px;
}

.qi-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #F7F8FA;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform .2s var(--ease);
}

.qi-icon.qi-accent { background: var(--accent-soft); }
.quick-item:active .qi-icon { transform: scale(.9); }
.qi-label { font-size: 12px; color: var(--text); }

/* ==================== 统计数字 ==================== */

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.stat {
  min-width: 0; overflow: hidden;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-green { background: var(--green-dot); }
.dot-red { background: var(--accent); }
.dot-blue { background: var(--blue-dot); }
.dot-gray { background: var(--gray-dot); }

.stat-line { display: flex; align-items: baseline; gap: 3px; }

.stat-num {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-unit { font-size: 12px; color: var(--text-2); font-style: normal; }

/* ==================== 列表 ==================== */

.list { display: flex; flex-direction: column; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child { border-bottom: 0; }

.lr-left { flex: 1; min-width: 0; cursor: pointer; }

.lr-cat { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.lr-tag { font-style: normal; font-size: 11px; font-weight: 500; color: var(--text-2); background: #F2F3F5; border-radius: var(--r-pill); padding: 1px 8px; }

.lr-meta {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lr-right { display: flex; align-items: center; gap: 4px; flex: none; }

.lr-amt {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex: none;
}

.amt-in { color: var(--green); }
.amt-out { color: var(--accent); }

.row-del {
  border: 0;
  background: none;
  font-size: 14px;
  color: var(--gray-dot);
  padding: 6px;
  cursor: pointer;
}

.row-del:active { color: var(--accent); }

/* ==================== 筛选 chips ==================== */

.filter-card { padding: 12px 16px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-row + .chip-row { margin-top: 8px; }

.chip {
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: #FAFAFC;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  max-width: 100%;
}

.chip:focus { outline: none; border-color: var(--accent); }
.chip:disabled { opacity: .45; }
.chip-btn:disabled { opacity: .45; }
.chip-btn:not(:disabled) { cursor: pointer; opacity: 1; }

.chip-grow { flex: 1; min-width: 120px; font-size: 16px; }

.chip-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:active { background: var(--accent-dark); }

/* ==================== 分页 ==================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0 2px;
}

.pagination .chip { cursor: pointer; }
.page-info { font-size: 12px; color: var(--text-2); }

/* ==================== 图表 ==================== */

.chart-card { padding: 12px; }
.chart-card canvas { max-height: 240px; }

/* ==================== 预算 ==================== */

.budget-list { display: flex; flex-direction: column; }

.budget-item { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.budget-item:active { background: rgba(0,0,0,.03); }
.budget-item:last-child { border-bottom: 0; }

.bc-head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.bc-pct { font-weight: 700; font-variant-numeric: tabular-nums; }

.bc-bar-bg { height: 8px; border-radius: var(--r-pill); background: #F0F1F3; overflow: hidden; }

.bc-bar { height: 100%; border-radius: var(--r-pill); background: var(--green-dot); transition: width .4s var(--ease); }

.status-warn .bc-pct { color: var(--orange); }
.status-warn .bc-bar { background: #FFAB00; }
.status-over .bc-pct { color: var(--accent); }
.status-over .bc-bar { background: var(--accent); }

.bc-detail { font-size: 12px; color: var(--text-2); margin-top: 6px; }

/* ==================== 状态标签 ==================== */

.pill { font-style: normal; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: var(--r-pill); }
.tag-pending { background: var(--accent-soft); color: var(--accent); }
.tag-paid { background: #E8F7F0; color: var(--green); }
.tag-archived { background: #F2F3F5; color: var(--text-2); }

/* ==================== 悬浮按钮 / 底部 Tab ==================== */

.fab {
  position: fixed;
  right: max(20px, calc(50vw - 300px));
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  cursor: pointer;
  z-index: 35;
  transition: transform .2s var(--ease);
}

.fab:active { transform: scale(.9); }

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 640px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
}

.tab-icon { font-size: 20px; filter: grayscale(1); opacity: .5; transition: transform .2s var(--ease), opacity .2s; }
.tab-label { font-weight: 500; }

.tab.active { color: var(--accent); }
.tab.active .tab-icon { filter: none; opacity: 1; transform: translateY(-1px); }
.tab.active .tab-label { font-weight: 700; }

/* ==================== 底部弹层 ==================== */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .2s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 86vh;
  overflow: auto;
  animation: slideUp .28s var(--ease);
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: .6; }
  to { transform: none; opacity: 1; }
}

.sheet h3 { margin: 0 0 16px; font-size: 17px; font-weight: 700; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.field { display: block; margin-bottom: 12px; }

.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-comp);
  padding: 0 12px;
  font-size: 15px;
  background: #FAFAFC;
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}

/* 防止移动端日期控件缩放 */
.field input[type="date"] {
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
}

.field input:focus,
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(230, 0, 68, .1); }

.sheet-actions { display: flex; gap: 12px; margin-top: 16px; }

.btn {
  flex: 1;
  height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s var(--ease);
}

.btn:active { transform: scale(.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-ghost { background: #F2F3F5; color: var(--text-2); }
.btn-danger { background: var(--accent); color: #fff; }

.confirm-text { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.confirm-sub { font-size: 13px; color: var(--text-2); margin: 0; }

/* ==================== 账号密码登录 + 计划历史（2026-09-10） ==================== */
.login-alt { margin: 14px 0 0; font-size: 12px; text-align: center; }
.login-alt a { color: var(--text-2); text-decoration: none; }
.seg { display: flex; flex: 1; background: #F2F3F5; border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg-btn { flex: 1; border: 0; background: transparent; padding: 7px 12px; border-radius: var(--r-pill); font-size: 13px; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.seg-btn.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.tag-auto { background: #E8F7F0; color: var(--green); }
.tag-manual { background: #FFF6E5; color: var(--orange); }
.tag-backfill { background: #F2F3F5; color: var(--text-2); }
.empty-tip { text-align: center; color: var(--text-2); font-size: 13px; padding: 24px 0; }
.debt-tap-row:active { opacity: 0.6; }

/* 明细页辅助 */
.empty-hint { padding: 16px; color: #666; text-align: center; font-size: 13px; }
.detail-section-head { border-bottom: 1px solid #333; }
.detail-sub-row { background: none; }
.detail-sub-row:hover { background: rgba(255,255,255,.03); }

/* 下拉刷新 */
.pull-indicator {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: opacity .2s;
  color: #888; font-size: 13px;
}
.pull-icon { font-size: 20px; }
.pull-icon.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* 计划弹窗：模式切换按钮组 */
.seg-row { display: flex; gap: 0; border-radius: var(--r-pill); overflow: hidden; border: 1px solid var(--line); }
.seg-btn { flex: 1; padding: 8px 0; text-align: center; font-size: 13px; border: none; background: #FAFAFC; color: var(--text-soft); cursor: pointer; transition: all .15s; }
.seg-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }

/* 开关行 */
.toggle-row { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* 概览页滑动翻页 */
.quick-slider { overflow: hidden; }
.quick-dots { display: flex; justify-content: center; gap: 6px; padding: 8px 0 0; }
.slide-dot { width: 6px; height: 6px; border-radius: 50%; background: #ddd; cursor: pointer; transition: background .2s; }

.quick-pages { display: flex; transition: transform .25s ease; }
.quick-page { flex: 0 0 100%; width: 100%; }
.slide-dot.active { background: var(--accent); width: 18px; border-radius: 3px; }

/* 底部导航栏 */
.btm-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-around;
  padding: 4px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
  box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
}
.btm-nav button {
  flex: 1;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 12px;
  padding: 4px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color .2s;
}
.btm-nav button.active {
  color: var(--accent, #e11d48);
  font-weight: 600;
}

/* 底部导航栏 */
.btm-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-around;
  padding: 4px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
  box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
}
.btm-nav button {
  flex: 1;
  border: none;
  background: none;
  color: #9ca3af;
  font-size: 12px;
  padding: 6px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color .2s;
}
.btm-nav button.active {
  color: var(--accent, #e11d48);
  font-weight: 600;
}

/* 计划账单页面确认按钮 */
.row-confirm {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.row-confirm:active { background: var(--accent); color: #fff; }
.confirm-result {
  background: var(--bg-2, #f7f7f8);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 40vh;
  overflow-y: auto;
  margin: 8px 0 12px;
  text-align: left;
}

/* 编辑弹窗标题行：右上角文字删除按钮 */
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet-head h3 { margin: 0; }
.sheet-del-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  padding: 4px 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.sheet-del-link:active { opacity: .6; }
