* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4f6ef7;
  --primary-dark: #3d5ae0;
  --primary-light: #eef1fe;
  --success: #16a34a;
  --success-light: #e8f7ee;
  --danger: #dc2626;
  --danger-light: #fdecec;
  --warning: #d97706;
  --warning-light: #fef4e6;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #98a1b0;
  --border: #e5e8ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(30, 40, 80, 0.06);
  --shadow-lg: 0 8px 32px rgba(30, 40, 80, 0.14);
}
html, body { height: 100%; }
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录页 ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; overflow: hidden; }
.auth-bg { position: absolute; inset: 0; background: linear-gradient(135deg, #e8edfd 0%, #f0f4ff 40%, #fdf4ee 100%); z-index: 0; }
.auth-bg::before, .auth-bg::after { content: ""; position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.auth-bg::before { width: 420px; height: 420px; background: #a8b8ff; top: -120px; left: -80px; }
.auth-bg::after { width: 380px; height: 380px; background: #ffc9a3; bottom: -120px; right: -60px; }
.auth-card { position: relative; z-index: 1; width: 400px; max-width: calc(100vw - 32px); background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 40px 36px 28px; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo-icon { width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), #7b96ff); color: #fff; font-size: 30px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(79, 110, 247, .35); }
.auth-logo h1 { font-size: 22px; font-weight: 700; }
.auth-sub { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.auth-form .field { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 13px; transition: all .2s; }
.seg-btn.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-tip { margin-top: 18px; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.6; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- 通用组件 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; transition: all .18s; font-family: inherit; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-light); border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit; color: var(--text); background: #fff; transition: border .18s, box-shadow .18s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 110, 247, .14); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 224px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; }
.side-brand .logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #7b96ff); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.side-brand b { font-size: 15px; display: block; }
.side-brand small { color: var(--text-3); font-size: 11px; }
.side-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; color: var(--text-2); cursor: pointer; font-size: 14px; margin-bottom: 2px; transition: all .15s; border: none; background: none; width: 100%; font-family: inherit; text-align: left; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; }
.side-user { border-top: 1px solid var(--border); padding: 14px 18px; }
.side-user .u-name { font-weight: 600; font-size: 14px; }
.side-user .u-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.main { flex: 1; margin-left: 224px; padding: 24px 28px; max-width: 1280px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }

/* ---------- 卡片/统计 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -18px; top: -18px; width: 74px; height: 74px; border-radius: 50%; background: var(--stat-color, var(--primary)); opacity: .1; }
.stat .label { color: var(--text-3); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .extra { color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { color: var(--text-3); font-weight: 500; font-size: 12px; background: #fafbfc; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-green { background: var(--success-light); color: var(--success); }
.pill-red { background: var(--danger-light); color: var(--danger); }
.pill-blue { background: var(--primary-light); color: var(--primary); }
.pill-amber { background: var(--warning-light); color: var(--warning); }
.pill-gray { background: #eef0f3; color: var(--text-2); }
.badge-up { color: var(--success); font-weight: 700; }
.badge-down { color: var(--danger); font-weight: 700; }

/* ---------- 类型/渠道标签 ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.tag-gray { background: #eef0f3; color: var(--text-2); }
.tag-badge { background: var(--warning-light); color: #9a6a00; }
.tag-admin { background: var(--primary-light); color: var(--primary); }
.tag-mall { background: var(--success-light); color: var(--success); }
.tag-task { background: #f3e8ff; color: #7c3aed; }
.tag-points { background: var(--success-light); color: var(--success); }
.tag-reward { background: #fff4e5; color: #b45309; }

/* ---------- 复选框组 ---------- */
.check-group { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.check-group .check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-1); cursor: pointer; }
.check-group .check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 6vh 16px; overflow-y: auto; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 480px; max-width: 100%; box-shadow: var(--shadow-lg); animation: modalIn .22s ease; }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--text-3); cursor: pointer; padding: 4px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- 提示 ---------- */
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-80px); background: #1f2430; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14px; z-index: 200; transition: all .3s; box-shadow: var(--shadow-lg); opacity: 0; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---------- 积分商城 ---------- */
.mall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.mall-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: all .2s; }
.mall-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.mall-card.is-badge { border: 1px solid rgba(255, 177, 32, .45); }
.mall-card-img { height: 120px; background: linear-gradient(135deg, var(--primary-light), #f6f8ff); display: flex; align-items: center; justify-content: center; font-size: 46px; overflow: hidden; }
.mall-card-img img { width: 100%; height: 100%; object-fit: cover; }
.mall-badge-icon { font-size: 46px; line-height: 1; }
.mall-badge-icon img { width: 64px; height: 64px; object-fit: contain; }
.mall-card-badge-hint { color: #9a6a00; font-size: 12px; margin-top: 4px; font-weight: 600; }
.mall-card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.mall-card-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mall-card-desc { color: var(--text-3); font-size: 12px; margin-top: 4px; flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mall-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.mall-price { color: var(--primary); font-weight: 700; font-size: 16px; }
.mall-price small { color: var(--text-3); font-size: 12px; font-weight: 400; }
.mall-stock { color: var(--text-3); font-size: 12px; }
.mall-stock.zero { color: var(--danger); }
.balance-pill { background: var(--primary-light); color: var(--primary); font-weight: 700; padding: 8px 16px; border-radius: 999px; font-size: 14px; }

/* ---------- 任务中心 ---------- */
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }
.task-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: all .2s; border: 1px solid transparent; }
.task-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.task-card.done { background: linear-gradient(180deg, #f6fef7, var(--card)); border-color: rgba(22, 163, 74, .35); }
.task-card-head { display: flex; align-items: center; gap: 12px; }
.task-card-icon { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #f3e8ff, #fff); display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; overflow: hidden; }
.task-card-icon img { width: 34px; height: 34px; object-fit: contain; }
.task-card-title { flex: 1; min-width: 0; }
.task-card-name { font-weight: 700; font-size: 14px; line-height: 1.4; }
.task-card-type { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-top: 3px; flex-wrap: wrap; }
.task-card-done { color: var(--success); background: var(--success-light); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; flex-shrink: 0; }
.task-card-desc { color: var(--text-3); font-size: 12px; line-height: 1.6; }
.task-reward { font-size: 13px; color: var(--text-2); background: #f7f8fa; padding: 8px 12px; border-radius: 8px; }
.task-reward b { color: #7c3aed; }
.task-bar { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.task-bar-fill { height: 100%; background: linear-gradient(90deg, #8b5cf6, #7c3aed); border-radius: 999px; transition: width .4s; }
.task-card.done .task-bar-fill { background: linear-gradient(90deg, #4ade80, #16a34a); }
.task-bar-text { font-size: 12px; color: var(--text-3); text-align: right; }
.task-card .task-reward .tag { margin: 2px 4px 2px 0; }
.task-card.done .task-reward { background: var(--success-light); }

/* ---------- 任务奖励配置行（弹窗） ---------- */
.tk-reward-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tk-reward-row .tk-reward-type { flex: 0 0 108px; }
.tk-reward-row .tk-reward-param { flex: 1; min-width: 0; display: flex; }
.tk-reward-row .tk-reward-param select,
.tk-reward-row .tk-reward-param input { width: 100%; }
.tk-reward-row .tk-reward-del { flex-shrink: 0; }

/* ---------- 其他 ---------- */
.empty { text-align: center; color: var(--text-3); padding: 36px 0; font-size: 13px; }
.loading { text-align: center; color: var(--text-3); padding: 24px 0; }
.log-list { max-height: 420px; overflow-y: auto; }
.log-item { display: flex; gap: 12px; padding: 10px 2px; border-bottom: 1px dashed var(--border); font-size: 13px; }
.log-item:last-child { border-bottom: none; }
.log-time { color: var(--text-3); white-space: nowrap; font-size: 12px; padding-top: 1px; }
.log-detail { color: var(--text-2); line-height: 1.5; }
.log-actor { color: var(--primary); font-weight: 600; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.search-box { display: flex; gap: 8px; align-items: center; }
.search-box input { width: 220px; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 860px) { .sidebar { width: 62px; } .side-brand b, .side-brand small, .nav-item span:not(.ico) { display: none; } .main { margin-left: 62px; padding: 16px; } .two-col { grid-template-columns: 1fr; } }

/* ---------- 徽章管理（管理端） ---------- */
.badge-row { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.badge-row:last-child { border-bottom: none; }
.badge-row-icon { flex: 0 0 52px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; }
.badge-icon { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--primary-light), #fdf3e3); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.badge-icon.default { font-size: 22px; }
.badge-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.badge-row-main { flex: 1; min-width: 180px; }
.badge-row-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.badge-row-desc { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.badge-row-channels { display: flex; gap: 6px; margin-top: 5px; }
.badge-row-meta { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.badge-row-actions { display: flex; gap: 6px; }

/* 成员徽章授予弹窗 */
.owned-badge { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px dashed var(--border); }
.owned-badge:last-child { border-bottom: none; }
.owned-badge-main { flex: 1; min-width: 0; }
.owned-badge-name { font-weight: 600; font-size: 13px; }
.owned-badge-meta { color: var(--text-3); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 徽章荣誉墙（用户端） ---------- */
.badge-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.badge-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 16px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; transition: all .2s; border: 1px solid transparent; position: relative; overflow: hidden; }
.badge-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.badge-card.locked { filter: grayscale(1); opacity: .62; }
.badge-card.locked::after { content: "🔒"; position: absolute; top: 8px; right: 10px; font-size: 13px; }
.badge-card-icon { width: 64px; height: 64px; margin-bottom: 12px; display: flex; align-items: center; justify-content: center; }
.badge-emoji { font-size: 40px; line-height: 1; }
.badge-img { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.badge-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }
.badge-card-name { font-weight: 700; font-size: 14px; }
.badge-card-desc { color: var(--text-3); font-size: 12px; margin-top: 5px; min-height: 32px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge-card-status { margin-top: 10px; font-size: 12px; font-weight: 600; }
.badge-card-status.owned { color: var(--success); }
.badge-card-status.owned small { display: block; color: var(--text-3); font-weight: 400; margin-top: 2px; }
.badge-card-status.locked { color: var(--text-3); }
.badge-card-channel { margin-top: 6px; font-size: 11px; color: var(--success); background: var(--success-light); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
