:root {
  color-scheme: light;
  --ink: #14212b;
  --ink-soft: #4d5f6d;
  --muted: #7b8a96;
  --line: #e4e9ee;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --sidebar: #10202b;
  --sidebar-2: #16303f;
  --accent: #0e7c66;
  --accent-soft: #e6f4f0;
  --amber: #b5791f;
  --amber-soft: #fdf3e2;
  --danger: #b83b3b;
  --danger-soft: #fbeaea;
  --blue: #2f5d8a;
  --blue-soft: #e9f0f8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 43, 0.04), 0 8px 24px rgba(16, 32, 43, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* 登录 */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(14, 124, 102, 0.18), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(181, 121, 31, 0.12), transparent 55%),
    #0f1d27;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 36px 34px 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  border-radius: 12px;
  margin-bottom: 18px;
}
.brand-mark.small { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; margin: 0; }
.login-card h1 { font-size: 20px; line-height: 1.35; margin-bottom: 6px; }
.login-card form { margin-top: 26px; display: grid; gap: 16px; }
.login-card label { display: grid; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.login-card input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 13px;
  background: #fbfcfd;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,124,102,.12); }
.login-note { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* 框架 */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #0c1821);
  color: #dbe6ec;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 0; }
.brand strong { display: block; font-size: 15px; color: #fff; letter-spacing: .02em; }
.brand span { display: block; font-size: 11px; color: #8fa4b1; margin-top: 1px; }
#nav { display: grid; gap: 2px; }
#nav a {
  padding: 10px 12px;
  border-radius: 8px;
  color: #b7c7d2;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s, color .15s;
}
#nav a::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px #4d6473;
}
#nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
#nav a.active { background: rgba(14,124,102,.22); color: #fff; }
#nav a.active::before { background: #37b394; box-shadow: none; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 0 8px 4px; }
.identity { font-size: 12px; color: #8fa4b1; }
.identity strong { display: block; color: #dbe6ec; font-size: 13px; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 30px 18px;
}
.topbar h2 { font-size: 21px; }
.topbar p { margin-top: 3px; font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.view { padding: 4px 30px 44px; max-width: 1400px; width: 100%; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #eef2f4; color: var(--ink-soft);
  white-space: nowrap;
}
.pill.live { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--blue-soft); color: var(--blue); }
.pill.dot::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }

/* 卡片与表格 */
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px 18px; }
.card + .card { margin-top: 16px; }
.section-gap { margin-top: 18px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.input, select.input {
  height: 36px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 11px; background: #fff; outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,124,102,.1); }
.input.narrow { width: 150px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: #c8d2d9; background: #fbfcfd; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0b6b57; }
.btn.danger { color: var(--danger); border-color: #eccaca; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: #9fb2bf; }
.btn.ghost:hover { background: rgba(255,255,255,.06); color: #fff; }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; letter-spacing: .02em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.clickable { cursor: pointer; }
.empty { padding: 38px 18px; text-align: center; color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 6px; padding: 4px; background: #eef2f4; border-radius: 9px; width: fit-content; }
.tabs button {
  border: none; background: transparent; padding: 6px 14px; border-radius: 7px;
  font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 10px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13px; background: var(--amber-soft); color: #7a5415; }
.alert.info { background: var(--blue-soft); color: #24486b; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 24, 33, .45);
  display: grid; place-items: center;
  padding: 20px;
}
.modal-panel {
  width: min(640px, 100%); max-height: 88vh; overflow: auto;
  background: #fff; border-radius: 12px; box-shadow: 0 30px 90px rgba(0,0,0,.3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-body { padding: 20px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 7px; border: none;
  background: transparent; font-size: 20px; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: #f2f5f7; color: var(--ink); }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.form-grid input, .form-grid select, .form-grid textarea {
  height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 11px; background: #fbfcfd;
}
.form-grid textarea { height: 84px; padding: 9px 11px; resize: vertical; }
.form-grid label.check-line { display: flex; align-items: center; gap: 8px; }
.form-grid label.check-line input { width: auto; height: auto; padding: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.inline-note { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  background: #14212b; color: #fff; padding: 11px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.22);
  max-width: 360px;
}
.toast.error { background: #8f2f2f; }

/* 积分包凭证审核 */
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.voucher-reason { color: var(--danger); }
.voucher-summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fafcfc; margin-bottom: 16px;
}
.voucher-summary > div > .muted { display: block; margin-bottom: 4px; }
.voucher-title { margin: 0 0 10px; font-size: 14px; color: var(--ink-soft); }
.voucher-list { display: grid; gap: 10px; max-height: 380px; overflow-y: auto; padding-right: 4px; }
.voucher-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.voucher-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.voucher-note { font-size: 13px; line-height: 1.6; word-break: break-word; }
.voucher-reject { margin-top: 6px; color: var(--danger); font-size: 12px; line-height: 1.5; }
.voucher-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.voucher-thumb {
  width: 84px; height: 84px; border-radius: 8px; border: 1px dashed var(--line);
  background: #fff; display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; overflow: hidden;
}
.voucher-thumb-loading { color: var(--muted); font-size: 11px; }
.voucher-thumb.failed { color: var(--danger); font-size: 11px; border-style: solid; border-color: #eccaca; }
.voucher-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.voucher-reject-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 20, 26, .78);
  display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: 0 18px 48px rgba(0,0,0,.45); }

/* 特殊积分包：商户授权弹窗 */
.grant-list {
  max-height: 320px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 12px; background: #fff;
}
.grant-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px;
}
.grant-row:last-child { border-bottom: none; }
.grant-row .grow { flex: 1; min-width: 0; word-break: break-word; }

/* 图文文章编辑器 */
.article-block {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: #fff; display: grid; gap: 10px; margin-bottom: 12px;
}
.article-block-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.article-block-head .grow { flex: 1; }

/* 富文本工具栏与编辑区 */
.rich-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 8px; background: #f6f8f9; border: 1px solid var(--line); border-radius: 8px;
}
.rt-btn {
  height: 28px; min-width: 30px; padding: 0 7px; border: 1px solid var(--line);
  background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; line-height: 1;
}
.rt-btn:hover { border-color: var(--accent); color: var(--accent); }
.rt-select {
  height: 28px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 12px; padding: 0 4px;
}
.rt-color-wrap {
  position: relative; display: inline-flex; align-items: center; gap: 4px; height: 28px;
  padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer;
}
.rt-color-label { font-size: 13px; font-weight: 600; border-bottom: 3px solid #333; line-height: 1.1; }
.rt-color { width: 18px; height: 18px; border: none; padding: 0; background: transparent; cursor: pointer; }
.rt-sep { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }
.rich-editor {
  min-height: 140px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; line-height: 1.8; font-size: 14px; outline: none; overflow-wrap: anywhere;
}
.rich-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,124,102,.1); }
.rich-editor:empty:before { content: attr(data-placeholder); color: #9aa7b0; }
.rich-editor p { margin: 0 0 10px; }
.rich-editor h1 { font-size: 22px; margin: 4px 0 10px; }
.rich-editor h2 { font-size: 19px; margin: 4px 0 10px; }
.rich-editor h3 { font-size: 16px; margin: 4px 0 10px; }
.article-image-preview {
  max-width: 100%; max-height: 280px; border-radius: 8px;
  background: #f2f5f7; display: block;
}
.article-preview { max-height: 66vh; overflow-y: auto; }
.article-preview-text { white-space: pre-wrap; line-height: 1.8; font-size: 14px; margin-bottom: 10px; }
.article-preview-text p { margin: 0 0 10px; }
.article-preview-text h1 { font-size: 22px; margin: 4px 0 10px; }
.article-preview-text h2 { font-size: 19px; margin: 4px 0 10px; }
.article-preview-text h3 { font-size: 16px; margin: 4px 0 10px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 12px 4px 2px; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .voucher-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  #nav { display: flex; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
  .stats { grid-template-columns: 1fr; }
}

/* P4：侧栏分组标签 */
.nav-group-label {
  margin: 14px 10px 4px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}
#nav a + .nav-group-label { margin-top: 16px; }
@media (max-width: 900px) {
  .nav-group-label { display: none; }
}

/* ============ P4：统一表格密度、吸顶筛选与 chip 筛选 ============ */
.toolbar { position: sticky; top: 0; z-index: 6; background: rgba(244, 247, 246, .96); backdrop-filter: blur(6px); padding: 8px 0; }
.toolbar .input { min-width: 160px; }
.toolbar .input.narrow { width: 190px; min-width: 140px; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px; }
.chip {
  border: 1px solid #e2e8e5; background: #fff; color: #4d5f57;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: #bfe0d6; color: #0e7c66; }
.chip.active { background: #e6f4f0; border-color: #bfe0d6; color: #0e7c66; font-weight: 600; }
.chip-count { font-size: 11px; background: #eef3f1; color: #5d6b57; padding: 1px 6px; border-radius: 999px; }
.chip.active .chip-count { background: #fff; color: #0e7c66; }
.table-wrap { overflow: auto; max-height: calc(100vh - 300px); }
.table-wrap thead th { position: sticky; top: 0; background: #f7faf8; z-index: 1; }
.table-wrap table td, .table-wrap table th { padding-top: 10px; padding-bottom: 10px; }
.table-wrap tbody tr:hover { background: #fafcfb; }
.table-empty { padding: 34px 16px; text-align: center; color: #7d8b85; }
.stat .value { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .toolbar { position: static; }
  .table-wrap { max-height: none; }
}

/* 优惠券图片（D2.2）：列表缩略图与详情大图 */
.coupon-thumb {
  width: 72px; height: 48px; object-fit: cover;
  border-radius: 6px; border: 1px solid #e2e8e5; background: #eef2f0;
  display: block; margin-bottom: 4px;
}
.coupon-image-list { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.coupon-image-item { margin: 0; width: 180px; }
.coupon-image-item img {
  width: 180px; height: 130px; object-fit: cover;
  border-radius: 8px; border: 1px solid #e2e8e5; background: #eef2f0; display: block;
}
.coupon-image-item figcaption { font-size: 12px; color: #5d6b57; margin-top: 4px; }

/* 合伙人工作台（上线收尾）：审核图片、分页与操作记录 */
.coupon-thumb-btn {
  padding: 0; border: 1px solid var(--line, #dde5e2); border-radius: 8px;
  background: #fff; cursor: zoom-in; overflow: hidden; display: block;
}
.coupon-thumb-btn img { width: 64px; height: 48px; object-fit: cover; display: block; }
.coupon-thumb-btn:hover { border-color: var(--primary, #0e7c66); }
.image-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.image-strip figure { margin: 0; border: 1px solid var(--line, #dde5e2); border-radius: 10px; overflow: hidden; background: #f7faf9; }
.image-strip img { width: 100%; height: 180px; object-fit: contain; display: block; background: #fff; }
.image-strip figcaption { padding: 6px 10px; font-size: 12px; color: #6b7c85; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.pager .btn[disabled] { opacity: .45; cursor: not-allowed; }

/* 协议编辑（后台） */
.policy-editor {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
  resize: vertical;
}

.grid.cards { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* 超级管理员积分调整 */
.alert.ok { background: #e6f4f0; color: #0e634f; }
.adjust-preview {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f2f7f5;
  border: 1px solid #dde8e3;
  font-size: 13px;
  color: #24483c;
}
.adjust-preview.danger-text { background: #fdecea; border-color: #f5c6c1; color: #a12b1f; }
