/* ==========================================================================
   记账 · 移动端样式
   设计取向：暖色纸感账本 —— 米白底 + 朱砂强调色 + 克制的圆角与阴影
   ========================================================================== */

:root {
  --brand:        #e2542c;
  --brand-deep:   #c4401c;
  --brand-soft:   #fdeee8;

  --bg:           #f7f4ef;
  --card:         #ffffff;
  --line:         #ece5dc;
  --line-strong:  #ded4c8;

  --ink:          #221f1c;
  --ink-2:        #5f5751;   /* 正文次要：白底对比度 7.1:1 */
  --ink-3:        #7d736b;   /* 辅助信息：白底对比度 4.6:1（满足 WCAG AA） */

  --radius-lg:    18px;
  --radius-md:    14px;
  --radius-sm:    10px;

  --shadow-card:  0 1px 2px rgba(45, 35, 25, .04), 0 6px 18px -12px rgba(45, 35, 25, .18);
  --shadow-float: 0 8px 28px -8px rgba(45, 35, 25, .28);

  --tabbar-h:     60px;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);

  --ease:         cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

/* hidden 属性必须能盖住组件自身的 display 声明 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  margin: 0;
}

button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

input:focus, button:focus { outline: none; }

/* 金额数字用等宽数字，避免抖动 -------------------------------------------------- */
.hero-amount, .ov-value, .amount-input, .rec-amount, .day-total,
.metric-value, .legend-amount, .summary-line, .mn-label,
.sum-value, .year-amount, .year-pct, .top-amount, .modal-amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ==========================================================================
   顶栏
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 18px 12px;
  background: rgba(247, 244, 239, .94);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}

.topbar.is-scrolled {
  border-bottom-color: var(--line);
  background: rgba(247, 244, 239, .88);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .topbar {
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
  }
}

.brand {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .06em;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  box-shadow: 0 1px 2px rgba(45, 35, 25, .04);
}

.mn-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}

.mn-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mn-btn:active { background: var(--brand-soft); color: var(--brand); }
.mn-btn[disabled] { color: #dcd4ca; pointer-events: none; }

.mn-label {
  min-width: 84px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* 记一笔 / 搜索 / 统计 页不需要顶栏月份切换（统计页有自己的范围切换） */
.tab-add .month-nav,
.tab-search .month-nav,
.tab-stats .month-nav { display: none; }

/* ==========================================================================
   主体
   ========================================================================== */
.stage {
  padding: 4px 14px calc(var(--tabbar-h) + var(--safe-bottom) + 22px);
  max-width: 560px;
  margin: 0 auto;
}

.screen { display: none; }
.screen.active { display: block; animation: rise .28s var(--ease) both; }

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

@media (prefers-reduced-motion: reduce) {
  .screen.active { animation: none; }
}

/* ==========================================================================
   概览条（记一笔）
   ========================================================================== */
.overview-strip {
  display: flex;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 9px 4px;
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
}

.ov-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ov-label { font-size: 12px; color: var(--ink-3); }
.ov-value { font-size: 17px; font-weight: 700; }
.ov-divider { width: 1px; height: 26px; background: var(--line); }

/* ==========================================================================
   表单
   ========================================================================== */
.field { margin-bottom: 13px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .04em;
  margin-bottom: 6px;
  padding-left: 2px;
}

/* 金额 */
.amount-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 9px 16px 11px;
  box-shadow: var(--shadow-card);
  border: 1.5px solid transparent;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.amount-box.is-focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.amount-symbol {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-3);
  transition: color .18s var(--ease);
}

.amount-box.is-focus .amount-symbol { color: var(--brand); }

.amount-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.015em;
  padding: 0;
  color: var(--ink);
}

.amount-input::placeholder { color: #d8cfc5; font-weight: 600; }

/* 类别 */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 2px 6px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  transition: transform .12s var(--ease), border-color .16s var(--ease),
              background .16s var(--ease), box-shadow .16s var(--ease);
}

.cat-icon { font-size: 18px; line-height: 1.1; }
.cat-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; }

.cat:active { transform: scale(.95); }

.cat.is-on {
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: 0 2px 10px -6px rgba(226, 84, 44, .8);
}

.cat.is-on .cat-name { color: var(--brand-deep); font-weight: 600; }

/* 文本输入 */
.input-box {
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 46px;
  box-shadow: var(--shadow-card);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.input-box.is-focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.text-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 16px;           /* ≥16px 防止 iOS 聚焦缩放 */
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}

