/* ========== 清新主题（默认） ========== */
body.theme-qingxin {
  /* 动森经典配色 */
  --primary: #19c8b9;        /* 薄荷绿主色 */
  --primary-dark: #14a99c;   /* 深薄荷绿（按下时） */
  --primary-light: #b8ece4;  /* 浅薄荷（背景装饰） */
  --accent: #ffb37c;         /* 暖橙（点缀） */
  --secondary: #92d3eb;      /* 天空蓝 */

  /* 中性色（奶油米色系） */
  --bg: #f5efe0;             /* 主背景：奶油米色 */
  --bg-soft: #faf6ea;        /* 卡片背景：暖象牙 */
  --card: #fffaf0;           /* 卡片底色：白米 */
  --border: #e0d4b8;         /* 暖灰边框 */
  --border-soft: #efe7d4;

  /* 文字 */
  --text: #574a3a;           /* 主文字：深棕 */
  --text-soft: #827157;      /* 次文字：中棕 */
  --muted: #a89878;          /* 弱化文字 */

  /* 状态 */
  --num: #2d8659;            /* 数字：森林绿 */
  --warn: #d96f5a;           /* 负数/警告：珊瑚红 */
  --ok: #19c8b9;

  /* 表格表头：单色系薄荷渐变（不再叠色，避免出现第三种颜色） */
  --th-head: linear-gradient(180deg, #e2f7f3 0%, #c9efe8 100%);
  --th-sticky: #d6f2ee;      /* 横向滚动时固定的首列表头（需不透明） */
  --row-hover: rgba(25, 200, 185, .10);

  /* 形状 */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* 描边层级：全站统一 1px 发丝线，替代原先的 3px 实心描边 */
  --stroke: 1px solid var(--border);
  --stroke-soft: 1px solid var(--border-soft);

  /* 间距层级 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* 层次（柔和 elevation，双层：贴地接触影 + 扩散影）
     替代原先的 0 4px 0 硬投影 —— 后者让按钮/页签/卡片层层叠加成一堆噪音 */
  --elev-1: 0 1px 2px rgba(120, 100, 60, .07);
  --elev-2: 0 1px 2px rgba(120, 100, 60, .05), 0 4px 10px rgba(120, 100, 60, .07);
  --elev-3: 0 2px 4px rgba(120, 100, 60, .05), 0 10px 24px rgba(120, 100, 60, .09);

  /* 主色投影：由 --primary 派生，跟随主题自动切换，
     修掉原先硬编码 rgba(25,200,185,·) 导致的薄荷绿泄漏到橘猫主题 */
  --elev-primary:      0 1px 2px color-mix(in srgb, var(--primary) 30%, transparent),
                       0 4px 12px color-mix(in srgb, var(--primary) 24%, transparent);
  --elev-primary-hover: 0 2px 4px color-mix(in srgb, var(--primary) 34%, transparent),
                        0 8px 20px color-mix(in srgb, var(--primary) 28%, transparent);
  --elev-primary-press: 0 1px 2px color-mix(in srgb, var(--primary) 26%, transparent);

  /* 兼容旧变量名，现已全部指向柔和层次 */
  --shadow: var(--elev-2);
  --shadow-press: var(--elev-1);
  --shadow-card: var(--elev-2);

  /* 字体 */
  --font: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  /* 背景斑纹颜色 */
  --badge-1: var(--primary-light);
  --badge-2: var(--secondary);
  --badge-3: var(--accent);
}

/* ========== 月薪喵主题 ========== */
body.theme-maojin {
  --primary: #ff9a76;        /* 橘粉主色（呼应橘猫） */
  --primary-dark: #e07a5f;   /* 深橘红 */
  --primary-light: #ffd6a5;  /* 浅橘黄（装饰） */
  --accent: #ff6b6b;         /* 鲜红（点缀） */
  --secondary: #ffcf8b;      /* 暖奶黄 */

  /* 中性色（浅奶油系） */
  --bg: #fff7ed;             /* 主背景：浅奶油 */
  --bg-soft: #fffaef;        /* 卡片背景 */
  --card: #ffffff;           /* 卡片底色：纯白 */
  --border: #f0e4d0;         /* 暖灰边框 */
  --border-soft: #faf0e0;

  /* 文字 */
  --text: #4a3f35;           /* 主文字：暖深棕 */
  --text-soft: #8a7e6b;      /* 次文字：中棕 */
  --muted: #b5a896;          /* 弱化文字 */

  /* 状态 */
  --num: #95c25a;            /* 收入绿：偏黄绿 */
  --warn: #ff6b6b;           /* 支出红：偏亮 */
  --ok: #ff9a76;

  /* 表格表头：单色系奶油橘渐变。
     原先 th 硬编码薄荷绿 rgba(184,236,228,.4) + thead 再叠 --primary-light 橘黄，
     半透明叠色后透出黄绿，与橘粉主题割裂；改为同色系深浅渐变。 */
  --th-head: linear-gradient(180deg, #ffe8d6 0%, #ffdcc0 100%);
  --th-sticky: #ffdcc0;      /* 横向滚动时固定的首列表头（需不透明） */
  --row-hover: rgba(255, 154, 118, .09);

  /* 形状（更圆） */
  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 28px;
  --r-pill: 999px;

  /* 描边层级：全站统一 1px 发丝线 */
  --stroke: 1px solid var(--border);
  --stroke-soft: 1px solid var(--border-soft);

  /* 间距层级 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  /* 层次（柔和 elevation，双层：贴地接触影 + 扩散影） */
  --elev-1: 0 1px 2px rgba(122, 92, 58, .06);
  --elev-2: 0 1px 2px rgba(122, 92, 58, .05), 0 4px 10px rgba(122, 92, 58, .07);
  --elev-3: 0 2px 4px rgba(122, 92, 58, .05), 0 10px 24px rgba(122, 92, 58, .09);

  /* 主色投影：由 --primary 派生，修掉薄荷绿硬编码泄漏 */
  --elev-primary:      0 1px 2px color-mix(in srgb, var(--primary) 32%, transparent),
                       0 4px 12px color-mix(in srgb, var(--primary) 26%, transparent);
  --elev-primary-hover: 0 2px 4px color-mix(in srgb, var(--primary) 36%, transparent),
                        0 8px 20px color-mix(in srgb, var(--primary) 30%, transparent);
  --elev-primary-press: 0 1px 2px color-mix(in srgb, var(--primary) 28%, transparent);

  /* 兼容旧变量名 */
  --shadow: var(--elev-2);
  --shadow-press: var(--elev-1);
  --shadow-card: var(--elev-2);

  /* 字体 */
  --font: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  --badge-1: var(--primary-light);
  --badge-2: var(--secondary);
  --badge-3: var(--primary);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
/* 永久预留滚动条位置：否则打开购物车抽屉时 body 变成 overflow:hidden，
   滚动条一消失整页宽度就变了，页头 flex 重排 → 右上角购物车按钮（连同角标）
   会横向挪动一下再跳回来，看着像"串位"。 */
html { scrollbar-gutter: stable; }

/* ========== 自定义背景层 ========== */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-image, none);
  background-size: var(--bg-size, cover);
  background-position: var(--bg-pos, center);
  background-repeat: var(--bg-repeat, no-repeat);
  filter: blur(var(--bg-blur, 0px));
  opacity: var(--bg-opacity, 0.3);
  transform: scale(var(--bg-scale, 1));
  pointer-events: none;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

/* 顶部装饰斑纹（清新：奶黄 + 蓝 / 月薪喵：橘黄 + 粉） */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, var(--badge-1) 0, transparent 8%),
    radial-gradient(circle at 88% 12%, var(--badge-2) 0, transparent 6%),
    radial-gradient(circle at 50% 92%, var(--badge-3) 0, transparent 5%);
  opacity: 0.6;
  transition: opacity 0.3s;
}

/* 自定义背景激活时，减弱顶部斑纹，避免冲突 */
body.theme-qingxin.has-custom-bg::before,
body.theme-maojin.has-custom-bg::before {
  opacity: 0.2;
}

/* ========== 顶部 ========== */
header {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: var(--stroke);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--elev-1);
}
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
button.secondary {
  background: var(--card);
  color: var(--primary-dark);
  border: var(--stroke);
  box-shadow: var(--elev-1);
}
button.secondary:hover { background: var(--primary-light); }
button.secondary:active { box-shadow: none; transform: translateY(1px); }
button.ghost {
  background: transparent;
  color: var(--primary-dark);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  box-shadow: none;
}
button.ghost:hover { background: var(--primary-light); }
button.danger {
  background: transparent;
  color: #b85a4a;
  border: 1px solid #e3bfb4;
  box-shadow: none;
}
button.danger:hover { background: #fbe6e0; border-color: #b85a4a; }

/* ========== 页头独立应用入口（口袋游戏厅） ========== */
/* 刻意不用 button 外观：它是「另一个应用」，不是记账页签，
   所以做成描边 + 独立配色 + 图标，和旁边录入类按钮区分开。 */
.header-app-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 11px;
  border: var(--stroke);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--primary-dark);
  font-family: var(--font);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--elev-1);
  transition: transform .1s, box-shadow .1s, background .15s;
}
.header-app-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: var(--elev-2);
}
.header-app-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}
.header-app-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.header-app-btn[hidden] { display: none; }
.gba-btn-icon { display: inline-flex; }
.gba-btn-icon svg { fill: var(--primary-dark); display: block; }
.gba-btn-icon svg .gba-btn-screen { fill: var(--card); }
.gba-btn-icon svg .gba-btn-btn { fill: var(--card); }
/* 有存档时的小圆点：暗示「上次没玩完」 */
.gba-btn-dot {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .15s, transform .15s;
}
.header-app-btn.has-save .gba-btn-dot { opacity: 1; transform: scale(1); }

header h1 {
  margin: 0;
  font-size: 20px;
  color: var(--primary-dark);
  font-weight: 700;
  letter-spacing: 1px;
}
header h1::before {
  content: '📒 ';
}

/* ========== 按钮 ========== */
button {
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  border: none;
  background: var(--card);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 8px 16px;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s, background .15s;
  box-shadow: var(--elev-1);
}
button:hover { background: var(--bg-soft); }
button:active {
  transform: translateY(1px);
  box-shadow: none;
}

button.primary, #btn-add {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--elev-primary);
}
button.primary:hover, #btn-add:hover { background: var(--primary-dark); box-shadow: var(--elev-primary-hover); }
button.primary:active, #btn-add:active {
  transform: translateY(1px);
  box-shadow: var(--elev-primary-press);
}

/* ========== 页签 ========== */
nav#tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  border-bottom: none;
  overflow-x: auto;
}
nav#tabs button {
  padding: 8px 18px;
  font-size: 14px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  background: var(--card);
  color: var(--text-soft);
  box-shadow: var(--elev-1);
}
nav#tabs button:hover { background: var(--bg-soft); }
nav#tabs button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--elev-primary);
}
nav#tabs button.active:active {
  transform: translateY(1px);
  box-shadow: var(--elev-primary-press);
}

main { padding: 12px 16px; }

.loading {
  color: var(--text-soft);
  text-align: center;
  padding: 40px;
  font-size: 15px;
}
.loading::before {
  content: '✨ ';
  animation: spin 2s linear infinite;
  display: inline-block;
}
/* 月薪喵主题加载中：换成表情包 */
body.theme-maojin #loading {
  padding: 32px 40px 24px;
}
body.theme-maojin #loading::before {
  content: '';
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
  background: var(--mj-loading-url, url('/static/themes/mj-all/001-月薪喵表情包.gif')) center/contain no-repeat;
  animation: none;
}

/* 月薪喵主题保存成功提示 */
.save-celebrate {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0 2px;
}
.save-celebrate img {
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
}
.save-celebrate .text {
  font-size: 14px;
  color: var(--primary, #ff9a76);
  font-weight: 700;
}
@keyframes spin {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

/* ========== 卡片（圆乎乎带阴影） ========== */
.card {
  background: var(--card);
  border: var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
  margin-bottom: 14px;
  overflow: hidden;
}
.card .title {
  padding: 10px 16px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  font-size: 15px;
  letter-spacing: .5px;
}
.card .title::before {
  content: attr(data-icon);
  margin-right: 4px;
}
.card .meta {
  padding: 8px 16px;
  color: var(--text-soft);
  font-size: 13px;
  background: var(--bg-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.card .meta .info { flex: 1; }

/* 展开按钮 */
.toggle-btn {
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  box-shadow: var(--elev-primary);
  transition: transform .1s, box-shadow .1s, background .15s;
}
.toggle-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--elev-primary-hover);
}
.toggle-btn:active { transform: translateY(1px); box-shadow: var(--elev-primary-press); }
.toggle-btn .arrow { display: inline-block; transition: transform .25s; margin-left: 4px; }
.toggle-btn.expanded .arrow { transform: rotate(180deg); }

/* ---------- C3 明细表触底自动加载 ---------- */
.load-sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 0 2px;
  font-size: 12px;
  color: var(--muted);
}
.load-more-btn {
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  box-shadow: var(--elev-primary);
  transition: transform .1s, box-shadow .1s, background .15s;
}
.load-more-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--elev-primary-hover);
}
.load-more-btn:active { transform: translateY(1px); box-shadow: var(--elev-primary-press); }
.load-more-btn[hidden] { display: none; }

th.highlight {
  color: var(--warn);
  background: var(--th-head);
}
td.highlight-num {
  color: var(--warn);
  font-weight: 700;
  background: rgba(217, 111, 90, 0.06);
}
/* 信用支付（花呗）账户余额：红色 + 加粗 */
td.num.credit {
  color: var(--warn);
  font-weight: 700;
  background: rgba(217, 111, 90, 0.08);
}

/* ========== 账户余额卡片网格 ========== */
.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 16px;
  background: var(--bg-soft);
}
.balance-tile {
  background: var(--card);
  border: var(--stroke);
  border-radius: var(--r-lg);
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--elev-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
}
.balance-tile:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--elev-primary-hover);
}
.balance-tile:active {
  transform: translateY(0);
  box-shadow: var(--elev-1);
}
.balance-tile .tile-name {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 600;
}
.balance-tile .tile-balance {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  color: var(--num);
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
  white-space: nowrap;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.balance-tile .tile-balance.neg {
  color: var(--warn);
}
.balance-tile .tile-type {
  font-size: 11px;
  color: var(--muted);
  background: var(--primary-light);
  padding: 2px 10px;
  border-radius: var(--r-pill);
}
.balance-tile.credit .tile-type {
  background: #ffd5cc;
  color: var(--warn);
}
.balance-tile.credit {
  border-color: #ffd5cc;
}

/* ========== B4 净资产总览（账户余额看板顶部） ========== */
.nw-panel {
  margin: 4px 0 14px;
  padding: 12px 14px 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
}
.nw-figs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
}
.nw-fig { display: flex; flex-direction: column; gap: 2px; min-width: 96px; }
.nw-label { font-size: 12px; color: var(--muted); }
.nw-num { font-size: 20px; font-weight: 800; color: var(--num); font-variant-numeric: tabular-nums; }
.nw-fig.neg .nw-num { color: var(--warn); }
.nw-bar {
  display: flex;
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(180, 160, 130, .18);
}
.nw-seg { height: 100%; min-width: 3px; }
.nw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  font-size: 12px;
}
.nw-li { display: inline-flex; align-items: center; gap: 5px; color: var(--text-soft); }
.nw-li i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.nw-li em { font-style: normal; font-weight: 600; color: var(--text); }
.nw-li b { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.nw-pct { color: var(--muted); }
.nw-note { margin-top: 9px; font-size: 12px; color: var(--muted); }
@media (max-width: 720px) {
  .nw-panel { margin: 2px 0 10px; padding: 10px 10px 11px; }
  /* 移动端三个数字等宽排一行，和上面的统计卡片形成同一套阅读节奏 */
  .nw-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .nw-fig { min-width: 0; align-items: center; text-align: center; }
  .nw-num { font-size: 15px; }
  .nw-label { font-size: 11px; }
  .nw-legend { gap: 4px 10px; font-size: 11px; }
  .nw-note { font-size: 11px; }
}

/* ========== 详情弹窗里的键值对网格 ========== */
.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 14px;
  margin: 10px 0;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: var(--r-md);
}
.detail-label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.detail-value {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}
.detail-value.neg {
  color: var(--warn);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ========== 常用速览-分类明细按钮 ========== */
.cat-detail-btn {
  background: var(--card);
  color: var(--primary-dark);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s cubic-bezier(.34, 1.2, .64, 1);
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.cat-detail-btn:hover {
  color: #fff;
  border-color: var(--primary-dark);
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary) 100%);
  transform: translateY(-2px);
  box-shadow: var(--elev-primary-hover);
}
.cat-detail-btn:active {
  transform: translateY(1px);
  background: var(--primary);
  box-shadow: var(--elev-primary-press);
}

/* ========== 分类明细弹窗内的小表 ========== */
.cat-detail-table {
  width: 100%;
  border-collapse: collapse;
  /* 固定列宽：配合 colgroup 的百分比，避免内容多寡把某列撑到挤掉其他列 */
  table-layout: fixed;
  margin-top: 10px;
  background: var(--card);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--elev-1);
}
.cat-detail-table th {
  background: var(--th-head);
  padding: 10px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
}
.cat-detail-table th.num { text-align: right; }
.cat-detail-table td {
  padding: 10px;
  border-bottom: var(--stroke-soft);
  font-size: 14px;
}
.cat-detail-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cat-detail-table td.num.neg { color: var(--warn); font-weight: 700; }
.cat-detail-table tfoot td {
  background: var(--bg-soft);
  border-bottom: none;
  font-size: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.cat-detail-table .muted { color: var(--muted); }

/* 子明细区 */
.cat-detail-expand {
  margin-top: 14px;
  padding-top: 14px;
  border-top: var(--stroke-soft);
}
.sub-table-wrap {
  max-height: 320px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border-soft);
  /* 给滚动条留出空间 */
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}
.sub-table-wrap::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}
.sub-table-wrap::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.sub-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
  background-clip: content-box;
}
.sub-table-wrap table {
  width: 100%;
  table-layout: fixed;   /* 与 .cat-detail-table 一致，列宽由 colgroup 决定 */
  word-break: break-word;
  white-space: normal;
}
.sub-table-wrap th, .sub-table-wrap td {
  white-space: normal;
  word-break: break-word;
}
.sub-table-wrap td.note-cell {
  white-space: normal;
  word-break: break-word;
  max-width: 260px;
}
.loading-mini, .empty-mini {
  text-align: center;
  padding: 18px 10px;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-radius: var(--r-md);
  font-size: 13px;
}
.empty-mini { color: var(--muted); }
/* 加载中：转圈 + 文字，避免只显示「加载中...」让人以为卡死 */
.loading-mini { display: flex; align-items: center; justify-content: center; gap: 8px; }
.spin {
  width: 15px; height: 15px;
  flex: 0 0 15px;
  border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 表格 ========== */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  position: relative;
}
/* 自定义滚动条（更细更含蓄，不抢表格内容的视线） */
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary) 55%, var(--border));
  border-radius: var(--radius-pill, 999px);
  border: 2px solid transparent;
  background-clip: content-box;
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--primary); background-clip: content-box; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
/* 表头：单色系不透明渐变，柔和过渡不切边。
   原先 thead 叠一层色相 + th 半透明色 = 两色混成脏色；改为 th 直接用不透明单色渐变。 */
thead {
  background: none;
}
th, td {
  padding: 8px 12px;
  border-bottom: var(--stroke-soft);
  text-align: left;
  vertical-align: middle;
  word-break: keep-all;          /* 中文不强行断词 */
  overflow-wrap: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
/* 宽表：固定首列，左侧滑动不消失 */
.table-wrap.wide col:first-child,
.table-wrap.wide th:first-child,
.table-wrap.wide td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  box-shadow: 4px 0 8px rgba(120,100,60,.06);
  min-width: 90px;
  max-width: 140px;
}
/* 「序号 / 排序」列在最前，固定首列的职责交给紧随其后的列（日期 / 编号），
   序号列自身也不要 90px 的最小宽度（宽表首列规则会把它撑开）。 */
.table-wrap.wide th.idx-col,
.table-wrap.wide td.idx-col {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}
/* 序号列之后的「日期」列顶替吸顶首列的角色 */
.table-wrap.wide th.idx-col + th,
.table-wrap.wide td.idx-col + td {
  position: sticky;
  left: 48px;
  z-index: 2;
  background: var(--card);
  box-shadow: 4px 0 8px rgba(120,100,60,.06);
}
.table-wrap.wide thead th.idx-col + th {
  background: var(--th-sticky);
  z-index: 3;
}
.table-wrap.wide thead th:first-child {
  background: var(--th-sticky);
  z-index: 3;
}
/* 长文本字段允许换行（覆盖 nowrap） */
td.wrap, th.wrap {
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: clip;
  max-width: 360px;
}
th {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  background: var(--th-head);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .55);  /* 底部一道浅高光，丝滑收边 */
}
tbody tr {
  transition: background .12s;
}
tbody tr:hover {
  background: var(--row-hover);
}
tbody tr:last-child td {
  border-bottom: none;
}

/* 数字列 */
td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
td.num { color: var(--num); }
td.num.neg { color: var(--warn); }
td.num.income { color: var(--num); font-weight: 700; }
td.num.expense { color: var(--warn); font-weight: 700; }
td.muted { color: var(--muted); }

/* 「排序」列（预算规划 / 花呗专项）：数字列默认右对齐，这里统一改成居中 */
th.sort-col, td.sort-col { text-align: center; }

