/* ─────────────────────────────────────────────────────────────
   components.css · ui/components.js、sheet.js、toast.js 产出的全部组件
   层次靠留白、字重和表面色阶，不靠边框；颜色一律来自令牌或由令牌 color-mix。
   ───────────────────────────────────────────────────────────── */

/* ── 色调（tone）──
   --tone：图标/文字用的前景色；--tone-soft：柔和底；--tone-solid：条、点这类实心色块。 */
.tone-s1 {
  --tone: var(--series-1);
}
.tone-s2 {
  --tone: var(--series-2);
}
.tone-s3 {
  --tone: var(--series-3);
}
.tone-s4 {
  --tone: var(--series-4);
}
.tone-s5 {
  --tone: var(--series-5);
}
.tone-s6 {
  --tone: var(--series-6);
}
.tone-s1,
.tone-s2,
.tone-s3,
.tone-s4,
.tone-s5,
.tone-s6 {
  --tone-soft: color-mix(in srgb, var(--tone) 15%, transparent);
  --tone-solid: var(--tone);
}
.tone-accent {
  --tone: var(--accent-text);
  --tone-soft: var(--accent-soft);
  --tone-solid: var(--accent);
}
.tone-pos {
  --tone: var(--pos);
  --tone-soft: var(--pos-soft);
  --tone-solid: var(--pos);
}
.tone-neg {
  --tone: var(--neg);
  --tone-soft: var(--neg-soft);
  --tone-solid: var(--neg);
}
.tone-warn {
  --tone: var(--warn);
  --tone-soft: var(--warn-soft);
  --tone-solid: var(--warn);
}
.tone-muted {
  --tone: var(--ink-2);
  --tone-soft: var(--fill);
  --tone-solid: var(--series-muted);
}

