:root {
  --brand: #4f7cff;
  --brand-2: #7b5cff;
  --brand-soft: #eef2ff;
  --earn: #22c55e;
  --earn-soft: #e8f8ee;
  --spend: #ff6b6b;
  --spend-soft: #ffeced;
  --pending: #fbbf24;
  --pending-soft: #fff7e6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2430;
  --text-2: #5b6478;
  --text-3: #98a1b3;
  --line: #e8ecf4;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 2px 10px rgba(31, 36, 48, 0.05);
  --shadow-lg: 0 8px 28px rgba(31, 36, 48, 0.1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  outline: none;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  background: #eef1f7;
  color: var(--text);
  transition: transform 0.12s, opacity 0.12s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 124, 255, 0.28);
}
.btn-danger { background: var(--spend-soft); color: var(--spend); }
.btn-success { background: var(--earn-soft); color: var(--earn); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 14px 22px; font-size: 16px; border-radius: 14px; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }

.input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus { border-color: var(--brand); background: #fff; }
select.input { appearance: none; background-image: none; }

.field-row { display: flex; gap: 10px; }
.field-row > * { flex: 1; min-width: 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 12px; background: #d9dfea;
  position: relative; transition: background 0.2s; flex: none;
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.tag-earn { background: var(--earn-soft); color: var(--earn); }
.tag-spend { background: var(--spend-soft); color: var(--spend); }
.tag-pending { background: var(--pending-soft); color: #d98b00; }
.tag-approved { background: var(--earn-soft); color: var(--earn); }
.tag-rejected { background: #f1f3f7; color: var(--text-3); }
.tag-gray { background: #f1f3f7; color: var(--text-2); }

/* ---------- 数字 ---------- */
.num-earn { color: var(--earn); font-weight: 600; }
.num-spend { color: var(--spend); font-weight: 600; }
.num-pending { color: #d98b00; font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 8px; text-align: left; white-space: nowrap; }
th { color: var(--text-3); font-weight: 500; font-size: 12.5px; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid #f2f5fa; }
tr:last-child td { border-bottom: none; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .icon { font-size: 40px; opacity: 0.4; margin-bottom: 10px; }
.empty .text { font-size: 14px; }

/* ---------- Toast ---------- */
.toast-box {
  position: fixed; top: 16px; left: 0; right: 0; z-index: 3000;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(31, 36, 48, 0.92); color: #fff; padding: 10px 20px;
  border-radius: 22px; font-size: 14px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-12px); transition: all 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  max-width: 84%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: rgba(24, 160, 88, 0.95); }
.toast-error { background: rgba(230, 70, 70, 0.95); }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 24, 34, 0.42);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; transition: opacity 0.2s;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-mask.show { opacity: 1; }
.modal {
  background: #fff; border-radius: 18px; width: 100%; max-width: 400px;
  padding: 22px; transform: translateY(14px) scale(0.97);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  /* 手机端防溢出：整体限高 + 内容区可滚动，标题与按钮常驻可见 */
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  margin: auto;
}
.modal-mask.show .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 560px; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 10px; flex: 0 0 auto; }
.modal-body { color: var(--text-2); font-size: 14px; margin-bottom: 16px; white-space: pre-wrap; }
.modal-scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-actions { display: flex; gap: 10px; margin-top: 16px; flex: 0 0 auto; }
.modal-actions .btn { flex: 1; }
.modal .input { margin-bottom: 4px; }
@media (max-width: 480px) {
  .modal-mask { padding: 12px; }
  .modal { padding: 18px; max-height: calc(100vh - 24px); }
  .modal-actions { margin-top: 12px; }
}

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef2ff 0%, #f7f3ff 45%, #f4f6fb 100%);
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: #fff; border-radius: 24px; padding: 34px 26px 30px;
  box-shadow: 0 12px 40px rgba(79, 124, 255, 0.12);
  text-align: center;
}
.login-logo { font-size: 46px; line-height: 1; margin-bottom: 12px; }
.login-title {
  font-size: 24px; font-weight: 700; letter-spacing: 1px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--text-3); font-size: 13px; margin: 6px 0 26px; }
.login-error {
  color: var(--spend); font-size: 13px; min-height: 20px;
  margin-bottom: 6px; text-align: left;
}
.login-tip { margin-top: 18px; font-size: 12px; color: var(--text-3); line-height: 1.7; }
.login-divider {
  margin: 4px 0 16px; font-size: 13px; color: var(--text-3);
  display: flex; align-items: center; gap: 10px;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.hint {
  font-size: 12.5px; color: var(--text-3); line-height: 1.6;
  background: #f7f9fd; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 11px; margin-bottom: 12px; text-align: left;
}
.hint b { color: var(--text-2); }

/* ---------- 加载 ---------- */
.loading { text-align: center; padding: 40px; color: var(--text-3); font-size: 14px; }
