/* ============================================================================
   Daily · 新板块样式（延续 app.css 的软 3D / 手账质感，字体完全沿用系统字体）
   覆盖：类别图标、预算首页、日历记账、当日计算器、固定支出、未归档资金、
        资产总预览、债务环形进度、现金流四块、复盘三档
   ========================================================================== */

/* ------------------------------------------------------------ 全局紧凑排版
   目标：手机上每屏看到更多内容。缩小内边距与圆角，阴影只保留在交互元素上。 */

/* 关掉双击放大：保留正常滚动，禁止双击缩放 */
html,
body {
  touch-action: manipulation;
}

button,
a,
label,
select,
input,
.tab,
.seg-btn,
.btn,
.link-btn,
.table td {
  touch-action: manipulation;
}

input,
textarea {
  touch-action: auto;
}

.app {
  padding: 14px 14px 96px;
}

.card {
  border-radius: 14px;
}

.card-head {
  padding: 13px 15px 0;
}

.card-head h3 {
  font-size: 14.5px;
}

.card-head p {
  margin-top: 3px;
  font-size: 11px;
}

.card-body {
  padding: 12px 15px 15px;
}

.page-head {
  margin-bottom: 8px;
}

.page-head h2 {
  font-size: 18px;
}

.page-head p {
  font-size: 11.5px;
}

.stat {
  padding: 10px 12px;
}

.stat-value {
  margin-top: 3px;
  font-size: 16px;
}

.stat-sub {
  margin-top: 3px;
  font-size: 10.5px;
}

.tabbar {
  margin: 10px 0 12px;
  padding: 4px;
}

.tab {
  min-width: 62px;
  padding: 8px 10px;
  font-size: 12.5px;
}

/* 一行式数字条（替代原来的多张统计卡） */

/* 表格统一收紧：一屏能多看几行 */
.table {
  font-size: 12px;
}

.table th {
  padding: 6px 8px;
}

.table td {
  padding: 7px 8px;
}

.table.compact th {
  padding: 5px 7px;
}

.table.compact td {
  padding: 6px 7px;
}

.table tbody tr:hover {
  box-shadow: none;
  background: rgba(255, 255, 255, 0.45);
}

.table tr.row-muted td {
  color: var(--text-light);
}

.table tr.row-hit td {
  background: rgba(79, 122, 94, 0.07);
}

/* 固定支出：三个小按钮一行 */
.fixed-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.fixed-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease);
}

.fixed-chip:hover {
  box-shadow: var(--shadow-out-hover);
}

.fixed-chip .fc-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.fixed-chip .fc-name {
  font-size: 10.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.fixed-chip .fc-amount {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fixed-chip .fc-count {
  margin-left: auto;
  font-size: 9.5px;
  color: var(--text-light);
  white-space: nowrap;
}

/* ------------------------------------------------------------ 记账网格
   横轴 = 生活支出类目，纵轴 = 日期；点格子记录当天的这一类支出。 */

.lg-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lg-body {
  width: 100%;
  max-width: 620px;
}

.lg-row {
  display: grid;
  /* 列数跟着类目数量走（支出 9 个 / 收入 7 个），始终铺满一屏 */
  grid-template-columns: 26px repeat(var(--cats, 9), minmax(0, 1fr));
  align-items: stretch;
  border-bottom: 1px solid rgba(150, 130, 106, 0.1);
}

.lg-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.22);
}

.lg-row.lg-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-base);
  border-bottom: 1px solid rgba(150, 130, 106, 0.32);
}

.lg-row.lg-foot {
  border-top: 1px solid rgba(150, 130, 106, 0.32);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.34);
  font-weight: 700;
}

