:root {
  --primary: #C4553A;
  --primary-deep: #8E3A28;
  --primary-soft: #FBEFEA;
  --gold: #E8A33D;
  --gold-deep: #C8852A;
  --paper: #F6F1EC;
  --card: #FFFFFF;
  --line: #ECE0D6;
  --text: #3A2E28;
  --text-2: #7A6A5E;
  --text-3: #A9998B;
  --green: #2E9E6B;
  --green-soft: #E5F4EC;
  --red: #D9534F;
  --red-soft: #FBE9E8;
  --amber: #C8852A;
  --amber-soft: #FBF0DD;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(58, 46, 40, 0.04), 0 2px 8px rgba(58, 46, 40, 0.05);
  --shadow: 0 4px 18px rgba(142, 58, 40, 0.08);
  --shadow-lg: 0 12px 38px rgba(58, 46, 40, 0.14);
  --ring: 0 0 0 3px rgba(196, 85, 58, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ===== 登录 ===== */
.login-mask {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(232,163,61,0.25), transparent 60%),
    linear-gradient(135deg, #C4553A 0%, #8E3A28 100%);
}
.login-card {
  width: 86%; max-width: 380px;
  background: #fff; border-radius: 22px; padding: 40px 30px 32px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.30);
  text-align: center;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-mark {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #C4553A, #8E3A28);
  color: #fff; font-size: 26px; font-weight: 800;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 19px; font-weight: 800; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-3); margin: 18px 0 22px; }
.login-input {
  width: 100%; height: 48px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 15px; font-size: 15px; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-input + .login-input { margin-top: 12px; }
.login-input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.login-btn {
  width: 100%; height: 48px; margin-top: 18px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #C4553A, #8E3A28); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .08s, box-shadow .15s, filter .15s;
  box-shadow: 0 8px 20px rgba(142,58,40,0.28);
}
.login-btn:hover { filter: brightness(1.04); }
.login-btn:active { transform: scale(0.985); }
.login-err { color: var(--red); font-size: 13px; margin-top: 14px; min-height: 16px; }

/* ===== 应用骨架 ===== */
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 60px;
  background: linear-gradient(135deg, #C4553A 0%, #8E3A28 100%);
  color: #fff; position: sticky; top: 0; z-index: 30;
  box-shadow: 0 2px 14px rgba(142,58,40,0.22);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; letter-spacing: .5px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(255,255,255,0.18); color: #fff; font-size: 15px; font-weight: 800;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; color: rgba(255,255,255,0.92); }
.logout-btn {
  border: 1px solid rgba(255,255,255,0.45); background: rgba(255,255,255,0.08);
  color: #fff; border-radius: 999px; padding: 6px 16px; font-size: 13px; cursor: pointer;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,255,255,0.18); }

.layout { display: flex; flex: 1; min-height: 0; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  border: none; background: transparent; cursor: pointer;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14.5px; font-weight: 600; text-align: left;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.tab:hover { background: var(--primary-soft); color: var(--primary-deep); }
.tab.on {
  background: var(--primary-soft); color: var(--primary-deep); font-weight: 700;
  border-left-color: var(--primary);
}
.side-foot { margin-top: auto; padding: 14px 14px 4px; font-size: 11px; color: var(--text-3); line-height: 1.6; }

/* ===== 内容区 ===== */
.content { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 28px 40px; }
.panel { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-head { margin-bottom: 18px; }
.panel-title { margin: 0; font-size: 20px; font-weight: 800; color: var(--text); }
.panel-desc { margin: 6px 0 0; font-size: 13px; color: var(--text-3); }

/* ===== 统计卡片 ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat.pending::before { background: var(--amber); }
.stat.approved::before { background: var(--green); }
.stat.rejected::before { background: var(--red); }
.stat .n { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.stat.pending .n { color: var(--amber); }
.stat.approved .n { color: var(--green); }
.stat.rejected .n { color: var(--red); }
.stat.total .n { color: var(--primary); }
.stat.waiting::before { background: var(--gold-deep); }
.stat.waiting .n { color: var(--gold-deep); }

/* 访客留资统计有 5 张卡片 */
#viewerStats { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* ===== 工具栏 ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters { display: flex; gap: 6px; }
.flt {
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  border-radius: 999px; padding: 8px 15px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.flt:hover { border-color: var(--primary); color: var(--primary); }
.flt.on { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.search {
  flex: 1; min-width: 180px; height: 42px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 15px; font-size: 14px; outline: none; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus { border-color: var(--primary); box-shadow: var(--ring); }
.refresh {
  border: 1px solid var(--line); background: #fff; color: var(--primary);
  border-radius: var(--radius-sm); padding: 0 18px; height: 42px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.refresh:hover { background: var(--primary-soft); }
.refresh:active { transform: scale(0.98); }
.refresh.ghost { background: var(--primary-soft); color: var(--primary-deep); border-color: transparent; }
.join-select {
  height: 42px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 12px; font-size: 13px; color: var(--text-2); background: #fff;
  outline: none; cursor: pointer; flex: 0 0 auto; min-width: 152px;
}
.join-select:focus { border-color: var(--primary); box-shadow: var(--ring); }

/* ===== 列表卡片 ===== */
.list { display: flex; flex-direction: column; gap: 12px; }
.pcard, .ccard, .ucard, .rcard {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.pcard:hover, .ccard:hover, .ucard:hover, .rcard:hover {
  transform: translateY(-2px); box-shadow: var(--shadow); border-color: #e2d2c4;
}
.pc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pc-name { font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.4; flex: 1; }
.pc-meta { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.ptag { font-size: 11px; padding: 3px 10px; border-radius: 6px; background: #f3e7da; color: var(--text-2); }
.ptag.cat { background: var(--primary); color: #fff; font-weight: 700; }
.ptag.off { background: var(--gold); color: #fff; }

.badge { font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.approved { background: var(--green-soft); color: var(--green); }
.badge.rejected { background: var(--red-soft); color: var(--red); }

.pc-row { font-size: 13px; color: var(--text-2); margin-top: 8px; line-height: 1.65; }
.pc-row b { color: var(--text); }
.pc-contact { font-size: 13px; color: var(--primary); margin-top: 8px; font-weight: 600; }
.pc-reject { font-size: 12px; color: var(--red); margin-top: 8px; }
.pc-actions { display: flex; gap: 10px; margin-top: 14px; }
.pc-done {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  background: #f0ede7;
  border: 1px dashed #d8d2c8;
}

/* ===== 按钮 ===== */
.btn {
  flex: 1; border: none; border-radius: var(--radius-sm); padding: 11px 0; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn.approve { background: var(--green); color: #fff; box-shadow: 0 6px 16px rgba(46,158,107,0.22); }
.btn.reject { background: var(--red); color: #fff; box-shadow: 0 6px 16px rgba(217,83,79,0.20); }
/* 接洽按钮与审核按钮同排，用浅色区分主次；同时给通用模态框的「保存」补上主色 */
.btn.contact { background: var(--primary-soft); color: var(--primary-deep); border: 1px solid rgba(196,85,58,0.28); box-shadow: none; }
.btn.primary { background: linear-gradient(135deg, #C4553A, #8E3A28); color: #fff; box-shadow: 0 6px 16px rgba(142,58,40,0.22); }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: #f3e7da; color: var(--text-2); box-shadow: none; }

.empty {
  text-align: center; padding: 56px 0; color: var(--text-3); font-size: 14px;
  background: #fff; border: 1px dashed var(--line); border-radius: var(--radius);
}

/* ===== 加入申请卡片 ===== */
.jtag-wait { background: var(--amber-soft); color: var(--amber); font-weight: 700; }
.jtag-done { background: var(--green-soft); color: var(--green); font-weight: 700; }
.jc-note { background: var(--green-soft); border-radius: 8px; padding: 8px 12px; color: #216B49; }
.modal-static { font-size: 14px; color: var(--text); font-weight: 700; padding: 9px 0; }
.modal-textarea {
  width: 100%; min-height: 108px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 14px; line-height: 1.6; color: var(--text);
  outline: none; box-sizing: border-box; font-family: inherit;
}
.modal-textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }

/* ===== 社群档位 ===== */
.btn.edit { background: #fff; color: var(--primary-deep); border: 1px solid var(--line); box-shadow: none; }
.tier-card .ck .badge { font-size: 10px; padding: 3px 9px; margin-left: 6px; vertical-align: middle; }
.tier-items { max-width: 720px; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 访客留资 ===== */
.viewer-phone {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .6px;
  color: var(--primary-deep);
  font-variant-numeric: tabular-nums;
}
.viewer-logs { max-height: 46vh; overflow: auto; margin: 8px 0 18px; }
.viewer-log {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 13.5px; color: var(--text);
}
.viewer-log time { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }

/* ===== 分类管理 ===== */
.cat-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ci { height: 42px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 12px; font-size: 14px; outline: none; background: #fff; transition: border-color .15s, box-shadow .15s; }
.ci:focus { border-color: var(--primary); box-shadow: var(--ring); }
.ci { flex: 1; min-width: 140px; }
.ci-s { max-width: 92px; flex: 0 0 92px; }
.cat-add-btn { border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, #C4553A, #8E3A28); color: #fff; padding: 0 20px; height: 42px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 16px rgba(142,58,40,0.22); transition: filter .15s; }
.cat-add-btn:hover { filter: brightness(1.05); }
.ccard { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ccard .ck { font-size: 15px; font-weight: 700; color: var(--text); }
.ccard .cl { font-size: 13px; color: var(--text-3); }
.ccard .cmeta { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.ccard .cact { display: flex; gap: 8px; align-items: center; }
.toggle { font-size: 12px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text-2); transition: all .15s; }
.toggle.on { background: var(--green-soft); color: var(--green); border-color: transparent; }
.toggle.off { background: var(--red-soft); color: var(--red); border-color: transparent; }
.del { font-size: 12px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--red); transition: all .15s; }
.del:hover { background: var(--red-soft); }

/* ===== 用户 / 角色 卡片 ===== */
.ucard .u-top, .rcard .r-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ucard .u-name { font-size: 16px; font-weight: 800; }
.ucard .u-meta { font-size: 12.5px; color: var(--text-3); margin-top: 6px; line-height: 1.7; }
.tag-role { font-size: 11px; padding: 3px 10px; border-radius: 6px; background: var(--primary); color: #fff; margin-right: 4px; white-space: nowrap; }
.tag-perm { font-size: 11px; padding: 4px 10px; border-radius: 6px; background: #f3e7da; color: var(--text-2); margin: 4px 4px 0 0; display: inline-block; }
.u-act, .r-act { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mini { font-size: 12.5px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text-2); transition: all .15s; }
.mini:hover { border-color: var(--primary); color: var(--primary); }
.mini.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.mini.primary:hover { filter: brightness(1.05); color: #fff; }
.mini.danger { color: var(--red); }
.mini.danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.status-dot { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.status-dot.active { background: var(--green-soft); color: var(--green); }
.status-dot.disabled { background: var(--red-soft); color: var(--red); }
.badge-builtin { font-size: 10px; padding: 2px 8px; border-radius: 5px; background: var(--gold); color: #fff; margin-left: 6px; }

/* ===== Modal ===== */
.modal-mask { position: fixed; inset: 0; z-index: 200; background: rgba(40,30,26,0.42); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; animation: fade .2s ease; }
.modal-box { width: 92%; max-width: 460px; max-height: 86vh; overflow: auto; background: #fff; border-radius: 18px; padding: 24px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--primary-deep); }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.modal-input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 13px; font-size: 14px; outline: none; box-sizing: border-box; background: #fff; transition: border-color .15s, box-shadow .15s; }
.modal-input:focus { border-color: var(--primary); box-shadow: var(--ring); }
select.modal-input { appearance: none; }
.modal-check { display: flex; flex-wrap: wrap; gap: 8px; max-height: 260px; overflow: auto; }
.modal-check label { display: flex; align-items: center; gap: 6px; font-size: 13px; background: #f7efe6; padding: 7px 11px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.modal-check label:hover { background: var(--primary-soft); }
.modal-group-title { font-size: 12px; color: var(--text-3); margin: 12px 0 5px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn.cancel { background: #f3e7da; color: var(--text-2); box-shadow: none; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(58,46,40,0.94); color: #fff; padding: 11px 22px; border-radius: 999px;
  font-size: 14px; z-index: 320; max-width: 86%; box-shadow: var(--shadow-lg);
}

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--line); padding: 10px 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .tab { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 14px; }
  .tab.on { border-left: none; border-bottom-color: var(--primary); }
  .side-foot { display: none; }
  .content { padding: 18px 16px 36px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 登记门槛（平台设置） ===== */
.policy-box { max-width: 760px; }
.pol-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.pol-label { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 12px; }
.pol-hint { font-size: 12.5px; color: var(--text-3); line-height: 1.7; margin: -4px 0 12px; }
.pol-modes { display: flex; flex-direction: column; gap: 10px; }
.pol-mode {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; cursor: pointer; background: #fff; transition: border-color .15s, background .15s, box-shadow .15s;
}
.pol-mode:hover { border-color: rgba(196, 85, 58, 0.35); background: var(--primary-soft); }
.pol-mode.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(196, 85, 58, 0.1); }
.pol-mode input { margin-top: 3px; accent-color: var(--primary); }
.pol-mode-t { font-size: 14px; font-weight: 800; color: var(--text); }
.pol-mode-d { font-size: 12.5px; color: var(--text-2); line-height: 1.65; margin-top: 4px; }
.pol-tiers { display: flex; flex-wrap: wrap; gap: 8px; }
.pol-tier {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px;
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; transition: all .15s; color: var(--text-2);
}
.pol-tier.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-deep); font-weight: 700; }
.pol-tier input { accent-color: var(--primary); }
.pol-tag { font-size: 10px; padding: 1px 7px; border-radius: 5px; background: var(--red-soft); color: var(--red); }
.pol-empty { font-size: 13px; color: var(--text-3); }
.pol-check {
  display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--text-2);
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); line-height: 1.6; cursor: pointer;
}
.pol-check input { margin-top: 2px; accent-color: var(--primary); }
.pol-actions { display: flex; gap: 10px; margin: 4px 0 14px; }
.pol-actions .btn { min-width: 140px; }
.pol-summary { font-size: 12.5px; color: var(--text-3); }
