﻿:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #8a94a6;
  --line: #e8ecf2;
  --primary: #ff5a36;
  --primary-d: #e8431f;
  --green: #16a34a;
  --red: #ef4444;
  --blue: #2563eb;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(24, 39, 75, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; }
input, select, button { font-size: 15px; }

/* ---------- Auth ---------- */
.auth-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(150deg, #ffe6dc 0%, #f2f4f7 45%, #dbeafe 100%);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 26px;
  box-shadow: 0 10px 40px rgba(24,39,75,.12);
}
.auth-logo { font-size: 40px; text-align: center; }
.auth-title { text-align: center; font-size: 22px; margin-top: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 20px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 9px 0;
  border-radius: 8px; color: var(--muted); font-weight: 500;
}
.auth-tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------- form fields ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
.field.inline > span { margin: 0; white-space: nowrap; }
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=month], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  color: var(--text);
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,90,54,.12); background: #fff; }
input[type=color] { padding: 2px; height: 40px; width: 48px; }
.amount-wrap { display: flex; align-items: center; gap: 8px; }
.amount-wrap .cny { font-size: 26px; font-weight: 700; color: var(--primary); }
.field.big .amount-wrap input { font-size: 26px; font-weight: 700; padding: 8px 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff; color: var(--text);
  padding: 10px 16px; border-radius: 10px;
  font-weight: 500; transition: all .15s;
}
.btn:hover { border-color: #cfd6e2; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { background: #fff; border-color: #ffd0d0; color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(0,0,0,.04); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 9px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 18px; }
.hint.ok { color: var(--green); }
.hint.err { color: var(--red); }
.muted { color: var(--muted); font-size: 13.5px; }
.auth-msg { font-size: 13px; margin-top: 10px; min-height: 18px; text-align: center; }
.auth-msg.err { color: var(--red); }
.auth-msg.ok { color: var(--green); }

/* ---------- App layout ---------- */
.app { min-height: 100vh; padding-bottom: 30px; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; color: var(--muted); }

.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 10px 12px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 52px; z-index: 19;
}
.tab {
  border: none; background: transparent;
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); white-space: nowrap; font-size: 14px;
}
.tab.active { background: rgba(255,90,54,.1); color: var(--primary); font-weight: 600; }

.content { max-width: 900px; margin: 0 auto; padding: 16px; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

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

/* ---------- segmented ---------- */
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 10px 0; border-radius: 8px; color: var(--muted); font-weight: 600; }
.seg-btn.active { background: #fff; box-shadow: var(--shadow); }
.seg-btn.active[data-type=expense] { color: var(--red); }
.seg-btn.active[data-type=income] { color: var(--green); }

/* ---------- category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.cat-chip {
  border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 10px 4px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all .12s;
}
.cat-chip .ic { font-size: 20px; }
.cat-chip .nm { font-size: 12px; color: var(--muted); }
.cat-chip.active { border-color: var(--primary); background: rgba(255,90,54,.07); }
.cat-chip.active .nm { color: var(--primary); }

/* ---------- list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=date] { width: auto; }
.filters input[type=text] { flex: 1; min-width: 130px; }
.filters select { width: auto; }
.tilde { color: var(--muted); }
.list-summary { display: flex; gap: 18px; flex-wrap: wrap; margin: 16px 0 6px; font-size: 14px; }
.list-summary b.in { color: var(--green); }
.list-summary b.ex { color: var(--red); }

.tx-list { margin-top: 8px; }
.tx-day { margin-top: 14px; }
.tx-day-head {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--muted);
  padding: 4px 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.tx-item:last-child { border-bottom: none; }
.tx-ic {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; background: var(--bg);
}
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 500; }
.tx-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-tag { display: inline-block; background: #eef2f8; color: #5b6b86; border-radius: 6px; padding: 0 6px; font-size: 11px; margin-right: 4px; }
.tx-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.in { color: var(--green); }
.tx-amt.ex { color: var(--text); }
.tx-del { border: none; background: transparent; color: #ccc; font-size: 18px; padding: 0 4px; }
.tx-del:hover { color: var(--red); }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }
.pager button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 14px; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager span { font-size: 13px; color: var(--muted); }

/* ---------- stats ---------- */
.stats-head { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; }
.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box { background: var(--bg); border-radius: 12px; padding: 10px 16px; min-width: 100px; }
.stat-box .lbl { font-size: 12px; color: var(--muted); }
.stat-box .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-box.inc .val { color: var(--green); }
.stat-box.exp .val { color: var(--red); }
.chart-box { position: relative; height: 300px; }
.cat-rank { display: flex; flex-direction: column; gap: 12px; }
.rank-row { }
.rank-top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.rank-bar { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 6px; }

/* ---------- budget ---------- */
.budget-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.bud-row { }
.bud-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 14px; }
.bud-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.bud-num.over { color: var(--red); font-weight: 600; }
.bud-bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bud-fill { height: 100%; border-radius: 6px; transition: width .3s; }
.budget-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.budget-add select, .budget-add input[type=text] { width: auto; min-width: 130px; flex: 0 0 auto; }
.budget-add input[type=number] { width: 140px; }