.lg-cell,
.lg-date,
.lg-total {
  display: grid;
  place-items: center;
  position: relative;
  padding: 0 1px;
  min-height: 24px;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.lg-head .lg-cell,
.lg-head .lg-date,
.lg-head .lg-total,
.lg-foot .lg-cell,
.lg-foot .lg-date,
.lg-foot .lg-total {
  min-height: 26px;
  font-size: 9px;
  color: var(--text-secondary);
}

.lg-date {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-base);
  border: 0;
  border-right: 1px solid rgba(150, 130, 106, 0.2);
  font-family: inherit;
  font-size: 9.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.lg-row.lg-head .lg-date {
  z-index: 3;
}

.lg-cell {
  border: 0;
  border-right: 1px solid rgba(150, 130, 106, 0.1);
  background: none;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background 140ms var(--ease);
}

/* 金额较长时再收一号，保证九个类目都在一屏内 */
.lg-cell .lg-tiny {
  font-style: normal;
  font-size: 8px;
  letter-spacing: -0.2px;
}

/* 底部合计行：与前 3 个月平均相比，绿色=下降、红色=上升，颜色深度表示差距大小 */
.lg-foot .lg-delta {
  justify-self: stretch;
  margin: 0 1px;
  border-radius: 4px;
}

/* good = 绿色（支出下降 / 收入上升），bad = 红色 */
.lg-foot .lg-delta.good.lv1 {
  background: rgba(79, 122, 94, 0.16);
  color: #3f6a4d;
}

.lg-foot .lg-delta.good.lv2 {
  background: rgba(79, 122, 94, 0.28);
  color: #345c41;
}

.lg-foot .lg-delta.good.lv3 {
  background: rgba(79, 122, 94, 0.42);
  color: #2c5138;
}

.lg-foot .lg-delta.good.lv4 {
  background: rgba(79, 122, 94, 0.58);
  color: #ffffff;
}

.lg-foot .lg-delta.bad.lv1 {
  background: rgba(168, 85, 75, 0.16);
  color: #8f4a41;
}

.lg-foot .lg-delta.bad.lv2 {
  background: rgba(168, 85, 75, 0.28);
  color: #7d382f;
}

.lg-foot .lg-delta.bad.lv3 {
  background: rgba(168, 85, 75, 0.44);
  color: #ffffff;
}

.lg-foot .lg-delta.bad.lv4 {
  background: rgba(168, 85, 75, 0.62);
  color: #ffffff;
}

.lg-foot .lg-delta.flat {
  color: var(--text-primary);
}

.lg-cell.has {
  color: var(--text-primary);
  font-weight: 600;
  background: rgba(166, 123, 91, 0.1);
}

.lg-cell:active {
  background: rgba(166, 123, 91, 0.22);
}

.lg-row.is-today .lg-date {
  color: var(--theme-text);
  font-weight: 700;
  background: color-mix(in srgb, var(--theme-color) 16%, var(--bg-base));
}

/* 合计之前再重复一次类目名，拉到底部也看得清是哪一类 */
.lg-head2 {
  border-top: 1px solid rgba(150, 130, 106, 0.32);
}

/* 月度生活支出合计：直接作为表格最后一行 */
.lg-totalrow {
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.34);
}

.lg-totalrow .lg-total-label {
  grid-column: 2 / -4;
  align-self: center;
  padding-left: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  text-align: left;
}

.lg-totalrow .lg-total-value {
  grid-column: -4 / -1;
  align-self: center;
  padding-right: 4px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 每天一条记录的小圆点，提示这一天记过几笔 */
.lg-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--theme-color);
}

/* 手机端弹窗改成底部面板，避免系统键盘挡住输入框 */
@media (max-width: 860px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
  }

  .modal-head {
    padding: 16px 16px 0;
  }

  .modal-body {
    padding: 14px 16px 6px;
  }

  .modal-foot {
    padding: 12px 16px 16px;
  }
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow-in);
}

.stat-strip .ss-item {
  display: grid;
  gap: 1px;
  border: 0;
  padding: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
}

button.ss-item {
  cursor: pointer;
}

.stat-strip .ss-label {
  font-size: 10px;
  color: var(--text-light);
}

.stat-strip .ss-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-strip .ss-sub {
  font-style: normal;
  font-size: 9.5px;
  color: var(--text-light);
}

.stat-strip .ss-item.pos .ss-value {
  color: var(--positive);
}

.stat-strip .ss-item.neg .ss-value {
  color: var(--negative);
}

.stat-strip .ss-item.warn .ss-value {
  color: var(--warning);
}

