/* =========================================================
   流水 · 日常消费记录 — 设计系统
   调性：沉静克制 · 纸质账本感
   断点：<640 移动 / 640–1023 平板 / ≥1024 桌面
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* 纸面与墨色：暖调中性，但收掉土黄，只留一点纸的温度 */
  --paper:        oklch(97.9% 0.007 88);
  --paper-sunk:   oklch(95.8% 0.010 86);
  --surface:      oklch(99.6% 0.003 90);
  --surface-2:    oklch(98.4% 0.006 88);

  --ink:          oklch(24% 0.015 180);
  --ink-2:        oklch(41% 0.013 180);
  --ink-3:        oklch(55% 0.011 180);
  --ink-4:        oklch(69% 0.009 180);

  --line:         oklch(91% 0.007 92);
  --line-2:       oklch(85% 0.010 92);

  /* 主色：墨绿（账本封皮） */
  --pine:         oklch(38% 0.054 170);
  --pine-deep:    oklch(28% 0.043 170);
  --pine-soft:    oklch(94.8% 0.021 170);
  --pine-line:    oklch(82% 0.040 170);

  /* 强调：赭石（印章） */
  --clay:         oklch(62% 0.126 52);
  --clay-soft:    oklch(95.5% 0.026 62);

  /* 语义：支出朱砂 / 收入竹青 */
  --expense:      oklch(51% 0.162 28);
  --expense-soft: oklch(96.2% 0.025 28);
  --income:       oklch(56% 0.102 156);
  --income-soft:  oklch(95.4% 0.023 156);
  --warn:         oklch(66% 0.124 72);
  --warn-soft:    oklch(96% 0.032 80);

  /* 分类色（低饱和，克制） */
  --c1: oklch(62% 0.115 30);  --c2: oklch(64% 0.095 62);
  --c3: oklch(58% 0.100 152); --c4: oklch(58% 0.090 232);
  --c5: oklch(55% 0.090 300); --c6: oklch(63% 0.110 12);
  --c7: oklch(58% 0.070 190); --c8: oklch(60% 0.090 95);
  --c9: oklch(52% 0.040 165);

  /* 阴影：极浅，只用来分出层次，不做装饰 */
  --sh-1: 0 1px 2px -1px oklch(24% 0.02 170 / .10), 0 0 0 1px oklch(24% 0.02 170 / .035);
  --sh-2: 0 3px 10px -5px oklch(24% 0.02 170 / .16), 0 0 0 1px oklch(24% 0.02 170 / .045);
  --sh-3: 0 18px 44px -20px oklch(24% 0.02 170 / .32);

  /* 字体 */
  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
               "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-num: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino,
              Georgia, "Songti SC", serif;

  /* 5 档字号（1.25 比例） */
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-base: 0.9375rem;
  --t-lg: 1.125rem;
  --t-xl: 1.5rem;
  --t-2xl: 2rem;

  /* 间距（4px 基准） */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --dur: 200ms;
  --ease: cubic-bezier(.22, .9, .28, 1);

  --side-w: 236px;
  --tabbar-h: 60px;
  --top-h: 60px;
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  /* 极淡纸光：只在左上角留一点暖意，不再做大面积晕染 */
  background-image:
    radial-gradient(120% 80% at 12% 0%, oklch(99% 0.006 90 / .9), transparent 60%);
  background-attachment: fixed;
}
h1, h2, h3, h4 { margin: 0; font-weight: 560; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--pine);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.015em;
}

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* hidden 属性必须永远生效：防止 .login/.shell 等的 display 规则覆盖它 */
[hidden] { display: none !important; }

/* ---------- 3. 登录 / 注册（首页：左侧文案 + 右侧卡片，双栏） ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.login__ledger {
  position: relative;
  padding: var(--s9) var(--s8);
  display: flex; flex-direction: column; justify-content: center;
  border-right: 1px solid var(--line);
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, oklch(90% 0.012 95 / .55) 31px 32px),
    linear-gradient(180deg, var(--surface), var(--paper));
  overflow: hidden;
}
.login__ledger::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--clay); opacity: .55;
}
.login__mark {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--pine); font-size: var(--t-lg); font-weight: 600;
  letter-spacing: .04em; margin-bottom: var(--s7);
}
.login__title {
  font-family: var(--font-num);
  font-size: clamp(2.4rem, 5.2vw, 3.9rem);
  line-height: 1.08; font-weight: 460; letter-spacing: -0.02em;
  color: var(--ink);
}
.login__sub { margin-top: var(--s5); color: var(--ink-2); max-width: 34ch; }
.login__facts {
  display: flex; gap: var(--s7); margin-top: var(--s8);
  padding-top: var(--s5); border-top: 1px solid var(--line);
}
.login__facts li { display: flex; flex-direction: column; gap: 2px; }
.login__facts b {
  font-family: var(--font-num); font-size: var(--t-xl);
  font-weight: 500; color: var(--pine);
}
.login__facts span { font-size: var(--t-xs); color: var(--ink-3); }

.login__card {
  align-self: center;
  margin: var(--s8) auto;
  display: flex; flex-direction: column; gap: var(--s4);
  width: min(380px, 100%);
  padding: var(--s7);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: 0 1px 2px oklch(25% 0.02 165 / .04), 0 14px 40px -22px oklch(25% 0.02 165 / .22);
}
.login__card--reg { width: min(540px, 100%); }

/* 注册页：无左侧文案，单卡片居中 */
.login#register { grid-template-columns: 1fr; }

.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--pine); font-size: var(--t-lg); font-weight: 600;
  letter-spacing: .04em; margin-bottom: var(--s1);
}
.brand::after {
  content: ""; flex: 1; height: 1px; background: var(--line); margin-left: var(--s2);
}

/* 注册表单两列并排，压到一屏内 */
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
@media (max-width: 520px) { .f2 { grid-template-columns: 1fr; gap: var(--s3); } }
.login__cardHead h2 { font-size: var(--t-xl); }
.login__cardHead p { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.login__err {
  font-size: var(--t-sm); color: var(--expense);
  background: var(--expense-soft); border: 1px solid oklch(88% 0.06 27);
  padding: var(--s2) var(--s3); border-radius: var(--r-sm);
}
.login__row { display: flex; align-items: center; justify-content: space-between; }
.login__hint { font-size: var(--t-xs); color: var(--ink-3); text-align: center; }

.field { display: flex; flex-direction: column; gap: var(--s2); }
.field__label { font-size: var(--t-sm); color: var(--ink-2); }
.field__err {
  font-size: var(--t-xs); color: var(--expense); min-height: 0;
  display: none;
}
.field__err.is-on { display: block; }
.input.is-bad { border-color: var(--expense); background: var(--expense-soft); }

/* 密码强度 */
.strength { display: flex; align-items: center; gap: var(--s3); }
.strength__bar {
  flex: 1; height: 4px; border-radius: 999px;
  background: var(--paper-sunk); overflow: hidden;
}
.strength__bar i {
  display: block; height: 100%; width: 0;
  border-radius: 999px; background: var(--line-2);
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease);
}
.strength[data-lv="1"] .strength__bar i { width: 33%; background: var(--expense); }
.strength[data-lv="2"] .strength__bar i { width: 66%; background: var(--warn); }
.strength[data-lv="3"] .strength__bar i { width: 100%; background: var(--income); }
.strength__t { font-size: var(--t-xs); color: var(--ink-3); min-width: 5.5em; }

