/* ==========================================================================
   后台管理样式
   ========================================================================== */

:root {
  --bg: #f3f4f7;
  --panel: #ffffff;
  --ink: #1b2130;
  --ink-2: #3a4353;
  --muted: #6f7787;
  --muted-2: #98a0ae;
  --line: #e6e8ee;
  --line-2: #eef0f4;
  --brand: #a97f2c;
  --brand-light: #f5edd9;
  --sidebar: #141922;
  --sidebar-2: #1b222d;
  --ok: #0f7a55;
  --ok-bg: #e7f6ef;
  --warn: #a15c07;
  --warn-bg: #fdf3e2;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --blue: #1d4ed8;
  --blue-bg: #eaeffd;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05), 0 1px 3px rgba(17, 24, 39, .04);
  --shadow: 0 4px 16px rgba(17, 24, 39, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
table { border-collapse: collapse; width: 100%; }

.admin-shell { display: flex; min-height: 100vh; }

/* ------------------------------ 侧栏 ------------------------------ */

.sidebar {
  width: 226px;
  flex: 0 0 226px;
  background: var(--sidebar);
  color: #cdd3de;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.side-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: var(--brand);
}
.side-brand strong {
  display: block;
  color: #f1f3f7;
  font-size: 14px;
  letter-spacing: .04em;
  line-height: 1.4;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-brand small { color: #6e7788; font-size: 11px; letter-spacing: .14em; }

.side-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.side-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  color: #9aa3b2;
  margin-bottom: 3px;
  transition: background .18s, color .18s;
}
.side-link .ic { width: 16px; text-align: center; font-size: 13px; opacity: .8; }
.side-link:hover { background: rgba(255, 255, 255, .045); color: #e6eaf1; }
.side-link.is-active { background: linear-gradient(90deg, rgba(200, 162, 74, .18), rgba(200, 162, 74, .05)); color: #f0d9a4; }
.side-link.is-active .ic { opacity: 1; }
.badge-dot {
  margin-left: auto;
  background: #c0392b;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.side-foot {
  padding: 14px 20px 20px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.side-foot a { font-size: 12.5px; color: #7d8697; }
.side-foot a:hover { color: #d7dce5; }

/* ------------------------------ 主区 ------------------------------ */

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

.topbar {
  height: 60px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumb { font-size: 13.5px; color: var(--ink-2); }
.crumb span { color: var(--muted-2); margin: 0 5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: var(--muted); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #ecdfc4;
}

.menu-btn {
  display: none;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
}
.menu-btn span { display: block; width: 15px; height: 1.5px; background: var(--ink-2); margin: 3px auto; }

.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ------------------------------ 页头 ------------------------------ */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-title { font-size: 21px; letter-spacing: .01em; }
.page-desc { color: var(--muted); font-size: 13px; margin-top: 5px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ 卡片 / 统计 ------------------------------ */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 14.5px; }
.card-head .sub { font-size: 12.5px; color: var(--muted-2); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -22px; top: -22px;
  width: 66px; height: 66px;
  border-radius: 50%;
  background: rgba(200, 162, 74, .07);
}
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin: 4px 0 2px; color: var(--ink); }
.stat-value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.stat-sub { font-size: 12px; color: var(--muted-2); }

/* ------------------------------ 表格 ------------------------------ */

.table-wrap { overflow-x: auto; }
table.data { min-width: 100%; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--muted);
  background: #fafbfc;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-2);
  color: var(--ink-2);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fcfcfd; }
table.data .num { font-variant-numeric: tabular-nums; }
table.data .strong { color: var(--ink); font-weight: 500; }
table.data .muted { color: var(--muted-2); font-size: 12.5px; }
table.data .nowrap { white-space: nowrap; }
table.data .actions-cell { white-space: nowrap; text-align: right; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.badge-amber { background: var(--warn-bg); color: var(--warn); border-color: #f4e3c4; }
.badge-blue { background: var(--blue-bg); color: var(--blue); border-color: #d9e2fb; }
.badge-green { background: var(--ok-bg); color: var(--ok); border-color: #cdeadd; }
.badge-gray { background: #f1f2f5; color: var(--muted); border-color: #e6e8ee; }
.badge-red { background: var(--danger-bg); color: var(--danger); border-color: #f8d7d5; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: #f3f4f7;
  color: var(--muted);
  font-size: 12px;
  margin: 1px 3px 1px 0;
}

.empty {
  padding: 54px 20px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13.5px;
}
.empty .big { font-size: 30px; color: #d6dae2; display: block; margin-bottom: 8px; }

/* ------------------------------ 按钮 / 表单 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover { border-color: #cfd4dd; background: #fbfbfc; }
.btn-primary {
  background: linear-gradient(180deg, #b98c33, #a97f2c);
  border-color: #a97f2c;
  color: #fff;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(169, 127, 44, .3);
}
.btn-primary:hover { background: linear-gradient(180deg, #c4963b, #a97f2c); border-color: #a97f2c; }
.btn-danger { color: var(--danger); border-color: #f0cfcd; background: #fff; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-link { border: none; background: none; color: var(--blue); padding: 4px 6px; }
.btn-link:hover { background: var(--blue-bg); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.field { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d9dde5;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: #c2a05c;
  box-shadow: 0 0 0 3px rgba(200, 162, 74, .14);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
.hint { font-size: 12px; color: var(--muted-2); margin-top: 5px; line-height: 1.7; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  background: #fcfcfd;
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; }
.filter-bar .spacer { flex: 1; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 12px 18px 0; border-bottom: 1px solid var(--line-2); }
.tabs a {
  padding: 7px 13px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 7px 7px 0 0;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); background: #f7f8fa; }
.tabs a.is-active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.tabs a .n { font-size: 11.5px; color: var(--muted-2); margin-left: 3px; }

.alert {
  border-radius: 9px;
  padding: 11px 15px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #cdeadd; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #f8d7d5; }
.alert-info { background: var(--brand-light); color: #7a5a18; border-color: #ecdfc4; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ------------------------------ 分页 ------------------------------ */

.pager { display: flex; gap: 5px; padding: 14px 18px; flex-wrap: wrap; align-items: center; }
.pager a, .pager span {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
  background: #fff;
}
.pager a:hover { border-color: #c9cfd8; background: #f9fafb; }
.pager .cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .gap { border: none; background: none; color: var(--muted-2); }

/* ------------------------------ 仪表盘 ------------------------------ */

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 148px;
  padding: 0 4px;
}
.chart-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bars .bar {
  width: 100%;
  max-width: 34px;
  border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, #d7b978, #b98c33);
  min-height: 3px;
  position: relative;
  transition: filter .2s;
}
.chart-bars .bar-col:hover .bar { filter: brightness(1.08); }
.chart-bars .bar-val { font-size: 11px; color: var(--muted); }
.chart-bars .bar-label { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }

.quick-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all .18s;
}
.quick-link .ic { color: var(--brand); }
.quick-link:hover { border-color: #e0d3b4; background: #fffdf8; transform: translateY(-1px); }

/* ------------------------------ 详情 / 时间线 ------------------------------ */

.detail-list { display: grid; grid-template-columns: 96px 1fr; gap: 12px 16px; font-size: 13.5px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; color: var(--ink); word-break: break-word; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 18px 4px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -18px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
}
.timeline-item .t { font-size: 12.5px; color: var(--muted-2); }
.timeline-item .m { font-size: 13.5px; color: var(--ink); }
.timeline-item.plus::before { border-color: var(--ok); }
.timeline-item.minus::before { border-color: var(--danger); }

.amount-plus { color: var(--ok); font-weight: 500; }
.amount-minus { color: var(--danger); font-weight: 500; }

.balance-box {
  border: 1px solid #ecdfc4;
  background: linear-gradient(135deg, #fffdf7, #fdf7e9);
  border-radius: 12px;
  padding: 20px 22px;
}
.balance-box .label { font-size: 12.5px; color: #8b6b28; }
.balance-box .value { font-size: 32px; font-weight: 600; color: #6f5316; letter-spacing: -.01em; }
.balance-box .value small { font-size: 13px; font-weight: 400; margin-left: 3px; }

/* ------------------------------ 登录页 ------------------------------ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 18px;
  background:
    radial-gradient(700px 400px at 50% 0%, rgba(200, 162, 74, .16), transparent 70%),
    linear-gradient(180deg, #131720, #0c0f14);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: rgba(255, 255, 255, .97);
  border-radius: 16px;
  padding: 34px 32px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .45);
}
.login-card .logo { color: var(--brand); margin-bottom: 16px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.login-card .field { margin-bottom: 15px; }
.login-card .btn { width: 100%; padding: 11px; margin-top: 6px; }
.login-foot { text-align: center; font-size: 12.5px; color: var(--muted-2); margin-top: 18px; }
.login-foot a { color: var(--brand); }
.login-err {
  background: var(--danger-bg);
  border: 1px solid #f8d7d5;
  color: var(--danger);
  font-size: 13px;
  padding: 10px 13px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 1100px) {
  .grid-2, .grid-2-even { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 20px 0 50px rgba(0, 0, 0, .2);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .crumb { font-size: 13px; }
  .who { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(11, 14, 19, .45);
    z-index: 25;
  }
}

@media (max-width: 560px) {
  .page-title { font-size: 18px; }
  .stat-value { font-size: 22px; }
  .quick-links { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 84px 1fr; }
}

/* ==========================================================================
   加盟商会员中心
   ========================================================================== */

.agent-body { background: var(--bg); }

.agent-top {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 3px rgba(17, 24, 39, .03);
}
.agent-top-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.agent-brand { display: flex; align-items: center; gap: 9px; color: var(--brand); }
.agent-brand strong { display: block; font-size: 14px; color: var(--ink); line-height: 1.3; }
.agent-brand small { font-size: 11px; color: var(--muted-2); letter-spacing: .1em; }

.agent-nav { display: flex; gap: 3px; }
.agent-nav a {
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--muted);
  transition: .18s;
  white-space: nowrap;
}
.agent-nav a:hover { background: #f6f7f9; color: var(--ink); }
.agent-nav a.is-active { background: var(--brand-light); color: #7a5a18; font-weight: 500; }

.agent-user { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.agent-user .bal { color: var(--muted); }
.agent-user .bal strong { color: var(--brand); font-size: 16px; margin: 0 2px; }
.agent-user .who { color: var(--muted-2); }

.agent-main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 24px 56px;
}
.agent-foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 24px 26px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted-2);
}

@media (max-width: 860px) {
  .agent-top-inner {
    height: auto;
    padding: 12px 16px 0;
    flex-wrap: wrap;
    gap: 10px;
  }
  .agent-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .agent-user { gap: 10px; }
  .agent-user .who { display: none; }
  .agent-main { padding: 18px 16px 40px; }
  .agent-foot { padding: 16px; flex-direction: column; }
}