/* ── 卡片 ── */
.card {
  --on: var(--surface);
  --fill: var(--surface-2);
  --fill-hover: var(--surface-3);
  --card-pad: var(--s-5);
  min-width: 0;
  padding: var(--card-pad);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
@media (min-width: 720px) {
  .card {
    --card-pad: var(--s-6);
  }
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 28px;
  margin-bottom: var(--s-4);
}
.card__titles {
  min-width: 0;
}
.card__title {
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
}
.card__subtitle {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--fs-sub);
}
.card__foot {
  margin-top: var(--s-4);
}
.card__head .btn--ghost,
.section-header .btn--ghost {
  margin-inline-end: calc(var(--s-3) * -1);
}
.card--plain {
  --on: var(--bg);
  --fill: var(--surface);
  --fill-hover: var(--surface-2);
  --card-pad: 0px;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.card--inset {
  --on: var(--surface-2);
  --fill: var(--surface-3);
  --fill-hover: var(--line-strong);
  --raised: var(--surface);
  --card-pad: var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: none;
}
/* 庆祝型渐变卡：只给“目标”用。把文字角色整体换成白系，里面的组件自动跟着变 */
.card--gradient {
  --ink: var(--accent-ink);
  --ink-2: color-mix(in srgb, var(--accent-ink) 80%, transparent);
  --ink-3: color-mix(in srgb, var(--accent-ink) 62%, transparent);
  --line: color-mix(in srgb, var(--accent-ink) 18%, transparent);
  --fill: color-mix(in srgb, var(--accent-ink) 16%, transparent);
  --fill-hover: color-mix(in srgb, var(--accent-ink) 24%, transparent);
  --accent-text: var(--accent-ink);
  --accent-soft: color-mix(in srgb, var(--accent-ink) 18%, transparent);
  --on: transparent;
  background: var(--card-gradient);
  box-shadow: none;
  color: var(--ink);
}
.card--gradient .meter {
  --tone-solid: var(--accent-ink);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 36px;
  padding-inline: var(--s-1);
}
.section-header__title {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  font-size: var(--fs-title-3);
  font-weight: var(--fw-bold);
}
.section-header__count {
  color: var(--ink-3);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}

/* ── 列表行 ── */
.list-group {
  --on: var(--surface);
  --fill: var(--surface-2);
  --fill-hover: var(--surface-3);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--s-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
/* 放进卡片：去掉自己的底，向外伸 12px，让行内文字与卡片标题左缘对齐、hover 底略宽于文字 */
.list-group--flush {
  margin: calc(var(--s-2) * -1) calc(var(--s-3) * -1);
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--row-h);
  padding: var(--s-2) var(--s-3);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: inherit;
  text-align: left;
  transition:
    background-color var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.row--tap {
  cursor: pointer;
}
.row--tap:hover,
.row.is-selected {
  background: var(--fill);
}
.row--tap:active {
  background: var(--fill-hover);
  transform: scale(0.99);
}
/* 保存后对应行闪一下：视图给行加 .is-flash 即可 */
.row.is-flash {
  animation: row-flash calc(var(--dur-4) * 2) var(--ease-out);
}
@keyframes row-flash {
  0%,
  35% {
    background: var(--accent-soft-2);
  }
}
.list-group--lined .row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: var(--s-3);
  left: calc(var(--s-3) + 40px + var(--s-3)); /* 从文字起始处开始，不从图标下面穿过 */
  height: 1px;
  background: var(--line);
}
.row__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tone-soft);
  color: var(--tone);
}
.row__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.row__title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-2);
  color: var(--ink-2);
  font-size: var(--fs-sub);
  line-height: var(--lh-snug);
}
.row__trail {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.row__amount {
  font-size: calc(var(--fs-body) + 1px);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}
.row__amount.is-pos {
  color: var(--pos);
}
.row__amount.is-neg {
  color: var(--neg);
}
.row__amount.is-muted {
  color: var(--ink-2);
}
.row__sub-amount {
  color: var(--ink-2);
  font-size: var(--fs-sub);
  line-height: var(--lh-snug);
}

/* ── 按钮 ── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-pill);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    opacity var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.is-loading:disabled {
  opacity: 1;
}
.btn__content {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.btn__icon {
  display: inline-flex;
}
.btn__spinner {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
}
.btn.is-loading .btn__content {
  visibility: hidden;
}
.btn.is-loading .btn__spinner {
  display: grid;
}
.btn--lg {
  min-height: 52px;
  padding: 0 var(--s-6);
  font-size: calc(var(--fs-body) + 1px);
}
@media (min-width: 1024px) {
  .btn--lg {
    min-height: var(--hit);
  }
}
.btn--md {
  min-height: var(--hit);
  padding: 0 var(--s-5);
  font-size: var(--fs-body);
}
.btn--sm {
  min-height: 36px;
  padding: 0 var(--s-3);
  font-size: var(--fs-sub);
}
/* 小号按钮视觉 36px，命中区补到 44px */
.btn--sm::after,
.icon-btn--sm::after,
button.chip--tap::after,
.chip__main::after,
.segmented--sm .segmented__option::after {
  content: "";
  position: absolute;
  inset: -4px 0;
}
.btn--block {
  display: flex;
  width: 100%;
}
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn--secondary {
  background: var(--fill);
  color: var(--ink);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--fill-hover);
}
.btn--tinted {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.btn--tinted:hover:not(:disabled) {
  background: var(--accent-soft-2);
}
.btn--ghost {
  background: none;
  color: var(--accent-text);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--accent-soft);
}
.btn--danger {
  background: var(--neg-soft);
  color: var(--neg);
}
.btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--neg) 22%, transparent);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-4) var(--s-5);
}
@media (min-width: 1024px) {
  .hero .action-row {
    justify-content: flex-start;
  }
}
.action-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  min-width: 64px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--ink);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  cursor: pointer;
  user-select: none;
}
.action-btn__circle {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--tone-soft);
  color: var(--tone);
  transition:
    background-color var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-spring);
}
.action-btn:hover:not(:disabled) .action-btn__circle {
  background: color-mix(in srgb, var(--tone) 24%, transparent);
}
.action-btn:active:not(:disabled) .action-btn__circle {
  transform: scale(0.92);
}
.action-btn:disabled {
  opacity: 0.4;
}
.action-btn:focus-visible {
  box-shadow: none;
}
.action-btn:focus-visible .action-btn__circle {
  box-shadow: var(--focus-ring);
}