/* 人机校验 */
.captcha { display: flex; align-items: center; gap: var(--s3); }
.captcha__q {
  flex: 0 0 auto; padding: 6px var(--s3);
  background: var(--paper); border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  font-size: var(--t-lg); color: var(--ink-2); letter-spacing: .05em;
  user-select: none;
}
.input {
  width: 100%; padding: 10px var(--s3);
  background: var(--paper-sunk);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:focus { background: var(--surface); border-color: var(--pine); outline: none; }
.inputWrap { position: relative; }
.inputWrap__btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; font-size: var(--t-xs); color: var(--ink-3);
  padding: 4px 6px; border-radius: 4px;
}
.inputWrap__btn:hover { color: var(--pine); }

.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); color: var(--ink-2); }
.check input { accent-color: var(--pine); width: 15px; height: 15px; }
.linkbtn {
  background: none; border: 0; padding: 0;
  font-size: var(--t-sm); color: var(--pine); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.linkbtn:hover { color: var(--pine-deep); }

/* ---------- 4. 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 10px var(--s4); border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: var(--t-base); font-weight: 500;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--pine); border-color: var(--pine); color: oklch(98.5% 0.008 90);
  box-shadow: 0 1px 2px -1px oklch(38% 0.054 170 / .45);
}
.btn--primary:hover { background: var(--pine-deep); border-color: var(--pine-deep); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--paper-sunk); border-color: var(--line); }
.btn--danger { color: var(--expense); border-color: oklch(86% 0.05 27); background: var(--expense-soft); }
.btn--danger:hover { background: oklch(92% 0.05 27); border-color: var(--expense); }
.btn--sm { padding: 6px var(--s3); font-size: var(--t-sm); }
.btn[disabled] { opacity: .45; pointer-events: none; }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.iconbtn:hover { background: var(--paper-sunk); color: var(--ink); }

/* ---------- 5. 外壳布局 ---------- */
/* 外壳固定一屏高：页面本身不滚，滚动交给 .content（明细列表）或面板内部（总览） */
.shell { display: flex; height: 100dvh; overflow: hidden; }

.side {
  position: sticky; top: 0; height: 100%;
  width: var(--side-w); flex: 0 0 var(--side-w);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--paper-sunk));
  z-index: 30;
  overscroll-behavior: contain;
}
.side__brand {
  display: flex; align-items: center; gap: var(--s2);
  height: var(--top-h); padding: 0 var(--s5);
  color: var(--pine); font-size: var(--t-lg); font-weight: 600; letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
}
.side__nav { padding: var(--s4) var(--s3); display: flex; flex-direction: column; gap: 2px; }
.nav {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: 9px var(--s3); border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2); text-align: left;
  font-size: var(--t-base);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__i { flex: 0 0 20px; width: 20px; height: 20px; }
.nav:hover { background: oklch(94% 0.016 163 / .8); color: var(--ink); }
.nav[aria-current="page"] {
  background: var(--pine-soft); color: var(--pine-deep); font-weight: 560;
  box-shadow: inset 2px 0 0 var(--pine);
}
.side__foot {
  margin-top: auto; padding: var(--s4) var(--s5);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
}
.whoami { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.whoami__av {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pine-soft); color: var(--pine-deep);
  font-size: var(--t-sm); font-weight: 600;
}
.whoami__meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.whoami__meta b { font-size: var(--t-sm); }
.whoami__meta i { font-size: var(--t-xs); color: var(--ink-3); font-style: normal; }

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h); flex: 0 0 var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: 0 var(--s5);
  background: oklch(97.4% 0.011 84 / .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top__left, .top__right { display: flex; align-items: center; gap: var(--s2); }
.top__title { font-size: var(--t-lg); font-weight: 560; }
.top__burger { display: none; }

.sync {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 5px var(--s3); border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: var(--t-xs); color: var(--ink-2);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sync:hover { border-color: var(--ink-4); }
.sync__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--income); box-shadow: 0 0 0 3px oklch(94.5% 0.028 152);
}
.content {
  flex: 1; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s5) var(--s5) var(--s7);
  outline: none;
}
/* 浮标（toast）贴着底边显示期间，给滚动区留一段底垫，别让最后一行被压在浮标下面 */
.content.is-toasted { padding-bottom: calc(var(--s7) + 58px + env(safe-area-inset-bottom)); }
.wrap { max-width: 1240px; margin: 0 auto; }
/* 总览页撑满可用高度，内部面板自己滚 */
.wrap--dash { max-width: 1360px; height: 100%; display: flex; flex-direction: column; }

.tabbar { display: none; }

/* ---------- 6. 通用组件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--sh-1);
}
.card--flat { background: transparent; border: 0; padding: 0; }
.card__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4);
}
.card__title { font-size: var(--t-base); font-weight: 560; }
.card__hint { font-size: var(--t-xs); color: var(--ink-3); }

.sechead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4);
}
/* 窄屏下说明文字会把标题挤成竖排单字（「预 / 算」）；标题不参与收缩 */
.sechead h3 { font-size: var(--t-lg); flex: 0 0 auto; }
.sechead p { font-size: var(--t-xs); color: var(--ink-3); }

.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip {
  padding: 5px var(--s3); border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: var(--t-sm); font-family: inherit; color: var(--ink-2);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.chip:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.chip:hover { border-color: var(--ink-4); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--pine); border-color: var(--pine); color: oklch(98.5% 0.008 90);
}

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 4px;
  font-size: var(--t-xs); font-weight: 500;
}
.tag--expense { background: var(--expense-soft); color: var(--expense); }
.tag--income { background: var(--income-soft); color: var(--income); }
.tag--warn { background: var(--warn-soft); color: oklch(48% 0.13 70); }
.tag--quiet { background: var(--paper-sunk); color: var(--ink-3); }

.divider { height: 1px; background: var(--line); margin: var(--s5) 0; }
.rule {
  height: 1px; border: 0; margin: 0;
  background: repeating-linear-gradient(to right, var(--line-2) 0 4px, transparent 4px 8px);
}

