/**
 * 反作弊控制台 · 简约 B 端样式（用户 2026-11-03「重新优化 WEB UI，符合简约 B 端页面」）。
 *
 * 约束：
 *  · HTML 禁止内联 style（CSP style-src 'self'），一切视觉走这里的 class；
 *  · 沿用品牌橙 #ff6b00，与小程序白橙设计系统同源；
 *  · B 端工具页：紧凑、信息密度优先，弱化装饰（无阴影堆叠、小圆角、细边框）；
 *  · 刻意不引外部 CSS 框架：内网 B 端页面，CDN 挂了不能让控制台白屏。
 */

:root {
  --brand: #ff6b00;
  --brand-deep: #e25a00;
  --brand-soft: #fff3e8;
  --text: #1f2329;
  --text-2: #4b5260;
  --text-3: #8a919f;
  --line: #e4e7ec;
  --line-2: #d3d8e0;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fdf1e3;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 13px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}
.hide { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ==================== 通用组件 ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-2);
  line-height: 1.4;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand-deep); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand-deep); color: #fff; }
.btn.danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn.wide { width: 100%; padding: 8px 14px; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--line);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.mute { background: var(--bg); color: var(--text-3); }

.note { color: var(--text-3); font-size: 12px; line-height: 1.7; }
.note.mb { margin: 0 0 10px; }
.card-sub { color: var(--text-3); font-size: 12px; }
.mt-18 { margin-top: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  white-space: nowrap;
}
th { color: var(--text-3); font-weight: 500; background: #fafbfc; }
td.r, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: none; }

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  margin: 8px 0;
}
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ==================== 登录页 ==================== */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login .card {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 4px 16px rgba(31, 35, 41, 0.05);
}
.login h1 { margin: 0 0 4px; font-size: 19px; }
.lg-sub { margin: 0 0 20px; color: var(--text-3); font-size: 12px; }
.fld { margin-bottom: 14px; }
.fld label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 12px; }
.fld input, .fld textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  outline: none;
}
.fld input:focus, .fld textarea:focus { border-color: var(--brand); }
.err {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 12px;
}
.ops { margin-top: 16px; color: var(--text-3); font-size: 12px; line-height: 1.8; }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.dot.bad { background: var(--bad); }

/* ==================== 应用壳：侧边栏 + 内容区 ==================== */

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

.sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fffdfb;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-name { font-size: 14px; font-weight: 600; }
.app-sub { font-size: 11px; color: var(--text-3); }

.tabs { display: flex; flex-direction: column; padding: 4px 8px; gap: 2px; }
.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.tab:hover { background: var(--brand-soft); color: var(--brand-deep); }
.tab.on {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 500;
  border-left-color: var(--brand);
}
.ico { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; flex-shrink: 0; }

.sidebar-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--line); }
.who { font-size: 12px; color: var(--text-2); margin-bottom: 8px; word-break: break-all; }
.side-actions { display: flex; gap: 8px; }

