:root {
  --bg: #f7f7f8;
  --card: #fff;
  --text: #16161a;
  --muted: #8b8b93;
  --line: #ebebef;
  --accent: #0a84ff;
  --out: #d92c2c;
  --in: #12a150;
  --warn: #b3760b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --card: #1c1c1f;
    --text: #f2f2f4;
    --muted: #8e8e96;
    --line: #2a2a2e;
    --accent: #3b9cff;
    --out: #ff6b6b;
    --in: #3ddc84;
    --warn: #e0a845;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 12px);
  max-width: 640px;
  margin: 0 auto;
}

.loading { padding: 40px 20px; color: var(--muted); text-align: center; }

/* 口令页 */
.gate { padding: 90px 24px 0; }
.gate-title { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; }
.gate-sub { color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.gate input {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  font-size: 17px;
  font-family: inherit;
  margin-bottom: 10px;
}
.gate input:focus { outline: none; border-color: var(--accent); }

/* 顶栏 */
.hd {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 4px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.hd .month { flex: 1; text-align: center; font-weight: 600; font-size: 16px; }
.nav {
  width: 40px; height: 40px;
  border: 0; background: transparent;
  color: var(--accent);
  font-size: 22px; line-height: 1;
  border-radius: 12px;
  cursor: pointer;
}
.nav:disabled { color: var(--line); }
.nav.ghost { color: var(--muted); font-size: 18px; }

/* 汇总 */
.summary { padding: 8px 20px 18px; }
.summary .cap { color: var(--muted); font-size: 13px; margin-bottom: 1px; }
.summary .big { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.summary .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* 按钮 */
.actions { padding: 0 16px 12px; display: flex; flex-direction: column; gap: 8px; }
button.primary, button.secondary {
  width: 100%;
  padding: 15px 16px;
  border: 0;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; }
button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
button.primary:active, button.secondary:active { opacity: 0.75; }

/* 列表 */
.list { background: var(--card); border-radius: 16px; margin: 0 16px; overflow: hidden; }
.list .pad { padding: 18px 16px; }
.row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amt { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.row-amt.out { color: var(--out); }
.row-amt.in { color: var(--in); }
.row-del {
  width: 28px; height: 28px;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.row-del:active { background: var(--line); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 16px 8px; }

/* 确认页卡片 */
.pad { padding: 0 16px 12px; }
.card {
  background: var(--card);
  border-radius: 16px;
  margin: 0 16px 12px;
  padding: 14px;
}
.card.warn-card { box-shadow: inset 0 0 0 1.5px var(--warn); }
.card-head { display: flex; align-items: center; gap: 4px; }
.card-head .cny { color: var(--muted); font-size: 20px; }
.amount {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  color: var(--text);
  font-size: 28px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 0;
}
.amount:focus { outline: none; }
.card-head .del {
  border: 0; background: transparent;
  color: var(--muted); font-size: 13px;
  padding: 8px 4px; cursor: pointer;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.field { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.field span { width: 54px; color: var(--muted); font-size: 14px; flex-shrink: 0; }
.field input, .field select {
  flex: 1; min-width: 0;
  border: 0; background: transparent;
  color: var(--text); font-size: 15px;
  padding: 2px 0;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; }

.tiny { font-size: 12px; line-height: 1.5; padding-top: 6px; }
.muted { color: var(--muted); }
.warn-text { color: var(--warn); }
.msg-warn {
  background: rgba(200, 140, 20, 0.12);
  color: var(--warn);
  font-size: 13px;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 16px 10px;
}
.ok { color: var(--in); font-weight: 600; }
.bad { color: var(--out); font-weight: 600; }

/* 覆盖层：识别 / 保存进度 */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 50;
  color: #fff;
}
.overlay[hidden] { display: none; }
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { font-size: 15px; }

/* 轻提示 */
.toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  max-width: 88vw;
  background: rgba(20, 20, 22, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 60;
  text-align: center;
}
.toast[hidden] { display: none; }