:root {
  --bg: #f2f4f8;
  --bg-soft: #e8ebf2;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --elev: #ffffff;
  --text: #161a22;
  --text-2: #4c5566;
  --muted: #8a92a3;
  --line: #e6e9f0;
  --brand: #5b6cff;
  --brand-2: #8b5cf6;
  --income: #10b981;
  --expense: #ef4444;
  --warning: #f59e0b;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 28px rgba(20, 28, 45, 0.06);
  --shadow-strong: 0 16px 40px rgba(20, 28, 45, 0.16);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0f14;
  --bg-soft: #07080b;
  --surface: #161920;
  --surface-2: #1d212b;
  --elev: #262c3a;
  --text: #eef1f6;
  --text-2: #b6bdcb;
  --muted: #818a9c;
  --line: #262c38;
  --brand: #7b8aff;
  --brand-2: #a78bfa;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-strong: 0 18px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14;
    --bg-soft: #07080b;
    --surface: #161920;
    --surface-2: #1d212b;
    --elev: #262c3a;
    --text: #eef1f6;
    --text-2: #b6bdcb;
    --muted: #818a9c;
    --line: #262c38;
    --brand: #7b8aff;
    --brand-2: #a78bfa;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-strong: 0 18px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.no-scroll {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.tx-amount,
.hero-amount,
.tile-value,
.account-balance,
.holding-value,
.invest-big,
.soft-amount,
.summary-item strong,
.rank-amount {
  font-variant-numeric: tabular-nums;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(18px + var(--safe-top)) 16px calc(104px + var(--safe-bottom));
}

@media (min-width: 620px) {
  body {
    background: var(--bg-soft);
  }

  .app {
    background: var(--bg);
    box-shadow: 0 0 60px rgba(20, 28, 45, 0.08);
  }
}

/* 顶部 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.hello {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 12px 5px 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.brand-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.subpage-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  min-height: 40px;
}

.subpage-head h1 {
  font-size: 19px;
  font-weight: 700;
  text-align: center;
}

.back-btn {
  font-size: 26px;
  line-height: 1;
  padding-bottom: 2px;
}

.subpage-action {
  display: flex;
  justify-content: flex-end;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
  padding: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s, transform 0.15s;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* 月份切换 */
.month-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 2px 0 16px;
}

.month-label {
  font-weight: 700;
  font-size: 15px;
  min-width: 104px;
  text-align: center;
}

/* 主卡片 */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 20px;
  background: linear-gradient(135deg, #5b6cff 0%, #7c5cff 52%, #a855f7 100%);
  color: #fff;
  box-shadow: 0 16px 38px rgba(91, 108, 255, 0.28);
  margin-bottom: 14px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  right: -70px;
  bottom: -95px;
  pointer-events: none;
}

.hero::before {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  right: 30px;
  top: -60px;
  pointer-events: none;
}

.hero-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero-tag {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 99px;
}

.hero-amount {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: clamp(36px, 10vw, 44px);
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.1;
  margin: 14px 0 16px;
  position: relative;
  z-index: 1;
}

.hero-currency {
  font-size: 22px;
  font-weight: 600;
  opacity: 0.9;
}

.hero-stats {
  display: flex;
  gap: 36px;
  position: relative;
  z-index: 1;
}

.hero-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-stats span {
  font-size: 12px;
  opacity: 0.78;
}

.hero-stats strong {
  font-size: 15px;
  font-weight: 650;
}

.hero-stats strong.down {
  color: #ffd5d5;
}

.soft-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.soft-amount {
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 2px 0;
}

/* 卡片与通用 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.card-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 10px 2px;
}

.link {
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}

.text-danger {
  color: var(--expense) !important;
}

.text-up {
  color: var(--income) !important;
}

.text-down {
  color: var(--expense) !important;
}

.chev {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

/* 预算 */
.budget-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  transition: width 0.35s ease;
}

.progress.over > span {
  background: linear-gradient(90deg, #f87171, #ef4444);
}

.budget-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.15s;
}

.budget-prompt:active {
  transform: scale(0.99);
}

.budget-prompt-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  display: grid;
  place-items: center;
  font-size: 19px;
  flex: 0 0 auto;
}

.budget-prompt-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.budget-prompt-text strong {
  font-size: 14px;
  font-weight: 600;
}

/* 数据小卡片 */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  padding: 14px;
}

.tile-label {
  font-size: 12px;
  color: var(--muted);
}