.text-input::placeholder { color: var(--ink-3); }

input[type="date"], input[type="time"] {
  min-height: 24px;
  color: var(--ink);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: .45;
  padding: 0;
}

.time-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 8px;
}

/* 提交：钉在 tabbar 上方。表单再长，按钮也始终可见，
   不依赖「内容刚好放得下」——小米/微信上字体被放大时会撑破首屏。
   用不透明底 + 细分隔线做成操作条，内容从下方滚过时不会透出来。 */
.submit-wrap {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  z-index: 5;
  margin: 0 -14px -1px;
  padding: 9px 14px 9px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.submit-btn {
  width: 100%;
  height: 50px;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .06em;
  box-shadow: 0 8px 20px -10px rgba(226, 84, 44, .95);
  transition: transform .12s var(--ease), background .18s var(--ease), opacity .18s var(--ease);
}

.submit-btn:active:not([disabled]) {
  transform: scale(.975);
  background: var(--brand-deep);
}

.submit-btn[disabled] {
  background: #e3dbd2;
  color: #fff;
  box-shadow: none;
}

/* ==========================================================================
   明细
   ========================================================================== */
.summary-line {
  font-size: 13px;
  color: var(--ink-2);
  padding: 8px 4px 12px;
}

.summary-line b {
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.day-group {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 12px;
  overflow: hidden;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px 9px;
  border-bottom: 1px solid var(--line);
}

.day-date { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.day-week { font-size: 11.5px; color: var(--ink-3); margin-left: 5px; font-weight: 400; }
.day-total { font-size: 13.5px; font-weight: 700; color: var(--ink); }

.rec {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  transition: background .15s var(--ease);
}

.rec + .rec { border-top: 1px solid #f5f1ec; }
.rec:active { background: #faf7f3; }

.rec-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: var(--bg);
  font-size: 18px;
}

.rec-body { flex: 1; min-width: 0; }

.rec-cat {
  font-size: 14.5px;
  font-weight: 600;
  display: block;
}

.rec-remark {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rec-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

.rec-amount { font-size: 16px; font-weight: 700; }
.rec-time { font-size: 11.5px; color: var(--ink-3); }

/* ==========================================================================
   统计
   ========================================================================== */
.hero-card {
  position: relative;
  border-radius: 22px;
  padding: 22px 18px 16px;
  margin-bottom: 14px;
  color: #fff;
  background: linear-gradient(145deg, #ef6a3d 0%, #e2542c 46%, #c4401c 100%);
  box-shadow: 0 16px 32px -18px rgba(196, 64, 28, .95);
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  top: -52px;
  right: -46px;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}

.hero-label {
  font-size: 12.5px;
  letter-spacing: .1em;
  opacity: .82;
}

.hero-amount {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-top: 4px;
}

.hero-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .16);
  min-height: 22px;
}

.hero-delta:empty { display: none; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .22);
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.metric-value { font-size: 15px; font-weight: 700; }
.metric-label { font-size: 11px; opacity: .8; }

/* 卡片 */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.card-sub { font-size: 12px; color: var(--ink-3); }

/* 环形图 */
.pie-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 2px auto 16px;
}

.donut {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut circle {
  fill: none;
  stroke-width: 13;
  transition: stroke-dasharray .5s var(--ease);
}

.pie-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.pie-center-pct {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.pie-center-name {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}

/* 图例 */
.legend { list-style: none; margin: 0; padding: 0; }

.legend li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 2px;
}

.legend li + li { border-top: 1px solid #f5f1ec; }

.legend-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 3px;
}

.legend-name { font-size: 13.5px; flex: 1; min-width: 0; }
.legend-count { font-size: 11.5px; color: var(--ink-3); margin-left: 5px; }

.legend-amount {
  font-size: 13.5px;
  font-weight: 700;
  text-align: right;
}

.legend-pct {
  width: 46px;
  text-align: right;
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* 柱状图 */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 116px;
  padding-top: 6px;
}

.bar-col {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}

.bar-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
}

/* 用 flex-grow 按比例分配高度，不依赖百分比高度（X5 更稳） */
.bar-spacer,
.bar-fill {
  flex-basis: 0;
  flex-shrink: 0;
}

.bar-spacer { min-height: 0; }

.bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 3px;
  background: #f2ded5;
  transition: flex-grow .5s var(--ease), background .2s var(--ease);
}

.bar-col.is-peak .bar-fill { background: var(--brand); }

.bar-label {
  font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  height: 11px;
  line-height: 11px;
  font-variant-numeric: tabular-nums;
}

.bar-foot {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ==========================================================================
   空状态
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 56px 20px;
}

.empty-icon { font-size: 42px; }
.empty-title { margin: 12px 0 4px; font-size: 15px; font-weight: 600; }
.empty-sub { margin: 0; font-size: 13px; color: var(--ink-3); }

/* ==========================================================================
   底部导航
   ========================================================================== */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tabbar {
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
  }
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-3);
  transition: color .16s var(--ease);
}

