:root {
  --bg: #f4f4f4;
  --surface: #ffffff;
  --ink: #111111;
  --ink-2: #3a3a3a;
  --muted: #7a7a7a;
  --line: #e2e2e2;
  --accent: #1a6b63;
  --warn: #8a5a00;
  --danger: #b42318;
  --ok: #1b6b3a;
  --tab-h: 52px;
  --header-h: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

button, input, select { font-family: inherit; }

#app, .app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.app-header {
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.brand-text { line-height: 1.15; }
.brand-text strong { display: block; font-size: 15px; font-weight: 600; }
.brand-text small { color: var(--muted); font-size: 11px; font-weight: 400; }

.app-header .icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 16px;
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--tab-h) + var(--safe-b) + 16px);
}

.app-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 30;
}

.tab-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  text-decoration: none;
  min-height: var(--tab-h);
}
.tab-item i { font-size: 18px; line-height: 1; }
.tab-item.active { color: var(--ink); font-weight: 600; }

.hero-card {
  background: var(--accent);
  color: #fff;
  padding: 16px;
  margin: 0 -16px 16px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.eyebrow { font-size: 12px; opacity: 0.85; }

.balance {
  font-size: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.balance-hint {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.75;
}

.hero-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,.25);
}

.hero-meta .cell { padding: 12px 0 0; }
.hero-meta .cell + .cell {
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.25);
}
.hero-meta .k { font-size: 11px; opacity: 0.75; }
.hero-meta .v {
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.seg {
  display: inline-flex;
  border: 1px solid rgba(255,255,255,.45);
}
.seg button {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 4px 10px;
  font-size: 12px;
}
.seg button.on {
  background: #fff;
  color: var(--accent);
}

.quick-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 16px;
}

.quick-btn {
  padding: 14px 4px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  border-right: 1px solid var(--line);
}
.quick-btn:last-child { border-right: 0; }
.quick-btn i {
  display: block;
  font-size: 18px;
  color: var(--accent);
  margin-bottom: 6px;
}
.quick-btn span { font-size: 12px; }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
}
.section-label h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.section-label a {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.card-desc {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--ink);
  flex: 0 0 auto;
  font-size: 15px;
}