.tile-value {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tile-sub {
  font-size: 11px;
  color: var(--muted);
}

/* 账单列表 */
.list-card {
  padding-top: 12px;
}

.tx-list {
  display: flex;
  flex-direction: column;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
  border-radius: 10px;
}

.tx-row + .tx-row {
  border-top: 1px solid var(--line);
}

.tx-row:active {
  opacity: 0.7;
}

.cat-emoji {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: color-mix(in srgb, var(--cat-color, #94a3b8) 15%, transparent);
  flex: 0 0 auto;
}

.cat-emoji.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 15px;
  display: inline-grid;
  vertical-align: middle;
  margin-right: 8px;
}

.tx-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.tx-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-amount {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
}

.tx-amount.expense {
  color: var(--text);
}

.tx-amount.income {
  color: var(--income);
}

.tx-amount.transfer {
  color: var(--muted);
  font-weight: 600;
}

.day-group {
  margin-bottom: 16px;
}

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 0 4px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.day-group .card {
  padding: 2px 14px;
  margin-bottom: 0;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.summary-item strong {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-item + .summary-item {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.search-box span {
  font-size: 14px;
  opacity: 0.8;
}

.search-box input {
  flex: 1;
  border: 0;
  background: none;
  padding: 11px 0;
  outline: none;
  font-size: 14px;
  min-width: 0;
}

.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* 分段控件 */
.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
}

.card .seg,
.sheet .seg {
  margin-bottom: 0;
}

.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-2);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.active {
  background: var(--elev);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(20, 28, 45, 0.08);
}

/* 统计 */
.chart-card {
  padding-top: 8px;
}

.donut-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 12px;
}

.donut {
  width: min(190px, 56vw);
  height: auto;
  overflow: visible;
}

.donut-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.donut-value {
  fill: var(--text);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
}

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rank-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.rank-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.rank-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-amount {
  font-weight: 600;
}

.rank-pct {
  color: var(--muted);
  font-size: 12px;
  min-width: 36px;
  text-align: right;
}

.rank-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.rank-bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  opacity: 0.85;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.legend .dot {
  margin-left: 6px;
}

.dot.income {
  background: var(--income);
}

.dot.expense {
  background: var(--expense);
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 4px;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.bar-income {
  fill: var(--income);
}

.bar-expense {
  fill: var(--expense);
}

.chart-label {
  fill: var(--muted);
  font-size: 9px;
  font-family: inherit;
}

/* 表单 */
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 13px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text);
  text-align: center;
  transition: transform 0.12s, opacity 0.12s;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(91, 108, 255, 0.26);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--expense);
  color: #fff;
}

.btn-danger-ghost {
  background: color-mix(in srgb, var(--expense) 12%, transparent);
  color: var(--expense);
}

.btn-block {
  width: 100%;
  display: flex;
}

.emoji-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 17px;
  display: grid;
  place-items: center;
  padding: 0;
}

.emoji-btn:active {
  background: var(--elev);
}

/* 底部导航 */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 1fr 1fr 72px 1fr 1fr;
  align-items: end;
  gap: 2px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(6px + var(--safe-bottom));
  z-index: 40;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px 0 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 12px;
  transition: color 0.15s;
}

.tab svg {
  width: 22px;
  height: 22px;
}

.tab.active {
  color: var(--brand);
}

.fab {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  margin: 0 auto -20px;
  box-shadow: 0 10px 24px rgba(91, 108, 255, 0.4), 0 0 0 5px color-mix(in srgb, var(--surface) 92%, transparent);
  transition: transform 0.15s;
}

.fab:active {
  transform: scale(0.93);
}

.fab svg {
  width: 25px;
  height: 25px;
}

/* 弹层 */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 13, 20, 0.46);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.16s ease;
}

.overlay.center {
  align-items: center;
  padding: 18px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(16px + var(--safe-bottom));
  animation: slideUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: var(--shadow-strong);
}

.sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 2px auto 10px;
}