.icon-btn {
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.icon-btn:hover:not(:disabled) {
  background: var(--fill);
}
.icon-btn:active:not(:disabled) {
  transform: scale(0.92);
}
.icon-btn:disabled {
  opacity: 0.4;
}
.icon-btn--sm {
  width: 36px;
  height: 36px;
}
.icon-btn--sm::after {
  inset: -4px;
}
.icon-btn--filled {
  background: var(--fill);
}
.icon-btn--filled:hover:not(:disabled) {
  background: var(--fill-hover);
}
.icon-btn--accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.icon-btn--accent:hover:not(:disabled) {
  background: var(--accent-soft-2);
}

.fab {
  position: fixed;
  right: max(var(--gutter), env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-4));
  z-index: var(--z-fab);
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--shadow-fab);
  color: var(--accent-ink);
  transition:
    background-color var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-spring);
}
.fab:hover {
  background: var(--accent-hover);
}
.fab:active {
  transform: scale(0.92);
}
.fab:focus-visible {
  box-shadow: var(--focus-ring), var(--shadow-fab);
}
@media (min-width: 1024px) {
  .fab {
    display: none;
  }
}

/* ── Chip / Badge ── */
.chip {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--ink);
  font-size: var(--fs-sub);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.chip--tap {
  cursor: pointer;
  user-select: none;
}
button.chip--tap::after,
.chip__main::after {
  inset: -6px 0;
}
.chip--tap:hover {
  background: var(--fill-hover);
}
button.chip--tap:active {
  transform: scale(0.96);
}
.chip.is-selected,
.chip.is-selected:hover {
  background: var(--ink);
  color: var(--ink-inverse);
}
.chip__main {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  font-weight: inherit;
  cursor: pointer;
}
.chip--removable {
  padding-inline-end: var(--s-1);
}
.chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone-solid);
}
.chip__remove {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}
.chip__remove::after {
  content: "";
  position: absolute;
  inset: -10px -6px;
}
.chip__remove:hover {
  background: color-mix(in srgb, currentColor 14%, transparent);
  opacity: 1;
}
.chip-row {
  display: flex;
  gap: var(--s-2);
  min-width: 0;
  padding-block: 6px; /* 给 chip 的扩展命中区和焦点环留位置，不被 overflow 裁掉 */
  margin-block: -6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar {
  display: none;
}
.chip-row--wrap {
  flex-wrap: wrap;
  overflow: visible;
}
/* 直接放在 .page 下时可以加 --bleed：横滑内容一直铺到屏幕边缘 */
.chip-row--bleed {
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
}

.badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--tone-soft);
  color: var(--tone);
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ── 分段控件 ── */
.segmented {
  position: relative;
  isolation: isolate;
  display: inline-grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  flex: none;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--fill);
}
.segmented--block {
  display: grid;
  width: 100%;
}
.segmented__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  z-index: -1;
  width: calc((100% - 6px) / var(--seg-count, 2));
  border-radius: var(--r-pill);
  background: var(--raised);
  box-shadow: var(--shadow-card);
  transform: translateX(calc(var(--seg-index, 0) * 100%));
  transition:
    transform var(--dur-3) var(--ease-out),
    opacity var(--dur-2) var(--ease-out);
}
.segmented.is-empty .segmented__thumb {
  opacity: 0;
}
.segmented__option {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  min-width: 56px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  color: var(--ink-2);
  font-size: var(--fs-sub);
  font-weight: var(--fw-semibold);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-2) var(--ease-out);
}
.segmented__option:hover,
.segmented__option[aria-checked="true"] {
  color: var(--ink);
}
.segmented--sm .segmented__option {
  height: 30px;
  min-width: 40px;
  padding: 0 var(--s-3);
}
.segmented--sm .segmented__option::after {
  inset: -7px 0;
}
.segmented--lg .segmented__option {
  height: var(--hit);
  font-size: var(--fs-body);
}
.currency-toggle .segmented__option {
  font-variant-numeric: tabular-nums;
}

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill-hover);
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.switch[aria-checked="true"] {
  background: var(--accent);
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-ink);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch[aria-checked="true"] .switch__thumb {
  transform: translateX(20px);
}
.switch:disabled {
  opacity: 0.4;
}

