/* ==========================================================================
   家庭账本 · 设计系统
   基调：清新、简约、高级
   做法：靠层次、留白与材质取胜；颜色稀缺而准确；只有一处「英雄时刻」
   ========================================================================== */

:root {
  color-scheme: light;

  /* 底色与层次：冷调极浅，带一点强调色的色相 */
  --bg: #f1f5f5;
  --surface: #ffffff;
  --surface-2: #f6f9f9;
  --surface-3: #eef3f3;

  /* 文字：带一点青绿倾向的近黑，比纯黑透气 */
  --text: #14201e;
  --text-soft: #4a5b58;
  --text-muted: #647572; /* 白底 4.9:1，用于正文级小字 */
  --text-faint: #7e8f8c; /* 白底 3.4:1，只用于图标与装饰 */

  /* 分隔线 */
  --line: #e6ecec;
  --line-strong: #d5e0df;

  /* 强调色：玉青。白底对比度 5.0:1，达到正文标准 */
  --accent: #0a7e68;
  --accent-deep: #075d4d;
  --accent-soft: #e2f2ee;
  --accent-line: #b5dbd1;

  /* 金额语义：支出保持中性，只让收入带色 */
  --expense: #14201e;
  --income: #0a7e68;

  --danger: #c0392b;
  --danger-soft: #fbeceb;
  --warning: #a86a10;

  /* 强调卡专用：浅玉青底、深青字，与白卡同一行但更醒目 */
  --lead-bg-1: #eef6f3;
  --lead-bg-2: #dfeee8;
  --lead-label: #3d6a5f;
  --lead-ink: #0a5c4d;
  --lead-up: #b34536;
  --lead-down: #0a6b59;

  /* 字形 */
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, -apple-system,
    "Segoe UI", sans-serif;

  /* 间距 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 28px;
  --s7: 40px;
  --s8: 56px;

  /* 圆角 */
  --radius: 10px;
  --radius-card: 18px;
  --radius-full: 999px;

  /* 阴影：大范围低透明度，制造面与面的层次 */
  --shadow-xs: 0 1px 2px rgba(20, 32, 30, 0.05);
  --shadow-sm: 0 1px 2px rgba(20, 32, 30, 0.04), 0 10px 24px -18px rgba(20, 32, 30, 0.28);
  --shadow-md: 0 2px 6px rgba(20, 32, 30, 0.05), 0 22px 44px -26px rgba(20, 32, 30, 0.3);
  --shadow-float: 0 6px 16px rgba(20, 32, 30, 0.1), 0 40px 80px -40px rgba(20, 32, 30, 0.45);

  --ring: 0 0 0 3px rgba(10, 126, 104, 0.16);

  --nav: 224px;
  --ease-out: cubic-bezier(0.16, 0.84, 0.34, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

/* ---------- 文字工具 ---------- */

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--text-muted);
}

.serif {
  font-family: var(--serif);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   外壳
   ========================================================================== */

.app {
  display: flex;
  min-height: 100vh;
}

.nav {
  width: var(--nav);
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--s6) var(--s4) var(--s5);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.nav-brand {
  padding: 0 var(--s3) var(--s7);
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.1em;
  color: var(--text);
}

.nav-brand small {
  display: block;
  margin-top: var(--s2);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--text-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-soft);
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--text-faint);
  transition: color 0.16s var(--ease-out);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 500;
}

.nav-item.is-active svg {
  color: var(--accent);
}

.nav-foot {
  margin-top: auto;
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.nav-status {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3) var(--s3);
  font-size: 11.5px;
  color: var(--text-muted);
}

.nav-status::before,
.topbar-status::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.nav-status.is-pending::before,
.topbar-status.is-pending::before {
  background: var(--warning);
}

.nav-status.is-off::before,
.topbar-status.is-off::before {
  background: var(--text-faint);
}

.nav-action {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 9px var(--s3);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text-soft);
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out);
}

.nav-action svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--text-faint);
}

.nav-action:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-action.is-on {
  color: var(--accent-deep);
  background: var(--accent-soft);
}

.nav-action.is-on svg {
  color: var(--accent);
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--s7) var(--s8) var(--s8);
  max-width: 1120px;
}