.sheet-top {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sheet-close {
  background: var(--surface-2);
  border: 0;
  font-size: 18px;
}

.sheet-spacer {
  width: 36px;
}

.amount-box {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 12px 2px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.amount-currency {
  font-size: 24px;
  font-weight: 600;
  color: var(--muted);
}

.amount-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 40px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
  padding: 0;
}

.amount-input::placeholder {
  color: var(--line);
  font-weight: 700;
}

.sheet-footer {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sheet-footer .btn-danger-ghost {
  flex: 0 0 auto;
  padding: 12px 16px;
}

.sheet-footer .btn-block {
  flex: 1;
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.entry-label {
  margin-bottom: 8px;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 208px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 14px;
  scrollbar-width: thin;
}

.cat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 3px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text-2);
  min-width: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.cat-cell .cat-emoji {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 17px;
}

.cat-name {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cat-cell.selected {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
  color: var(--brand);
  font-weight: 600;
}

/* 对话框 */
.modal {
  width: 100%;
  max-width: 430px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 20px;
  margin: 0;
  animation: pop 0.18s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-actions .btn {
  flex: 1;
}

.confirm-message {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin-top: 8px;
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0.5; }
  to { transform: none; opacity: 1; }
}

/* Toast */
#toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(112px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}

.toast {
  background: rgba(22, 26, 34, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  max-width: 82%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  background: rgba(190, 36, 52, 0.96);
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 14px;
  text-align: center;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.9;
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
}

.empty-hint {
  font-size: 12px;
  color: var(--muted);
  max-width: 260px;
}

.empty-state .btn {
  margin-top: 8px;
}

/* 菜单 */
.menu {
  padding: 4px 14px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
  font-size: 14px;
}

.menu-row + .menu-row {
  border-top: 1px solid var(--line);
}

.menu-row:active {
  opacity: 0.65;
}

.menu-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-size: 15px;
  flex: 0 0 auto;
}

.menu-label {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.menu-value {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.menu-row.danger .menu-label {
  color: var(--expense);
}

.menu-row.danger .menu-ico {
  color: var(--expense);
  background: color-mix(in srgb, var(--expense) 10%, transparent);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(91, 108, 255, 0.25);
  flex: 0 0 auto;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.profile-title {
  font-size: 17px;
  font-weight: 700;
}

.app-foot {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.7;
  margin: 18px 0 6px;
}

/* 导入 */
.steps {
  margin: 10px 0 14px;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.7;
}

.steps li {
  margin-bottom: 6px;
}

.steps b {
  color: var(--text);
}

.preview-card .filename {
  margin: -2px 0 12px;
  word-break: break-all;
}

.source-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}

.preview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.preview-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
}

.preview-stats strong {
  font-size: 16px;
  font-weight: 700;
}

.preview-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 6px 2px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.preview-section {
  margin-bottom: 12px;
}

.preview-section > .field-label {
  margin-bottom: 7px;
}

.map-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}

.map-row:last-child {
  border-bottom: 0;
}

.map-from {
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45%;
}

.map-arrow {
  color: var(--muted);
}

.map-to {
  font-weight: 600;
  flex: 1;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  padding: 2px 7px;
  border-radius: 99px;
  vertical-align: middle;
}

.preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.preview-row:last-child {
  border-bottom: 0;
}

.preview-date {
  color: var(--muted);
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.preview-note {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-cat {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}

.preview-row .tx-amount {
  font-size: 13px;
}

.result-card {
  text-align: center;
}

.result-icon {
  font-size: 34px;
}

.result-title {
  font-size: 17px;
  font-weight: 700;
  margin: 4px 0;
}

.result-card .modal-actions {
  margin-top: 14px;
}

/* 账户与理财 */
.account-list,
.holding-list {
  padding: 2px 14px;
}

.account-row,
.holding-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
}

.account-row + .account-row,
.holding-row + .holding-row {
  border-top: 1px solid var(--line);
}

.account-row:active,
.holding-row:active {
  opacity: 0.7;
}

.account-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.account-balance {
  font-size: 16px;
  font-weight: 700;
  flex: 0 0 auto;
}

.invest-summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--surface)), var(--surface));
}

.invest-big {
  font-size: 32px;
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 2px 0 8px;
}

.invest-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.invest-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.invest-stats strong {
  font-size: 14px;
  font-weight: 650;
}

.alloc-bar {
  display: flex;
  height: 10px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--surface-2);
  margin: 10px 0 8px;
  gap: 2px;
}

.alloc-bar span {
  display: block;
  height: 100%;
}

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 11px;
  color: var(--muted);
}

.alloc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.holding-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

.holding-value {
  font-size: 15px;
  font-weight: 700;
}

.holding-profit {
  font-size: 11px;
  font-weight: 600;
}

/* 预算页 */
.budget-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 14px;
}

.budget-input-row > span {
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
}

.budget-input-row input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font-size: 26px;
  font-weight: 700;
  padding: 8px 0;
  min-width: 0;
}

.budget-input-row.sm {
  padding: 2px 12px;
  margin-top: 8px;
}

.budget-input-row.sm > span {
  font-size: 14px;
}

.budget-input-row.sm input {
  font-size: 15px;
  font-weight: 600;
  padding: 7px 0;
}

.budget-cat {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.budget-cat:last-child {
  border-bottom: 0;
  padding-bottom: 4px;
}

.budget-cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.budget-cat .progress {
  margin-top: 8px;
}

.cat-manage-list {
  padding: 4px 14px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.file-pick {
  position: relative;
  display: block;
}

.file-pick-input {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  font-size: 0;
}

.menu-row + .file-pick > .menu-row,
.file-pick + .menu-row {
  border-top: 1px solid var(--line);
}

.file-native {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.file-native::file-selector-button {
  margin-right: 12px;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
}

.summary-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
}