/* 顶部信息条：手机上压成一行 */
@media (max-width: 860px) {
  .topbar {
    position: static;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    overflow: hidden;
  }

  .brand {
    min-width: 0;
    gap: 8px;
  }

  .brand strong {
    font-size: 12.5px;
  }

  .brand strong {
    display: none;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 9px;
    font-size: 13px;
  }

  .topbar-stats {
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
  }

  .topbar-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
  }

  .topbar-stat span {
    font-size: 10px;
  }

  .topbar-stat strong {
    font-size: 12px;
  }

  .topbar-actions {
    display: none;
  }

  /* 卡片头部：标题一行，操作按钮另起一行右对齐 */
  .card-head {
    flex-wrap: wrap;
  }

  .card-head .card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* 预算是首页，压缩到两行：数字 + 进度 */
  .budget-hero {
    padding: 12px 14px;
    gap: 8px;
  }

  .bh-top {
    flex-direction: column;
    gap: 3px;
  }

  .bh-amount {
    font-size: 21px;
  }

  .bh-state {
    align-self: flex-start;
  }

  .bh-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .bh-cell {
    padding: 7px 9px;
  }

  .bh-legend {
    font-size: 10px;
  }

  /* 结余条：一行放下 */
  .balance-strip {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
  }

  .balance-strip .bs-value {
    font-size: 16px;
  }

  .balance-strip .bs-facts {
    font-size: 10.5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
  }

  /* 三个数字时，最后一个占满整行，不留空位 */
  .stat-strip .ss-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

/* 保存状态在手机上只留一个小圆点 */
@media (max-width: 860px) {
  .brand-sub {
    font-size: 0;
  }

  .brand-sub::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
  }
}

/* ------------------------------------------------------------ 类别图标块 */

.icon-chip {
  --chip: #a89c8b;
  --chip-size: 38px;
  display: inline-grid;
  place-items: center;
  width: var(--chip-size);
  height: var(--chip-size);
  flex: none;
  border-radius: 50%;
  color: var(--chip);
  background: var(--bg-base);
  background: linear-gradient(
    158deg,
    color-mix(in srgb, var(--chip) 30%, #fff),
    color-mix(in srgb, var(--chip) 14%, var(--bg-base))
  );
  box-shadow: -2px -2px 5px rgba(255, 255, 255, 0.92), 3px 3px 7px rgba(150, 130, 106, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.icon-chip svg {
  display: block;
}

.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* ------------------------------------------------------------ 预算首页 */

.budget-hero {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 18px 20px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  background: linear-gradient(
    150deg,
    color-mix(in srgb, var(--tone-color) 14%, var(--bg-base)),
    color-mix(in srgb, var(--tone-color) 5%, var(--bg-base))
  );
  box-shadow: var(--shadow-out);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 140ms ease;
}

.budget-hero:hover {
  box-shadow: var(--shadow-out-hover);
}

.budget-hero:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.budget-hero.tone-lv0 {
  --tone-color: #a89c8b;
}

.budget-hero.tone-lv1 {
  --tone-color: #4f7a5e;
}

.budget-hero.tone-lv2 {
  --tone-color: #d3a12c;
}

.budget-hero.tone-lv3 {
  --tone-color: #d98040;
}

.budget-hero.tone-lv4 {
  --tone-color: #c0392b;
}

.bh-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.bh-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.bh-amount {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bh-amount em {
  font-size: 13px;
  font-style: normal;
  font-weight: 500;
  color: var(--text-light);
}

.bh-state {
  flex: none;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tone-color) 20%, transparent);
  color: color-mix(in srgb, var(--tone-color) 78%, #2f2a24);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.bh-bar {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
  overflow: hidden;
}

.bh-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone-color) 70%, #fff), var(--tone-color));
  transition: width 320ms var(--ease);
}

.bh-legend {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.bh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.bh-cell {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-in);
}

.bh-cell span {
  font-size: 11px;
  color: var(--text-light);
}

.bh-cell strong {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bh-foot {
  text-align: right;
  font-size: 11.5px;
  color: var(--theme-text);
}

/* 收入预期 */

.income-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.income-hero .ih-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--positive);
  font-variant-numeric: tabular-nums;
}

.income-hero .ih-sub {
  font-size: 12px;
  color: var(--text-light);
}

