/* ============================================================
   家账簿 HomeLedger — 样式表
   服务端渲染，零前端框架依赖
   ============================================================ */

:root {
  --emoji-font: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji","Twemoji Mozilla","EmojiOne Color","Android Emoji",sans-serif;
  --bg: #f4f6fb;
  --card: #ffffff;
  --card-2: #fafbfe;
  --border: #e9edf3;
  --border-strong: #dbe1ea;
  --text: #1f2937;
  --text-2: #475467;
  --muted: #8b95a5;
  --primary: #4f7cff;
  --primary-soft: #eef3ff;
  --primary-deep: #3563e9;
  --income: #16a34a;
  --income-soft: #e9f9ef;
  --expense: #f5222d;
  --expense-soft: #fff1f0;
  --warn: #fa8c16;
  --warn-soft: #fff7e6;
  --info: #1677ff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --sidebar-w: 224px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0e131f;
  --card: #161d2c;
  --card-2: #1b2333;
  --border: #232c3f;
  --border-strong: #2e3950;
  --text: #e6eaf3;
  --text-2: #b9c2d4;
  --muted: #7f8ba2;
  --primary-soft: #1b2540;
  --income-soft: #12291d;
  --expense-soft: #2c1619;
  --warn-soft: #2c2113;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
}

/* ============================================================
   界面配色主题（accent）—— 与明暗模式正交：
   theme 管底色（light/dark），accent 管主色（6 套）。
   两属性都挂在 <html> 上，所以选择器是 [data-theme][data-accent] 组合。
   新增配色：在这里补两组变量 + db.js 的 ACCENT_THEMES 加一项即可。
   ============================================================ */
[data-accent="blue"] {
  --primary: #4f7cff; --primary-soft: #eef3ff; --primary-deep: #3563e9;
}
[data-accent="forest"] {
  --primary: #0e9f6e; --primary-soft: #e7f7f0; --primary-deep: #0b8259;
}
[data-accent="amber"] {
  --primary: #e07b1a; --primary-soft: #fdf1e3; --primary-deep: #b9620d;
}
[data-accent="rose"] {
  --primary: #e0457b; --primary-soft: #fdeef4; --primary-deep: #bf3165;
}
[data-accent="violet"] {
  --primary: #7c5cfc; --primary-soft: #f1edff; --primary-deep: #6338e8;
}
[data-accent="graphite"] {
  --primary: #5a6472; --primary-soft: #eef1f4; --primary-deep: #454e5a;
}
/* 深色模式：主色提亮一档，soft 换成深底，保证对比度 */
[data-theme="dark"][data-accent="blue"] {
  --primary: #6b95ff; --primary-soft: #1b2540; --primary-deep: #8aabff;
}
[data-theme="dark"][data-accent="forest"] {
  --primary: #34c58b; --primary-soft: #12332a; --primary-deep: #5bd6a4;
}
[data-theme="dark"][data-accent="amber"] {
  --primary: #f09a45; --primary-soft: #33240f; --primary-deep: #ffb76b;
}
[data-theme="dark"][data-accent="rose"] {
  --primary: #f0689a; --primary-soft: #351726; --primary-deep: #ff8fb8;
}
[data-theme="dark"][data-accent="violet"] {
  --primary: #9d85ff; --primary-soft: #241d47; --primary-deep: #b9a8ff;
}
[data-theme="dark"][data-accent="graphite"] {
  --primary: #9aa6b5; --primary-soft: #232a33; --primary-deep: #b6c0cd;
}

/* --------------------- 图标库选择器 --------------------- */
.icon-picker-mask {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 20, 30, .45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.icon-picker-mask.hidden { display: none !important; }
.icon-picker {
  width: min(680px, 100%); max-height: min(76vh, 640px);
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  animation: aiPop .18s ease;
}
.icon-picker-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: var(--card-2);
}
.icon-picker-head b { font-size: 14px; }
.icon-picker-head input {
  flex: 1; min-width: 0; padding: 7px 12px; border-radius: 999px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); background: var(--card); color: var(--text); outline: none;
}
.icon-picker-head input:focus { border-color: var(--primary); }
.icon-picker-x {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 4px 8px; border-radius: 8px;
}
.icon-picker-x:hover { color: var(--text); background: var(--card); }
.icon-picker-body { overflow-y: auto; padding: 12px 14px 16px; }
.icon-picker-group { margin-bottom: 14px; }
.icon-picker-group-name { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
}
.icon-picker-item {
  appearance: none; cursor: pointer; font-family: inherit;
  height: 44px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--card-2); font-size: 21px; line-height: 1;
  display: grid; place-items: center; transition: all .12s;
}
.icon-picker-item:hover { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.08); }
.icon-picker-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* --------------------- 账户管理：分组折叠 --------------------- */.acc-group-sum {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.acc-group-sum::-webkit-details-marker { display: none; }
.acc-group-sum:hover h2 { color: var(--primary); }
.acc-fold-ico {
  display: inline-flex; color: var(--muted); margin-right: 2px;
}

/* --------------------------- 设置页：配色选择 --------------------------- */.accent-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; margin-top: 10px;
}
.accent-cell {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card-2);
}
.accent-cell.on { border-color: var(--primary); background: var(--primary-soft); }
.accent-dot {
  width: 26px; height: 26px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px -2px rgba(0,0,0,.25);
}
.accent-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.accent-cell.on .accent-label { color: var(--primary); font-weight: 600; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 420px at 85% -10%, color-mix(in srgb, var(--primary) 5%, transparent) 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; opacity: .85; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
svg { vertical-align: middle; }

/* ------------------------------ 布局骨架 ------------------------------ */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px;
  font-weight: 700; font-size: 16px;
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 62%, #ffffff));
  color: #fff; display: grid; place-items: center; font-size: 16px;
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--primary) 70%, transparent);
}

.ledger-switch {
  margin: 0 4px 14px; padding: 9px 10px;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ledger-switch label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.ledger-switch select {
  width: 100%; border: 0; background: transparent; color: var(--text);
  font-size: 13px; font-weight: 600; font-family: var(--font); cursor: pointer; outline: none;
}

.nav-group { margin-bottom: 6px; }
.nav-title { font-size: 11px; color: var(--muted); padding: 10px 10px 6px; font-weight: 600; letter-spacing: .04em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--card-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  position: relative;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item .ico { width: 17px; text-align: center; font-size: 14px; line-height: 1; font-family: var(--emoji-font); display: inline-flex; align-items: center; justify-content: center; }
.nav-item .ico { filter: saturate(1.12) brightness(1.06); }
/* 亮色主题下反过来压一点饱和，避免 emoji 在纯白底上过艳 */
[data-theme="light"] .nav-item .ico { filter: saturate(1.02) brightness(.98); }
.nav-item .count {
  margin-left: auto; font-size: 11px; background: var(--expense); color: #fff;
  border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 17px;
}

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--card-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 600; flex: 0 0 30px;
}
.user-meta { min-width: 0; }
.user-meta b { display: block; font-size: 13px; font-weight: 600; }
.user-meta span { display: block; font-size: 11px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { flex: 1; min-width: 0; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---------------- 顶栏用户菜单 ---------------- */
.user-menu { position: relative; flex: none; }
.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--card);
  border-radius: 999px; padding: 4px 10px 4px 4px;
  cursor: pointer; font-family: var(--font); color: var(--text);
  transition: box-shadow .15s, border-color .15s;
}
.user-menu-btn:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.user-menu-name { font-size: 13px; font-weight: 600; max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { font-size: 10px; color: var(--muted); }
.user-menu-drop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80;
  min-width: 220px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
}
.user-menu-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; font-family: var(--font); cursor: pointer; text-align: left;
}
.user-menu-item:hover { background: var(--card-2); }
/* 自传头像：圆形图片，替代首字母色块 */
.avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
/* 可点击换头像的头像：手型 + 悬停光圈提示 */
.avatar-click { cursor: pointer; transition: box-shadow .15s ease; }
.avatar-click:hover { box-shadow: 0 0 0 3px rgba(79, 124, 255, .35); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
/* 窄屏：用户菜单收成纯头像圆标 */
@media (max-width: 860px) {
  .user-menu-name, .user-menu-caret { display: none; }
  .user-menu-btn { padding: 3px; border-radius: 50%; }
}

.content { padding: 20px 22px 96px; max-width: 1240px; width: 100%; }

.mobile-nav { display: none; }

/* ------------------------------ 通用组件 ------------------------------ */

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 16px; margin-bottom: 16px;
}
.card.tight { padding: 12px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 12px;
}
.card-head h2 { flex: 1; min-width: 0; }
.card-head .hint { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 650; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }

.amount { font-variant-numeric: tabular-nums; font-weight: 650; }
.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }
.amount.neutral { color: var(--text-2); }
.amount.big { font-size: 26px; letter-spacing: -.02em; }
.amount.xl { font-size: 30px; letter-spacing: -.025em; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--card); color: var(--text); font-size: 13.5px; font-family: var(--font);
  font-weight: 550; cursor: pointer; line-height: 1.4; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--card-2); color: var(--text); }
.btn-danger { color: var(--expense); border-color: color-mix(in srgb, var(--expense) 35%, var(--border)); }
.btn-danger:hover { background: var(--expense-soft); color: var(--expense); border-color: var(--expense); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 7px 9px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); font-weight: 550; margin-bottom: 6px; }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="month"], input[type="time"], input[type="search"],
select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--card); color: var(--text);
  font-size: 14px; font-family: var(--font); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type="color"] { width: 40px; height: 34px; padding: 2px; border-radius: 8px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; vertical-align: -2px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

.amount-input { position: relative; }
.amount-input input { font-size: 30px; font-weight: 700; padding: 12px 14px 12px 40px; letter-spacing: -.02em; }
.amount-input .cur { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--muted); font-weight: 600; }

