/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-0: #04070f;
  --bg-1: #081226;
  --card: rgba(17, 31, 56, 0.55);
  --border: rgba(126, 168, 255, 0.14);
  --border-soft: rgba(126, 168, 255, 0.08);
  --text-1: #eaf2ff;
  --text-2: #93aacd;
  --text-3: #5d7497;
  --accent: #56c8ff;
  --accent-2: #6f8bff;
  --danger: #ff7d8a;
  --ok: #57e0ae;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(2, 6, 16, 0.55);
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text-1);
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(64, 84, 255, 0.16), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, rgba(34, 170, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
::selection { background: rgba(86, 200, 255, 0.3); }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ============ 背景装饰 ============ */
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.orb {
  position: absolute;
  width: 46vmax; height: 46vmax;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}
.orb-a {
  top: -18vmax; right: -12vmax;
  background: radial-gradient(circle, rgba(64, 106, 255, 0.5), transparent 65%);
  animation: drift 22s ease-in-out infinite alternate;
}
.orb-b {
  bottom: -20vmax; left: -14vmax;
  background: radial-gradient(circle, rgba(38, 208, 255, 0.34), transparent 65%);
  animation: drift 26s ease-in-out -8s infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vmax, 4vmax, 0) scale(1.12); }
}

.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(120, 150, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 150, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(90% 55% at 50% 0%, #000 25%, transparent 80%);
  mask-image: radial-gradient(90% 55% at 50% 0%, #000 25%, transparent 80%);
}

/* ============ 布局 ============ */
.app {
  position: relative; z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 32px;
  display: flex; flex-direction: column; gap: 18px;
  min-height: 100dvh;
}
main { display: flex; flex-direction: column; gap: 18px; }

.header { text-align: center; padding: 8px 0 4px; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 30px rgba(86, 200, 255, 0.5);
  animation: pulse 2.2s ease-in-out infinite;
}
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: 0.06em; }
.subtitle { margin-top: 8px; color: var(--text-3); font-size: 0.82rem; letter-spacing: 0.18em; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: 0.55; }
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  animation: rise 0.55s cubic-bezier(0.22, 0.68, 0.32, 1) backwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.setup-card   { animation-delay: 0.04s; }
.balance-card { animation-delay: 0.04s; }
.expense-card { animation-delay: 0.16s; }

.card-title { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.03em; }
.card-desc  { color: var(--text-2); font-size: 0.84rem; line-height: 1.7; margin: 10px 0 18px; }

/* ============ 余额区 ============ */
.balance-top { display: flex; align-items: center; justify-content: space-between; }
.balance-label { color: var(--text-2); font-size: 0.86rem; letter-spacing: 0.12em; }

.state-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid; letter-spacing: 0.08em;
}
.state-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.state-badge.ok  { color: var(--ok); border-color: rgba(87, 224, 174, 0.35); background: rgba(87, 224, 174, 0.08); }
.state-badge.bad { color: var(--danger); border-color: rgba(255, 125, 138, 0.35); background: rgba(255, 125, 138, 0.08); }
.state-badge.end { color: var(--text-3); border-color: var(--border); background: rgba(120, 150, 255, 0.05); }
.state-badge.ok::before { animation: pulse 2s ease-in-out infinite; }

.balance {
  margin: 18px 0 6px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.4rem, 10.5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-1);
  animation: breathe 3.6s ease-in-out infinite;
}
.balance .balance-dec { font-size: 0.58em; color: var(--text-2); font-weight: 600; }
.balance.negative { color: var(--danger); animation-name: breathe-red; }
.balance.negative .balance-dec { color: rgba(255, 125, 138, 0.75); }

@keyframes breathe {
  0%, 100% { text-shadow: 0 0 22px rgba(86, 200, 255, 0.22); }
  50%      { text-shadow: 0 0 42px rgba(86, 200, 255, 0.5); }
}
@keyframes breathe-red {
  0%, 100% { text-shadow: 0 0 22px rgba(255, 125, 138, 0.22); }
  50%      { text-shadow: 0 0 42px rgba(255, 125, 138, 0.5); }
}

.balance.bump { animation: bump 0.45s cubic-bezier(0.3, 0.7, 0.4, 1.4), breathe 3.6s ease-in-out infinite; }
.balance.negative.bump { animation: bump 0.45s cubic-bezier(0.3, 0.7, 0.4, 1.4), breathe-red 3.6s ease-in-out infinite; }
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.035); }
  100% { transform: scale(1); }
}

.balance-hint { color: var(--text-3); font-size: 0.8rem; margin-bottom: 18px; }
.balance-hint .num { color: var(--text-2); }

.progress {
  position: relative;
  height: 8px; border-radius: 999px;
  background: rgba(120, 150, 255, 0.12);
}
.progress-fill {
  position: relative;
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(111, 139, 255, 0.9), var(--accent));
  box-shadow: 0 0 14px rgba(86, 200, 255, 0.45);
  transition: width 0.12s linear;
}
.progress-fill::after {
  content: '';
  position: absolute; right: -3px; top: 50%;
  width: 10px; height: 10px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #dff4ff;
  box-shadow: 0 0 12px var(--accent), 0 0 26px rgba(86, 200, 255, 0.6);
}
.progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  color: var(--text-3); font-size: 0.78rem;
}

