:root {
  --bg: #fdf7f5;
  --surface: #ffffff;
  --surface-2: #fff6f4;
  --surface-3: #fbf1ef;
  --border: #f0e3df;
  --border-strong: #e3cfc9;
  --text: #2f2429;
  --text-2: #6b565b;
  --muted: #9b8589;
  --primary: #c9405c;
  --primary-dark: #a83047;
  --primary-soft: #fceaf0;
  --gold: #c99a3f;
  --gold-soft: #faf1de;
  --male: #4a7fb5;
  --male-soft: #e8f1f9;
  --female: #d0698f;
  --female-soft: #fceaf1;
  --ok: #2f9e6e;
  --ok-soft: #e6f6ee;
  --warn: #d1902b;
  --warn-soft: #fbf1de;
  --danger: #d0453f;
  --danger-soft: #fcebea;
  --shadow: 0 2px 8px rgba(120, 70, 80, .06), 0 12px 32px rgba(120, 70, 80, .06);
  --shadow-lg: 0 8px 24px rgba(120, 70, 80, .12), 0 24px 60px rgba(120, 70, 80, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: .2px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  font-size: 14px; font-weight: 600; transition: all .16s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: #f0cfcd; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: vertical; min-height: 76px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%239b8589' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2);
}
.tag-male { background: var(--male-soft); color: var(--male); }
.tag-female { background: var(--female-soft); color: var(--female); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-gold { background: var(--gold-soft); color: var(--gold); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-primary { background: var(--primary-soft); color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { font-size: 40px; opacity: .5; }
.empty p { margin: 8px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(253, 247, 245, .88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #e47c92); color: #fff; font-size: 17px;
  box-shadow: 0 4px 12px rgba(201, 64, 92, .28);
}
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 1px; }
.topnav { display: flex; align-items: center; gap: 6px; }

/* ---------- 前台 Hero ---------- */
.hero { padding: 44px 0 26px; text-align: center; }
.hero h1 { font-size: 34px; line-height: 1.35; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero p { margin: 12px auto 0; max-width: 560px; color: var(--text-2); }
.hero-stats { display: flex; justify-content: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.hero-stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 22px; min-width: 108px; box-shadow: var(--shadow);
}
.hero-stat b { display: block; font-size: 24px; color: var(--primary); line-height: 1.2; }
.hero-stat span { font-size: 12px; color: var(--muted); }

/* ---------- 筛选栏 ---------- */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.filters .field { flex: 1 1 150px; min-width: 130px; }
.filters .field-grow { flex: 2 1 220px; }
.filters .actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---------- 会员卡片 ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 18px; padding-bottom: 40px; }
.member-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.member-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.member-photo {
  position: relative; height: 190px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--surface-3), var(--primary-soft));
}
.member-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.member-photo .initial {
  width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center;
  font-size: 30px; font-weight: 800; color: #fff; letter-spacing: 2px;
}
.member-photo .badge-gender {
  position: absolute; top: 12px; left: 12px; background: rgba(255,255,255,.94);
  border-radius: 999px; padding: 3px 12px; font-size: 12px; font-weight: 700;
}
.member-photo .badge-status {
  position: absolute; top: 12px; right: 12px; border-radius: 999px; padding: 3px 12px;
  font-size: 12px; font-weight: 700; background: rgba(255,255,255,.94); color: var(--primary);
}
.member-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.member-name { display: flex; align-items: baseline; gap: 8px; }
.member-name h3 { font-size: 18px; }
.member-name .meta { font-size: 13px; color: var(--muted); }
.member-line { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.member-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.member-req {
  font-size: 12.5px; color: var(--muted); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-top: auto;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

footer.site { border-top: 1px solid var(--border); padding: 26px 0 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(50, 30, 38, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 80;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--surface); border-radius: 20px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal-lg { max-width: 760px; }
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; }
.icon-btn { border: none; background: transparent; cursor: pointer; font-size: 20px; color: var(--muted); line-height: 1; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.form-section h4 { font-size: 13px; color: var(--primary); margin-bottom: 10px; }

.detail-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.detail-hero .avatar { width: 96px; height: 96px; border-radius: 18px; object-fit: cover; flex: 0 0 auto; background: var(--surface-3); }
.detail-hero .avatar-init { width: 96px; height: 96px; border-radius: 18px; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #fff; flex: 0 0 auto; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }

/* ---------- 后台布局 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: 0 0 216px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 8px 18px; }
.navitem {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 14px; border: none; background: transparent; text-align: left; width: 100%;
}
.navitem:hover { background: var(--surface-3); }
.navitem.active { background: var(--primary-soft); color: var(--primary); }
.navitem .ico { width: 20px; text-align: center; font-size: 15px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.admin-main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.view[hidden] { display: none; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 880px; }
table.data th {
  text-align: left; padding: 12px 14px; font-size: 12px; color: var(--muted); font-weight: 700;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 12.5px; color: var(--muted); }
.stat-card .value { font-size: 28px; font-weight: 800; line-height: 1.25; margin-top: 2px; }
.stat-card .value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat-card .sub { font-size: 12px; color: var(--muted); }
.stat-card.accent .value { color: var(--primary); }
.stat-card.gold .value { color: var(--gold); }
.stat-card.ok .value { color: var(--ok); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.chart-card h4 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.chart-card h4 span { font-size: 12px; color: var(--muted); font-weight: 500; }
.chart-card svg { width: 100%; height: auto; display: block; overflow: visible; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .bar-label { width: 74px; flex: 0 0 74px; color: var(--text-2); text-align: right; }
.bar-row .bar-track { flex: 1; height: 20px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), #e88ba1); transition: width .4s ease; }
.bar-row .bar-fill.blue { background: linear-gradient(90deg, var(--male), #7fb0dd); }
.bar-row .bar-fill.green { background: linear-gradient(90deg, #2f9e6e, #6fc99f); }
.bar-row .bar-fill.gold { background: linear-gradient(90deg, var(--gold), #e3c078); }
.bar-row .bar-value { width: 40px; flex: 0 0 40px; font-weight: 700; color: var(--text-2); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); justify-content: center; margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card > p { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.tabs { display: flex; gap: 4px; background: var(--surface-3); border-radius: 999px; padding: 4px; margin-bottom: 20px; }
.tabs button {
  flex: 1; border: none; background: transparent; padding: 8px 6px; border-radius: 999px;
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-2); transition: all .15s;
}
.tabs button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(120,70,80,.12); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.login-foot { margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.login-foot a { cursor: pointer; font-weight: 600; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f2d3d1; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #cfe9dc; }
.alert-info { background: var(--primary-soft); color: var(--primary); border: 1px solid #f6dbe3; }
.alert[hidden] { display: none; }

/* ---------- Toast ---------- */
#toast-host { position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(47, 36, 41, .94); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
}
.toast.ok { background: rgba(47, 158, 110, .96); }
.toast.err { background: rgba(208, 69, 63, .96); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.loading { display: grid; place-items: center; padding: 60px 0; color: var(--muted); gap: 10px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
  .sidebar .brand { padding: 0 4px 0 0; }
  .navitem { width: auto; }
  .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .admin-main { padding: 18px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 26px; }
}