/* ---------- settings ---------- */
.cat-manage { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.cm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cm-ic { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--bg); font-size: 17px; }
.cm-name { flex: 1; }
.cm-type { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.mem-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.mem-av { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#ffb199,#ff5a36); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,26,38,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none !important; }
.modal-card { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 400px; max-height: 90vh; overflow: auto; }
.modal-card h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(31,36,48,.92); color: #fff; padding: 10px 20px;
  border-radius: 10px; font-size: 14px; z-index: 100; animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

@media (max-width: 600px) {
  .content { padding: 12px; }
  .card { padding: 15px; }
  .row2 { grid-template-columns: 1fr; }
  .stat-cards { width: 100%; }
  .tabs { top: 48px; }
  .topbar { padding: 10px 14px; }
}
/* ---------- 汇率换算 ---------- */
.fx-wrap { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.fx-row { display: flex; align-items: center; gap: 10px; }
.fx-arrow { color: var(--muted); font-size: 18px; flex-shrink: 0; }
.fx-wrap select { flex: 1; }
.fx-wrap input[type=number] { flex: 1; }
.fx-result { font-size: 20px; font-weight: 600; color: var(--primary); padding: 6px 0; }
/* ---------- 宠物养成 ---------- */
.pet-card { text-align: center; max-width: 440px; margin: 0 auto; }
.pet-stage { display: flex; justify-content: center; padding: 10px 0 4px; }
.cat-bob { animation: catBob 2.6s ease-in-out infinite; }
@keyframes catBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.pet-name-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 2px; }
.pet-name { font-size: 20px; font-weight: 700; }
.pet-level-row { display: flex; align-items: baseline; justify-content: center; gap: 8px; margin: 4px 0 12px; }
.pet-title { font-size: 14px; color: var(--muted); }
.pet-level { font-size: 15px; font-weight: 600; color: var(--primary); }
.pet-exp { max-width: 320px; margin: 0 auto; }
.pet-exp-bar { height: 12px; background: #ececec; border-radius: 8px; overflow: hidden; }
.pet-exp-fill { height: 100%; width: 0; background: linear-gradient(90deg,#7ed957,#52b788); transition: width .4s ease; }
.pet-exp-text { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pet-info { margin-top: 14px; font-size: 14px; }
/* ---------- 宠物动画 ---------- */
.pet-stage-wrap { position: relative; display: flex; justify-content: center; padding: 6px 0 4px; }
.pet-style-toggle { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
.seg { border: 1px solid var(--line); background: #fff; color: var(--muted); padding: 6px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; transition: all .15s; }
.seg:hover { border-color: var(--primary); }
.seg.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cat-bob { transform-box: fill-box; transform-origin: center; animation: catBob 2.6s ease-in-out infinite; }
@keyframes catBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.cat-tail { transform-box: view-box; transform-origin: 150px 150px; animation: catTail 2.4s ease-in-out infinite; }
@keyframes catTail { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }

.cat-head { transform-box: fill-box; transform-origin: center; animation: catSway 5s ease-in-out infinite; }
@keyframes catSway { 0%,100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }

.cat-eyes .eye { transform-box: fill-box; transform-origin: center; animation: catBlink 4.2s infinite; }
@keyframes catBlink { 0%,90%,100% { transform: scaleY(1); } 94% { transform: scaleY(.1); } 97% { transform: scaleY(1); } }

.cat-pixel .peye { animation: catBlinkPx 4.2s infinite; }
@keyframes catBlinkPx { 0%,90%,100% { opacity: 1; } 94% { opacity: .12; } 97% { opacity: 1; } }

.cat-shadow { transform-box: fill-box; transform-origin: center; animation: catShadow 2.6s ease-in-out infinite; }
@keyframes catShadow { 0%,100% { transform: scale(1); opacity: .10; } 50% { transform: scale(.86); opacity: .07; } }

/* 升级庆祝 */
.pet-stage-wrap.levelup .pet-body { animation: catPop .65s ease; }
@keyframes catPop { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-18px) scale(1.12); } 60% { transform: translateY(0) scale(.96); } 100% { transform: translateY(0) scale(1); } }
.pet-sparkles { position: absolute; inset: 0; pointer-events: none; }
.pet-sparkles span { position: absolute; font-size: 22px; animation: sparkle 1.4s ease forwards; transform: translate(-50%,-50%); }
@keyframes sparkle { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.3) rotate(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-160%) scale(1.2) rotate(40deg); } }
/* ---------- 罗小黑风动画补充 ---------- */
.cat-ear { transform-box: fill-box; transform-origin: 50% 92%; animation: catEar 6s ease-in-out infinite; }
.cat-ear-r { animation-delay: -3s; }
@keyframes catEar { 0%,86%,100% { transform: rotate(0); } 90% { transform: rotate(-3.5deg); } 94% { transform: rotate(2.5deg); } 97% { transform: rotate(0); } }

.cat-look { transform-box: fill-box; transform-origin: center; animation: catLook 7s ease-in-out infinite; }
@keyframes catLook { 0%,42%,100% { transform: translateX(0); } 56% { transform: translateX(-2.6px); } 72% { transform: translateX(2.6px); } 86% { transform: translateX(0); } }
/* ---------- 宠物 SVG 版（萨摩耶，毛绒绒 + 多部位动画） ---------- */
.pet-svg { width: 220px; height: 220px; display: block; }
.pet-body { transform-origin: 100px 200px; animation: petBreath 3s ease-in-out infinite; }
@keyframes petBreath { 0%,100% { transform: scaleY(1) translateY(0); } 50% { transform: scaleY(1.035) translateY(-3px); } }

.pet-head { transform-origin: 100px 145px; animation: petSway 4.5s ease-in-out infinite; }
@keyframes petSway { 0%,100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-1px); } }

.pet-ear-l { transform-origin: 70px 84px; animation: petEarL 2.4s ease-in-out infinite; }
.pet-ear-r { transform-origin: 130px 84px; animation: petEarR 2.4s ease-in-out infinite; }
@keyframes petEarL { 0%,100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes petEarR { 0%,100% { transform: rotate(7deg); } 50% { transform: rotate(-7deg); } }

.pet-eye-l, .pet-eye-r { transform-box: fill-box; transform-origin: center; animation: petBlink 5s infinite; }
@keyframes petBlink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(0.08); } }

.pet-tail { transform-origin: 152px 162px; animation: petTail 0.45s ease-in-out infinite alternate; }
@keyframes petTail { 0% { transform: rotate(-22deg); } 100% { transform: rotate(22deg); } }

.pet-tongue { transform-box: fill-box; transform-origin: center; animation: petTongue 4.5s infinite; }
@keyframes petTongue { 0%,75%,100% { transform: scale(0); } 82%,92% { transform: scale(1); } }

.pet-shadow { transform-origin: 100px 208px; animation: petShadow 3s ease-in-out infinite; }
@keyframes petShadow { 0%,100% { transform: scaleX(1); opacity: .13; } 50% { transform: scaleX(.85); opacity: .07; } }

.pet-collar { display: none; }
.pet-lv-2 .pet-collar, .pet-lv-3 .pet-collar, .pet-lv-4 .pet-collar { display: block; }