.mini-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.36);
  box-shadow: var(--shadow-in);
  font-size: 12.5px;
}

.mini-list .mini-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-list .mini-date {
  color: var(--text-light);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.mini-list strong {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.table-gap {
  margin-top: 14px;
}

/* ------------------------------------------------------------ 竖向柱状图 */

.col-chart {
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
  align-items: flex-end;
  gap: 4px;
  padding: 8px 0 0;
}

.col-item {
  display: grid;
  grid-template-rows: auto 76px auto auto;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}

.col-item .col-value {
  font-size: 7.5px;
  letter-spacing: -0.2px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.col-item .col-track {
  display: flex;
  align-items: flex-end;
  width: 100%;
  max-width: 20px;
  height: 100%;
  padding: 2px;
  position: relative;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

/* 零线模式：正数往上、负数往下 */
.col-item .col-track.signed {
  padding: 0;
  border-radius: 4px;
  background: rgba(150, 130, 106, 0.1);
  box-shadow: none;
}

.col-item .col-track.signed .col-zero {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(150, 130, 106, 0.55);
  z-index: 1;
}

.col-item .col-fill.abs {
  position: absolute;
  left: 12%;
  right: 12%;
  border-radius: 2px;
}

.col-item .col-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 999px;
  transition: height 320ms var(--ease);
}

/* 堆叠柱：一段一段表示支出构成 */
.col-item .col-fill.stacked {
  display: flex;
  flex-direction: column-reverse;
  border-radius: 4px;
  overflow: hidden;
  min-height: 0;
}

.col-item .col-fill.stacked .part {
  display: block;
  width: 100%;
}

/* 并排条（收入 vs 支出） */
.col-item .col-fill.grouped {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.col-item .col-fill.grouped .gbar {
  flex: 1;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
}

/* 比例图图例里的第二行小字（月均） */
.donut-legend .donut-sub {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: var(--text-light);
}

.col-item .col-label {
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.col-item .col-sub {
  font-size: 8px;
  color: var(--text-light);
  white-space: nowrap;
}

.col-item.is-current .col-label {
  color: var(--theme-text);
  font-weight: 700;
}

.col-item.is-negative .col-value {
  color: var(--negative);
}

/* ------------------------------------------------------------ 环形进度 */

svg.ring {
  display: block;
  flex: none;
  filter: drop-shadow(0 2px 5px rgba(150, 130, 106, 0.22));
}

svg.ring .ring-text {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  fill: var(--text-primary);
}

/* ------------------------------------------------------------ 记账页 */

/* 返回按钮：做成明显的软 3D 药丸按钮，不再是一行小字 */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px 18px 10px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--theme-text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 140ms ease;
}

.back-btn:hover {
  box-shadow: var(--shadow-out-hover);
}

.back-btn:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.back-btn .bb-arrow {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--theme-color) 24%, #fff);
  color: var(--theme-text);
  font-size: 16px;
  line-height: 1;
}

/* 首页上的本月结余条 */
.balance-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 14px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

.balance-strip .bs-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.balance-strip .bs-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.balance-strip .bs-facts {
  font-size: 12px;
  color: var(--text-light);
}

.balance-strip .bs-spacer {
  flex: 1;
}

.balance-strip.pos {
  background: linear-gradient(120deg, color-mix(in srgb, var(--positive) 12%, var(--bg-base)), var(--bg-base));
}

.balance-strip.neg {
  background: linear-gradient(120deg, color-mix(in srgb, var(--negative) 12%, var(--bg-base)), var(--bg-base));
}

/* 类别九宫格 */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 10px;
}

.cat-pick {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 12px 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), color var(--dur) var(--ease), transform 140ms ease;
}

.cat-pick:hover {
  box-shadow: var(--shadow-out);
}

.cat-pick:active {
  transform: translateY(1px);
}

.cat-pick.active {
  box-shadow: var(--shadow-in);
  color: var(--theme-text);
  font-weight: 600;
  background: color-mix(in srgb, var(--theme-color) 12%, var(--bg-base));
}

.calc-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* 当日快速记账：类目小胶囊 */
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 140ms ease;
}

.cat-chip:hover {
  box-shadow: var(--shadow-out-hover);
}