/* ---------- 页头 ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.page-title {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.page-sub {
  margin-top: var(--s2);
  font-size: 12.5px;
  color: var(--text-muted);
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
}

/* ---------- 区块卡 ---------- */

.section {
  margin-top: var(--s5);
  padding: var(--s6);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
}

.section-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text);
}

.section-meta {
  font-size: 12px;
  color: var(--text-muted);
}

a.section-meta:hover {
  color: var(--accent);
}

/* 可折叠的区块标题：流水页的统计 */
.section-head.is-toggle {
  cursor: pointer;
}

.section-head.is-toggle .section-title::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 8px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(-45deg) translateY(-2px);
  transition: transform 0.16s var(--ease-out);
}

.section-head.is-toggle.is-open .section-title::after {
  transform: rotate(45deg) translateY(-1px);
}

.stats-dims {
  margin-bottom: var(--s4);
}

.label {
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

/* ==========================================================================
   按钮
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out),
    border-color 0.16s var(--ease-out), transform 0.12s var(--ease-out);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: #22332f;
}

.btn-ghost {
  border-color: var(--line-strong);
  color: var(--text-soft);
  background: var(--surface);
}

.btn-ghost:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.btn-quiet {
  padding: 6px 8px;
  color: var(--text-muted);
  border-radius: 8px;
}

.btn-quiet:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   表单
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.field-label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px var(--s3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--text-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.6;
}

.select {
  appearance: none;
  border-radius: var(--radius);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

.input.num,
.select.num {
  font-variant-numeric: tabular-nums;
}

.input-amount {
  padding: 10px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.input-amount:hover,
.input-amount:focus {
  border: none;
  box-shadow: none;
}

.input-amount:focus {
  color: var(--accent-deep);
}

.field-error {
  font-size: 12px;
  color: var(--danger);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s5);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s5);
}

.checkline {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
}

.checkline input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ==========================================================================
   分段控件
   ========================================================================== */

.segmented {
  display: inline-flex;
  gap: var(--s1);
  padding: var(--s1);
  background: var(--surface-2);
  border-radius: var(--radius-full);
}

.section-head .segmented {
  background: var(--surface-2);
}

.seg {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.16s var(--ease-out), color 0.16s var(--ease-out),
    box-shadow 0.16s var(--ease-out);
}

.seg:hover {
  color: var(--text);
}

.seg.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}

/* 报表页头用的是横向并排的区间按钮 */
.page-head-actions .seg {
  padding: 7px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.page-head-actions .seg.is-active {
  background: var(--text);
  color: var(--surface);
}

/* ==========================================================================
   英雄卡与指标
   ========================================================================== */

/* 指标卡：所有指标等分一行，首张为深色强调卡 */
.stat-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--s4);
  margin-top: var(--s6);
}

.stat-card {
  display: flex;
  flex-direction: column;
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.stat-card.is-lead {
  background: linear-gradient(135deg, var(--lead-bg-1) 0%, var(--lead-bg-2) 100%);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px rgba(10, 126, 104, 0.12);
}

.stat-card-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-card.is-lead .stat-card-label {
  color: var(--lead-label);
}

.stat-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}

.stat-card-note {
  font-size: 11.5px;
  color: var(--lead-label);
  white-space: nowrap;
}

.stat-card-value {
  margin-top: 4px;
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card-value.is-lead {
  font-size: 25px;
  color: var(--lead-ink);
}

/* 夫妻两人共用一张卡：各自一行，名字在左、金额在右 */
.stat-pair {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.stat-pair-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
}

.stat-pair-name {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-pair-amount {
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

/* 强调卡上的环比：支出走高用暖色，回落用玉青 */
.metric-delta {
  margin-top: 4px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--lead-label);
}

.metric-delta.is-up {
  color: var(--lead-up);
}

.metric-delta.is-down {
  color: var(--lead-down);
}

/* 强调卡底部一行：左边环比、右边近 6 个月走势，不额外占高度 */
.stat-lead-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
  margin-top: 4px;
}

.stat-lead-foot .metric-delta {
  margin-top: 0;
}

/* 迷你趋势条：最后一根是当前月份，用深色顶出来 */
.trend {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex: none;
  width: 72px;
  height: 24px;
}

.trend-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 2px;
  background: var(--accent-line);
}

