:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d4d8df;
  --text: #1c2024;
  --muted: #6b7280;
  --faint: #9aa1ab;
  --brand: #2f6bff;
  --brand-soft: #eaf0ff;
  --ok: #12805c;
  --ok-soft: #e7f6f0;
  --warn: #9a6200;
  --warn-soft: #fdf3e0;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(246, 247, 249, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 6px 10px; border-radius: 9px; color: var(--muted);
  font-size: 14px; font-weight: 500; text-decoration: none;
}
.nav a:hover { background: #eceef2; color: var(--text); text-decoration: none; }
.nav a.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 18px 16px 64px; }

h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }

.notice {
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px;
  border: 1px solid var(--line-strong); background: var(--panel);
}
.notice.bad { background: var(--bad-soft); border-color: #f6c9c4; color: #7a1a12; }
.notice.warn { background: var(--warn-soft); border-color: #f3ddb5; color: #6b4500; }
.notice.ok { background: var(--ok-soft); border-color: #c3e8da; color: #0c5c43; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.card-title { font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head .spacer { margin-left: auto; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.metrics.five { grid-template-columns: repeat(5, 1fr); }
.metric { background: #fafbfc; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }
.metric .v { font-size: 16px; font-weight: 650; letter-spacing: -.02em; margin-top: 1px; font-variant-numeric: tabular-nums; }
.metric .v.warn { color: var(--warn); }
.metric .v small { font-size: 11.5px; font-weight: 500; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #cdeade; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f2dcb2; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #f7cbc6; }
.badge.mute { background: #f0f1f4; color: var(--muted); border-color: var(--line-strong); }
.badge.brand { background: var(--brand-soft); color: var(--brand); border-color: #cfdcff; }

.reason {
  font-size: 13px; color: #33383f; background: #fafbfc;
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: 8px; padding: 8px 12px; margin: 10px 0 0;
}

/* 卡片上的模型小标签：绿=可用，红=失败，灰=样本不足 */
.model-line { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.mtag {
  font-size: 11px; line-height: 1.5; padding: 1px 7px; border-radius: 6px;
  background: #f0f1f4; color: var(--muted); white-space: nowrap;
}
.mtag.ok { background: var(--ok-soft); color: var(--ok); }
.mtag.bad { background: var(--bad-soft); color: var(--bad); }
.mtag.more { background: transparent; border: 1px dashed var(--line-strong); color: var(--faint); }

/* 候选表里可点开的模型明细 */
.model-count { border-bottom: 1px dashed var(--faint); cursor: pointer; }
.model-count:hover { color: var(--brand); border-bottom-color: var(--brand); }
.model-pop {
  position: absolute; z-index: 60; max-width: 300px;
  display: flex; flex-wrap: wrap; gap: 5px;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px; box-shadow: var(--shadow);
}
.model-pop-title { width: 100%; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 550;
  padding: 7px 13px; border-radius: 9px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #f4f5f7; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); border-color: #f0c2bd; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; color: #fff;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 11.5px; color: var(--faint);
  letter-spacing: .04em; text-transform: uppercase; padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid #f1f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 68px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.inline { display: flex; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }

/* 详情页的检测图：不再铺满整屏，控制在能看清又不过分占位的大小 */
.preview-wrap { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.preview {
  width: auto; max-width: 100%; max-height: 330px; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--line); background: #f0f1f4;
  display: block;
}
a.preview-link { display: inline-block; line-height: 0; border-radius: 10px; }
a.preview-link:hover .preview { border-color: var(--brand); }
.preview-empty {
  width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; border: 1px dashed var(--line-strong);
  display: flex; align-items: center; justify-content: center; color: var(--faint);
  font-size: 12.5px; background: #fafbfc;
}

/* 缩略图：首页卡片与候选列表里用，一小块就够 */
.thumb {
  display: block; flex: 0 0 auto; width: 64px; height: 40px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--line);
  background: #f0f1f4; line-height: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--brand); }
.thumb.sm { width: 34px; height: 22px; border-radius: 5px; }
.thumb.noimg {
  display: flex; align-items: center; justify-content: center;
  color: var(--faint); font-size: 10.5px; border-style: dashed;
}

/* 自动刷新提示条 */
.livebar {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.livebar .dotlive { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.livebar.paused .dotlive { background: var(--faint); }
button.livebar { cursor: pointer; font: inherit; font-size: 12px; }
button.livebar:hover { border-color: var(--line-strong); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { justify-content: center; font-size: 17px; margin-bottom: 6px; }
.login-card .sub { text-align: center; margin-bottom: 20px; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 13.5px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 12px; border-radius: 9px; font-size: 13.5px; color: var(--muted); border: 1px solid transparent; }
.tabs a:hover { background: #eceef2; text-decoration: none; }
.tabs a.active { background: var(--panel); border-color: var(--line); color: var(--text); box-shadow: var(--shadow); }

.pager { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

.tok { background: #f5f6f8; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 12.5px; word-break: break-all; }

@media (max-width: 720px) {
  .wrap { padding: 14px 12px 56px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics.five { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 4px 2px; }
  table.responsive td::before {
    content: attr(data-label); color: var(--faint); font-size: 12px; font-weight: 600;
  }
}

/* ---------- 策略表单：分区、平台勾选、权重 ---------- */
.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: .06em;
  margin: 20px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.section-label:first-of-type { margin-top: 4px; padding-top: 0; border-top: none; }

/* 可折叠的分区标题 */
.section-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; border-radius: 6px;
}
.section-toggle:hover { color: var(--muted); }
.section-toggle:focus-visible { outline: 2px solid var(--brand-soft); }
.section-state { font-weight: 600; color: var(--brand); font-size: 12px; letter-spacing: 0; }
.section-arrow { margin-left: auto; font-weight: 500; color: var(--faint); font-size: 11.5px; letter-spacing: 0; }
#model-section.collapsed { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-strong); background: var(--panel);
  border-radius: 999px; padding: 6px 12px 6px 10px;
  font-size: 13.5px; font-weight: 550; cursor: pointer; user-select: none;
}
.chip:hover { border-color: #bfc6d2; background: #fafbfc; }
.chip input { width: 15px; height: 15px; accent-color: var(--brand); margin: 0; }
.chip em {
  font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--muted);
  background: #f0f1f4; border-radius: 999px; padding: 1px 7px; margin-left: 2px;
}
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.chip:has(input:checked) em { background: #dfe8ff; color: var(--brand); }
.chip:has(input:checked) span { color: #14428f; }

.hint-block { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.bad-hint { color: var(--bad); font-weight: 600; }

/* 只有在「自定义权重」模式下才出现在页面上，其它模式不占位 */
.weights {
  display: none;
  border: 1px solid #d5e0ff; border-radius: 12px;
  padding: 12px 14px; background: #f7f9ff;
}
.weights.on { display: block; }
.weights-head { font-size: 13px; font-weight: 650; margin-bottom: 10px; }
.weights-pct { display: block; font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 3px; }
.weights-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wfield { display: flex; align-items: center; gap: 8px; }
.wfield > span { font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 42px; }
.wfield input { padding: 5px 8px; font-size: 13.5px; }

/* ---------- 候选表 ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.cand-table { font-size: 13px; min-width: 700px; }
.cand-table th { padding: 0 8px 8px; }
.cand-table td { padding: 8px; }
.cand-table .dim { color: var(--faint); width: 26px; }
.cand-table .strong { font-weight: 700; }
.cand-name { font-weight: 600; font-size: 13.5px; line-height: 1.35; display: flex; align-items: center; gap: 7px; }
.cand-platform { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.cand-table.compact tbody tr.row-extra { display: none; }

/* ---------- 模型选择 ---------- */
.model-panel {
  display: none;
  border: 1px solid #d5e0ff; border-radius: 12px;
  padding: 12px 14px; background: #fbfcff; margin-bottom: 16px;
}
.model-panel.on { display: block; }
.model-head { font-size: 13px; font-weight: 650; margin-bottom: 10px; }
.model-hint { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 3px; }
.model-count-panel { margin-bottom: 4px; }
#model-chips { max-height: 260px; overflow-y: auto; padding-right: 4px; }
#model-chips .chip { font-size: 12.5px; padding: 5px 10px 5px 8px; }
#model-chips .chip span { display: inline-flex; align-items: center; gap: 6px; }
#model-chips .chip-missing { border-color: #f0c2bd; background: #fffafa; }
#model-chips .chip-missing:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); }
#model-chips .chip-missing em { background: var(--bad-soft); color: var(--bad); }
.model-summary {
  margin-top: 10px; font-size: 12.5px; line-height: 1.7; color: #14428f;
  background: #eef3ff; border: 1px solid #d5e0ff; border-radius: 9px;
  padding: 8px 11px; display: none;
}
.model-summary.on { display: block; }
.model-summary.warn { color: var(--warn); background: var(--warn-soft); border-color: #f3ddb5; }

/* ---------- 被排除的分组：整行标红 ---------- */
.rej-table { min-width: 660px; }
.rej-table tbody tr { background: #fffbfa; }
.rej-table tbody tr td { color: var(--bad); }
.rej-table tbody tr:hover td { background: var(--bad-soft); }
.rej-table .cand-platform { color: #a5645d; }
.rej-table .dim { color: #c98b85; }
.rej-reason { font-weight: 650; color: var(--bad); }

.cand-details { margin-top: 10px; }
.cand-details > summary {
  cursor: pointer; font-size: 13px; color: var(--brand);
  padding: 6px 0; list-style: none; font-weight: 550;
}
.cand-details > summary::-webkit-details-marker { display: none; }
.cand-details > summary::before { content: "▸ "; }
.cand-details[open] > summary::before { content: "▾ "; }
.cand-details .table-scroll { margin-top: 6px; }
.cand-details .cand-table { min-width: 660px; }

@media (max-width: 720px) {
  .weights-grid { grid-template-columns: repeat(2, 1fr); }
  .chip { font-size: 13px; padding: 5px 10px; }
  .thumb { width: 56px; height: 35px; }
  .thumb.sm { width: 30px; height: 20px; }
  .preview { max-height: 210px; }
}

/* ---------- 伪代码规则编辑器 ---------- */
/* 同样只在该模式下出现 */
.rule-panel {
  display: none;
  border: 1px solid #d5e0ff; border-radius: 12px;
  padding: 12px 14px; background: #fbfcff; margin-bottom: 16px;
}
.rule-panel.on { display: block; }
.rule-head { font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.rule-hint { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 3px; }
.rule-panel textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.75; background: #fff; min-height: 150px;
}
.rule-ok {
  margin-top: 10px; font-size: 12.5px; background: #eef7f2;
  border: 1px solid #cfe9dd; border-radius: 10px; padding: 8px 12px; color: #14543c;
}
.rule-ok-title { font-weight: 650; margin-bottom: 4px; }
.rule-ok ul { margin: 0; padding-left: 18px; }
.rule-weights { margin-top: 6px; }
.rule-help { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.95; }
.rule-help code, .rule-ok code {
  background: #eff1f4; border-radius: 5px; padding: 1px 5px; font-size: 11.5px;
}