/* 徽标 / 标签 */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: 11.5px;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
.chip.primary { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.chip.income { background: var(--income-soft); border-color: transparent; color: var(--income); }
.chip.expense { background: var(--expense-soft); border-color: transparent; color: var(--expense); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tag-pill {
  display: inline-block; padding: 1px 7px; border-radius: 99px;
  font-size: 11px; background: var(--card-2); border: 1px solid var(--border); color: var(--text-2);
}

/* 统计卡 */
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat .value { margin-top: 5px; font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 11.5px; margin-top: 3px; color: var(--muted); }
.stat .delta.up { color: var(--expense); }
.stat .delta.down { color: var(--income); }

/* 交易列表 */
.txn-day { border-bottom: 1px solid var(--border); }
.txn-day:last-child { border-bottom: 0; }
.txn-day-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 2px 7px; font-size: 12px; color: var(--muted);
  background: var(--card); position: sticky; top: 57px; z-index: 5;
}
.txn-day-head .day-sum { margin-left: auto; display: flex; gap: 12px; font-variant-numeric: tabular-nums; }

/* ---------------------- 账单行：左右滑动操作（iCost 式） ----------------------
   .txn 是滑动容器，.txn-face 跟着手指平移，底层动作条被「揭开」。
   右滑露出左边三条（退款 / 编辑 / 删除），左滑露出右边一条（复制）。
   桌面端不支持滑动也不用担心，悬停时 .txn-act 那排按钮照样能用。 */
.txn { position: relative; overflow: hidden; border-radius: var(--radius-sm); }
.txn + .txn { border-top: 1px solid var(--border); border-radius: 0; }
.txn + .txn:hover { border-radius: var(--radius-sm); }

.txn-face {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 6px; background: var(--card);
  transform: translateX(0); transition: transform .18s ease;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.txn:hover .txn-face { background: var(--card-2); }
.txn.sw-l .txn-face { transform: translateX(222px); }
.txn.sw-r .txn-face { transform: translateX(-74px); }
.txn.dragging .txn-face { transition: none; }

.txn-acts { position: absolute; top: 0; bottom: 0; z-index: 1; display: flex; }
.txn-acts-l { left: 0; }
.txn-acts-r { right: 0; }
.txn-act-btn {
  appearance: none; border: 0; cursor: pointer; font-family: inherit; width: 74px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: #fff; text-decoration: none;
}
.txn-act-btn .ico { font-size: 15px; line-height: 1; font-family: var(--emoji-font); }
.txn-act-btn.refund { background: #2f80ed; }
.txn-act-btn.edit { background: #78838f; }
.txn-act-btn.del { background: #d64545; }
.txn-act-btn.copy { background: #0f9d58; }
.txn-act-btn:active { filter: brightness(.92); }
.txn-ico {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 36px;
  display: grid; place-items: center; font-size: 17px; background: var(--card-2);
}
.txn-main { flex: 1; min-width: 0; }
.txn-title { font-size: 14px; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.txn-title .note { color: var(--muted); font-weight: 400; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.txn-amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 15px; white-space: nowrap; }
.txn-act { opacity: 0; transition: opacity .15s; display: flex; gap: 4px; }
.txn:hover .txn-act { opacity: 1; }
.txn.pending { opacity: .7; }

.list-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.list-empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* 进度条 */
.progress { background: var(--card-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }

/* 图例 / 排行 */
.legend-row, .rank-row {
  display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px;
}
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }
.legend-name, .rank-name { flex: 0 0 auto; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-bar, .rank-track { flex: 1; height: 7px; background: var(--card-2); border-radius: 99px; overflow: hidden; min-width: 30px; border: 1px solid var(--border); }
.legend-bar i, .rank-track i { display: block; height: 100%; border-radius: 99px; }
.legend-pct { flex: 0 0 46px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.legend-val, .rank-val { flex: 0 0 84px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; font-size: 12.5px; }
.rank-idx { flex: 0 0 16px; color: var(--muted); font-size: 11px; text-align: center; }
.rank-name { flex: 0 0 100px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--card-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* 分类选择栅格 */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px; }
.cat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); cursor: pointer; font-size: 11.5px; color: var(--text-2);
  text-align: center; transition: all .13s;
}
.cat-item:hover { border-color: var(--primary); color: var(--primary); }
.cat-item.selected { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.cat-item .ci { font-size: 19px; }
.cat-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* 类型切换 */
.type-tabs { display: flex; gap: 6px; background: var(--card-2); padding: 4px; border-radius: 11px; border: 1px solid var(--border); flex-wrap: wrap; }
.type-tabs a, .type-tabs button {
  flex: 1; min-width: 62px; text-align: center; padding: 8px 6px; border-radius: 8px;
  font-size: 13px; color: var(--text-2); border: 0; background: transparent; cursor: pointer;
  font-family: var(--font); font-weight: 550; white-space: nowrap;
}
.type-tabs .active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs a {
  padding: 9px 13px; font-size: 13.5px; color: var(--text-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }

/* 提示条 */
.flash {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; animation: slideIn .28s ease;
}
.flash.success { background: var(--income-soft); color: #12693a; border-color: color-mix(in srgb, var(--income) 25%, transparent); }
.flash.error { background: var(--expense-soft); color: #a8071a; border-color: color-mix(in srgb, var(--expense) 25%, transparent); }
.flash.info { background: var(--primary-soft); color: var(--primary-deep); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: #ad4e00; border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
[data-theme="dark"] .flash.success { color: #56d68c; }
[data-theme="dark"] .flash.error { color: #ff7b7b; }
[data-theme="dark"] .flash.info { color: #8aabff; }
[data-theme="dark"] .flash.warn { color: #ffb74d; }

.notice {
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.6;
  background: var(--card-2); border: 1px dashed var(--border-strong); color: var(--text-2);
}
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.notice.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* 空状态 */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 38px; display: block; margin-bottom: 10px; opacity: .8; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px 0 4px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 8px;
  border-radius: 8px; border: 1px solid var(--border); font-size: 13px; color: var(--text-2); background: var(--card);
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager .cur { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .gap { border: 0; background: transparent; }

/* 上传区 */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 30px 18px; text-align: center; cursor: pointer;
  background: var(--card-2); transition: all .18s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .big { font-size: 30px; display: block; margin-bottom: 8px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.thumb { position: relative; width: 78px; height: 78px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 19px; height: 19px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; cursor: pointer; line-height: 1;
}
.thumb .tag { position: absolute; left: 0; right: 0; bottom: 0; font-size: 9px; background: rgba(0,0,0,.55); color: #fff; text-align: center; }

/* 草稿卡（AI 识别结果） */
.draft {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px;
  background: var(--card); margin-bottom: 10px;
}
.draft-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.draft-grid { display: grid; grid-template-columns: 118px 1fr 1fr; gap: 9px; }
.draft-grid .field { margin-bottom: 0; }
.confidence { font-size: 10.5px; padding: 1px 6px; border-radius: 99px; }
.confidence.high { background: var(--income-soft); color: var(--income); }
.confidence.mid { background: var(--warn-soft); color: var(--warn); }
.confidence.low { background: var(--expense-soft); color: var(--expense); }

/* 图表容器 */
.chart-box { width: 100%; overflow: hidden; }
.chart-legend-inline { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }

/* 登录页 */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1000px 520px at 12% -8%, #e8efff 0%, transparent 62%),
              radial-gradient(820px 460px at 100% 0%, #e6f7f4 0%, transparent 55%), var(--bg);
}
[data-theme="dark"] .auth-wrap {
  background: radial-gradient(1000px 520px at 12% -8%, #16203a 0%, transparent 62%),
              radial-gradient(820px 460px at 100% 0%, #12261f 0%, transparent 55%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand .brand-logo { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.auth-brand b { font-size: 17px; display: block; }
.auth-brand span { font-size: 12px; color: var(--muted); }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 18px; }

/* 详情行 */
.kv { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { flex: 0 0 88px; color: var(--muted); }
.kv .v { flex: 1; word-break: break-all; }

/* 日历 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 11.5px; color: var(--muted); padding: 6px 0; font-weight: 600; }
.cal-cell {
  min-height: 62px; border-radius: 10px; border: 1px solid var(--border); padding: 6px 7px;
  background: var(--card); display: flex; flex-direction: column; gap: 2px; position: relative;
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--primary); border-width: 1.6px; }
.cal-cell.active { cursor: pointer; }
.cal-cell.active:hover { border-color: var(--primary); background: var(--primary-soft); }
.cal-cell .d { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-cell.today .d { color: var(--primary); }
.cal-cell .e { font-size: 10.5px; color: var(--expense); font-weight: 600; }
.cal-cell .i { font-size: 10.5px; color: var(--income); font-weight: 600; }

/* 图库 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; background: var(--card); }
.gallery img { width: 100%; height: 132px; object-fit: cover; display: block; cursor: zoom-in; background: var(--card-2); }
.gallery figcaption { padding: 7px 9px; font-size: 11.5px; color: var(--muted); }
.gallery figcaption b { display: block; color: var(--text-2); font-size: 12.5px; }

/* 工具类 */
.scroll-x { overflow-x: auto; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.sticky-side { position: sticky; top: 72px; }

/* 滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* --------------------------- AI 记账助手 --------------------------- */

.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #ffffff));
  color: #fff; font-size: 24px;
  box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--primary) 85%, transparent);
  display: grid; place-items: center; transition: transform .18s, box-shadow .18s, opacity .2s;
}
.ai-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 14px 30px -8px color-mix(in srgb, var(--primary) 90%, transparent); }
.ai-fab:active { transform: scale(.95); }
/* 滚动中淡出：宽表末列（含右固定列）不被浮动按钮压住数字 */
.ai-fab.is-scrolling { opacity: .16; transform: scale(.9); pointer-events: none; }
.ai-fab.is-scrolling:hover, .ai-fab.is-scrolling:focus-visible { opacity: 1; transform: translateY(-2px) scale(1.05); pointer-events: auto; }
/* 指针落在宽矩阵上时让位：读表场景下按钮退成浅影，不遮挡任何数值 */
body:has(.ar-matrix:hover) .ai-fab { opacity: .12; transform: scale(.86); }

/* 全站 SVG 图标：默认跟随字号，颜色继承 currentColor */
.ico-svg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; fill: currentColor; }
.ico-svg-lg { width: 30px; height: 30px; }

.ai-panel {
  position: fixed; right: 22px; bottom: 88px; z-index: 70;
  width: 372px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 120px);
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  animation: aiPop .22s ease;
}
@keyframes aiPop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--card-2);
}
.ai-head-avatar {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #ffffff));
  color: #fff;
  display: grid; place-items: center; font-size: 17px;
}
.ai-head-meta { flex: 1; min-width: 0; }
.ai-head-meta b { display: block; font-size: 13.5px; }
.ai-head-meta span { display: block; font-size: 11px; color: var(--muted); }
.ai-icon-btn {
  border: 0; background: transparent; cursor: pointer; font-size: 14px;
  color: var(--muted); padding: 5px; border-radius: 7px; line-height: 1;
}
.ai-icon-btn:hover { background: var(--card); color: var(--text); }

.ai-msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-bubble {
  max-width: 88%; padding: 9px 12px; border-radius: 14px;
  font-size: 13px; line-height: 1.55; word-break: break-word;
}
.ai-bubble.bot { align-self: flex-start; background: var(--card-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.ai-bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble em { font-style: normal; color: var(--primary); font-weight: 600; }
.ai-bubble.user em { color: #fff; }
.ai-bubble img { max-width: 150px; border-radius: 9px; display: block; margin-top: 6px; border: 1px solid var(--border); }
.ai-bubble.error { background: var(--expense-soft); color: var(--expense); border-color: transparent; }
.ai-bubble.error a { color: inherit; text-decoration: underline; }

.ai-record { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.ai-record:last-child { border-bottom: 0; }
.ai-record .ico { font-size: 15px; flex: 0 0 auto; font-family: var(--emoji-font); }
.ai-record .m { flex: 1; min-width: 0; }
.ai-record .m b { display: block; font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-record .m span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-record .amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-record .amt.income { color: var(--income); }
.ai-record .amt.expense { color: var(--expense); }
.ai-warn { font-size: 11px; color: var(--warn); margin-top: 7px; line-height: 1.5; }
.ai-meta { font-size: 10.5px; color: var(--muted); margin-top: 7px; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.ai-typing { display: inline-flex; gap: 4px; padding: 3px 2px; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: aiBlink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.ai-thumbs { display: flex; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; }
.ai-thumbs .t { position: relative; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.ai-thumbs .t img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-thumbs .t button {
  position: absolute; top: 0; right: 0; width: 16px; height: 16px; border: 0;
  border-radius: 0 0 0 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 9px; cursor: pointer; line-height: 1;
}

.ai-inputbar { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--card-2); }
.ai-inputbar textarea {
  flex: 1; resize: none; min-height: 38px; max-height: 110px;
  padding: 8px 11px; border-radius: 12px; font-size: 13px; line-height: 1.5;
}
.ai-send {
  width: 38px; height: 38px; flex: 0 0 38px; border: 0; border-radius: 12px;
  background: var(--primary); color: #fff; font-size: 15px; cursor: pointer;
  transition: background .15s, transform .1s;
}
.ai-send:hover { background: var(--primary-deep); }
.ai-send:active { transform: scale(.94); }
.ai-send:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .content { padding: 14px 14px 92px; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 17px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 13px; border-radius: 13px; }
  .draft-grid { grid-template-columns: 1fr 1fr; }
  .draft-grid .field:first-child { grid-column: span 2; }
  .txn-day-head { top: 53px; }
  .stat .value { font-size: 19px; }
  .amount.big { font-size: 23px; }
  .cal-cell { min-height: 52px; padding: 4px; }
  .cal-cell .e, .cal-cell .i { font-size: 9.5px; }
  .table.responsive th:nth-child(n+5), .table.responsive td:nth-child(n+5) { display: none; }

  /* 移动端底部导航 */
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    justify-content: space-around; align-items: flex-end;
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
    font-size: 10.5px; color: var(--muted); padding: 5px 0;
  }
  .mobile-nav a .ico { font-size: 17px; line-height: 1.2; font-family: var(--emoji-font); }
  .mobile-nav a.active { color: var(--primary); font-weight: 600; }
  .mobile-nav .fab {
    flex: 0 0 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff;
    display: grid; place-items: center; font-size: 24px; margin: 0 6px;
    box-shadow: 0 8px 20px -6px rgba(79, 124, 255, .75); transform: translateY(-12px);
  }
  .mobile-nav .fab .ico { font-size: 26px; }

  /* AI 助手：避开底部导航 */
  .ai-fab { right: 14px; bottom: 84px; width: 48px; height: 48px; font-size: 21px; }
  .ai-panel { right: 12px; bottom: 140px; height: min(480px, calc(100vh - 170px)); }
}

@media (max-width: 520px) {
  .grid-4, .grid-5 { grid-template-columns: 1fr 1fr; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend-val, .rank-val { flex: 0 0 70px; }
  .rank-name { flex: 0 0 74px; }
}

@media print {
  .sidebar, .topbar, .mobile-nav, .btn { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ------------------------------ 关于页 ------------------------------ */

.about-hero { display: flex; flex-direction: column; gap: 18px; padding: 22px; }
.about-hero-main { display: flex; gap: 16px; align-items: flex-start; }

.about-features { gap: 12px; }
.about-feature {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card-2, transparent); transition: transform .15s ease, border-color .15s ease;
}
.about-feature:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.about-feature .ico {
  flex: 0 0 38px; height: 38px; border-radius: 10px; font-size: 19px;
  display: grid; place-items: center; background: var(--primary-soft);
}

.about-feedback { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
@media (min-width: 821px) {
  .about-feedback { flex-direction: row; align-items: center; justify-content: space-between; }
  .about-fb-text { flex: 1; min-width: 0; padding-right: 18px; }
}

.about-timeline { position: relative; padding-left: 18px; }
.about-timeline::before {
  content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px;
  width: 2px; border-radius: 1px; background: var(--border);
}
.tl-item { position: relative; padding: 0 0 18px 14px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-dot {
  position: absolute; left: -18px; top: 7px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ============================================================
   记一笔 —— 严格对齐 iCost 模板布局（v6）
   结构：顶栏（✕/tabs/保存再记）→ 上部一级分类网格 → 底部固定区
        （chips → 金额卡 → 键盘）。
   二级分类、账户、标签、优惠、日期、更多 全部收进同一个底部 sheet。

   ★ 覆盖层的安全铁律（v2 踩过的坑，别再犯）：
     自带 hidden 的块必须显式写 `X[hidden]{display:none !important}`。
     作者样式的 display:flex 会盖掉浏览器默认的 [hidden]{display:none}，
     于是遮罩常驻、透明却仍吃掉点击 —— 表现为「界面点不到、像卡死」。
     本版全站只有一个 sheet + 一个 mask，且都有显式兜底。
   ============================================================ */

.content:has(.ql) { max-width: 720px; padding: 16px 20px 40px; margin: 0 auto; }

/* 记账页的键盘铺满右下角，AI 悬浮球会压住最右一列（运算符键），一律隐藏 */
body.page-quick-entry #aiFab { display: none; }

.ql {
  --ql-accent: var(--expense);
  --ql-accent-soft: var(--expense-soft);
  --ql-tile: var(--card-2);
  --ql-tile-on: color-mix(in srgb, var(--ql-accent) 15%, var(--card-2));
  display: flex; flex-direction: column;
  /* 固定高度（而非 min-height）：这样上半段分类区内部滚动，
     键盘永远钉在视口底部 —— 与 iCost 的行为一致，也不会出现「最后一行按键被裁掉」 */
  height: calc(100dvh - 132px);
  min-height: 480px;
}
.ql[data-cur-type="expense"]  { --ql-accent: var(--expense); --ql-accent-soft: var(--expense-soft); }
.ql[data-cur-type="income"]   { --ql-accent: var(--income);  --ql-accent-soft: var(--income-soft);  }
.ql[data-cur-type="transfer"] { --ql-accent: var(--primary); --ql-accent-soft: var(--primary-soft); }

/* ------------------------------- 顶栏 ------------------------------- */
.ql-head { display: flex; align-items: center; gap: 8px; padding: 2px 0 14px; }
.ql-x {
  width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center;
  border-radius: 50%; background: var(--card); border: 1px solid var(--border);
  color: var(--text-2); text-decoration: none; font-size: 14px; line-height: 1;
}
.ql-x:hover { color: var(--text); border-color: var(--border-strong); }

.ql-tabs {
  flex: 0 1 auto; margin: 0 auto; display: flex; justify-content: center; gap: 2px; padding: 3px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 999px;
}
.ql-tabs button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 7px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  color: var(--muted); font-family: inherit; transition: all .16s;
}
.ql-tabs button:hover { color: var(--text-2); }
.ql-tabs button.active {
  background: var(--ql-accent); color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--ql-accent) 55%, transparent);
}

/* 「保存再记」在模板里是一行纯色文字，不是按钮块 */
.ql-btn-next {
  appearance: none; cursor: pointer; font-family: inherit;
  flex: 0 0 auto; padding: 8px 4px; border: 0; background: transparent;
  color: var(--ql-accent); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.ql-btn-next:hover { text-decoration: underline; }

/* -------------------------- 上下两段布局 -------------------------- */
/* 上半段可滚（分类多的时候不至于顶掉键盘），下半段钉在底部。
   底部加一道渐隐，提示「这里还能往下滚」，避免看到被硬切一半的图标行。 */
.ql-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 14px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
}
.ql-bottom { flex: 0 0 auto; display: flex; flex-direction: column; }

/* ★ 铁律兜底：这一段覆盖了本页所有自带 hidden 的块 */
.ql-sheet[hidden], .ql-mask[hidden], .ql-panel[hidden],
.ql-cats[hidden], .ql-transfer[hidden], .ql-catwrap[hidden], .ql-chip-x[hidden],
.ql-chip-n[hidden], .ql-help[hidden] { display: none !important; }

/* --------------------------- 一级分类磁贴 ---------------------------
   模板观感：5 列圆形磁贴，右下角一个 ⊕ 提示「还有下一层」。 */
.ql-cats { padding: 2px 0 0; }
.ql-cat-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px 2px;
}
.ql-cat {
  appearance: none; cursor: pointer; font-family: inherit; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0; border: 0; background: transparent; min-width: 0;
}
.ql-cat-ico {
  position: relative; width: 54px; height: 54px; flex: 0 0 54px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--ql-tile); font-size: 24px; line-height: 1;
  transition: background .15s, transform .12s;
}
.ql-cat:hover .ql-cat-ico { background: color-mix(in srgb, var(--ql-accent) 12%, var(--ql-tile)); }
.ql-cat:active .ql-cat-ico { transform: scale(.94); }
.ql-cat.on .ql-cat-ico { background: var(--ql-accent); box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--ql-accent) 80%, transparent); }
/* 有子分类时右下角的小 ⊕（模板里的「可展开」标记） */
.ql-cat-plus {
  position: absolute; right: -2px; bottom: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1;
}
.ql-cat-name {
  font-size: 11.5px; line-height: 1.2; color: var(--text-2); text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ql-cat.on .ql-cat-name { color: var(--ql-accent); font-weight: 600; }
.ql-cat-set .ql-cat-ico { background: transparent; border: 1px dashed var(--border-strong); font-size: 20px; }
.ql-cat-picked {
  min-height: 18px; font-size: 11.5px; color: var(--muted);
  padding: 12px 2px 0; text-align: center;
}

/* ----------------------------- 转账双卡 ----------------------------- */
.ql-transfer { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.ql-tr-acc {
  appearance: none; cursor: pointer; font-family: inherit; text-align: left;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--card);
  transition: border-color .15s;
}
.ql-tr-acc:hover { border-color: var(--border-strong); }
.ql-tr-acc.has-val { border-color: color-mix(in srgb, var(--ql-accent) 45%, var(--border)); }
.ql-tr-ico {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--card-2); font-size: 20px; line-height: 1;
}
.ql-tr-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ql-tr-label { font-size: 11px; color: var(--muted); }
.ql-tr-name { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-tr-acc.has-val .ql-tr-name { color: var(--ql-accent); }
.ql-tr-chev { color: var(--muted); font-size: 18px; line-height: 1; }
.ql-tr-swap {
  align-self: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--card); color: var(--text-2);
  cursor: pointer; font-size: 15px; line-height: 1; transition: all .15s;
}
.ql-tr-swap:hover { border-color: var(--ql-accent); color: var(--ql-accent); }

/* ------------------------------- chips ------------------------------- */
.ql-chips {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0 10px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.ql-chips::-webkit-scrollbar { display: none; }
.ql-chip {
  appearance: none; cursor: pointer; font-family: inherit; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px; max-width: 200px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-2); font-size: 12.5px;
  transition: all .15s;
}
.ql-chip:hover { border-color: var(--border-strong); color: var(--text); }
.ql-chip.has-val, .ql-chip.on {
  background: var(--ql-accent-soft); color: var(--ql-accent); font-weight: 600;
  border-color: color-mix(in srgb, var(--ql-accent) 40%, var(--border));
}
.ql-chip.open { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ql-accent) 14%, transparent); }
.ql-chip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-chip-x {
  font-style: normal; cursor: pointer; flex: 0 0 auto;
  width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ql-accent) 20%, transparent);
  color: var(--ql-accent); font-size: 11px; line-height: 1;
}
.ql-chip-x:hover { background: var(--ql-accent); color: #fff; }
.ql-chip-n {
  font-style: normal; font-size: 10.5px; line-height: 1;
  background: var(--ql-accent); color: #fff;
  border-radius: 99px; padding: 2px 5px; min-width: 15px; text-align: center;
}
.ql-chip-gear { padding: 6px 11px; font-size: 13px; }

/* ------------------------------- 金额 ------------------------------- */
.ql-amount {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px 6px;
}
.ql-amt-line { display: flex; align-items: baseline; gap: 5px; }
.ql-cur { font-size: 22px; font-weight: 700; color: var(--ql-accent); opacity: .9; }
/* ★ 选择器必须写 `.ql .ql-amt-input`：全局有 `input[type="text"]{border:...}`（特异性 0,1,1），
   只写单类名（0,1,0）会被它盖掉，金额框里会凭空多一圈输入框边框。 */
.ql .ql-amt-input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: 44px; font-weight: 700; letter-spacing: -.5px;
  color: var(--ql-accent); padding: 0; font-variant-numeric: tabular-nums;
  box-shadow: none; border-radius: 0;
}
.ql .ql-amt-input:focus { border: 0; box-shadow: none; background: transparent; }
.ql-amt-input::placeholder { color: color-mix(in srgb, var(--ql-accent) 30%, transparent); }
.ql-amt-sub {
  display: flex; align-items: center; gap: 12px;
  border-top: 1px dashed var(--border); margin-top: 2px; padding: 6px 0 4px;
}
.ql-datebtn {
  appearance: none; cursor: pointer; font-family: inherit; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: transparent; padding: 2px 0;
  color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.ql-datebtn:hover { color: var(--ql-accent); }
.ql-datebtn-ico { font-size: 12px; line-height: 1; }
.ql .ql-note {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: 13px; color: var(--text-2); padding: 2px 0;
  box-shadow: none; border-radius: 0; height: auto;
}
.ql .ql-note:focus { border: 0; box-shadow: none; background: transparent; }
.ql-note::placeholder { color: var(--muted); }
.ql-hidden-check { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ------------------------------- 键盘 ------------------------------- */
.ql-pad {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; user-select: none; padding-top: 10px;
}
.ql-pad button {
  appearance: none; cursor: pointer; font-family: inherit;
  height: 52px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 21px; font-weight: 500; line-height: 1;
  transition: background .1s, transform .06s;
  font-variant-numeric: tabular-nums;
}
.ql-pad button:hover { background: var(--card-2); }
.ql-pad button:active { transform: scale(.96); background: var(--ql-tile-on); }
.ql-pad .ql-pad-op { font-size: 15px; color: var(--text-2); }
.ql-pad .ql-pad-done {
  grid-column: 4; grid-row: 3 / span 2; height: auto;
  background: var(--ql-accent); border-color: var(--ql-accent); color: #fff;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--ql-accent) 80%, transparent);
}
.ql-pad .ql-pad-done:hover { background: color-mix(in srgb, var(--ql-accent) 88%, #000); }

/* ============================ 底部 sheet ============================
   全站唯一覆盖层。桌面收窄居中，手机通栏贴底（模板形态）。 */
.ql-mask {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(12, 16, 24, .46);
  animation: qlFade .16s ease-out;
}
@keyframes qlFade { from { opacity: 0 } to { opacity: 1 } }

.ql-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 121;
  display: flex; flex-direction: column;
  max-height: 76vh;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -14px 38px -14px rgba(0, 0, 0, .32);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: qlSheetUp .22s cubic-bezier(.22, 1, .36, 1);
}
@keyframes qlSheetUp { from { transform: translateY(18px); opacity: 0 } to { transform: none; opacity: 1 } }

.ql-sheet-head {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px;
  padding: 10px 12px 8px; border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.ql-sheet-head b { text-align: center; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-sheet-x {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card-2); color: var(--text-2); font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.ql-sheet-x:hover { background: var(--border); color: var(--text); }
.ql-sheet-view {
  appearance: none; cursor: pointer; font-family: inherit;
  border: 0; background: transparent; color: var(--muted);
  font-size: 13px; padding: 6px 8px; border-radius: 8px;
}
.ql-sheet-view:hover { background: var(--card-2); color: var(--text); }
.ql-sheet-body { overflow-y: auto; padding: 12px 14px 20px; flex: 1 1 auto; min-height: 0; }

/* 二级分类网格（sheet 内） */
.ql-catgrid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px 2px;
}
.ql-catcell {
  appearance: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 0; border: 0; background: transparent; min-width: 0;
}
.ql-catcell-ico {
  font-family: var(--emoji-font);
  width: 50px; height: 50px; flex: 0 0 50px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ql-tile);
  font-size: 22px; line-height: 1; transition: background .15s;
}
.ql-catcell:hover .ql-catcell-ico { background: color-mix(in srgb, var(--ql-accent) 12%, var(--ql-tile)); }
.ql-catcell.on .ql-catcell-ico { background: var(--ql-accent); }
.ql-catcell-name {
  font-size: 11px; line-height: 1.2; color: var(--text-2); text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ql-catcell.on .ql-catcell-name { color: var(--ql-accent); font-weight: 600; }
.ql-catcell.is-parent .ql-catcell-name { color: var(--muted); }
/* 列表视图：一列行，信息密度更高 */
.ql-catgrid.is-list { grid-template-columns: 1fr; gap: 2px; }
.ql-catgrid.is-list .ql-catcell {
  flex-direction: row; gap: 12px; padding: 9px 8px; border-radius: 10px; text-align: left;
}
.ql-catgrid.is-list .ql-catcell:hover { background: var(--card-2); }
.ql-catgrid.is-list .ql-catcell-ico { width: 32px; height: 32px; flex-basis: 32px; font-size: 16px; }
.ql-catgrid.is-list .ql-catcell-name { font-size: 13.5px; text-align: left; }

/* sheet 内的搜索框（账户 / 标签） */
.ql-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 10px;
}
.ql-search:focus-within { border-color: var(--primary); background: var(--card); }
.ql-search-ico { font-size: 12px; line-height: 1; opacity: .7; }
.ql-search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-family: inherit; font-size: 13.5px; color: var(--text);
  box-shadow: none; border-radius: 0; padding: 0; height: auto;
}
/* 同上：全局 input[type=text]:focus 会画出蓝色描边，这里必须显式清掉，
   否则搜索框会出现「框里还有一个框」的双层边框 */
.ql-search input:focus { border: 0; box-shadow: none; background: transparent; }
.ql-search input::placeholder { color: var(--muted); }

/* 账户列表 */
.ql-acc-group { font-size: 11px; color: var(--muted); font-weight: 600; padding: 10px 6px 4px; letter-spacing: .02em; }
.ql-acc-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  padding: 9px 6px; border-radius: 10px; text-align: left;
}
.ql-acc-item:hover { background: var(--card-2); }
.ql-acc-ico {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  display: grid; place-items: center; background: var(--card-2); font-size: 15px; line-height: 1;
}
.ql-acc-name { flex: 1; min-width: 0; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ql-acc-bal { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.ql-acc-item.on { background: var(--ql-accent-soft); }
.ql-acc-item.on .ql-acc-name { color: var(--ql-accent); font-weight: 600; }
.ql-acc-item.on .ql-acc-bal { color: var(--ql-accent); }

/* 标签多选 */
.ql-tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ql-tagchip {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-2);
  color: var(--text-2); font-size: 12.5px;
}
.ql-tagchip:hover { border-color: var(--border-strong); color: var(--text); }
.ql-tagchip.on { background: var(--ql-accent); border-color: var(--ql-accent); color: #fff; font-weight: 600; }
.ql-empty { padding: 14px 6px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------------------------- sheet 内表单 ---------------------------- */
.ql-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ql-field > span { font-size: 11.5px; color: var(--muted); }
.ql-field input, .ql-field select {
  width: 100%; padding: 9px 12px; border-radius: 10px; font-family: inherit; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--card-2); color: var(--text); outline: none;
}
.ql-field input:focus, .ql-field select:focus { border-color: var(--ql-accent); background: var(--card); }
.ql-help { font-size: 11.5px; color: var(--muted); line-height: 1.6; margin: 2px 0 10px; }
/* 优惠算式预览：一行小字，正数常色、异常红字 */
.ql-disc-preview { font-size: 12px; color: var(--text-2); margin: -2px 0 10px; min-height: 16px; }
.ql-disc-preview b { color: var(--ql-accent, #4f7cff); font-weight: 700; }
.ql-disc-preview.is-bad { color: #b3261e; font-weight: 600; }

.ql-disc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* 只有一个字段的面板（手续费）别留半条空白 */
.ql-disc-row.is-one { grid-template-columns: 1fr; }
.ql-disc-quick { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.ql-disc-quick button {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text-2); font-size: 12px;
}
.ql-disc-quick button:hover { border-color: var(--ql-accent); color: var(--ql-accent); }
.ql-disc-quick .ql-quick-done {
  margin-left: auto; background: var(--ql-accent); border-color: var(--ql-accent);
  color: #fff; font-weight: 600;
}
.ql-details { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.ql-details > summary { cursor: pointer; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.ql-extra-types { display: flex; flex-wrap: wrap; gap: 7px; }
.ql-extra {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-2); color: var(--text-2); font-size: 12.5px; text-align: left;
}
.ql-extra.on { border-color: var(--ql-accent); background: var(--ql-accent-soft); color: var(--ql-accent); font-weight: 600; }
.ql-more-links {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.ql-btn-ghost {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 12.5px;
  padding: 7px 13px; border-radius: 999px;
  border: 1px dashed var(--border-strong); background: transparent; color: var(--muted);
}
.ql-btn-ghost:hover { color: var(--ql-accent); border-color: var(--ql-accent); }

/* ----------------------------- 日期滚轮 ----------------------------- */
.ql-wheel {
  position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  height: 180px; overflow: hidden;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 12px;
  touch-action: pan-y; margin-bottom: 12px;
}
.ql-wheel-band {
  position: absolute; left: 8px; right: 8px; top: 72px; height: 36px;
  border-radius: 8px; pointer-events: none;
  background: var(--ql-accent-soft);
  border: 1px solid color-mix(in srgb, var(--ql-accent) 30%, transparent);
}
.ql-wheel-col {
  height: 180px; overflow-y: auto; scroll-snap-type: y mandatory;
  scrollbar-width: none; position: relative; z-index: 1;
}
.ql-wheel-col::-webkit-scrollbar { display: none; }
.ql-wheel-item {
  scroll-snap-align: center; height: 36px; width: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--text-2); background: transparent; border: 0;
  font-family: inherit; font-variant-numeric: tabular-nums; cursor: pointer;
}
.ql-wheel-item.on { color: var(--ql-accent); font-weight: 700; }
.ql-wheel-pad { cursor: default; }

/* ---------------------------- 平板 / 手机 ---------------------------- */
@media (max-width: 820px) {
  /* 沉浸式：去掉外层留白与标题栏 */
  .content:has(.ql) { padding: 0; max-width: none; margin: 0; }
  .topbar:has(+ .content .ql) { display: none; }
  body:has(.ql) .mobile-nav { display: none; }

  .ql { height: 100dvh; min-height: 0; padding: 0 12px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .ql-head { padding: 10px 0 12px; }
  .ql-tabs button { padding: 7px 14px; font-size: 13.5px; }
  .ql-x { width: 34px; height: 34px; flex-basis: 34px; }
  .ql-btn-next { font-size: 13px; }

  .ql-cat-grid { gap: 14px 0; }
  .ql-cat-ico { width: 50px; height: 50px; flex-basis: 50px; font-size: 22px; }
  .ql-cat-name { font-size: 10.5px; }

  .ql-chips { padding-bottom: 8px; }
  .ql-amount { border-radius: 14px; }
  .ql-amt-input { font-size: 38px; }

  .ql-pad { gap: 7px; padding-top: 8px; }
  .ql-pad button { height: 50px; font-size: 20px; border-radius: 11px; }

  .ql-sheet { max-height: 80vh; }
  .ql-sheet-body { padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .ql-catgrid { gap: 14px 0; }
  .ql-catcell-ico { width: 46px; height: 46px; flex-basis: 46px; font-size: 20px; }
}

/* 桌面：sheet 收窄居中，不横跨整个宽屏 */
@media (min-width: 900px) {
  .ql-mask { background: rgba(12, 16, 24, .34); }
  .ql-sheet {
    left: 50%; right: auto; transform: translateX(-50%);
    width: 640px; bottom: 28px;
    border-radius: 18px; border: 1px solid var(--border);
    animation: qlFade .18s ease-out;
  }
}

/* 桌面窗口高度通常只有 800~900px：把磁贴与键盘压紧一点，
   让常见分类（20 来个）能整行显示完，少一次内部滚动 */
@media (min-width: 821px) {
  .ql-cat-grid { gap: 12px 2px; }
  .ql-cat { gap: 6px; }
  .ql-cat-ico { width: 48px; height: 48px; flex-basis: 48px; font-size: 21px; }
  .ql-cat-name { font-size: 11px; }
  .ql-cat-picked { padding-top: 8px; min-height: 14px; }
  .ql .ql-amt-input { font-size: 40px; }
  .ql-amount { padding: 10px 16px 4px; }
  .ql-pad button { height: 48px; }
  .ql-scroll {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 26px), transparent);
  }
}

@media (max-width: 380px) {
  .ql-cat-ico { width: 46px; height: 46px; flex-basis: 46px; font-size: 20px; }
  .ql-catcell-ico { width: 42px; height: 42px; flex-basis: 42px; font-size: 18px; }
  .ql-pad button { height: 46px; }
}

/* ---------------------- 优惠：原价划线 + 省了多少 ---------------------- */
.txn-orig {
  font-size: 11px; font-weight: 400; color: var(--muted);
  text-decoration: line-through; text-decoration-thickness: 1px;
  line-height: 1.3; font-variant-numeric: tabular-nums;
}
.txn-disc {
  font-size: 10.5px; font-weight: 500; color: var(--warn);
  line-height: 1.4; margin-top: 1px;
}

/* 表格合计行（往来净额用到） */
table tfoot th {
  border-top: 2px solid var(--border-strong);
  background: var(--card-2);
  font-weight: 600; font-size: 12.5px; color: var(--text);
  padding: 10px 12px; text-align: left;
}
table tfoot th.num { text-align: right; }

/* 记账页沉浸式兜底：不依赖 :has()，由模板脚本给 body 打 class。
   老浏览器走这条，新浏览器与 :has() 规则叠加（幂等，无副作用）。 */
@media (max-width: 820px) {
  body.page-quick-entry .topbar { display: none; }
  body.page-quick-entry .mobile-nav { display: none; }
  body.page-quick-entry .content {
    padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0));
    max-width: none;
  }
}

/* ============================================================
   长按「记一笔」→ 快捷模板选择器
   与记账页的 sheet 同一套语言：遮罩 + 底部升起，桌面收窄居中。
   ============================================================ */
.tpl-picker {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(12, 16, 24, .46);
  animation: qlFade .16s ease-out;
}
.tpl-picker.hidden { display: none !important; }
.tpl-picker-box {
  width: 100%; max-height: 72vh;
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -14px 38px -14px rgba(0, 0, 0, .32);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: qlSheetUp .22s cubic-bezier(.22, 1, .36, 1);
}
.tpl-picker-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px 10px; border-bottom: 1px solid var(--border);
}
.tpl-picker-head b { flex: 1; font-size: 15px; }
.tpl-picker-manage { font-size: 12.5px; color: var(--muted); }
.tpl-picker-manage:hover { color: var(--primary); }
.tpl-picker-x {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card-2); color: var(--text-2); font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}
.tpl-picker-x:hover { background: var(--border); color: var(--text); }
.tpl-picker-search { padding: 10px 14px 4px; }
.tpl-picker-search input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-2);
  color: var(--text); font-family: inherit; font-size: 13.5px; outline: none;
}
.tpl-picker-search input:focus { border-color: var(--primary); background: var(--card); }
.tpl-picker-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 14px 12px; }
.tpl-picker-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}
.tpl-picker-empty { padding: 22px 6px; font-size: 12.5px; color: var(--muted); line-height: 1.8; text-align: center; }
/* 必须排除 .btn：`.tpl-picker-empty a`(0,1,1) 会压过 `.btn-primary`(0,1,0)，
   导致蓝底按钮上写蓝字、文字看不见 */
.tpl-picker-empty a:not(.btn) { color: var(--primary); }

/* 一条模板都没有时的引导卡：说清「为什么没有」+ 给两条出口，避免长按后看到空列表无路可走 */
.tpl-picker-empty-lg {
  padding: 26px 18px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tpl-picker-empty-ico {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card-2); font-size: 24px; line-height: 1; margin-bottom: 4px;
}
.tpl-picker-empty-lg b { font-size: 14.5px; color: var(--text); font-weight: 600; }
.tpl-picker-empty-lg p { margin: 2px 0 4px; max-width: 320px; font-size: 12.5px; line-height: 1.75; }
.tpl-picker-empty-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }

.tpl-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; cursor: pointer; font-family: inherit;
  padding: 10px 8px; border-radius: 12px; text-align: left;
}
.tpl-card:hover { background: var(--card-2); }
.tpl-card-ico {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
  display: grid; place-items: center; background: var(--card-2); font-size: 19px; line-height: 1;
}
.tpl-card:hover .tpl-card-ico { background: var(--primary-soft); }
.tpl-card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tpl-card-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-card-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-card-use { font-size: 11px; color: var(--muted); flex: 0 0 auto; }

@media (min-width: 900px) {
  .tpl-picker { align-items: center; }
  .tpl-picker-box {
    width: 560px; max-height: 70vh;
    border-radius: 18px; border: 1px solid var(--border);
    animation: qlFade .18s ease-out;
  }
}

/* ============================================================
   总览页：三列布局（iCost Mac 总览式「一眼看全」）
   左列看趋势与流水，中列看当日与预算，右列看固定支出与往来。
   列宽按信息密度分配（1.25 : 1 : .92），窄屏逐级降列，不出现半屏空白。
   ============================================================ */
.content:has(.dash-grid) { max-width: 1500px; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .92fr);
  gap: 16px; align-items: start;
}
.dash-col { min-width: 0; }
.dash-col > .card:last-child { margin-bottom: 0; }

.dash-donut { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.dash-donut-legend { width: 100%; }

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 三列 → 两列：第三列整体下移成一行两列，信息不丢、留白不增 */
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-col-3 {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px; align-items: start;
  }
  .dash-col-3 > .card { margin-bottom: 0; }
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-col-3 { grid-template-columns: 1fr; }
}

/* 导航里的自绘图标略大于 emoji，视觉重量才接近（emoji 有透明留白，SVG 是满幅） */
.nav-item .ico-svg { width: 16px; height: 16px; }
/* ---- AI 位图头像尺寸（public/img/ai-bot.png）------------------------------
   其它图标都是线性 SVG，只有 AI 助手是一张 3D 机器人头像图。
   位图在 16px 下五官全糊，导航里给到 18px、悬浮球给到 34px，
   聊天面板头像 22px，正好都是「一眼能认出是脸」的下限。 */
.ico-svg-lg { width: 34px; height: 34px; }
.nav-item .ico-svg, a[href="/ai"] .ico-svg { width: 18px; height: 18px; }
.ai-head-avatar .ico-svg { width: 22px; height: 22px; }

/* ============================================================
   应收管理 / 往来闭环（2026-10-27）
   只做「新增类」，不动任何既有类，删掉本段即回到改造前的视觉。
   全部颜色走 :root 变量，dark 模式与 6 套 accent 自动适配。
   ============================================================ */

/* ---- 顶部勾稽校验条：通过是绿，差异是红，一眼判断账本健康度 ---- */
.ar-verdict { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.ar-verdict-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.ar-verdict-icon {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; line-height: 1;
}
.ar-verdict-icon.ok { background: var(--income-soft); color: var(--income); }
.ar-verdict-icon.bad { background: var(--expense-soft); color: var(--expense); }
.ar-verdict-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.ar-verdict-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.ar-verdict-sub b { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---- 四类款项卡片：.stat 被 <a> 包住时必须去掉链接默认样式 ---- */
a.ar-stat { display: block; color: inherit; text-decoration: none; }
a.ar-stat:hover { text-decoration: none; }
a.ar-stat .value { font-variant-numeric: tabular-nums; }

/* ---- 客户色点 ---- */
.ar-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle; flex: 0 0 8px;
}

/* ---- 合计行 ---- */
.ar-total-row { border-top: 2px solid var(--border-strong); }
.ar-total-row td { background: var(--card-2); }

/* ---- 计划表单：两行自适应网格，窄屏自动落单列 ---- */
.ar-plan-form { padding: 4px 0 2px; }
.ar-plan-grid {
  display: grid; gap: 12px 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}
.ar-plan-submit { display: flex; align-items: flex-end; }
.ar-plan-submit .btn { width: 100%; }

/* ---- 计划表：进度条要有确定高度，否则 .progress 会塌成 0 ---- */
.ar-plan-table td { vertical-align: middle; }
.ar-plan-table .progress { height: 7px; width: 84px; }
.ar-plan-table .progress i { background: var(--primary); }
.ar-row-overdue { box-shadow: inset 3px 0 0 var(--expense); }
.ar-row-overdue td { background: color-mix(in srgb, var(--expense-soft) 55%, transparent); }
.ar-row-bad td { background: color-mix(in srgb, var(--expense-soft) 55%, transparent); }

/* ---- 对账表：左右值上下两行，避免长中文把列撑爆 ---- */
.ar-recon-table td { vertical-align: top; }
.ar-recon-table td.num > div:last-child { font-variant-numeric: tabular-nums; }

/* ---- 客户 × 月份矩阵：首列吸附，横向滚动仍能看到客户名 ---- */
.ar-matrix { font-size: 12.5px; }
.ar-matrix th, .ar-matrix td { padding: 7px 8px; white-space: nowrap; }
.ar-matrix .sticky-col {
  position: sticky; left: 0; z-index: 1;
  background: var(--card);
  box-shadow: 1px 0 0 var(--border);
  max-width: 168px; overflow: hidden; text-overflow: ellipsis;
}
.ar-matrix thead .sticky-col { background: var(--card-2); }
.ar-matrix tfoot .sticky-col { background: var(--card-2); }
.ar-matrix .ar-sum { background: var(--card-2); }
.ar-matrix tbody tr:hover td { background: var(--primary-soft); }
.ar-matrix tbody tr:hover .sticky-col { background: var(--primary-soft); }

/* ---- 窄屏：计划表横滚，别把按钮挤成两行 ---- */
@media (max-width: 760px) {
  .ar-verdict { flex-wrap: wrap; }
  .ar-verdict .btn { width: 100%; }
  .ar-plan-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- 净额桥：毛额 / 抵减 / 净额 三段并列，解释「47 万从哪来」 ----
   不画 − 和 =：分隔交给竖线（.ar-bridge-seg），运算关系由标题文案表达。 */
.ar-bridge-row {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  padding-bottom: 10px; border-bottom: 1px dashed var(--border);
}
.ar-bridge-n {
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-top: 2px; color: var(--text);
}
.ar-bridge-n.income { color: var(--income); }
.ar-bridge-n.expense { color: var(--expense); }

/* ---- 客户 TOP 表：日期列不能被挤成两行，客户名允许省略并保留 title ---- */
.ar-top-table { font-size: 13px; }
.ar-top-table th, .ar-top-table td { padding: 8px 9px; }
.ar-top-table td:last-child, .ar-top-table th:last-child { white-space: nowrap; }
.ar-top-table td:first-child { max-width: 148px; }
.ar-top-table td:first-child a {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- 计划表单：第一行五个字段等宽，第二行备注撑满 + 按钮靠右 ----
   用显式两段而不是 auto-fit：auto-fit 会把「备注」和「提交」挤到第三行不同列，
   七个格子对六个列宽，最后必然错位。 */
.ar-plan-row {
  display: grid; gap: 12px 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.ar-plan-row2 {
  display: flex; gap: 14px; align-items: flex-end; margin-top: 12px;
}
.ar-plan-row2 .field { flex: 1 1 auto; min-width: 0; }
.ar-plan-row2 .btn { flex: 0 0 auto; height: 38px; padding: 0 22px; }
@media (max-width: 1080px) {
  .ar-plan-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .ar-plan-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ar-plan-row2 { flex-wrap: wrap; }
  .ar-plan-row2 .btn { width: 100%; }
}

/* ---- 计划操作列：登记输入框 + 登记 + 取消必须并排，不能各占一行 ---- */
.ar-plan-table td:last-child { min-width: 188px; }
.ar-plan-acts {
  display: flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: nowrap;
}
.ar-plan-acts form { display: flex; align-items: center; gap: 4px; }
.ar-plan-acts input[name="amount"] {
  width: 96px; padding: 5px 7px; font-size: 12.5px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.ar-plan-table .progress { min-width: 64px; }

/* ---- 矩阵：压缩列宽让 12 个月尽量一屏放下；「当前未结」列固定右侧，
        横向滚动时始终可见（合计里最该盯的一列） ---- */
.ar-matrix th, .ar-matrix td { padding: 6px 6px; }
.ar-matrix { font-size: 12px; }
.ar-matrix .ar-sum-last {
  position: sticky; right: 0; z-index: 2;
  background: var(--card-2);
  box-shadow: -1px 0 0 var(--border);
}
.ar-matrix tbody tr:hover .ar-sum-last { background: var(--primary-soft); }

/* ---- 一键排计划的小链接：低调但可点，不抢金额的视觉重量 ---- */
.ar-quick { color: var(--primary); text-decoration: none; font-size: 11.5px; }
.ar-quick:hover { text-decoration: underline; }

/* ---- 窄屏：净额桥改竖排，运算符去掉、改用左侧竖线分段，
        否则「=」会孤零零掉在行尾，读起来像算式没写完 ---- */
@media (max-width: 640px) {
  .ar-bridge-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .ar-bridge-seg {
    border-left: 3px solid var(--border-strong);
    border-right: 0; padding-left: 10px; padding-right: 0;
  }
  .ar-bridge-seg.is-net { border-left-color: var(--primary); }
  /* 卡片头部在窄屏允许换行，别把右侧链接挤掉 */
  .ar-bridge + .card .card-head,
  .ar-verdict { flex-wrap: wrap; }
}

/* ============================================================
   饼图下钻 + 总览账户分组折叠 + 表内搜索（2026-10-27）
   全部为新增类，不改既有类；命名前缀 pie-/drill-/acc-fold-/tbl-filter
   ============================================================ */

/* ------------------------------ 饼图与下钻 ------------------------------ */

.pie-drill { display: flex; flex-direction: column; gap: 10px; }
.pie-canvas { display: flex; justify-content: center; }
.pie-svg { display: block; }
.pie-slice { transition: opacity .16s ease, filter .16s ease; }
.pie-svg.is-clickable .pie-slice { cursor: pointer; }
.pie-svg.is-clickable .pie-slice:hover { filter: brightness(1.08) saturate(1.05); }
.pie-svg.is-clickable .pie-slice:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* 有选中时，其它扇区退成背景；选中那块保持原色 */
.pie-drill:not([data-on=""]) .pie-slice { opacity: .32; }
.pie-drill:not([data-on=""]) .pie-slice.is-on { opacity: 1; filter: brightness(1.06); }

.pie-side {
  /* 固定最小高度：切换面板时卡片不跳，鼠标不用重新找位置 */
  min-height: 196px;
}
.drill-panel[hidden] { display: none; }
.pie-tip { padding-top: 8px; border-top: 1px dashed var(--border); margin-top: 6px; }

.legend-row.is-clickable { cursor: pointer; border-radius: 7px; transition: background .14s; }
.legend-row.is-clickable:hover { background: var(--card-2); }
.legend-row.is-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.legend-row.is-on { background: var(--primary-soft); box-shadow: inset 2px 0 0 var(--primary); }
.legend-row.is-on .legend-name { color: var(--primary); font-weight: 600; }

.drill-head {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.drill-back {
  appearance: none; border: 1px solid var(--border); background: var(--card);
  color: var(--text-2); font: inherit; font-size: 11.5px; line-height: 1;
  padding: 5px 8px; border-radius: 7px; cursor: pointer; flex: 0 0 auto;
}
.drill-back:hover { border-color: var(--primary); color: var(--primary); }
.drill-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-sum { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; }

.drill-row { display: flex; align-items: center; gap: 7px; padding: 4px 0; font-size: 12.5px; }
.drill-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.drill-name { flex: 0 1 auto; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-bar {
  flex: 1 1 30px; height: 6px; background: var(--card-2); border-radius: 99px;
  overflow: hidden; min-width: 24px; border: 1px solid var(--border);
}
.drill-bar i { display: block; height: 100%; border-radius: 99px; }
.drill-pct { flex: 0 0 42px; text-align: right; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.drill-val { flex: 0 0 84px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.drill-foot { padding-top: 7px; margin-top: 4px; border-top: 1px dashed var(--border); font-size: 11.5px; color: var(--muted); }

/* 三级下钻：二级行可点 + 懒加载流水明细 */
.drill-row.is-clickable { cursor: pointer; border-radius: 6px; padding-left: 3px; padding-right: 3px; margin-left: -3px; margin-right: -3px; }
.drill-row.is-clickable:hover { background: var(--card-2); }
.drill-row.is-clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.drill-row.is-open .drill-name { font-weight: 650; }
.drill-detail { margin: 6px 0 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-2); padding: 7px 9px; max-height: 240px; overflow-y: auto; }
.drill-detail-head { display: flex; align-items: baseline; gap: 6px; padding-bottom: 5px; border-bottom: 1px dashed var(--border); }
.drill-detail-list { margin-top: 3px; }
.drill-txn { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.drill-txn:last-child { border-bottom: 0; }
.drill-txn-date { flex: 0 0 38px; color: var(--muted); font-variant-numeric: tabular-nums; }
.drill-txn-main { flex: 1 1 auto; min-width: 0; display: flex; gap: 5px; align-items: baseline; overflow: hidden; }
.drill-txn-cat { flex: 0 1 auto; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drill-txn-note { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drill-txn-acc { flex: 0 0 auto; color: var(--muted); font-size: 11.5px; max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drill-txn-amt { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* 表内排序：点表头切换升降序 */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--primary); }
th.sortable::after { content: '⇅'; margin-left: 4px; font-size: 10px; opacity: .35; }
th.sortable.is-sorted::after { opacity: 1; color: var(--primary); }
th.sortable[data-sort-dir="asc"]::after { content: '▲'; }
th.sortable[data-sort-dir="desc"]::after { content: '▼'; }

/* -------------------------- 总览页账户分组折叠 -------------------------- */

.acc-fold-list { display: flex; flex-direction: column; }
.acc-fold { border-bottom: 1px dashed var(--border); }
.acc-fold:last-child { border-bottom: 0; }
.acc-fold-sum {
  display: flex; align-items: center; gap: 7px; padding: 7px 2px;
  cursor: pointer; list-style: none; font-size: 13px;
}
.acc-fold-sum::-webkit-details-marker { display: none; }
.acc-fold-sum:hover .acc-fold-name { color: var(--primary); }
.acc-fold-ico { color: var(--muted); flex: 0 0 auto; display: inline-flex; }
.acc-fold-name {
  flex: 1; min-width: 0; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acc-fold-n {
  font-size: 10.5px; color: var(--muted); background: var(--card-2);
  border: 1px solid var(--border); padding: 0 6px; border-radius: 99px;
  flex: 0 0 auto; font-variant-numeric: tabular-nums;
}
.acc-fold-amt { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; flex: 0 0 auto; }
.acc-fold-body { padding: 0 0 7px 15px; }
.acc-fold-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 4px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border);
}
.acc-fold-row:last-child { border-bottom: 0; }
.acc-fold-acc { display: flex; align-items: center; gap: 6px; min-width: 0; }
.acc-fold-foot {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 12.5px; text-align: right;
}

/* 总览第三列的小行（订阅/借贷/自动记账共用，替掉原来的内联 style） */
.dash-mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 5px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border);
}
.dash-mini-row:last-child { border-bottom: 0; }

/* ------------------------------- 表内搜索 ------------------------------- */

.tbl-filter {
  display: flex; align-items: center; gap: 7px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 0 10px; height: 34px; min-width: 0;
}
.tbl-filter:focus-within { border-color: var(--primary); background: var(--card); }
.tbl-filter-ico { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.tbl-filter input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 13px; color: var(--text); padding: 0;
  height: 100%; box-shadow: none;
}
.tbl-filter input::-webkit-search-cancel-button { cursor: pointer; }
.tbl-filter-n { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.tbl-filter-n.is-hit { color: var(--primary); }
.tbl-filter-n.is-none { color: var(--expense); }
.tbl-filter-empty {
  padding: 16px; text-align: center; font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 10px; margin-top: 8px;
}
[data-filter-row].filtered-out { display: none; }

/* 卡片头里的搜索条：与标题同一行，宽度自适应 */
.card-head .tbl-filter { flex: 0 1 240px; height: 30px; }
@media (max-width: 720px) {
  .card-head .tbl-filter { flex: 1 1 100%; margin-top: 6px; }
  .card-head.has-filter { flex-wrap: wrap; }
}

/* ------------------------- 记账金额：符号内嵌 ------------------------- */
/* 原来 ¥ 是输入框外的 flex 兄弟，占掉一行宽度且与 44px 数字不成比例。
   现在把它绝对定位进输入框左侧，数字用 padding-left 让位，
   视觉上「¥ 是这个输入框的前缀」，而不是两个并列元素。
   ★ 用户反馈：¥ 只有 26px 且半透明，看起来仍像「在框外面」——
   现在放大到与数字同级（34px）、同色不透明，占位宽度同步加大。 */
.ql-amt-line { position: relative; display: flex; align-items: baseline; }
.ql-cur {
  position: absolute; left: 2px; bottom: 10px;
  font-size: 34px; font-weight: 700; line-height: 1;
  color: var(--ql-accent); opacity: 1; pointer-events: none; user-select: none;
}
.ql .ql-amt-input { padding-left: 38px; }
@media (max-width: 420px) {
  .ql-cur { font-size: 30px; bottom: 9px; }
  .ql .ql-amt-input { padding-left: 34px; }
}

/* 金额下方的人民币大写（壹佰贰拾叁元肆角伍分），随键盘输入实时更新 */
.ql-amt-caps {
  font-size: 12px; color: var(--muted); letter-spacing: .5px;
  padding: 0 0 4px; min-height: 18px; user-select: none;
}
.ql-amt-caps:empty { display: none; }

/* -------------------------- 双身份往来（客户＋供应商） -------------------------- */

.dual-chip {
  background: var(--warn-soft); color: #ad6800; border-color: #ffd591;
  font-weight: 600;
}
[data-theme="dark"] .dual-chip { color: #ffc069; border-color: #613400; background: #2b1d08; }

.dual-card { border-left: 3px solid var(--warn); }
.dual-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1.05fr);
  gap: 10px; align-items: start; padding: 4px 2px 0;
}
.dual-col { min-width: 0; }
.dual-col-net {
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.dual-op {
  color: var(--muted); font-size: 18px; font-weight: 600;
  align-self: center; padding-top: 12px;
}
.dual-num {
  font-size: 20px; font-weight: 700; letter-spacing: -.4px;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.dual-table td, .dual-table th { vertical-align: middle; }
.dual-table .chip { margin-left: 4px; }

@media (max-width: 860px) {
  .dual-cols { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .dual-op {
    padding: 0; text-align: left; align-self: start;
    font-size: 14px; color: var(--border-strong);
  }
  .dual-col-net { padding: 8px 10px; }
}

/* 表内搜索的「展开全部」小按钮（data-filter-limit 场景） */
.tbl-filter-more {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--primary);
  white-space: nowrap; padding: 0 0 0 2px; flex: 0 0 auto;
}
.tbl-filter-more:hover { text-decoration: underline; }

/* ---------------------------- 应收分析页排版 ---------------------------- */

/* 口径说明：默认收起，点开才展开（每天看报表不需要它占三行） */
.report-note { padding: 0; }
.report-note > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; cursor: pointer; list-style: none;
  font-size: 12.5px; color: var(--text-2);
}
.report-note > summary::-webkit-details-marker { display: none; }
.report-note > summary:hover { color: var(--primary); }
.report-note[open] > summary { border-bottom: 1px solid var(--border); }
.note-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 700; flex: 0 0 16px;
}
.note-body { padding: 12px 16px; font-size: 12.5px; line-height: 1.65; color: var(--text-2); }
.note-body p { margin: 0 0 8px; }
.note-body p:last-child { margin-bottom: 0; }

/* 底部两卡：左集中度、右款项性质。宽度不等 —— 集中度有名字有链接，
   款项构成只有四个短标签，等宽会让右边空一大截。 */
.ar-report-bottom {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px; align-items: start;
}
@media (max-width: 1080px) { .ar-report-bottom { grid-template-columns: minmax(0, 1fr); } }

.conc-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 13px; }
.conc-idx {
  flex: 0 0 18px; height: 18px; border-radius: 5px; background: var(--card-2);
  border: 1px solid var(--border); color: var(--muted); font-size: 10.5px;
  display: flex; align-items: center; justify-content: center;
}
.conc-name { flex: 0 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conc-bar {
  flex: 1 1 40px; height: 8px; background: var(--card-2); border-radius: 99px;
  overflow: hidden; border: 1px solid var(--border); min-width: 30px;
}
.conc-bar i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.conc-pct { flex: 0 0 46px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.conc-val { flex: 0 0 92px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.conc-foot {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 11.5px; color: var(--muted);
}

.nature-row { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; font-size: 13px; }
.nature-name { flex: 0 0 78px; font-weight: 600; }
.nature-bar {
  flex: 1 1 30px; height: 8px; background: var(--card-2); border-radius: 99px;
  overflow: hidden; border: 1px solid var(--border); min-width: 26px;
}
.nature-bar i { display: block; height: 100%; border-radius: 99px; }
.nature-val { flex: 0 0 100px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.nature-note {
  font-size: 11px; color: var(--muted); padding: 2px 0 6px 86px;
  border-bottom: 1px dashed var(--border);
}
.nature-row:last-of-type + .nature-note { border-bottom: 0; }

/* 小屏把标签列收窄，数字列保住不换行 */
@media (max-width: 520px) {
  .conc-name { flex: 0 1 84px; }
  .conc-val { flex: 0 0 76px; font-size: 12px; }
  .nature-name { flex: 0 0 64px; font-size: 12.5px; }
  .nature-val { flex: 0 0 84px; font-size: 12.5px; }
  .nature-note { padding-left: 72px; }
}

/* ═══════════════════ 报表页：工具栏 / 分类栏 / 主区 ═══════════════════ */

/* 工具栏吸顶：往下翻多维分析时，时间/视角/分类筛选始终在手边 */
.rep-toolbar { position: sticky; top: 8px; z-index: 40; }
.rep-toolbar-label { flex: 0 0 auto; width: 30px; text-align: right; user-select: none; }

/* 生效中的分类筛选：面包屑 + 清除按钮，让「这页被筛过」一眼可见 */
.rep-scope-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 99px; padding: 4px 12px; font-size: 12px; font-weight: 600;
}
.rep-scope-chip .rep-scope-x {
  color: inherit; text-decoration: none; font-size: 11px;
  padding: 0 2px; line-height: 1;
}
.rep-scope-chip .rep-scope-x:hover { opacity: .75; }

/* 主体两栏：左分类栏（sticky）、右报表。1080 以下分类栏折到页首 */
.rep-body {
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
  gap: 16px; align-items: start;
}
.rep-main { min-width: 0; }
.rep-rail {
  position: sticky; top: 8px; max-height: calc(100vh - 24px);
  overflow-y: auto; padding: 13px; margin-bottom: 0;
}
.rep-rail-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.rep-rail-head h2 { flex: 1; }

.rail-list { display: flex; flex-direction: column; }
.rail-item {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 4px; border-radius: 8px;
  font-size: 12.5px; color: var(--text); text-decoration: none;
}
.rail-item:hover { background: var(--card-2); }
.rail-item.is-on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.rail-all { font-weight: 600; }
.rail-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.rail-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-pct { flex: 0 0 30px; text-align: right; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.rail-val { flex: 0 0 70px; text-align: right; font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 550; white-space: nowrap; }
.rail-toggle {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 10px; flex: 0 0 16px; padding: 2px; line-height: 1;
}
.rail-toggle:hover { color: var(--primary); }
.rail-subs {
  margin: 2px 0 4px 13px; padding-left: 6px;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column;
}
.rail-sub { padding: 4px 6px; font-size: 12px; color: var(--text-2); }
.rail-sub.is-on { color: var(--primary); }
.rail-foot { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
@media (max-width: 1080px) {
  .rep-body { grid-template-columns: minmax(0, 1fr); }
  .rep-rail { position: static; max-height: 320px; }
}

/* ═══════════════ 完整名称：不再一个字一行或省略成「商…」 ═══════════════ */

/* 下钻二级行：名字允许换行完整展示（面板本来就窄，截断比换行更伤） */
.pie-drill .drill-name {
  flex: 1 1 auto; max-width: none; min-width: 0;
  white-space: normal; word-break: break-word; line-height: 1.3;
}
/* 图例行：最多两行，完整名称可见，超长仍有 title 兜底 */
.legend-name {
  max-width: 120px; white-space: normal; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 三级流水明细：分类列显示「一级 / 二级」完整路径，允许换行 */
.drill-txn-cat { white-space: normal; word-break: break-all; line-height: 1.3; max-width: 150px; }

/* ═══════════════════ 手机端账单行修复（明细页） ═══════════════════ */
/* 根因：.txn-title 是 flex，三个 span 默认 min-width:auto，中文的 min-content
   是一个字。触屏没有 hover，右侧 .txn-act 按钮排永远隐形却占 ~100px 宽，
   把标题挤成 20px 宽 → 「商品采购」一个字一行、标签挤成圆形。
   修复三件事：
   ① 触屏隐藏悬停按钮排（编辑/删除/复制走左右滑与行点击，功能不丢）；
   ② 主名 nowrap + 上限 60%，不再被压缩换行；
   ③ 副行所有元素 nowrap，挤不下就整体换行，不缩成圆点。 */
.txn-title > span:first-child {
  flex: 0 1 auto; white-space: nowrap;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis;
}
.txn-title .tiny.muted { white-space: nowrap; flex: 0 0 auto; }
.txn-title .note { flex: 1 1 0; min-width: 0; }
.txn-sub > * { white-space: nowrap; }
@media (max-width: 820px) {
  .txn-act { display: none; }
  .txn-face { gap: 10px; padding: 10px 4px; }
  .txn-ico { width: 34px; height: 34px; flex-basis: 34px; }
  .txn-amt { font-size: 14px; max-width: 34vw; }
}

/* ============================================================
   报表页 MoneyWiz 式版式 + 分类图标徽章（2026-10-27 第二轮）
   前缀 mw-（MoneyWiz 版式）、cat-badge（图标徽章）
   ============================================================ */

/* ---------- 暖化底色：把冷灰换成米白，卡片带一点奶油感 ---------- */
:root {
  --bg: #f6f2ec;
  --card: #fffdfb;
  --card-2: #faf5ef;
  --border: #ece3d8;
  --border-strong: #dfd2c2;
  --text: #33302c;
  --text-2: #5b544c;
  --muted: #918880;
  --warm-glow: rgba(228, 176, 128, .38);
  --warm-line: rgba(196, 148, 104, .22);
  --shadow: 0 1px 2px rgba(122, 88, 52, .05), 0 10px 26px -14px rgba(122, 88, 52, .18);
}
[data-theme="dark"] {
  --bg: #14110f;
  --card: #1c1815;
  --card-2: #241f1b;
  --border: #302824;
  --border-strong: #3d332c;
  --text: #f0e8e0;
  --text-2: #c8bcb1;
  --muted: #92867c;
  --warm-glow: rgba(221, 143, 43, .16);
  --warm-line: rgba(221, 143, 43, .2);
}

/* ---------- 图标徽章：圆形浅底 + 同色描边环 ---------- */
.cat-badge {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  border-radius: 50%; line-height: 1;
  background: linear-gradient(155deg, var(--cb-soft) 0%, var(--card) 118%);
  box-shadow: inset 0 0 0 1.5px var(--cb-ring);
  font-family: var(--emoji-font);
  vertical-align: middle;
}
.mw-ava {
  display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%; background: var(--cb-soft);
  box-shadow: inset 0 0 0 1.5px var(--cb-ring);
  color: var(--cb); font-weight: 700; font-size: 12px; letter-spacing: -.02em;
}

/* ---------- 期间步进条 ---------- */
.mw-periodbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 8px 10px; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.mw-stepper { display: flex; align-items: center; gap: 4px; }
.mw-step {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px;
  display: grid; place-items: center; text-decoration: none;
  color: var(--text-2); font-size: 17px; line-height: 1;
  transition: background .14s, color .14s;
}
.mw-step:hover { background: var(--card-2); color: var(--primary); }
.mw-step.is-off { color: var(--border-strong); pointer-events: none; }
.mw-period { min-width: 0; padding: 0 2px; }
.mw-period-title { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; }
.mw-period-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.mw-quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.mw-chip {
  padding: 5px 11px; border-radius: 99px; font-size: 12px; text-decoration: none;
  color: var(--text-2); background: var(--card-2); border: 1px solid transparent;
  white-space: nowrap;
}
.mw-chip:hover { border-color: var(--border-strong); }
.mw-chip.is-on { background: var(--primary-soft); color: var(--primary); font-weight: 650; }

.mw-more { position: relative; }
.mw-more > summary {
  list-style: none; cursor: pointer; padding: 5px 11px; border-radius: 99px;
  font-size: 12px; color: var(--text-2); background: var(--card-2);
}
.mw-more > summary::-webkit-details-marker { display: none; }
.mw-more[open] > summary { background: var(--primary-soft); color: var(--primary); }
.mw-more-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 10px; min-width: 268px;
}
.mw-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mw-form + .mw-form { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.mw-form label { font-size: 11.5px; color: var(--muted); flex: 0 0 68px; }
.mw-form input { width: auto; padding: 5px 7px; font-size: 12px; }

/* 视角切换：分段控件（MoneyWiz 顶部那个支出/收入开关） */
.mw-seg {
  display: inline-flex; background: var(--card-2); border-radius: 10px; padding: 3px; gap: 2px;
}
.mw-seg-item {
  padding: 5px 13px; border-radius: 8px; font-size: 12.5px; text-decoration: none;
  color: var(--text-2); font-weight: 550; white-space: nowrap;
}
.mw-seg-item.is-on { background: var(--card); color: var(--primary); font-weight: 700; box-shadow: var(--shadow-sm); }

/* ---------- 报告类型条 ---------- */
.mw-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; padding-bottom: 3px; scrollbar-width: none;
}
.mw-tabs::-webkit-scrollbar { display: none; }
.mw-tab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 9px; border-radius: 14px; text-decoration: none;
  background: var(--card); border: 1px solid var(--border); color: var(--text-2);
  transition: border-color .14s, background .14s, transform .14s;
}
.mw-tab:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.mw-tab.is-on { background: var(--primary-soft); border-color: transparent; box-shadow: inset 0 0 0 1.5px var(--primary); }
.mw-tab-ico {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px;
  background: var(--card-2); box-shadow: inset 0 0 0 1px var(--warm-line);
}
.mw-tab.is-on .mw-tab-ico { background: var(--card); }
.mw-tab-txt { display: flex; flex-direction: column; line-height: 1.2; }
.mw-tab-txt b { font-size: 13px; font-weight: 700; }
.mw-tab-txt i { font-style: normal; font-size: 10.5px; color: var(--muted); }

/* ---------- Hero：大数字 + 环比 + 四个小指标 ---------- */
.mw-hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 18px 22px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.mw-hero::before {
  content: ''; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  right: -90px; top: -220px; pointer-events: none;
  background: radial-gradient(circle, var(--warm-glow) 0%, transparent 68%);
}
.mw-hero-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.mw-hero-value {
  font-size: clamp(30px, 4.4vw, 42px); font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.08;
}
.mw-hero-value .cur { font-size: .5em; font-weight: 700; opacity: .5; margin-right: 3px; vertical-align: .28em; }
.mw-hero-value.is-expense { color: var(--expense); }
.mw-hero-value.is-income { color: var(--income); }
.mw-hero-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 7px; }

.mw-hero-r {
  display: grid; grid-template-columns: repeat(2, minmax(90px, auto));
  gap: 10px 26px; position: relative; z-index: 1;
}
.mw-mini { display: flex; flex-direction: column; gap: 1px; }
.mw-mini-k { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mw-mini-l { font-size: 11px; color: var(--muted); }

/* 涨跌标签 */
.mw-delta-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.mw-delta-pill.is-good { background: var(--income-soft); color: var(--income); }
.mw-delta-pill.is-bad { background: var(--expense-soft); color: var(--expense); }
.mw-delta { font-size: 11px; font-weight: 650; }
.mw-delta.is-good { color: var(--income); }
.mw-delta.is-bad { color: var(--expense); }
.mw-delta.is-new { color: var(--muted); }

/* ---------- 卡片头 ---------- */
.mw-card { margin-bottom: 14px; }
.mw-card-title { font-size: 14px; font-weight: 700; }
.mw-card-note { font-size: 11.5px; color: var(--muted); text-decoration: none; }

/* ---------- 通用清单行（分类/对方/账户/成员） ---------- */
.mw-scroll { max-height: 540px; overflow-y: auto; padding-right: 2px; }
.mw-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; border-radius: 12px; transition: background .13s;
}
.mw-row + .mw-row { margin-top: 1px; }
.mw-row:hover { background: var(--card-2); }
.mw-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mw-row-top { display: flex; align-items: baseline; gap: 8px; }
.mw-row-name {
  flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mw-row-val {
  flex: 0 0 auto; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mw-row-val.expense { color: var(--expense); }
.mw-row-val.income { color: var(--income); }
.mw-row-sub {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}
.mw-row-pct { font-variant-numeric: tabular-nums; }
.mw-row-bar { height: 5px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 1px; }
.mw-row-bar i { display: block; height: 100%; border-radius: 99px; }

/* ---------- 空态 / 脚注 / 图例 / KPI ---------- */
.mw-empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 26px 12px; color: var(--muted); font-size: 12.5px; text-align: center;
}
.mw-empty.sm { padding: 16px 8px; }
.mw-empty > span { font-size: 26px; opacity: .85; }
.mw-footnote {
  font-size: 11px; color: var(--muted); line-height: 1.7;
  padding: 10px 2px 4px; border-top: 1px dashed var(--border); margin-top: 6px;
}
.mw-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 11.5px; color: var(--text-2); }
.mw-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.mw-legend-item i { width: 9px; height: 9px; border-radius: 3px; }
.mw-kpis { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 10px; }
.mw-kpis > div { display: flex; flex-direction: column; gap: 2px; }
.mw-kpi-l { font-size: 11px; color: var(--muted); }
.mw-kpis b { font-size: 14px; font-variant-numeric: tabular-nums; }

/* 同期对比小表 */
.mw-cmp { display: flex; flex-direction: column; gap: 2px; }
.mw-cmp-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 9px; border-radius: 10px; font-size: 12px;
}
.mw-cmp-row:nth-child(odd) { background: var(--card-2); }
.mw-cmp-l { flex: 1 1 150px; color: var(--text-2); font-weight: 600; }
.mw-cmp-v { font-variant-numeric: tabular-nums; color: var(--muted); }
.mw-cmp-v b { font-size: 12.5px; }

/* ---------- 饼图区：宽屏改成「图左 清单右」 ---------- */
@media (min-width: 1000px) {
  .mw-card .pie-drill {
    display: grid; grid-template-columns: 236px minmax(0, 1fr);
    gap: 22px; align-items: center;
  }
  .mw-card .pie-canvas { align-self: center; }
  .mw-card .pie-side { min-height: 210px; }
}
/* 右侧清单里省掉百分比列，把宽度让给分类名（饼图本身已经在表达比例） */
.pie-side .legend-pct { display: none; }
.pie-side .legend-name { flex: 1 1 auto; max-width: none; }
.pie-side .legend-bar { flex: 0 0 46px; min-width: 30px; }
.pie-side .legend-val { flex: 0 0 82px; }
.pie-side .drill-row { gap: 8px; padding: 5px 0; }
.pie-side .drill-name { flex: 1 1 auto; max-width: none; white-space: normal; line-height: 1.25; }
.pie-side .drill-bar { flex: 0 0 42px; }
.pie-side .drill-val { flex: 0 0 82px; }

/* ---------- 分类栏暖化 ---------- */
.rep-rail { border-radius: 16px; }
.rail-clear { font-size: 11.5px; color: var(--primary); text-decoration: none; }
.rail-dot-sm { width: 6px; height: 6px; border-radius: 2px; flex: 0 0 6px; margin-left: 9px; }
.rail-badge { font-size: 11px !important; font-weight: 700; color: var(--primary); }
.rail-item { border-radius: 10px; }
.rail-item.is-on { box-shadow: inset 0 0 0 1px var(--primary); }
.rail-subs { border-left-color: var(--border); }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .mw-hero { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px 16px; }
  .mw-hero-r { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .mw-mini-k { font-size: 13px; }
}
@media (max-width: 640px) {
  .mw-periodbar { gap: 8px; padding: 8px; }
  .mw-quick { margin-left: 0; width: 100%; }
  .mw-seg { margin-left: auto; }
  .mw-hero-r { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mw-tab-txt i { display: none; }
  .mw-tab { padding: 7px 12px 7px 8px; }
  .mw-cmp-l { flex-basis: 100%; }
  .mw-more-panel { right: auto; left: 0; min-width: 250px; }
  .pie-side .legend-bar { display: none; }
}

/* ---------- glyph 徽章（Phosphor fill，MIT）：纯色底 + 白色图形 ---------- */
/* 与 emoji 徽章（浅底）不同：glyph 直接用分类色当底，白色图形浮在上面，
   就像 MoneyWiz 图标选择器里的那种实心色块。 */
.cat-badge.is-glyph {
  background: linear-gradient(160deg, var(--cb) 0%, var(--cb-deep) 135%);
  box-shadow: 0 2px 7px -4px var(--cb-deep), inset 0 0 0 1px rgba(255, 255, 255, .16);
}
.cat-badge.is-glyph svg { display: block; fill: rgba(255, 255, 255, .96); }
[data-theme="dark"] .cat-badge.is-glyph { box-shadow: 0 2px 8px -4px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .12); }
/* 交易行里徽章与旧 .txn-ico 同尺寸同对齐 */
.txn-badge { flex: 0 0 auto; }

/* ---------- 分类管理的暖色板快捷色点 ---------- */
.swatch-row { display: flex; flex-wrap: wrap; gap: 5px; max-width: 240px; }
.swatch-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25), 0 1px 3px -1px rgba(80,50,20,.5);
  transition: transform .12s;
}
.swatch-dot:hover { transform: scale(1.18); }

/* ═══════════════ 折叠控件统一图标：三条横线（fold-ico） ═══════════════ */
/* 全站所有可折叠区域（报表分类栏、总览账户余额、账户管理分组、构成卡图例、
   分类排行）统一用这个三条横线 SVG；不再使用 ▾/▸ 小三角。
   状态表达：收起 = 整体变淡 + 中间线缩短；展开 = 正常。不做旋转。 */
.fold-ico { display: inline-block; flex: 0 0 14px; transition: opacity .15s; }
.fold-ico rect { fill: currentColor; transition: opacity .15s, x .15s, width .15s; }
.fold-ico rect:nth-of-type(2) { width: 9px; transition: width .15s; }
/* 收起态（details 未展开，或 JS 挂的未展开组） */
.fold-ico.is-closed,
details:not([open]) > * .fold-ico,
details:not([open]) > .fold-ico { opacity: .45; }
details:not([open]) > * .fold-ico rect:nth-of-type(2),
details:not([open]) > .fold-ico rect:nth-of-type(2) { width: 14px; }
/* 展开态：中间线变短，作为「已展开」的视觉记号 */
details[open] > * .fold-ico,
details[open] > .fold-ico,
.fold-ico.is-open { opacity: .9; }
details[open] > * .fold-ico rect:nth-of-type(2),
details[open] > .fold-ico rect:nth-of-type(2),
.fold-ico.is-open rect:nth-of-type(2) { width: 9px; }

/* 报表左侧分类栏的折叠按钮：原来是字符三角，现在装 SVG */
.rail-toggle { display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; }
.rail-toggle .fold-ico { opacity: .55; }
.rail-toggle.is-open .fold-ico { opacity: .95; }
.rail-toggle.is-open .fold-ico rect:nth-of-type(2) { width: 9px; }
.rail-toggle:not(.is-open) .fold-ico rect:nth-of-type(2) { width: 14px; }
.rail-toggle:hover .fold-ico { opacity: 1; color: var(--primary); }

/* 构成卡图例：一级行 + 可折叠的二级子列表 */
.legend-fold { width: 100%; }
.legend-fold-group > .legend-row { padding-right: 2px; }
.legend-fold-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); padding: 3px; margin-left: 2px; border-radius: 4px;
  display: inline-flex; align-items: center; flex: 0 0 auto; line-height: 1;
}
.legend-fold-btn:hover { color: var(--primary); }
.legend-fold-btn .fold-ico { opacity: .5; }
.legend-fold-btn.is-open .fold-ico { opacity: .95; }
.legend-fold-btn.is-open .fold-ico rect:nth-of-type(2) { width: 9px; }
.legend-fold-btn:not(.is-open) .fold-ico rect:nth-of-type(2) { width: 14px; }
.legend-subs {
  margin: 1px 0 5px 12px; padding-left: 8px;
  border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 1px;
}
.legend-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 6px; font-size: 12px; color: var(--text-2);
  border-radius: 6px; cursor: pointer; transition: background .12s;
}
.legend-sub:hover { background: var(--card-2); }
.legend-sub:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.legend-sub-dot { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.legend-sub-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-sub-val { flex: 0 0 auto; font-weight: 550; font-variant-numeric: tabular-nums; }
.legend-sub-pct { flex: 0 0 44px; text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

/* 分类排行：按一级分类折叠分组 */
.mw-fold-group { border-bottom: 1px dashed var(--border); padding: 6px 0; }
.mw-fold-group:last-child { border-bottom: 0; }
.mw-fold-head {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 7px; cursor: pointer; user-select: none;
  transition: background .12s;
}
.mw-fold-head:hover { background: var(--card-2); }
.mw-fold-name { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mw-fold-sum { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.mw-fold-cnt { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.mw-fold-body { margin: 2px 0 4px 10px; padding-left: 8px; border-left: 2px solid var(--border); }

/* KPI 卡金额前的 ¥：小一号、上标对齐，与报表 hero 的大数风格一致 */
.stat .value .cur { font-size: .58em; font-weight: 700; opacity: .5; margin-right: 3px; vertical-align: .28em; }

/* 顶栏用户菜单的下拉指示：同样用三条横线，收起时更淡 */
.user-menu-caret { display: inline-flex; opacity: .6; }
button[aria-expanded="true"] > .user-menu-caret,
.user-menu-btn[aria-expanded="true"] .user-menu-caret { opacity: 1; }

/* ═══════════════ 折叠控件兜底（2026-10-27 · 修「点折叠没反应」） ═══════════════
   ★ 为什么必须有这一条：
     浏览器默认的 [hidden] { display: none } 属于 UA 样式表，**优先级最低**，
     任何作者声明的 display（flex / grid / block）都会盖掉它。于是 JS 里
     `el.hidden = true` 属性明明写上了，元素却照样显示 —— 用户看到的就是
     「折叠按钮点了没反应」。
     本次实测踩中的两处：.legend-subs（构成卡二级列表）、.rail-subs（左侧
     分类栏二级列表），两者都是 display:flex 容器，四条折叠交互全哑。
     （同样的坑 2026-09 在快捷记账的 .ql-* 遮罩上踩过一次，当时是逐个补
     `X[hidden]{display:none!important}`，漏一个就复发。这次改成全站兜底。）

   为什么用 !important：hidden 属性的语义就是「现在不显示」，任何布局规则
   都不该推翻它；需要显示时由 JS 摘掉属性，不是靠 CSS 硬顶。 */
[hidden] { display: none !important; }

/* <details> 收起时子元素不渲染，同样要防 display 覆盖。
   （UA 规则是 details:not([open]) > *:not(summary){display:none}，一个
   display:flex 的卡片体就能把它顶掉，表现为「收起了但内容还在」。） */
details:not([open]) > *:not(summary) { display: none !important; }
/* 反过来：展开时 summary 之外的内容必须恢复原来的布局，上面那条不影响
   open 状态，这里只需保证不误伤注释节点与空白。 */

/* 折叠状态的视觉钩子：三个图标（报表图例 / 分类栏 / 分类排行）统一走 CSS，
   JS 只切 hidden + class，不再写字符。 */
.fold-ico { color: currentColor; }
[data-fold-head][aria-expanded="true"] .fold-ico rect:nth-of-type(2),
.legend-fold-btn.is-open .fold-ico rect:nth-of-type(2),
.rail-toggle.is-open .fold-ico rect:nth-of-type(2) { width: 9px; }
[data-fold-head][aria-expanded="false"] .fold-ico rect:nth-of-type(2),
.legend-fold-btn:not(.is-open) .fold-ico rect:nth-of-type(2),
.rail-toggle:not(.is-open) .fold-ico rect:nth-of-type(2) { width: 14px; }

/* 总览顶部的时间范围切换条：复用报表页的 .mw-chip，两页切换观感一致 */
.dash-range {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: -2px 0 12px;
}
.dash-range-ico { font-size: 13px; opacity: .65; line-height: 1; }
.dash-range-note { font-size: 12px; color: var(--muted); margin-left: 2px; }

/* ═══════════════ 应收净额桥：取消运算符，改三段式分隔（2026-10-27 二改） ═══════════════
   演进过程留档，避免以后又绕回来：
   ① 初版用字体字符 − / =：等号两横比减号长且细、垂直基准不一致，宽度随字体回退漂移；
   ② 二版改 CSS 伪元素画线：几何完全一致了，但两根横线夹在金额中间仍显得「排版刻意」；
   ③ 现在（用户选择）：不画运算符 —— 三段用竖线分隔，③ 净额加重描边。
      计算关系交给标题里的「抵减 / 净额」字面表达，视觉更干净。 */
.ar-bridge-seg {
  flex: 1 1 0; min-width: 150px;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}
.ar-bridge-seg:first-child { border-left: 0; padding-left: 0; }
.ar-bridge-seg.is-net {
  border-left: 2px solid var(--border-strong);
  padding-left: 16px;
}
/* ①② 是过程量，视觉让位；③ 是结论，字重与颜色都提一级 */
.ar-bridge-seg.is-net .ar-bridge-n { font-size: 22px; }
.ar-bridge-seg.is-net .tiny { color: var(--text-2); }

/* 搜索状态行：计数与「展开全部」移出搜索胶囊，紧贴表头上方 */
.tbl-meta {
  display: flex; align-items: center; gap: 8px;
  margin: -4px 0 8px; font-size: 12px; color: var(--muted); min-height: 20px;
}
.tbl-meta .tbl-filter-n { font-variant-numeric: tabular-nums; }
.tbl-meta-more {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--primary);
  padding: 1px 6px; border-radius: 6px; transition: background .12s;
}
.tbl-meta-more:hover { background: var(--card-2); }

/* 口径说明 summary 行的常显摘要：收起时也能看到最关键的结论 */
.report-note summary .note-digest {
  margin-left: auto; padding-left: 12px;
  font-size: 12px; font-weight: 400; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 720px) {
  .report-note summary .note-digest { display: none; }
}

/* 批量条里的「改时间」控件：日期/天数输入收到与按钮同高，用竖线分组 */
.bulk-sep {
  width: 1px; height: 18px; background: var(--border); flex: 0 0 1px; margin: 0 2px;
}
/* ★ 选择器必须写成 input.bulk-date（0,1,1）：
   全局有 `input[type="date"]{width:100%; padding:9px 12px}`（同为 0,1,1 且在文件更早），
   只用类名 .bulk-date（0,1,0）会被它压住 —— 日期框被拉成整行宽、按钮挤到下一行，
   这是实测踩到的第一个版本。写成 input.bulk-date 后按顺序覆盖。 */
input.bulk-date, input.bulk-days {
  flex: 0 0 auto; height: 32px; padding: 0 8px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
}
input.bulk-date { width: 150px; }
input.bulk-days { width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
/* 日期控件的日历图标在内边距里会顶到文字，稍微收一下 */
.bulk-date::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; margin-left: 2px; }
.bulk-date:focus, .bulk-days:focus { outline: none; border-color: var(--primary); }