.trend-bar.is-current {
  background: var(--lead-ink);
}

.locked-value {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  letter-spacing: 0.14em;
  color: var(--text-faint);
}

.locked-value svg {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   构成条
   ========================================================================== */

.bars {
  display: flex;
  flex-direction: column;
}

.bar-row {
  display: grid;
  grid-template-columns: 104px 1fr 112px;
  align-items: center;
  gap: var(--s4);
  padding: 9px var(--s2);
  margin: 0 calc(var(--s2) * -1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.16s var(--ease-out);
}

.bar-row:hover {
  background: var(--surface-2);
}

/* 统计下钻：点开某一行看它包含的流水 */
.bar-row.is-group .bar-name::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 7px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(-45deg) translateY(-2px);
  transition: transform 0.16s var(--ease-out);
}

.bar-row.is-open {
  background: var(--surface-2);
}

.bar-row.is-open .bar-name::after {
  transform: rotate(45deg) translateY(-1px);
}

.bar-detail {
  display: none;
  padding: 0 var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
}

.bar-detail.is-open {
  display: block;
}

.bar-detail-head {
  padding: var(--s2) 0 var(--s1);
  font-size: 11.5px;
  color: var(--text-faint);
}

.bar-detail .rows {
  padding-bottom: var(--s1);
}

.bar-name {
  font-size: 13px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-line);
  transform-origin: left center;
  animation: barIn 0.72s var(--ease-out) both;
  transition: background 0.16s var(--ease-out);
}

.bar-row:hover .bar-fill,
.bar-row.is-active .bar-fill {
  background: var(--accent);
}

.bar-value {
  text-align: right;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.bar-share {
  margin-left: var(--s2);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ==========================================================================
   交叉表：行是项目，列是各支付方
   ========================================================================== */

.cross {
  overflow-x: auto;
}

.cross .cross-head,
.cross .cross-row,
.cross .cross-foot {
  display: grid;
  grid-template-columns:
    minmax(96px, 1.3fr) repeat(var(--cross-cols, 1), minmax(78px, 1fr)) minmax(88px, auto);
  align-items: center;
  gap: var(--s3);
  min-width: 360px;
}

.cross .cross-head {
  padding: 0 var(--s2) var(--s2);
  border-bottom: 1px solid var(--line-strong);
  font-size: 11.5px;
  color: var(--text-muted);
}

.cross .cross-row {
  padding: 9px var(--s2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.16s var(--ease-out);
}

.cross .cross-row:hover,
.cross .cross-row.is-open {
  background: var(--surface-2);
}

.cross .cross-foot {
  padding: var(--s2);
  border-top: 1px solid var(--line-strong);
}

.cross .cross-foot .cross-name {
  color: var(--text-muted);
}

.cross-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cross .cross-row.is-group .cross-name::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 7px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(-45deg) translateY(-2px);
  transition: transform 0.16s var(--ease-out);
}

.cross .cross-row.is-open .cross-name::after {
  transform: rotate(45deg) translateY(-1px);
}

.cross-cell {
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}

.cross-cell.is-total {
  font-weight: 500;
  color: var(--text);
}

.cross-cell.is-empty {
  color: var(--text-faint);
}

/* ==========================================================================
   列表
   ========================================================================== */

.rows {
  display: flex;
  flex-direction: column;
}

.row {
  display: grid;
  grid-template-columns: 64px minmax(120px, 1.1fr) minmax(0, 1.6fr) 152px;
  align-items: center;
  gap: var(--s4);
  min-height: 52px;
  padding: var(--s2) var(--s2);
  margin: 0 calc(var(--s2) * -1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.16s var(--ease-out);
}

.row:hover {
  background: var(--surface-2);
}

.row + .row {
  box-shadow: inset 0 1px 0 var(--line);
}

.row-main {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
}

.row-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* 明细行标签：支付方实心，消费对象浅底 */
.row-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11.5px;
  line-height: 1.6;
}

.row-tag.is-payer {
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

.row-tag .row-yen {
  margin-left: 2px;
  opacity: 0.9;
  font-weight: 400;
}

.row-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amount {
  text-align: right;
  font-size: 13.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.row-amount.is-expense {
  color: var(--expense);
}

.row-amount.is-income {
  color: var(--income);
}

.row-amount.is-neutral {
  color: var(--text-muted);
}

.row-tools {
  display: none;
  gap: var(--s1);
}

.row:hover .row-tools {
  display: flex;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--s5) 0 var(--s3);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--text-soft);
}

.day-head:first-child {
  padding-top: 0;
}

.day-head .num {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* 简单行：设置页、账户页、借贷已结清 */

.simple-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  min-height: 48px;
  padding: var(--s2);
  margin: 0 calc(var(--s2) * -1);
  border-radius: var(--radius);
  font-size: 13.5px;
  transition: background 0.16s var(--ease-out);
}

.simple-row + .simple-row {
  box-shadow: inset 0 1px 0 var(--line);
}

.simple-row.is-off {
  color: var(--text-muted);
}

.simple-row.is-clickable {
  cursor: pointer;
}

.simple-row.is-clickable:hover {
  background: var(--surface-2);
}

.simple-row.is-active {
  background: var(--accent-soft);
}

.row-name-wrap {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  min-width: 0;
}

.row-name-wrap.is-indent {
  padding-left: var(--s4);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: var(--s1);
  flex: none;
}

/* 设置页分类：一级折叠组，默认收起子分类 */
.cat-group + .cat-group,
.cat-group + .simple-row {
  box-shadow: inset 0 1px 0 var(--line);
}

.cat-group-head {
  cursor: pointer;
}

.cat-caret {
  flex: none;
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.16s var(--ease-out);
}

.cat-group.is-open .cat-caret {
  transform: rotate(90deg);
}

.cat-group-body {
  display: none;
}

.cat-group.is-open .cat-group-body {
  display: block;
}

.child-add {
  display: none;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s2) var(--s3) var(--s5);
}

.child-add.is-showing {
  display: flex;
}

.child-add .input {
  flex: 1;
}

/* ==========================================================================
   保险概览
   ========================================================================== */

.insurance-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

/* 列表卡片刻意做薄：只看名称、保额、单次缴费与状态，点开才展开全部信息 */
.insurance-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: var(--s3) var(--s4);
  font-family: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.16s var(--ease-out);
}

