:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --sub: #86868b;
  --line: rgba(0, 0, 0, 0.07);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.10);
  --expense: #e5484d;
  --income: #12805c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --sub: #98989d;
    --line: rgba(255, 255, 255, 0.09);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --expense: #ff6961;
    --income: #32d74b;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: env(safe-area-inset-bottom); }

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ---------- 顶部月份 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 0 12px;
}

.month-label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  min-width: 108px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.month-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sub);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.month-btn:hover { background: var(--line); color: var(--text); }
.month-btn:active { transform: scale(0.94); }

/* ---------- 概览 ---------- */

.overview {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.ov-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.ov-label {
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 4px;
}

.ov-amount {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.ov-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  padding-bottom: 3px;
  flex-shrink: 0;
}

.ov-item { display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; }
.ov-k { font-size: 12px; color: var(--sub); }
.ov-v { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ov-v.income { color: var(--income); }
.ov-v.minus { color: var(--sub); }

.budget-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  margin-top: 16px;
  overflow: hidden;
}

.budget-track-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.35s ease, background 0.2s;
}
.budget-track-fill.warn { background: #f5a524; }
.budget-track-fill.over { background: var(--expense); }

.budget-hint {
  font-size: 12px;
  color: var(--sub);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.budget-hint.over { color: var(--expense); }

/* ---------- Tab ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--line);
  padding: 3px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--sub);
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}

.tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel { display: none; }
.panel.active { display: block; animation: fade 0.18s ease; }

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

/* ---------- 记一笔 ---------- */

.type-switch {
  display: flex;
  gap: 4px;
  background: var(--line);
  padding: 3px;
  border-radius: 11px;
  width: 252px;
  margin: 0 auto 6px;
}

.type-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 0;
  font-size: 14px;
  color: var(--sub);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
}

.type-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.amount-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.currency {
  font-size: 24px;
  color: var(--sub);
  font-weight: 400;
  align-self: center;
  padding-top: 6px;
}

.amount-input {
  border: none;
  background: transparent;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  width: 68%;
  text-align: center;
  outline: none;
  padding: 0;
}
.amount-input::placeholder { color: var(--sub); opacity: 0.35; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.cat-grid[hidden] { display: none; }

/* ---------- 还款 ---------- */

.repay-box {
  margin-bottom: 18px;
  padding: 12px;
  border-radius: 14px;
  background: var(--accent-soft);
}

.repay-box[hidden] { display: none; }

.repay-label {
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 6px;
}

.repay-box .field-select {
  width: 100%;
  background-color: var(--card);
  color: var(--text);
  font-weight: 500;
}

.repay-split {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.repay-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.repay-lb { font-size: 11.5px; color: var(--sub); padding-left: 2px; }

.repay-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-family: inherit;
  text-align: right;
  padding: 8px 10px;
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s;
}

.repay-input:focus { border-color: var(--accent); }
.repay-input[readonly] { color: var(--sub); background: transparent; border-style: dashed; }

.repay-preview {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--sub);
}

.repay-preview b { color: var(--text); font-variant-numeric: tabular-nums; }
.repay-preview .hit { color: var(--expense); }

.tx-amount.repay { color: var(--expense); }

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 4px 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow);
}

.cat-btn .cat-icon { font-size: 21px; line-height: 1.1; }
.cat-btn .cat-name {
  font-size: 11.5px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cat-btn:active { transform: scale(0.95); }

.cat-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.cat-btn.active .cat-name { color: var(--accent); font-weight: 600; }

.meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.field {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--sub); opacity: 0.7; }
.field-date { flex: 0 0 42%; }

.field-select {
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--sub) 50%),
    linear-gradient(135deg, var(--sub) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
  color: var(--sub);
  cursor: pointer;
}

.save-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  border-radius: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.save-btn:hover { opacity: 0.9; }
.save-btn:active { transform: scale(0.985); }

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.ghost-btn:hover { background: var(--line); }
.ghost-btn.danger { color: var(--expense); }
.ghost-btn.full { width: 100%; margin-top: 10px; }

/* ---------- 明细 ---------- */

.day-group { margin-bottom: 22px; }

.day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px 8px;
  font-size: 12.5px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}

.day-head .day-sum { font-weight: 500; }

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

.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.14s;
}
.tx-item:last-child { border-bottom: none; }
.tx-item:hover { background: var(--accent-soft); }

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