/* ── 金额 ── */
.money {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
  color: var(--ink);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-snug);
  white-space: nowrap;
}
.money--start {
  align-items: flex-start;
}
.money--center {
  align-items: center;
}
.money--end {
  align-items: flex-end;
}
.money__main {
  display: inline-block;
}
.money__approx {
  margin-inline-end: 0.2em;
  color: var(--ink-2);
  font-weight: var(--fw-regular);
}
.money--md {
  font-size: var(--fs-title-3);
}
.money--sm {
  font-size: var(--fs-body);
}
/* 三档大数字：比例数字（不是等宽）、符号与小数 0.6em 退成次要色 */
.money--hero,
.money--display,
.money--lg {
  font-weight: var(--fw-bold);
  font-variant-numeric: normal;
}
.money--hero {
  font-size: var(--fs-hero);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-hero);
}
.money--display {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-title);
}
.money--lg {
  font-size: var(--fs-title-1);
  letter-spacing: var(--track-title);
}
:is(.money--hero, .money--display, .money--lg) :is(.money__sym, .money__frac, .money__suffix) {
  color: var(--ink-2);
  font-size: 0.6em;
  letter-spacing: var(--track-title);
}
:is(.money--hero, .money--display, .money--lg) .money__sym {
  margin-inline-end: 0.08em;
}
.money--pos .money__main {
  color: var(--pos);
}
.money--neg .money__main {
  color: var(--neg);
}
.money--muted .money__main {
  color: var(--ink-2);
}
.money__sub {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--fs-sub);
  font-weight: var(--fw-regular);
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-body);
}
:is(.money--hero, .money--display) .money__sub {
  margin-top: var(--s-2);
  font-size: var(--fs-body);
}
.money--tap {
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out);
}
.money--tap:active {
  transform: scale(0.98);
}
/* rollNumber 过渡期间，旧数字脱离文档流叠在原位 */
.money__ghost {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.money--center .money__ghost {
  left: 50%;
  transform: translateX(-50%);
}
.money--end .money__ghost {
  right: 0;
  left: auto;
}

/* ── 进度条 ── */
.meter {
  --meter-h: 8px;
  position: relative;
  width: 100%;
}
.meter--sm {
  --meter-h: 4px;
}
.meter--lg {
  --meter-h: 12px;
}
.meter--labelled {
  padding-bottom: 20px;
}
.meter__track {
  display: block;
  height: var(--meter-h);
  overflow: hidden;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--tone-solid) 18%, transparent);
}
.meter__fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--tone-solid);
  transition:
    width var(--dur-4) var(--ease-out),
    background-color var(--dur-2) var(--ease-out);
  animation: meter-grow var(--dur-4) var(--ease-out) backwards;
}
@keyframes meter-grow {
  from {
    width: 0;
  }
}
.meter__marks {
  position: absolute;
  inset: 0 0 auto;
  height: var(--meter-h);
  pointer-events: none;
}
/* 刻度是一道“缝”：用所在表面的颜色切开进度条 */
.meter__mark {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  margin-left: -1px;
  background: var(--on);
}
.meter__mark-label {
  position: absolute;
  top: calc(var(--meter-h) + 6px);
  left: 50%;
  color: var(--ink-3);
  font-size: var(--fs-micro);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  transform: translateX(-50%);
}