.cat-chip:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.cat-chip.income {
  color: var(--positive);
}

.cat-chip.more {
  color: var(--text-secondary);
  padding-left: 12px;
}

.cat-chip .more-plus {
  font-size: 15px;
  line-height: 1;
  color: var(--theme-text);
}

.entry-list.compact .day-entry {
  padding: 9px 4px;
}

.day-entry {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

/* 其他固定支出项 */
.fixed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.fixed-tile {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease), transform 140ms ease;
}

.fixed-tile:hover {
  box-shadow: var(--shadow-out-hover);
}

.fixed-tile:active {
  box-shadow: var(--shadow-in);
  transform: translateY(1px);
}

.fixed-tile .ft-name {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.fixed-tile .ft-amount {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fixed-tile .ft-sub {
  font-size: 11px;
  color: var(--text-light);
}

/* 未归档资金 */
.pending-list {
  display: grid;
  gap: 12px;
}

.pending-item {
  display: grid;
  gap: 9px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
}

.pending-item.done {
  opacity: 0.72;
}

.pending-item .pi-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pending-item .pi-numbers {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.pending-item .pi-numbers b {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pending-item .pi-ops {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ------------------------------------------------------------ 资产页 */

/* 紧凑资产条：一行数字，去掉大卡片 */
.asset-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
  max-width: 620px;
  padding: 9px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow-in);
}

.asset-strip .as-item {
  display: grid;
  gap: 1px;
  border: 0;
  padding: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
}

button.as-item {
  cursor: pointer;
}

button.as-item::after {
  content: '点击设置';
  font-size: 9px;
  color: var(--theme-text);
}

.asset-strip .as-item > span {
  font-size: 10px;
  color: var(--text-light);
}

.asset-strip .as-item strong {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 债务清单：一行一笔的表格 */
.card-debt .card-body {
  padding-top: 6px;
}

.dt-sortbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 3px;
  font-size: 10.5px;
  color: var(--text-light);
}

.dt-sortbar .spacer,
.dt-line .spacer,
.dt-progress .spacer {
  flex: 1;
}

.dt-sort {
  padding: 2px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10.5px;
  cursor: pointer;
}

.dt-sort.on {
  color: var(--theme-text);
  font-weight: 700;
  box-shadow: var(--shadow-in);
  background: color-mix(in srgb, var(--theme-color) 14%, var(--bg-base));
}

/* 债务清单：真表格，列宽按内容分配，不会出现某列特别空、某列特别挤 */
.dt-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dt-table th {
  padding: 4px 8px;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-light);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.3);
}

.dt-table td {
  padding: 7px 8px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.13);
}

.dt-table .dt-name {
  font-weight: 600;
  text-align: left;
}

.dt-table .dt-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dt-table .dt-main {
  font-weight: 700;
}

.dt-table .dt-dim {
  color: var(--text-light);
}

.dt-table .dt-name i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--theme-color);
  vertical-align: middle;
}

.dt-table .dt-name i.warn {
  background: var(--negative);
}

.dt-table tbody tr.dt-row {
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.dt-table tbody tr.dt-row:hover td {
  background: rgba(255, 255, 255, 0.45);
}

/* 第一行总计 */
.dt-table tr.dt-total td {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.34);
  border-bottom: 1px solid rgba(150, 130, 106, 0.3);
}

/* 还款计划表保持按内容排布 */
.pt-head,
.pt-body,
.pt-foot {
  max-width: 880px;
}

.dt-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dt-name i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--theme-color);
}

.dt-name i.warn {
  background: var(--negative);
}

.dt-num {
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dt-main {
  font-weight: 700;
}

.dt-dim {
  color: var(--text-light);
}

.dt-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.dt-track {
  width: 104px;
  height: 3px;
  flex: none;
  border-radius: 2px;
  background: rgba(150, 130, 106, 0.22);
  overflow: hidden;
}

.dt-track i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--positive);
}

.dt-pct {
  font-size: 9.5px;
  color: var(--text-light);
  font-variant-numeric: tabular-nums;
}

.dt-pct.neg {
  color: var(--negative);
  font-weight: 600;
}

/* 债务详情：一行数字 + 每期计划表 */
.detail-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 10px;
  padding: 9px 12px;
  margin: 10px 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow-in);
}