/* ========== 录入弹窗（圆润卡片式） ========== */
.modal {
  position: fixed; inset: 0;
  background: rgba(87, 74, 58, .4);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  /* 窗口矮（非全屏）时整层可滚动：原来只居中不留滚动，卡片比视口高就被上下裁掉 */
  overflow-y: auto;
  padding: 16px 0;
  z-index: 100;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 92%;
  max-width: 440px;
  max-height: 90vh;
  /* overflow-y: auto; -- 改用 form 内层容器单独滚动，避免截断备注下拉 */
  overflow-y: visible;
  border: 4px solid var(--primary-light);
  box-shadow: 0 20px 60px rgba(87, 74, 58, .3);
  animation: popIn .3s cubic-bezier(.34, 1.56, .64, 1);
}
/* 录入 / 批量录入弹窗：高度按视口算，标题固定、表单自己滚动，内容再长也不会溢出卡片 */
.modal > .modal-card {
  margin: auto;  /* 空间够时垂直居中，不够时从顶部开始、可随外层滚动 */
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}
.modal-card form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  margin-right: -4px;
}
.modal-card.wide {
  max-width: 820px;
  padding: 22px 26px;
  /* 桌面端同样会溢出：子明细展开后内容高 866px 超过 max-height:90vh(720px)，
     而 .modal-card 的 overflow-y 是 visible（故意不开，避免裁掉备注下拉），
     结果关闭按钮被顶到 top=874 超出视口点不到。
     不能给 .modal-card 全局加 overflow，会裁掉录入弹窗的备注下拉，
     所以只给 .wide 用「主体滚动 + 底部按钮固定」的 flex 布局。 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* 分类表：内容多时自己可缩可滚，不会把下面两块顶出卡片 */
.modal-card.wide > .cat-detail-table {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}
/* 子明细区：占据剩余空间并独立滚动 */
.modal-card.wide > .cat-detail-expand {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* 按钮区始终留在卡片内，关闭永远可点 */
.modal-card.wide > .actions {
  flex: 0 0 auto;
  margin-top: 18px;
}
@keyframes popIn {
  from { transform: scale(.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-card h2 {
  margin: 0 0 18px;
  font-size: 18px;
  color: var(--primary-dark);
  text-align: center;
}
.modal-card h2::before { content: '🖊️ '; }

.modal-card label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
}
.modal-card label.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-soft);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-weight: normal;
  margin-bottom: 12px;
}
.modal-card label.check input[type="checkbox"] {
  width: auto;
  margin: 2px 0 0;
  flex-shrink: 0;
}
.modal-card label.check .check-text {
  flex: 1;
  line-height: 1.5;
}
.modal-card label.check.disabled {
  opacity: .45;
  cursor: not-allowed;
  background: var(--bg-soft-disabled, #f1ede5);
}
.modal-card label.check.disabled input[type="checkbox"]:disabled { cursor: not-allowed; }

/* 备注联想下拉（直接在 body 末尾，position: fixed 避免被 overflow 裁剪） */
.note-suggest {
  position: fixed;
  z-index: 9999;
  background: var(--card);
  border: 1px solid var(--primary-light);
  border-radius: var(--r-sm);
  box-shadow: var(--elev-3);
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
  min-width: 200px;
}
.note-suggest .item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.note-suggest .item:hover,
.note-suggest .item.active {
  background: var(--primary-light);
}
.note-suggest .item .cnt {
  color: var(--text-soft);
  font-size: 11px;
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
}
.note-suggest .empty {
  padding: 10px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}
.modal-card input, .modal-card select {
  width: 100%;
  padding: 10px 12px;
  border: var(--stroke);
  border-radius: var(--r-sm);
  font-size: 14px;
  margin-top: 4px;
  font-family: var(--font);
  background: #fff;
  transition: border-color .15s;
}
.modal-card input:focus, .modal-card select:focus {
  outline: none;
  border-color: var(--primary);
}
.modal-card .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}
.modal-card .msg {
  margin: 10px 0 0;
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}
.modal-card .msg.ok { color: var(--num); }
.modal-card .msg.err { color: var(--warn); }

/* ========== 批量录入弹窗 ========== */
.modal-card.modal-batch {
  max-width: 720px;
  width: 95%;
}
.modal-card.modal-batch h2::before { content: '📦 '; }
/* 窄屏记账页式连续录入：默认隐藏，<=720px 启用（见移动端段落） */
.batch-mobile { display: none; }
.modal-card .hint {
  font-size: 13px;
  color: var(--text-soft);
  margin: 4px 0 14px;
  text-align: center;
}
.batch-common {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
  align-items: end;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}
.batch-common label { margin: 0; }
.batch-table-wrap {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px dashed var(--primary-light);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: 10px;
}
.batch-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
.batch-table thead th {
  background: var(--th-sticky);
  color: var(--text);
  font-weight: 700;
  padding: 8px 6px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
.batch-table tbody td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--primary-light);
  vertical-align: middle;
}
.batch-table .col-idx { width: 6%; text-align: center; color: var(--text-soft); }
.batch-table .col-cat { width: 24%; }
.batch-table .col-amount { width: 18%; }
.batch-table .col-huabei { width: 10%; text-align: center; vertical-align: middle; }
.batch-table .col-note { width: 30%; }
.batch-table .col-actions { width: 12%; text-align: center; }
table.batch-table .batch-hb {
  width: 20px !important;
  height: 20px !important;
  margin: 0 !important;
  padding: 0 !important;
  accent-color: var(--warn);
  cursor: pointer;
  vertical-align: middle;
}
table.batch-table .batch-hb:disabled { cursor: not-allowed; accent-color: #bbb; }
.batch-table .col-huabei.disabled { opacity: .4; }
.batch-table .col-huabei.disabled .batch-hb { cursor: not-allowed; }
.batch-table thead .col-huabei.disabled-hint {
  color: #b8775a;
  font-style: italic;
}
.batch-table select, .batch-table input {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 6px;
  font-size: 13px;
  border: 1px solid var(--primary-light);
  border-radius: 6px;
  background: var(--card);
  font-family: var(--font);
  min-width: 0;
}
.batch-table input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.batch-row-btns {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.batch-row-btns button {
  padding: 3px 8px;
  font-size: 12px;
  min-height: 22px;
  line-height: 16px;
  border-radius: 6px;
  border: 1px solid var(--primary-light);
  background: var(--card);
  color: var(--primary-dark);
  cursor: pointer;
  vertical-align: middle;
  box-sizing: border-box;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.batch-row-btns button:hover { background: var(--primary-light); }
.batch-row-btns button.del:hover { background: var(--warn); color: #fff; border-color: var(--warn); }
.batch-row.invalid { background: rgba(217, 111, 90, .12); }
.batch-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  margin: 4px;
  background: var(--bg-soft);
}
.batch-empty.hidden { display: none; }
.batch-empty-icon {
  display: block;
  font-size: 36px;
  margin-bottom: 8px;
  opacity: .75;
  filter: grayscale(.1);
}
.batch-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.batch-empty-tip {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.6;
}
.batch-empty-tip b {
  color: var(--primary-dark);
  font-weight: 600;
  margin: 0 2px;
}
.batch-add-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}
.batch-summary {
  text-align: center;
  font-size: 14px;
  color: var(--primary-dark);
  padding: 8px;
  background: var(--primary-light);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  font-weight: 700;
}
.batch-summary #batch-total .sum-cash { color: var(--num); }
.batch-summary #batch-total .sum-huabei { color: var(--warn); }
.batch-summary #batch-total .sum-total { color: var(--primary-dark); }

/* ========== 移动端 ========== */
@media (max-width: 640px) {
  header { padding: 10px 14px; }
  header h1 { font-size: 17px; }
  nav#tabs { padding: 10px 14px; gap: 6px; }
  nav#tabs button { padding: 6px 12px; font-size: 13px; }
  main { padding: 10px 14px; }
  table { font-size: 13px; }
  th, td { padding: 7px 8px; }
  .card { border-width: 2px; }
  .modal-card { padding: 18px; }
  .batch-common { grid-template-columns: 1fr 1fr; }
}

/* ============================================
   主题切换面板 + 自定义背景
   ============================================ */

/* 主题按钮 */
#btn-theme {
  background: var(--card);
  color: var(--primary-dark);
  border: var(--stroke);
  box-shadow: var(--elev-1);
}
#btn-theme:hover {
  background: var(--primary-light);
}
#btn-theme.active {
  background: var(--primary);
  color: #fff;
}

/* 主题面板 */
.theme-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.04);
  padding: 18px;
  display: none;
  z-index: 999;
  isolation: isolate;
}
body.theme-maojin .theme-panel {
  background: #fffaf2;
}
.theme-panel.open {
  display: block;
  animation: panelIn 0.25s ease;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.theme-panel .panel-title {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0 0 12px;
  font-weight: 600;
}

/* 主题卡片 */
.theme-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.theme-card {
  position: relative;
  padding: 12px 8px;
  border-radius: var(--r-md);
  border: var(--stroke);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--text);
}
.theme-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.theme-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
}
.theme-card .preview {
  height: 50px;
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.theme-card[data-theme="qingxin"] .preview {
  background: linear-gradient(135deg, #19c8b9, #b8ece4);
}
.theme-card[data-theme="maojin"] .preview {
  background: linear-gradient(135deg, #ff9a76, #ffd6a5);
}
.theme-card[data-theme="custom"] .preview {
  background: linear-gradient(135deg, #c5d2eb, #d8bfd8);
  color: #5e3a8c;
}

/* 自定义背景配置 */
.bg-config {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}
.bg-config.hidden { display: none; }
.bg-config .config-row {
  margin-bottom: 12px;
}
.bg-config label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 6px;
  font-weight: 600;
}
.bg-config label .val {
  color: var(--primary-dark);
  font-weight: 700;
}
.bg-config input[type=range] {
  width: 100%;
  accent-color: var(--primary);
}
.bg-config .file-btn {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 12px;
  box-shadow: none;
  display: block;
}
.bg-config .file-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 72px;
  margin-left: auto;
}
.pos-cell {
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  padding: 0;
  box-shadow: none;
}
.pos-cell:hover {
  border-color: var(--primary);
}
.pos-cell.active {
  background: var(--primary);
  border-color: var(--primary);
}

.config-row.pos-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.config-row.pos-row label { margin: 0; }

.bg-config .row-btns {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.bg-config .row-btns button {
  flex: 1;
  padding: 6px;
  font-size: 12px;
}

/* 月薪喵 logo */
.theme-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
  background: var(--card);
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
body.theme-qingxin .theme-logo-img { display: none; }

/* 月薪喵点缀：表格为空时 */
.mj-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-soft);
}
.mj-empty img {
  width: 80px;
  height: 80px;
  margin-bottom: 10px;
}
.mj-empty .text {
  font-size: 14px;
  color: var(--text-soft);
}

/* 月薪喵 Tab 装饰 */
.tab-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 4px;
  display: inline-block;
}
body.theme-qingxin .tab-icon { display: none; }

/* ========== 月薪喵 GIF 配置面板 ========== */
.mj-config {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  margin-top: 14px;
}
.mj-config.hidden { display: none; }
.mj-config .panel-hint {
  font-size: 12px;
  color: var(--text-soft);
  margin: 0 0 10px;
  line-height: 1.5;
}
.mj-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.mj-toolbar button {
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
}
.mj-toolbar button.primary { margin-left: auto; }

/* ========== 紧凑位置列表（方案 C） ========== */
.mj-pos-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.mj-pos-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
}
.mj-pos-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateX(2px);
}
.mj-pos-item .pos-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: #fff;
  flex-shrink: 0;
  border: 1px solid var(--border-soft);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mj-pos-item .pos-thumb img { width: 100%; height: 100%; object-fit: contain; }
.mj-pos-item .pos-info { flex: 1; min-width: 0; line-height: 1.3; }
.mj-pos-item .pos-name { font-size: 13px; color: var(--text); font-weight: 600; }
.mj-pos-item .pos-file { font-size: 10px; color: var(--text-soft); font-family: ui-monospace, monospace; }
.mj-pos-item .pos-custom-mark {
  font-size: 10px;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 700;
  flex-shrink: 0;
}
.mj-pos-item .pos-arrow {
  color: var(--text-soft);
  font-size: 14px;
  flex-shrink: 0;
}

/* ========== GIF 选择模态浮层 ========== */
.mj-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}
.mj-modal.hidden { display: none !important; }
.mj-modal-card {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  overflow: hidden;
  isolation: isolate;
  animation: modalPop 0.22s cubic-bezier(.2,.9,.3,1.2);
}
body.theme-maojin .mj-modal-card { background: #fffaf2; }
@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.mj-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.mj-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.mj-modal-title span { color: var(--primary-dark); }
.mj-modal-close {
  background: transparent;
  border: 0;
  font-size: 18px;
  color: var(--text-soft);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.mj-modal-close:hover { background: rgba(0,0,0,.06); color: var(--accent); }

.mj-modal-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  flex-shrink: 0;
}
.mj-modal-preview .preview-label {
  color: var(--text-soft);
  font-weight: 600;
}
.mj-modal-preview .preview-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.mj-modal-preview .preview-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  background: transparent;
  display: block;
}
.mj-modal-preview .preview-img-empty {
  background: #fff5ec;
  border-style: dashed;
  color: var(--primary);
}
.mj-modal-preview .preview-empty-icon {
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
/* 有图时隐藏占位猫 */
.preview-img-empty.has-img .preview-empty-icon { display: none; }
.preview-img-empty.has-img img { display: block; }
.preview-img-empty:not(.has-img) img { display: none; }
.mj-modal-preview .preview-name {
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 11px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mj-modal-preview .preview-arrow {
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  margin: 0 2px;
}

/* 预览区两端（当前位置 vs 新选） */
.mj-modal-preview .preview-side {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.mj-modal-preview .preview-side-current {
  flex: 1.2;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-soft, rgba(255, 154, 118, 0.08));
  border: 1px dashed var(--primary-light, #ffb89a);
}
.mj-modal-preview .preview-side-new {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(76, 175, 80, 0.06);
  border: 1px dashed rgba(76, 175, 80, 0.35);
}
.mj-modal-preview .preview-side .preview-label {
  flex-shrink: 0;
  font-size: 11px;
  white-space: nowrap;
}
.mj-modal-preview .preview-side-current .preview-img-static {
  width: 44px;
  height: 44px;
}
.mj-modal-preview .preview-side-current img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  display: block;
  background: transparent;
}
.mj-modal-preview .preview-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.mj-modal-preview .preview-meta .preview-name {
  font-weight: 700;
  color: var(--text);
  font-size: 12px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mj-modal-preview .preview-meta .preview-desc {
  color: var(--text-soft);
  font-size: 11px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mj-modal-preview .preview-side-new .preview-name {
  font-weight: 600;
  color: var(--accent, #2e7d32);
}

.mj-modal-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

/* 顶部位置选择条 - 网格布局（按 group 分组） */
.mj-slot-bar,
.mj-modal-slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  flex-shrink: 0;
  max-height: 280px;
  overflow-y: auto;
}
.mj-slot-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mj-slot-group-label {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 700;
  letter-spacing: 0.5px;
  padding-left: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mj-slot-group-label::before {
  content: '';
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: var(--primary);
  display: inline-block;
}
.mj-slot-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
}
.mj-slot-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.12s;
  font-family: inherit;
  text-align: center;
  min-width: 0;
}
.mj-slot-chip:hover {
  background: rgba(255,154,118,.18);
  border-color: var(--primary-light);
  transform: translateY(-1px);
}
.mj-slot-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,154,118,.22);
}
.mj-slot-chip.dirty::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  top: 4px;
  right: 4px;
  border: 2px solid var(--bg);
}
.mj-slot-chip {
  position: relative;
}
.mj-slot-chip .chip-thumb {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border-soft);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mj-slot-chip .chip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.mj-slot-chip .chip-name {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.mj-slot-chip .chip-code {
  font-size: 9px;
  color: var(--text-soft);
  font-family: ui-monospace, monospace;
  opacity: 0.7;
}
.mj-slot-chip.active .chip-name { font-weight: 700; color: var(--primary-dark); }
.mj-slot-chip.dirty .chip-name { color: var(--accent); }

.mj-modal-summary {
  font-size: 12px;
  color: var(--text-soft);
  flex: 1;
  min-width: 0;             /* 允许 flex 子项收缩 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;              /* 暗示有完整内容 */
}
.mj-modal-summary strong {
  color: var(--accent);
  font-weight: 700;
}
.mj-modal-summary.has-changes {
  color: var(--primary-dark);
  font-weight: 600;
}

button.ghost.small, button.secondary.small, button.primary.small {
  font-size: 12px;
  padding: 5px 10px;
  white-space: nowrap;
}
.mj-modal-toolbar input[type=text] {
  flex: 1;
  border: var(--stroke);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-family: ui-monospace, monospace;
}
.mj-modal-toolbar input[type=text]:focus { border-color: var(--primary); }
.mj-modal-tip { font-size: 11px; color: var(--text-soft); white-space: nowrap; }

.mj-modal-gallery {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 88px);
  gap: 8px;
  overflow-y: auto;
  align-content: start;
  justify-content: start;
  flex: 1;
  min-height: 240px;
}
.mj-modal-gallery .mj-gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  padding: 30px;
}

.mj-modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
  background: var(--bg);
  flex-wrap: wrap;          /* 移动端允许换行 */
}
.mj-modal-foot button {
  font-size: 13px;
  padding: 7px 16px;
  flex-shrink: 0;           /* 按钮永远不收缩 */
  white-space: nowrap;
}

.mj-summary {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-soft);
  border: 1px dashed var(--border);
}
.mj-summary.ok { background: #fff0e2; border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }

/* 模态浮层里的缩略图 */
.mj-thumb {
  width: 88px;
  height: 88px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, border-color 0.12s;
  overflow: hidden;
  flex-shrink: 0;
}
.mj-thumb:hover { transform: translateY(-2px); border-color: var(--primary-light); }
.mj-thumb.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(255,154,118,.25);
}
.mj-thumb img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
}