.insurance-card:hover {
  border-color: var(--accent-line);
}

.ins-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

.ins-name {
  min-width: 0;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ins-tags {
  display: flex;
  gap: var(--s2);
  flex: none;
}

/* 保额在左、缴费与状态在右，一行看完 */
.ins-mini {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  flex-wrap: wrap;
}

.ins-mini-coverage {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
}

.ins-mini-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
}

.ins-mini-pay {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
  white-space: nowrap;
}

.ins-mini-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.ins-mini-arrow {
  display: inline-flex;
  margin-left: auto;
  color: var(--text-faint);
}

/* 详情弹窗里的标签行与说明块 */
.ins-detail-tags {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.ins-detail-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ins-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2) var(--s4);
}

.ins-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ins-label {
  font-size: 11.5px;
  color: var(--text-muted);
}

.ins-value {
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: break-word;
}

.ins-value.ins-detail {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text-soft);
}

/* 缴费状态徽标：交费中中性、已交清玉青、已豁免暖色 */
.ins-pay-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
}

.ins-pay-status.is-done {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.ins-pay-status.is-exempt {
  background: #f8f0dd;
  color: var(--warning);
}

/* 即将缴费：马上要花钱，用最扎眼的暖色把它顶出来 */
.ins-pay-status.is-soon {
  background: var(--danger-soft);
  color: var(--danger);
}

/* 保险到期提醒弹窗 */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3) 0;
}

.reminder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border-radius: var(--radius);
}

.reminder-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.reminder-name {
  font-size: 13.5px;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reminder-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* 保险概览：缴费记录入口（总次数 + 累计）与明细弹窗 */
.ins-pay-link {
  display: inline-flex;
  align-items: baseline;
  gap: var(--s2);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.16s var(--ease-out);
}

.ins-pay-link:hover {
  background: var(--accent-line);
}

.ins-pay-sum {
  font-size: 11.5px;
  font-weight: 400;
  opacity: 0.82;
}

.pay-record-list {
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow-y: auto;
  padding: var(--s2) 0;
}

.pay-record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  font-size: 13px;
}

.pay-record-row:nth-child(odd) {
  background: var(--surface-2);
}