.list-main { flex: 1; min-width: 0; }
.list-main .t { font-weight: 600; font-size: 14px; }
.list-main .s {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-side { text-align: right; flex: 0 0 auto; }
.list-side .amt {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.list-side .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.list-side .btn-mini { margin-bottom: 4px; }

.badge { display: inline-block; font-size: 11px; color: var(--muted); }
.badge-ok { color: var(--ok); }
.badge-warn { color: var(--warn); }
.badge-mute { color: var(--muted); }

.money-pos { color: var(--ok); }
.money-neg { color: var(--danger); }

.amount-display {
  text-align: center;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.amount-display .currency {
  color: var(--muted);
  font-size: 16px;
  margin-right: 4px;
}
.amount-display input {
  border: 0;
  outline: none;
  background: transparent;
  width: min(100%, 260px);
  text-align: center;
  font-size: 36px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.amount-display input::placeholder { color: #c8c8c8; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
  padding: 10px 0;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
.field input:focus,
.field select:focus {
  border-bottom-color: var(--ink);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-2);
}
.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-block {
  width: 100%;
  border: 0;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
}
.btn-ghost {
  width: 100%;
  border: 1px solid var(--ink);
  background: transparent;
  padding: 11px 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.btn-danger-soft {
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 4px 0 0;
  font-size: 12px;
}
.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2px;
}
.row-actions .btn-danger-soft { padding: 0; }

.plan-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.plan-seg button {
  border: 0;
  background: var(--surface);
  padding: 12px 10px;
  text-align: left;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.plan-seg button:nth-child(2n) { border-right: 0; }
.plan-seg button.on {
  background: var(--ink);
  color: #fff;
}
.plan-seg button.on .sc { color: rgba(255,255,255,.7); }
.plan-seg .g { font-size: 13px; font-weight: 600; }
.plan-seg .sc { font-size: 11px; color: var(--muted); margin-top: 2px; }

.summary-box {
  background: var(--bg);
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 12px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.step {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; padding-bottom: 0; }
.step .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
.step .reason { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.45; }

.toast-error {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.empty {
  text-align: center;
  padding: 24px 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.empty i { display: none; }
.empty p { margin: 0; }

.cat-row { margin-bottom: 12px; }
.cat-row:last-child { margin-bottom: 0; }
.cat-row-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}
.cat-row-top span { color: var(--ink-2); }
.cat-row-top strong { font-variant-numeric: tabular-nums; font-weight: 600; }

.cat-bar {
  height: 2px;
  background: var(--line);
}
.cat-bar > span {
  display: block;
  height: 100%;
  background: var(--ink);
}
.cat-bar[data-status="over"] > span { background: var(--danger); }
.cat-bar[data-status="tight"] > span { background: var(--warn); }
.cat-bar[data-status="ok"] > span { background: var(--ok); }

.save-banner {
  border-color: var(--ok);
}

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  text-decoration: none;
  color: inherit;
}
.link-row + .link-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.link-row .chev {
  color: var(--muted);
  font-size: 14px;
  flex: 0 0 auto;
}

.mine-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mine-avatar {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex: 0 0 auto;
}
.mine-hero .t { font-size: 16px; font-weight: 600; }
.mine-hero .s { margin-top: 4px; font-size: 12px; color: var(--muted); }

.mine-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.mine-stats .cell {
  background: var(--surface);
  padding: 14px;
}
.mine-stats .k { font-size: 11px; color: var(--muted); }
.mine-stats .v {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card-title .text-link {
  width: auto;
  padding: 0;
  text-align: right;
}

.toolbar .btn-ghost {
  width: auto;
  display: inline-block;
  padding: 8px 14px;
  margin: 0;
}

.loading-bar {
  height: 1px;
  background: var(--ink);
  margin: 0 0 12px;
}

.toast-ok {
  background: #fff;
  color: var(--ok);
  border: 1px solid var(--ok);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 20px 16px;
}
.check-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.check-row input { margin-top: 2px; }

.lb-me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lb-score {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent, #1a6b63);
  white-space: nowrap;
}
.lb-rank {
  width: 28px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.lb-me-row {
  background: color-mix(in srgb, var(--accent, #1a6b63) 8%, transparent);
}
.muted { color: var(--muted); font-size: 12px; font-weight: 400; }

.seg-link {
  color: #fff;
  font-size: 12px;
  text-decoration: underline;
  opacity: 0.9;
}

.today-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.25);
}
.today-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
}
.today-row strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.today-box .cat-bar {
  margin-top: 8px;
  background: rgba(255,255,255,.25);
  height: 3px;
}
.today-box .cat-bar > span { background: #fff; }
.today-meta {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.8;
}

.pool-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.pool-cell {
  background: var(--surface);
  padding: 12px 10px;
}
.pool-cell .k { font-size: 11px; color: var(--muted); }
.pool-cell .v {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pool-cell .s { margin-top: 4px; font-size: 10px; color: var(--muted); }

.cat-tile {
  border: 0;
  background: var(--surface);
  padding: 14px 6px;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.cat-tile .cat-name { font-size: 14px; }
.cat-tile small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

.field select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
  padding: 10px 0;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  padding: 10px 0 0;
  width: 100%;
  text-align: center;
}

.toolbar {
  margin-bottom: 12px;
}

.btn-mini {
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 auto;
}

.tip-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.tip-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px 14px;
}

.tip-card[data-level="danger"] { border-color: var(--danger); }
.tip-card[data-level="warn"] { border-color: var(--warn); }
.tip-card[data-level="ok"] { border-color: var(--ok); }

.tip-title { font-size: 14px; font-weight: 600; }
.tip-body { margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.tip-action {
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
}

.preset-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.preset {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 6px 12px;
  font-size: 13px;
}