/* ── 分段占比条 + 图例 ── */
.seg-bar {
  --seg-h: 12px;
  width: 100%;
}
.seg-bar--sm {
  --seg-h: 8px;
}
.seg-bar--lg {
  --seg-h: 16px;
}
.seg-bar__track {
  display: flex;
  gap: 2px;
  height: var(--seg-h);
  overflow: hidden;
  border-radius: var(--r-pill);
}
.seg-bar__seg {
  flex: 0 1 0;
  min-width: 4px;
  border-radius: 2px;
  background: var(--tone-solid);
  animation: fade-in var(--dur-4) var(--ease-out) backwards;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-3);
}
.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sub);
  line-height: var(--lh-snug);
}
.legend__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tone-solid);
}
.legend__label {
  color: var(--ink-2);
}
.legend__value {
  color: var(--ink);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

/* ── 统计块 ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--kpi-min, 140px), 100%), 1fr));
  gap: var(--s-3);
}
.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--s-4);
  border: 0;
  border-radius: var(--r-md);
  background: var(--fill);
  color: inherit;
  text-align: left;
}
.stat-tile--plain {
  padding: 0;
  border-radius: 0;
  background: none;
}
.hero .stat-tile--plain {
  align-items: center;
  text-align: center;
}
@media (min-width: 1024px) {
  .hero .stat-tile--plain {
    align-items: flex-start;
    text-align: left;
  }
}
.stat-tile--tap {
  cursor: pointer;
  transition:
    background-color var(--dur-2) var(--ease-out),
    transform var(--dur-1) var(--ease-out);
}
.stat-tile--tap:hover {
  background: var(--fill-hover);
}
.stat-tile--tap:active {
  transform: scale(0.98);
}
.stat-tile__label {
  color: var(--ink-2);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}
.stat-tile__value {
  font-size: var(--fs-title-2);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-title);
  overflow-wrap: normal;
}
.stat-tile--sm .stat-tile__value {
  font-size: var(--fs-title-3);
}
.stat-tile--lg .stat-tile__value {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
}
.stat-tile__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  color: var(--tone);
  font-size: var(--fs-sub);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}
.stat-tile__hint {
  color: var(--ink-3);
  font-size: var(--fs-cap);
  line-height: var(--lh-snug);
}
.stat-tile__slot {
  display: block;
  margin-top: var(--s-2);
}

/* ── 表单 ── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}
.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  color: var(--ink-2);
  font-size: var(--fs-sub);
  font-weight: var(--fw-semibold);
}
.field__optional {
  color: var(--ink-3);
  font-weight: var(--fw-regular);
}
.field__hint {
  color: var(--ink-2);
  font-size: var(--fs-sub);
}
.field__error {
  color: var(--neg);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
}
.input,
.select__control {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-md);
  background: var(--fill);
  color: var(--ink);
  /* 16px：低于这个字号 iOS 聚焦输入框时会自动放大页面 */
  font-size: calc(var(--fs-body) + 1px);
  line-height: var(--lh-snug);
  appearance: none;
  transition:
    background-color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.input::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
.input:hover,
.select__control:hover {
  background: var(--fill-hover);
}
.input:focus,
.select__control:focus {
  box-shadow: var(--focus-ring);
}
.input:disabled,
.select__control:disabled {
  opacity: 0.5;
}
.field.is-invalid :is(.input, .select__control) {
  box-shadow: inset 0 0 0 2px var(--neg);
}
.input--area {
  min-height: 88px;
  padding: var(--s-4);
  line-height: var(--lh-body);
  resize: none;
  field-sizing: content;
}
.input--date {
  font-variant-numeric: tabular-nums;
}
/* iOS 默认把日期值居中，和其它输入框对不齐 */
.input--date::-webkit-date-and-time-value {
  text-align: left;
}
.input--date::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
}
.select {
  position: relative;
  min-width: 0;
}
.select__control {
  padding-inline-end: calc(var(--s-4) + 28px);
  cursor: pointer;
  text-overflow: ellipsis;
}
.select__chevron {
  position: absolute;
  top: 50%;
  right: var(--s-4);
  color: var(--ink-2);
  pointer-events: none;
  transform: translateY(-50%);
}
.month-input {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: var(--s-2);
}
.input-wrap {
  position: relative;
}
.input-wrap .input {
  padding-inline-end: calc(var(--hit) + var(--s-2));
}
.input-wrap .icon-btn {
  position: absolute;
  top: 50%;
  right: var(--s-1);
  color: var(--ink-2);
  transform: translateY(-50%);
}
.input-wrap .icon-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.92);
}