/* 空状态：有教育意义，不空洞 */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  padding: var(--s9) var(--s5); text-align: center;
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty__art { color: var(--pine-line); margin-bottom: var(--s1); }
.empty h4 { font-size: var(--t-lg); }
.empty p { font-size: var(--t-sm); color: var(--ink-2); max-width: 42ch; }
.empty__steps {
  display: flex; flex-direction: column; gap: var(--s2);
  margin-top: var(--s3); text-align: left; font-size: var(--t-sm); color: var(--ink-2);
}
.empty__steps li { display: flex; gap: var(--s2); align-items: flex-start; }
.empty__steps b {
  flex: 0 0 18px; height: 18px; border-radius: 50%;
  background: var(--pine-soft); color: var(--pine-deep);
  font-size: 11px; display: grid; place-items: center; font-weight: 600;
}

/* ---------- 7. 明细页 ---------- */
.monthbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s5);
}
.monthbar__nav { display: flex; align-items: center; gap: var(--s1); }
.monthbar__label {
  font-family: var(--font-num); font-size: var(--t-xl);
  font-variant-numeric: tabular-nums; min-width: 8ch; text-align: center;
}
.monthbar__label small { font-size: var(--t-sm); color: var(--ink-3); font-family: var(--font-sans); }
/* 窄屏下这行技术说明会把「2026 年 11 月」挤成两行，报表/明细多一行日期控件后更显拥挤。
   说明是静态提示，桌面端保留，手机端隐藏；不影响任何数据与交互。 */
@media (max-width: 639px) {
  .monthbar > div:last-child { display: none; }
}

.summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; margin-bottom: var(--s5);
}
.summary__cell { padding: var(--s4) var(--s5); border-right: 1px solid var(--line); }
.summary__cell:last-child { border-right: 0; }
.summary__k { font-size: var(--t-xs); color: var(--ink-3); }
.summary__v {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--t-2xl); font-weight: 480; letter-spacing: -0.02em;
  margin-top: 2px;
}
.summary__v.is-expense { color: var(--expense); }
.summary__v.is-income { color: var(--income); }
.summary__v small { font-size: var(--t-sm); font-family: var(--font-sans); color: var(--ink-3); margin-left: 4px; }

.filters {
  display: flex; align-items: center; gap: var(--s2);
  flex-wrap: wrap; margin-bottom: var(--s4);
}
/* 分类行：小屏横滑（别把明细列表挤下去），≥640 换行铺满 */
.filters--cats {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; margin-top: calc(var(--s2) * -1);
}
.filters--cats::-webkit-scrollbar { display: none; }
.filters--cats .chip { flex: 0 0 auto; }
@media (min-width: 640px) {
  .filters--cats { flex-wrap: wrap; overflow: visible; margin-top: 0; }
}
/* 报表的分类行前面是子页签，不是明细的 .filters 行，
   不能沿用 filters--cats 的负上外边距（窄屏会把 chip 拉到子页签上）。 */
.filters--report { margin-top: 0; }
.search {
  position: relative; flex: 1 1 200px; min-width: 160px;
}
.search input {
  width: 100%; padding: 7px var(--s3) 7px 34px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
}
.search input:focus { outline: none; border-color: var(--pine); }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-4);
}

/* 「筛选中」提示条：把当前生效的条件明写出来，并给一键复位入口 */
.filterbar {
  display: flex; align-items: center; gap: var(--s3);
  margin: 0 0 var(--s3); padding: var(--s2) var(--s3);
  border: 1px solid oklch(88% 0.045 165); border-radius: 999px;
  background: var(--pine-soft); color: var(--ink-2);
  font-size: var(--t-xs);
}
.filterbar__t b { color: var(--pine-deep); font-weight: 600; }
.filterbar .linkbtn { margin-left: auto; }

.daygroup { margin-bottom: var(--s5); }
.daygroup__head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 var(--s1) var(--s2);
  border-bottom: 1px solid var(--line);
  /* 吸顶基准是 .content（它才是滚动容器），顶栏在外面 */
  position: sticky; top: 0; background: var(--paper);
  z-index: 5; padding-top: var(--s2);
  /* 右缘让出行内操作区(74px)+列间距(--s3)，与每行金额右缘对齐成一条竖线 */
  padding-right: calc(var(--s1) + 74px + var(--s3));
}
.daygroup__date { font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.daygroup__week { font-size: var(--t-xs); color: var(--ink-3); margin-left: 6px; }
.daygroup__sum { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.rec {
  display: flex; align-items: center; gap: var(--s3);
  padding: 11px var(--s1); border-bottom: 1px solid var(--line);
  transition: background var(--dur) var(--ease);
  position: relative;
}
.rec:hover { background: var(--surface-2); }
.rec:hover .rec__act { opacity: 1; }
.rec__ico {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 17px;
  background: var(--paper-sunk); border: 1px solid var(--line);
}
.rec__body { flex: 1 1 0%; min-width: 0; }
.rec__cat { font-size: var(--t-base); display: flex; align-items: center; gap: 6px; }
.rec__note {
  font-size: var(--t-xs); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
/* 金额：自成右对齐的一列，右缘与日期行汇总「支 xxx」落在同一条竖线上 */
.rec__amt {
  flex: 0 0 auto; margin-left: auto; text-align: right;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--t-lg); letter-spacing: -0.015em; white-space: nowrap;
}
.rec__amt.is-expense { color: var(--expense); }
.rec__amt.is-income { color: var(--income); }
.rec__act { display: flex; gap: 2px; opacity: 0; transition: opacity var(--dur) var(--ease); }
.rec:focus-within .rec__act { opacity: 1; }

/* 操作按钮 hover 才显现，但始终占位（2×iconbtn 36px + gap 2px = 74px）。
   占位不能去掉：否则 hover 时按钮会盖住紧贴右缘的金额。
   因此让日期行汇总共用同一条预留宽度，两者落在同一竖线上。 */
/* 触屏无 hover，行内操作必须常驻（保留占位，金额仍严格右对齐于其左侧） */
@media (hover: none) { .rec__act { opacity: 1; } }

/* 待同步标记改挂到图标角标：不再撑开右侧内边距，避免整行相对正常行左移 */
.rec__pending {
  position: absolute; left: calc(var(--s1) + 27px); top: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--warn);
  box-shadow: 0 0 0 2px var(--paper);
}

/* 桌面双栏 */
.split { display: grid; grid-template-columns: minmax(0,1fr); gap: var(--s5); }

/* ---------- 8. 记一笔 ---------- */
.addpad { max-width: 460px; margin: 0 auto; }
.seg {
  display: inline-flex; padding: 3px; gap: 3px;
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: 999px;
}
.seg button {
  border: 0; background: transparent; padding: 6px var(--s5);
  border-radius: 999px; font-size: var(--t-base); color: var(--ink-2);
  transition: all var(--dur) var(--ease);
}
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 560;
  box-shadow: 0 1px 2px oklch(25% 0.02 165 / .10);
}
.seg button[data-t="expense"][aria-pressed="true"] { color: var(--expense); }
.seg button[data-t="income"][aria-pressed="true"] { color: var(--income); }