@media (max-width: 600px) {
  .mj-modal-card { max-height: 95vh; }
  .mj-modal-gallery { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .mj-modal-preview { flex-wrap: wrap; gap: 8px; }
  .mj-modal-preview .preview-side { flex-basis: 100%; }
  .mj-modal-preview .preview-arrow { transform: rotate(90deg); align-self: center; }
  .mj-slot-bar, .mj-modal-slots { max-height: 200px; }
  .mj-thumb { min-height: 80px; }
  .mj-thumb img { max-height: 80px; }
}

/* 响应式调整 */
@media (max-width: 600px) {
  .theme-panel { width: calc(100vw - 32px); right: -8px; }
  .theme-cards { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
}

/* ============================================================ */
/* 入场动画：封面（Cover） + 转场加载（Loader）                  */
/* ============================================================ */

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
@keyframes floatUp {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes floatCat {
  0%   { transform: translate(0, 0) rotate(0); opacity: 0; }
  10%  { opacity: .8; }
  100% { transform: translate(40px, -120vh) rotate(20deg); opacity: 0; }
}
@keyframes glowPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 154, 118, .55); }
  100% { box-shadow: 0 0 0 18px rgba(255, 154, 118, 0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pawWalk {
  0%   { transform: translateX(0); opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateX(40px); opacity: 0; }
}
@keyframes stageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes stageFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes barShine {
  0%   { transform: translateX(-30%); }
  100% { transform: translateX(130%); }
}

/* 封面 */
.cover-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(135deg, #e8f5e9 0%, #fff8e1 100%);
  animation: stageFadeIn .6s ease both;
  overflow: hidden;
}
body.theme-maojin .cover-screen {
  background: linear-gradient(135deg, #fff7ed 0%, #ffe4d1 60%, #ffd6c2 100%);
}

.cover-screen.leaving {
  animation: stageFadeOut .5s ease both;
  pointer-events: none;
}

.cover-bg-cats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.cover-cat {
  position: absolute;
  bottom: -40px;
  font-size: 28px;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
  animation: floatCat 14s linear infinite;
}
/* 猫只在外侧留白里飘，别横穿中间的登录卡片和提示文字。
   桌面端内容区约 348px 宽，手机端卡片更宽，所以左右各留出一段“安全走廊”。 */
.cover-cat-1 { left:  4%; font-size: 22px; animation-delay: 0s;  animation-duration: 16s; }
.cover-cat-2 { left: 16%; font-size: 18px; animation-delay: 3s;  animation-duration: 18s; }
.cover-cat-3 { left: 84%; font-size: 26px; animation-delay: 6s;  animation-duration: 15s; }
.cover-cat-4 { left: 74%; font-size: 20px; animation-delay: 9s;  animation-duration: 17s; }
.cover-cat-5 { left: 92%; font-size: 24px; animation-delay: 12s; animation-duration: 14s; }
.cover-cat-6 { left:  2%; font-size: 18px; animation-delay: 2s;  animation-duration: 19s; }

/* 窄屏内容更宽，安全走廊更窄，猫往两边靠 */
@media (max-width: 720px) {
  .cover-cat-1 { left:  1%; }
  .cover-cat-2 { left: 11%; }
  .cover-cat-3 { left: 88%; }
  .cover-cat-4 { left: 78%; }
  .cover-cat-5 { left: 95%; }
  .cover-cat-6 { left: -2%; }
}

.cover-main {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 24px;
  max-width: 720px;
}

.cover-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 10px 30px rgba(255, 154, 118, .25);
  margin-bottom: 28px;
  animation: breathe 3s ease-in-out infinite;
}

.cover-title {
  font-size: 64px;
  font-weight: 800;
  margin: 0 0 18px;
  letter-spacing: 12px;
  text-align: center;
  color: var(--primary-dark, #3a6a4d);
}
body.theme-maojin .cover-title {
  color: #d96b4a;
  text-shadow: 0 2px 0 rgba(255,255,255,.6);
}
.cover-title .ch {
  display: inline-block;
  animation: floatUp .8s cubic-bezier(.2, .8, .25, 1) both;
}
.cover-title .ch1 { animation-delay: .15s; }
.cover-title .ch2 { animation-delay: .30s; }
.cover-title .ch3 { animation-delay: .45s; }

.cover-sub {
  font-size: 16px;
  font-style: italic;
  letter-spacing: 4px;
  margin: 0 0 48px;
  color: var(--text-soft, #6a7868);
  opacity: 0;
  animation: floatUp .8s ease-out .6s both;
}
body.theme-maojin .cover-sub {
  color: #b56a52;
}

.cover-enter {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #fff;
  background: linear-gradient(135deg, #ff9a76, #ff7a50);
  border: none;
  border-radius: 999px;
  padding: 14px 42px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(255, 122, 80, .35);
  opacity: 0;
  animation: floatUp .8s ease-out .8s both, glowPulse 2s ease-out infinite 1.8s;
  transition: transform .25s ease;
}
.cover-enter:hover { transform: translateY(-2px) scale(1.04); }
.cover-enter-paw {
  font-size: 18px;
  animation: pawWalk 1.2s ease-in-out infinite;
}

/* ========== 登入表单（嵌入封面） ========== */
/* 手机 APP 端优先：做成白底卡片，输入框加大到 48px 高，带前置图标，
   避免飘落猫爪 emoji 盖住输入框（表单在 .cover-main 内且 z-index 更高）。 */
.login-form {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 300px;
  margin: 6px auto 0;
  padding: 20px 20px 14px;
  border-radius: 20px;
  background: var(--card, #fff);
  box-shadow: 0 12px 32px rgba(180, 110, 80, .16);
  border: 1px solid var(--border, #e2d6c3);
  opacity: 0;
  animation: floatUp .8s ease-out 1.0s both;
}

/* 带前置图标的输入行 */
.login-field {
  position: relative;
  display: flex;
  align-items: center;
}
.login-field .login-ico {
  position: absolute;
  left: 14px;
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
  opacity: .55;
}
.login-form input {
  width: 100%;
  height: 46px;
  padding: 0 44px 0 40px;
  border-radius: 23px;
  border: 1.5px solid var(--border, #e2d6c3);
  background: var(--bg-soft, #fdf7f0);
  font-size: 15px;
  color: var(--text, #4a3f35);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-form input::placeholder {
  color: var(--text-soft, #a89886);
}
.login-form input:focus {
  border-color: var(--primary, #ff9a76);
  box-shadow: 0 0 0 3px rgba(255,154,118,.18);
  background: var(--card, #fff);
}
/* 密码可见性切换按钮（盖在输入框右侧） */
.login-pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: .6;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .2s, background .2s;
}
.login-pw-toggle:hover { opacity: 1; background: var(--bg-soft, #fdf7f0); }
.login-pw-toggle:active { transform: translateY(-50%) scale(.94); }

.login-form button#login-submit {
  height: 46px;
  border: none;
  border-radius: 23px;
  background: linear-gradient(135deg, var(--primary, #ff9a76), var(--primary-dark, #e07a5f));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: 4px;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--elev-primary);
}
.login-form button#login-submit:hover { transform: translateY(-1px); box-shadow: var(--elev-primary-hover); }
.login-form button#login-submit:active { transform: translateY(0); }
.login-form button#login-submit:disabled { opacity: .55; cursor: not-allowed; }

/* 记住账号 */
.login-remember {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft, #8a7e6b);
  cursor: pointer;
  user-select: none;
  margin-top: -2px;
}
.login-remember input[type=checkbox] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary, #ff9a76);
  cursor: pointer;
}

.login-form .msg {
  margin: 0;
  font-size: 13px;
  color: #d9444f;
  min-height: 18px;
  text-align: center;
  line-height: 1.4;
  word-break: break-all;
}
/* 没有提示信息时不要占高度，保持卡片紧凑 */
.login-form .msg:empty { min-height: 0; }

.cover-hint {
  position: absolute;
  bottom: -52px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-soft, #8a8a8a);
  opacity: 0;
  animation: floatUp .8s ease-out 1s both;
  margin: 0;
  white-space: nowrap;
  /* 淡底衬，飘过的猫爪不会糊住这行字 */
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
}
/* 手机 APP 端没有 ESC 键，提示「按 ESC 跳过」是误导 —— 改成点封面空白处即可进入。
   用项目统一的 720px 断点判定，不用 hover/pointer 特性（WebView 上不可靠）。 */
.cover-hint .cover-hint-desktop { display: inline; }
.cover-hint .cover-hint-touch { display: none; }
@media (max-width: 720px) {
  .cover-hint .cover-hint-desktop { display: none; }
  .cover-hint .cover-hint-touch { display: inline; }
}

.cover-clock {
  position: absolute;
  left: 24px;
  bottom: 18px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--text-soft, #8a8a8a);
  opacity: 0;
  animation: floatUp .8s ease-out 1s both;
}
body.theme-maojin .cover-clock { color: #b07c6c; }

/* 转场加载 */
.loader-screen {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f5e9 0%, #fff8e1 100%);
  overflow: hidden;
  padding: 0 24px;
}
body.theme-maojin .loader-screen {
  background: linear-gradient(135deg, #fff7ed 0%, #ffe4d1 60%, #ffd6c2 100%);
}
.loader-screen.active {
  display: flex;
  animation: stageFadeIn .35s ease both;
}
.loader-screen.leaving {
  animation: stageFadeOut .5s ease both;
  pointer-events: none;
}

.loader-track {
  display: flex;
  gap: 14px;
  margin-bottom: 36px;
  flex-wrap: wrap;
  justify-content: center;
}
.loader-cat {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  filter: grayscale(.85) opacity(.4);
  transition: filter .35s ease, transform .35s ease;
}
.loader-cat.lit {
  filter: none;
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(255, 154, 118, .35);
}
.loader-cat img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.loader-tip {
  font-size: 16px;
  letter-spacing: 2px;
  color: var(--text-soft, #6a7868);
  margin: 0 0 18px;
  min-height: 24px;
}
body.theme-maojin .loader-tip { color: #b56a52; }

.loader-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(560px, 90vw);
}
.loader-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.6);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a8d8a8 0%, #ffd28a 100%);
  border-radius: 999px;
  transition: width .15s linear;
  position: relative;
  overflow: hidden;
}
body.theme-maojin .loader-bar-fill {
  background: linear-gradient(90deg, #ff9a76 0%, #ffb088 100%);
}
.loader-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  background-size: 200% 100%;
  animation: barShine 1.6s linear infinite;
}
.loader-percent {
  font-size: 13px;
  color: var(--text-soft, #6a7868);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
}
body.theme-maojin .loader-percent { color: #b56a52; }

.loader-hint {
  position: absolute;
  bottom: 28px;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-soft, #8a8a8a);
  opacity: .7;
  margin: 0;
}
/* 手机 APP 端没有 ESC 键：文案换掉，并给加载页绑了轻触跳过 */
.loader-hint .loader-hint-desktop { display: inline; }
.loader-hint .loader-hint-touch { display: none; }
@media (max-width: 720px) {
  .loader-hint .loader-hint-desktop { display: none; }
  .loader-hint .loader-hint-touch { display: inline; }
  /* 轻触跳过需要整页可点，但不能影响内部元素本身的点击 */
  .loader-screen { cursor: pointer; }
}

/* 主题面板中的重看按钮 */
.replay-intro {
  font-size: 12px;
  padding: 6px 12px;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
.replay-intro:hover {
  background: var(--accent);
  color: #fff;
}

/* 入场动画配置块 */
.intro-config {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-soft);
}
.intro-config .row-btns {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.intro-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.intro-toggle input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* 主页出场（loader 关闭时主页浮起） */
/* 默认：opacity 0 + 下移 + 不可点击，等封面/loader 走完才显示 */
/* 只门控顶部 nav#tabs；底部 #mobile-tabs 不在其列，避免入场卡住时 App 底部 Tab 整排点不动 */
body.intro-pending > .bg-layer,
body.intro-pending > header,
body.intro-pending > #tabs,
body.intro-pending > main {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}
body.intro-pending > .bg-layer,
body.intro-pending > header,
body.intro-pending > #tabs,
body.intro-pending > main {
  transition: opacity .45s ease, transform .45s ease;
}
body.intro-ready > .bg-layer,
body.intro-ready > header,
body.intro-ready > #tabs,
body.intro-ready > main {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
body.intro-ready > .bg-layer,
body.intro-ready > header,
body.intro-ready > #tabs,
body.intro-ready > main {
  transition: opacity .5s ease, transform .5s ease;
}

/* ========== 月薪喵气泡动画（背景层之上、主内容之下）========== */
.mj-bubble-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;            /* 高于 .bg-layer(0)，低于 main/header */
  overflow: hidden;
}
.mj-bubble {
  position: absolute;
  bottom: -120px;
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 50%;
  box-shadow: 0 6px 20px rgba(255, 154, 118, .18);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  animation: bubble-float 18s linear infinite;
  backdrop-filter: blur(2px);
}
.mj-bubble img {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
}
@keyframes bubble-float {
  0%   { transform: translateY(0)        rotate(0deg);   opacity: 0; }
  8%   {                                              opacity: .85; }
  50%  { transform: translateY(-55vh)    rotate(180deg); }
  92%  {                                             opacity: .85; }
  100% { transform: translateY(-110vh)   rotate(360deg); opacity: 0; }
}
/* 各个气泡的位置和节奏各不相同（12 个槽位） */
.mj-bubble.b1  { left:  4%; width:64px; height:64px; animation-duration: 16s; animation-delay:  0s; }
.mj-bubble.b2  { left: 12%; width:84px; height:84px; animation-duration: 22s; animation-delay: -3s; }
.mj-bubble.b3  { left: 20%; width:58px; height:58px; animation-duration: 19s; animation-delay: -7s; }
.mj-bubble.b4  { left: 32%; width:72px; height:72px; animation-duration: 24s; animation-delay: -11s; }
.mj-bubble.b5  { left: 44%; width:90px; height:90px; animation-duration: 20s; animation-delay: -2s; }
.mj-bubble.b6  { left: 56%; width:66px; height:66px; animation-duration: 17s; animation-delay: -9s; }
.mj-bubble.b7  { left: 68%; width:78px; height:78px; animation-duration: 23s; animation-delay: -5s; }
.mj-bubble.b8  { left: 78%; width:60px; height:60px; animation-duration: 18s; animation-delay: -14s; }
.mj-bubble.b9  { left: 86%; width:84px; height:84px; animation-duration: 21s; animation-delay: -8s; }
.mj-bubble.b10 { left:  8%; width:72px; height:72px; animation-duration: 25s; animation-delay: -16s; }
.mj-bubble.b11 { left: 50%; width:58px; height:58px; animation-duration: 19s; animation-delay: -12s; }
.mj-bubble.b12 { left: 72%; width:96px; height:96px; animation-duration: 26s; animation-delay: -4s; }

/* 清屏/小屏时不显示气泡 */
@media (max-width: 720px) {
  .mj-bubble-layer { display: none; }
}

/* 偏好减少动画：直接跳过 */
@media (prefers-reduced-motion: reduce) {
  .mj-bubble { display: none; }
}

/* ========== 移动端响应式 ========== */
@media (max-width: 720px) {
  body { font-size: 14px; }
  header {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  header h1 { font-size: 16px; }
  .theme-logo-img { width: 28px; height: 28px; }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 4px;
  }
  .header-actions button {
    padding: 6px 10px;
    font-size: 12px;
    flex-shrink: 0;
  }
  /* 游戏厅入口在窄屏只留图标，避免挤掉录入按钮 */
  .header-app-btn {
    padding: 6px 9px;
    gap: 0;
    flex-shrink: 0;
  }
  .header-app-btn .gba-btn-label { display: none; }
  .gba-btn-dot { top: 3px; right: 4px; }
  #btn-account .account-name { display: none; }

  /* 登录表单在手机上：卡片化 + 输入框加大到 48px（更好点）+ 占满屏幕宽度 */
  .login-form {
    width: min(90vw, 340px);
    padding: 22px 18px 16px;
    border-radius: 22px;
  }
  .login-form input {
    height: 48px;
    font-size: 16px;   /* ≥16px 可避免 iOS 聚焦时自动放大页面 */
    border-radius: 24px;
  }
  .login-form button#login-submit {
    height: 48px;
    font-size: 16px;
    border-radius: 24px;
  }
  .login-remember { font-size: 13px; padding: 2px 4px; }

  /* 卡片小屏边距 */
  .card { padding: 10px; margin-bottom: 10px; }
  .card .title { padding: 10px 12px; font-size: 14px; }
  .card .title::before { font-size: 16px; margin-right: 6px; }

  /* 表格转卡片布局（仅明细类用，账户看板等单独处理）*/
  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td {
    display: block; width: 100%;
  }
  table.responsive-table tr {
    margin-bottom: 10px;
    border: 1px solid var(--border, #e2d6c3);
    border-radius: 10px;
    padding: 6px 10px;
    background: var(--card, #fff);
  }
  table.responsive-table td {
    padding: 4px 0;
    border-bottom: 1px dashed var(--border, #e2d6c3);
    text-align: right !important;
  }
  table.responsive-table td:last-child { border-bottom: 0; }
  table.responsive-table td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--text-soft, #8a7e6b);
    margin-right: 8px;
  }

  /* 弹窗全屏 */
  .modal-overlay .modal-card {
    width: 100vw !important;
    max-width: none;
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  /* 账号面板例外：内容很少，全屏会拉成一条空白长条，改成居中卡片。
     实际规则放在文件末尾的移动端媒体查询里（那里才是最终生效的 .modal-card 全屏规则）。 */

  /* 账号菜单 */
  /* 账号菜单（旧的下拉菜单样式，已改为居中弹窗，保留空规则占位以免误改其它块） */
  .account-menu { display: none; }

  /* 气泡层 */
  .mj-bubble-layer { display: none; }

  /* 封面：小屏缩放 */
  .cover-main { transform: scale(.92); }
  .cover-title { font-size: 48px !important; }
  .cover-logo { width: 90px; height: 90px; }
}

/* 账号体系：按钮 / 菜单 / 用户管理弹窗 ========== */
#btn-account {
  position: relative;
  padding-left: 12px; padding-right: 12px;
}
#btn-account.is-admin {
  border-color: var(--primary, #ff9a76);
  color: var(--primary-dark, #e07a5f);
}
.account-name { margin-left: 4px; }

/* 头像：有图用图，没图用名字首字色块 */
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  vertical-align: middle;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}
.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.account-avatar-lg {
  width: 36px;
  height: 36px;
  font-size: 16px;
}

/* 账号面板：头像点开后弹出的居中弹窗
   （原先是页头下的下拉菜单，但顶栏的 backdrop-filter 会给 fixed 后代
     建立包含块，菜单被顶栏裁掉后贴在屏幕最上方，故改为独立弹窗） */
.account-panel-overlay { z-index: 1200; }
.modal-overlay .account-panel {
  width: min(340px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  padding: 0;
  overflow: hidden;
}
.account-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 14px;
  background: var(--bg-soft, #faf6ee);
  border-bottom: 1px solid var(--border, #e2d6c3);
}
.account-panel-head .account-avatar-lg {
  width: 44px;
  height: 44px;
  font-size: 19px;
}
.account-panel-list { padding: 6px 0; }
.account-panel-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: var(--text, #4a3f35);
  border-radius: 0;
  letter-spacing: 0;
}
.account-panel-list button:hover { background: rgba(255,154,118,.08); }
.account-panel-list button .ap-ico { font-size: 16px; line-height: 1; flex: 0 0 auto; }
.account-panel-list button.logout { color: #d9444f; }
.account-panel .modal-foot {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border, #e2d6c3);
  margin-top: 0;
}
.account-panel .modal-foot button { width: 100%; }

.account-menu-name { font-weight: 700; font-size: 14px; }
.account-menu-name .badge-admin {
  display: inline-block; background: #ffe5d4; color: #c2410c;
  padding: 1px 6px; border-radius: 8px; font-size: 11px; margin-left: 6px;
}
.account-menu-user { color: var(--text-soft, #8a7e6b); font-size: 12px; margin-top: 2px; }

/* 改密弹窗 */
.modal-pw { max-width: 380px; }
.modal-pw label { display: block; margin-bottom: 10px; font-size: 13px; }
.modal-pw input { width: 100%; height: 38px; padding: 0 12px;
  border: 1.5px solid var(--border); border-radius: 8px; margin-top: 4px; }
.modal-pw .modal-foot { margin-top: 12px; }

/* 用户管理弹窗 */
.user-admin-overlay .modal-card { width: min(820px, 96vw); max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; }
.ua-toolbar { padding: 4px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.ua-list { overflow: auto; max-height: 60vh; }
.ua-row { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: #fffaf3; }
.ua-row-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.ua-name { font-weight: 600; font-size: 14px; }
.ua-username { color: var(--text-soft, #8a7e6b); font-size: 12px; }
.ua-actions { margin-left: auto; display: flex; gap: 6px; }
.ua-actions button { padding: 4px 10px; font-size: 12px; }
.ua-actions button.danger { color: #d9444f; border-color: #f5b8be; }
.badge-admin { display: inline-block; background: #ffe5d4; color: #c2410c;
  padding: 1px 6px; border-radius: 8px; font-size: 11px; margin-left: 4px; }
.badge-warn { display: inline-block; background: #fff5cc; color: #b45309;
  padding: 1px 6px; border-radius: 8px; font-size: 11px; margin-left: 4px; }

.ua-sub-overlay { z-index: 1100; }
.modal-overlay .ua-edit-card,
.ua-sub-overlay .ua-edit-card { width: min(1080px, 97vw); max-width: 97vw; }
.ua-edit-card .modal-body { display: flex; flex-direction: column; gap: 12px; }
.ua-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.ua-card-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 12px; }
.ua-card-sub { font-weight: 400; font-size: 11px; color: var(--text-soft); margin-left: 6px; }

.ua-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* 注意：以下涉及 label 的选择器必须带 .ua-edit-card 前缀，
   否则会被 .modal-card label { display:block } (0,1,1) 覆盖 */
.ua-edit-card .ua-field,
.ua-edit-card label.ua-admin-row { display: flex; }
.ua-edit-card .ua-field { flex-direction: column; gap: 5px; font-size: 13px; margin-bottom: 0; }
.ua-edit-card label.ua-admin-row { align-items: center; justify-content: space-between; cursor: pointer; margin-bottom: 0; }
.ua-field-full { grid-column: 1 / -1; }
.ua-field-label { color: var(--text-soft); font-size: 12px; }
.ua-field input[type=text], .ua-field input[type=password] {
  width: 100%; height: 38px; padding: 0 12px; border: 1.5px solid var(--border);
  border-radius: 9px; background: #fff; font-size: 13px; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.ua-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.ua-field input:disabled { background: #f1ece4; color: var(--text-soft); cursor: not-allowed; }

/* 管理员高亮卡 */
.ua-admin-card { background: linear-gradient(135deg, #fff5ec, #ffe9da); border-color: #ffd2ba; }
.ua-admin-text { display: flex; flex-direction: column; gap: 2px; }
.ua-admin-t { font-weight: 600; font-size: 14px; color: #c2410c; }
.ua-admin-s { font-size: 11px; color: #b06a4d; }

/* 权限区 */
.ua-perm-head, .ua-perm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 20px; }
.ua-perm-head { padding: 0 4px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ua-perm-h-page { font-size: 12px; color: var(--text-soft); font-weight: 600; }
.ua-perm-h-ops { font-size: 11px; color: var(--text-soft); font-weight: 600; text-align: right; }
.ua-perm-list { max-height: 38vh; overflow: auto; padding-right: 6px; }
.ua-perm-row { padding: 9px 4px; border-bottom: 1px dashed var(--border); }
.ua-perm-row:last-child { border-bottom: 0; }
.ua-page-cell { min-width: 0; }
.ua-page-name { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; }
.ua-page-key { margin-left: 6px; font-weight: 400; font-size: 11px; color: #a99c87; }
.ua-btn-hint { display: block; font-size: 11px; color: #b8860b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ua-perm-toggles { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-shrink: 0; }

/* 勾选框：未选=浅灰描边，选中=实心主题色，状态一眼可辨 */
.ua-edit-card .ua-tg { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; margin-bottom: 0; }
.ua-tg input { position: absolute; opacity: 0; width: 0; height: 0; }
.ua-tg-box {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  border: 2px solid #c3b6a2; background: #fff; color: transparent;
  font-size: 13px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.ua-tg:hover .ua-tg-box { border-color: var(--primary); }
.ua-tg input:checked + .ua-tg-box {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.ua-tg input:focus-visible + .ua-tg-box { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.ua-tg-txt { font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.ua-tg input:checked ~ .ua-tg-txt { color: var(--text); font-weight: 600; }
.ua-tg-lg .ua-tg-box { width: 26px; height: 26px; border-radius: 8px; font-size: 16px; }

.ua-edit-foot { margin-top: 2px; padding-top: 4px; }

/* 偏好减少动画：直接跳过 */
@media (prefers-reduced-motion: reduce) {
  .cover-screen, .loader-screen { animation-duration: .01s; }
  .cover-cat, .cover-logo, .cover-title .ch, .cover-sub, .cover-enter, .cover-clock, .cover-hint {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* 移动端适配 */
@media (max-width: 600px) {
  .cover-title { font-size: 44px; letter-spacing: 8px; }
  .cover-sub   { font-size: 14px; letter-spacing: 3px; margin-bottom: 36px; }
  .cover-logo  { width: 90px; height: 90px; }
  .cover-enter { padding: 12px 32px; font-size: 14px; }
  .loader-cat  { width: 42px; height: 42px; }
  .loader-track { gap: 8px; }
}

/* ============================================ */
/* ========= 流水明细：编辑按钮 + 编辑弹窗 ======== */
/* ============================================ */

/* 操作列单元格：居中、紧凑 */
.edit-col {
  text-align: center !important;
  padding: 4px 6px !important;
  white-space: nowrap;
}
th.edit-col {
  font-weight: 600;
  color: var(--text-soft);
  /* 走主题 token：--th-sticky 是表头渐变的平色末端，作为弱化列的纯色底 */
  background: var(--th-sticky);
}

/* 花呗专项：排序列（与预算规划等页面的「排序」列保持同一套外观：正常字号、左对齐） */
.idx-col {
  padding: 4px 8px !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th.idx-col {
  /* 走主题 token：sticky 场景下需要平色底，避免渐变断层 */
  background: var(--th-sticky);
}
/* 有序号列的表保持 auto 布局：列宽按内容自适应，备注列才能拿到足够宽度。
   序号列用 col + 单元格 width 一起约束到 48px 左右。
   （fixed 布局下 colgroup 里的估算宽度是硬约束，备注会被压成一列竖字，
    末列 auto 又会吃掉全部剩余空间 —— 别改回 fixed。） */
table.responsive-table.tx-indexed { table-layout: auto; width: 100%; }
table.responsive-table.tx-indexed col:first-child,
table.responsive-table.tx-indexed th.idx-col,
table.responsive-table.tx-indexed td.idx-col { width: 48px; }

/* 编辑按钮：小巧，不抢眼 */
.edit-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .18s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.edit-btn:hover:not(:disabled) {
  background: var(--primary-dark, #14a99c);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.edit-btn:active:not(:disabled) {
  transform: translateY(0);
}
.edit-btn:disabled {
  background: #d0d0d0;
  cursor: not-allowed;
  opacity: .55;
}

/* 编辑弹窗：通用 modal-overlay 风格 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: overlay-fade .18s ease;
}
@keyframes overlay-fade { from { opacity: 0 } to { opacity: 1 } }
.modal-overlay .modal-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
  padding: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: card-pop .22s cubic-bezier(.34,1.56,.64,1);
  position: relative;  /* 给 .modal-close 绝对定位用 */
}
@keyframes card-pop {
  from { opacity: 0; transform: scale(.9) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-overlay .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #eee;
  background: var(--bg-soft, #faf6ee);
  flex-shrink: 0;
}
.modal-overlay .modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #333);
}
.modal-overlay .modal-close {
  position: absolute;     /* 始终位于右上角 */
  top: 10px;
  right: 12px;
  z-index: 2;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all .15s;
}
.modal-overlay .modal-close:hover { background: rgba(0,0,0,.06); color: #333; }
/* 让标题给 × 留出空间，避免遮挡 */
.modal-overlay .modal-card > h3 { padding-right: 36px; }
.modal-overlay .modal-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-overlay .form-row { margin-bottom: 12px; }
.modal-overlay .info-line {
  font-size: 12px;
  color: var(--text-soft, #777);
  background: var(--bg-soft, #faf6ee);
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-block;
  word-break: break-all;
}
.modal-overlay .edit-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft, #888);
  margin-bottom: 4px;
}
.modal-overlay #edit-tx-amount {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 18px;
  font-weight: 600;
  border: 1.5px solid #e0d8c8;
  border-radius: 8px;
  background: var(--bg-soft, #faf6ee);
  color: var(--text, #333);
  outline: none;
  transition: border-color .15s;
}
.modal-overlay #edit-tx-amount:focus { border-color: var(--primary); background: #fff; }

/* 编辑弹窗里的日期、分类、备注输入 */
.modal-overlay #edit-tx-date,
.modal-overlay #edit-tx-category,
.modal-overlay #edit-tx-note {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  font-size: 14px;
  border: 1.5px solid #e0d8c8;
  border-radius: 8px;
  background: var(--bg-soft, #faf6ee);
  color: var(--text, #333);
  outline: none;
  transition: border-color .15s;
}
.modal-overlay #edit-tx-date:focus,
.modal-overlay #edit-tx-category:focus,
.modal-overlay #edit-tx-note:focus { border-color: var(--primary); background: #fff; }

/* 支付方式切换：两个大按钮 */
.edit-pay-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pay-opt {
  padding: 10px;
  border: 1.5px solid #e0d8c8;
  background: var(--bg-soft, #faf6ee);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-soft, #777);
  transition: all .15s;
  font-weight: 500;
}
.pay-opt:hover:not(.active) { border-color: var(--primary); color: var(--text); }
.pay-opt.active {
  border-color: var(--primary);
  background: var(--primary-light, #d6f2ee);
  color: var(--primary-dark, #14a99c);
  font-weight: 600;
  box-shadow: var(--elev-1);
}

/* 联动提示 */
.edit-delta {
  background: #fff8e1;
  border: 1px dashed #f0c060;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.7;
  color: #5a4500;
  min-height: 20px;
}
.edit-delta:empty { display: none; }
.edit-delta .dim { color: #999; font-style: italic; }
.edit-delta .up { color: #d33; font-weight: 600; }
.edit-delta .down { color: #4a4; font-weight: 600; }

/* msg / 底部按钮 */
.modal-overlay .msg {
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}
.modal-overlay .msg.ok  { color: #4a8a4a; }
.modal-overlay .msg.err { color: #c0392b; }
.modal-overlay .modal-foot {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid #f0f0f0;
  justify-content: flex-end;
  flex-shrink: 0;
}
.modal-overlay .modal-foot button {
  padding: 8px 18px;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  font-weight: 500;
  transition: all .15s;
}
.modal-overlay .modal-foot .secondary { background: #f0f0f0; color: #555; }
.modal-overlay .modal-foot .secondary:hover { background: #e6e6e6; }
.modal-overlay .modal-foot .primary { background: var(--primary); color: #fff; }
.modal-overlay .modal-foot .primary:hover:not(:disabled) { background: var(--primary-dark, #14a99c); }
.modal-overlay .modal-foot .primary:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================ */
/* ========= 全局 Toast（流水编辑等场景）========= */
/* ============================================ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  transition: all .25s ease;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
.toast.ok  { background: #2d7a4e; }
.toast.err { background: #b03a3a; }
.toast.warn { background: #c08425; }
.toast.info { background: #2c5577; }

/* ===== 利息补登弹窗 ===== */
.modal-overlay #modal-interest .modal-card { width: 460px; }
.modal-overlay #modal-interest .form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
#modal-interest .form-row label .hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-soft);
  margin-left: 4px;
}
#modal-interest .form-row select,
#modal-interest .form-row input[type="number"],
#modal-interest .form-row input[type="date"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
#modal-interest .form-row select:focus,
#modal-interest .form-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft, rgba(91,184,168,.15));
}
.date-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-range input[type="date"] { flex: 1; min-width: 0; }
.date-arrow {
  color: var(--text-soft);
  font-size: 14px;
  flex-shrink: 0;
}
.interest-preview {
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary-soft, #f7e9c8) 0%, var(--bg-soft) 100%);
  border: 1.5px dashed var(--primary, #5bb8a8);
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  min-height: 60px;
}
.interest-preview .dim { color: var(--text-soft); font-size: 12px; }
.interest-preview b { font-weight: 600; }
.modal-overlay .interest-foot {
  /* 复用 .modal-overlay .modal-foot 的基础布局 */
  justify-content: flex-end;
}
.modal-overlay .interest-summary {
  flex: 1;
  min-width: 0;
  margin-right: auto;          /* 把按钮顶到右边 */
  font-size: 12px;
  color: var(--text-soft, #888);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
  padding-right: 12px;
  align-self: center;
}

/* ========== 月度汇总：攒钱目标 ========== */
.saving-target-card {
  margin-bottom: 14px;
  padding: 12px 16px 14px;
  background: linear-gradient(135deg, #fffdf5 0%, var(--card) 60%, #fdf3e0 100%);
}
.saving-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.saving-head .saving-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary-dark);
  letter-spacing: .5px;
}
.saving-head .saving-ym {
  font-size: 12px;
  color: var(--text-soft);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 1px 10px;
  font-weight: 600;
}
.saving-set-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.saving-set-row .saving-cur { font-size: 13px; color: var(--text-soft); }
.saving-set-row .saving-cur b { color: var(--primary-dark); font-size: 15px; }
.saving-set-row input[type="number"] {
  width: 130px; padding: 7px 12px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.saving-set-row input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.saving-set-row .saving-save-btn { border-radius: 999px; padding: 7px 18px; font-size: 13px; }
.saving-set-row .saving-del-btn {
  border-radius: 999px; padding: 7px 14px; font-size: 13px;
  background: #fff; color: var(--warn); border: 1.5px solid var(--border);
}
.saving-set-row .saving-del-btn:hover { border-color: var(--warn); }
.saving-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); }
.saving-field select {
  padding: 7px 10px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text); outline: none; cursor: pointer;
}
.saving-field select:focus { border-color: var(--primary); }
.saving-set-row .saving-msg { font-size: 12px; color: var(--warn); }
/* 三个控件（当前目标 / 目标金额 / 按钮组）横向均分整行，右侧不留大片空白 */
.saving-set-row .saving-cur {
  flex: 1 1 0; min-width: 0;
  font-size: 13px; color: var(--text-soft);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 16px;
  display: flex; align-items: center;
}
.saving-set-row input[type="number"] { flex: 1 1 0; width: auto; min-width: 0; }
.saving-set-row .saving-btns { display: flex; gap: 10px; }
td.saving-ok { color: #2e9e5b; font-weight: 600; }
td.saving-bad { color: #d9534f; font-weight: 600; }
td.saving-ok .saving-saying, td.saving-bad .saving-saying { display: block; }
.saving-saying {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-soft);
  margin-top: 2px;
  line-height: 1.3;
}

/* ===== 月度汇总表：列宽均分 =====
   问题：JS 给每个 <col> 写了 inline px 宽度，fixed 布局下 col 优先级高于
   th/td 的 CSS 宽度，且 JS 追加的「攒钱目标/目标差额」两列没有 <col>，导致
   末两列宽度为 0；同时 col 宽度合计 1072px > 容器 1032px，表格反向撑宽 40px。
   对策：
   1) col 宽度一律回退为 auto（!important 压过 inline），让列宽重新由 th/td 决定；
   2) 14 列按实测文本宽显式给百分比，表头 5 字节宽的两列单独放宽，
      不会再出现「末两列独吞空间」，表头文字也不再出省略号；
   3) 文言单行省略（完整文案走 title 提示）。 */
.msum-table {
  min-width: 0 !important;              /* 覆盖 JS 的 inline min-width */
  table-layout: fixed;
  width: 100%;
  font-size: 12.5px;
}
.msum-table col { width: auto !important; }
/* fixed 布局下 max/min-width 不参与列宽计算，清掉避免干扰 */
.msum-table th, .msum-table td {
  padding-left: 4px; padding-right: 4px;
  min-width: 0; max-width: none;
  overflow: hidden; text-overflow: ellipsis;
}
/* 列宽分配：容器 1032px 下按百分比分配，14 列视觉宽度接近一条线。
   实测 13px 字号下「当月总收入/当月总支出」5 个汉字文本宽 65px，加左右 padding 8px
   需 ≥73px 列宽；而 4 字表头只要 60px。
   所以：首列(年月份)压到 6.6%，笔数(2字)5%，攒钱目标(4字)6.6%，目标差额(要塞金额+小文言)8.1%；
   5 字节宽的两列显式给 7.4%≈76px（可用 68px，留 3px 余量，避开亚像素临界）；
   余下 8 个 4 字节宽列自动均分 ≈76px。 */
/* 覆盖 .table-wrap.wide 首列的 min-width:90px，把空间还给金额列 */
.msum-table th:first-child,
.msum-table td:first-child { width: 6.6%; min-width: 68px; max-width: none; }
/* 5 字节宽：必须显式给宽，否则被均分挤到 73px 触发省略号 */
.msum-table th:nth-child(2),
.msum-table td:nth-child(2),
.msum-table th:nth-child(3),
.msum-table td:nth-child(3) { width: 7.4%; }
.msum-table th:nth-child(12),
.msum-table td:nth-child(12) { width: 5%; }   /* 笔数：2 字，压到最窄 */
.msum-table .saving-target-col { width: 6.6%; }  /* 4 字 */
.msum-table .saving-diff-col { width: 8.1%; }
.msum-table .saving-diff-col .saving-saying {
  display: block;
  white-space: normal;      /* 完整显示：小文言是完整一句话，截断了读不通 */
  overflow: visible;
  text-overflow: clip;
  font-size: 11px;
  line-height: 1.5;
  word-break: break-word;
}

/* ========== 花呗专项：一键还清当月 ========== */
.huabei-repay-bar {
  /* 继承 .card 的圆角/阴影/clip-path；标题栏直接复用 .card .title */
  border: 1px solid var(--primary);
  box-shadow: var(--elev-primary, 0 6px 18px rgba(255, 154, 118, .25));
  margin-bottom: 14px;
}
body.theme-maojin .huabei-repay-bar {
  border-color: #ff9a76;
}
.huabei-repay-bar > .title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.huabei-repay-sub {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 400;
  margin-left: auto;
}
.huabei-repay-sub b {
  color: #d97706;
  font-size: 14px;
  margin-left: 4px;
  font-weight: 600;
}
.huabei-repay-body {
  padding: 14px 16px;
}
.huabei-repay-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.huabei-repay-grid > div {
  background: rgba(255,255,255,.7);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  min-width: 0;
}
.huabei-repay-grid .lbl { display: block; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.huabei-repay-grid .val { font-size: 17px; font-weight: 600; color: var(--text); word-break: break-all; }
.huabei-repay-grid .val.primary { color: #d97706; }
.huabei-repay-foot {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.huabei-repay-foot .tip { color: var(--text-soft); font-size: 12px; flex: 1 1 200px; min-width: 0; }
.huabei-repay-foot button { flex-shrink: 0; white-space: nowrap; }
.huabei-repay-btns { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.huabei-repay-btns .secondary {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border);
}
.huabei-repay-btns .secondary:hover { background: var(--card); border-color: var(--primary); }

/* ========== 花呗专项：批量还款弹窗 ========== */
/* 宽度要压过 `.modal-overlay .modal-card { width: 360px }`（0,2,0），
   这里用 0,3,0 的 `.modal-overlay .repay-batch-card`。 */
.modal-overlay .repay-batch-card { width: 520px; max-width: 92vw; }
.repay-batch-card h3 { margin: 0; padding: 18px 20px 0; font-size: 16px; }
.repay-batch-tip {
  padding: 8px 20px 0;
  color: var(--text-soft); font-size: 12.5px; line-height: 1.6;
}
.repay-batch-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px 8px;
}
.repay-batch-toolbar .ghost.small {
  min-height: 32px; padding: 0 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--bg-soft); color: var(--text-soft);
}
.repay-batch-toolbar .ghost.small:hover { border-color: var(--primary); color: var(--primary); }
.rb-count {
  margin-left: auto; font-size: 13px; color: var(--text-soft);
  white-space: nowrap;
}
.rb-count b { color: var(--num); font-weight: 700; }
.repay-batch-list {
  /* 可压缩的 flex 子项：卡片高度不够时它内部滚动，
     保证底部「确认还款」按钮始终留在可视区内。 */
  flex: 1 1 auto; min-height: 120px;
  max-height: 40vh; overflow-y: auto;
  margin: 0 20px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-soft);
}
.repay-batch-list .rb-item {
  /* 特异性要压过 `.modal-card label`（display:block; margin-bottom:12px），
     且必须显式写 flex-direction:row —— 竖排会把整行撑得很高。 */
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  margin-bottom: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-height: var(--touch-min);
  font-weight: 400;
}
.repay-batch-list .rb-item:last-child { border-bottom: none; }
.repay-batch-list .rb-item:hover { background: var(--card); }
.repay-batch-list .rb-item input[type="checkbox"] {
  width: 20px; height: 20px; min-width: 20px; flex-shrink: 0;
  margin: 0;
  accent-color: var(--primary);
}
.rb-idx {
  font-size: 11px; color: var(--muted, var(--text-soft));
  flex-shrink: 0; min-width: 34px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.rb-date {
  font-size: 12px; color: var(--text-soft); flex-shrink: 0;
  font-variant-numeric: tabular-nums; width: 42px;
}
.rb-note {
  flex: 1 1 auto; min-width: 0;
  font-size: 14px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rb-amt {
  flex-shrink: 0; font-size: 14px; font-weight: 600;
  color: var(--num); font-variant-numeric: tabular-nums;
}
.repay-batch-card .modal-body {
  display: flex; flex-direction: column; gap: 12px;
  /* 表单区不参与压缩，底部按钮始终可见 */
  flex: 0 0 auto;
}
/* 只让表单区（还款日期/账户/备注）的 label 竖排；
   勾选清单里的 .rb-item 是 label 元素，必须保持横排。 */
.repay-batch-card .modal-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); }
.repay-batch-card .modal-body label span { font-size: 12px; }
.repay-batch-card input, .repay-batch-card select {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; background: #fff;
}
.repay-batch-card .modal-foot { padding: 14px 20px 18px; }

/* 弹窗 */
.repay-month-card { width: 460px; max-width: 92vw; }
.repay-month-card h3 { margin: 0 0 16px; font-size: 16px; }
.repay-month-card .modal-body { display: flex; flex-direction: column; gap: 12px; }
.repay-month-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); }
.repay-month-card label span { font-size: 12px; }
.repay-month-card input, .repay-month-card select {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; background: #fff;
}
.repay-preview {
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: 6px;
}
.repay-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 13px; color: var(--text);
}
.repay-row b { font-weight: 600; }
.repay-diff {
  border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 8px;
}
.repay-diff b { color: #d97706; font-size: 16px; }
.repay-hint {
  background: #fff8e6; border: 1px solid #f3d794;
  border-radius: var(--r-md); padding: 8px 12px;
  font-size: 12px; color: #8a6d3b;
}
.repay-hint b { color: #d97706; font-size: 14px; }
.repay-month-card .modal-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 8px;
}
.repay-month-card .modal-foot button[disabled] { opacity: .5; cursor: not-allowed; }
/* ========== 过滤工具条（流水明细 / 花呗专项） ========== */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px; padding: 8px 12px;
  margin: 4px 0 8px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(120,140,180,0.18);
  border-radius: 10px;
}
.filter-bar .fb-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: #4a5568;
}
.filter-bar .fb-item input[type="date"],
.filter-bar .fb-item input[type="search"],
.filter-bar .fb-item select {
  padding: 4px 8px; border: 1px solid rgba(120,140,180,0.35);
  border-radius: 6px; font-size: 13px; background: #fff;
  outline: none; transition: border-color .15s;
}
.filter-bar .fb-item input:focus, .filter-bar .fb-item select:focus { border-color: #5a9ad8; }
.filter-bar .fb-item.fb-note input { width: 200px; }
.filter-bar .fb-reset {
  padding: 4px 12px; font-size: 13px;
}
.filter-bar .fb-summary {
  margin-left: auto; font-size: 12px; color: #d97706;
}
@media (max-width: 720px) {
  .filter-bar .fb-item.fb-note input { width: 140px; }
}

/* ========== 花呗专项 · 批量还款（窄屏适配） ========== */
@media (max-width: 720px) {
  .huabei-repay-btns { width: 100%; }
  .huabei-repay-btns button {
    flex: 1 1 0; min-height: var(--touch-min); font-size: 14px;
  }
  /* 弹窗改成接近全屏的抽屉，方便单手勾选 */
  .modal-overlay .repay-batch-card {
    width: 100%; max-width: 100%;
    /* 必须覆盖 `.modal-overlay .modal-card { height: 100vh }`：
       固定 100vh 会把底部「确认还款」按钮挤出屏幕且 overflow:hidden 裁掉。 */
    height: auto;
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  }
  /* 勾选清单：窄屏取消 40vh 上限，交给 flex 分配剩余空间 */
  .repay-batch-list {
    max-height: none;
  }
  /* 表单区固定在卡片底部，不参与压缩 */
  .repay-batch-card .modal-body {
    overflow: visible;
  }
  .repay-batch-card h3 { padding: 16px 16px 0; font-size: 16px; }
  .repay-batch-tip { padding: 8px 16px 0; }
  .repay-batch-toolbar { padding: 12px 16px 8px; gap: 6px; }
  .repay-batch-toolbar .ghost.small {
    flex: 1 1 0; min-height: var(--touch-min); font-size: 14px;
  }
  .rb-count {
    margin-left: 0; width: 100%; text-align: center;
    font-size: 14px; padding-top: 2px;
  }
  .repay-batch-list {
    margin: 0 16px; max-height: 42dvh; -webkit-overflow-scrolling: touch;
  }
  .repay-batch-list .rb-item { padding: 12px; }
  .repay-batch-list .rb-item input[type="checkbox"] { width: 22px; height: 22px; min-width: 22px; }
  .rb-date { font-size: 13px; width: 46px; }
  .rb-idx { font-size: 11.5px; min-width: 36px; }
  .rb-note { font-size: 15px; }
  .rb-amt { font-size: 15px; }
  .repay-batch-card .modal-body { padding: 16px; }
  .repay-batch-card .modal-body label { font-size: 14px; }
  .repay-batch-card input, .repay-batch-card select {
    min-height: var(--touch-min); font-size: 16px; width: 100%; box-sizing: border-box;
  }
  .repay-batch-card .modal-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  .repay-batch-card .modal-foot button {
    flex: 1 1 0; min-height: var(--touch-min); font-size: 15px;
  }
}
/* ========== 鼠标跟随猫爪印 ========== */
.paw-layer {
  position: fixed; inset: 0;
  pointer-events: none;       /* 不挡鼠标事件 */
  z-index: 50;                /* 高于普通内容 (auto)，低于 modal (.modal=100, .modal-overlay=1000) */
  overflow: hidden;
}
.paw-print {
  position: absolute;
  font-size: 18px; line-height: 1;
  user-select: none;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.4);
  opacity: 0;
  animation: paw-print 1.2s ease-out forwards;
  filter: drop-shadow(0 1px 2px rgba(120, 90, 60, .15));
}
@keyframes paw-print {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.4); }
  18%  { opacity: 0.85; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.15); }
  35%  { opacity: 0.6; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 22px)) rotate(var(--rot, 0deg)) scale(0.85); }
}

/* ========== 空状态萌化 ========== */
.empty-cute {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 36px 20px; gap: 12px;
  color: #7b6b58; text-align: center;
}
.empty-cute .empty-cute-icon {
  font-size: 56px;
  animation: empty-cute-breathe 2.4s ease-in-out infinite;
}
@keyframes empty-cute-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.05); }
}
.empty-cute .empty-cute-title { font-size: 16px; font-weight: 600; color: #5a4a3a; }
.empty-cute .empty-cute-tip   { font-size: 13px; color: #8a7a68; }
.empty-cute .empty-cute-btn {
  margin-top: 4px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #ffb56b, #ff8a5b);
  color: #fff; border: none; border-radius: 999px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 138, 91, 0.35);
  transition: transform .15s ease, box-shadow .15s ease;
}
.empty-cute .empty-cute-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 138, 91, 0.45); }
.empty-cute .empty-cute-btn:active { transform: translateY(0); }
/* ========== C-1 顶部统计小条幅 ========== */
.stats-strip {
  max-width: 1200px; margin: 8px auto 0; padding: 8px 14px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: rgba(255,255,255,.65);
  border: 1px solid rgba(180,160,130,.25);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  font-size: 13px; color: #5a4a3a;
  box-shadow: 0 2px 6px rgba(120,90,60,.08);
}
.ss-item { display: inline-flex; align-items: baseline; gap: 6px; }
.ss-icon { font-size: 16px; }
.ss-label { color: #8a7a68; font-size: 12px; }
.ss-val b { color: #5a4a3a; font-size: 16px; font-weight: 700; }
.ss-val b.ss-pop { animation: ss-pop .5s ease-out; }
@keyframes ss-pop { 0% { transform: scale(1); } 30% { transform: scale(1.25); color: #ff8a5b; } 100% { transform: scale(1); } }
.ss-sub { color: #b87a3a; font-weight: 600; }
.ss-diff { padding: 0 10px; border-left: 1px solid rgba(180,160,130,.3); border-right: 1px solid rgba(180,160,130,.3); }
.ss-arrow { color: #b8a78b; }
.ss-diff-val { font-weight: 600; }
.ss-diff-val.up   { color: #2e9a6a; }
.ss-diff-val.down { color: #c45a4a; }
.ss-diff-val.flat { color: #8a7a68; }
.ss-msg { margin-left: auto; font-size: 12px; color: #8a7a68; }
@media (max-width: 720px) {
  .stats-strip { padding: 6px 10px; gap: 6px; font-size: 12px; }
  .ss-val b { font-size: 14px; }
  .ss-diff { padding: 0 6px; }
}

/* ========== C-2 tab 摇动 ========== */
#tabs button:hover {
  animation: tab-wiggle .4s ease-in-out;
}
@keyframes tab-wiggle {
  0%, 100% { transform: translateY(0) rotate(0); }
  20%      { transform: translateY(-2px) rotate(-1.5deg); }
  50%      { transform: translateY(-2px) rotate(1.5deg); }
  80%      { transform: translateY(-1px) rotate(-0.5deg); }
}
#tabs button.active { animation: none; }   /* 当前激活 tab 不再触发 */

/* ========== C-3 新流水 toast 提醒 ========== */
.new-tx-badge {
  position: absolute; top: -6px; right: -6px;
  background: linear-gradient(135deg, #ff8a5b, #ff5b5b);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(255, 91, 91, .5);
  animation: badge-pop .35s ease-out;
  pointer-events: none;
}
@keyframes badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ========== C-4 里程碑庆祝 banner ========== */
.milestone-banner {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #ffd86b, #ff8a5b);
  color: #fff; font-size: 16px; font-weight: 700;
  padding: 14px 24px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(255, 138, 91, .35);
  z-index: 1500;
  display: flex; align-items: center; gap: 10px;
  animation: milestone-in .55s cubic-bezier(.2, 1.5, .4, 1) forwards;
}
.milestone-banner.leave { animation: milestone-out .35s ease-in forwards; }
@keyframes milestone-in {
  0% { transform: translateX(-50%) translateY(-80px) scale(.6); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
@keyframes milestone-out {
  0% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-80px) scale(.8); opacity: 0; }
}
.milestone-banner .ms-emoji { font-size: 26px; }
.milestone-banner .ms-close { background: rgba(255,255,255,.25); border: none; color: #fff; padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: 12px; }

/* 全屏彩带 */
.celebrate-emoji {
  position: fixed;
  font-size: 22px;
  pointer-events: none; z-index: 1499;
  animation: celebrate-fly 1.6s ease-out forwards;
}
@keyframes celebrate-fly {
  0%   { transform: translate(0, 0) scale(.4) rotate(0); opacity: 0; }
  20%  { opacity: 1; transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); }
  100% { transform: translate(calc(var(--dx) * 2), calc(var(--dy) * 2 + 200px)) scale(.6) rotate(calc(var(--rot) * 2)); opacity: 0; }
}

/* ===== 用户编辑弹窗宽度（置于文件末尾以覆盖 .modal-card 的 360px） ===== */
.ua-sub-overlay .ua-edit-card {
  width: min(1080px, 97vw);
  max-width: 97vw;
}
/* 底部按钮常驻：form 不再整体滚动，改由权限列表滚动 */
.ua-sub-overlay .ua-edit-card form {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}
.ua-edit-card .ua-perm-card { display: flex; flex-direction: column; min-height: 0; }
.ua-sub-overlay .ua-edit-card .ua-perm-list { max-height: none; flex: 1 1 auto; min-height: 120px; }


/* ==================================================================
   移动端适配层（微信级）—— 置于文件末尾以覆盖桌面基线
   基准：390–430px 视口，48dp 触控目标，viewport-fit=cover 安全区
   ================================================================== */

/* ---------- 0. 安全区变量（全局，桌面端 env() 自动回退 0） ---------- */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 0px;          /* 桌面端为 0，移动端由 --tabbar-h-real 覆盖 */
  --tabbar-h-real: 0px;
  --touch-min: 44px;        /* 触控最小热区 */
}

/* ---------- 1. 顶栏：只留 Logo + 标题 + 账号图标 ---------- */
@media (max-width: 720px) {
  header {
    padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 12px) 8px calc(var(--safe-l) + 12px);
    min-height: 50px;
    gap: 8px;
    flex-wrap: nowrap;              /* 关键修复：不再换行，按钮不再被挤出左边缘 */
    align-items: center;
  }
  header h1 {
    font-size: 17px; font-weight: 700; letter-spacing: .3px;
    white-space: nowrap;          /* 标题不换行（否则被挤成竖排）*/
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
  }
  header h1::before { content: none; }   /* 去掉 📒 前缀，Logo 图已足够 */
  .theme-logo-img { width: 30px; height: 30px; flex-shrink: 0; }

  .header-actions {
    width: auto;                     /* 覆盖桌面 width:100% */
    flex: 0 0 auto;
    margin-left: auto;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: flex-end;
  }
  /* 录入/批量/利息/账单导入 已下沉到底部导航（记账凸起键 + 更多面板），
     顶栏在窄屏只保留账号图标、购物车与工具箱 —— 否则按钮会占满整行把标题挤没 */
  .header-actions > #btn-add,
  .header-actions > #btn-add-batch,
  .header-actions > #btn-add-interest,
  .header-actions > #btn-alipay-import { display: none !important; }

  .header-actions > button,
  .header-actions > .header-app-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0 !important;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
    font-size: 17px;
    box-shadow: var(--elev-1);
    position: relative;
  }
  /* 文字内容用字号 0 + emoji 恢复的方式隐藏，避免按钮空白 */
  .header-actions > button { font-size: 0; }
  .header-actions > button::before { font-size: 17px; line-height: 1; }
  /* 显式给每个按钮恢复图标的 ::before 字符 */
  #btn-account::before     { content: '\1F464'; }     /* 账号：人像 */
  #btn-account .account-name { display: none; }
  /* 有自定义头像时，用头像替代人像 emoji */
  #btn-account.has-avatar::before { content: none; }
  #btn-account.has-avatar { padding-left: 0; padding-right: 0; }
  #btn-account.has-avatar .account-avatar { width: 24px; height: 24px; font-size: 12px; }
  #btn-account.is-admin { box-shadow: var(--elev-primary); }

  .header-actions .gba-btn-label { display: none; }
  .header-actions .gba-btn-icon { display: flex; }
  .gba-btn-dot { top: 2px; right: 2px; }
  /* 游戏厅 / 账单导入 的 SVG 图标在圆形按钮里居中 */
  #btn-gba .gba-btn-icon svg,
  #btn-alipay-import .gba-btn-icon svg { width: 19px; height: 19px; }

  /* 账号面板（居中弹窗）：窄屏下加大点击区 */
  .account-panel-list button { min-height: var(--touch-min); }
}

/* ---------- 2. 主体：留出底部 Tab 栏空间 ---------- */
@media (max-width: 720px) {
  :root { --tabbar-h-real: calc(58px + var(--safe-b)); }
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }

  /* B2：统计条改成三张等宽小卡片（今日 / 较昨日 / 本月），一屏读完，不再横滑 */
  #stats-strip.stats-strip {
    max-width: none;
    margin: 0;
    padding: 8px 10px 9px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    font-size: 12px;
    border-radius: 0;
    border-left: none; border-right: none;
    box-shadow: none;
  }
  #stats-strip .ss-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1px;
    min-width: 0;
    min-height: 54px;
    padding: 6px 4px;
    text-align: center;
    white-space: normal;
    background: var(--card);
    border: var(--stroke-soft);
    border-radius: 12px;
    box-shadow: var(--elev-1);
  }
  /* 小卡里图标/箭头冗余，靠上方的文字标签定位就够了 */
  #stats-strip .ss-icon, #stats-strip .ss-arrow { display: none; }
  #stats-strip .ss-label, #stats-strip .ss-diff-label {
    font-size: 11px; color: var(--muted); white-space: nowrap;
  }
  #stats-strip .ss-val { display: inline-flex; align-items: baseline; gap: 2px; font-size: 11px; color: var(--text-soft); }
  #stats-strip .ss-val b { font-size: 17px; line-height: 1.15; color: var(--text); }
  #stats-strip .ss-sub {
    font-size: 11px; font-weight: 700; color: var(--text);
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #stats-strip [data-ss="diff-count"] { font-size: 15px; font-weight: 700; color: var(--text-soft); }
  /* 「↑多花¥1234.56」最长，超出省略号兜底，颜色仍由 .up/.down/.flat 决定 */
  #stats-strip [data-ss="diff-amount"] {
    font-size: 11px; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #stats-strip .ss-msg {
    grid-column: 1 / -1;
    margin-left: 0; padding: 0 2px;
    font-size: 11px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  /* 没有里程碑/提示文案时整行消失，别在卡片下面留一条空隙 */
  #stats-strip .ss-msg:empty { display: none; }

  /* 旧的顶部胶囊页签在移动端隐藏，改用底部 Tab 栏 */
  nav#tabs { display: none; }

  main {
    padding: 12px 12px calc(var(--tabbar-h-real) + 16px);
    max-width: none;
  }
  main > * { max-width: none; }
}

/* ---------- 3. 底部 Tab 栏 + 中间凸起录入键 ---------- */
.mobile-tabbar {
  display: none;
}
@media (max-width: 720px) {
  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(58px + var(--safe-b));
    padding-bottom: var(--safe-b);
    padding-left: var(--safe-l);
    padding-right: var(--safe-r);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--stroke);
    box-shadow: 0 -2px 16px rgba(120, 100, 60, .1);
    z-index: 900;
    align-items: stretch;
  }
  .mtb-item {
    flex: 1 1 0;
    min-width: 0;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px 4px;
    color: var(--text-soft);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mtb-item .mtb-ico {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    transition: transform .22s cubic-bezier(.34, 1.56, .64, 1);
  }
  .mtb-item .mtb-ico img { width: 22px; height: 22px; object-fit: contain; }
  .mtb-item.active { color: var(--primary); font-weight: 700; }
  .mtb-item.active .mtb-ico { transform: translateY(-2px) scale(1.12); }
  /* A4：切 tab 时当前图标弹一下，让「我在这儿」有明确反馈 */
  .mtb-item.active .mtb-ico.mtb-pop { animation: mtb-ico-pop .34s cubic-bezier(.34, 1.56, .64, 1); }
  @keyframes mtb-ico-pop {
    0%   { transform: translateY(-2px) scale(1); }
    38%  { transform: translateY(-7px) scale(1.22); }
    100% { transform: translateY(-2px) scale(1.12); }
  }
  .mtb-item:active { opacity: .6; }

  /* 中间凸起录入键 */
  .mtb-item.mtb-fab {
    flex: 0 0 auto;
    width: 62px;
    position: relative;
  }
  .mtb-fab-inner {
    position: absolute;
    left: 50%;
    top: -20px;
    transform: translateX(-50%);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 42%, transparent);
    border: 3px solid var(--card);
    transition: transform .12s;
  }
  .mtb-fab-inner:active { transform: translateX(-50%) scale(.92); }
  .mtb-fab-label {
    margin-top: 26px;
    font-size: 10px;
    font-weight: 600;
    color: var(--primary);
  }
}

/* ---------- 4. 全部视图表格 → 卡片列表 ---------- */
@media (max-width: 720px) {
  /* 4.1 解除逐字竖排的根源：全局 nowrap + 固定列宽
     overflow-wrap 不能用 anywhere：它会把 min-content 压到 1 个字符，
     导致「2026-10-03」被逐字拆成 202 / 6- / 10- / 03。break-word 只在整行放不下时才断。 */
  th, td {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    max-width: 100%;
    max-height: none;
    text-align: left;
  }
  th, td { padding: 6px 0; }

  /* 4.2 所有 table 一律卡片化（含 wide 表） */
  .table-wrap { overflow-x: visible !important; max-width: 100%; }
  /* wide 表的固定首列在卡片模式下只解除粘附，不改宽度（改 0 会把「编号」列压没） */
  .table-wrap.wide table { min-width: 0 !important; }
  .table-wrap.wide col:first-child,
  .table-wrap.wide th:first-child,
  .table-wrap.wide td:first-child {
    position: static !important;
    box-shadow: none !important;
    min-width: 0 !important;
  }
  /* 序号列之后的「日期」列在桌面端是 sticky 吸附列（横向滚动时固定在左侧），
     但卡片模式下每一行本来就是独立的横排，日期列再吸附就会盖住右边备注的首字
     （实测「宠物医保」被切成「物医保」）。这里把吸附彻底解除。 */
  .table-wrap.wide th.idx-col + th,
  .table-wrap.wide td.idx-col + td {
    position: static !important;
    left: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
  }

  table.responsive-table,
  table.responsive-table tbody,
  table.responsive-table tr,
  table.responsive-table td,
  table.responsive-table th { display: block; width: 100%; }

  table.responsive-table thead { display: none; }
  table.responsive-table colgroup { display: none; }

  table.responsive-table tr {
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    margin-bottom: 10px;
    border: 1px solid var(--stroke);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--card);
    box-shadow: var(--elev-1);
    position: relative;
    overflow: hidden;
  }
  table.responsive-table tr:hover { background: var(--card); }

  /* 卡片内单元格：默认两列小格（微信账单的信息密度）
     用 flex-basis 锁定尺寸而非 width：各视图的桌面表格（如 .msum-table）
     给列设了百分比 width，卡片化后百分比会按 330px 容器重算成 20~25px，
     把标签压成竖排；flex-basis 是 flex 主轴尺寸，不受那些 width 影响。 */
  table.responsive-table td {
    display: block;
    flex: 0 0 calc(50% - 5px);
    min-width: 0;
    padding: 6px 0;
    border-bottom: none;
    text-align: left !important;
    font-size: 14px;
    min-height: 0;
    line-height: 1.45;
    overflow-wrap: break-word;
    box-sizing: border-box;
  }
  table.responsive-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 500;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 1px;
    max-width: none;
    text-align: left;
  }
  /* 无标签的单元格（如快速添加行）不显示空标签位 */
  table.responsive-table td:not([data-label])::before { content: none; }

  /* 隐藏档：主键 / 数据来源 / 统计口径等内部字段不上手机端（桌面端不受影响） */
  table.responsive-table td.mb-hide { display: none !important; }

  /* 主档：日期 / 金额 等独占整行，左标签右数值 */
  table.responsive-table td.mb-lead {
    flex: 0 0 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    margin-bottom: 6px;
    border-bottom: 1px dashed var(--stroke-soft);
  }
  table.responsive-table td.mb-lead::before {
    display: inline;
    font-size: 13px;
    margin-bottom: 0;
    flex: 0 0 auto;
  }
  table.responsive-table td.mb-lead > * { min-width: 0; }

  /* 首个主档字段作卡片标题：日期 / 年月 / 年份 */
  table.responsive-table td.mb-lead:first-of-type { font-weight: 700; font-size: 15px; }
  /* 金额作为主数值突出 */
  table.responsive-table td.mb-lead.num,
  table.responsive-table td[data-label="金额"] { font-size: 17px; }
  table.responsive-table td.num { font-weight: 700; font-variant-numeric: tabular-nums; }
  /* 无值字段（如汇总行没有「账户类型」）整行隐藏，卡片只留有内容的项 */
  table.responsive-table td.blank { display: none !important; }

  /* 长文本（备注 / 说明）独占整行 */
  table.responsive-table td.mb-grid[data-label="备注"],
  table.responsive-table td.mb-grid[data-label="总收入说明"],
  table.responsive-table td.mb-grid[data-label="总支出说明"] {
    flex: 0 0 100%;
  }

  /* 4.4 操作列按钮撑满卡片底部 */
  table.responsive-table td.mb-act {
    flex: 0 0 100%;
    padding-top: 10px;
  }
  table.responsive-table td.mb-act::before { content: none; }
  table.responsive-table .edit-btn,
  table.responsive-table .cat-detail-btn,
  table.responsive-table td.mb-act button,
  table.responsive-table td:last-child button {
    width: 100%;
    min-height: 38px;   /* 与第 8 节按钮统一尺寸 */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 4.5 空值单元格弱化 */
  table.responsive-table td.muted { color: var(--muted); }

  /* ---------- 4.55 B1 流水类视图：一笔压成一行，点整行展开其余字段 ---------- */
  /* 只在窄屏卡片化里生效，桌面端 table 仍是普通多列表格 */
  table.responsive-table.mb-tx > tbody > tr {
    padding: 0 12px;
    margin-bottom: 8px;
    min-height: 50px;
    gap: 0;
    align-items: center;
    flex-wrap: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  table.responsive-table.mb-tx > tbody > tr:active { background: var(--bg-soft); }

  /* 行尾展开箭头（tr 已是 flex，伪元素即成一个 flex 项） */
  table.responsive-table.mb-tx > tbody > tr::after {
    content: '⌄';
    order: 4;
    flex: 0 0 auto;
    margin-left: 4px;
    font-size: 13px;
    line-height: 1;
    color: var(--muted);
    transition: transform .2s ease;
  }

  /* 首行三件套不显示字段标签，直接读值
     width:auto 是必需的：通用规则给所有 td 设了 width:100%，
     而 flex-basis:auto 会回落到 width，三个格子会各撑满一行把彼此挤掉 */
  table.responsive-table.mb-tx td.mb-x-date,
  table.responsive-table.mb-tx td.mb-x-amt,
  table.responsive-table.mb-tx td.mb-x-note {
    padding: 0;
    width: auto;
  }
  table.responsive-table.mb-tx td.mb-x-date::before,
  table.responsive-table.mb-tx td.mb-x-amt::before,
  table.responsive-table.mb-tx td.mb-x-note::before { content: none; }

  table.responsive-table.mb-tx > tbody > tr::after {
    width: auto;
  }

  table.responsive-table.mb-tx td.mb-x-date {
    order: 1;
    flex: 0 0 auto;
    font-size: 12.5px;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
  }
  /* 花呗专项排序号：窄屏下作为首行最左侧的小徽标 */
  /* 窄屏是卡片布局，fixed 表格布局不适用 */
  table.responsive-table.tx-indexed { table-layout: auto; width: 100%; min-width: 0; }
  table.responsive-table.mb-tx td.idx-col {
    order: 0;
    flex: 0 0 auto;
    width: auto; max-width: none; min-width: 0;
    padding: 0 6px 0 0;
    font-size: 11.5px;
    color: var(--muted);
    text-align: left !important;
  }
  table.responsive-table.mb-tx td.idx-col::before { content: none; }
  table.responsive-table.mb-tx td.mb-x-note {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table.responsive-table.mb-tx td.mb-x-note.muted {
    font-weight: 500;
    color: var(--muted);
  }
  table.responsive-table.mb-tx td.mb-x-amt {
    order: 3;
    flex: 0 0 auto;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  /* 折叠态：次要字段与操作按钮一律不显示 */
  table.responsive-table.mb-tx td.mb-x-more,
  table.responsive-table.mb-tx td.mb-act { display: none; }
  table.responsive-table.mb-tx td.mb-x-dup { display: none !important; }

  /* 展开态：先插一个整行高的空 flex 项换行，再把次要字段排成两列 */
  table.responsive-table.mb-tx > tbody > tr.x-open {
    align-items: flex-start;
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  table.responsive-table.mb-tx > tbody > tr.x-open::before {
    content: '';
    order: 5;
    flex: 0 0 100%;
    height: 0;
  }
  table.responsive-table.mb-tx tr.x-open td.mb-x-more {
    display: block;
    order: 10;
    flex: 0 0 calc(50% - 6px);
    padding: 7px 0 0;
    font-size: 13px;
  }
  table.responsive-table.mb-tx tr.x-open td.mb-x-more:nth-child(even) { margin-left: 12px; }
  table.responsive-table.mb-tx tr.x-open td.mb-x-more::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    line-height: 1.4;
    color: var(--text-soft);
    margin-bottom: 1px;
  }
  table.responsive-table.mb-tx tr.x-open td.mb-act {
    display: block;
    order: 20;
    flex: 0 0 100%;
    padding-top: 10px;
  }
  table.responsive-table.mb-tx tr.x-open .edit-btn {
    width: 100%;
    min-height: 38px;   /* 与第 8 节按钮统一尺寸 */
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 4.6 余额看板的卡片网格 */
  .balance-grid { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .balance-grid .card { margin-bottom: 0; }

  /* 4.7 各视图内嵌的横向表单（攒钱目标设置等）改单列堆叠，避免窄屏挤成竖排 */
  .saving-set-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: center;
  }
  .saving-set-row > * { min-width: 0; }
  .saving-set-row .saving-field { display: flex; align-items: center; gap: 8px; }
  .saving-set-row .saving-field select { flex: 1 1 auto; min-width: 0; }
  .saving-set-row .saving-cur {
    grid-column: 1 / -1;
    order: -1;
    padding: 7px 14px;
    justify-content: center;
  }
  .saving-set-row input[type="number"] { width: 100%; }
  .saving-set-row .saving-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  /* 按钮文案不折行：窄屏两列各约 150px，「保存目标」四字放得下 */
  .saving-set-row .saving-btns .toggle-btn { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
  .saving-set-row .saving-msg { grid-column: 1 / -1; text-align: center; }

  /* 4.8 批量录入 → 记账页式连续录入（仿钱迹/随手记）：
     <=720px 完全隐藏桌面表格区，改用 #batch-mobile 全屏录入页（大金额 + 分类 chips + 内置数字键盘）。 */
  #modal-batch .modal-card.modal-batch h2,
  #modal-batch .modal-card.modal-batch .hint,
  #modal-batch .batch-common,
  #modal-batch .batch-table-wrap,
  #modal-batch .batch-add-row,
  #modal-batch .batch-summary,
  #modal-batch .actions { display: none !important; }
  #modal-batch .modal-card.modal-batch {
    display: flex; flex-direction: column;
    height: calc(100dvh - var(--tabbar-h-real) - 64px);
    max-height: none; overflow: hidden;
    padding-bottom: calc(10px + var(--safe-b));
  }
  #modal-batch #form-batch {
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
  }
  .batch-mobile {
    display: flex; flex-direction: column; gap: 8px;
    flex: 1 1 auto; min-height: 0; position: relative;
  }
  /* 顶栏：关闭 / 待存清单开关 / 保存全部 */
  .mb-bar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .mb-x {
    flex: 0 0 auto; width: 38px; height: 38px; padding: 0;
    border-radius: var(--r-pill); border: 1px solid var(--stroke);
    background: var(--bg-soft); color: var(--text-soft); font-size: 15px;
  }
  .mb-toggle {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px;
    min-height: var(--touch-min); padding: 0 12px;
    border-radius: var(--r-pill); border: 1px solid var(--stroke);
    background: var(--card); color: var(--text); font-size: 14px;
  }
  .mbt-label { flex: 0 0 auto; color: var(--text-soft); }
  .mbt-count { flex: 0 0 auto; }
  .mbt-count b { color: var(--num); font-weight: 700; }
  .mb-toggle .mbt-sum {
    flex: 1 1 auto; min-width: 0; text-align: right;
    color: var(--num); font-weight: 600; font-variant-numeric: tabular-nums;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mb-toggle .mbt-caret { flex: 0 0 auto; transition: transform 0.18s; color: var(--muted); }
  .mb-toggle.open .mbt-caret { transform: rotate(180deg); }
  .mb-save { flex: 0 0 auto; min-height: var(--touch-min); padding: 0 18px; border-radius: var(--r-pill); font-size: 15px; font-weight: 600; white-space: nowrap; }
  /* 待存清单：悬浮下拉，点行取回编辑，✕ 删除 */
  .mb-list {
    position: absolute; left: 0; right: 0; top: 54px; z-index: 6;
    max-height: 28dvh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px;
    background: var(--card); border: 1px solid var(--stroke); border-radius: 12px;
    box-shadow: 0 10px 28px rgba(87, 74, 58, 0.18); padding: 6px;
  }
  .mb-li {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 8px; border-radius: 10px; font-size: 14px; color: var(--text);
  }
  .mb-li:active { background: var(--row-hover); }
  .mbli-idx { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
  .mbli-cat { flex: 0 1 auto; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mbli-hb { flex: 0 0 auto; color: var(--warn); font-weight: 600; font-size: 12px; }
  .mbli-note { flex: 0 1 auto; max-width: 24%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
  .mbli-amt { flex: 0 0 auto; margin-left: auto; font-weight: 600; color: var(--num); }
  .mbli-x { flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border: none; background: transparent; color: var(--muted); font-size: 15px; }
  .mb-li-empty { padding: 14px 8px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
  /* 公共行：日期 / 支出收入切换 / 归属人（不换行，日期自适应占剩余空间） */
  .mb-common { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .mb-date {
    flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 6px 8px; font-size: 14px;
    border: 1px solid var(--stroke); border-radius: 10px; background: var(--card); color: var(--text);
  }
  .mb-seg { flex: 0 0 auto; display: flex; border: 1px solid var(--stroke); border-radius: var(--r-pill); overflow: hidden; }
  .mb-seg button { min-height: 40px; padding: 0 14px; border: none; background: var(--bg-soft); color: var(--text-soft); font-size: 14px; white-space: nowrap; }
  .mb-seg button.on { background: var(--primary); color: #fff; font-weight: 600; }
  .mb-member {
    flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 6px 8px; font-size: 14px;
    border: 1px solid var(--stroke); border-radius: 10px; background: var(--card); color: var(--text);
  }
  /* 金额显示行 */
  .mb-amount {
    flex: 0 0 auto; display: flex; align-items: baseline; gap: 4px;
    padding: 2px 4px 0; font-size: 36px; font-weight: 700; color: var(--text); min-height: 50px;
  }
  .mb-amount .mb-cur { font-size: 20px; color: var(--muted); font-weight: 500; }
  #mb-amount-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #mb-amount-val.is-zero { color: var(--muted); font-weight: 500; }
  /* 分类：自动换行网格，所有分类全部可见，不再横滑截断 */
  .mb-cats {
    flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px;
    padding: 2px 0 4px;
  }
  .mb-chip {
    flex: 0 0 auto; max-width: 100%; min-height: 40px; padding: 8px 14px;
    border-radius: var(--r-pill); border: 1px solid var(--stroke);
    background: var(--card); color: var(--text); font-size: 14px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mb-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
  /* 备注 + 花呗 */
  .mb-extra { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
  .mb-note {
    flex: 1 1 auto; min-width: 0; min-height: var(--touch-min); padding: 8px 14px;
    border: 1px solid var(--stroke); border-radius: var(--r-pill);
    background: var(--card); color: var(--text); font-size: 15px;
  }
  .mb-hb {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--touch-min); padding: 0 14px;
    border: 1px solid var(--stroke); border-radius: var(--r-pill);
    background: var(--bg-soft); color: var(--text-soft); font-size: 14px;
  }
  .mb-hb input { width: 20px; height: 20px; accent-color: var(--primary); }
  .mb-hb.hidden { display: none; }
  /* 内置数字键盘：右侧「存一笔」大按钮 */
  .mb-pad {
    margin-top: auto; flex: 0 0 auto;
    display: grid; grid-template-columns: 1fr 1fr 1fr 1.5fr; gap: 8px;
    grid-template-areas: "k1 k2 k3 kdel" "k4 k5 k6 kadd" "k7 k8 k9 kadd" "kdot k0 k0 kadd";
  }
  .mb-pad button {
    min-height: 52px; border-radius: 12px; border: 1px solid var(--stroke);
    background: var(--card); color: var(--text); font-size: 22px; font-weight: 600;
  }
  .mb-pad button:active { background: var(--row-hover); }
  .mb-pad .k1 { grid-area: k1; }
  .mb-pad .k2 { grid-area: k2; }
  .mb-pad .k3 { grid-area: k3; }
  .mb-pad .k4 { grid-area: k4; }
  .mb-pad .k5 { grid-area: k5; }
  .mb-pad .k6 { grid-area: k6; }
  .mb-pad .k7 { grid-area: k7; }
  .mb-pad .k8 { grid-area: k8; }
  .mb-pad .k9 { grid-area: k9; }
  .mb-pad .kdot { grid-area: kdot; }
  .mb-pad .k0 { grid-area: k0; }
  .mb-pad .kdel { grid-area: kdel; font-size: 18px; color: var(--text-soft); }
  .mb-pad .kadd {
    grid-area: kadd; border-radius: 14px;
    background: var(--primary); border-color: var(--primary);
    color: #fff; font-size: 17px; line-height: 1.3;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  }
  .kadd-ico { font-size: 22px; line-height: 1; }
  .kadd-tx { font-weight: 700; white-space: nowrap; }
  .kadd-sub { font-size: 12px; opacity: .85; font-weight: 400; white-space: nowrap; }
  .mb-pad .kadd:active { filter: brightness(0.92); }
}

/* ---------- 5. 卡片 / 标题 / 元信息 ---------- */
@media (max-width: 720px) {
  .card {
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: var(--elev-1);
  }
  .card .title {
    padding: 12px 14px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .card .meta {
    padding: 9px 14px;
    font-size: 12.5px;
    flex-wrap: wrap;
    gap: 6px;
    row-gap: 4px;
  }
  .card .meta .info { flex: 1 1 100%; }
}

/* ---------- 6. 筛选表单 → 底部抽屉 ---------- */
/* 桌面：抽屉结构对布局透明（display:contents 让子元素回到 filter-bar 的 flex 流），
   触发条隐藏 —— 桌面观感与改造前完全一致 */
.filter-bar > .fb-trigger { display: none; }
.filter-bar > .fb-panel { display: contents; }
/* C2：桌面端顶栏本就有「记一笔」按钮，这里只给窄屏用 */
.filter-bar > .fb-add { display: none; }

@media (max-width: 720px) {
  /* 触发条与「记一笔」同行，面板换行独占一整行 */
  .filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0 !important;
    margin: 0;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--stroke);
  }
  .filter-bar .fb-trigger {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--touch-min);
    padding: 10px 14px;
    background: none;
    border: none;
    box-shadow: none;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .filter-bar .fb-trigger .fb-trg-txt { display: flex; align-items: center; gap: 6px; font-weight: 600; }
  .filter-bar .fb-trigger .fb-trg-badge {
    display: inline-flex;
    align-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
  }
  .filter-bar .fb-trigger .fb-trg-badge[hidden] { display: none; }
  .filter-bar .fb-trigger .fb-trg-arrow { font-size: 12px; color: var(--text-soft); transition: transform .2s; }
  .filter-bar.open .fb-trigger .fb-trg-arrow { transform: rotate(180deg); }

  .filter-bar .fb-panel {
    display: none;
    flex: 1 0 100%;
    padding: 4px 14px 14px;
    background: var(--card);
    border-top: 1px solid var(--stroke-soft);
    max-height: 62vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 960;   /* 高于内容区，展开时不被遮罩压住，清晰可点 */
  }
  .filter-bar.open .fb-panel { display: block; }

  /* C2：筛选条右侧的就地记账入口（小胶囊，跟底部凸起键同一个动作） */
  .filter-bar .fb-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 0 0 auto;
    min-height: 32px;
    margin: 0 10px;
    padding: 0 12px;
    border: none;
    border-radius: var(--r-pill);
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: var(--elev-primary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .filter-bar .fb-add:active { background: var(--primary-dark); transform: translateY(1px); }

  /* 抽屉内控件撑满 + 44dp 高 */
  .filter-bar .fb-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text);
  }
  .filter-bar .fb-item input,
  .filter-bar .fb-item select {
    flex: 1 1 60%;
    min-width: 0;
    min-height: var(--touch-min);
    font-size: 15px;   /* ≥16px 可防 iOS 缩放，这里 15px 配合 maximum-scale 已够 */
    padding: 8px 30px 8px 11px;   /* 留右侧箭头空间，与全局 select 一致 */
  }
  .filter-bar .fb-note { display: flex; }
  .filter-bar .fb-reset {
    width: 100%;
    min-height: var(--touch-min);
    margin-top: 2px;
  }
  .filter-bar .fb-summary { display: none; }

  /* 内联展开，不使用模糊遮罩（避免面板被糊、点击被拦截）。
     关键：展开筛选【不锁整页滚动】，页面其它区域照常上下滑动；
     仅筛选面板自身在 max-height 内滚动，解决“点开就移动不了”的卡死问题。
     注意：与「更多」面板的 fb-drawer-open 区分开，避免状态互相干扰。 */
  body.fb-filter-open { /* 不锁 overflow，保留页面可滚 */ }
  .fb-drawer-mask { display: none !important; }
}

/* ---------- 7. 弹窗：移动端（编辑类全屏 + 录入类底部抽屉） ---------- */
@keyframes sheet-up {
  from { transform: translateY(72px); opacity: .4; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (max-width: 720px) {
  /* 层级必须高于 #mobile-tabs(900) 和「更多」面板(1000)：
     否则底部 Tab 栏会压在弹窗上，弹窗底部内容（含关闭按钮）点不到。 */
  .modal, .modal-overlay { z-index: 1100; padding: 0; }

  /* 编辑 / 详情类弹窗（自带 ✕，内容长）：继续全屏，滚动空间最大 */
  .modal-overlay { align-items: stretch; }
  .modal-overlay .modal-card,
  #modal-interest .modal-card {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh;
    max-height: none !important;
    border-width: 0;
    border-radius: 0;
    padding: 18px 16px calc(var(--safe-b) + 18px);
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
  }

  /* 「加入明细」结算弹窗：从购物车抽屉里点出来的，内容不多，
     不跟着上面的全屏规则走 —— 改成贴在底部的抽屉，
     这样弹窗上方还能看见购物车列表，用户知道自己在结算哪些商品。 */
  #cart-checkout-modal {
    align-items: flex-end;
    padding: 0;
  }
  #cart-checkout-modal .cart-checkout-card {
    width: 100vw;
    max-width: none;
    height: auto;
    max-height: 88dvh;
    border-width: 0;
    border-radius: 18px 18px 0 0;
    padding: 6px 16px calc(var(--safe-b) + 14px);
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-shadow: 0 -12px 40px rgba(87, 74, 58, .26);
    animation: sheet-up .28s cubic-bezier(.22, .8, .28, 1);
  }
  /* 顶部抓手 */
  #cart-checkout-modal .cart-checkout-card::before {
    content: '';
    flex: 0 0 auto;
    width: 42px; height: 5px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: var(--stroke);
  }
  #cart-checkout-modal .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  /* 底部按钮吸底：内容再长也始终可点 */
  #cart-checkout-modal .modal-foot {
    position: sticky;
    bottom: 0;
    margin-top: 10px;
    padding-top: 12px;
    background: linear-gradient(to top, #fff 70%, transparent);
  }

  /* C1：录入 / 批量录入 / 账户·分类明细（.modal）改成贴在底部导航之上的抽屉。
     原来是 100dvh 整屏，把底部导航一起盖死：用户看不到「下面还能切页」，
     关闭入口又埋在长表单最底下的「取消」里，于是出现「弹层关不掉」的体验。
     现在遮罩只铺到导航上沿 —— 顶部那截暗区点一下就关，5 个 tab 照常可点。 */
  .modal { align-items: flex-end; inset: 0 0 var(--tabbar-h-real) 0; }
  .modal > .modal-card {
    width: 100vw;
    max-width: none;
    height: auto;
    max-height: 100%;
    align-self: flex-end;
    border-width: 0;
    border-radius: 18px 18px 0 0;
    padding: 6px 16px 14px;
    box-shadow: 0 -12px 40px rgba(87, 74, 58, .26);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    animation: sheet-up .28s cubic-bezier(.22, .8, .28, 1);
  }
  /* 顶部抓手：视觉上提示「上面那片暗的能点掉」 */
  .modal > .modal-card::before {
    content: '';
    flex: 0 0 auto;
    width: 42px; height: 5px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: var(--stroke);
  }

  /* 内容超出时只滚中间区域，卡片固定在可用区内，底部不溢出 */
  .modal .modal-card > h2 { flex: 0 0 auto; }
  /* 分类列表限高可滚：分类多时不会把下面的关闭按钮顶出视口 */
  .modal > .modal-card > .cat-detail-table { flex: 0 1 auto; max-height: 40dvh; }
  /* 子明细区是主要变量，占据剩余空间并独立滚动 */
  .modal .cat-detail-expand {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 关闭按钮吸底：内容再长也始终可点（这是「页面关不掉」的直接修复点） */
  .modal-card .actions {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding-top: 12px;
    background: linear-gradient(to top, var(--card) 70%, transparent);
    flex: 0 0 auto;
  }

  /* 账号面板例外：内容很少（头像 + 4 个菜单项），跟着上面的全屏规则会拉成
     一整屏空白长条。改成居中小卡片，遮罩仍铺满全屏。 */
  .modal-overlay .account-panel {
    width: min(340px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 48px) !important;
    height: auto !important;
    max-height: 80vh !important;
    border-radius: 14px !important;
    border-width: 1px;
    align-self: center;
    justify-content: flex-start;
    align-items: stretch;
  }
  /* 面板内部按钮不再需要吸底，直接排布即可 */
  .account-panel .modal-foot .actions,
  .account-panel .modal-foot {
    position: static;
    background: none;
    margin-top: 0;
  }
  .modal-card .actions button { flex: 1 1 auto; }
  .modal-card form {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-card input, .modal-card select, .modal-card textarea {
    min-height: var(--touch-min);
    font-size: 15px;
  }
  .modal-card button { min-height: var(--touch-min); }
  /* 提交按钮固定吸底 */
  .modal-card .submit,
  .modal-card button[type="submit"] { min-height: 50px; font-size: 16px; }

  /* 利息补登弹窗窄屏易用性增强 */
  #modal-interest .modal-card {
    gap: 0;
  }
  #modal-interest .modal-body {
    padding: 16px 16px 0;
    gap: 4px;
  }
  #modal-interest .form-row { margin-bottom: 14px; }
  #modal-interest .form-row label { font-size: 14px; }
  #modal-interest .form-row select,
  #modal-interest .form-row input[type="number"],
  #modal-interest .form-row input[type="date"] {
    width: 100%;
    min-height: var(--touch-min);
    font-size: 16px;
    padding: 10px 12px;
  }
  /* 双日期在窄屏换行，避免挤成看不清 */
  #modal-interest .interest-dates .date-range {
    flex-wrap: wrap;
  }
  #modal-interest .interest-dates .date-range input[type="date"] {
    flex: 1 1 44%;
  }
  #modal-interest .interest-dates .date-arrow { flex: 0 0 100%; text-align: center; }
  /* 操作栏吸底、按钮铺满可点 */
  #modal-interest .interest-foot {
    position: sticky;
    bottom: 0;
    gap: 10px;
    padding: 12px 0 calc(env(safe-area-inset-bottom, 0px) + 4px);
    margin-top: 6px;
    background: linear-gradient(to top, var(--card) 72%, transparent);
  }
  #modal-interest .interest-foot .secondary,
  #modal-interest .interest-foot .primary {
    flex: 1 1 0;
    min-height: 50px;
    font-size: 16px;
  }

  /* toast 抬高，避免被 Tab 栏遮挡 */
  .toast { bottom: calc(var(--tabbar-h-real) + 20px); }
}

/* ---------- 8. 窄屏按钮尺寸统一 ----------
   全 app 的行内小按钮（展开/明细/编辑/保存/清除/加载更多）统一为
   38px 高、13px 字、水平 16px 内边距 —— 既保证手指可点，又不会
   大得像块头（之前 44px + 14px 字，用户反馈「按钮过大」）。 */
@media (max-width: 720px) {
  .toggle-btn,
  .cat-detail-btn,
  .edit-btn,
  .load-more-btn,
  .saving-set-row .saving-save-btn,
  .saving-set-row .saving-del-btn {
    min-height: 38px;
    height: 38px;
    padding: 0 16px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }
  .toggle-btn { padding: 0 16px; }
  /* C3：窄屏下加载更多做成整行大按钮，手指好点；提示文字放在按钮上方 */
  .load-sentinel {
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
  }
  .load-more-btn { width: 100%; }
  /* 表单里的 checkbox / radio 行也放大 */
  label input[type="checkbox"], label input[type="radio"] {
    width: 20px; height: 20px; min-height: 20px;
  }
}

/* ---------- 9. 减少动态效果偏好 ---------- */
@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 10. 「更多」底部弹出面板 ---------- */
.mtb-more-panel { display: none; }
@media (max-width: 720px) {
  /* 必须 fixed：body 是 static，卡片用 absolute + bottom:0 会参照整篇文档的底边，
     页面内容一长卡片就被顶到视口外（实测卡片 top=-78px，X 按钮 top=-28px 点不到）。 */
  .mtb-more-panel {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;          /* 高于 #mobile-tabs(900)，否则底部工具区被 tabbar 压住 */
    pointer-events: none;
  }
  .mtb-more-panel[aria-hidden="false"] { pointer-events: auto; }

  /* 首次引导：让「更多」按钮呼吸高亮，提示入口所在（游戏厅/导入收在里面） */
  #mobile-tabs .mtb-item.mtb-hint {
    animation: mtb-hint-pulse 1.3s ease-in-out infinite;
  }
  #mobile-tabs .mtb-item.mtb-hint .mtb-ico {
    color: var(--primary);
  }
  @keyframes mtb-hint-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 55%, transparent); }
    50%      { transform: scale(1.08); box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 0%, transparent); }
  }

  .mtb-more-mask {
    position: fixed;
    inset: 0;
    background: rgba(87, 74, 58, .4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .22s;
  }
  .mtb-more-panel[aria-hidden="false"] .mtb-more-mask { opacity: 1; }

  .mtb-more-card {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: 18px 18px 0 0;
    padding: 6px calc(var(--safe-r) + 14px) calc(var(--safe-b) + 58px + 14px) calc(var(--safe-l) + 14px);
    box-shadow: 0 -6px 28px rgba(87, 74, 58, .26);
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  }
  .mtb-more-panel[aria-hidden="false"] .mtb-more-card { transform: translateY(0); }

  .mtb-more-grip {
    width: 38px; height: 4px; border-radius: 2px;
    background: var(--stroke); margin: 4px auto 8px;
  }
  .mtb-more-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2px 10px;
    border-bottom: 1px solid var(--stroke-soft);
  }
  .mtb-more-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
  .mtb-more-close {
    width: var(--touch-min); height: var(--touch-min); padding: 0;
    flex: 0 0 auto;
    border-radius: 50%; background: var(--bg-soft); color: var(--text-soft);
    display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
  }

  .mtb-more-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 2px;
    padding-top: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mtb-more-grid .mtg-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 10px 2px;
    min-height: 72px;
    background: none;
    border: none;
    box-shadow: none;
    border-radius: 12px;
    font-size: 11.5px;
    color: var(--text);
    cursor: pointer;
    position: relative;          /* 角标定位基准 */
    -webkit-tap-highlight-color: transparent;
  }
  .mtb-more-grid .mtg-item:active { background: var(--bg-soft); }
  .mtb-more-grid .mtg-item.active { color: var(--primary); font-weight: 700; }
  .mtb-more-grid .mtg-ico {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px;
    background: color-mix(in srgb, var(--primary) 12%, var(--card));
    border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
    position: relative;
  }
  .mtb-more-grid .mtg-ico img { width: 26px; height: 26px; object-fit: contain; }
  .mtb-more-grid .mtg-item.active .mtg-ico {
    background: color-mix(in srgb, var(--primary) 22%, var(--card));
  }
  .mtb-more-grid .mtg-lb {
    text-align: center; line-height: 1.25;
    word-break: break-all;
    max-width: 100%;
  }
  .mtb-more-grid .mtg-dot {
    position: absolute; top: -3px; right: -3px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--warn);
    border: 2px solid var(--card);
  }
  /* 「想买清单」入口的件数角标 */
  .mtb-more-grid .mtg-count {
    position: absolute;
    top: 4px;
    right: calc(50% - 26px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
  }
  .mtb-more-grid .mtg-count.hidden { display: none; }
  /* 分组小标题 */
  .mtb-more-grid .mtg-sep {
    grid-column: 1 / -1;
    font-size: 11.5px; color: var(--text-soft);
    padding: 10px 2px 2px;
    font-weight: 600;
    letter-spacing: .4px;
    display: flex; align-items: center; gap: 6px;
  }
  .mtb-more-grid .mtg-sep::after {
    content: ''; flex: 1; height: 1px; background: var(--stroke-soft);
  }
  .mtb-more-grid .mtg-sep:first-child { padding-top: 0; }
}

/* ============================================================
   易用性改造 A 组：切换丝滑（进度条 / 压暗 / 入场）+ B3 页头
   ============================================================ */

/* A1 顶部细进度条：切 tab 不再整屏闪白，只在最顶端跑一条光带 */
.top-progress {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 3px;
  z-index: 3000;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity .18s ease;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.top-progress.active { opacity: 1; }
.top-progress::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 36%;
  background: linear-gradient(90deg,
    transparent,
    var(--primary),
    color-mix(in srgb, var(--accent) 85%, var(--primary)),
    transparent);
  animation: top-progress-slide 1.05s cubic-bezier(.4, .1, .6, .9) infinite;
}
@keyframes top-progress-slide {
  from { transform: translateX(-115%); }
  to   { transform: translateX(315%); }
}

/* A1 等新数据期间：旧内容压暗并禁止误点，视觉上仍是「这一页」 */
.view-stale {
  opacity: .42;
  filter: saturate(.55);
  pointer-events: none;
  transition: opacity .16s ease;
}

/* 离屏渲染容器（渲染完再整块挂进内容区） */
.view-mount { display: block; }

/* A4 入场：淡入 + 轻微上移。
   起始不透明度刻意不到 0，避免动画被节流停在首帧时内容整块不可见 */
.view-enter { animation: view-enter .24s ease-out both; }
@keyframes view-enter {
  from { opacity: .3; transform: translateY(10px); }
  to   { opacity: 1;  transform: none; }
}

/* B3 页头：桌面端有顶部页签，不显示；移动端在吸顶页头里给出位置感 */
.page-head { display: none; }
@media (max-width: 720px) {
  .page-head {
    display: block;
    position: sticky;
    top: var(--header-h, 55px);
    z-index: 9;
    margin: -2px -12px 10px;
    padding: 7px 12px 6px;
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: var(--stroke-soft);
  }
  .page-head .ph-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
    letter-spacing: .2px;
  }
  .page-head .ph-sub {
    margin-top: 1px;
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-soft);
  }
  .page-head .ph-sub:empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view-enter,
  .top-progress::after,
  .mtb-item.active .mtb-ico.mtb-pop { animation: none; }
  .mtb-item .mtb-ico { transition: none; }
}

/* ============================================================
   D 组：常用速览「分类明细」弹层重做
   旧版痛点：分类项被卡片化后每条 90px 高、弹层吃掉整屏、
   「关闭」按钮埋在列表最底下、选中行整块橘色和记账 FAB 撞色。
   新版：抽屉只占下半屏 + 分类紧凑成两行（名称/占比/金额 + 占比条）
        + 顶部常驻 ✕ 与返回键 + 点分类切二级视图（不再往下堆）
   ============================================================ */

/* 桌面端也用新结构：分类改成两行紧凑条目，替代原来的表格 */
.cat-modal {
  max-width: 560px;
  padding: 0;
  overflow: hidden;
  background: var(--card);
  border: none;
  box-shadow: 0 20px 60px rgba(87, 74, 58, .3);
}
.cat-grip { display: none; }
.cat-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: var(--stroke-soft);
  background: var(--card);
}
.cat-modal-titles { flex: 1 1 auto; min-width: 0; }
.cat-modal-t1 {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.cat-modal-ico { font-size: 15px; }
.cat-modal-t2 {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 1px;
  line-height: 1.35;
}
.cat-modal-close,
.cat-back {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cat-modal-close:active,
.cat-back:active { background: var(--primary-light); color: var(--text); }
.cat-back { font-size: 22px; padding-bottom: 3px; }
.cat-back[hidden] { display: none; }

/* 合计条：一眼看到总额，不用自己加 */
.cat-sum {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 10px 18px;
  background: var(--bg-soft);
  border-bottom: var(--stroke-soft);
}
.cat-sum-cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.cat-sum-cell + .cat-sum-cell {
  margin-left: 14px;
  padding-left: 14px;
  border-left: var(--stroke-soft);
}
.cat-sum-v {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
  line-height: 1.2;
}
.cat-sum-v.neg { color: var(--warn); }
/* 收入金额：不用主题的 --num（月薪喵主题下是 #95c25a 黄绿，和暖橘主题割裂），
   改用偏青的深绿，两个主题下都协调且方向明确 */
.cat-sum-v.pos { color: #2f9e7e; }
.cat-sum-k { font-size: 12px; color: var(--text-soft); }

/* 分类列表：可滚，底部按钮不外露 */
.cat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 8px 10px;
}
.cat-item {
  padding: 9px 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-item:active { background: var(--bg-soft); }
.cat-item-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.cat-emoji { flex: 0 0 auto; font-size: 15px; line-height: 1.3; }
.cat-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-pct {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  background: var(--bg-soft);
  border-radius: var(--r-pill);
  padding: 1px 7px;
}
.cat-amt {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 700;
  color: #2f9e7e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cat-amt.neg { color: var(--warn); }
.cat-bar {
  margin-top: 6px;
  height: 5px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}
.cat-bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--primary) 55%, var(--accent)),
    var(--primary));
}
/* 支出条用红、收入条用青绿，和金额数字同色，方向一眼可辨 */
.cat-bar.inc > i {
  background: linear-gradient(90deg, #2f9e7e 0%, #57c9a3 100%);
}
.cat-bar.exp > i {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--warn) 55%, var(--primary-light)),
    var(--warn));
}

/* 二级视图：分类流水的头部汇总 */
.cat-tx-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 2px 10px;
}
.cat-tx-title { font-size: 14px; font-weight: 700; color: var(--text); }
.cat-tx-count { font-size: 12px; color: var(--text-soft); }
.cat-tx-total {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cat-back-list {
  width: 100%;
  margin-top: 12px;
  min-height: var(--touch-min);
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
  cursor: pointer;
}
.cat-back-list:active { background: var(--primary-light); }

/* 弹层内的分类流水：复用 B1 的紧凑行（日期/备注/金额 一行） */
.cat-modal .sub-table-wrap { max-height: none; border-radius: 12px; }
.cat-modal .cat-detail-table { margin-top: 0; box-shadow: none; }
.cat-modal .cat-detail-table tbody tr.cat-row { display: none; }

/* 分类明细里的流水是"只读清单"：不可点、无展开箭头，
   否则用户会以为点一下能展开更多，反而找不到内容 */
@media (max-width: 720px) {
  table.responsive-table.cat-tx-list > tbody > tr {
    cursor: default;
    min-height: 46px;
    margin-bottom: 0;
    border-bottom: var(--stroke-soft);
    border-radius: 0;
    background: transparent;
  }
  table.responsive-table.cat-tx-list > tbody > tr::after { content: none; }
  table.responsive-table.cat-tx-list > tbody > tr:active { background: transparent; }
}

@media (max-width: 720px) {
  /* 抽屉只占下半屏：上半屏露出来，用户仍知道自己在哪、能点遮罩关闭 */
  .cat-modal-overlay {
    align-items: flex-end;
    inset: 0 0 var(--tabbar-h-real) 0;
  }
  .cat-modal-overlay > .cat-modal {
    width: 100vw;
    max-width: none;
    height: auto;
    max-height: 82%;
    align-self: flex-end;
    border-radius: 18px 18px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    animation: sheet-up .28s cubic-bezier(.22, .8, .28, 1);
    box-shadow: 0 -12px 40px rgba(87, 74, 58, .26);
  }
  /* 顶部抓手 */
  .cat-modal-overlay > .cat-modal > .cat-grip {
    display: block;
    flex: 0 0 auto;
    width: 42px;
    height: 5px;
    margin: 8px auto 2px;
    border-radius: 999px;
    background: var(--stroke);
  }
  .cat-modal-overlay .cat-modal-head { padding: 8px 14px 10px; }
  .cat-modal-overlay .cat-modal-close,
  .cat-modal-overlay .cat-back { width: var(--touch-min); height: var(--touch-min); }
  .cat-modal-overlay .cat-sum { padding: 9px 14px; }
  .cat-modal-overlay .cat-sum-v { font-size: 19px; }
  .cat-modal-overlay .cat-sum-cell + .cat-sum-cell { margin-left: 12px; padding-left: 12px; }
  .cat-modal-overlay .cat-list { padding: 4px 6px 8px; }
  .cat-modal-overlay .cat-item { padding: 10px 10px 11px; }
  /* 二级视图在抽屉里也要能滚 */
  .cat-modal-overlay .cat-detail-expand {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 14px 14px;
    border-top: var(--stroke-soft);
    margin-top: 0;
  }
}

/* ============================================================
   统一主题化下拉框（select）
   之前各页面 select 边框/圆角/配色不统一，且 filter-bar 用蓝灰边框
   与主题割裂。这里统一用主题变量：--primary / --border / --r-md，
   并加自定义箭头，所有页面（主页弹窗、筛选、花呗还款、设置、导入）共用。
   ============================================================ */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  font-family: inherit;
  color: var(--text);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 10px);
  padding: 8px 30px 8px 11px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23a89878' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
body.theme-maojin select:focus { border-color: #ff9a76; }
select:disabled { opacity: .55; cursor: not-allowed; }

/* 窄屏：下拉撑到 44dp 触控高度 */
@media (max-width: 720px) {
  .filter-bar .fb-item select,
  select.text-input,
  .repay-month-card select,
  #modal select,
  #modal-interest select {
    min-height: var(--touch-min, 44px);
    font-size: 15px;
  }
}



/* ========== 想买清单（购物车） ========== */
/* 顶部图标按钮：圆形，右上角数量角标 */
.header-cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--card);
  border: var(--stroke);
  box-shadow: var(--elev-1);
  cursor: pointer;
  line-height: 1;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.header-cart-btn:hover { background: var(--primary-light); transform: translateY(-1px); }
.header-cart-btn:active { transform: translateY(1px); box-shadow: none; }
.header-cart-btn .cart-ico { font-size: 18px; line-height: 1; }
.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  pointer-events: none;
}
.cart-badge.hidden { display: none; }

/* 抽屉：桌面从右侧滑出，窄屏改为底部整屏 sheet */
.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  visibility: hidden;
  pointer-events: none;
}
.cart-drawer.open { visibility: visible; pointer-events: auto; }
.cart-mask {
  position: absolute;
  inset: 0;
  background: rgba(40, 32, 20, .38);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .22s ease;
}
.cart-drawer.open .cart-mask { opacity: 1; }
.cart-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: var(--stroke);
  box-shadow: -8px 0 32px rgba(90, 74, 48, .18);
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.34, 1.1, .64, 1);
}
.cart-drawer.open .cart-panel { transform: translateX(0); }
body.cart-open { overflow: hidden; }

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: var(--stroke);
}
.cart-head-title { font-size: 15px; font-weight: 700; color: var(--text); }
.cart-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 8px;
}
.cart-x:hover { background: rgba(0, 0, 0, .05); color: var(--text); }

/* 快速添加：名称 + 价格 + ＋ */
.cart-add { display: flex; gap: 8px; padding: 12px 16px; }
.cart-add input {
  height: 40px;
  min-width: 0;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}
.cart-add #cart-title { flex: 1 1 auto; }
.cart-add #cart-amount { flex: 0 0 86px; width: 86px; }
.cart-add input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.cart-add-btn {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--elev-primary);
  transition: background .15s, transform .1s;
}
/* ＋ 用伪元素画：字体里的全角加号（U+FF0B）字形偏心、字重也不一致，
   改成两条 2px 的线交叉，视觉上永远是正位居中。 */
.cart-add-btn::before,
.cart-add-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 2px;
  margin: -1px 0 0 -7.5px;
  border-radius: 1px;
  background: currentColor;
}
.cart-add-btn::after {
  transform: rotate(90deg);
}
.cart-add-btn:hover { background: var(--primary-dark); }
.cart-add-btn:active { transform: translateY(1px); }

/* 列表 */
.cart-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--card);
  border: var(--stroke);
  border-radius: 12px;
}
.cart-row-check {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}
.cart-row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cart-row-title,
.cart-row-note {
  width: 100%;
  min-width: 0;
  padding: 2px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font);
  color: var(--text);
}
.cart-row-title { font-size: 14px; font-weight: 600; }
.cart-row-note { font-size: 12px; color: var(--text-soft); }
.cart-row-note::placeholder { color: var(--muted); }
.cart-row-title:focus,
.cart-row-note:focus { outline: none; background: var(--bg); }
.cart-row-price {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 12px;
  color: var(--text-soft);
}
.cart-row-amount {
  width: 62px;
  padding: 2px 0;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--num, var(--text));
  text-align: right;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.cart-row-amount::-webkit-outer-spin-button,
.cart-row-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cart-row-amount:focus { outline: none; background: var(--bg); border-radius: 6px; }
.cart-row-del {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cart-row-del:hover { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }

/* 空态 */
.cart-empty { margin: 44px auto; text-align: center; color: var(--text-soft); }
.cart-empty-ico { font-size: 40px; opacity: .4; margin-bottom: 8px; }
.cart-empty p { margin: 0; font-size: 14px; font-weight: 600; }
.cart-empty .cart-empty-sub { margin-top: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }

/* 底部结算条 */
.cart-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: var(--stroke);
  background: var(--card);
}
.cart-all {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
}
.cart-all input { width: 16px; height: 16px; accent-color: var(--primary); }
.cart-sum {
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
}
.cart-sum-lb { font-size: 12px; color: var(--text-soft); }
.cart-sum-amount {
  font-size: 17px;
  font-weight: 700;
  color: var(--num, var(--text));
  font-variant-numeric: tabular-nums;
}
.cart-foot .primary { flex: 0 0 auto; padding: 9px 16px; border-radius: var(--r-pill); white-space: nowrap; }

/* 结算弹窗 */
/* 「加入明细」弹窗是从购物车抽屉里点出来的，抽屉本身 z-index 1200（移动端还更高），
   弹窗若沿用 .modal-overlay 的 1000/1100 就会被抽屉的遮罩盖住、点不动。
   这里单独提到抽屉之上。 */
#cart-checkout-modal { z-index: 1300; }
.cart-checkout-card { width: 400px; }
.cart-checkout-card .modal-body { display: flex; flex-direction: column; gap: 10px; }
.cx-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: var(--stroke);
  font-size: 13px;
  color: var(--text-soft);
}
.cx-total {
  font-size: 20px;
  font-weight: 700;
  color: var(--num, var(--text));
  font-variant-numeric: tabular-nums;
}
.cx-hint { margin: 0; font-size: 12px; color: var(--muted); }

@media (max-width: 720px) {
  /* 顶栏按钮在窄屏被统一压成 font-size:0，这里单独恢复图标尺寸 */
  #btn-cart .cart-ico { font-size: 17px; }
  .cart-badge { top: -2px; right: -2px; }
  .cart-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 88vh;
    border-left: none;
    border-top: var(--stroke);
    border-radius: 20px 20px 0 0;
    transform: translateY(102%);
    box-shadow: 0 -8px 32px rgba(90, 74, 48, .2);
  }
  .cart-drawer.open .cart-panel { transform: translateY(0); }
  /* 输入框字号 ≥16px，避免 iOS 聚焦时自动放大 */
  .cart-add input,
  .cart-row-title,
  .cart-row-note,
  .cart-row-amount { font-size: 16px; }
  .cart-row-amount { width: 74px; }
  .cart-foot .primary { padding: 10px 14px; }
}

/* ========== 登录后首页看板 v2（2026-11-12 重排：统一字号阶梯 / 栅格 / 去掉按钮胶囊） ========== */
/* 首页已有消费主卡，顶部统计条只在其它页面显示 */
body.home-active #stats-strip { display: none !important; }

.home-dashboard {
  --h-pad: 20px;
  --h-gap: 16px;
  --h-line: var(--border);
  --h-fs-title: 15px;
  --h-fs-body: 13.5px;
  --h-fs-label: 12px;
  --h-fs-num: 34px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 4px 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--h-gap);
  align-items: start;
  font-variant-numeric: tabular-nums;
}
.home-col-main, .home-col-side {
  display: grid;
  gap: var(--h-gap);
  align-content: start;
  min-width: 0;
}

/* ---- 卡片：细边框 + 极轻阴影，去掉厚重层次 ---- */
.home-dashboard .home-card {
  margin: 0;
  padding: var(--h-pad);
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--h-line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(87, 74, 58, .04);
}

/* ---- 卡片头：15px 标题 + 12px 次要 + 文本型操作 ---- */
.home-dashboard .home-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}
.home-dashboard .home-card-head > b {
  font-size: var(--h-fs-title);
  font-weight: 600;
  color: var(--text);
  letter-spacing: .2px;
}
.home-dashboard .home-card-head > span { font-size: var(--h-fs-label); color: var(--text-soft); }
.home-dashboard .home-month {
  font-size: var(--h-fs-label);
  color: var(--text-soft);
  letter-spacing: .4px;
}

/* 文字型操作：彻底去掉全局 button 的胶囊外观 */
.home-dashboard .home-link {
  margin: 0;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: var(--h-fs-body);
  font-weight: 500;
  line-height: 1.4;
  color: var(--primary);
}
.home-dashboard .home-link:hover { background: none; color: var(--primary-dark); }
.home-dashboard .home-link:active { transform: none; box-shadow: none; }

/* ---- 本月消费 ---- */
.home-dashboard .home-spend-card .home-card-head { margin-bottom: 2px; }
.home-dashboard .home-spend-main {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 0 4px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-align: left;
  color: var(--text);
}
.home-dashboard .home-spend-main:hover { background: none; }
.home-dashboard .home-spend-main:active { transform: none; box-shadow: none; }
.home-dashboard .home-label {
  display: block;
  font-size: var(--h-fs-label);
  color: var(--text-soft);
  letter-spacing: .3px;
}
.home-dashboard .home-spend-num {
  display: block;
  margin: 2px 0 4px;
  font-size: var(--h-fs-num);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.5px;
  color: var(--text);
}
.home-dashboard .home-spend-count { font-size: var(--h-fs-label); color: var(--text-soft); }

/* 三项指标：等宽三列，标签在上、值在下 */
.home-dashboard .home-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--h-line);
}
.home-dashboard .home-metric { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.home-dashboard .home-metric > span { font-size: var(--h-fs-label); color: var(--text-soft); }
.home-dashboard .home-metric > b { font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; }
.home-dashboard .home-metric > em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-dashboard .home-metric.is-clickable { cursor: pointer; }
.home-dashboard .home-metric.is-clickable:hover > b { color: var(--primary-dark); }

.home-dashboard .home-income { color: var(--num); }
.home-dashboard .home-negative { color: var(--warn); }

/* ---- 快捷操作 ---- */
.home-dashboard .home-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.home-dashboard .home-quick-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 62px;
  margin: 0;
  padding: 8px 4px;
  border: 1px solid var(--h-line);
  border-radius: 12px;
  background: var(--bg-soft);
  box-shadow: none;
  font-size: var(--h-fs-label);
  font-weight: 500;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.home-dashboard .home-quick-actions button:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.home-dashboard .home-quick-actions button:active { transform: none; }
.home-dashboard .home-quick-actions button span { font-size: 20px; line-height: 1; }
.home-dashboard .home-quick-actions button b { font-size: var(--h-fs-label); font-weight: 500; }

/* ---- 最近支出：真列表，不要一行一个小胶囊 ---- */
.home-dashboard .home-recent-list { display: flex; flex-direction: column; }
.home-dashboard .home-recent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  width: 100%;
  margin: 0;
  padding: 11px 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-align: left;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.home-dashboard .home-recent-row + .home-recent-row { border-top: 1px solid var(--h-line); }
.home-dashboard .home-recent-row:hover { background: none; }
.home-dashboard .home-recent-row:active { transform: none; box-shadow: none; }
.home-dashboard .home-recent-row:hover .home-recent-main > b { color: var(--primary-dark); }
.home-dashboard .home-recent-main { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.home-dashboard .home-recent-main > b { font-size: var(--h-fs-body); font-weight: 500; }
.home-dashboard .home-recent-main > small { font-size: var(--h-fs-label); color: var(--text-soft); }
.home-dashboard .home-recent-row > strong {
  font-size: var(--h-fs-body);
  font-weight: 600;
  color: var(--warn);
  white-space: nowrap;
}
.home-dashboard .home-recent-sub {
  grid-column: 1 / -1;
  font-size: var(--h-fs-label);
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- 分类占比 ---- */
.home-dashboard .home-cat-list { display: flex; flex-direction: column; }
.home-dashboard .home-cat-row {
  display: grid;
  grid-template-columns: 52px minmax(24px, 1fr) auto 44px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 6px 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-dashboard .home-cat-row:hover { background: none; }
.home-dashboard .home-cat-row:active { transform: none; box-shadow: none; }
.home-dashboard .home-cat-name { font-size: var(--h-fs-body); }
.home-dashboard .home-cat-track { height: 6px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.home-dashboard .home-cat-track i {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 99px;
  background: var(--primary);
}
.home-dashboard .home-cat-row > b { font-size: var(--h-fs-body); font-weight: 500; white-space: nowrap; }
.home-dashboard .home-cat-row > small { font-size: var(--h-fs-label); color: var(--text-soft); text-align: right; }

/* ---- 攒钱目标 ---- */
.home-dashboard .home-saving-nums { display: flex; justify-content: space-between; gap: 12px; }
.home-dashboard .home-saving-nums > span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--h-fs-label);
  color: var(--text-soft);
}
.home-dashboard .home-saving-nums b { font-size: 16px; font-weight: 600; color: var(--text); }
.home-dashboard .home-saving-track {
  height: 8px;
  margin: 14px 0 6px;
  border-radius: 99px;
  background: var(--bg-soft);
  overflow: hidden;
}
.home-dashboard .home-saving-track i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }

/* ---- 家庭净资产 ---- */
.home-dashboard .home-net-num {
  margin-bottom: 12px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.3px;
  color: var(--text);
}
.home-dashboard .home-asset-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.home-dashboard .home-asset-pair > span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--h-fs-label);
  color: var(--text-soft);
}
.home-dashboard .home-asset-pair b { font-size: 14px; font-weight: 600; color: var(--text); }
.home-dashboard .home-account-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--h-line);
  font-size: var(--h-fs-label);
  color: var(--text-soft);
}
.home-dashboard .home-account-mini b { margin-left: 4px; font-weight: 500; color: var(--text); }

/* ---- 近 6 个月趋势 ---- */
.home-dashboard .home-trend-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  height: 170px;
}
.home-dashboard .home-trend-col {
  display: grid;
  grid-template-rows: 20px 1fr 18px;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text-soft);
  font: inherit;
  cursor: pointer;
}
.home-dashboard .home-trend-col:hover { background: none; }
.home-dashboard .home-trend-col:active { transform: none; box-shadow: none; }
.home-dashboard .home-trend-val {
  font-size: 10px;
  color: var(--text-soft);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-dashboard .home-trend-bar-track { display: flex; align-items: flex-end; justify-content: center; background: none; }
.home-dashboard .home-trend-col.is-neg .home-trend-bar-track { align-items: flex-start; }
.home-dashboard .home-trend-bar-track i {
  display: block;
  width: 56%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
}
.home-dashboard .home-trend-col.is-neg .home-trend-bar-track i { border-radius: 0 0 4px 4px; background: var(--warn); }
.home-dashboard .home-trend-col small { font-size: 11px; color: var(--text-soft); text-align: center; }

/* ---- 待处理 ---- */
.home-dashboard .home-todo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.home-dashboard .home-todo-row + .home-todo-row { border-top: 1px solid var(--h-line); }
.home-dashboard .home-todo-row:hover { background: none; }
.home-dashboard .home-todo-row:active { transform: none; box-shadow: none; }
.home-dashboard .home-todo-row > span { font-size: 16px; line-height: 1; }
.home-dashboard .home-todo-row > b { font-size: var(--h-fs-body); font-weight: 500; }
.home-dashboard .home-todo-row > em {
  margin-left: auto;
  font-style: normal;
  font-size: var(--h-fs-body);
  color: var(--primary);
  white-space: nowrap;
}

/* ---- 空态 / 说明文字 ---- */
.home-dashboard .home-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 0;
  font-size: var(--h-fs-body);
  color: var(--text-soft);
}
.home-dashboard .home-empty > b { font-size: var(--h-fs-body); font-weight: 500; color: var(--text); }
.home-dashboard .home-card-foot { margin-top: 10px; font-size: var(--h-fs-label); color: var(--text-soft); }
.home-dashboard .home-error { grid-column: 1 / -1; }

/* ---- 中等宽度：侧栏收窄，避免主列被挤 ---- */
@media (max-width: 1100px) and (min-width: 721px) {
  .home-dashboard { grid-template-columns: minmax(0, 1fr) 320px; }
}

/* ---- 手机：拉平成一列，按使用频率排序 ---- */
@media (max-width: 720px) {
  .home-dashboard {
    --h-pad: 16px;
    --h-gap: 12px;
    --h-fs-num: 30px;
    display: flex;
    flex-direction: column;
    gap: var(--h-gap);
    padding: 0 0 16px;
  }
  .home-col-main, .home-col-side { display: contents; }
  .home-spend-card { order: 1; }
  .home-quick-card { order: 2; }
  .home-todos      { order: 3; }
  .home-recent     { order: 4; }
  .home-categories { order: 5; }
  .home-saving     { order: 6; }
  .home-accounts   { order: 7; }
  .home-trend      { order: 8; }

  .home-dashboard .home-card { border-radius: 14px; }
  .home-dashboard .home-quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .home-dashboard .home-quick-actions button {
    min-height: 60px;
    padding: 4px 0;
    border: 0;
    background: none;
  }
  .home-dashboard .home-quick-actions button:hover { background: none; }
  .home-dashboard .home-metrics { gap: 10px; }
  .home-dashboard .home-cat-row { grid-template-columns: 46px minmax(20px, 1fr) auto 40px; gap: 8px; }
  .home-dashboard .home-trend-chart { height: 150px; gap: 6px; }
  .home-dashboard .home-net-num { font-size: 24px; }
}

/* ---- v2.1 修正：手机端卡片要撑满（align-items:start 在 flex 下会按内容收缩） ---- */
@media (max-width: 720px) {
  .home-dashboard { align-items: stretch; }
}

/* ---- v2.1 消费卡标题行：左侧「本月消费 + 月份」成组 ---- */
.home-dashboard .home-head-left { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.home-dashboard .home-head-left > b { font-size: var(--h-fs-title); font-weight: 600; color: var(--text); }
.home-dashboard .home-card-head .home-head-left .home-month { font-weight: 400; }

/* ---- v2.2 指标行：标签 + 值 + 小字挤在一行，三项高度一致 ---- */
.home-dashboard .home-metric > b { display: block; font-size: 16px; line-height: 1.3; }
.home-dashboard .home-metric > em {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 720px) {
  .home-dashboard .home-metric > b { font-size: 15px; }
  .home-dashboard .home-metrics { gap: 8px; }
}

/* ---- v2.3 趋势图：零轴居中，正柱向上、负柱向下 ---- */
.home-dashboard .home-trend-chart { height: 190px; gap: 14px; }
.home-dashboard .home-trend-col { grid-template-rows: 18px 1fr 18px; gap: 8px; }
.home-dashboard .home-trend-bar-track {
  position: relative;
  display: block;
  background: none;
  border-radius: 0;
}
/* 零轴：所有列高度一致，直接在每条轨道上画一条，视觉连成横线 */
.home-dashboard .home-trend-bar-track::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: var(--zero, 100%);
  height: 1px;
  background: var(--border);
}
.home-dashboard .home-trend-bar-track > i {
  position: absolute;
  left: 50%;
  width: 56%;
  min-height: 2px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: var(--primary);
}
/* 正值：贴零轴向上长 */
.home-dashboard .home-trend-bar-track > i.pos {
  bottom: calc(100% - var(--zero, 100%));
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
/* 负值：贴零轴向下长 */
.home-dashboard .home-trend-bar-track > i.neg {
  top: var(--zero, 100%);
  background: var(--warn);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.home-dashboard .home-trend-val { font-size: 10.5px; }

/* ---- v2.3 分类条形：轨道加深、条加粗，白卡上才看得见 ---- */
.home-dashboard .home-cat-track {
  height: 8px;
  background: var(--primary-light);
  border: 1px solid var(--border);
}
.home-dashboard .home-cat-track i { background: var(--primary); }
.home-dashboard .home-cat-row { min-height: 38px; padding: 5px 0; }

/* ---- v2.3 列表行距收紧 ---- */
.home-dashboard .home-recent-row { padding: 9px 0; }
.home-dashboard .home-recent-sub { margin-top: 1px; }
.home-dashboard .home-todo-row { min-height: 40px; padding: 8px 0; }
.home-dashboard .home-card-head { margin-bottom: 10px; }
.home-dashboard .home-spend-card .home-card-head { margin-bottom: 4px; }

/* ---- v2.4 细节收尾 ---- */
/* 桌面 5 个快捷入口：最后一个跨两列，避免 2-2-1 的残缺感 */
@media (min-width: 721px) {
  .home-dashboard .home-quick-actions button:last-child:nth-child(odd) { grid-column: span 2; }
}
/* 进度轨道与分类条同一套观感：加深底色 + 细边，0% 时也看得见 */
.home-dashboard .home-saving-track {
  height: 8px;
  background: var(--primary-light);
  border: 1px solid var(--border);
}

/* ---- v2.5 进度轨道：不用描边，改用极淡的品牌色填充，0% 时才不会被误看成已满 ---- */
.home-dashboard .home-cat-track,
.home-dashboard .home-saving-track {
  border: 0;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
}
.home-dashboard .home-cat-track i,
.home-dashboard .home-saving-track i { background: var(--primary); }

/* ========== 工具箱（2026-11-12） ========== */
/* 页头入口 + 手机底部抽屉 / 桌面锚定浮层。层级 1350：
   高于 #cart-checkout-modal(1300) > .cart-drawer(1200) > .modal(1100) > #mtb-more-panel(1000) > tabbar(900)。 */
.tbx {
  position: fixed;
  inset: 0;
  z-index: 1350;
  pointer-events: none;
}
.tbx[aria-hidden="true"] { visibility: hidden; }
.tbx.is-open { pointer-events: auto; }

.tbx-mask {
  position: absolute;
  inset: 0;
  background: rgba(87, 74, 58, .4);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .22s;
}
.tbx.is-open .tbx-mask { opacity: 1; }

.tbx-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(87, 74, 58, .18);
  overflow: hidden;
}

.tbx-grip { display: none; }

.tbx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.tbx-title { font-size: 15px; font-weight: 600; color: var(--text); }
.tbx-x {
  width: 30px; height: 30px;
  padding: 0; margin: 0;
  border: 0; border-radius: 50%;
  background: var(--bg-soft);
  box-shadow: none;
  color: var(--text-soft);
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tbx-x:hover { background: var(--primary-light); color: var(--primary-dark); }
.tbx-x:active { transform: none; box-shadow: none; }

.tbx-body {
  padding: 4px 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tbx-sep {
  margin: 14px 0 8px;
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: .4px;
}
.tbx-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
/* 可点格子：必须显式清掉全局 button 的胶囊外观 */
.tbx-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  margin: 0;
  min-height: 76px;
  border: 0;
  border-radius: 12px;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tbx-item:hover { background: var(--bg-soft); }
.tbx-item:active { transform: none; box-shadow: none; }
.tbx-ico {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 21px;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.tbx-lb { line-height: 1.25; word-break: break-all; text-align: center; }
.tbx-dot {
  position: absolute;
  top: 6px; right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---- 工具弹窗（计算器 / 倒数日） ---- */
.tbx-tool {
  position: fixed;
  inset: 0;
  z-index: 1360;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tbx-tool[aria-hidden="true"] { display: none; }
.tbx-tool-mask {
  position: absolute;
  inset: 0;
  background: rgba(87, 74, 58, .45);
  backdrop-filter: blur(2px);
}
.tbx-tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 340px;
  max-height: 88vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(87, 74, 58, .22);
  overflow: hidden;
}
.tbx-tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.tbx-tool-title { font-size: 15px; font-weight: 600; color: var(--text); }

/* 计算器 */
.calc-display {
  padding: 18px 18px 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.calc-expr { min-height: 16px; font-size: 12px; color: var(--text-soft); }
.calc-val {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 14px 16px;
}
.calc-key {
  min-height: 52px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  box-shadow: none;
  font: inherit;
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.calc-key:hover { background: var(--primary-light); }
.calc-key:active { transform: none; box-shadow: none; background: var(--primary-light); }
.calc-key.fn { color: var(--primary-dark); font-size: 16px; }
.calc-key.op { color: var(--primary-dark); font-size: 20px; }
.calc-key.eq { background: var(--primary); color: #fff; border-color: transparent; }
.calc-key.eq:hover { background: var(--primary-dark); }
.calc-key.wide { grid-column: span 2; }

/* 倒数日 */
.cd-card { width: 420px; }
.cd-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px auto;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cd-form input {
  min-height: 40px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.cd-form input:focus { outline: none; border-color: var(--primary); }
.cd-add { min-height: 40px; padding: 0 16px; border-radius: 10px; font-size: 13.5px; }
.cd-list { padding: 6px 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cd-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 26px;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.cd-row:last-child { border-bottom: 0; }
.cd-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cd-main b { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-main span { font-size: 12px; color: var(--text-soft); }
.cd-days { font-size: 13.5px; font-weight: 600; color: var(--primary-dark); white-space: nowrap; }
.cd-row.is-today .cd-days { color: var(--warn); }
.cd-row.is-past .cd-main b,
.cd-row.is-past .cd-main span,
.cd-row.is-past .cd-days { color: var(--muted); }
.cd-del {
  width: 26px; height: 26px;
  padding: 0; margin: 0;
  border: 0; border-radius: 50%;
  background: var(--bg-soft);
  box-shadow: none;
  color: var(--text-soft);
  font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.cd-del:hover { background: var(--warn); color: #fff; }
.cd-del:active { transform: none; box-shadow: none; }
.cd-empty {
  padding: 26px 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.7;
}
.cd-empty span { font-size: 12px; }

/* 背景滚动锁 */
body.tbx-open, body.tbx-tool-open { overflow: hidden; }

/* ---- 手机：底部抽屉 + 全屏工具弹窗 ---- */
@media (max-width: 720px) {
  .tbx-mask { background: rgba(87, 74, 58, .45); }
  .tbx-panel {
    left: 0; right: 0; bottom: 0;
    top: auto;
    max-height: 78vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding-bottom: calc(var(--safe-b) + 10px);
    transform: translateY(100%);
    transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  }
  .tbx.is-open .tbx-panel { transform: translateY(0); }
  .tbx-grip {
    display: block;
    width: 38px; height: 4px;
    margin: 8px auto 2px;
    border-radius: 2px;
    background: var(--stroke);
    flex: 0 0 auto;
    touch-action: none;
  }
  .tbx-head { padding: 8px 16px 10px; }
  .tbx-body { padding: 4px 16px 12px; }

  .tbx-tool { padding: 0; }
  .tbx-tool-card {
    width: 100% !important;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    padding-top: var(--safe-t);
    padding-bottom: var(--safe-b);
  }
  .tbx-tool-head { padding: 14px 16px 12px; }
  .calc-display { padding: 24px 20px 16px; }
  .calc-val { font-size: 40px; }
  .calc-pad { gap: 10px; padding: 6px 16px 20px; }
  .calc-key { min-height: 58px; font-size: 21px; }
  .cd-card { width: 100% !important; }
  .cd-form {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px 16px;
  }
  .cd-form input[type="date"] { grid-column: 1; }
  .cd-form .cd-add { grid-column: 2; grid-row: 1 / span 2; align-self: stretch; }
  .cd-list { padding: 6px 16px 20px; }
}

/* ---- 工具箱 v2.1：手机计算器铺满（显示区吸底、键盘贴底，iOS 风格） ---- */
@media (max-width: 720px) {
  .calc-card .calc-display {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 23px 20px 18px;
  }
  .calc-val { font-size: 46px; }
  .calc-pad { flex: 0 0 auto; padding: 0 16px 14px; }
  .calc-key { min-height: 62px; }
}

/* ---- 工具箱 v2.2：桌面是下拉浮层，不需要把整页压暗 ---- */
@media (min-width: 721px) {
  .tbx-mask { display: none; }
}

/* ========== 倒数日 · 纪念日模式 + 首页卡（2026-11-12 v2） ========== */

/* 类型切换：胶囊分段控件，只影响新增 */
.cd-kind {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 10px;
}
.cd-kind-btn {
  flex: 1;
  min-height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cd-kind-btn:hover { background: none; color: var(--primary-dark); }
.cd-kind-btn:active { transform: none; box-shadow: none; }
.cd-kind-btn.is-on {
  background: var(--card);
  color: var(--primary-dark);
  box-shadow: 0 1px 2px rgba(87, 74, 58, .08);
}

/* 列表分组标题 */
.cd-sep {
  margin: 10px 0 2px;
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: .4px;
}
.cd-sep:first-child { margin-top: 4px; }

/* 首页看板：倒数日卡 */
.home-dashboard .home-cd-list { display: flex; flex-direction: column; }
.home-dashboard .home-cd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.home-dashboard .home-cd-row + .home-cd-row { border-top: 1px solid var(--border); }
.home-dashboard .home-cd-row:hover { background: none; }
.home-dashboard .home-cd-row:hover .home-cd-name { color: var(--primary-dark); }
.home-dashboard .home-cd-row:active { transform: none; box-shadow: none; }
.home-dashboard .home-cd-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-dashboard .home-cd-days {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-dark);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 手机端顺序：攒钱目标之前插一张倒数日卡 */
@media (max-width: 720px) {
  .home-countdown { order: 6; }
  .home-saving     { order: 7; }
  .home-accounts   { order: 8; }
  .home-trend      { order: 9; }
}

/* ---- 倒数日 v2.1：修输入框边框（--stroke 是完整 border 值，不能写 border:1px solid var(--stroke)） ---- */
.cd-form input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-sizing: border-box;
  width: 100%;
}
.cd-form input::placeholder { color: var(--muted); }
.cd-form input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
}

/* 手机：类型分段占整行，名称/日期各占一行，添加按钮跨两行 */
@media (max-width: 720px) {
  .cd-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 14px 16px;
  }
  .cd-form .cd-kind { grid-column: 1 / -1; grid-row: 1; }
  .cd-form #cd-title { grid-column: 1; grid-row: 2; }
  .cd-form #cd-date  { grid-column: 1; grid-row: 3; }
  .cd-form .cd-add {
    grid-column: 2; grid-row: 2 / span 2;
    align-self: stretch;
    min-height: 0;
  }
}

/* ========== 工具箱 · 七个新工具（2026-11-12） ========== */
/* 通用：卡片内最后一个区块负责滚动，避免手机全屏时撑破 */
.tbx-tool-card > .unit-list,
.tbx-tool-card > .note-list,
.tbx-tool-card > .todo-list,
.tbx-tool-card > .weight-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- 单位换算 ---- */
.unit-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.unit-tabs::-webkit-scrollbar { display: none; }
.unit-tab {
  flex: 0 0 auto;
  min-height: 32px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--card);
  box-shadow: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.unit-tab:hover { background: var(--bg-soft); }
.unit-tab.is-on {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}
.unit-tab:active { transform: none; }
.unit-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
  padding: 4px 16px 10px;
}
.unit-input-row input,
.unit-input-row select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  box-sizing: border-box;
  width: 100%;
}
.unit-input-row input:focus { outline: none; border-color: var(--primary); background: var(--card); }
.unit-list { padding: 0 16px 16px; }
.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.unit-row:last-child { border-bottom: 0; }
.unit-row.is-src .unit-name { color: var(--primary-dark); font-weight: 600; }
.unit-name { color: var(--text-soft); }
.unit-val { font-weight: 600; color: var(--text); }
.unit-empty {
  padding: 22px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
}

/* ---- 记事本 ---- */
.note-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.note-form textarea {
  grid-column: 1;
  min-height: 72px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  box-sizing: border-box;
}
.note-form textarea:focus { outline: none; border-color: var(--primary); background: var(--card); }
.note-save { grid-column: 2; align-self: end; min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; }
.note-list { padding: 0 16px 16px; }
.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 10px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.note-row:last-child { border-bottom: 0; }
.note-row.is-editing { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.note-main p {
  margin: 0 0 4px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.note-main span { font-size: 11.5px; color: var(--text-soft); }
.note-empty {
  padding: 26px 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.7;
}
.note-empty span { font-size: 12px; }

/* ---- 摇一摇 ---- */
.dice-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 16px 0;
  padding: 3px;
  background: var(--bg-soft);
  border-radius: 10px;
}
.dice-tab {
  flex: 1;
  min-height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
}
.dice-tab.is-on { background: var(--card); color: var(--primary-dark); box-shadow: 0 1px 2px rgba(87, 74, 58, .08); }
.dice-tab:active { transform: none; }
.dice-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 16px 18px;
}
.dice-face {
  width: 128px;
  height: 128px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 24%, transparent);
  font-size: 58px;
  font-weight: 700;
  color: var(--primary-dark);
  cursor: pointer;
  transition: transform .12s;
  text-align: center;
  padding: 8px;
  box-sizing: border-box;
  word-break: break-all;
  line-height: 1.15;
}
.dice-face.is-text { font-size: 26px; font-weight: 600; }
.dice-face.is-pop { transform: scale(1.08); }
.dice-go {
  margin: 0 16px 16px;
  min-height: 46px;
  border-radius: 12px;
  font-size: 14px;
}
.draw-box { padding: 0 16px 16px; }
.draw-box[hidden] { display: none; }
.draw-box input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-sizing: border-box;
}
.draw-box input:focus { outline: none; border-color: var(--primary); background: var(--card); }
.draw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  max-height: 150px;
  overflow-y: auto;
}
.draw-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--bg-soft);
  box-shadow: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.draw-chip i { font-style: normal; font-size: 11px; color: var(--text-soft); }
.draw-chip:hover i { color: var(--warn); }
.draw-empty { font-size: 12.5px; color: var(--text-soft); }

/* ---- 游戏通用 ---- */
.game-card { width: 400px; }
.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 6px;
  font-size: 12.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.game-bar b { font-size: 16px; color: var(--text); }
.game-stage { display: flex; justify-content: center; padding: 4px 16px 2px; }
.game-canvas {
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
  touch-action: none;
}
.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 14px;
}
.game-tip { font-size: 12px; color: var(--text-soft); }
.game-restart { min-height: 36px; padding: 0 14px; border-radius: 10px; font-size: 12.5px; font-weight: 500; }

/* ---- 2048 ---- */
.g2048-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  aspect-ratio: 1;
  margin: 0 16px;
  padding: 8px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
  box-sizing: border-box;
  touch-action: none;
}
.g2048-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  background: var(--card);
  transition: background .1s;
  font-variant-numeric: tabular-nums;
}
.g2048-cell.v2    { background: var(--card); }
.g2048-cell.v4    { background: color-mix(in srgb, var(--primary) 14%, var(--card)); }
.g2048-cell.v8    { background: color-mix(in srgb, var(--primary) 26%, var(--card)); }
.g2048-cell.v16   { background: color-mix(in srgb, var(--primary) 38%, var(--card)); }
.g2048-cell.v32   { background: color-mix(in srgb, var(--primary) 50%, var(--card)); color: #fff; }
.g2048-cell.v64   { background: color-mix(in srgb, var(--primary) 62%, var(--card)); color: #fff; }
.g2048-cell.v128  { background: color-mix(in srgb, var(--primary) 72%, var(--card)); color: #fff; font-size: 17px; }
.g2048-cell.v256  { background: color-mix(in srgb, var(--primary) 80%, var(--card)); color: #fff; font-size: 17px; }
.g2048-cell.v512  { background: color-mix(in srgb, var(--primary) 88%, var(--card)); color: #fff; font-size: 17px; }
.g2048-cell.v1024 { background: var(--primary-dark); color: #fff; font-size: 15px; }
.g2048-cell.v2048 { background: var(--primary-dark); color: #fff; font-size: 15px; }
.g2048-cell.vmax  { background: #8a5a3b; color: #fff; font-size: 15px; }
.g2048-over {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 14px;
  background: rgba(87, 74, 58, .55);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.g2048-over span { font-size: 12px; font-weight: 400; opacity: .85; }

/* ---- 待办清单 ---- */
.todo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.todo-form input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-sizing: border-box;
  width: 100%;
}
.todo-form input:focus { outline: none; border-color: var(--primary); background: var(--card); }
.todo-add { min-height: 40px; padding: 0 16px; border-radius: 10px; font-size: 13.5px; }
.todo-list { padding: 0 16px 16px; }
.todo-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.todo-row:last-child { border-bottom: 0; }
.todo-check {
  width: 22px; height: 22px;
  margin: 0; padding: 0;
  border: 1.5px solid var(--stroke-color, var(--border));
  border-radius: 50%;
  background: var(--card);
  box-shadow: none;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.todo-row.is-done .todo-check { background: var(--primary); border-color: transparent; }
.todo-row.is-done .todo-title { color: var(--muted); text-decoration: line-through; }
.todo-title { font-size: 13.5px; color: var(--text); word-break: break-word; }

/* ---- 体重记录 ---- */
.weight-form {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 84px auto;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.weight-form input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-sizing: border-box;
  width: 100%;
}
.weight-form input:focus { outline: none; border-color: var(--primary); background: var(--card); }
.weight-save { min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 13.5px; }
.weight-chart { padding: 10px 16px 0; }
.weight-svg { width: 100%; height: auto; display: block; }
.weight-range {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px 8px;
  font-size: 11px;
  color: var(--text-soft);
}
.weight-list { padding: 0 16px 16px; }
.weight-sum {
  padding: 10px 0;
  font-size: 13px;
  color: var(--text-soft);
  border-bottom: 1px solid var(--border);
}
.weight-sum b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.weight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 26px;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.weight-row:last-child { border-bottom: 0; }
.weight-row span { color: var(--text-soft); }
.weight-row b { font-variant-numeric: tabular-nums; color: var(--text); }

/* 手机：全屏卡片时拉平内边距，列表占据剩余高度 */
@media (max-width: 720px) {
  .game-card { width: 100% !important; }
  .game-stage { flex: 0 0 auto; }
  .g2048-board { margin: 0 16px; }
  .dice-face { width: 140px; height: 140px; font-size: 64px; }
  .unit-input-row input,
  .unit-input-row select { font-size: 16px; }
}

/* ---- 工具 v2 微调：2048 低数值对比度、贪吃蛇卡片底部不空 ---- */
.g2048-cell.v4  { background: color-mix(in srgb, var(--primary) 20%, var(--card)); }
.g2048-cell.v8  { background: color-mix(in srgb, var(--primary) 34%, var(--card)); }
.g2048-cell.v16 { background: color-mix(in srgb, var(--primary) 46%, var(--card)); }
.game-card { display: flex; flex-direction: column; }
.game-stage { flex: 0 0 auto; }

/* ========== 摇一摇 · 3D 骰子 / 翻转硬币 / 抽签（2026-11-12） ========== */
.dice-scene {
  --dice: 96px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 172px;
  perspective: 900px;
}
.dice-scene > *[hidden] { display: none !important; }
/* 落定时整个舞台轻弹一下（不能作用在 cube 上，否则会盖掉它的 rotate） */
.dice-scene.is-land { animation: diceLandPop .3s ease-out; }
@keyframes diceLandPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---- 骰子：六个面拼成立方体 ---- */
.dice-cube {
  position: relative;
  width: var(--dice);
  height: var(--dice);
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.22, .9, .28, 1.02);
  will-change: transform;
}
.dice-side {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: calc(var(--dice) * .06);
  padding: calc(var(--dice) * .12);
  box-sizing: border-box;
  border-radius: calc(var(--dice) * .16);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: inset 0 -2px 6px rgba(87, 74, 58, .06);
}
.dice-side i {
  display: block;
  border-radius: 50%;
  background: var(--primary-dark);
  opacity: 0;
}
.dice-side i.on { opacity: 1; }
/* 六个面：s1 前 s6 后 s3 右 s4 左 s2 上 s5 下 */
.dice-side.s1 { transform: translateZ(calc(var(--dice) / 2)); }
.dice-side.s6 { transform: rotateY(180deg) translateZ(calc(var(--dice) / 2)); }
.dice-side.s3 { transform: rotateY(90deg) translateZ(calc(var(--dice) / 2)); }
.dice-side.s4 { transform: rotateY(-90deg) translateZ(calc(var(--dice) / 2)); }
.dice-side.s2 { transform: rotateX(90deg) translateZ(calc(var(--dice) / 2)); }
.dice-side.s5 { transform: rotateX(-90deg) translateZ(calc(var(--dice) / 2)); }

/* ---- 硬币：上抛 + 绕竖轴翻转 ---- */
.coin-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  transform-style: preserve-3d;
}
.coin-wrap.is-throw { animation: coinThrow 1.15s cubic-bezier(.35, .1, .4, 1); }
@keyframes coinThrow {
  0%   { transform: translateY(0); }
  28%  { transform: translateY(-56px); }
  55%  { transform: translateY(-66px); }
  82%  { transform: translateY(-14px); }
  100% { transform: translateY(0); }
}
.coin {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.2, .85, .25, 1);
  will-change: transform;
}
.coin-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  backface-visibility: hidden;
  font-size: 38px;
  font-weight: 700;
  color: var(--primary-dark);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .9), transparent 60%),
    color-mix(in srgb, var(--primary) 18%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 32%, transparent);
  box-shadow:
    inset 0 0 0 7px color-mix(in srgb, var(--primary) 10%, transparent),
    0 6px 18px rgba(87, 74, 58, .12);
}
.coin-back { transform: rotateY(180deg); }

/* ---- 抽签结果 ---- */
.draw-result {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  min-height: 92px;
  padding: 10px 20px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--primary) 26%, transparent);
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
  word-break: break-all;
  box-sizing: border-box;
}
.draw-result.is-pop { animation: drawPop .4s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drawPop {
  0%   { transform: scale(.65); opacity: 0; }
  60%  { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}
.draw-chip.is-hot {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  transform: scale(1.06);
}
.draw-chip { transition: background .12s, color .12s, transform .12s; }

/* ---- 结果说明行 ---- */
.dice-caption {
  min-height: 20px;
  padding: 2px 16px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
}

@media (max-width: 720px) {
  .dice-scene { --dice: 110px; min-height: 190px; }
  .coin-wrap { width: 148px; height: 148px; }
  .coin-face { font-size: 42px; }
  .draw-result { font-size: 26px; min-height: 100px; }
}

/* ---- 摇一摇 v2.1：骰子去描边（避免 3D 侧面露出细线）+ 立体感 + 间距 ---- */
.dice-side {
  border: 0;
  background:
    linear-gradient(145deg, #fff 0%, color-mix(in srgb, var(--primary) 7%, var(--card)) 100%);
  box-shadow:
    inset 0 0 0 1px var(--border),
    inset 0 -4px 10px rgba(87, 74, 58, .07);
}
.dice-go { margin-top: 10px; }
.dice-scene { padding: 8px 0 0; }

/* ---- 批量录入（手机）v2：高度自适应，不再写死 100dvh ----
   原来 height: calc(100dvh - tabbar - 64px) 在小屏刚好，大屏（如 Mate X6 内屏）
   会在「备注」和数字键盘之间留一大块空白，看着像串位；
   改成按内容撑高 + 上限不压底部 tabbar。 */
@media (max-width: 720px) {
  #modal-batch .modal-card.modal-batch {
    height: auto;
    max-height: calc(100dvh - var(--tabbar-h-real) - 28px);
    padding-bottom: calc(10px + var(--safe-b));
  }
  /* 分类多时在中间自己滚，不撑破卡片 */
  .mb-cats {
    flex: 0 1 auto;
    max-height: 33dvh;
    overflow-y: auto;
    align-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  /* 键盘不再被 margin-top:auto 顶到底，跟着内容走 */
  .mb-pad { margin-top: 4px; }
}