.amount-input {
  --amount-scale: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.06em;
  max-width: 100%;
  padding: var(--s-4) 0;
  font-size: calc(var(--fs-hero) * var(--amount-scale));
  font-weight: var(--fw-bold);
  line-height: 1.1;
  letter-spacing: var(--track-hero);
  cursor: text;
  transition: font-size var(--dur-2) var(--ease-out);
}
.amount-input:is([data-len="7"], [data-len="8"]) {
  --amount-scale: 0.82;
}
.amount-input:is([data-len="9"], [data-len="10"]) {
  --amount-scale: 0.68;
}
.amount-input:is([data-len="11"], [data-len="12"]) {
  --amount-scale: 0.56;
}
.amount-input__sym {
  color: var(--ink-2);
  font-size: 0.6em;
  letter-spacing: var(--track-title);
}
/* 输入框宽度跟着内容走：::after 镜像同一串字撑开盒子，真正的 input 绝对定位盖在上面 */
.amount-input__field {
  position: relative;
  display: inline-block;
  min-width: 0.62em;
}
.amount-input__field::after {
  content: attr(data-mirror);
  visibility: hidden;
  white-space: pre;
}
.amount-input__control {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: inherit;
  caret-color: var(--accent);
}
.amount-input__control::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
/* 这么大的输入框，闪动的 accent 光标本身就是焦点指示 */
.amount-input__control:focus-visible {
  box-shadow: none;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.search-box__icon {
  position: absolute;
  left: 14px;
  color: var(--ink-2);
  pointer-events: none;
}
.search-box__control {
  width: 100%;
  height: var(--hit);
  padding: 0 var(--hit) 0 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--ink);
  font-size: calc(var(--fs-body) + 1px);
  appearance: none;
  transition: background-color var(--dur-2) var(--ease-out);
}
.search-box__control::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
.search-box__control::-webkit-search-cancel-button {
  display: none;
}
.search-box__control:hover {
  background: var(--fill-hover);
}
.search-box__clear {
  position: absolute;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
}
.search-box__clear::after {
  content: "";
  position: absolute;
  inset: -6px;
}
.search-box__clear:hover {
  background: var(--fill-hover);
  color: var(--ink);
}