.pay-record-date {
  color: var(--text-soft);
}

.pay-record-amount {
  color: var(--text);
}

.pay-record-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* 保险概览：维度 tab 下方的值筛选 tab */
.filter-tabs {
  margin-top: var(--s4);
}

/* 保险概览：维度 tab 与值筛选 tab 分两行，维度在上、值筛选在下 */
.ins-tabs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s5);
  margin-top: var(--s5);
}

.ins-tabs .range-tabs,
.ins-tabs .filter-tabs {
  margin-top: 0;
  max-width: 100%;
}

.ins-tabs .filter-tabs {
  flex-wrap: wrap;
  gap: var(--s2);
}

.ins-tabs + .ins-table,
.ins-tabs + .insurance-list {
  margin-top: var(--s5);
}

/* 值筛选 tab 的数字角标 */
.seg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 5px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.seg.is-active .seg-count {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

/* 保险概览：表格视图 */
.ins-table {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.ins-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 760px;
}

.ins-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.ins-table td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  white-space: nowrap;
}

.ins-table tbody tr:last-child td {
  border-bottom: none;
}

.ins-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.ins-table .ins-note {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   筛选
   ========================================================================== */

.range-tabs {
  margin-top: var(--s5);
}

.payer-tabs {
  margin-top: var(--s3);
}

.payer-tabs .segmented {
  align-items: center;
}

.payer-tabs-label {
  margin: 0 var(--s2);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.payer-tabs .seg.is-active {
  font-weight: 600;
}

.range-tabs + .filters,
.payer-tabs + .filters {
  margin-top: var(--s4);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4) var(--s5);
  margin-top: var(--s5);
  padding: var(--s4) var(--s5);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.filter {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.filter-label {
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.filter .select,
.filter .input {
  width: auto;
  min-width: 88px;
  padding: 6px 26px 6px 10px;
  font-size: 12.5px;
  border-color: transparent;
  background-color: var(--surface-2);
}

.filter .input {
  padding-right: 10px;
}

.filter .select:hover,
.filter .input:hover {
  border-color: var(--line-strong);
}

.filter .input[type="date"] {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   分栏与借贷
   ========================================================================== */

.panel {
  padding-top: var(--s4);
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s7);
}

.debt-item {
  padding: var(--s4) var(--s2);
  margin: 0 calc(var(--s2) * -1);
  border-radius: var(--radius);
  transition: background 0.16s var(--ease-out);
}

.debt-item + .debt-item {
  box-shadow: inset 0 1px 0 var(--line);
}

.debt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}

.debt-name {
  font-size: 14px;
  color: var(--text);
}

.debt-track {
  margin: var(--s3) 0;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.debt-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 0.5s var(--ease-out);
}

.debt-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  font-size: 12px;
  color: var(--text-muted);
}

.debt-meta .num {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   保险统计弹窗
   ========================================================================== */

/* 统计弹窗比常规弹窗宽，用来容纳图表 */
.modal-wide {
  width: min(780px, 100%);
  max-height: calc(100vh - 2 * var(--s5));
  overflow-y: auto;
}

.ins-stats {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* 每块统计独立成卡，靠底色与描边和白底弹窗拉开层次 */
.ins-card {
  padding: var(--s4) var(--s5) var(--s5);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}

.ins-card-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.ins-card-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex: none;
}

.ins-card-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

.ins-card-sub {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* 顶部关键指标：一张卡里分成几格 */
.ins-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: var(--s4) var(--s5);
}

.ins-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.ins-kpi-value {
  margin-top: 5px;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.2;
  color: var(--text);
}

/* 横向条形图：条长按组内最大值归一 */
.ins-chart {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.ins-bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: 5px;
  font-size: 13px;
}

.ins-bar-label {
  color: var(--text);
}

.ins-bar-value {
  color: var(--text-soft);
}

.ins-bar-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.ins-bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transform-origin: left center;
  animation: barIn 0.6s var(--ease-out) both;
}

/* 单条堆叠条：各险种按份数占比 */
.ins-stack {
  display: flex;
  height: 14px;
  margin-bottom: var(--s4);
  border-radius: var(--radius-full);
  overflow: hidden;
  background: var(--surface-3);
}

.ins-stack-seg {
  display: block;
  height: 100%;
}

/* 竖状柱形图：少量对象之间比高低 */
.ins-columns {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
}

.ins-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ins-col-value {
  font-size: 12.5px;
  color: var(--text-soft);
}

.ins-col-track {
  width: 100%;
  height: 88px;
  display: flex;
  align-items: flex-end;
  border-radius: var(--radius);
  background: var(--surface-3);
  overflow: hidden;
}

.ins-col-fill {
  display: block;
  width: 100%;
  background: var(--accent);
  transform-origin: bottom center;
  animation: colIn 0.6s var(--ease-out) both;
}

.ins-col-label {
  max-width: 100%;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes colIn {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

/* 缴费状态：环形图 + 图例 */
.ins-status-row {
  display: flex;
  align-items: center;
  gap: var(--s5);
}

.ins-donut {
  width: 132px;
  height: 132px;
  flex: none;
}

/* SVG 内的字号以 viewBox 单位计（42 单位约合 132px） */
.ins-donut-num {
  font-family: var(--serif);
  font-size: 6.4px;
  fill: var(--text);
}

.ins-donut-cap {
  font-size: 3.4px;
  fill: var(--text-muted);
}

.ins-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.ins-legend-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
}

.ins-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  flex: none;
}

.ins-legend-label {
  color: var(--text-soft);
}

.ins-legend-value {
  margin-left: auto;
  color: var(--text);
}

/* ==========================================================================
   遮罩层
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #101b1a;
  opacity: 0;
  transition: opacity 0.24s var(--ease-out);
}

.scrim.is-open {
  opacity: 0.34;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: 444px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-card) 0 0 var(--radius-card);
  box-shadow: var(--shadow-float);
  transform: translateX(16px);
  opacity: 0;
  transition: transform 0.28s var(--ease-out), opacity 0.2s var(--ease-out);
}

.drawer.is-open {
  transform: none;
  opacity: 1;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s5) var(--s6) var(--s4);
  border-bottom: 1px solid var(--line);
}

.drawer-title {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.08em;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--line);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding-bottom: var(--s5);
  border-bottom: 1px solid var(--line);
}

.field-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* 弹层 */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
}

.modal {
  position: relative;
  z-index: 61;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s6);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-float);
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  animation: modalIn 0.26s var(--ease-out) forwards;
}

