:root {
  --blue: #2563eb;
  --blue-dark: #1e3a8a;
  --blue-light: #eff6ff;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --text-mute: #9ca3af;
  --border: #f0f0f0;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}
button { font-family: inherit; border: none; cursor: pointer; outline: none; }
input, textarea, select { font-family: inherit; outline: none; border: none; background: transparent; }

/* ===== 视图切换 ===== */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ===== 登录 ===== */
#view-login {
  background: linear-gradient(160deg, var(--blue-dark) 0%, var(--blue) 50%, #3b82f6 100%);
  padding: 72px 28px 40px;
  color: #fff;
  min-height: 100vh;
  display: none;
  flex-direction: column;
}
#view-login.active { display: flex; }
/* 微信 PC 版会以较宽视口打开，加宽度上限避免卡片拉得过宽 */
#view-login > * { width: 100%; max-width: 480px; margin-left: auto; margin-right: auto; }
.login-logo {
  width: 72px; height: 72px; background: rgba(255,255,255,.18);
  border-radius: 20px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
}
.login-logo svg { width: 40px; height: 40px; }
.login-title { font-size: 26px; font-weight: 700; margin-bottom: 8px; letter-spacing: .5px; }
.login-subtitle { font-size: 14px; opacity: .8; margin-bottom: 40px; line-height: 1.6; }
.login-card {
  background: #fff; border-radius: 20px; padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(30,58,138,.25);
}
.login-label { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; font-weight: 500; }
.login-input {
  width: 100%; height: 52px; background: var(--bg); border-radius: 12px;
  padding: 0 16px; font-size: 17px; color: var(--text); letter-spacing: 1px;
  margin-bottom: 20px;
}
.login-input::placeholder { color: var(--text-mute); letter-spacing: 0; }
.login-btn {
  width: 100%; height: 50px; background: var(--blue); color: #fff;
  border-radius: 12px; font-size: 16px; font-weight: 600;
}
.login-btn:active { opacity: .85; }
.login-btn[disabled] { background: #93c5fd; }
.login-footer { margin-top: auto; text-align: center; font-size: 12px; opacity: .6; padding-top: 32px; }

/* ===== 首页 ===== */
.home-topbar {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  padding: 20px 20px 24px; color: #fff; border-radius: 0 0 24px 24px;
  max-width: 560px; margin: 0 auto;
}
.home-event-name { font-size: 18px; font-weight: 700; text-align: center; }
.profile-card {
  background: rgba(255,255,255,.15); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 14px; margin-top: 16px;
}
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--blue); flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.profile-meta { font-size: 12px; opacity: .85; line-height: 1.5; }
.home-content { padding: 16px 16px 40px; max-width: 520px; margin: 0 auto; }

.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat-label { font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-value small { font-size: 15px; font-weight: 600; margin-right: 2px; }

.section-title { font-size: 15px; font-weight: 700; margin: 20px 0 12px; }

.invoice-entry {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.invoice-entry:active { transform: scale(.98); }
.invoice-icon {
  width: 44px; height: 44px; background: #fef3c7; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.invoice-icon svg { width: 24px; height: 24px; }
.invoice-info { flex: 1; }
.invoice-title { font-size: 15px; font-weight: 600; }
.invoice-desc { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.invoice-arrow { color: #d1d5db; }
.logout-btn {
  display: block; margin: 24px auto 0; font-size: 13px; color: var(--text-mute);
  text-decoration: underline;
}

/* ===== 发票页 ===== */
.inv-navbar {
  background: #fff; padding: 12px 16px; display: flex; align-items: center;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
  max-width: 560px; margin: 0 auto;
}
.inv-back { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.inv-title { flex: 1; text-align: center; font-size: 16px; font-weight: 600; }
.inv-spacer { width: 32px; }
.inv-content { padding: 16px; padding-bottom: 40px; max-width: 520px; margin: 0 auto; }
.inv-section-label { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; font-weight: 500; }

.date-selector {
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.date-value { font-size: 15px; font-weight: 500; }

.upload-zone {
  background: var(--card); border: 2px dashed #d1d5db; border-radius: var(--radius);
  padding: 36px 20px; text-align: center; margin-bottom: 20px;
}
.upload-icon {
  width: 56px; height: 56px; background: var(--blue-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px;
}
.upload-icon svg { width: 28px; height: 28px; }
.upload-text { font-size: 14px; color: var(--text-sub); margin-bottom: 4px; }
.upload-hint { font-size: 12px; color: var(--text-mute); }

.preview-card { background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.preview-img { width: 100%; height: 180px; object-fit: cover; background: var(--bg); display: block; }
.preview-bar { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); }
.preview-name { font-size: 13px; color: var(--text-sub); }
.preview-remove { font-size: 13px; color: var(--red); }

.amount-card { background: var(--card); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.amount-label { font-size: 13px; color: var(--text-sub); margin-bottom: 10px; }
.amount-row { display: flex; align-items: baseline; gap: 8px; }
.amount-symbol { font-size: 20px; font-weight: 600; }
.amount-input {
  font-size: 32px; font-weight: 700; border-bottom: 2px solid #e5e7eb;
  width: 180px; padding: 0 0 4px;
}
.amount-input:focus { border-color: var(--blue); }
.amount-hint { font-size: 12px; color: var(--amber); margin-top: 10px; }

.submit-btn {
  width: 100%; height: 52px; background: var(--blue); color: #fff;
  border-radius: 14px; font-size: 16px; font-weight: 600;
}
.submit-btn:active { background: #1d4ed8; }
.submit-btn[disabled] { background: #93c5fd; }

.history-list { margin-top: 28px; }
.history-item {
  background: var(--card); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.history-date { font-size: 13px; color: var(--text-sub); flex-shrink: 0; }
.history-amount { font-size: 15px; font-weight: 600; margin-left: auto; }
.history-actions { display: flex; gap: 6px; flex-shrink: 0; }
.history-btn {
  font-size: 12px; padding: 4px 10px; border-radius: 8px;
  border: 1px solid #bfdbfe; color: var(--blue);
}
.history-btn.del { border-color: #fecaca; color: var(--red); }
.empty-tip { text-align: center; font-size: 13px; color: var(--text-mute); padding: 32px 0; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 14px; display: none; z-index: 999;
  white-space: nowrap; max-width: 88vw;
}

/* ===== 遮罩：非微信环境 ===== */
#view-block {
  position: fixed; inset: 0; background: #fff; z-index: 9999;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; text-align: center;
}
#view-block.active { display: flex; }
.block-icon { font-size: 52px; margin-bottom: 20px; }
.block-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.block-desc { font-size: 14px; color: var(--text-sub); line-height: 1.7; }