.tab svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s var(--ease);
}

.tab span { font-size: 11px; }

.tab.active { color: var(--brand); }
.tab.active span { font-weight: 600; }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab:active svg { transform: scale(.88); }

/* ==========================================================================
   底部弹层
   ========================================================================== */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  background: rgba(30, 24, 20, .42);
  animation: fade .2s var(--ease) both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + var(--safe-bottom));
  animation: slideUp .26s var(--ease) both;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 4px auto 16px;
}

.sheet-amount {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 8px 0 4px;
  font-size: 13px;
  color: var(--ink-2);
}

.sheet-remark {
  font-size: 13.5px;
  color: var(--ink-2);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
  word-break: break-all;
}

.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.sheet-btn {
  height: 50px;
  border-radius: var(--radius-md);
  font-size: 15.5px;
  font-weight: 600;
  background: var(--bg);
  color: var(--ink-2);
  transition: transform .12s var(--ease), background .16s var(--ease);
}

.sheet-btn:active { transform: scale(.98); }

.sheet-btn.is-danger {
  background: #fdeceb;
  color: #c9342a;
  font-weight: 700;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  z-index: 50;
  transform: translateX(-50%);
  max-width: calc(100vw - 56px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(34, 31, 28, .93);
  color: #fff;
  font-size: 14px;
  text-align: center;
  box-shadow: var(--shadow-float);
  animation: toastIn .24s var(--ease) both;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   统计页：范围切换
   ========================================================================== */
.segmented {
  display: flex;
  gap: 4px;
  background: #efe9e1;
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 13px;
}

.seg {
  flex: 1;
  height: 36px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}

.seg.is-on {
  background: var(--card);
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(45, 35, 25, .13);
}

/* ==========================================================================
   统计页：支出总览四宫格
   ========================================================================== */
.sum-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sum-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--card);
  padding: 12px 6px;
}

.sum-value { font-size: 17px; font-weight: 700; }
.sum-label { font-size: 11.5px; color: var(--ink-3); }

/* ==========================================================================
   统计页：年度消费
   ========================================================================== */
.year-list { display: flex; flex-direction: column; gap: 12px; }
.year-row { display: flex; flex-direction: column; gap: 5px; }

.year-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13.5px;
}

.year-name { font-weight: 600; }
.year-count { font-size: 11.5px; color: var(--ink-3); margin-left: 5px; font-weight: 400; }
.year-amount { font-weight: 700; }
.year-pct { font-size: 12px; color: var(--ink-3); margin-left: 6px; }

.year-bar {
  height: 7px;
  border-radius: 4px;
  background: #f1ebe4;
  overflow: hidden;
}

.year-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--brand);
  transition: width .5s var(--ease);
}