.modal-title {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: calc(var(--s2) * -1) 0 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s2);
}

.modal-actions-split {
  justify-content: space-between;
  align-items: center;
}

.delete-area {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.delete-area .btn-quiet {
  color: var(--danger);
}

.delete-area .btn-quiet:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.delete-area .field-hint {
  max-width: 132px;
  line-height: 1.35;
  font-size: 11.5px;
}

.lock-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s5);
  padding: var(--s8) 0;
  color: var(--text-faint);
}

.lock-panel svg {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   解锁页
   ========================================================================== */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s7);
  padding: var(--s6) var(--s5);
  overflow-y: auto;
  background: radial-gradient(120% 80% at 50% 0%, #eaf3f1 0%, var(--bg) 55%);
}

.login-brand {
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--text);
}

.login-form {
  width: 288px;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s6);
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
}

.login-form .input {
  text-align: center;
  letter-spacing: 0.34em;
  font-size: 16px;
  padding: 12px var(--s3);
}

.login-form .btn {
  width: 100%;
  padding: 12px var(--s4);
}

.offline-note {
  max-width: 260px;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
}

.shake {
  animation: shake 0.32s var(--ease-out);
}

/* ==========================================================================
   零碎
   ========================================================================== */

.empty {
  padding: var(--s8) 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s7);
  z-index: 80;
  padding: 10px var(--s4);
  border-radius: var(--radius-full);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.22s var(--ease-out), transform 0.22s var(--ease-out);
}

.toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: var(--danger);
}

.inline-form {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-soft);
}

.tag.is-off {
  color: var(--text-muted);
}

.tag button {
  line-height: 1;
  color: var(--text-faint);
}

.tag button:hover {
  color: var(--danger);
}