.detail-stats span {
  display: grid;
  gap: 2px;
}

.detail-stats em {
  font-style: normal;
  font-size: 10px;
  color: var(--text-light);
}

.detail-stats b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.card-plan .card-body {
  padding-top: 6px;
}

.pt-head,
.pt-row {
  display: grid;
  grid-template-columns: 26px 58px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr) 62px;
  align-items: center;
  gap: 6px;
}

.pt-head {
  padding: 4px 2px;
  font-size: 9.5px;
  color: var(--text-light);
  border-bottom: 1px solid rgba(150, 130, 106, 0.3);
}

.pt-row {
  padding: 6px 2px;
  border-bottom: 1px solid rgba(150, 130, 106, 0.13);
}

.pt-row.is-paid {
  opacity: 0.55;
}

.pt-row.is-overdue {
  background: rgba(168, 85, 75, 0.07);
}

.pt-num {
  text-align: right;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.pt-main {
  font-weight: 700;
}

.pt-dim {
  color: var(--text-light);
}

.pt-op {
  text-align: right;
}

.pt-btn {
  padding: 3px 8px;
  border: 0;
  border-radius: 7px;
  background: rgba(166, 123, 91, 0.16);
  color: var(--theme-text);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pt-btn.on {
  background: var(--positive-soft);
  color: var(--positive);
}

.pt-btn.warn {
  background: var(--negative-soft);
  color: var(--negative);
}

.pt-foot {
  display: grid;
  grid-template-columns: 26px 58px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr) 62px;
  gap: 6px;
  padding: 7px 2px 2px;
  border-top: 1px solid rgba(150, 130, 106, 0.3);
  font-size: 11.5px;
  font-weight: 700;
}

.pt-foot > span:first-child {
  grid-column: 1 / 3;
  text-align: left;
}

.asset-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
}

.asset-preview .ap-item {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-out);
  font-family: inherit;
  text-align: left;
  color: var(--text-primary);
}

button.ap-item {
  cursor: pointer;
}

.asset-preview .ap-item > span {
  font-size: 12px;
  color: var(--text-secondary);
}

.asset-preview .ap-item strong {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.asset-preview .ap-item em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-light);
}

.ap-item.is-pos {
  background: linear-gradient(150deg, var(--positive-soft), var(--bg-base));
}

.ap-item.is-neg {
  background: linear-gradient(150deg, var(--negative-soft), var(--bg-base));
}

/* 债务清单 */
.debt-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.debt-item .di-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.debt-item .di-main {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
}

.debt-item .di-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.debt-item .di-ring {
  display: grid;
  place-items: center;
}

.debt-item .di-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.debt-progress-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

.debt-progress-row .dpr-text {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------ 现金流页 */

/* 额外资金 / 现金流清单：真表格，列宽按内容分配，一屏放得下 */
.cf-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.cf-table th {
  padding: 4px 8px;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--text-light);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.3);
}

.cf-table td {
  padding: 6px 8px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.13);
}

.cf-table .cf-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cf-table .cf-kind {
  text-align: center;
  font-size: 10.5px;
  color: var(--text-secondary);
}

.cf-table .cf-dim {
  color: var(--text-light);
}

.cf-table .cf-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.cf-table .cf-date {
  font-variant-numeric: tabular-nums;
}

.cf-table tbody tr.cf-row {
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}

.cf-table tbody tr.cf-row:hover td {
  background: rgba(255, 255, 255, 0.45);
}

/* 表内小节标题（收入 / 支出） */
.cf-subhead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.cf-subhead:first-child {
  margin-top: 0;
}

.cf-subhead .cf-subtotal {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.cf-subhead .link-btn {
  margin-left: auto;
}

/* 年份筛选按钮 */
.cf-years {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}

.forecast-grid .fc-item {
  display: grid;
  gap: 5px;
  padding: 15px 16px;
  border-radius: var(--radius);
  background: var(--bg-base);
  box-shadow: var(--shadow-in);
}

.forecast-grid .fc-item > span {
  font-size: 11.5px;
  color: var(--text-light);
}

.forecast-grid .fc-item strong {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.forecast-grid .fc-item strong.small-strong {
  font-size: 16px;
}

.forecast-grid .fc-item em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-secondary);
}