.amount {
  text-align: center; padding: var(--s6) 0 var(--s5);
  border-bottom: 1px solid var(--line); margin-bottom: var(--s5);
  cursor: text;
}
.amount__cur { font-size: var(--t-sm); color: var(--ink-3); }
/* 金额是真输入框：PC 直接键盘打字，移动端靠 inputmode=decimal 唤起数字盘 */
.amount__val {
  display: block; width: 100%; text-align: center;
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: clamp(2.8rem, 11vw, 4.2rem); font-weight: 400;
  letter-spacing: -0.03em; line-height: 1.15; color: var(--ink);
  min-height: 1.15em; padding: 2px 8px; margin: 0 auto;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
  caret-color: var(--pine);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.amount__val::placeholder { color: var(--ink-4); }
.amount__val:hover { border-color: var(--line); }
.amount__val:focus { outline: none; background: var(--surface); border-color: var(--pine-line); }
.amount__val.is-zero { color: var(--ink-4); }
.amount__val.is-expense { color: var(--expense); }
.amount__val.is-income { color: var(--income); }
.amount__hint { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--s2); }
.amount__hint b { color: var(--expense); font-weight: 600; }

.catgrid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--s2);
  margin-bottom: var(--s5);
}
.catgrid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--s3) 2px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent;
  transition: all var(--dur) var(--ease);
}
.catgrid button:hover { background: var(--paper-sunk); }
.catgrid button[aria-pressed="true"] {
  background: var(--pine-soft); border-color: var(--pine-line);
}
.catgrid__ico {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 19px;
  background: var(--surface); border: 1px solid var(--line);
}
.catgrid button[aria-pressed="true"] .catgrid__ico { background: var(--surface); border-color: var(--pine-line); }
.catgrid__t { font-size: 11px; color: var(--ink-2); }

.addrows { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s5); }
.addrow {
  display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.addrow__k { flex: 0 0 46px; font-size: var(--t-sm); color: var(--ink-3); }
.addrow__v { flex: 1; min-width: 0; display: flex; gap: var(--s2); align-items: center; }
.addrow input {
  flex: 1; min-width: 0; border: 0; background: transparent; padding: 2px 0;
  font-size: var(--t-base);
}
.addrow input:focus { outline: none; }
.addrow input[type="date"] { font-variant-numeric: tabular-nums; }

/* 3 列 × 4 行 12 键：7 8 9 / 4 5 6 / 1 2 3 / 小数点 · 0 · 退格。
   无框化：平时透明，按下才浮出淡底——像原生键盘，不像一摞表单卡片。
   桌面整个不显示，窄屏拇指点大按钮更稳。 */
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px var(--s2); }
.keypad button {
  padding: 15px 0; border: 0; border-radius: 14px;
  background: transparent; color: var(--ink);
  font-family: var(--font-num); font-size: 25px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  transition: background 90ms var(--ease), transform 90ms var(--ease);
}
.keypad button:hover { background: var(--paper-sunk); }
.keypad button:active { background: var(--pine-soft); transform: scale(.96); }
.keypad button[data-k="del"] { color: var(--ink-3); }
.keypad button[data-k="del"] svg { display: block; margin: 0 auto; }
.keypad button[data-k="del"]:active { color: var(--expense); }

/* 保存动作组：PC 在金额右侧（跟金额同一行），窄屏在金额下方。
   数字键盘只负责数字，不再夹带「保存 / ＋」两个按钮。 */
.addpad__acts { display: flex; gap: var(--s2); align-items: stretch; }
.addpad__acts .acts__save {
  flex: 1 1 auto; min-width: 0;
  padding: 13px 14px; border: 0; border-radius: var(--r-md);
  background: var(--pine); color: oklch(98% 0.01 84);
  font-family: var(--font-sans); font-size: var(--t-base); font-weight: 560;
  cursor: pointer;
  transition: background 90ms var(--ease), transform 90ms var(--ease);
}
.addpad__acts .acts__save:hover { background: var(--pine-deep); }
.addpad__acts .acts__save:active { transform: scale(.98); }
.addpad__acts .acts__more {
  flex: 0 0 auto; width: 52px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--clay); font-size: var(--t-lg);
  cursor: pointer;
  transition: background 90ms var(--ease), transform 90ms var(--ease);
}
.addpad__acts .acts__more:hover { background: var(--paper-sunk); }
.addpad__acts .acts__more:active { transform: scale(.97); }

/* 手机：点金额框时闪一下数字盘，提示「键盘在下面，用这个录入」 */
.keypad.is-pulse { animation: padPulse 900ms var(--ease) 2; }
@keyframes padPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
  40%      { box-shadow: 0 0 0 4px var(--pine-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .keypad.is-pulse { animation: none; }
}

/* 键盘快捷键提示（桌面显示；触屏没有 Alt 键，默认隐藏） */
.addpad__kb {
  display: none;
  flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--s2) var(--s4);
  margin-top: var(--s4);
  font-size: var(--t-xs); color: var(--ink-3);
}
.addpad__kb kbd {
  display: inline-block; padding: 1px 6px; margin: 0 2px;
  font-family: var(--font-sans); font-size: 11px; line-height: 18px;
  color: var(--ink-2); background: var(--paper-sunk);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
}

/* 桌面（≥1024）：金额是真输入框，物理键盘直接敲；界面数字键盘整个撤掉，
   「保存 / 保存并继续」收进金额行右侧，不再让数字键盘占着半栏空位。 */
@media (min-width: 1024px) {
  .addpad__kb { display: flex; }
  .addpad .keypad { display: none; }
  .addpad__acts { flex-direction: column; gap: var(--s2); }
  .addpad__acts .acts__more { width: auto; height: 46px; }
}

/* ---------- 9. 汇总 ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s5); }
.legend { display: flex; flex-direction: column; gap: var(--s2); }
.legend__row {
  display: grid; grid-template-columns: 10px 1fr auto auto;
  align-items: center; gap: var(--s3);
  padding: 5px 0; font-size: var(--t-sm);
}
.legend__sw { width: 10px; height: 10px; border-radius: 3px; }
.legend__n { color: var(--ink-2); }
.legend__p { color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
.legend__v { font-variant-numeric: tabular-nums; font-family: var(--font-num); min-width: 8ch; text-align: right; }

.donutwrap { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.donutwrap__chart { flex: 0 0 auto; position: relative; min-width: 176px; min-height: 176px; }
.donutwrap__center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  gap: 3px; line-height: 1.15;
}
.donutwrap__center b {
  display: block; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--t-xl); font-weight: 480; color: var(--expense);
}
.donutwrap__center span { display: block; font-size: 11px; color: var(--ink-3); }

.insight {
  display: flex; gap: var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--r-md); background: var(--pine-soft);
  border: 1px solid var(--pine-line); font-size: var(--t-sm); color: var(--pine-deep);
  margin-bottom: var(--s5);
}
.insight svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }

/* ---------- 已停用分类的统一展示 ----------
   历史流水的金额照常计入合计，但分类名不再单列，统一折成灰色标记。
   .is-off 只降饱和度、不改布局，避免 PC / 手机出现跳动。 */