/* ============ 统计 ============ */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
  animation-delay: 0.1s;
}
.stat:nth-child(2) { animation-delay: 0.14s; }
.stat:nth-child(3) { animation-delay: 0.18s; }
.stat:nth-child(4) { animation-delay: 0.22s; }

.stat-label { color: var(--text-3); font-size: 0.74rem; letter-spacing: 0.1em; }
.stat-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.06rem; font-weight: 700;
  color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value.accent { color: var(--accent); }
.stat-value.danger { color: var(--danger); }

/* ============ 输入 ============ */
.money-input {
  display: flex; align-items: center; gap: 10px;
  background: rgba(5, 12, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.money-input:focus-within {
  border-color: rgba(86, 200, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(86, 200, 255, 0.12);
}
.money-unit { color: var(--accent); font-weight: 700; font-size: 1.15rem; }
.money-input input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--text-1);
  font-family: var(--mono);
  font-size: 1.3rem; font-weight: 600;
}
.money-input input::placeholder { color: var(--text-3); font-weight: 400; }
.money-input.small { padding: 10px 12px; flex: 1; }
.money-input.small input { font-size: 1rem; }

.text-input {
  background: rgba(5, 12, 24, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text-1);
  font-size: 0.9rem;
  outline: none; min-width: 0; flex: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.text-input:focus {
  border-color: rgba(86, 200, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(86, 200, 255, 0.12);
}
.text-input::placeholder { color: var(--text-3); }

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ============ 按钮 / 标签 ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  background: rgba(120, 150, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--text-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s ease;
}
.chip:hover { border-color: rgba(86, 200, 255, 0.4); color: var(--text-1); }
.chip.active {
  background: rgba(86, 200, 255, 0.14);
  border-color: rgba(86, 200, 255, 0.6);
  color: var(--accent);
  box-shadow: 0 0 14px rgba(86, 200, 255, 0.18);
}

.btn {
  border: none; cursor: pointer;
  font-family: inherit; font-weight: 600;
  border-radius: 12px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-primary {
  background: linear-gradient(120deg, #3f9dff, #5f7bff);
  color: #fff;
  padding: 13px 18px;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  box-shadow: 0 8px 24px rgba(63, 157, 255, 0.3);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 10px 30px rgba(63, 157, 255, 0.45);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-block { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 0.74rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
.btn-ghost:hover {
  color: var(--accent);
  border-color: rgba(86, 200, 255, 0.45);
  background: rgba(86, 200, 255, 0.07);
}

.error-msg { color: var(--danger); font-size: 0.78rem; min-height: 1.2em; margin: 10px 0 4px; }
.error-msg.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ============ 开销记录 ============ */
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.card-head h3 { font-size: 1rem; font-weight: 600; letter-spacing: 0.04em; }
.head-actions { display: flex; gap: 8px; }

.expense-row { display: flex; gap: 10px; }

.expense-list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 0 4px; padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.expense-list-head h4 { font-size: 0.88rem; font-weight: 600; letter-spacing: 0.06em; }
.muted { color: var(--text-3); font-size: 0.74rem; }

.expense-list { list-style: none; }
.expense-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
  animation: rise 0.3s ease backwards;
}
.expense-item:last-child { border-bottom: none; }

.exp-tag {
  flex-shrink: 0;
  font-size: 0.68rem;
  color: var(--accent);
  background: rgba(86, 200, 255, 0.1);
  border: 1px solid rgba(86, 200, 255, 0.25);
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}
.exp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.exp-name { font-size: 0.88rem; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-time { font-size: 0.7rem; color: var(--text-3); }
.exp-amt {
  flex-shrink: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 0.9rem;
  color: var(--danger);
}
.exp-del {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: 1rem; line-height: 1;
  cursor: pointer;
  transition: all 0.18s ease;
}
.exp-del:hover {
  color: var(--danger);
  border-color: rgba(255, 125, 138, 0.4);
  background: rgba(255, 125, 138, 0.08);
}

.empty-hint { text-align: center; color: var(--text-3); font-size: 0.8rem; padding: 18px 0 4px; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(2, 5, 12, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade 0.25s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 380px; animation: rise 0.3s cubic-bezier(0.22, 0.68, 0.32, 1); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; padding: 11px 16px; font-size: 0.88rem; }
.btn-ghost2 {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
.btn-ghost2:hover { color: var(--text-1); border-color: rgba(126, 168, 255, 0.35); }

/* ============ 页脚 ============ */
.footer { text-align: center; color: var(--text-3); font-size: 0.72rem; letter-spacing: 0.1em; padding-top: 6px; }

/* ============ 响应式 ============ */
@media (max-width: 420px) {
  .app { padding: 28px 14px 24px; }
  .card { padding: 20px 16px; }
  .expense-row { flex-direction: column; }
  .head-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
