/* ============================================================
   钱多多记账 · 全端响应式样式
   黄色多层主题：主 #FFC107 / 深 #F9A825 / 亮 #FFD54F
                奶油底 #FFF8E1 / 焦黄 #EF8B00
                文字深棕 #3E2723 / 支出 #D84315 / 收入 #558B2F
   ============================================================ */

:root {
  --y-main: #FFC107;
  --y-deep: #F9A825;
  --y-light: #FFD54F;
  --y-cream: #FFF8E1;
  --y-cream-2: #FFFDE7;
  --y-amber: #EF8B00;
  --y-brown: #3E2723;
  --text-main: #3E2723;
  --text-sub: #795548;
  --text-light: #A1887F;
  --expense: #D84315;
  --income: #558B2F;
  --line: #F0E4C8;
  --white: #fff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 10px rgba(243, 188, 36, .18);
  --shadow-lg: 0 8px 30px rgba(243, 188, 36, .28);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text-main);
  background: var(--y-cream);
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }
a { color: var(--y-amber); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text-main); }
.hidden { display: none !important; }

/* ---------------- 通用按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: 42px; padding: 0 18px;
  border-radius: 999px; font-size: 15px; font-weight: 600;
  transition: transform .12s, box-shadow .2s, background .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: linear-gradient(135deg, var(--y-main), var(--y-amber)); color: var(--y-brown); box-shadow: 0 4px 14px rgba(239, 139, 0, .3); }
.btn-ghost { background: var(--y-cream); color: var(--text-sub); border: 1px solid var(--line); }
.btn-outline { background: #fff; border: 1.5px solid var(--y-deep); color: var(--y-amber); }
.btn-danger { background: #fff; border: 1.5px solid var(--expense); color: var(--expense); }
.btn-lg { height: 48px; width: 100%; font-size: 16px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 12px; }
.link-btn { color: var(--y-amber); font-size: 14px; padding: 4px; }
.link { color: var(--y-amber); }

/* ---------------- 登录/注册 ---------------- */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px;
  background:
    radial-gradient(circle at 12% 8%, #FFE082 0%, transparent 42%),
    radial-gradient(circle at 88% 92%, #FFCC80 0%, transparent 42%),
    linear-gradient(160deg, #FFF8E1 0%, #FFFDE7 45%, #FFF3CD 100%);
}
.auth-box {
  width: 100%; max-width: 420px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  padding: 30px 24px 26px;
  box-shadow: var(--shadow-lg);
  border: 1px solid #FFE9A8;
}
.brand { text-align: center; margin-bottom: 18px; }
.brand-logo {
  width: 66px; height: 66px; margin: 0 auto 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6B3B10, #2A1403);
  border-radius: 20px;
  box-shadow: 0 8px 22px rgba(122,58,10,.32);
  transform: rotate(-6deg); overflow: hidden;
}
.brand-logo img { width: 44px; height: 44px; display: block; }
.brand h1 { font-size: 24px; margin: 6px 0 4px; letter-spacing: 1px; }
.brand-slogan { color: var(--text-sub); font-size: 13px; margin: 0; }

.seg {
  display: flex; background: var(--y-cream); border-radius: 999px;
  padding: 4px; margin: 0 0 18px; border: 1px solid var(--line);
}
.seg-btn {
  flex: 1; height: 36px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--text-sub); transition: all .2s;
}
.seg-btn.active { background: var(--y-main); color: var(--y-brown); box-shadow: 0 2px 8px rgba(239,139,0,.25); }
.seg-sm { margin: 0; padding: 3px; }
.seg-sm .seg-btn { height: 30px; font-size: 12px; padding: 0 10px; flex: none; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-sub); font-weight: 500; }
.field input {
  height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #FFFDF5;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--y-main); box-shadow: 0 0 0 3px rgba(255,193,7,.22); background: #fff; }
.tip { font-size: 12px; color: var(--text-light); text-align: center; margin: 4px 0 0; line-height: 1.6; }

/* ---------------- 应用外壳 ---------------- */
.app-shell {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #FFF4CE 0%, var(--y-cream) 220px, #FFFDF5 100%);
  padding-bottom: calc(64px + var(--safe-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px;
  background: linear-gradient(135deg, #FFD54F 0%, #FFC107 55%, #FFB300 100%);
  box-shadow: 0 3px 14px rgba(239,139,0,.22);
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { font-size: 17px; font-weight: 800; color: var(--y-brown); letter-spacing: .5px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.greet { font-size: 12px; color: #6D4C41; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  background: #fff; color: var(--y-amber); box-shadow: 0 2px 8px rgba(109,76,65,.15);
  flex: none;
}
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }

.book-picker { position: relative; }
.book-picker-btn {
  display: flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 10px; border-radius: 999px;
  background: rgba(255,255,255,.85); font-size: 13px; font-weight: 600; color: var(--y-brown);
  max-width: 180px; box-shadow: 0 1px 6px rgba(109,76,65,.12);
}
.book-picker-btn > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-menu {
  position: absolute; top: 40px; left: 0; min-width: 246px; max-width: calc(100vw - 28px); z-index: 40;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(62,39,35,.16);
  padding: 6px; border: 1px solid var(--line);
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.book-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; border-radius: 10px; font-size: 14px; text-align: left;
}
.book-menu-item:active { background: var(--y-cream); }
.book-menu-item.active { background: var(--y-cream); font-weight: 700; }
.book-menu-item { white-space: nowrap; }
.book-menu-item > span:nth-child(2) {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-menu-item small { color: var(--text-light); font-size: 11px; margin-left: auto; flex: none; }
.bk-dft { flex: none; white-space: nowrap; }

/* ---------------- 主体 ---------------- */
.main {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 14px 14px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: #fff; border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #FFF3D0;
}
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }

/* ---------------- 汇总卡片 ---------------- */
.summary-wrap {
  background: linear-gradient(150deg, #FFE082 0%, #FFD54F 40%, #FFC107 100%);
  border-radius: 18px; padding: 14px 14px 16px;
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.summary-wrap::after {
  content: ""; position: absolute; right: -40px; top: -50px;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,.28);
}
.summary-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; position: relative; z-index: 1; }
.summary-head h2 { margin: 0; font-size: 15px; font-weight: 800; color: var(--y-brown); }
.summary-hint { font-size: 11px; color: #7C5A1E; }
.summary-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px;
  position: relative; z-index: 1;
}
.sum-card {
  background: rgba(255,255,255,.82);
  border-radius: 12px; padding: 10px 11px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.9);
}
.sum-card:first-child { grid-column: 1 / -1; background: #fff; }
.sum-card .sum-label { font-size: 11px; color: var(--text-sub); display: flex; justify-content: space-between; }
.sum-card .sum-expense { font-size: 19px; font-weight: 800; color: var(--expense); line-height: 1.25; margin-top: 3px; }
.sum-card:first-child .sum-expense { font-size: 24px; }
.sum-card .sum-expense small { font-size: 11px; font-weight: 500; opacity: .75; }
.sum-card .sum-income { font-size: 11.5px; color: var(--income); margin-top: 2px; font-weight: 600; }
.sum-card .sum-count { font-size: 10.5px; color: var(--text-light); }

/* ---------------- 记账输入 ---------------- */
.record-head { display: flex; justify-content: space-between; align-items: center; }
.record-head h3 { margin: 0; }
.record-input-wrap { position: relative; display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.record-input-wrap textarea {
  flex: 1; min-height: 74px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--y-cream-2);
  resize: none; outline: none; line-height: 1.5; font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.record-input-wrap textarea:focus { border-color: var(--y-main); background: #fff; box-shadow: 0 0 0 3px rgba(255,193,7,.2); }
.mic-btn {
  width: 52px; height: 52px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--y-light), var(--y-deep));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(239,139,0,.35);
  position: relative; transition: transform .15s, box-shadow .2s;
  user-select: none; touch-action: none;
}
.mic-btn:active, .mic-btn.recording { transform: scale(1.08); background: linear-gradient(135deg, #FF8A65, #D84315); box-shadow: 0 0 0 6px rgba(216,67,21,.18); }
.mic-btn.recording::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(216,67,21,.45); animation: pulse 1.2s infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: .8 } 100% { transform: scale(1.35); opacity: 0 } }
.mic-hint {
  position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%);
  background: rgba(62,39,35,.9); color: #fff; font-size: 11px;
  padding: 4px 9px; border-radius: 8px; white-space: nowrap; opacity: 0;
  pointer-events: none; transition: opacity .2s;
}
.mic-hint.show { opacity: 1; }

.record-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.quick-chips { display: flex; gap: 7px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.quick-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--y-cream); color: var(--text-sub); font-size: 12.5px;
  border: 1px solid var(--line);
}
.chip:active { background: var(--y-light); }

/* ---------------- 解析结果 ---------------- */
.parse-head { display: flex; justify-content: space-between; align-items: baseline; }
.parse-head h3 { margin: 0; }
.parse-count { font-size: 12px; color: var(--text-light); }
.parse-item {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; margin-top: 10px; background: var(--y-cream-2);
}
.parse-item .pi-top { display: flex; align-items: center; gap: 8px; }
.parse-item .pi-new-cat {
  font-size: 11px; line-height: 1; padding: 4px 6px; border-radius: 6px;
  color: #a15c00; background: #fff2d9; border: 1px solid #ffd591; white-space: nowrap;
}
.pi-type {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700;
}
.pi-type.expense { background: #FDE4DC; color: var(--expense); }
.pi-type.income { background: #E8F1DF; color: var(--income); }
.pi-amount { font-size: 20px; font-weight: 800; margin-left: auto; }
.pi-amount input {
  width: 92px; text-align: right; font-size: 20px; font-weight: 800;
  border: none; background: transparent; outline: none; border-bottom: 1px dashed var(--y-deep);
}
.pi-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 10px; }
.pi-fields label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-light); min-width: 0; overflow: hidden; }
.pi-fields input, .pi-fields select {
  height: 34px; border-radius: 8px; border: 1px solid var(--line);
  padding: 0 8px; background: #fff; font-size: 13px; outline: none;
  width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
  text-overflow: ellipsis;
}
/* 时间输入在某些系统上有固有最小宽度，窄屏下独占一行避免撑破卡片 */
.pi-fields .pi-wide { grid-column: 1 / -1; }
.pi-meta { font-size: 11px; color: var(--text-light); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }
.parse-warn { font-size: 12px; color: var(--y-amber); margin-top: 8px; line-height: 1.5; }
.parse-foot { display: flex; gap: 10px; margin-top: 14px; }
.parse-foot .btn { flex: 1; }

/* ---------------- 列表 ---------------- */
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.list-head h3 { margin: 0; }
.record-list { display: flex; flex-direction: column; }
.day-group { margin-top: 8px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 2px; font-size: 12px; color: var(--text-light);
  border-bottom: 1px dashed var(--line); margin-bottom: 4px;
}
.day-head b { color: var(--text-sub); font-size: 12.5px; }
.rec-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid #FDF6E3;
}
.rec-row:active { background: var(--y-cream-2); }
.rec-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--y-cream);
}
.rec-main { flex: 1; min-width: 0; }
.rec-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-sub { font-size: 11px; color: var(--text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-amt { font-size: 16px; font-weight: 800; flex: none; }
.rec-amt.expense { color: var(--expense); }
.rec-amt.income { color: var(--income); }
.empty { text-align: center; color: var(--text-light); font-size: 13px; padding: 30px 0; }
.empty .empty-emoji { font-size: 40px; display: block; margin-bottom: 8px; opacity: .6; }

.list-sum {
  display: flex; gap: 14px; font-size: 12.5px; color: var(--text-sub);
  background: var(--y-cream-2); border-radius: 10px; padding: 8px 12px; margin: 10px 0 4px;
  flex-wrap: wrap;
}
.list-sum b.expense { color: var(--expense); }
.list-sum b.income { color: var(--income); }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--text-sub); }