.insight__off {
  margin-top: 5px; font-size: var(--t-xs); line-height: 1.55;
  color: var(--ink-3); border-top: 1px solid var(--pine-line); padding-top: 5px;
}
.rec__cat.is-off, .budget__name.is-off,
.legend__row.is-off .legend__n, .legend__row.is-off .legend__p, .legend__row.is-off .legend__v {
  color: var(--ink-4);
}
.legend__row.is-off .legend__sw { opacity: .55; }
.sheet__off {
  font-size: var(--t-xs); line-height: 1.55; color: var(--ink-3);
  background: var(--paper-sunk); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3); margin-bottom: var(--s3);
}

/* ---------- 10. 预算 ---------- */
.budget {
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface);
}
.budget.is-over { border-color: oklch(86% 0.06 27); background: var(--expense-soft); }
.budget__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.budget__name { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-base); }
.budget__num { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--t-sm); color: var(--ink-2); }
.budget__num b { font-size: var(--t-lg); color: var(--ink); font-weight: 480; }
.bar { height: 8px; border-radius: 999px; background: var(--paper-sunk); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--pine); transition: width 600ms var(--ease); }
.bar__fill.is-warn { background: var(--warn); }
.bar__fill.is-over { background: var(--expense); }

/* ---------- 11. 设置 ---------- */
.setgroup { margin-bottom: var(--s6); }
.setgroup__t {
  font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); margin-bottom: var(--s3); padding-left: var(--s1);
}
.setlist { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.setrow {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: var(--s3) var(--s4); border: 0; border-bottom: 1px solid var(--line);
  background: var(--surface); text-align: left;
  transition: background var(--dur) var(--ease);
}
.setrow:last-child { border-bottom: 0; }
.setrow:hover { background: var(--surface-2); }
.setrow__i { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-sunk); color: var(--ink-2); }
.setrow__b { flex: 1; min-width: 0; }
.setrow__t { font-size: var(--t-base); }
.setrow__d { font-size: var(--t-xs); color: var(--ink-3); }
.setrow__r { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s2); color: var(--ink-3); font-size: var(--t-sm); }
.setrow__chev { width: 16px; height: 16px; color: var(--ink-4); }

/* ---------- 12. 覆盖层：抽屉 / 弹窗 / Toast ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: oklch(25% 0.02 165 / .38);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s4) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom));
  max-height: 82dvh; overflow: auto;
  animation: rise 280ms var(--ease);
}
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
.sheet__grab { width: 36px; height: 4px; border-radius: 999px; background: var(--line-2); margin: 0 auto var(--s4); }
.sheet__t { font-size: var(--t-lg); margin-bottom: var(--s3); }
.sheet__acts { display: flex; gap: var(--s3); margin-top: var(--s5); }

.modal {
  position: fixed; z-index: 60; inset: 0;
  display: grid; place-items: center; padding: var(--s5);
}
.modal__box {
  width: min(560px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--s6); box-shadow: var(--sh-3);
  max-height: calc(100dvh - var(--s8)); overflow-y: auto;
  animation: pop 260ms var(--ease);
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4);
}
.modal__t { font-size: var(--t-lg); display: flex; align-items: center; gap: var(--s2); }
.modal__t svg { width: 20px; height: 20px; color: var(--warn); }
.modal__d { font-size: var(--t-sm); color: var(--ink-2); margin-top: var(--s2); }

.toasts {
  position: fixed; z-index: 70; left: 50%; bottom: calc(var(--s6) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--s2); align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-size: var(--t-sm); box-shadow: 0 10px 30px -12px oklch(25% 0.02 165 / .5);
  animation: toastin 260ms var(--ease);
  pointer-events: auto;
}
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } }
.toast button {
  background: none; border: 0; color: oklch(88% 0.06 90); font-size: var(--t-sm);
  text-decoration: underline; text-underline-offset: 3px; padding: 0;
}

/* ---------- 12.5 总览 Dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: var(--s4); height: 100%; min-height: 0; }
.dash .monthbar { margin-bottom: 0; }

.hero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 3px;
  padding: var(--s4) var(--s5);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.stat--pine {
  background: linear-gradient(165deg, var(--pine-soft), var(--surface) 72%);
  border-color: var(--pine-line);
}
.stat__k { font-size: var(--t-xs); color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.stat__v {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--t-2xl); font-weight: 470; letter-spacing: -.022em; line-height: 1.12;
}
.stat__v small { font-family: var(--font-sans); font-size: var(--t-sm); font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.stat--expense .stat__v { color: var(--expense); }
.stat--income  .stat__v { color: var(--income); }
.stat__d { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.stat__d b { font-weight: 600; }
.stat__d.up   b { color: var(--expense); }
.stat__d.down b { color: var(--income); }
.stat__bar { margin-top: var(--s2); }

.dash__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden;
}
.panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s5); border-bottom: 1px solid var(--line);
}
.panel__t { font-size: var(--t-base); font-weight: 560; }
.panel__x { font-size: var(--t-xs); color: var(--ink-3); }
.panel__body {
  flex: 1; min-height: 0; padding: var(--s4) var(--s5);
  display: flex; flex-direction: column;
}
.panel__body--flush { padding: 0; }
.panel__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* 分类占比 */
.donutwrap { display: flex; align-items: center; gap: var(--s5); flex: 1; min-height: 0; }
.donutwrap > svg { flex: 0 0 auto; }
.catlist { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; }
.catrow { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); }
.catrow__sw { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 3px; }
.catrow__n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catrow__v { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.catrow__p { flex: 0 0 40px; text-align: right; font-size: var(--t-xs); color: var(--ink-4); font-variant-numeric: tabular-nums; }

/* 走势 */
.sparkwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: var(--s2); }
.sparkwrap svg { width: 100%; }
.sparkfoot { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--ink-3); }

/* 预算小条 */
.brow { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.brow:last-child { border-bottom: 0; }
.brow__t { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: 7px; }
.brow__n { font-size: var(--t-sm); display: flex; align-items: center; gap: 7px; min-width: 0; }
.brow__v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--t-sm); color: var(--ink-3); }
.brow__v b { color: var(--ink); font-weight: 480; }

