:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #0e9f6e;
  --primary-dark: #0b7d57;
  --accent: #0d9488;
  --danger: #dc2626;
  --warn: #d97706;
  --green: #059669;
  --green-bg: #e8f7f0;
  --red: #dc2626;
  --red-bg: #fdecec;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}

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

html { font-size: 16px; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }

/* 隐藏数字输入框自带的上下箭头（手机上仍是数字键盘） */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  display: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  -webkit-appearance: none;
  appearance: textfield;
}

#app { max-width: 620px; margin: 0 auto; padding-bottom: 88px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 2px 10px rgba(13, 148, 136, .25);
}
.topbar .brand { font-size: 18px; font-weight: 800; letter-spacing: .5px; }
.topbar .sub { font-size: 12px; opacity: .85; font-weight: 500; }
.chip-btn {
  background: rgba(255,255,255,.18); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.3);
}
.chip-btn:active { background: rgba(255,255,255,.3); }
.demo-tag { background: #fff; color: var(--warn); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }

/* ---------- 卡片与列表 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 12px 16px;
}
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 18px 18px 6px; }
.section-title h2 { font-size: 16px; font-weight: 800; }
.section-title .hint { font-size: 12px; color: var(--muted); }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row.off { opacity: .55; }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.avatar.muted { background: #cbd5e1; }
.name { font-weight: 700; font-size: 15px; }
.sub { color: var(--muted); font-size: 12.5px; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: var(--green-bg); color: var(--green); margin-left: 6px;
}
.tag.admin { background: #fef3c7; color: var(--warn); }
.tag.off { background: #f1f5f9; color: var(--muted); }
.tag.warn { background: #fef3c7; color: var(--warn); }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.err { background: var(--red-bg); color: var(--red); }

.money { font-weight: 800; font-variant-numeric: tabular-nums; }
.money.pos { color: var(--green); }
.money.neg { color: var(--red); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 12px; padding: 11px 18px; font-size: 15px; font-weight: 700;
  transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; box-shadow: 0 4px 12px rgba(14, 159, 110, .3); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #eef2f7; color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 10px; background: #f1f5f9; font-size: 14px; line-height: 1; }
.btn-icon.danger { background: var(--red-bg); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 12px; background: #fafbfc; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field textarea { resize: vertical; min-height: 60px; }
.inline-fields { display: flex; gap: 10px; }
.inline-fields .field { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.form-actions .btn { flex: 1; }

/* ---------- 登录页 ---------- */
.login-hero { text-align: center; padding: 48px 20px 8px; }
.login-hero .logo { font-size: 52px; }
.login-hero h1 { font-size: 24px; font-weight: 800; margin-top: 6px; }
.login-hero p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.login-tabs { display: flex; gap: 8px; margin: 22px 16px 0; background: #e2e8f0; border-radius: 12px; padding: 5px; }
.login-tabs button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.login-tabs button.on { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.login-form { margin-top: 12px; }
.demo-box {
  margin: 18px 16px; border: 1.5px dashed var(--primary); border-radius: var(--radius);
  padding: 14px; background: #f3fbf7; text-align: center;
}
.demo-box p { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.demo-box .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.foot-note { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 20px; }

/* ---------- 统计卡 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 12.5px; color: var(--muted); }
.stat-card .value { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 条形图 ---------- */
.bar-line { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.bar-line .bl-name { width: 76px; flex: none; color: var(--text); font-weight: 600; }
.bar-line .bl-track { flex: 1; height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-line .bl-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.bar-line .bl-val { width: 70px; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar-inner { max-width: 620px; margin: 0 auto; display: flex; width: 100%; }
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px; color: var(--muted); font-weight: 600;
  border-radius: 10px;
}
.tabbar button .ic { font-size: 20px; line-height: 1.2; }
.tabbar button.on { color: var(--primary); background: var(--green-bg); }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 20px 20px 0 0; width: 100%; max-width: 620px;
  max-height: 92vh; overflow-y: auto; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.modal .sub { margin-bottom: 14px; }
.modal-close {
  position: absolute; right: 14px; top: 14px; font-size: 22px; color: var(--muted);
  width: 34px; height: 34px; border-radius: 50%; background: #f1f5f9; line-height: 1;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- 芯片选择 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 14px; font-weight: 600; background: #fafbfc; color: var(--muted);
}
.chip.on { border-color: var(--primary); background: var(--green-bg); color: var(--primary); font-weight: 700; }
.chip:disabled { opacity: .4; }

/* ---------- 活动卡片 ---------- */
.activity-card { margin: 10px 16px; }
.activity-head { display: flex; align-items: center; gap: 10px; }
.cat-icon { font-size: 22px; }
.activity-head .grow { flex: 1; min-width: 0; }
.activity-title { font-weight: 700; font-size: 15px; }
.activity-meta { font-size: 12.5px; color: var(--muted); }
.cat-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: var(--muted); }
.activity-detail { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 13.5px; }
.activity-detail .pd-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text); }
.activity-detail .pd-row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }
.activity-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ---------- 余额大字卡 ---------- */
.balance-hero {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
  border-radius: var(--radius); margin: 14px 16px; padding: 22px 18px; box-shadow: 0 8px 20px rgba(13, 148, 136, .3);
}
.balance-hero .label { font-size: 13px; opacity: .9; }
.balance-hero .value { font-size: 34px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.balance-hero.neg { background: linear-gradient(135deg, #dc2626, #b91c1c); box-shadow: 0 8px 20px rgba(220, 38, 38, .3); }

/* ---------- 流水列表 ---------- */
.tx-row .tx-icon { font-size: 18px; }
.tx-amount { font-weight: 800; font-variant-numeric: tabular-nums; }
.tx-amount.in { color: var(--green); }
.tx-amount.out { color: var(--red); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 14px; }
.empty .ic { font-size: 36px; display: block; margin-bottom: 8px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 99;
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  max-width: 86vw; text-align: center;
}
.toast.err { background: var(--danger); }

.info-banner {
  background: #fefce8; border: 1px solid #fde68a; color: #854d0e;
  border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 10px 16px;
}
.code-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #f1f5f9; border-radius: 10px; padding: 10px 12px; margin: 8px 0;
  font-weight: 700; font-size: 14px; letter-spacing: 1px;
}
.code-box .grow { overflow-x: auto; white-space: nowrap; }

@media (min-width: 640px) {
  #app { padding-bottom: 20px; }
  .tabbar { top: auto; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: 20px; max-height: 85vh; }
  .toast { bottom: 40px; }
}
