/* ==================================================================
   会员运营后台样式
   设计原则：浅色、信息密度适中、表格为主、无第三方依赖
   ================================================================== */
:root {
  --brand: #1a6dff;
  --brand-dark: #0d54d6;
  --brand-light: #eef4ff;
  --success: #07c160;
  --success-light: #e8f8ef;
  --danger: #ee0a24;
  --danger-light: #fdecee;
  --warning: #ff8f1f;
  --warning-light: #fff5e8;
  --gold: #b8860b;
  --gold-light: #fdf5e3;

  --text: #1f2329;
  --text-2: #5a6169;
  --text-3: #8f959e;
  --line: #e9ebef;
  --bg: #f4f6f9;
  --card: #ffffff;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 35, 41, 0.06), 0 6px 20px rgba(31, 35, 41, 0.04);
}

* { box-sizing: border-box; }

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

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

[hidden] { display: none !important; }

/* ================= 启动提示 / 登录页 ================= */
.boot-tip, .login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.boot-card {
  max-width: 560px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.boot-card h2 { font-size: 20px; margin-bottom: 14px; }
.boot-card p { color: var(--text-2); line-height: 1.8; }
.boot-card code {
  background: #f4f6f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--brand-dark);
}
.boot-sub { margin-top: 12px; font-size: 13px; color: var(--text-3); }

.login-view { background: linear-gradient(140deg, #eaf1ff, #f4f6f9 55%, #eef4ff); }

.login-box {
  width: 400px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(26, 109, 255, 0.12);
  padding: 40px 36px 32px;
}

.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { font-size: 48px; line-height: 1; }
.login-brand h1 { font-size: 22px; margin-top: 14px; }
.login-brand p { font-size: 13px; color: var(--text-3); margin-top: 8px; }

.login-field { display: block; margin-bottom: 18px; }
.login-field span {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.login-field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.login-field input:focus { border-color: var(--brand); }

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-tip {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  margin-top: 20px;
}

/* ================= 主框架 ================= */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}

.sb-logo { font-size: 26px; margin-right: 10px; }
.sb-text strong { display: block; font-size: 14px; }
.sb-text small { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.nav-item i { font-style: normal; font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: #f4f6f9; }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sf-user { min-width: 0; }
.sf-user span { display: block; font-size: 13px; font-weight: 600; }
.sf-user small { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; }
.topbar-tenant { font-size: 13px; color: var(--text-3); }

.page-root { padding: 20px 24px 48px; }

/* ================= 通用组件 ================= */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title { font-size: 15px; font-weight: 600; }
.panel-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* ---------------- KPI 卡片 ---------------- */
.kpi {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.kpi-label { font-size: 13px; color: var(--text-3); }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.kpi-accent { color: var(--brand); }
.kpi-success { color: var(--success); }
.kpi-warning { color: var(--warning); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  background: #fafbfc;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fafbfc; }
.table-empty {
  text-align: center;
  color: var(--text-3);
  padding: 36px 0 !important;
}
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- 按钮 ---------------- */
.btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { border-color: #cfd5de; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.94); }
.btn-sm { height: 28px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; height: 44px; font-size: 15px; }
.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  padding: 0 6px;
  font-size: 13px;
}
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 7px;
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}
textarea { height: auto; min-height: 76px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input:disabled, select:disabled, textarea:disabled { background: #f6f7f9; color: var(--text-3); }

.input-inline { width: 200px; }
.input-sm { height: 34px; }

/* ---------------- 徽标 ---------------- */
.badge {
  display: inline-block;
  font-size: 12px;
  line-height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--brand-light);
  color: var(--brand-dark);
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-gold { background: var(--gold-light); color: var(--gold); }
.badge-grey { background: #f1f3f5; color: var(--text-3); }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 28, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-mask.show { opacity: 1; }

.modal {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 20, 28, 0.18);
  transform: translateY(-8px);
  transition: transform 0.2s;
}
.modal-mask.show .modal { transform: translateY(0); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

.confirm-text { color: var(--text-2); line-height: 1.7; }

/* ---------------- 提示 ---------------- */
.toast-root {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(31, 35, 41, 0.9);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.22s;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: rgba(7, 193, 96, 0.95); }
.toast-error { background: rgba(238, 10, 36, 0.95); }

/* ---------------- 分页 ---------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-info { font-size: 12px; color: var(--text-3); }
.pager-btns { display: flex; gap: 8px; }

/* ---------------- 图表 ---------------- */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 220px;
  padding-top: 10px;
}
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bar {
  width: 60%;
  max-width: 44px;
  min-height: 3px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #6ba1ff, var(--brand));
  transition: height 0.4s;
}
.bar-label { font-size: 11px; color: var(--text-3); margin-top: 8px; }
.bar-value { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.chart-empty { text-align: center; color: var(--text-3); padding: 60px 0; font-size: 13px; }

/* ---------------- 其他 ---------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 7px 16px;
  border-radius: 18px;
  font-size: 13px;
  color: var(--text-2);
  background: #f4f6f9;
  cursor: pointer;
  border: none;
}
.tab.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }

.empty-block { text-align: center; color: var(--text-3); padding: 60px 0; font-size: 13px; }

.code-chip {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  letter-spacing: 1px;
  background: var(--brand-light);
  color: var(--brand-dark);
  border-radius: 6px;
  padding: 3px 10px;
  font-weight: 600;
}

.notice-box {
  background: var(--warning-light);
  border: 1px solid #ffe0bb;
  color: #9a6412;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.row-actions { display: flex; gap: 2px; flex-wrap: wrap; }

/* ---------------- 表单扩展 ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.checkbox-list { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  user-select: none;
}
.checkbox-item input { width: auto; height: auto; margin: 0; cursor: pointer; }
.checkbox-item.on { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-light); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .sr-text { font-size: 13px; }
.switch-row .sr-text small { display: block; color: var(--text-3); font-size: 12px; margin-top: 3px; }
.switch-row input[type=checkbox] { width: 16px; height: 16px; flex-shrink: 0; cursor: pointer; }

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f3f5;
  display: block;
}
.thumb-ph {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.desc-cell { max-width: 240px; }
.mt-16 { margin-top: 16px; }
