/* ==================== 基础 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #ffc300;
  --primary-dark: #e6b000;
  --primary-light: #fffbe6;
  --blue: #1677ff;
  --green: #52c41a;
  --red: #ff4d4f;
  --text: #1f1f1f;
  --text2: #666;
  --text3: #999;
  --border: #e8e8e8;
  --bg: #f5f6fa;
  --card: #fff;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b3b3b3; }
::-webkit-scrollbar-track { background: transparent; }

/* ==================== 通用组件 ==================== */
.input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border 0.2s; background: #fff; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(255,195,0,0.12); }
.input.sm { padding: 7px 10px; font-size: 13px; width: auto; }
.textarea { resize: vertical; min-height: 56px; }

.btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; background: var(--primary); border: none; border-radius: 8px; font-size: 14px; font-weight: 600; color: #333; cursor: pointer; transition: all 0.2s; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary.sm { padding: 7px 14px; font-size: 13px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-cancel { padding: 10px 20px; background: #fff; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; cursor: pointer; }
.btn-cancel:hover { border-color: var(--text3); }
.btn-primary.btn-blue { background: var(--blue); color: #fff; }
.btn-primary.btn-blue:hover { background: #4096ff; }
.btn-primary.btn-green { background: var(--green); color: #fff; }
.btn-primary.btn-green:hover { background: #73d13d; }

.logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }
.logo-dot.big { width: 14px; height: 14px; box-shadow: 0 0 0 4px rgba(255,195,0,0.18); }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); animation: toastIn 0.3s; }
.toast.success { background: #f6ffed; border: 1px solid #b7eb8f; color: var(--green); }
.toast.error { background: #fff2f0; border: 1px solid #ffccc7; color: var(--red); }
.toast.info { background: #e6f4ff; border: 1px solid #91caff; color: var(--blue); }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ==================== 推广端 ==================== */
.user-body { background: linear-gradient(135deg, #fffbe6 0%, #f5f6fa 40%); min-height: 100vh; }
.user-container { max-width: 900px; margin: 0 auto; padding: 0 20px; }

.user-header { padding: 20px 0; padding-top: calc(20px + env(safe-area-inset-top)); }
.user-header-inner { display: flex; align-items: center; justify-content: space-between; }
.user-logo { display: flex; align-items: center; gap: 10px; }
.user-logo h1 { font-size: 20px; font-weight: 700; }
.admin-entry { font-size: 13px; color: var(--text3); padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; transition: all 0.2s; }
.admin-entry:hover { color: var(--primary-dark); border-color: var(--primary); }

.query-section { margin-bottom: 24px; }
.query-card { background: var(--card); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.query-card-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.query-card-desc { font-size: 14px; color: var(--text3); margin-bottom: 24px; }
.query-form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.query-field { display: flex; flex-direction: column; gap: 6px; }
.query-field label { font-size: 13px; font-weight: 500; color: var(--text2); }
.query-field .input { min-width: 170px; }
.btn-query { display: inline-flex; align-items: center; gap: 8px; padding: 10px 24px; background: var(--primary); border: none; border-radius: 8px; font-size: 15px; font-weight: 600; color: #333; cursor: pointer; transition: all 0.2s; height: 42px; }
.btn-query:hover { background: var(--primary-dark); transform: translateY(-1px); }
/* 查询按钮加载态(禁用+转圈) */
.btn-query:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }
.btn-query.loading svg { display: none; }
.btn-query.loading::before { content: ''; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.25); border-top-color: #333; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 日期快捷按钮 */
.date-quick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.date-quick { padding: 8px 14px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; font-size: 13px; color: var(--text2); cursor: pointer; transition: all 0.2s; height: 42px; }
.date-quick:hover { border-color: var(--primary); color: var(--primary); }
.date-quick.active { background: var(--primary); border-color: var(--primary); color: #333; font-weight: 600; }

/* SID绑定锁定(首次查询后不可更改, 仅可看自己数据) */
.sid-badge { display: none; font-size: 11px; font-weight: 500; color: var(--green); background: rgba(82,196,26,0.1); border: 1px solid rgba(82,196,26,0.3); padding: 1px 8px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.input.sid-locked { background: #f6f6f6; color: var(--text2); cursor: not-allowed; border-color: var(--border); }

/* 结果抬头(查询口径) */
.result-meta { font-size: 13px; color: var(--text3); background: var(--card); border-left: 3px solid var(--primary); border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--shadow); }

.data-section { margin-bottom: 40px; }
.stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-box { background: var(--card); border-radius: var(--radius); padding: 24px; text-align: center; box-shadow: var(--shadow); }
.stat-num { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-name { font-size: 13px; color: var(--text3); margin-top: 4px; }

.data-tabs { display: flex; gap: 0; margin-bottom: 0; background: var(--card); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; box-shadow: var(--shadow); }
.tab { flex: 1; padding: 14px; text-align: center; font-size: 14px; font-weight: 500; border: none; background: #fff; cursor: pointer; color: var(--text2); transition: all 0.2s; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); background: var(--primary-light); }
.tab:hover { background: #fafafa; }

.data-panel { background: var(--card); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
.simple-table { width: 100%; border-collapse: collapse; }
.simple-table th, .simple-table td { padding: 12px 16px; text-align: left; font-size: 13px; border-bottom: 1px solid #f5f5f5; }
.simple-table th { background: #fafafa; font-weight: 600; color: var(--text2); font-size: 12px; }
.simple-table tr:hover td { background: #fefefe; }
.empty-td { text-align: center; color: var(--text3); padding: 40px !important; }

.empty-section { text-align: center; padding: 60px 0; color: var(--text3); }
.empty-section p { margin-top: 12px; font-size: 14px; }

.user-footer { text-align: center; padding: 30px 0; color: var(--text3); font-size: 12px; }
/* 管理端页脚(第 21 批): 与 .user-footer 同款, 只是底部留白小一点 */
.admin-footer { text-align: center; padding: 30px 0 12px; color: var(--text3); font-size: 12px; }
/* 备案行: 与版权行之间的间距; 链接继承文字色, 避免页脚出现两种颜色 */
.site-icp { margin-top: 4px; }
.site-icp a { color: inherit; text-decoration: none; }
.site-icp a:hover { text-decoration: underline; }

/* 推广端状态样式 */
.stat-sub { font-size: 11px; margin-top: 6px; color: var(--text3); }
.sub-valid { color: #52c41a; }
.sub-pending { color: #faad14; }
.sub-invalid { color: #ff4d4f; }
.status-legend { display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 16px; margin-bottom: 12px; background: #fafafa; border-radius: var(--radius); font-size: 12px; color: var(--text2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-pending { background: #faad14; }
.dot-valid { background: #52c41a; }
.dot-invalid { background: #ff4d4f; }
.u-status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.u-status.st-valid { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.u-status.st-pending { background: #fffbe6; color: #d48806; border: 1px solid #ffe58f; }
.u-status.st-invalid { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.sub-table-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }

/* ==================== 登录页 ==================== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; border-top: 4px solid var(--primary); }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
/* 第 22 批: 站点名可自定义 ⇒ 必须给长文本加护栏, 否则管理员填长了会撑破登录卡片 */
.login-logo h2 { font-size: 22px; font-weight: 700; word-break: break-word; }
.login-desc { font-size: 13px; color: var(--text3); margin-bottom: 32px; word-break: break-word; }
.login-field { margin-bottom: 16px; }
.login-field .input { padding: 12px 16px; border-radius: 10px; }
.btn-login { width: 100%; padding: 13px; background: var(--primary); border: none; border-radius: 10px; font-size: 16px; font-weight: 700; color: #333; cursor: pointer; margin-top: 8px; transition: all 0.2s; }
.btn-login:hover { background: var(--primary-dark); transform: translateY(-1px); }
.back-link { display: inline-block; margin-top: 20px; font-size: 13px; color: var(--text3); }
.back-link:hover { color: var(--primary-dark); }

/* ==================== 管理后台 ==================== */
.admin-app { min-height: 100vh; }
.admin-header { background: #1a1a2e; color: #fff; padding: 0 24px; height: calc(56px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); display: flex; align-items: center; justify-content: space-between; position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
.admin-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* min-width:0 让它能收缩, 否则省略号不生效(长名称会把退出按钮挤出屏幕) */
.admin-header-left h1 { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-toggle { display: none; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; width: 34px; height: 34px; border-radius: 6px; font-size: 18px; line-height: 1; cursor: pointer; align-items: center; justify-content: center; }
.sidebar-mask { display: none; }
.admin-header-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.header-link { font-size: 13px; color: rgba(255,255,255,0.7); }
.header-link:hover { color: #fff; }
.header-role { font-size: 12px; color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 4px; }
.btn-logout { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.btn-logout:hover { background: rgba(255,77,79,0.2); border-color: var(--red); }

/* 弱口令警告横幅(固定在顶栏下方, 商用安全强提醒) */
.weak-pass-banner { position: fixed; top: calc(56px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 99; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 24px; background: #fffbe6; border-bottom: 2px solid #faad14; color: #874d01; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.weak-pass-banner b { color: #d4380d; }
.weak-pass-btn { padding: 5px 16px; background: #faad14; color: #fff; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.weak-pass-btn:hover { background: #d48806; }
.weak-pass-close { background: none; border: none; color: #874d01; cursor: pointer; font-size: 15px; opacity: 0.6; padding: 2px 6px; margin-left: auto; flex-shrink: 0; }
.weak-pass-close:hover { opacity: 1; }

/* 同步健康告警横幅(超过2小时未同步, 红色强提醒) */
/* 为什么是 pointer-events:none：
   它是 position:fixed 的通栏横幅，压在下方 .admin-page-header 上 —— 而"刷新"等按钮就在那里。
   本批把"备份自检"也接进同一个横幅之后，告警会**同时出现两条**、横幅变高，
   遮住顶部按钮的概率明显上升（第 10.2 批浏览器验证里，同步+备份双告警时
   点"刷新"被 playwright 报 "intercepts pointer events" 拦下，就是这么发现的）。
   横幅本身没有任何可交互元素，所以让它**不接收指针事件**，底下的按钮就能正常点到。
   （视觉遮挡仍在，但页面一滚动按钮就露出来；彻底改成参与文档流属于另一批的布局改动。） */
/* 全局告警横幅（数据同步异常 / 备份自检告警）。
   【第 12 批修正】原先是 position:fixed; left:0; right:0 的通栏，压在布局**之上**且不占位，
   实测遮挡（1440x900）：页面标题 100%、统计口径徽标 99.6%、「↻ 刷新」按钮 89.1%、
   侧边栏首项 97.9%；移动端 390x844：标题 100%、徽标 75.8%、刷新按钮 70.3%。
   第 10 批只加了 pointer-events:none（修掉"点不到"），**视觉遮挡仍在** —— 这就是本批要治的。
   现在：元素移入 .admin-main 内部 + position:sticky。参与文档流 → 不再压住任何控件；
   它从 x=228 起、侧边栏占 0~200，几何上不相交。sticky 只为滚动时仍看得见告警。
   pointer-events:none 保留：万一滚动中盖住内容，点击仍能穿透。 */
.sync-health-banner { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 98; pointer-events: none; margin: 0 0 16px; padding: 10px 14px; background: #fff2f0; border: 1px solid #ffccc7; border-left: 3px solid #ff4d4f; border-radius: 9px; color: #a8071a; font-size: 13px; font-weight: 500; line-height: 1.6; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }

/* 数据可靠性状态条（同步新鲜度 + 备份自检）。
   三态配色：正常=绿、未知/需留意=琥珀、告警=红。
   它常驻在看板顶部，与上面那个"出问题才出现"的固定横幅是两种角色：
   横幅负责"现在有事，去处理"；状态条负责"这些检查在跑，结果是这个"。 */
.reliability-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; margin: 0 0 14px; padding: 9px 14px; border-radius: 9px; border: 1px solid transparent; font-size: 12.5px; line-height: 1.6; }
.reliability-strip.rs-ok { background: #f6ffed; border-color: #b7eb8f; color: #237804; }
.reliability-strip.rs-warn { background: #fffbe6; border-color: #ffe58f; color: #ad6800; }
.reliability-strip.rs-alert { background: #fff2f0; border-color: #ffccc7; color: #a8071a; }
.reliability-strip .rs-item { display: inline-flex; align-items: baseline; gap: 4px; }
.reliability-strip .rs-k { opacity: 0.72; }

.admin-layout { display: flex; margin-top: calc(56px + env(safe-area-inset-top)); min-height: calc(100vh - 56px - env(safe-area-inset-top)); }
.admin-sidebar { width: 200px; background: #16213e; position: fixed; top: calc(56px + env(safe-area-inset-top)); bottom: 0; padding: 14px 0; overflow-y: auto; }
.side-item { display: flex; align-items: center; gap: 11px; margin: 3px 12px; padding: 11px 14px; font-size: 14px; color: rgba(255,255,255,0.62); cursor: pointer; transition: all 0.2s; border-radius: 9px; }
.side-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side-item.active { background: rgba(255,195,0,0.16); color: var(--primary); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.side-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.admin-main { flex: 1; margin-left: 200px; padding: 24px 28px; min-width: 0; }
.admin-page { animation: pageIn 0.3s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.admin-page-header h2 { font-size: 20px; font-weight: 700; }
.page-title { min-width: 0; }
.page-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }
.header-filters { display: flex; gap: 10px; align-items: center; }

/* 筛选工具栏(订单/结算) */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 18px; }
.filter-sep { color: var(--text3); }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }

.admin-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.admin-table th, .admin-table td { padding: 11px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid #f5f5f5; }
.admin-table th { background: #fafafa; font-weight: 600; color: var(--text2); font-size: 12px; white-space: nowrap; }
.admin-table tr:hover td { background: #fffdf2; }
.admin-table .link-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue); font-size: 12px; }
.admin-table td code { font-size: 11px; background: var(--bg); padding: 2px 6px; border-radius: 4px; color: var(--text2); font-family: 'SF Mono', 'Fira Code', monospace; }

.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.status-dot.ok { background: var(--green); }
.status-dot.fail { background: var(--red); }
.status-dot.wait { background: var(--primary); }

.op-btn { background: none; border: none; font-size: 12px; cursor: pointer; padding: 3px 6px; border-radius: 4px; }
.op-btn.copy { color: var(--blue); }
.op-btn.del { color: var(--red); }
.op-btn:hover { background: var(--bg); }

.admin-pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.admin-pagination button { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.admin-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.admin-pagination span { font-size: 13px; color: var(--text3); line-height: 32px; }

.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.config-card { background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.config-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.config-field { margin-bottom: 16px; }
.config-field:last-child { margin-bottom: 0; }
.config-field label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.config-actions { display: flex; justify-content: flex-end; }

/* ==================== 弹窗 ==================== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s; }
.modal-box { background: #fff; border-radius: 14px; width: 520px; max-width: 92vw; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: popIn 0.25s; }
.modal-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid #f0f0f0; }
.modal-top h3 { font-size: 16px; font-weight: 700; }
.modal-x { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text3); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--bg); }
.modal-content { padding: 24px; overflow-y: auto; flex: 1; }
.modal-bottom { padding: 16px 24px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 12px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.field label i { color: var(--red); font-style: normal; }
.field-tip { display: block; font-size: 12px; color: var(--text3); margin-top: 4px; }

.type-options { display: flex; flex-wrap: wrap; gap: 10px; }
.type-opt { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; transition: all 0.2s; }
.type-opt:hover { border-color: var(--primary); }
.type-opt.highlight { border-color: var(--primary); background: var(--primary-light); }
.type-opt input { accent-color: var(--primary); }

/* 生成方式切换(指定推广位/团队分发) */
.gen-mode-tabs { display: flex; gap: 0; background: var(--bg); border-radius: 8px; padding: 3px; }
.gen-mode { flex: 1; border: none; background: transparent; padding: 8px 0; font-size: 13px; font-weight: 500; color: var(--text2); border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.gen-mode:hover { color: var(--text); }
.gen-mode.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

.perm-options { display: flex; flex-wrap: wrap; gap: 12px; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; transition: all 0.2s; }
.perm-item:hover { border-color: var(--primary); }
.perm-item input { accent-color: var(--primary); }
.perm-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 全局Loading指示器 */
.global-loading { position: fixed; top: 60px; right: 20px; z-index: 9998; display: none; align-items: center; justify-content: center; }
.loading-spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 数据看板 ==================== */
/* 月度摘要横幅 */
.dash-hero { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%); border-radius: 14px; padding: 24px 28px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero-main { display: flex; gap: 32px; flex-wrap: wrap; }
.hero-item { display: flex; flex-direction: column; gap: 4px; }
.hero-val { font-size: 24px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.hero-item.highlight .hero-val { color: var(--primary); }
.hero-label { font-size: 12px; color: rgba(255,255,255,0.55); }
.mom { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; display: inline-block; width: fit-content; }
.mom.up { color: #95de64; background: rgba(82,196,26,0.15); }
.mom.down { color: #ff7875; background: rgba(255,77,79,0.15); }
.hero-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; min-width: 230px; flex: 1; max-width: 320px; }
.hero-stack { display: flex; flex-direction: column; gap: 7px; width: 100%; }
.stack-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.12); }
.stack-seg { height: 100%; transition: width 0.5s ease; }
.stack-seg.done { background: #52c41a; }
.stack-seg.pending { background: #1677ff; }
.stack-seg.invalid { background: #ff4d4f; }
.stack-legend { display: flex; gap: 14px; font-size: 12px; color: rgba(255,255,255,0.75); justify-content: flex-end; flex-wrap: wrap; }
.stack-legend span { display: flex; align-items: center; gap: 5px; }
.seg-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.seg-dot.done { background: #52c41a; }
.seg-dot.pending { background: #1677ff; }
.seg-dot.invalid { background: #ff4d4f; }
.hero-week { font-size: 12px; color: rgba(255,255,255,0.5); display: flex; align-items: center; gap: 6px; }

/* 今日卡片 */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.dash-card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; position: relative; border-left: 3px solid transparent; transition: transform 0.2s, box-shadow 0.2s; }
.dash-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }
.dash-card.accent-blue { border-left-color: var(--blue); }
.dash-card.accent-gold { border-left-color: var(--primary); }
.dash-card.accent-green { border-left-color: var(--green); }
.dash-card.accent-orange { border-left-color: #faad14; }
.dash-card.accent-purple { border-left-color: #722ed1; }
.dash-card.accent-cyan { border-left-color: #13c2c2; }
.dash-card-icon { font-size: 26px; }
.dash-card-info { display: flex; flex-direction: column; min-width: 0; }
.dash-card-value { font-size: 20px; font-weight: 700; color: var(--text); white-space: nowrap; }
.dash-card-label { font-size: 12px; color: var(--text3); margin-top: 2px; }
.dash-card-growth { position: absolute; top: 10px; right: 12px; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.dash-card-growth.up { color: var(--green); background: rgba(82,196,26,0.1); }
.dash-card-growth.down { color: var(--red); background: rgba(255,77,79,0.1); }
.dash-card-growth.neutral { color: var(--text3); background: var(--bg); }

.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.dash-panel { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.dash-panel.wide { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin: 0; }
.panel-sub { font-size: 12px; color: var(--text3); }

/* 柱状图 */
.dash-chart { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: 70%; max-width: 36px; background: linear-gradient(180deg, #ffd666, var(--primary-dark)); border-radius: 5px 5px 0 0; transition: height 0.5s cubic-bezier(0.4,0,0.2,1); min-height: 4px; }
.chart-bar.today { background: linear-gradient(180deg, #69b1ff, var(--blue)); }
.chart-bar:hover { opacity: 0.85; }
.chart-label { font-size: 11px; color: var(--text3); margin-top: 6px; }
.chart-label.today { color: var(--blue); font-weight: 600; }
.chart-num { font-size: 11px; color: var(--text2); font-weight: 600; }


/* 实时动态 */
.dash-feed { max-height: 300px; overflow-y: auto; }
.feed-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; animation: pulse 2s infinite; background: var(--green); }
.feed-dot.st-paid { background: var(--blue); }
.feed-dot.st-refund { background: var(--red); }
.feed-dot.st-pending { background: #faad14; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.feed-info { flex: 1; min-width: 0; }
.feed-title { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-meta { font-size: 12px; color: var(--text3); }
.feed-time { font-size: 11px; color: var(--text3); flex-shrink: 0; }

/* SID排行 */
.dash-rank { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: flex-start; gap: 10px; }
.rank-no { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--text3); flex-shrink: 0; margin-top: 2px; }
.rank-no.top { background: var(--primary); color: #333; }
.rank-body { flex: 1; min-width: 0; }
.rank-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.rank-sid { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.rank-bar-bg { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.rank-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 3px; transition: width 0.5s; }

/* 实时标记 */
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.5s infinite; }
.refresh-hint { font-size: 12px; color: var(--text3); }

/* 统计口径标识: 让管理员一眼看到"这些数字是按哪个业务线口径统计的"。
   背景: 口径统一到私域(bl=9)后, 看板/结算/订单的数字会变小, 若无任何说明会被当成丢单。 */
.scope-badge { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: rgba(22,119,255,0.1); color: var(--blue); white-space: nowrap; }
.scope-badge.warn { background: rgba(250,173,20,0.18); color: #d48806; }
.empty-hint { text-align: center; color: var(--text3); padding: 30px 0; font-size: 13px; }

/* 双链接显示 */
.dual-link { display: flex; flex-direction: column; gap: 6px; }
.link-row { display: flex; align-items: center; gap: 6px; }
.link-tag { flex-shrink: 0; font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.link-tag.work { background: rgba(22,119,255,0.1); color: var(--blue); }
.link-tag.query { background: rgba(82,196,26,0.1); color: var(--green); }
.link-text { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* 同步状态栏 */
.sync-bar { padding: 10px 16px; margin-bottom: 12px; background: var(--primary-light); border: 1px solid var(--primary); border-radius: 8px; font-size: 13px; color: #333; }

/* ==================== 佣金结算 ==================== */
.settle-summary { margin-bottom: 20px; }
.settle-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.settle-card { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.settle-card.highlight { background: var(--primary-light); border: 1px solid var(--primary); }
.sc-val { font-size: 20px; font-weight: 700; color: var(--text); }
.sc-label { font-size: 12px; color: var(--text3); }
.refund { color: var(--red) !important; }

.settle-table td code { font-size: 11px; background: var(--bg); padding: 2px 6px; border-radius: 4px; color: var(--text2); }

.settle-detail { margin-top: 20px; background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.settle-detail h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text); }

/* ==================== 状态标签 ==================== */
.status-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1.6; }
.status-tag.st-done { background: rgba(82,196,26,0.1); color: var(--green); }
.status-tag.st-refund { background: rgba(255,77,79,0.1); color: var(--red); }
.status-tag.st-paid { background: rgba(250,173,20,0.1); color: #faad14; }
.status-tag.st-pending { background: rgba(0,0,0,0.04); color: var(--text3); }

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  /* 推广端 */
  .query-form { flex-direction: column; }
  .query-field .input { min-width: 100%; }
  .query-field { width: 100%; }
  .stats-row { grid-template-columns: 1fr; }
  .query-card { padding: 20px 16px; }
  .query-card-title { font-size: 19px; }
  .user-container { padding: 0 12px; }
  .btn-query { width: 100%; justify-content: center; height: 46px; font-size: 16px; }
  .date-quick { flex: 1; min-width: 0; text-align: center; height: 44px; }
  .date-quick-row { gap: 6px; }
  .status-legend { flex-direction: column; gap: 6px; padding: 10px 12px; }
  .simple-table th, .simple-table td { padding: 10px 10px; font-size: 12px; white-space: nowrap; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .toast-container { right: 12px; left: 12px; align-items: center; }
  .toast { width: 100%; text-align: center; }
  .stat-box { padding: 18px 14px; }
  .stat-num { font-size: 24px; }
  .user-footer { padding: 24px 0 calc(24px + env(safe-area-inset-bottom)); }

  /* 管理后台顶栏 */
  .admin-header { padding: 0 12px; }
  .menu-toggle { display: inline-flex; }
  .admin-header-left h1 { font-size: 15px; }
  .header-role { display: none; }
  .btn-logout { padding: 5px 10px; font-size: 12px; }

  /* 侧边栏改为抽屉式覆盖导航 */
  .admin-sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 200; box-shadow: 2px 0 12px rgba(0,0,0,0.1); width: 200px; }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; position: fixed; inset: 0; top: calc(56px + env(safe-area-inset-top)); background: rgba(0,0,0,0.4); z-index: 150; }
  .admin-main { margin-left: 0; padding: 16px 12px; }

  /* 页面头部与筛选 */
  .admin-page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .header-filters { flex-wrap: wrap; width: 100%; }
  .header-filters .input.sm { flex: 1; min-width: 0; width: auto; }
  .header-filters .btn-primary.sm { flex-shrink: 0; }
  .filter-bar { padding: 12px; gap: 8px; }
  .filter-bar .input.sm { flex: 1; min-width: 0; width: auto; }
  .filter-actions { margin-left: 0; width: 100%; }
  .filter-actions .btn-primary.sm { flex: 1; justify-content: center; }

  /* 看板 */
  .dash-hero { padding: 18px 16px; }
  .hero-main { gap: 18px; }
  .hero-val { font-size: 19px; }
  .hero-side { align-items: flex-start; width: 100%; }
  .dash-row { grid-template-columns: 1fr; }
  .dash-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-card { padding: 14px; gap: 10px; }
  .dash-card-value { font-size: 18px; }
  .settle-cards { grid-template-columns: repeat(2, 1fr); }

  /* 表格紧凑化+横滑 */
  .admin-table th, .admin-table td { padding: 9px 10px; font-size: 12px; white-space: nowrap; }
  .table-wrap { -webkit-overflow-scrolling: touch; }

  /* 配置卡片 */
  .config-card { padding: 18px; max-width: 100%; }
  .config-grid { grid-template-columns: 1fr; }

  /* 弹窗 */
  .modal-box { width: 94vw; max-height: 90vh; }
  .modal-content { padding: 16px; }
  .modal-bottom { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .dash-cards { grid-template-columns: 1fr; }
  .settle-cards { grid-template-columns: 1fr; }
  .admin-header-left h1 { font-size: 14px; }
  .promo-tabs { gap: 4px; }
  .promo-tab { padding: 8px 12px; font-size: 12px; }
  .query-card-title { font-size: 17px; }
  .stat-num { font-size: 22px; }
  .hero-main { gap: 12px; }
  .hero-val { font-size: 17px; }
}

/* ==================== 地推管理Tab ==================== */
.promo-tabs { display: flex; gap: 8px; margin-bottom: 20px; background: var(--card); padding: 6px; border-radius: 10px; box-shadow: var(--shadow); }
.promo-tab { flex: 1; padding: 10px 16px; border: none; background: transparent; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--text2); cursor: pointer; transition: all 0.2s; text-align: center; }
.promo-tab:hover { background: var(--primary-light); color: var(--text); }
.promo-tab.active { background: var(--primary); color: #333; font-weight: 600; box-shadow: 0 2px 8px rgba(255,195,0,0.3); }
.promo-panel { animation: fadeIn 0.25s ease; }
.promo-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.promo-section-header h3 { font-size: 15px; font-weight: 600; }

/* 分发预览 */
.batch-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 13px; color: var(--text2); }
.batch-preview .preview-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.preview-check-all { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--text); }
.preview-check-all input { accent-color: var(--primary); width: 15px; height: 15px; }
.preview-cnt { font-size: 12px; color: var(--text3); }
.preview-body { max-height: 140px; overflow-y: auto; }
.batch-preview .preview-item { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.batch-preview .preview-item:last-child { border-bottom: none; }
.batch-preview .preview-item.checkable { align-items: center; gap: 8px; padding: 6px 6px; border-bottom: none; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
.batch-preview .preview-item.checkable:hover { background: rgba(255,195,0,0.1); }
.batch-preview .preview-item.checkable input { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; }
.batch-preview .preview-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-preview .preview-sid { font-family: monospace; color: var(--blue); font-size: 12px; }
.batch-preview .preview-empty { text-align: center; color: var(--text3); padding: 10px; }

/* ==================== 公告横幅(推广端/团长端共用) ==================== */
.notice-area { max-width: 900px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.notice-banner { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin-top: 12px; background: #fffbe6; border: 1px solid #ffe58f; border-left: 4px solid #faad14; border-radius: 8px; animation: fadeIn 0.3s ease; }
.notice-icon { flex-shrink: 0; font-size: 15px; line-height: 1.5; }
.notice-text { flex: 1; min-width: 0; font-size: 13px; color: #614700; line-height: 1.5; }
.notice-text strong { display: block; font-size: 13px; font-weight: 600; color: #874d01; }
.notice-text span { display: block; margin-top: 2px; color: #8c6d1f; word-break: break-all; }
.notice-close { flex-shrink: 0; border: none; background: none; color: #d4b106; font-size: 14px; cursor: pointer; padding: 0 2px; line-height: 1.5; transition: color 0.2s; }
.notice-close:hover { color: #874d01; }

/* ==================== 「点击即筛选」的通用视觉 ====================
   可点的数据展示元素必须**看起来就能点**, 否则功能等于不存在。
   只加 cursor 是不够的: 移动端没有光标, 桌面端用户也未必去悬停 ——
   所以配 hover 底色 + 键盘焦点环, 并给元素加 role=button/tabindex(见各端 JS), 让键盘也能触发。 */
.clickable { cursor: pointer; border-radius: 8px; transition: background 0.15s, box-shadow 0.15s, transform 0.15s; }
.clickable:hover { background: rgba(255,195,0,0.12); }
.clickable:active { transform: scale(0.985); }
.clickable:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 2px; }

/* 统计块/列表行原本没有内边距, hover 底色会紧贴文字。
   用等值负外边距抵消, 保证**不改变原有布局**(否则一改就会挤压旁边的元素)。 */
.hero-item.clickable { padding: 6px 10px; margin: -6px -10px; }
.stack-legend .clickable { padding: 2px 8px; margin: -2px -8px; }
.rank-item.clickable { padding: 8px; margin: -8px; }
.feed-item.clickable { padding: 10px 8px; margin: -10px -8px; }

/* ---- 推广端: 统计卡片可点(点它切换页签) ---- */
.stat-box.clickable { cursor: pointer; }
.stat-box.clickable:hover { background: #fffdf3; box-shadow: 0 6px 18px rgba(0,0,0,0.1); transform: translateY(-2px); }
/* 用 inset 阴影而不是 border 表示选中: 加 border 会让卡片宽高各涨 2px, 触发整行重排 */
.stat-box.is-active { box-shadow: 0 0 0 2px var(--primary), var(--shadow); }

/* 卡片下的「有效/待生效/失效」本身就是筛选入口, 触控目标要够大 */
.stat-sub .sub-chip { display: inline-block; padding: 2px 6px; border-radius: 6px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.stat-sub .sub-chip:hover { background: rgba(255,195,0,0.16); }
.stat-sub .sub-chip.on { background: var(--primary); color: #333; font-weight: 700; }

/* ---- 当前筛选提示条(推广端/团队端共用) ----
   筛选态必须**可见且可清除**: 否则用户会以为"数据本来就只有这些"。 */
.filter-active { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 8px 12px; background: var(--primary-light); border: 1px solid #ffe58f; border-radius: 8px; font-size: 12px; color: #614700; }
.filter-active .fa-clear { border: 1px solid #ffe58f; background: #fff; border-radius: 6px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: #874d01; }
.filter-active .fa-clear:hover { background: #fff3c4; }