/* 总览里的紧凑流水行 */
.rec--tight { padding: 9px var(--s5); }
.rec--tight .rec__ico { flex: 0 0 28px; width: 28px; height: 28px; font-size: 15px; border-radius: 8px; }
.rec--tight .rec__amt { font-size: var(--t-base); }

/* ---------- 12.6 总览：预算条 + 功能入口 ---------- */
.strip {
  padding: var(--s4) var(--s5);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.strip__h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.strip__t { font-size: var(--t-sm); color: var(--ink-3); }
.strip__v { font-size: var(--t-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.strip__v b { font-size: var(--t-lg); color: var(--ink); font-weight: 480; }
.strip .bar { height: 10px; }
.strip__f { margin-top: var(--s2); font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.entrygrid {
  display: grid; gap: var(--s3);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.entry {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4); text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.entry:hover { border-color: var(--pine-line); background: var(--surface-2); transform: translateY(-1px); }
.entry:active { transform: translateY(0); }
.entry__i {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px;
  background: var(--paper-sunk); border: 1px solid var(--line);
}
.entry__b { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry__t { font-size: var(--t-base); font-weight: 560; }
.entry__d {
  font-size: var(--t-xs); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry__go { flex: 0 0 16px; width: 16px; height: 16px; color: var(--ink-4); }
.entry--primary {
  background: linear-gradient(165deg, var(--pine-soft), var(--surface) 78%);
  border-color: var(--pine-line);
}
.entry--primary .entry__i { background: var(--pine); border-color: var(--pine); }
.entry--primary .entry__t { color: var(--pine-deep); }
.entry--primary:hover { background: var(--pine-soft); border-color: var(--pine); }
.entry--primary .entry__go { color: var(--pine); }

/* ---------- 12.7 报表页子页签 ---------- */
.subtabs {
  display: inline-flex; gap: 3px; padding: 3px; margin-bottom: var(--s5);
  background: var(--paper-sunk); border: 1px solid var(--line); border-radius: 999px;
}
.subtab {
  border: 0; background: transparent; padding: 6px var(--s5);
  border-radius: 999px; font-size: var(--t-base); color: var(--ink-2);
  transition: all var(--dur) var(--ease);
}
.subtab[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 560;
  box-shadow: 0 1px 2px oklch(25% 0.02 165 / .10);
}

/* 侧栏记一笔按钮 / 顶栏按钮 */
.side__cta { padding: 0 var(--s3) var(--s3); }
.side__cta .btn { justify-content: center; }
.top__add { gap: 5px; }

/* 设置页：账号与退出登录 */
.setlogout { padding: var(--s3) var(--s4) 0; }
.btn--logout {
  background: var(--surface); color: var(--expense);
  border: 1px solid oklch(86% 0.05 28);
}
.btn--logout:hover { background: oklch(97% 0.025 28); }

/* 总览一屏：桌面下页面本身不滚 */
@media (min-width: 1024px) {
  .content.is-fit { overflow: hidden; }
}

/* ---------- 13. 响应式：三档断点 ---------- */

/* 平板 640–1023：侧栏收为图标栏 */
@media (max-width: 1023px) {
  :root { --side-w: 72px; }
  .side__name { display: none; }
  .side__brand { justify-content: center; padding: 0; }
  .nav { justify-content: center; padding: 10px 0; }
  .nav__t { display: none; }
  .nav[aria-current="page"] { box-shadow: inset 3px 0 0 var(--pine); }
  .side__foot { flex-direction: column; padding: var(--s3) var(--s2); }
  .whoami__meta, .side__foot .linkbtn { display: none; }
  .content { padding: var(--s5) var(--s4) var(--s7); }
}

/* 移动 <640：底部 Tab，无侧栏 */
@media (max-width: 639px) {
  .side {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px; flex-basis: 240px;
    transform: translateX(-100%); transition: transform var(--dur) var(--ease);
    box-shadow: 0 0 40px -10px oklch(25% 0.02 165 / .3);
    will-change: transform;
    touch-action: pan-y;
    z-index: 45;            /* 高于遮罩(40)，抽屉可点；低于弹层(50/60) */
  }
  .side.is-open { transform: none; }
  .side__name { display: inline; }
  .side__brand { justify-content: flex-start; padding: 0 var(--s5); }
  .nav { justify-content: flex-start; padding: 9px var(--s3); }
  .nav__t { display: inline; }
  .side__foot { flex-direction: row; padding: var(--s4) var(--s5); }
  .whoami__meta { display: flex; }
  .side__foot .linkbtn { display: inline-block; }

  .top__burger { display: inline-grid; }
  .content { padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom)); }

  .tabbar {
    display: flex; align-items: stretch;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: oklch(97.4% 0.011 84 / .94);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: 0; background: none; color: var(--ink-3);
    font-size: 10.5px; padding: 0;
    transition: color var(--dur) var(--ease);
  }
  .tab svg { width: 22px; height: 22px; }
  .tab[aria-current="page"] { color: var(--pine); font-weight: 600; }
  .tab--fab {
    flex: 0 0 60px; color: oklch(98% 0.01 84);
  }
  .tab--fab svg {
    width: 44px; height: 44px; padding: 10px; border-radius: 50%;
    background: var(--pine); box-shadow: 0 6px 16px -6px oklch(40% 0.058 163 / .7);
  }
  .tab--fab[aria-current="page"] { color: var(--pine); }
  .tab--fab[aria-current="page"] svg { background: var(--pine-deep); }

  .summary { grid-template-columns: 1fr; }
  .summary__cell { border-right: 0; border-bottom: 1px solid var(--line); padding: var(--s3) var(--s4); }
  .summary__cell:last-child { border-bottom: 0; }
  .summary__v { font-size: var(--t-xl); }

  .catgrid { grid-template-columns: repeat(4, 1fr); }
  .addpad { max-width: none; }
  .login { padding: 0; grid-template-columns: 1fr; }
  .login__ledger { display: none; }
  .login__card { padding: var(--s5); margin: var(--s5) auto; }
  .top__add span { display: none; }
  .top__add { padding: 6px var(--s2); }
  .toasts { bottom: calc(var(--tabbar-h) + var(--s4) + env(safe-area-inset-bottom)); }

  /* 移动端顶栏：退出入口已移入设置页，搜索图标保持隐藏避免拥挤
     （HTML 上只有 id、没有 class，两个选择器都要写，否则隐藏不生效） */
  .top__search, #topSearch { display: none; }
}

/* 记一笔弹窗：<1024（手机 + 平板）统一走全屏底部抽屉，数字键盘钉在屏幕最底。
   只作用于 .modal--add —— 冲突 / 清空 / 载入演示等普通弹窗仍是居中可滚动卡片，
   不再被全屏规则误伤（内容贴边、overflow hidden、底部按钮被裁）。 */
@media (max-width: 1023px) {
  .modal--add { padding: 0; align-items: stretch; justify-items: stretch; }
  .modal--add .modal__box {
    width: 100%; max-width: 100%;
    max-height: 100dvh; height: 100dvh;
    border: 0; border-radius: 0; overflow: hidden;
    /* 底部内边距交给数字键盘（它自带安全区），这里必须清零，否则键盘下方垫一层空白 */
    padding: max(var(--s4), env(safe-area-inset-top)) 0 0;
    display: flex; flex-direction: column;
    animation: rise 280ms var(--ease);
  }
  .modal--add .modal__box > .modal__head { flex: 0 0 auto; margin-bottom: 0; padding: 0 var(--s5) var(--s3); }
  /* 普通弹窗：保留居中卡片的滚动能力，长内容的确定按钮不会被屏幕底部裁掉 */
  .modal:not(.modal--add) .modal__box {
    max-height: calc(100dvh - var(--s7));
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  /* 抽屉 = 内容区（可滚动）＋ 保存条（常驻）＋ 数字键盘（钉底），三者互不挤占 */
  .addpad {
    flex: 1 1 auto; min-height: 0; max-width: 100%;
    display: flex; flex-direction: column;
    padding: 0; overflow: hidden;
  }
  .addpad__body {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column;
    padding: 0 var(--s5);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .addpad .seg { flex: 0 0 auto; align-self: center; }
  .addpad .amount { flex: 0 0 auto; padding: var(--s2) 0 var(--s3); margin-bottom: 0; border-bottom: 0; }
  .addpad .amount__hint { display: none; }
  .addpad .catgrid { flex: 0 0 auto; margin-bottom: var(--s3); }
  .addpad .addrows { flex: 0 0 auto; margin-bottom: 0; gap: var(--s2); }
  .addpad__acts { flex: 0 0 auto; margin: 0 var(--s5) var(--s2); }
  /* 键盘通栏钉底：按键铺满屏宽更好按；高度 clamp(200px, 34dvh, 300px)
     随屏高伸缩，矮屏不被挤出视口、高屏也不留大片空白 */
  .addpad .keypad {
    flex: 0 0 auto;
    margin: 0;
    padding: var(--s2) var(--s5) max(var(--s3), env(safe-area-inset-bottom));
    height: 262px;
    height: clamp(200px, 34dvh, 300px);
    grid-template-rows: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: var(--paper);
    box-shadow: 0 -6px 16px -12px oklch(25% 0.02 165 / .35);
  }
  .keypad button { padding: 0; min-height: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
  .addpad > p { display: none; }
}

/* 桌面 ≥1024：记一笔单屏不滚动
   单列竖向堆叠会把 seg → 金额 → 分类 → 日期备注 拉成 5 屏高，
   这里改成左右两栏：左表单、右侧只放「保存 / 保存并继续」竖排按钮。
   界面数字键盘在桌面整个隐藏，金额用物理键盘直接敲（打开即聚焦）。
   移动端(max-width:1023)的纵向 flex 规则在这之上，互不干扰。 */
@media (min-width: 1024px) {
  .addpad {
    max-width: none; margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 168px;
    column-gap: var(--s6); row-gap: var(--s3);
    align-items: start;
  }
  .addpad .seg       { grid-area: 1 / 1 / 2 / 2; justify-self: start; }
  /* 内容区在桌只是个逻辑分组：display:contents 让 seg/金额/分类/日期继续直接
     参与这层栅格，移动端那套「滚动内容区」写法不会影响桌面视图 */
  .addpad__body      { display: contents; }
  .addpad .amount    { grid-area: 2 / 1 / 3 / 2; padding: var(--s3) 0 var(--s4); margin-bottom: 0; }
  .addpad .catgrid   { grid-area: 3 / 1 / 4 / 2; margin-bottom: 0; }
  .addpad .addrows   { grid-area: 4 / 1 / 5 / 2; margin-bottom: 0; }
  .addpad__acts      { grid-area: 2 / 2 / 3 / 3; align-self: center; }
  .addpad .keypad    { display: none; }
  .addpad__kb        { grid-area: 5 / 1 / 6 / 3; }
  .addpad > p        { grid-area: 6 / 1 / 7 / 3; margin-top: var(--s1); }
  .addpad .amount__val { font-size: clamp(2.3rem, 3.2vw, 3rem); }
  .addpad .amount__hint { margin-top: 2px; }
  .catgrid { gap: var(--s3); }
  .catgrid__ico { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
  .catgrid__t { font-size: 11.5px; }
}

/* 桌面 ≥1024：明细页双栏 */
@media (min-width: 1024px) {
  .split { grid-template-columns: minmax(0, 1fr) 336px; align-items: start; }
  .rail { position: sticky; top: 0; }
}

/* 平板 640–1023 的汇总双栏 */
@media (min-width: 640px) and (max-width: 1023px) {
  .statgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 总览：平板起 hero 四联 */
@media (min-width: 640px) {
  .hero { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
}

/* 总览：桌面一屏。两行面板按 7:5 分，高度由栅格分配，页面整体不滚 */
@media (min-width: 1024px) {
  .dash__grid {
    flex: 1; min-height: 0;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr);
  }
  .p-7 { grid-column: span 7; }
  .p-5 { grid-column: span 5; }
}

/* 平板与移动：总览改为常规纵向滚动，面板给个下限免得塌 */
@media (max-width: 1023px) {
  .wrap--dash { height: auto; }
  .panel { min-height: 210px; }
  .panel__scroll { max-height: 320px; }
  .donutwrap { flex-wrap: wrap; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ================= 时间区间选择（明细 / 报表共用） ================= */
.rangebar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 0 0 var(--s2);
}
.rangebar__now {
  font-size: var(--t-xs); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
/* 总览：月份切换内嵌进区间栏同一行，避免多占一行高度 */
.rangebar__month { display: flex; align-items: center; }
.rangebar__month .monthbar__label {
  font-size: var(--t-lg); min-width: 0; white-space: nowrap;
}
.dash .rangebar { margin-bottom: 0; }
/* ---------- 自定义区间：单窗口日历（PC 双月 / 移动单月） ---------- */
.modal--cal .modal__box { width: min(720px, 100%); }
.cal__sel {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); margin-bottom: var(--s2);
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: 10px;
}
.cal__sel > span { display: inline-flex; align-items: baseline; gap: 6px; }
.cal__sel i { font-style: normal; font-size: var(--t-xs); color: var(--ink-3); }
.cal__sel b { font-size: var(--t-base); font-weight: 600; color: var(--ink); }
.cal__arrow { color: var(--ink-3); }
.cal__span { margin-left: auto; font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }
.cal__hint { font-size: var(--t-xs); color: var(--ink-3); margin: 0 0 var(--s3); line-height: 1.6; }
.cal__nav { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.cal__navt { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.cal__months { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
.cal__mt {
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-2);
  text-align: center; margin-bottom: var(--s2);
}
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal__wd {
  display: flex; align-items: center; justify-content: center;
  height: 26px; font-size: var(--t-xs); color: var(--ink-3);
}
.cal__day {
  display: flex; align-items: center; justify-content: center;
  height: 40px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: var(--t-sm); font-variant-numeric: tabular-nums;
  cursor: pointer; transition: background var(--dur) var(--ease);
}
.cal__day.is-empty { cursor: default; }
.cal__day:not(.is-empty):hover { background: var(--pine-soft); }
.cal__day.is-in { background: var(--pine-soft); border-radius: 0; }
.cal__day.is-preview { background: var(--pine-soft); opacity: .72; }
.cal__day.is-edge { background: var(--pine); color: var(--surface); font-weight: 600; }
.cal__day.is-today:not(.is-edge) { outline: 1px solid var(--pine); outline-offset: -1px; }
.cal__day:focus-visible { outline: 2px solid var(--pine); outline-offset: 1px; position: relative; z-index: 1; }
.cal__acts { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); }
@media (max-width: 719px) {
  /* 窄屏只显示一个月，「回到今天 / 上月 / 下月」仍可翻到任意月份 */
  .cal__months { grid-template-columns: 1fr; }
  .cal__month:nth-child(2) { display: none; }
}
@media (pointer: coarse) {
  .cal__day { height: 44px; }
}
.btn--sm { padding: 5px 14px; font-size: var(--t-sm); }

/* ================= 支出节奏图 ================= */
#sparkBox { position: relative; }
/* 指标表头：峰值 / 均 / 合计 / 周期数 */
.sparkhead {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 6px var(--s4);
  margin: 0 0 var(--s3); padding-bottom: var(--s2);
  border-bottom: 1px solid var(--line);
}
.sparkhead__i {
  font-size: var(--t-xs); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sparkhead__i b { color: var(--ink); font-weight: 600; margin: 0 2px; }
.spark__hit { cursor: crosshair; }
.spark__focus { transition: opacity .12s linear; }
.sparktip {
  position: absolute; top: 2px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-size: var(--t-xs); line-height: 1.5;
  padding: 3px 9px; border-radius: 7px; white-space: nowrap;
  pointer-events: none; z-index: 4;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  font-variant-numeric: tabular-nums;
}
.sparktip[hidden] { display: none; }
/* ================= 输入控件：iOS 聚焦缩放防护 =================
   iOS Safari 对 font-size < 16px 的输入框会在聚焦时自动放大整个页面，
   且不会自动缩回。统一提到 16px（只改可输入控件，不动全局排版字号）。 */
.input,
.inputWrap input,
.search input,
.addrow input,
#q {
  font-size: 16px;
}

/* ================= 触屏触摸目标 =================
   极简布局里的图标按钮 / chip / 文字链接视觉尺寸较小，
   用透明伪元素把可点区域扩到 44×44，不改变任何视觉尺寸。 */
@media (pointer: coarse) {
  .iconbtn, .linkbtn, .btn--sm, .chip, .subtab, .top__add, .rec__act button {
    position: relative;
  }
  .iconbtn::after, .linkbtn::after, .btn--sm::after, .chip::after,
  .subtab::after, .top__add::after, .rec__act button::after {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: max(100%, 44px); height: max(100%, 44px);
    transform: translate(-50%, -50%);
  }
}

/* ================= 分类管理弹窗 =================
   沿用纸张质感：一张卡片、两栏页签、每行一条分类。
   所有可点控件本身就有 44px 高，触屏无需再靠伪元素补热区。 */
.modal--cats .modal__box { width: min(640px, 100%); }
.catm__hint {
  margin-top: var(--s3); padding: var(--s3) var(--s4);
  background: var(--warn-soft); border: 1px solid oklch(88% 0.05 80);
  border-radius: 10px; font-size: var(--t-sm); color: var(--ink-2);
}
.catm__tabs { display: flex; gap: var(--s4); margin: var(--s4) 0 var(--s3); border-bottom: 1px solid var(--line); }
.catm__tab {
  min-height: 44px; padding: 0 4px; background: none; border: 0;
  border-bottom: 2px solid transparent; color: var(--ink-3);
  font-size: var(--t-base); cursor: pointer;
}
.catm__tab[aria-pressed="true"] { color: var(--pine); border-bottom-color: var(--pine); font-weight: 600; }
.catm__list { display: flex; flex-direction: column; gap: var(--s2); }
.catm__row { padding: var(--s3); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.catm__row.is-hidden { background: var(--paper-sunk); opacity: .72; }
.catm__main { display: flex; align-items: center; gap: var(--s2); }
.catm__emoji {
  flex: 0 0 44px; width: 44px; height: 44px; font-size: 22px; line-height: 1;
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer;
}
.catm__emoji:disabled { cursor: default; }
.catm__name { flex: 1 1 auto; min-width: 0; }
.catm__tag { flex: 0 0 auto; font-size: var(--t-xs); color: var(--ink-3); }
.catm__ops { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.catm__op {
  min-height: 44px; padding: 0 14px; font-size: var(--t-sm);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink-2); cursor: pointer;
}
.catm__op:hover:not(:disabled) { border-color: var(--ink-4); color: var(--ink); }
.catm__op:disabled { opacity: .35; cursor: default; }
.catm__op.is-danger { color: var(--expense); }
.catm__picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line);
}
.catm__pick {
  height: 44px; font-size: 20px; line-height: 1;
  background: var(--paper-sunk); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.catm__pick:hover { border-color: var(--pine); background: var(--pine-soft); }
.catm__confirm {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  margin-top: var(--s3); padding: var(--s3); border-radius: 10px;
  background: var(--expense-soft); font-size: var(--t-sm); color: var(--ink-2);
}
.catm__confirm .btn { min-height: 44px; }
.catm__confirm .btn:first-of-type { margin-left: auto; }
.catm__new { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }
.catm__new > .input:first-child { flex: 1 1 160px; min-width: 0; }
.catm__newicon { flex: 0 0 72px; width: 72px; text-align: center; }
.catm__add { margin-top: var(--s3); }
.catm__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); }
.catm__empty { padding: var(--s5); text-align: center; font-size: var(--t-sm); color: var(--ink-3); }
/* 桌面端把操作按钮收到同一行右侧，9 个分类一屏看得完；手机仍保持两行避免挤压 */
@media (min-width: 640px) {
  .catm__row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2); }
  .catm__ops { margin-top: 0; flex-wrap: nowrap; }
  .catm__confirm, .catm__picker { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .modal--cats .modal__box { padding: var(--s4); }
  .catm__tag { display: none; }         /* 手机上省掉「预置/自建」标签，给名称让位 */
  .catm__op { padding: 0 12px; }
}