/* ---------------- 筛选 ---------------- */
.filter-bar { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-sep { font-size: 12px; color: var(--text-light); flex: none; }
.input {
  height: 38px; border-radius: 10px; border: 1.5px solid var(--line);
  padding: 0 10px; background: var(--y-cream-2); outline: none; font-size: 14px;
  min-width: 0; flex: 1;
}
.input:focus { border-color: var(--y-main); background: #fff; }
.input-sm { height: 32px; font-size: 13px; flex: none; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-sub); }

/* ---------------- 报表 ---------------- */
.report-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.report-head h3 { margin: 0; }
.chart-box { position: relative; width: 100%; overflow: hidden; }
.chart-box canvas { width: 100%; display: block; }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: var(--text-sub); margin-top: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot-income { background: var(--income); }
.dot-expense { background: var(--expense); }

.cat-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cat-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.cat-bar-wrap { flex: 1; height: 8px; background: var(--y-cream); border-radius: 4px; overflow: hidden; }
.cat-bar { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--y-light), var(--y-amber)); }
.cat-bar.income { background: linear-gradient(90deg, #9CCC65, var(--income)); }
.cat-name { width: 76px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-sub); }
.cat-val { width: 84px; text-align: right; flex: none; font-weight: 600; }

.export-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.export-tile {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 6px; border-radius: 12px; background: var(--y-cream);
  border: 1.5px solid var(--line); transition: all .2s;
}
.export-tile:active { background: var(--y-light); border-color: var(--y-deep); }
.export-tile b { font-size: 14px; color: var(--y-brown); }
.export-tile small { font-size: 10.5px; color: var(--text-light); text-align: center; }
.export-range { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.backup-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.backup-actions .btn { flex: 1; min-width: 140px; }
.import-box { margin-top: 10px; }
.import-result { font-size: 12.5px; color: var(--text-sub); margin-top: 10px; line-height: 1.6; }
.import-result.err { color: var(--expense); }
.import-result.ok { color: var(--income); }

/* ---------------- 账本 ---------------- */
.book-list { display: flex; flex-direction: column; gap: 10px; }
.book-card {
  display: flex; align-items: center; gap: 12px;
  padding: 13px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--y-cream-2);
}
.book-card.active { border-color: var(--y-main); background: var(--y-cream); }
.book-emoji { font-size: 22px; flex: none; width: 36px; height: 36px; display: grid; place-items: center; background: #fff; border-radius: 10px; }
.book-info { flex: 1; min-width: 0; }
.book-info strong { font-size: 15px; display: block; }
.book-info small { font-size: 11.5px; color: var(--text-light); }
.book-ops { display: flex; gap: 5px; flex: none; align-items: center; }
.book-info small { line-height: 1.5; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fff; border: 1px solid var(--line); font-size: 13px; }

/* ---------------- 我的 ---------------- */
.profile-card { display: flex; align-items: center; gap: 14px; position: relative; cursor: pointer; }
.me-profile.menu-open { box-shadow: 0 10px 26px rgba(255, 183, 0, .24); }
.me-caret { font-size: 12px; color: var(--text-light); margin-left: auto; flex: none; transition: transform .2s; }
.me-profile.menu-open .me-caret { transform: rotate(180deg); }
.me-menu {
  position: absolute; right: 10px; top: calc(100% - 2px); z-index: 60;
  min-width: 210px; max-width: calc(100vw - 44px);
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 34px rgba(93, 64, 28, .18); padding: 6px;
  text-align: left; cursor: default;
  animation: meMenuIn .16s ease-out;
}
@keyframes meMenuIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.me-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px; border: none; background: transparent; border-radius: 10px;
  font-family: inherit; font-size: 14px; color: var(--text-main);
  text-align: left; cursor: pointer;
}
.me-menu-item i { width: 20px; text-align: center; font-style: normal; font-size: 13px; color: var(--text-light); flex: none; }
.me-menu-item span { flex: 1; min-width: 0; }
.me-menu-item em { display: block; font-style: normal; font-size: 11.5px; color: var(--text-light); margin-top: 2px; line-height: 1.4; }
.me-menu-item:active { background: #FFF6DF; }
.me-menu-item.danger { color: #D84315; }
.me-menu-item.danger i { color: #D84315; }
.about-list .me-row { border-bottom: 1px solid #FDF6E3; }
.about-list .link-btn { padding: 2px 4px; }
.profile-info { flex: 1; min-width: 0; }
.profile-info strong { font-size: 17px; display: block; }
.profile-info small { font-size: 12px; color: var(--text-light); }
.me-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #FDF6E3; font-size: 14px; color: var(--text-sub);
}
.me-row:last-of-type { border-bottom: none; }
.me-row b { color: var(--text-main); font-weight: 600; font-size: 13.5px; }
.update-box { margin-top: 10px; font-size: 13px; color: var(--text-sub); line-height: 1.7; }
.update-box .up-ver { font-weight: 700; color: var(--y-amber); }
.update-box a { display: inline-block; margin-top: 8px; padding: 8px 16px; border-radius: 999px; background: var(--y-main); color: var(--y-brown); font-weight: 700; }

.footer-beian {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 0 4px; font-size: 11.5px; color: var(--text-light);
}
.footer-beian a { color: var(--text-light); }
.footer-beian .gongan { display: inline-flex; align-items: center; gap: 5px; }
.footer-beian img { display: block; }

/* ---------------- 底部 tab ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid #FFE9A8;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -3px 16px rgba(243,188,36,.16);
}
.tab {
  flex: 1; height: 54px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; color: var(--text-light); transition: color .2s;
}
.tab svg { width: 21px; height: 21px; fill: var(--text-light); transition: fill .2s, transform .2s; }
.tab.active { color: var(--y-amber); font-weight: 700; }
.tab.active svg { fill: var(--y-amber); transform: translateY(-1px); }

/* ---------------- 弹层 / 提示 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(62,39,35,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 560px;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: none } }
.sheet h3 { margin: 0 0 14px; font-size: 17px; }
.sheet .field { margin-bottom: 12px; }
.sheet-foot { display: flex; gap: 10px; margin-top: 16px; }
.sheet-foot .btn { flex: 1; }
.chip-select { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-select button {
  height: 32px; padding: 0 13px; border-radius: 999px; font-size: 13px;
  background: var(--y-cream); border: 1.5px solid var(--line); color: var(--text-sub);
}
.chip-select button.active { background: var(--y-main); border-color: var(--y-deep); color: var(--y-brown); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(62,39,35,.92); color: #fff; font-size: 13.5px;
  padding: 10px 18px; border-radius: 999px; z-index: 200;
  max-width: 84vw; text-align: center; line-height: 1.4;
  animation: toastIn .24s ease-out;
  box-shadow: 0 6px 20px rgba(62,39,35,.3);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px) } to { opacity: 1; transform: translate(-50%, 0) } }
.toast.err { background: rgba(216,67,21,.95); }
.toast.ok { background: rgba(85,139,47,.95); }

/* ============================================================
   响应式断点
   ============================================================ */
@media (min-width: 481px) {
  .summary-cards { grid-template-columns: repeat(4, 1fr); }
  .sum-card:first-child { grid-column: span 2; }
  .pi-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pi-fields .pi-wide { grid-column: auto; }
}

@media (min-width: 768px) {
  .main { max-width: 1120px; padding: 18px 20px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; align-content: start; }
  .view { display: contents; }
  .summary-wrap { grid-column: 1 / -1; }
  .summary-cards { grid-template-columns: repeat(5, 1fr); }
  .sum-card:first-child { grid-column: auto; }
  .record-card { grid-column: 1 / 2; }
  #parse-panel { grid-column: 1 / 2; }
  .record-list { max-height: none; }
  /* 桌面端：底部导航改为悬浮胶囊 */
  .tabbar {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px;
    width: auto; max-width: none; margin: 0; padding: 6px; gap: 2px;
    border: 1px solid #FFE9A8; border-radius: 999px;
    box-shadow: 0 10px 28px rgba(243,188,36,.3);
  }
  .tab { flex: 0 0 auto; flex-direction: row; height: 44px; padding: 0 20px; gap: 7px; border-radius: 999px; font-size: 13.5px; }
  .tab svg { width: 19px; height: 19px; }
  .tab.active { background: linear-gradient(135deg, #FFE082, #FFC107); }
  .app-shell { padding-bottom: 104px; }
  .auth-box { max-width: 460px; padding: 36px 32px 30px; }
  /* 账单页与「我的」页在宽屏占满整行，避免只挤在左半列 */
  #view-bills > .card { grid-column: 1 / -1; }
  #view-me .profile-card { grid-column: 1 / -1; }
  #view-me .footer-beian { grid-column: 1 / -1; }
  #view-me > .card:last-of-type { grid-column: 1 / -1; }
}

@media (min-width: 1180px) {
  .main { max-width: 1280px; grid-template-columns: 1.15fr .85fr; }
  .summary-cards { grid-template-columns: repeat(5, 1fr); }
  .topbar { padding-left: max(24px, calc((100vw - 1280px) / 2 + 6px)); padding-right: max(24px, calc((100vw - 1280px) / 2 + 6px)); }
}

/* 极窄屏（360px）微调 */
@media (max-width: 359px) {
  .topbar-title { display: none; }
  .sum-card .sum-expense { font-size: 17px; }
  .card { padding: 13px; }
}

/* 桌面端悬停反馈 */
@media (hover: hover) {
  .rec-row:hover { background: var(--y-cream-2); }
  .btn:hover { filter: brightness(1.04); }
  .export-tile:hover { border-color: var(--y-deep); }
  .book-menu-item:hover { background: var(--y-cream); }
}

/* 我的页：行内小按钮 */
.link-btn {
  border: none; background: none; color: var(--y-amber); font-size: 12.5px;
  font-weight: 600; padding: 4px 0 4px 8px; cursor: pointer;
}
.link-btn:active { opacity: .7; }

/* 更新下载进度条 */
.up-progress {
  height: 8px; border-radius: 999px; background: var(--y-cream-2);
  overflow: hidden; margin-top: 8px;
}
.up-progress i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--y-main), var(--y-amber)); transition: width .2s; }

/* ---------------- 账号安全（注销账号） ---------------- */
.me-note {
  font-size: 12.5px; line-height: 1.75; color: var(--text-light);
  margin: 0 0 12px;
}
.me-note b { color: var(--text); }
.del-check {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 2px; font-size: 13px; line-height: 1.5; color: var(--text-sub);
}
.del-check input { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--y-amber); }
.btn-danger:disabled { opacity: .5; }

/* 记账音效开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: #E7DCC2; transition: background .2s; }
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .2s;
}
.switch input:checked + i { background: linear-gradient(135deg, var(--y-main), var(--y-amber)); }
.switch input:checked + i::after { transform: translateX(20px); }

/* ============================================================
   版本更新弹窗
   ============================================================ */
.qdd-mask {
  position: fixed; inset: 0; z-index: 320;
  background: rgba(62,39,35,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; opacity: 0;
  transition: opacity .18s ease;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.qdd-mask.show { opacity: 1; }
.qdd-dlg {
  width: 100%; max-width: 380px; background: #fff;
  border-radius: 18px; padding: 22px 20px 18px;
  box-shadow: 0 18px 50px rgba(62,39,35,.3);
  text-align: center;
  transform: translateY(12px) scale(.96);
  transition: transform .22s cubic-bezier(.2,.8,.3,1);
}
.qdd-mask.show .qdd-dlg { transform: none; }
.qdd-dlg-mark { display: flex; justify-content: center; margin-bottom: 8px; }
.qdd-dlg h3 { margin: 0 0 6px; font-size: 18px; color: var(--text-main); }
.qdd-dlg-sub { font-size: 13px; color: var(--text-sub); }
.qdd-dlg-sub b { color: var(--y-amber); }
.qdd-dlg-note {
  margin: 12px 0 0; font-size: 13px; line-height: 1.65; color: var(--text-sub);
  text-align: left; background: var(--y-cream); border-radius: 10px;
  padding: 10px 12px; max-height: min(38vh, 240px); overflow-y: auto; white-space: pre-wrap;
  word-break: break-word;
}
.qdd-dlg-bar { height: 6px; border-radius: 999px; background: var(--y-cream); margin-top: 12px; overflow: hidden; }
.qdd-dlg-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--y-light), var(--y-amber));
  transition: width .25s ease;
}
.qdd-dlg-tip { font-size: 12.5px; color: var(--text-light); margin-top: 8px; text-align: left; line-height: 1.5; }
.qdd-dlg-foot { display: flex; gap: 10px; margin-top: 16px; }
.qdd-dlg-foot .btn { flex: 1; height: 44px; }
.qdd-dlg-foot .btn-primary:disabled { opacity: .75; }

@media (max-width: 359px) {
  .qdd-dlg { padding: 18px 15px 15px; }
  .qdd-dlg-note { max-height: 116px; }
}

/* ============================================================
   账本管理（默认账本 / 下拉操作区）
   ============================================================ */
.book-note {
  margin: 2px 0 12px; font-size: 12px; line-height: 1.6; color: var(--text-light);
  background: var(--y-cream); border-radius: 10px; padding: 8px 10px;
}
.book-tip { margin-top: 12px; font-size: 11.5px; color: var(--text-light); line-height: 1.6; }
.bk-tag {
  font-size: 10.5px; font-weight: 600; color: var(--y-amber);
  background: #FFF3D6; border-radius: 6px; padding: 1px 5px; margin-left: 4px;
  vertical-align: middle;
}
.bk-cur { font-size: 11px; color: var(--text-light); white-space: nowrap; }
.bk-dft {
  font-style: normal; font-size: 10.5px; color: var(--y-amber);
  background: #FFF3D6; border-radius: 6px; padding: 1px 5px; margin-left: 6px;
}
.book-menu-actions {
  display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); margin-top: 2px;
}
.book-menu-act {
  flex: 1; height: 34px; border-radius: 9px; font-size: 12.5px; white-space: nowrap; padding: 0 4px;
  background: var(--y-cream); border: 1px solid var(--line); color: var(--text-sub);
}
.book-menu-act:first-child { background: linear-gradient(135deg, var(--y-main), var(--y-amber)); color: var(--y-brown); border-color: var(--y-deep); font-weight: 600; }
.book-menu-act:active { transform: scale(.97); }