/* ── 反馈与点缀 ── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-9) var(--s-5);
  text-align: center;
}
.empty--compact {
  padding: var(--s-6) var(--s-4);
}
.empty__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--s-2);
  border-radius: 50%;
  background: var(--fill);
  color: var(--ink-2);
}
.empty--compact .empty__icon {
  width: 48px;
  height: 48px;
}
.empty__title {
  font-size: var(--fs-title-3);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}
.empty__body {
  max-width: 30em;
  color: var(--ink-2);
}
.empty__action {
  margin-top: var(--s-3);
}

.banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--tone-soft);
}
.banner__icon {
  flex: none;
  color: var(--tone);
}
.banner__text {
  flex: 1;
  min-width: 0;
}
.banner__title {
  font-weight: var(--fw-semibold);
  line-height: var(--lh-snug);
}
.banner__body {
  color: var(--ink-2);
  font-size: var(--fs-sub);
}
.banner__title + .banner__body {
  margin-top: 2px;
}
.banner .btn,
.banner .icon-btn {
  flex: none;
  margin-inline-end: calc(var(--s-2) * -1);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 1px;
  color: var(--ink-3);
  font-size: var(--fs-cap);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.divider--labelled {
  padding-block: var(--s-2);
}
.divider__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.spinner {
  display: inline-block;
  flex: none;
  width: var(--spinner-size, 20px);
  height: var(--spinner-size, 20px);
  border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin calc(var(--dur-4) * 1.5) linear infinite;
}

.kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  background: var(--fill);
  color: var(--ink-2);
  font-family: inherit;
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  line-height: 1;
}

/* ── Sheet ── */
.sheet-root {
  position: fixed;
  top: var(--vv-top, 0px);
  left: 0;
  z-index: var(--z-sheet);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: var(--vv-height, 100dvh);
}
.sheet-root.is-closing {
  pointer-events: none;
}
.sheet-backdrop {
  position: absolute;
  inset: -100vh 0; /* 键盘把可视视口顶上去时，遮罩仍然盖满整屏 */
  background: var(--overlay);
  animation: fade-in var(--dur-3) var(--ease-out) backwards;
}
.is-closing .sheet-backdrop {
  animation: fade-out var(--dur-3) var(--ease-out) forwards;
}
.sheet {
  --on: var(--surface);
  --fill: var(--surface-2);
  --fill-hover: var(--surface-3);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100% - var(--s-6) - env(safe-area-inset-top));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transition: transform var(--dur-2) var(--ease-out);
  animation: sheet-up var(--dur-3) var(--ease-out) backwards;
}
.sheet:focus-visible {
  box-shadow: var(--shadow-pop);
}
.sheet.is-dragging {
  transition: none;
}
.is-closing .sheet {
  animation: sheet-down var(--dur-3) var(--ease-in-out) forwards;
}
@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}
.sheet__grabber {
  display: grid;
  flex: none;
  place-items: center;
  height: 20px;
  cursor: grab;
  touch-action: none;
}
.sheet__grabber::before {
  content: "";
  width: 36px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
}
.sheet__header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--hit);
  padding: 0 var(--s-4) var(--s-2) var(--s-5);
  touch-action: none;
}
.sheet__title {
  font-size: var(--fs-title-2);
  font-weight: var(--fw-bold);
}
.sheet__body {
  flex: 1;
  min-height: 0;
  padding: var(--s-2) var(--s-5) var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet__body:last-child {
  padding-bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
}
.sheet__text {
  color: var(--ink-2);
}
.sheet__footer {
  display: flex;
  flex: none;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-5) calc(var(--s-4) + env(safe-area-inset-bottom));
}
.sheet__footer > * {
  flex: 1;
  min-width: 0;
}
@media (min-width: 720px) {
  .sheet-root {
    align-items: center;
    padding: var(--s-6);
  }
  .sheet {
    --sheet-w: 480px;
    width: min(100%, var(--sheet-w));
    max-height: min(100%, 780px);
    border-radius: var(--r-xl);
    animation-name: sheet-pop;
  }
  .sheet--sm {
    --sheet-w: 400px;
  }
  .sheet--lg {
    --sheet-w: 640px;
  }
  .is-closing .sheet {
    animation-name: sheet-pop-out;
  }
  .sheet__grabber {
    display: none;
  }
  .sheet__header {
    padding-top: var(--s-5);
    touch-action: auto;
  }
  .sheet__footer {
    padding-bottom: var(--s-5);
  }
}
@keyframes sheet-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}
@keyframes sheet-pop-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ── Toast ── */
.toast-stack {
  position: fixed;
  right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-4));
  left: 0;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding-inline: var(--gutter);
  pointer-events: none;
}
@media (min-width: 1024px) {
  .toast-stack {
    bottom: var(--s-7);
    left: var(--nav-w);
  }
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: min(100%, 440px);
  min-height: 48px;
  padding: var(--s-2) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--ink);
  box-shadow: var(--shadow-pop);
  color: var(--ink-inverse);
  font-size: var(--fs-sub);
  font-weight: var(--fw-medium);
  line-height: var(--lh-snug);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-spring) backwards;
}
.toast:has(.toast__action) {
  padding-inline-end: var(--s-2);
}
.toast.is-leaving {
  animation: toast-out var(--dur-2) var(--ease-out) forwards;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
}
@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
.toast__icon {
  display: inline-flex;
  flex: none;
}
.toast__message {
  min-width: 0;
}
.toast__action {
  position: relative;
  flex: none;
  min-height: 32px;
  margin-inline-start: var(--s-2);
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, currentColor 16%, transparent);
  color: inherit;
  font-weight: var(--fw-bold);
}
.toast__action::after {
  content: "";
  position: absolute;
  inset: -8px -4px;
}
.toast__action:hover {
  background: color-mix(in srgb, currentColor 26%, transparent);
}