.tx-mid { flex: 1; min-width: 0; }
.tx-cat { font-size: 14.5px; font-weight: 500; }
.tx-note {
  font-size: 12.5px;
  color: var(--sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.tx-amount {
  font-size: 15.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.tx-amount.expense { color: var(--text); }
.tx-amount.income { color: var(--income); }

.empty {
  text-align: center;
  color: var(--sub);
  font-size: 14px;
  padding: 56px 20px;
  line-height: 1.9;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: 0.5; }

/* ---------- 预算 ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--sub); }

.budget-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.currency-sm { color: var(--sub); font-size: 16px; }
.field-budget { font-size: 18px; font-weight: 600; padding: 10px 12px; }

.bud-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.bud-row:last-child { border-bottom: none; }

.bud-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.bud-mid { flex: 1; min-width: 0; }
.bud-name { font-size: 14px; font-weight: 500; margin-bottom: 5px; }
.bud-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.bud-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.3s ease;
}
.bud-bar-fill.warn { background: #f5a524; }
.bud-bar-fill.over { background: var(--expense); }

.bud-spent {
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.bud-spent.over { color: var(--expense); }

.bud-input {
  width: 92px;
  flex-shrink: 0;
  text-align: right;
  padding: 7px 9px;
  font-size: 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.bud-input:focus { border-color: var(--accent); }
.bud-input::placeholder { color: var(--sub); opacity: 0.6; }

.data-actions { display: flex; gap: 8px; }
.data-actions .ghost-btn { flex: 1; text-align: center; }

.footnote {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.65;
  margin: 12px 0 0;
}

/* ---------- Sheet ---------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: maskIn 0.18s ease;
}
.sheet-mask[hidden] { display: none; }

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

.sheet {
  width: 100%;
  max-width: 620px;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}

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

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

.sheet-body { padding-bottom: 16px; }

.sheet-title {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.sheet-meta { font-size: 13px; color: var(--sub); line-height: 1.7; }

.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .ghost-btn { flex: 1; padding: 13px; font-size: 15px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translate(-50%, 14px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  backdrop-filter: blur(8px);
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 资产负债表 ---------- */

.ov-v.expense { color: var(--expense); }

.bs-pair {
  display: flex;
  gap: 22px;
  margin-top: 14px;
}
.bs-pair .ov-item { justify-content: flex-start; }

.bs-compare { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }

.bs-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.bs-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.bs-bar-fill.income { background: var(--income); }
.bs-bar-fill.expense { background: var(--expense); }

.bs-name {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 7px 8px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.bs-name:hover { background: var(--accent-soft); }
.bs-name:focus { border-color: var(--accent); background: var(--card); }

/* ---------- 资产条目：基线 + 变动流水 ---------- */

.as-item {
  padding: 2px 0;
  border-bottom: 1px solid var(--line);
}
.as-item:last-child { border-bottom: none; }

.as-main {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.as-bal {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  letter-spacing: -0.2px;
}

.as-toggle {
  border: none;
  background: transparent;
  color: var(--sub);
  font-size: 11.5px;
  font-family: inherit;
  padding: 4px 7px;
  border-radius: 7px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: background 0.15s, color 0.15s;
}
.as-toggle:hover { background: var(--accent-soft); color: var(--accent); }
.as-caret { font-size: 9px; opacity: 0.7; }

.as-sub {
  font-size: 11.5px;
  color: var(--sub);
  padding: 0 8px 6px;
  font-variant-numeric: tabular-nums;
}
.as-sub .up { color: var(--income); }
.as-sub .down { color: var(--expense); }

.as-edit {
  margin: 2px 0 12px;
  padding: 12px;
  background: var(--line);
  border-radius: 12px;
}

.as-base-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.as-changes { max-height: 220px; overflow-y: auto; }

.as-ch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.as-ch:last-child { border-bottom: none; }

.as-ch-date { color: var(--sub); font-size: 11.5px; flex-shrink: 0; }
.as-ch-note {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-ch-amt { flex-shrink: 0; font-weight: 500; }
.as-ch-amt.up { color: var(--income); }
.as-ch-amt.down { color: var(--expense); }

.as-ch-del {
  width: 20px; height: 20px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--sub);
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
}
.as-ch-del:hover { background: var(--line); color: var(--expense); }

.as-ch-empty {
  font-size: 12px;
  color: var(--sub);
  padding: 6px 0;
  line-height: 1.65;
}

.as-add-row {
  display: grid;
  grid-template-columns: 124px 92px 1fr 50px;
  gap: 6px;
  margin-top: 10px;
}

.as-add-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 9px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.as-add-btn:hover { background: var(--accent); color: #fff; }

.as-account {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--sub);
  margin-top: 12px;
  cursor: pointer;
}
.as-account input { accent-color: var(--accent); }

.as-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 5px;
  vertical-align: 1px;
  font-weight: 500;
}

.bs-add {
  width: 100%;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--sub);
  font-size: 13.5px;
  font-family: inherit;
  padding: 10px;
  border-radius: 11px;
  cursor: pointer;
  margin-top: 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.bs-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.bs-hist-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.bs-hist-row:last-child { border-bottom: none; }
.bs-hist-date { font-size: 13.5px; color: var(--sub); }
.bs-hist-right { text-align: right; }
.bs-hist-net { font-size: 14.5px; font-weight: 600; }
.bs-hist-delta { font-size: 11.5px; margin-left: 8px; }
.bs-hist-delta.up { color: var(--income); }
.bs-hist-delta.down { color: var(--expense); }
.bs-hist-empty { font-size: 13px; color: var(--sub); padding: 8px 0 12px; }

/* ---------- 贷款 / 负债卡片 ---------- */

.bs-kpi {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 12px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}
.bs-kpi b { color: var(--text); font-weight: 600; }

.loan {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.loan:last-child { border-bottom: none; }

.loan-head { cursor: pointer; }
.loan-head:hover .loan-name { color: var(--accent); }

.loan-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.loan-name { font-size: 14.5px; font-weight: 500; transition: color 0.15s; }

.loan-rate {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  white-space: nowrap;
}
.loan-rate.warn {
  background: rgba(229, 72, 77, 0.13);
  color: var(--expense);
}
.loan-rate.pending {
  background: var(--line);
  color: var(--sub);
  font-weight: 400;
}

.loan-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12.5px;
  color: var(--sub);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.loan-meta b { color: var(--text); font-weight: 500; }

.loan-due {
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.loan-due.soon { color: var(--expense); }

.loan-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.lf { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lf.full { grid-column: 1 / -1; }
.lf-label { font-size: 11px; color: var(--sub); padding-left: 2px; }

.lf-input {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  padding: 8px 9px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  width: 100%;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}
.lf-input:focus { border-color: var(--accent); }
.lf-input::placeholder { color: var(--sub); opacity: 0.6; }

.loan-result {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.75;
  background: var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-variant-numeric: tabular-nums;
}
.loan-result b { color: var(--text); font-size: 13px; }
.loan-result .hit { color: var(--expense); }
.loan-result .good { color: var(--income); }

.loan-del {
  grid-column: 1 / -1;
  border: none;
  background: transparent;
  color: var(--expense);
  font-size: 13px;
  font-family: inherit;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  margin-top: 2px;
}
.loan-del:hover { background: rgba(229, 72, 77, 0.09); }

.loan-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
}
.loan-summary b { color: var(--text); font-weight: 600; font-size: 13.5px; }

/* ---------- 桌面横向布局（≥960px 生效，手机版式不受影响） ---------- */

@media (min-width: 960px) {
  .app {
    max-width: 1180px;
    padding: 0 28px 56px;
  }

  .topbar { padding-top: 26px; }
  .overview { padding: 24px 26px; }
  .ov-amount { font-size: 38px; }

  /* 记一笔：左（金额+分类）右（还款/日期/保存）两栏 */
  #panel-entry.active {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    column-gap: 36px;
    align-items: start;
  }
  .entry-left, .entry-right { min-width: 0; }
  .entry-right { padding-top: 10px; }
  .type-switch { width: 288px; margin: 0 0 6px; }
  .cat-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
  }
  .cat-btn { padding: 15px 4px 13px; }
  .cat-btn .cat-icon { font-size: 24px; }
  .cat-btn .cat-name { font-size: 12.5px; }
  .amount-row { justify-content: center; padding: 26px 0 28px; }

  /* 预算：分类预算宽栏在左，总预算 + 备份窄栏在右 */
  #panel-budget.active {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    column-gap: 24px;
    align-items: start;
  }
  .budget-main, .budget-side { min-width: 0; }

  /* 资产：资产 / 负债 并排，概览与净值记录全宽 */
  .asset-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 24px;
    align-items: start;
  }

  /* 明细在宽屏下也放开宽度，行内信息更舒展 */
  .tx-item { padding: 14px 18px; }
  .tx-cat { font-size: 15px; }
  .tx-amount { font-size: 16px; }

  /* 弹层改为居中浮窗 */
  .sheet-mask { align-items: center; }
  .sheet {
    max-width: 480px;
    border-radius: 20px;
    padding-bottom: 20px;
    animation: popIn 0.2s ease;
  }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 数据存储状态 ---------- */

.storage-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--line);
  color: var(--sub);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.storage-status.ok {
  background: rgba(18, 128, 92, 0.10);
  color: var(--income);
}
.storage-status.warn {
  background: rgba(245, 165, 36, 0.12);
  color: #a86a00;
}
@media (prefers-color-scheme: dark) {
  .storage-status.warn { color: #f5a524; }
}

.storage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  margin-top: 6px;
}

.ghost-btn.full-soft {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 8px;
}

/* ---------- 每月最低还款 ---------- */

.minrepay-hero {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.minrepay-amount {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.minrepay-tag {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--line);
  color: var(--sub);
  flex-shrink: 0;
}
.minrepay-tag.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.minrepay-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.minrepay-row:last-child { border-bottom: none; }

.minrepay-mid { flex: 1; min-width: 0; }
.minrepay-name { font-size: 13.5px; font-weight: 500; }
.minrepay-note {
  font-size: 11px;
  color: var(--sub);
  margin-top: 1px;
  line-height: 1.5;
}

.minrepay-method {
  font-size: 10px;
  color: var(--sub);
  background: var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.minrepay-amt {
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.minrepay-empty {
  font-size: 12.5px;
  color: var(--sub);
  padding: 2px 0 10px;
  line-height: 1.7;
}

.minrepay-hint {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.75;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.minrepay-hint .hit { color: var(--expense); }

@media (max-width: 480px) {
  .as-add-row { grid-template-columns: 1fr 1fr; }
  .as-new-note { grid-column: 1 / -1; }
  .as-add-btn { grid-column: 1 / -1; padding: 8px; }
}

@media (max-width: 380px) {
  .ov-amount { font-size: 30px; }
  .amount-input { font-size: 38px; }
  .bud-input { width: 78px; }
  .as-bal { font-size: 13px; }
}

/* ---------- 分类预算：汇总 / 自动「其他」/ 自定义分类 ---------- */

.card-action {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.card-action:hover { filter: brightness(1.08); }
.card-action:active { transform: scale(0.97); }

.bud-auto {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 1px 5px;
  margin-left: 2px;
  vertical-align: 1px;
}

.bud-input.auto {
  color: var(--sub);
  background: var(--line);
  border-style: dashed;
  cursor: default;
}

.bud-del {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sub);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.bud-del:hover { color: var(--expense); background: var(--line); }

.bud-summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.bud-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
}
.bud-summary-note { color: var(--accent); font-weight: 500; white-space: nowrap; }
.bud-summary-note.over { color: var(--expense); }
.bud-summary-note.dim { color: var(--sub); font-weight: 400; }

/* 添加分类弹层 */
.cat-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.cat-form-field { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.cat-form-lb { font-size: 12px; color: var(--sub); }
.cat-form-field .field { width: 100%; }
.cat-form-icon {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 22px;
  text-align: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.cat-form-icon:focus { border-color: var(--accent); }

.ghost-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ghost-btn.primary:hover { filter: brightness(1.08); background: var(--accent); }

/* ---------- 应用内确认弹层（替代原生 confirm） ---------- */

.confirm-text {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
}
.confirm-sheet .sheet-actions { gap: 10px; }

/* ---------- 数据安全 / 版本号 / 多按钮确认弹层 ---------- */

.safety-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  background: var(--line);
}
.safety-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.safety-title { font-size: 13px; font-weight: 600; }
.safety-info { font-size: 11.5px; color: var(--sub); font-variant-numeric: tabular-nums; }
.safety-warn {
  font-size: 12px;
  line-height: 1.6;
  color: var(--expense);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.safety-box .ghost-btn { width: 100%; background: var(--card); }

.app-version {
  text-align: center;
  font-size: 11px;
  color: var(--sub);
  opacity: 0.75;
  padding: 6px 0 18px;
  font-variant-numeric: tabular-nums;
}

/* 恢复备份时按钮较多，允许换行 */
.confirm-sheet .sheet-actions { flex-wrap: wrap; }
.confirm-sheet .sheet-actions .ghost-btn { flex: 1 1 44%; }

/* ---------- v1.1：信用卡负债 + 首页 10 日前需还款 ---------- */

.loan-rate.good {
  background: rgba(52, 168, 83, 0.12);
  color: var(--income, #1e9e55);
  font-weight: 500;
}

.lf-note {
  grid-column: 1 / -1;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--sub);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 10px;
}
.lf-note b { color: var(--text); }

.ov-due {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}
.ov-due-k {
  font-size: 12px;
  color: var(--sub);
  flex-shrink: 0;
}
.ov-due-v {
  font-size: 16px;
  font-weight: 600;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.ov-due-v.on { color: var(--expense); }
.ov-due-hint {
  font-size: 11px;
  color: var(--sub);
  opacity: 0.85;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ---------- v1.2：资产二级账户 ---------- */

.as-kids {
  margin: 10px 0 4px;
  padding: 10px 10px 6px;
  border-radius: 12px;
  background: var(--line);
}
.as-kids-title {
  font-size: 11px;
  color: var(--sub);
  margin-bottom: 6px;
}
.as-item.as-child {
  background: var(--card);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.as-item.as-child .bs-name { font-size: 13px; }
.as-item.as-child .as-bal { font-size: 13px; }

.as-sub-add {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.as-sub-add:hover { filter: brightness(1.05); }
.as-sub-add:active { transform: scale(0.98); }
