:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e7e9f0;
  --border-strong: #d8dbe6;
  --text: #1a1d29;
  --text-2: #5c6172;
  --text-3: #9298a8;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --income: #d92d20;
  --expense: #079455;
  --amber: #f79009;
  --violet: #7f56d9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 6px 24px rgba(16, 24, 40, .07);
  --radius: 14px;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 15% 0%, #e8ecff 0%, transparent 60%),
    radial-gradient(800px 460px at 90% 100%, #f4eaff 0%, transparent 60%),
    var(--bg);
}
.login-panel { width: 100%; max-width: 420px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; padding-left: 4px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 22px; letter-spacing: -.5px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .28);
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 10px; font-size: 17px; box-shadow: none; }
.brand-title { font-size: 18px; font-weight: 750; letter-spacing: -.3px; }
.brand-title.sm { font-size: 14px; }
.brand-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.brand-sub.sm { font-size: 11px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.4px; }
.login-desc { margin: 0 0 24px; color: var(--text-2); font-size: 13px; }
.field-label { display: block; font-size: 12px; font-weight: 650; color: var(--text-2); margin: 14px 0 7px; }
.input {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.input::placeholder { color: var(--text-3); }
.code-row { display: flex; gap: 8px; }
.code-btn { flex: 0 0 auto; height: 44px; padding: 0 12px; white-space: nowrap; }
.field-error { color: var(--income); font-size: 12px; min-height: 18px; margin-top: 5px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-foot { text-align: center; color: var(--text-3); font-size: 11px; margin-top: 18px; }
.auth-tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 11px; margin-bottom: 6px; }
.auth-tab {
  flex: 1; height: 36px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600; transition: background .15s, color .15s;
}
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.auth-panel { padding-top: 2px; }
.auth-hint { color: var(--text-3); font-size: 11px; line-height: 1.5; margin-top: 12px; text-align: center; }

/* ---------- 独立登录页 / 注册页 ---------- */
.auth-panel-wide { max-width: 520px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-2); }
.auth-link { color: var(--primary); font-weight: 700; text-decoration: none; margin-left: 2px; }
.auth-link:hover { text-decoration: underline; }
.auth-foot-link { text-align: center; margin-top: 16px; font-size: 12px; }
.auth-foot-link a { color: var(--text-3); text-decoration: none; }
.auth-foot-link a:hover { color: var(--primary); }
.auth-success {
  background: #e7f8ef; color: #0f7a43; border: 1px solid #b7ebcd;
  border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
}
.req { color: var(--income); font-weight: 700; margin-left: 2px; }
.field-note { color: var(--text-3); font-size: 11px; line-height: 1.6; margin-top: 5px; }
.register-card .field-label { margin-top: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.subject-choice { display: flex; gap: 10px; margin: 4px 0 6px; }
.subject-option {
  flex: 1; position: relative; display: block; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 11px;
  padding: 11px 14px; background: var(--surface);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.subject-option:hover { border-color: var(--primary); }
.subject-option.active {
  border-color: var(--primary); background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.subject-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.so-title { display: block; font-size: 13px; font-weight: 700; color: var(--text); }
.so-sub { display: block; font-size: 11px; color: var(--text-3); margin-top: 3px; }
.subject-option.active .so-title { color: var(--primary); }
#register-error { min-height: 0; margin: 0 0 4px; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .subject-choice { flex-direction: column; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 9px;
  border: 1px solid transparent; font-size: 13px; font-weight: 650;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: #e3e8ff; }
.btn-danger-soft { background: #fef3f2; color: #b42318; }
.btn-wechat { width: 100%; height: 42px; background: #f2f8f4; color: #14834b; border-color: #cdebd9; }
.btn-wechat:hover:not(:disabled) { background: #e6f4ec; }
.btn-block { width: 100%; height: 44px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Layout ---------- */
.app-view { min-height: 100vh; display: flex; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  padding: 20px 14px 16px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-divider { height: 1px; background: var(--border); margin: 10px 8px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  height: 42px; padding: 0 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600;
  text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: 0 0 18px; }
.nav-icon svg { width: 18px; height: 18px; display: block; }
.sidebar-foot { margin-top: auto; padding: 14px; border-radius: 12px; background: linear-gradient(150deg, #f2f4ff, #f8f5ff); border: 1px solid #e7e9fb; }
.side-tip-title { font-size: 12px; font-weight: 700; color: #4338ca; margin-bottom: 5px; }
.side-tip { font-size: 11px; color: var(--text-2); line-height: 1.6; }
.side-tip-btn {
  display: block; width: 100%; margin-top: 10px;
  border: 0; border-radius: 8px; padding: 8px 10px;
  background: #ffffff; color: var(--primary);
  font-size: 12px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background .16s, color .16s, transform .16s;
}
.side-tip-btn:hover { background: var(--primary); color: #fff; }
.side-tip-btn:active { transform: scale(.985); }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 76px; flex: 0 0 76px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 18px; font-weight: 750; letter-spacing: -.3px; }
.page-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.user-name { font-size: 12px; font-weight: 650; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.level-tag { font-size: 10px; color: var(--primary); background: var(--primary-soft); padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.content { padding: 26px 28px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 15px; font-weight: 750; }
.section-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.grid-hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; }
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }

.stat-card { padding: 18px 20px; position: relative; overflow: hidden; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--text-2); font-size: 12px; font-weight: 600; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-icon svg { width: 17px; height: 17px; }
.stat-value { font-size: 26px; font-weight: 780; letter-spacing: -.8px; margin: 10px 0 3px; font-variant-numeric: tabular-nums; }
.stat-value .unit { font-size: 14px; font-weight: 600; color: var(--text-2); margin-right: 2px; }
.stat-note { font-size: 11px; color: var(--text-3); }
.stat-note.up { color: var(--income); }
.stat-note.down { color: var(--expense); }

.member-card { padding: 22px; background: linear-gradient(135deg, #2b2569 0%, #4f46e5 58%, #7c3aed 100%); color: #fff; border: 0; position: relative; overflow: hidden; }
.member-card::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; right: -70px; top: -90px; background: rgba(255,255,255,.09); }
.member-card::before { content: ""; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: 50px; bottom: -100px; background: rgba(255,255,255,.07); }
.member-label { font-size: 11px; opacity: .75; letter-spacing: 1px; }
.member-name { font-size: 23px; font-weight: 800; margin: 6px 0 2px; }
.member-desc { font-size: 12px; opacity: .8; }
.member-progress-wrap { margin-top: 22px; position: relative; z-index: 1; }
.member-progress-head { display: flex; justify-content: space-between; font-size: 11px; opacity: .9; margin-bottom: 8px; }
.progress { height: 7px; border-radius: 999px; background: rgba(255,255,255,.25); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: #fff; }
.member-bottom { display: flex; gap: 26px; margin-top: 20px; position: relative; z-index: 1; }
.member-bottom div span { display: block; }
.mb-label { font-size: 10px; opacity: .75; }
.mb-value { font-size: 15px; font-weight: 750; margin-top: 3px; }

/* ---------- Product ---------- */
.product-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; transition: transform .16s, box-shadow .16s, border-color .16s; }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #d5d9ea; }
.product-cover { height: 108px; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: linear-gradient(135deg, #f1f3ff, #f8f5ff); border-bottom: 1px solid #eceefa; }
.product-cover.gift { background: linear-gradient(135deg, #fff5e8, #fdf0f6); border-bottom-color: #fae9dc; }
.product-glyph { width: 50px; height: 50px; border-radius: 13px; background: #fff; box-shadow: var(--shadow-sm); display: grid; place-items: center; font-size: 20px; font-weight: 800; color: var(--primary); border: 1px solid #e8eafd; }
.product-glyph.gift { color: #db7500; border-color: #fae4c8; }
.badge { font-size: 10px; font-weight: 750; padding: 4px 9px; border-radius: 999px; background: var(--primary); color: #fff; }
.badge.gift { background: #f79009; }
.product-body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.product-name { font-size: 15px; font-weight: 750; }
.product-desc { color: var(--text-2); font-size: 12px; line-height: 1.6; margin: 7px 0 16px; min-height: 38px; }
.product-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-size: 20px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.price small { font-size: 12px; font-weight: 600; margin-right: 1px; }
.price.old { font-size: 12px; color: var(--text-3); text-decoration: line-through; font-weight: 500; margin-left: 6px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: none; padding: 12px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-2); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfe; }
.td-main { color: var(--text); font-weight: 650; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--text-3); }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pill.green { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.pill.red { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.pill.amber { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.pill.primary { background: var(--primary-soft); color: var(--primary); border-color: #dbe2ff; }
.amount { font-weight: 750; font-variant-numeric: tabular-nums; }
.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }
.empty { padding: 46px 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty-title { font-size: 14px; color: var(--text-2); font-weight: 650; margin-bottom: 5px; }

/* ---------- Referral ---------- */
.invite-box { padding: 22px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; background: linear-gradient(120deg, #f5f3ff, #eef2ff); border-color: #e3e2fb; }
.invite-glyph { width: 54px; height: 54px; border-radius: 14px; background: #fff; border: 1px solid #e4e2fb; display: grid; place-items: center; color: var(--primary); }
.invite-glyph svg { width: 25px; height: 25px; }
.invite-info { flex: 1; min-width: 220px; }
.invite-label { font-size: 11px; color: var(--text-2); }
.invite-code { font-size: 27px; font-weight: 800; letter-spacing: 3px; color: #312e81; margin: 3px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.invite-hint { font-size: 11px; color: var(--text-3); }
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rule-list { padding: 20px; }
.rule-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--border); font-size: 12px; color: var(--text-2); }
.rule-item:last-child { border-bottom: 0; }
.rule-num { width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 10px; font-weight: 800; }

/* ---------- Member levels ---------- */
.level-card { padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); position: relative; }
.level-card.current { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.08); }
.level-head { display: flex; align-items: center; justify-content: space-between; }
.level-name { font-size: 14px; font-weight: 750; }
.level-threshold { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.level-bar { height: 5px; border-radius: 999px; background: var(--border); margin: 14px 0 12px; overflow: hidden; }
.level-bar > span { display: block; height: 100%; border-radius: 999px; }
.benefit-list { display: flex; flex-direction: column; gap: 7px; }
.benefit { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--text-2); }
.benefit svg { width: 13px; height: 13px; color: var(--expense); flex: 0 0 13px; }
.info-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.info-row:last-child { border-bottom: 0; }
.info-label { color: var(--text-3); }
.info-value { font-weight: 650; color: var(--text); }

/* ---------- 会员中心：修改登录密码入口 ---------- */
.pwd-entry {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.pwd-entry-main { min-width: 0; }
.pwd-entry-title { font-size: 12px; font-weight: 650; color: var(--text); }
.pwd-entry-sub { margin-top: 3px; font-size: 11px; line-height: 1.5; color: var(--text-3); }
.pwd-entry .btn { flex: 0 0 auto; }
.pwd-rule {
  margin-top: 12px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
  font-size: 11px; line-height: 1.65; color: var(--text-3);
}
@media (max-width: 560px) {
  .pwd-entry { flex-direction: column; align-items: stretch; }
  .pwd-entry .btn { width: 100%; }
}

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-chip { height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600; }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Toast & modal ---------- */
.toast-root { position: fixed; top: 88px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { min-width: 220px; max-width: 360px; padding: 12px 15px; border-radius: 10px; background: #1d2130; color: #fff; font-size: 12px; box-shadow: var(--shadow); animation: toastIn .2s ease-out; }
.toast.error { background: #912018; }
.toast.success { background: #116b45; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 20, 36, .42); z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(16,24,40,.22); padding: 24px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal-desc { color: var(--text-2); font-size: 12px; margin: 0 0 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }
.modal-summary { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 14px; }
.summary-row { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 0; color: var(--text-2); }
.summary-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.summary-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 13px; }
.amount-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.amount-option { height: 38px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 12px; font-weight: 700; }
.amount-option.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { color: var(--text-3); padding: 30px; text-align: center; font-size: 12px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-hero { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 100%; }
  .app-view { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; padding: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { width: auto; flex: 0 0 auto; padding: 0 12px; }
  .nav-item span:last-child { display: none; }
  .nav-item { height: 38px; }
  .topbar { height: 66px; flex-basis: 66px; padding: 0 14px; }
  .page-sub { display: none; }
  .recharge-btn, .user-name { display: none; }
  .content { padding: 16px 14px 40px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 15px; }
}

/* ===== 代理商中心（agent.html） ===== */
.agent-gate { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center; background: #f5f6fa; }
.agent-gate-box { text-align: center; color: #667085; font: 14px/1.6 -apple-system, 'Microsoft YaHei', sans-serif; }
.agent-gate-title { font-size: 19px; font-weight: 700; color: #1f2430; margin-bottom: 8px; }
.agent-app { min-height: 100vh; background: #f5f6fa; }
.agent-topbar { background: #fff; border-bottom: 1px solid #e5e7eb; }
.agent-topbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.agent-brand { display: flex; align-items: center; gap: 10px; }
.agent-brand-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.agent-brand-title { font-size: 15px; font-weight: 700; color: #1f2430; }
.agent-brand-sub { font-size: 11px; color: #98a2b3; }
.agent-topbar-right { display: flex; align-items: center; gap: 12px; }
.agent-name { font-size: 13px; color: #344054; }
.agent-main { max-width: 1180px; margin: 0 auto; padding: 24px 22px 40px; }
.agent-welcome h1 { font-size: 20px; margin: 0 0 6px; color: #1f2430; }
.agent-welcome p { font-size: 13px; color: #667085; margin: 0; line-height: 1.6; }
.agent-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
.agent-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px 18px; }
.agent-card .k { font-size: 12px; color: #667085; }
.agent-card .v { font-size: 22px; font-weight: 700; color: #1f2430; margin-top: 6px; }
.agent-card .s { font-size: 11px; color: #98a2b3; margin-top: 4px; }
.agent-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.agent-toolbar .input { max-width: 300px; }
.agent-note { margin-left: auto; font-size: 12px; color: #98a2b3; }
.agent-table-wrap { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; overflow-x: auto; }
.agent-table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; }
.agent-table-wrap th, .agent-table-wrap td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
.agent-table-wrap th { background: #fafbfc; color: #667085; font-weight: 600; white-space: nowrap; }
.agent-table-wrap tbody tr:last-child td { border-bottom: 0; }
.agent-loading, .agent-empty { text-align: center; padding: 46px 20px; color: #98a2b3; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; }
.agent-pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 14px; font-size: 13px; color: #667085; }
.agent-foot { margin-top: 26px; font-size: 11px; color: #98a2b3; text-align: center; }
.agent-modal-backdrop { position: fixed; inset: 0; z-index: 9999; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.agent-modal { background: #fff; border-radius: 14px; padding: 24px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(16, 24, 40, .2); }
.agent-modal h2 { font-size: 18px; margin: 0 0 6px; color: #1f2430; }
.agent-modal .field-label { margin-top: 12px; }
.agent-modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.agent-toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.agent-toast { background: #1f2430; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
.agent-toast.success { background: #138a4b; }
.agent-toast.error { background: #d13a3a; }
@media (max-width: 860px) {
  .agent-cards { grid-template-columns: repeat(2, 1fr); }
  .agent-note { margin-left: 0; }
}

/* ==================== 登录安全：验证码 / 密码强度 / 锁定提示 ==================== */
.captcha-block { margin-top: 2px; }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-input { flex: 1; min-width: 0; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.captcha-img {
  width: 132px; height: 46px; flex-shrink: 0; border: 1px solid #e4e7ee; border-radius: 9px;
  background: #f5f7fc; cursor: pointer; object-fit: cover; transition: border-color .15s, box-shadow .15s;
}
.captcha-img:hover { border-color: #a5a0f5; box-shadow: 0 3px 10px rgba(79, 70, 229, .12); }
.captcha-img[aria-busy="true"] { opacity: .6; }

.auth-security-note {
  margin-top: 14px; padding: 9px 12px; border-radius: 9px;
  background: #f4f6ff; border: 1px solid #e6e8ff;
  color: #4f46a8; font-size: 11.5px; line-height: 1.6;
}

/* 错误提示分级：普通警告（剩余次数）与账户锁定 */
.field-error.is-warn {
  background: #fff8e8; border: 1px solid #f7dfa6; color: #96620b;
  padding: 8px 11px; border-radius: 8px; line-height: 1.6;
}
.field-error.is-locked {
  background: #fdecec; border: 1px solid #f4bcbc; color: #b42318;
  padding: 10px 12px; border-radius: 9px; font-weight: 600; line-height: 1.7;
}
.field-error:empty { min-height: 0; margin-top: 0; padding: 0; border: 0; }

/* 密码强度 */
.pw-meter { margin-top: 12px; padding: 12px 14px; border: 1px solid #e9ebf2; border-radius: 10px; background: #fafbfe; }
.pw-meter-bar { height: 6px; border-radius: 6px; background: #e9ebf2; overflow: hidden; }
.pw-meter-bar span { display: block; width: 0; height: 100%; border-radius: 6px; background: #d0d5e2; transition: width .22s, background .22s; }
.pw-meter-bar span.weak { background: #e5484d; }
.pw-meter-bar span.medium { background: #f5a524; }
.pw-meter-bar span.strong { background: #12a150; }
.pw-meter-head { margin-top: 8px; font-size: 12px; color: #667085; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.pw-meter-head b.weak { color: #e5484d; }
.pw-meter-head b.medium { color: #c47f0a; }
.pw-meter-head b.strong { color: #0f7a43; }
.pw-class-note { font-size: 11.5px; color: #98a2b3; }
.pw-class-note b { color: #4f46e5; }
.pw-rules { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pw-rules li { font-size: 11.5px; color: #98a2b3; display: flex; align-items: center; gap: 5px; }
.pw-rules li::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #c9cedb; flex-shrink: 0; }
.pw-rules li.ok { color: #0f7a43; }
.pw-rules li.ok::before {
  border-color: #12a150; background: #12a150;
  box-shadow: inset 0 0 0 2px #fff;
}
@media (max-width: 520px) {
  .captcha-img { width: 108px; }
  .pw-rules { gap: 6px 10px; }
}

/* 代理商中心：分页条与文字图标 */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 4px 2px; color: var(--text-3); font-size: 12px; }
.nav-icon { font-size: 16px; line-height: 1; }

/* ==================== 代理商中心弹窗：三段式对话框 ==================== */
/* 仅作用于 .agent-dialog，不影响会员中心 / 后台共用的 .modal */
.modal-backdrop.agent-backdrop { z-index: 60; }
.modal.agent-dialog {
  max-width: 620px; padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 24px);
}
.modal.agent-dialog .ad-head {
  flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 20px 24px 15px; border-bottom: 1px solid var(--border);
}
.modal.agent-dialog .ad-titles { min-width: 0; }
.modal.agent-dialog .ad-titles h2 { margin: 0; font-size: 18px; line-height: 1.4; }
.modal.agent-dialog .ad-titles .modal-sub { margin: 5px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.6; }
.ad-close {
  flex: 0 0 auto; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  background: var(--surface-2); color: var(--text-2); font-size: 21px; line-height: 28px;
  text-align: center; cursor: pointer; transition: background .15s, color .15s;
}
.ad-close:hover { background: #feeceb; color: #b42318; }
/* 弱密码强制改密：必须改完才能继续，隐藏关闭按钮（ESC / 遮罩关闭由 JS 拦截） */
.modal.agent-dialog.ad-locked .ad-close { display: none; }
.modal.agent-dialog .ad-body { flex: 1 1 auto; overflow-y: auto; padding: 2px 24px 20px; }
.modal.agent-dialog .ad-body.is-empty { display: none; }
.modal.agent-dialog .ad-foot {
  flex: 0 0 auto; padding: 14px 24px 17px; border-top: 1px solid var(--border); background: var(--surface);
}
.modal.agent-dialog .ad-foot.is-empty { display: none; }
.ad-foot .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 0; }
.ad-section { margin-top: 18px; }
.ad-section:first-child { margin-top: 12px; }
.ad-section-title {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 700;
  color: var(--primary); line-height: 1.2; padding-left: 9px; border-left: 3px solid var(--primary);
}
.form-grid.ad-grid { gap: 0 16px; }
.ad-grid .field-label { margin: 11px 0 6px; }
.ad-grid .input { height: 40px; }
.ad-grid .ad-hint {
  padding: 9px 11px; border-radius: 9px; background: var(--primary-soft);
  color: #4f46a8; font-size: 11px; line-height: 1.65;
}
.modal.agent-dialog .input:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
@media (max-width: 560px) {
  .modal.agent-dialog { max-width: 100%; max-height: calc(100vh - 24px); }
  .modal.agent-dialog .ad-head { padding: 16px 16px 12px; }
  .modal.agent-dialog .ad-body { padding: 2px 16px 16px; }
  .modal.agent-dialog .ad-foot { padding: 12px 16px 14px; }
  .form-grid.ad-grid { gap: 0; }
  .ad-tip { display: none; }
}

/* 代理商中心：下属会员筛选栏保持单行 */
.filter-bar.agent-filter { flex-wrap: nowrap; }
.agent-filter .search-input { flex: 1 1 auto; width: auto; min-width: 0; }
.agent-filter .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 700px) {
  .filter-bar.agent-filter { flex-wrap: wrap; }
  .agent-filter .search-input { flex: 1 1 100%; width: 100%; }
}

/* ==================== 代理商代付购买（给下属会员买年数 / 用户数） ==================== */
.agent-balance-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 16px; margin-bottom: 12px;
  border: 1px solid #dbe2ff; border-radius: 12px;
  background: linear-gradient(100deg, #eef2ff 0%, #f8f9ff 60%, #fff 100%);
  box-shadow: var(--shadow-sm);
}
.abb-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.abb-label { font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.abb-value { font-size: 20px; font-weight: 800; color: var(--primary); letter-spacing: -.4px; white-space: nowrap; }
.abb-tip { font-size: 11.5px; color: var(--text-3); line-height: 1.55; }
.agent-balance-bar .btn { flex: 0 0 auto; white-space: nowrap; }

/* 会员列表操作按钮组：三个动作并排、不换行挤压 */
.row-ops { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.row-ops .btn { white-space: nowrap; }
.td-main.muted { color: var(--text-3); font-weight: 600; }

/* 代付购买弹窗：现状卡片 + 实时费用明细 */
.modal.agent-dialog .ad-body .ad-field { margin-top: 2px; }
.modal.agent-dialog .ad-body .ad-field .field-label { margin: 12px 0 6px; }
.modal.agent-dialog .ad-body .ad-hint {
  margin-top: 12px; padding: 10px 12px; border-radius: 9px;
  background: var(--primary-soft); color: #4f46a8; font-size: 11.5px; line-height: 1.7;
}
.modal.agent-dialog .ad-body .ad-hint.is-warn {
  background: #fffaeb; border: 1px solid #fedf89; color: #b54708;
}
.quote-meta {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin-top: 12px; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: var(--border);
}
.quote-meta > div { background: var(--surface); padding: 10px 12px; min-width: 0; }
.quote-meta span { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.quote-meta b { display: block; font-size: 12.5px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.quote-meta .mono { font-size: 12px; }
.quote-meta > div.hl { background: var(--primary-soft); }
.quote-meta > div.hl b { color: var(--primary); font-size: 15px; }
.quote-box { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.quote-detail { padding: 12px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.9; }
.quote-detail b { color: var(--text); font-variant-numeric: tabular-nums; }
.quote-total {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.quote-total span { font-size: 12px; color: var(--text-2); font-weight: 650; }
.quote-total b { font-size: 20px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }

/* 购买弹窗内容较多：适度压缩纵向间距，让费用说明在常见屏幕内完整可见 */
.ad-purchase .ad-section { margin-top: 13px; }
.ad-purchase .ad-section:first-child { margin-top: 10px; }
.ad-purchase .quote-meta { margin-top: 9px; }
.ad-purchase .quote-meta > div { padding: 8px 12px; }
.ad-purchase .quote-box { margin-top: 9px; }
.ad-purchase .quote-detail { padding: 9px 14px; }
.ad-purchase .quote-total { padding: 9px 14px; }
.modal.agent-dialog .ad-body .ad-purchase .ad-hint { margin-top: 9px; padding: 8px 12px; }
.modal.agent-dialog .ad-body .ad-purchase .ad-field .field-label { margin: 9px 0 5px; }

@media (max-width: 700px) {
  .agent-balance-bar { align-items: flex-start; }
  .abb-tip { flex: 1 1 100%; }
}
@media (max-width: 560px) {
  .quote-meta { grid-template-columns: repeat(2, 1fr); }
  .row-ops { flex-wrap: wrap; }
}

/* 累计购买：自购 + 代购 的购买支出统计（代理商概览 / 财务中心） */
.purchase-card { margin-top: 16px; }
.purchase-total {
  display: inline-flex; align-items: baseline; gap: 8px; flex: 0 0 auto;
  padding: 8px 14px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.purchase-total b { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.purchase-table td, .purchase-table th { padding-left: 14px; padding-right: 14px; }
.purchase-table .td-sub {
  color: var(--text-3); font-size: 11.5px; white-space: normal;
  line-height: 1.55; min-width: 210px;
}
.purchase-table tr.purchase-sum td {
  background: var(--surface-2); border-top: 1px solid var(--border);
  color: var(--text); font-weight: 700;
}
.purchase-table tr.purchase-sum .amount { color: var(--primary); font-size: 15px; }
.purchase-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.pd-block { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.pd-title { font-size: 12px; font-weight: 750; color: var(--text); margin-bottom: 8px; }
.pd-line { font-size: 11.5px; color: var(--text-2); line-height: 1.9; }
.pd-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.pd-em { color: var(--primary); font-weight: 800; }
.pd-chips { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pd-chips span { white-space: nowrap; }
.purchase-note { margin: 12px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.7; }
.info-row.info-row-sub { padding: 7px 0 2px; border-bottom: 0; font-size: 11px; color: var(--text-3); }
.info-row.info-row-sub .info-value { color: var(--text-2); font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .purchase-detail { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .purchase-card .section-head { flex-wrap: wrap; gap: 10px; }
  .purchase-table .td-sub { min-width: 150px; }
}

/* ============ 充值支付（支付方式由后台「支付接口」配置） ============ */
.pay-channel-list { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; max-height: 230px; overflow-y: auto; }
.pay-channel {
  position: relative; display: block; padding: 10px 12px 10px 34px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.pay-channel:hover { border-color: var(--primary); }
.pay-channel.active { border-color: var(--primary); background: var(--primary-soft); }
.pay-channel input[type="radio"] { position: absolute; left: 12px; top: 14px; accent-color: var(--primary); }
.pc-main { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pc-mode { font-size: 10px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.pc-desc { display: block; margin-top: 4px; font-size: 11px; line-height: 1.6; color: var(--text-3); }
.pay-total {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: 12px; background: var(--primary-soft);
  border: 1px solid #dbe2ff; margin: 2px 0 14px;
}
.pay-total span { font-size: 12px; color: var(--text-2); }
.pay-total b { font-size: 22px; color: var(--primary); font-variant-numeric: tabular-nums; }
.pay-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.pay-info-grid > div { min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px; }
.pay-info-grid span { display: block; font-size: 10px; color: var(--text-3); margin-bottom: 4px; }
.pay-info-grid b { display: block; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.pay-qr { text-align: center; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; margin-bottom: 14px; }
.pay-qr img { width: 200px; height: 200px; object-fit: contain; background: #fff; border-radius: 8px; }
.pay-qr div { font-size: 11px; color: var(--text-3); margin-top: 8px; }
.pay-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pay-actions .btn { flex: 1 1 auto; }
.pay-hint { font-size: 11px; line-height: 1.7; color: var(--text-3); margin: 8px 0 0; }
.pay-offline { border: 1px solid var(--border); border-radius: 10px; padding: 2px 14px; margin-bottom: 12px; }
.pay-orders { max-height: 340px; overflow: auto; }
.pay-orders table { font-size: 11px; }
.pay-orders .btn-sm { padding: 4px 8px; }
@media (max-width: 560px) {
  .pay-info-grid { grid-template-columns: 1fr; }
  .pay-channel-list { max-height: 200px; }
  .pay-qr img { width: 170px; height: 170px; }
}