/* ==========================================================================
   动效
   ========================================================================== */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes barIn {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes modalIn {
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  45% {
    transform: translateX(5px);
  }
  70% {
    transform: translateX(-3px);
  }
}

/* 页面内容按顺序淡入，形成节奏而不是硬切 */
.main > * {
  animation: rise 0.34s var(--ease-out) both;
}

.main > *:nth-child(2) {
  animation-delay: 0.06s;
}

.main > *:nth-child(3) {
  animation-delay: 0.12s;
}

.main > *:nth-child(4) {
  animation-delay: 0.17s;
}

.main > *:nth-child(5) {
  animation-delay: 0.21s;
}

.main > *:nth-child(n + 6) {
  animation-delay: 0.25s;
}

/* ==========================================================================
   手机端：顶部条与悬浮按钮
   ========================================================================== */

.topbar,
.fab {
  display: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--s4) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 0.1em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar .nav-action {
  padding: 8px 2px;
  font-size: 12px;
  border-radius: var(--radius);
}

.topbar .nav-action svg {
  width: 16px;
  height: 16px;
}

.topbar .nav-action.is-on {
  background: none;
}

.topbar [data-action="install"] span {
  display: none;
}

.fab {
  position: fixed;
  right: var(--s5);
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 35;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-float);
  transition: transform 0.18s var(--ease-out);
}

.fab:active {
  transform: scale(0.94);
}

.fab.is-visible {
  display: none;
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   平板
   ========================================================================== */

@media (max-width: 1024px) {
  .app {
    flex-direction: column;
  }

  .nav {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: var(--s5);
    padding: var(--s4) var(--s6);
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .nav-brand {
    padding: 0;
    font-size: 17px;
  }

  .nav-brand small {
    display: none;
  }

  .nav-list {
    flex-direction: row;
    gap: var(--s1);
  }

  .nav-item {
    padding: 8px var(--s3);
  }

  .nav-foot {
    margin: 0 0 0 auto;
    padding: 0;
    border: none;
    flex-direction: row;
    align-items: center;
    gap: var(--s1);
  }

  .nav-status {
    padding: 0 var(--s3) 0 0;
  }

  .main {
    padding: var(--s6) var(--s6) var(--s8);
  }

  .split {
    grid-template-columns: 1fr;
    gap: var(--s6);
  }
}

/* ==========================================================================
   手机
   ========================================================================== */

@media (max-width: 640px) {
  .app {
    padding-top: calc(52px + env(safe-area-inset-top));
  }

  .topbar {
    display: flex;
  }

  .main {
    padding: var(--s5) var(--s4) calc(96px + env(safe-area-inset-bottom));
  }

  /* 导航改为底部标签栏 */
  .nav {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0 0 env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    border-bottom: none;
    background: var(--surface);
  }

  .nav-brand,
  .nav-foot {
    display: none;
  }

  .nav-list {
    flex: 1;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0 var(--s1);
  }

  .nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 2px 8px;
    border-radius: 0;
    font-size: 10.5px;
    font-weight: 400;
  }

  .nav-item.is-active {
    background: none;
    color: var(--accent-deep);
    font-weight: 500;
  }

  .nav-item.is-active svg {
    color: var(--accent);
  }

  .fab.is-visible {
    display: flex;
  }

  /* 表单控件提到 16px，避免 iOS 聚焦时自动放大 */
  .input,
  .select,
  .textarea {
    font-size: 16px;
  }

  .filter .select,
  .filter .input {
    font-size: 16px;
    min-width: 76px;
  }

  .input-amount {
    font-size: 30px;
  }

  .btn {
    padding: 11px 16px;
  }

  .page-head {
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--s5);
  }

  .page-title {
    font-size: 22px;
  }

  .page-head-actions {
    flex-wrap: wrap;
  }

  .section {
    padding: var(--s5);
    border-radius: 14px;
  }

  /* 手机上换成两列，卡片多于两张时不至于挤成一条 */
  .stat-grid {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s3);
    margin-top: var(--s5);
  }

  .stat-card {
    padding: var(--s3) var(--s4);
  }

  .stat-card-value {
    font-size: 17px;
  }

  .stat-card-value.is-lead {
    font-size: 22px;
  }

  /* 张数为奇数时，末一张占满整行，不留缺口 */
  .stat-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .metric-cell + .metric-cell {
    padding-left: 0;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--s4);
    padding: var(--s3) var(--s4);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar {
    display: none;
  }

  .filter {
    flex: none;
  }

  .segmented {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .segmented::-webkit-scrollbar {
    display: none;
  }

  /* 流水行改为两行式 */
  .row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--s3);
    min-height: 0;
    padding: var(--s3) var(--s2);
  }

  .row + .row {
    box-shadow: none;
  }

  .rows .row:not(:last-child) {
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .row > span:nth-child(1) {
    flex: none;
    width: 38px;
  }

  .row > span:nth-child(2) {
    flex: 1 1 0;
    min-width: 0;
  }

  .row > span:nth-child(3) {
    flex: 0 0 100%;
    order: 5;
    padding-left: 38px;
  }

  .row > span:nth-child(4) {
    flex: none;
  }

  /* 构成条改为名称与数字一行、进度条独占一行 */
  .bar-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name value" "track track";
    gap: var(--s2);
    padding: var(--s3) 0;
    margin: 0;
  }

  .bar-name {
    grid-area: name;
  }

  .bar-value {
    grid-area: value;
  }

  .bar-track {
    grid-area: track;
    height: 6px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-wrap: wrap;
    gap: var(--s2);
  }

  .inline-form .input {
    flex: 1 1 100%;
  }

  .inline-form .select {
    flex: 1 1 auto;
  }

  .drawer {
    width: 100%;
    border-radius: 0;
  }

  .drawer-head {
    padding: var(--s4) var(--s5) var(--s3);
  }

  .drawer-body {
    padding: var(--s5);
    gap: var(--s4);
  }

  .drawer-foot {
    padding: var(--s3) var(--s5) calc(var(--s3) + env(safe-area-inset-bottom));
  }

  .modal {
    width: 100%;
    max-width: 420px;
    padding: var(--s5);
  }

  .toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