.main { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.wrap { max-width: 1180px; margin: 0 auto; }
.card + .card { margin-top: 12px; }

/* ==================== 卡片 ==================== */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-t { font-size: 14px; font-weight: 600; }

.grid { display: grid; gap: 10px; }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g4 { grid-template-columns: repeat(4, 1fr); }
.gap-top { margin-top: 10px; }

.stat {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.stat .k { color: var(--text-3); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0; }
.stat .m { color: var(--text-3); font-size: 11px; }

/* ==================== 训练台：筛选条 ==================== */

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.seg i {
  padding: 4px 12px;
  font-style: normal;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  border-right: 1px solid var(--line);
  background: var(--card);
}
.seg i:last-child { border-right: none; }
.seg i:hover { color: var(--brand-deep); }
.seg i.on { background: var(--brand); color: #fff; }

.filters select, .filters input[type="text"] {
  padding: 5px 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--card);
}
.filters select { font-size: 12px; }
.filters input[type="text"] { width: 170px; }
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

/* ==================== 训练台：紧凑表格行 + 展开详情 ==================== */

.tbl { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.tbl-head {
  display: flex;
  align-items: center;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  color: var(--text-3);
  font-size: 12px;
}
.tbl-head span { padding: 8px 6px; }
.tbl-head .c-op { text-align: center; }

.tbl-wrap { border-bottom: 1px solid var(--line); }
.tbl-wrap:last-child { border-bottom: none; }

.tbl-row {
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  background: var(--card);
}
.tbl-row:hover { background: #fffaf5; }
.tbl-row.open { background: var(--brand-soft); }
.tbl-row > span { padding: 9px 6px; min-width: 0; }

.c-who { flex: 2.2; display: flex; flex-direction: column; line-height: 1.35; }
.c-who b { font-weight: 600; font-size: 13px; }
.c-who small { color: var(--text-3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-src { flex: 0 0 64px; color: var(--text-2); font-size: 12px; }
.c-size { flex: 0 0 92px; display: flex; align-items: baseline; gap: 3px; }
.c-size b { font-size: 13px; font-weight: 600; }
.c-size small { color: var(--text-3); font-size: 11px; }
.c-score { flex: 0 0 100px; display: flex; align-items: baseline; gap: 6px; }
.c-score b { font-size: 15px; font-weight: 600; }
.c-score small { color: var(--text-3); font-size: 11px; }
.c-label { flex: 0 0 112px; }
.c-status { flex: 0 0 120px; }
.c-op { flex: 0 0 34px; text-align: center; color: var(--text-3); font-size: 12px; }
.c-arr { display: inline-block; transition: transform 0.15s; }
.tbl-row.open .c-arr { transform: rotate(180deg); }

/* 展开详情面板 */
.det {
  background: #fffdfb;
  border-top: 1px dashed var(--line);
  padding: 12px;
}
.det-main { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; }
.kv-grid {
  flex: 1;
  min-width: 300px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px 10px;
  align-content: start;
}
.kv {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  line-height: 1.4;
}
.kv span { display: block; color: var(--text-3); font-size: 11px; }
.kv b { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; word-break: break-all; }

/* GPS 路线图（SVG 由 JS createElementNS 生成，CSP 兼容，无外部资源） */
.route-box { flex: 1; min-width: 260px; max-width: 420px; }
.route-svg {
  width: 100%;
  height: 190px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.route-line { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.route-start { fill: var(--ok); }
.route-end { fill: var(--brand); }
.route-none, .route-loading {
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 12px;
  background: var(--card);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 0 14px;
}
.route-cap { margin-top: 4px; color: var(--text-3); font-size: 11px; text-align: center; }

.det-quality { margin-top: 8px; flex: none; }

/* 当日同步历史（增速研判）：紧凑小表格 */
.sync-hist { margin-top: 10px; }
.sync-hist-body {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 4px 10px;
  font-size: 12px;
}
.sh-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1.3fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.sh-row:last-child { border-bottom: none; }
.sh-row.r, .sh-row > span.r { text-align: right; }
.sh-head { color: var(--text-3); font-size: 11px; }
.sh-head + .sh-row { border-top: 1px solid var(--line); }
.sh-fast { background: var(--bad-soft); }
.sh-fast > span:last-child { color: var(--bad); font-weight: 600; }
.sh-short { color: var(--text-3); }
.sh-short > span:last-child { font-style: normal; }
.sync-hist .route-cap { text-align: left; margin-top: 4px; }

.reasons { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.reasons span {
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
}

/* 动作区：判定 / 处置 两组（用户 2026-11-03「处置和标记是两码事，UI 理解不了」） */
.det-acts {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.act-group { flex: 1; min-width: 280px; }
.act-t { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.act-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.act-note { margin-top: 6px; color: var(--text-3); font-size: 11px; line-height: 1.6; }

/* ==================== 模型配置页 ==================== */

.row-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.ri-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ri-name { font-weight: 600; font-size: 13px; }
.acts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.acts input[type="number"] {
  width: 72px;
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
}

/* ==================== 阶段性自升级（用户 2026-11-12） ====================
 *
 * 三级阶梯的视觉目标是「一眼看出现在在哪一级、下一级缺什么」：
 *   · 当前级：橙色左边框 + 高亮底；已达级：✓ 前缀 + 绿色左边框；
 *   · 未达级：灰底，不抢注意力；
 *   · 「下一阶段缺什么」用红色列表（这是管理员唯一需要行动的地方）。
 */
.stage-src {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 10px;
}
.stage-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stage-src-name { font-size: 13px; }
.stage .spacer, .stage-head .spacer { flex: 1; }

.stage-ladder { display: flex; gap: 8px; flex-wrap: wrap; }
.stage-step {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border-left: 3px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.stage-step.done { border-left-color: var(--ok); background: var(--ok-soft); }
.stage-step.current { border-left-color: var(--brand); background: var(--brand-soft); }
.stage-step-t { display: block; font-size: 12px; font-weight: 600; }
.stage-step-d { color: var(--text-3); font-size: 11px; line-height: 1.55; margin-top: 2px; }
.stage-step .pill { margin-top: 4px; }

.stage-kv { margin-top: 10px; }
.stage-next {
  margin-top: 10px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
}
.stage-next.is-ok { border-color: var(--ok); background: var(--ok-soft); border-style: solid; }
.stage-next-t { font-weight: 600; }
.stage-miss { color: var(--bad); font-size: 11px; line-height: 1.7; }
.stage-warn {
  margin-top: 8px;
  color: var(--bad);
  background: var(--bad-soft);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11px;
}
.stage-hist { margin-top: 10px; }
.stage-hist-row { color: var(--text-3); font-size: 11px; line-height: 1.8; }

/* ==================== 弹层 / Toast ==================== */

.mask {
  position: fixed;
  inset: 0;
  background: rgba(31, 35, 41, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.sheet {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
}
.sheet h3 { margin: 0 0 4px; font-size: 15px; }
.sheet .lg-sub { margin-bottom: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 99;
  max-width: 80vw;
}
.toast.bad { background: var(--bad); }

/* ==================== 响应式 ==================== */

@media (max-width: 1080px) {
  .console-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 10px 14px; }
  .tabs { flex-direction: row; padding: 0 8px; }
  .tab { border-left: none; border-bottom: 3px solid transparent; border-radius: 0; }
  .tab.on { border-left: none; border-bottom-color: var(--brand); border-radius: 0; }
  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    border-top: none;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .who { margin-bottom: 0; max-width: 140px; }
  .main { padding: 14px 12px 32px; }
}

@media (max-width: 860px) {
  .grid.g4, .grid.g3 { grid-template-columns: repeat(2, 1fr); }
  .tbl-head { display: none; }
  .c-src, .c-label, .c-size { display: none; }
  .c-who { flex: 1.6; }
}
