:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --text: #111827;
  --muted: #6b7280;
  --accent-bg: #eff6ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.topbar .brand { display: flex; align-items: center; gap: 14px; }
.topbar .logo {
  width: 42px; height: 42px;
  background: rgba(255,255,255,.18);
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,.3);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar .sub { margin: 2px 0 0; font-size: 12px; opacity: .85; }
.topbar .meta { display: flex; align-items: center; gap: 10px; }
.chip {
  font-size: 12px; padding: 5px 10px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
}
.chip.ok { background: rgba(34,197,94,.25); border-color: rgba(34,197,94,.4); }
.chip.warn { background: rgba(245,158,11,.25); border-color: rgba(245,158,11,.4); }

.btn {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}
.btn.primary { background: #fff; color: var(--primary-dark); }
.btn.primary:hover { background: #f3f4f6; }
.btn.primary:disabled { opacity: .55; cursor: wait; }
.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.ghost:hover { background: var(--accent-bg); border-color: var(--primary); }

/* ---------------- 主布局 ---------------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 70px);
}

/* ---------------- 侧栏 ---------------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.bureau-block { padding: 14px 16px 6px; border-bottom: 1px solid var(--border); }
.bureau-block h2 {
  margin: 0; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.bureau-block .count {
  font-size: 11px; color: var(--muted);
  background: #f3f4f6; padding: 2px 7px; border-radius: 999px;
}
.bureau-block .hint { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }

.cand-list { list-style: none; margin: 0; padding: 0; }
.cand-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
  margin-bottom: 2px;
}
.cand-list li:hover { background: var(--accent-bg); }
.cand-list li.active {
  background: var(--primary); color: #fff;
}
.cand-list li.active .badge { background: rgba(255,255,255,.25); color: #fff; }
.cand-list li.active .score { color: #fff; }

.cand-list .name { display: flex; align-items: center; gap: 6px; }
.cand-list .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #d1d5db;
}
.cand-list .dot.graded { background: var(--success); }
.cand-list .dot.blank { background: var(--danger); }

.cand-list .score { color: var(--muted); font-variant-numeric: tabular-nums; }
.cand-list .badge {
  background: #f3f4f6; color: var(--muted);
  padding: 1px 6px; border-radius: 4px; font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 内容区 ---------------- */
.content { display: flex; flex-direction: column; overflow: hidden; }
.tabs {
  display: flex;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 4px;
}
.tab {
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-pane {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}
.tab-pane.active { display: block; }

.empty {
  margin-top: 80px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .pill {
  font-size: 12px;
  background: var(--accent-bg);
  color: var(--primary-dark);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.card-body { padding: 16px 18px; }

/* ---------------- 试卷查看 ---------------- */
.q-stem {
  background: #fafbfc;
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 12px;
  white-space: pre-wrap;
  font-size: 13px;
  color: #374151;
  max-height: 220px;
  overflow-y: auto;
}
.q-answer {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.85;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: "Songti SC", "SimSun", "PingFang SC", serif;
}
.q-answer.empty {
  background: #fef2f2; color: var(--danger);
  font-style: italic;
  text-align: center;
  padding: 24px;
  font-family: inherit;
}
.word-count {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  text-align: right;
}

/* ---------------- AI 评分维度表 ---------------- */
.dim-row {
  display: grid;
  grid-template-columns: 130px 100px 1fr;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.dim-row:last-child { border-bottom: none; }
.dim-name { font-weight: 600; color: var(--text); }
.dim-score {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.dim-score .full { font-size: 12px; color: var(--muted); font-weight: 400; }
.dim-reason {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.7;
}
.score-good { color: var(--success); }
.score-mid  { color: var(--warn); }
.score-bad  { color: var(--danger); }

.total-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  margin-bottom: 14px;
}
.total-banner .num {
  font-size: 32px; font-weight: 700; color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.total-banner .num small { font-size: 16px; color: var(--muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
}
.tag.good { background: #dcfce7; color: #15803d; }
.tag.bad  { background: #fee2e2; color: #b91c1c; }
.tag.tip  { background: #fef3c7; color: #92400e; }

.comment {
  background: #f9fafb;
  border-left: 3px solid var(--muted);
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: #374151;
  margin-top: 12px;
}

/* ---------------- 对比 ---------------- */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.compare-table th, .compare-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.compare-table th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.compare-table .num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.diff-pos { color: var(--success); }
.diff-neg { color: var(--danger); }
.diff-zero { color: var(--muted); }

/* ---------------- 统计仪表盘 ---------------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: 8px;
}
.metric-card .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.metric-card .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.metric-card .desc { font-size: 11px; color: var(--muted); margin-top: 4px; }

.chart-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  height: 360px;
}

/* ---------------- Rubric ---------------- */
.rubric-card {
  margin-bottom: 14px;
}
.rubric-card .card-head .meta {
  font-size: 12px; color: var(--muted);
}
.rubric-dim {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.rubric-dim:last-child { border-bottom: none; }
.rubric-dim .name {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex; justify-content: space-between;
}
.rubric-dim .name .pts {
  color: var(--primary-dark);
  background: var(--accent-bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.rubric-dim .criteria {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.7;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 100;
}
.toast.show { opacity: .95; }
.toast.err { background: var(--danger); }

/* ---------------- 考生树（单位 / 场次 / 考生） ---------------- */
.sidebar-head { padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.sidebar-head h2 {
  margin: 0; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.sidebar-head .count {
  font-size: 11px; color: var(--muted);
  background: #f3f4f6; padding: 2px 7px; border-radius: 999px;
}
.sidebar-head .hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.cand-tree { padding: 6px 8px 18px; }
.empty-tree { padding: 22px 12px; font-size: 13px; color: var(--muted); text-align: center; }

.tree-dept { border-bottom: 1px solid var(--border); padding: 4px 0 6px; }
.tree-dept-head, .tree-session-head {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; user-select: none;
}
.tree-dept-head { font-weight: 600; font-size: 13px; }
.tree-dept-head:hover, .tree-session-head:hover { background: var(--accent-bg); }
.tree-dept-head .td-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-session-head .ts-name { flex: 1; }
.tree-dept-head .count, .tree-session-head .count {
  font-size: 11px; color: var(--muted);
  background: #f3f4f6; padding: 1px 7px; border-radius: 999px;
}
.tree-dept-meta { font-size: 11px; color: var(--muted); padding: 0 8px 4px 26px; }
.tree-dept-meta.warn { color: var(--danger); }
.tree-session { margin-left: 12px; }
.tree-session-head { font-size: 12.5px; color: #374151; }
.tree-session .cand-list { padding-left: 8px; }

.caret { font-size: 10px; color: var(--muted); transition: transform .15s; display: inline-block; }
.tree-dept.collapsed .tree-dept-body { display: none; }
.tree-dept.collapsed > .tree-dept-head .caret { transform: rotate(-90deg); }
.tree-session.collapsed .cand-list { display: none; }
.tree-session.collapsed > .tree-session-head .caret { transform: rotate(-90deg); }

/* ---------------- 导入：结构提示 / 结果 ---------------- */
.zip-struct {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: 12.5px; line-height: 1.9; margin-bottom: 14px;
}
.zip-struct code { background: #eef2f7; padding: 1px 6px; border-radius: 4px; }
.warn-line { color: #b45309; font-size: 13px; padding: 2px 0; }
.dept-btns { display: flex; flex-wrap: wrap; gap: 8px; }