/* ==========================================================================
   减少动态效果
   ========================================================================== */

/* ==========================================================================
   移动端 App 化
   ========================================================================== */

/* 抽屉顶部的抓握条，桌面隐藏 */
.modal-grip {
  display: none;
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: var(--radius-full);
  background: var(--line-strong);
}

/* 侧栏里挂在主标签下面的次级入口 */
.nav-more {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin-top: var(--s2);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}

/* 云端登录页：记住的账号与「切换账号」入口 */
.login-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 0 var(--s1);
  font-size: 12.5px;
  color: var(--text-muted);
}

.login-switch {
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}

/* 「我的」的按钮列表 */
.menu {
  margin-top: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.menu + .menu {
  margin-top: var(--s3);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 46px;
  padding: var(--s3) var(--s4);
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background 0.16s var(--ease-out);
}

.menu-item + .menu-item {
  border-top: 1px solid var(--line);
}

.menu-item:hover {
  background: var(--surface-2);
}

.menu-icon {
  display: inline-flex;
  flex: none;
  color: var(--text-muted);
}

.menu-label {
  flex: 1;
  min-width: 0;
}

.menu-value {
  flex: none;
  max-width: 56%;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-arrow {
  flex: none;
  color: var(--text-faint);
}

.menu-item.is-danger .menu-label,
.menu-item.is-danger .menu-icon {
  color: var(--danger);
}

/* 平板：次级入口并到同一行 */
@media (max-width: 1024px) {
  .nav-more {
    display: contents;
  }
}

/* 手机：弹窗改为底部抽屉，标签栏固定五项 */
@media (max-width: 640px) {
  .modal-wrap {
    align-items: flex-end;
    padding: 0;
  }

  .modal,
  .modal-wide {
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: var(--s6) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    opacity: 1;
    transform: translateY(100%);
    animation: sheetIn 0.28s var(--ease-out) forwards;
  }

  .modal-grip {
    display: block;
  }

  .nav-more {
    display: none;
  }

  .menu-item {
    min-height: 52px;
    padding: var(--s3) var(--s4);
  }

  /* 统计弹窗在抽屉里收紧尺寸 */
  .ins-stats {
    gap: var(--s3);
  }

  /* 手机上卡片变窄，趋势条跟着收 */
  .trend {
    width: 56px;
    height: 22px;
  }

  .ins-card {
    padding: var(--s4);
  }

  .ins-col-track {
    height: 72px;
  }

  .ins-donut {
    width: 108px;
    height: 108px;
  }
}

@keyframes sheetIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

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