@media (max-width: 419px) {
  .book-card { gap: 9px; padding: 11px 10px; flex-wrap: wrap; }
  .book-info { flex: 1 1 calc(100% - 46px); }
  .book-ops { flex: 1 1 100%; justify-content: flex-end; margin-top: 1px; }
  .book-ops .icon-btn { width: 28px; height: 28px; font-size: 12px; }
  .book-info strong { font-size: 14px; }
  .book-info small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ============================================================
   AI 财务助手
   ============================================================ */
.ai-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 6px; font-size: 10.5px; font-weight: 800; font-style: normal;
  letter-spacing: .3px; color: #8A4B00; vertical-align: 3px;
  background: linear-gradient(135deg, #FFE082, #FFC107);
}
.parse-count { display: inline-flex; align-items: center; gap: 6px; }
#parse-engine {
  display: none; font-style: normal; font-size: 10.5px; font-weight: 800;
  color: #8A4B00; background: #FFF3CD; border: 1px solid #FFE082;
  border-radius: 6px; padding: 1px 6px;
}
#parse-engine.on { display: inline-block; }

.ai-hero {
  background: linear-gradient(150deg, #FFE9A8 0%, #FFD54F 55%, #FFC107 100%);
  border: 1px solid #FFD54F;
}
.ai-hero-head { display: flex; align-items: center; gap: 10px; }
.ai-badge {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 900; letter-spacing: .5px;
  color: #fff; background: linear-gradient(135deg, #FF8F00, #EF6C00);
  box-shadow: 0 4px 12px rgba(239, 108, 0, .32);
}
.ai-hero-text { min-width: 0; }
.ai-hero-text h3 { margin: 0 0 3px; font-size: 16px; }
.ai-hero-text p { margin: 0; font-size: 12.5px; line-height: 1.5; color: #7A4B00; }

.ai-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.ai-quick button {
  height: 31px; padding: 0 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: #6D4C41;
  background: rgba(255, 255, 255, .92); border: 1px solid #FFE082;
  box-shadow: 0 1px 4px rgba(109, 76, 65, .08);
  transition: transform .15s, background .15s;
}
.ai-quick button:active { transform: scale(.97); background: #fff; }

.ai-chat-card { display: flex; flex-direction: column; }
.ai-log {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 132px; max-height: 44vh; overflow-y: auto;
  padding: 2px; scroll-behavior: smooth;
}
.ai-empty {
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 6px; text-align: center; color: var(--text-light);
}
.ai-empty b { font-size: 14px; color: var(--text-sub); }
.ai-empty span { font-size: 12.5px; line-height: 1.6; }

.ai-msg {
  max-width: 88%; padding: 10px 13px; border-radius: 14px;
  font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  animation: aiIn .18s ease-out;
}
@keyframes aiIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.ai-msg.user {
  align-self: flex-end; color: var(--y-brown);
  background: linear-gradient(135deg, #FFE082, #FFC107);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(239, 139, 0, .2);
}
.ai-msg.bot {
  align-self: flex-start; color: var(--text-main);
  background: #FFFDF5; border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.ai-msg.err { background: #FFF3EF; border-color: #FFCDBE; color: var(--expense); }
.ai-msg.typing { display: inline-flex; align-items: center; gap: 5px; color: var(--text-light); }
.ai-msg.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #F4B740;
  animation: aiDot 1s infinite ease-in-out;
}
.ai-msg.typing i:nth-child(2) { animation-delay: .18s; }
.ai-msg.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes aiDot {
  0%, 100% { opacity: .35; transform: translateY(0); }
  45% { opacity: 1; transform: translateY(-3px); }
}
.ai-facts {
  align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: -4px; max-width: 92%;
}
.ai-facts span {
  font-size: 11.5px; color: var(--text-sub);
  background: var(--y-cream); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 8px;
}

.ai-input-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
.ai-input-row textarea {
  flex: 1; min-width: 0; height: 44px; max-height: 96px; resize: none;
  padding: 11px 13px; line-height: 1.5;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: #FFFDF5; outline: none; transition: border-color .18s, box-shadow .18s;
}
.ai-input-row textarea:focus {
  border-color: var(--y-main); background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, .22);
}
.ai-send { height: 44px; width: 62px; flex: none; padding: 0; font-size: 15px; }
.ai-note { margin: 9px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--text-light); }

.ai-summary {
  font-size: 14px; line-height: 1.8; color: var(--text-sub);
  white-space: pre-wrap; word-break: break-word;
}
.ai-summary.loading { color: var(--text-light); }
.ai-sum-head { display: flex; align-items: baseline; justify-content: space-between; }

@media (min-width: 768px) {
  #view-ai .ai-hero { grid-column: 1 / 2; }
  #view-ai .ai-chat-card { grid-column: 1 / 2; }
  #view-ai .ai-sum-card { grid-column: 2 / 3; align-self: start; position: sticky; top: 84px; }
  .ai-log { max-height: 46vh; }
}
@media (min-width: 1180px) {
  #view-ai .ai-hero { grid-column: 1 / 2; }
  #view-ai .ai-chat-card { grid-column: 1 / 2; }
  #view-ai .ai-sum-card { grid-column: 2 / 3; }
}

/* AI 复核提示条（识别结果卡片内） */
.parse-tip {
  margin: 0 0 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fff6e5;
  border: 1px solid #ffe0a3;
  color: #a8620a;
  font-size: 13px;
  line-height: 1.5;
}
.parse-tip.warn { background: #fff1e0; border-color: #ffc78a; color: #a34a00; font-weight: 600; }
.parse-tip.hidden { display: none; }