.year-row.is-current .year-fill { background: linear-gradient(90deg, #ef6a3d, #c4401c); }

/* ==========================================================================
   统计页：大额支出
   ========================================================================== */
.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}

.top-item + .top-item { border-top: 1px solid #f5f1ec; }

.top-rank {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-item:nth-child(-n+3) .top-rank {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.top-body { flex: 1; min-width: 0; }

.top-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-meta { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.top-amount { flex: 0 0 auto; font-size: 14.5px; font-weight: 700; }

/* ==========================================================================
   保存成功模态窗
   ========================================================================== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 24, 20, .5);
  animation: fade .18s var(--ease) both;
}

.modal {
  width: 100%;
  max-width: 320px;
  background: var(--card);
  border-radius: 22px;
  padding: 26px 22px 20px;
  text-align: center;
  box-shadow: 0 24px 64px -20px rgba(30, 24, 20, .5);
  animation: pop .26s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(.9) translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.modal-check {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: checkIn .34s var(--ease) both;
}

@keyframes checkIn {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-check svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-amount {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 6px 0 14px;
  color: var(--brand);
}

.modal-rows {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 2px 12px;
  text-align: left;
}

.modal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-size: 13.5px;
}

.modal-row + .modal-row { border-top: 1px solid var(--line); }
.modal-row .k { color: var(--ink-3); flex: 0 0 auto; }
.modal-row .v { font-weight: 600; text-align: right; word-break: break-all; }

.modal-btn {
  width: 100%;
  height: 48px;
  margin-top: 18px;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .1em;
  transition: transform .12s var(--ease), background .18s var(--ease);
}

.modal-btn:active { transform: scale(.975); background: var(--brand-deep); }

/* ==========================================================================
   搜索页
   ========================================================================== */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  background: var(--card);
  border: 1.5px solid transparent;
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  margin-bottom: 10px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}

.search-box.is-focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.search-icon {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
  stroke-linecap: round;
}

.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder { color: var(--ink-3); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2.4;
  stroke-linecap: round;
}

/* 快捷时间范围 */
.quick-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.quick-row::-webkit-scrollbar { display: none; }

.qchip {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}

.qchip.is-on {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-deep);
  font-weight: 600;
}

/* 筛选 / 排序 */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.fbtn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
}

.fbtn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.fbtn.is-open {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-deep);
  font-weight: 600;
}

.fbtn-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.sort-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.sort-select {
  -webkit-appearance: none;
  appearance: none;
  height: 34px;
  padding: 0 26px 0 13px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
}

.sort-arrow {
  position: absolute;
  right: 9px;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2.2;
  stroke-linecap: round;
  pointer-events: none;
}

/* 筛选面板 */
.filter-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px;
  margin-bottom: 12px;
  animation: rise .22s var(--ease) both;
}

.filter-group { margin-bottom: 14px; }
.filter-group:last-of-type { margin-bottom: 0; }

.pair-row { display: flex; align-items: center; gap: 8px; }
.pair-sep { flex: 0 0 auto; font-size: 13px; color: var(--ink-3); }

.reset-btn {
  width: 100%;
  height: 42px;
  margin-top: 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 600;
}

.reset-btn:active { background: #efe9e1; }

/* 结果区 */
.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 12px;
  padding: 4px 4px 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.result-bar b { color: var(--ink); font-size: 15px; font-weight: 700; }
.result-bar .rb-item { font-variant-numeric: tabular-nums; }

.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.result-chips:empty { display: none; }

.rc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.rc b { color: var(--ink); font-weight: 700; }

.hit-list {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.hit {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
}

.hit + .hit { border-top: 1px solid #f5f1ec; }
.hit:active { background: #faf7f3; }

.hit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  background: var(--bg);
  font-size: 17px;
}

.hit-body { flex: 1; min-width: 0; }

.hit-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-name mark {
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-radius: 3px;
  padding: 0 1px;
}

.hit-meta { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

.hit-amount {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.load-more {
  width: 100%;
  height: 46px;
  margin-top: 12px;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 14.5px;
  font-weight: 600;
}

.load-more:active { background: #faf7f3; }

/* ==========================================================================
   小屏微调
   ========================================================================== */
@media (max-width: 340px) {
  .stage { padding-left: 11px; padding-right: 11px; }
  .amount-input { font-size: 30px; }
  .hero-amount { font-size: 32px; }
  .cat-name { font-size: 11px; }
  .pie-wrap { width: 146px; height: 146px; }
  .sum-value { font-size: 15px; }
}

/* 矮屏进一步压缩表单：微信内置浏览器有底部工具栏，实际可视高度比标称小，
   配合黏底按钮，保证首屏能看到全部输入项 */
@media (max-height: 720px) {
  .stage { padding-top: 0; }
  .overview-strip { padding: 6px 4px; margin-bottom: 9px; }
  .ov-value { font-size: 15px; }
  .field { margin-bottom: 8px; }
  .field-label { margin-bottom: 4px; font-size: 12px; }
  .amount-box { padding: 6px 14px 7px; }
  .amount-input { font-size: 28px; }
  .cat { padding: 5px 2px 4px; }
  .cat-icon { font-size: 16px; }
  .cat-name { font-size: 11.5px; }
  .input-box { height: 40px; }
  .submit-wrap { padding: 7px 14px; }
  .submit-btn { height: 46px; }
}

@media (min-width: 420px) {
  .bar-chart { height: 132px; }
}