.year-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.year-legend .yl-item {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.year-tone-0 {
  background: rgba(201, 138, 75, 0.09);
}

.year-tone-1 {
  background: rgba(127, 160, 138, 0.11);
}

.year-tone-2 {
  background: rgba(141, 148, 196, 0.1);
}

.year-tone-3 {
  background: rgba(176, 106, 74, 0.09);
}

.cf-date {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.cf-date em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-light);
}

/* ------------------------------------------------------------ 复盘页 */

/* 复盘表格：列宽收紧，手机上也能一屏看全 */
.rv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  table-layout: fixed;
}

.rv-table th {
  padding: 3px 1px;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-light);
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.3);
}

.rv-table td {
  padding: 4px 1px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(150, 130, 106, 0.12);
  font-variant-numeric: tabular-nums;
}

.rv-table .rv-name {
  width: 34px;
  text-align: left;
  color: var(--text-secondary);
}

.rv-table .rv-num {
  text-align: right;
}

.rv-table tr.rv-total td {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.34);
  border-top: 1px solid rgba(150, 130, 106, 0.3);
  border-bottom: 0;
}

/* 逐年数据只有四列，宽度放开一点 */
.rv-table-wide .rv-name {
  width: 56px;
}

/* 生活支出分类表：类目 + 三列数字 */
.rv-table-life {
  font-size: 11px;
}

.rv-table-life .rv-name {
  width: 96px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
}

.rv-table-life th {
  font-size: 10px;
}

.rv-table-life td {
  padding: 5px 2px;
}

.rv-table-wide {
  font-size: 11.5px;
}

.rv-table-wide th {
  font-size: 10px;
}

.page-subbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.stack {
  display: grid;
  gap: 14px;
}

.axis.mark {
  font-size: 10px;
  font-weight: 700;
  fill: var(--text-secondary);
}

/* ------------------------------------------------------------ 小屏适配 */

@media (max-width: 720px) {
  .col-item {
    grid-template-rows: auto 68px auto auto;
  }

  .col-chart {
    gap: 3px;
  }

  .cat-grid {
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 8px;
  }

  .bh-amount {
    font-size: 22px;
  }

  .asset-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .debt-item .di-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .forecast-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------ 手机端最终覆盖
   放在文件末尾，确保覆盖前面所有基样式（媒体查询不提升优先级，只按顺序生效）。 */

@media (max-width: 860px) {
  /* 结余条：一行放下 */
  .balance-strip {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius);
  }

  .balance-strip .bs-value {
    font-size: 16px;
  }

  .balance-strip .bs-facts {
    font-size: 10.5px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* 预算使用块：两行数字 + 进度 + 2×2 小格 */
  .budget-hero {
    padding: 12px 14px;
    gap: 8px;
  }

  .bh-top {
    flex-direction: column;
    gap: 3px;
  }

  .bh-amount {
    font-size: 21px;
  }

  .bh-state {
    align-self: flex-start;
  }

  .bh-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .bh-cell {
    padding: 7px 9px;
  }

  .bh-legend {
    font-size: 10px;
  }

  /* 数字条：手机两列 */
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
  }

  /* 卡片里的按钮小一号 */
  .card-head .seg-btn,
  .card-head .btn {
    padding: 4px 9px;
    font-size: 11.5px;
  }

  /* 日历：格子压扁，一屏能看完整月 */
  .cal-grid {
    gap: 4px;
  }

  .cal-cell {
    min-height: 46px;
    padding: 4px 5px;
    gap: 1px;
  }

  .cal-cell .cal-day {
    font-size: 11.5px;
  }

  .cal-cell .cal-out,
  .cal-cell .cal-in {
    font-size: 10px;
  }

  .cal-foot {
    gap: 14px;
    margin-top: 10px;
    padding-top: 10px;
    font-size: 11.5px;
  }

  /* 条状图每行更紧凑 */
  .hbars {
    gap: 8px;
  }

  .hbars-row {
    grid-template-columns: 78px minmax(0, 1fr) 72px;
    gap: 8px;
    font-size: 12px;
  }
}
