:root {
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1b2430;
  --muted: #5f6b7a;
  --primary: #3158ec;
  --border: #e2e8f2;
  --danger: #c02626;
  --ok: #0d7a5c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--primary); }
.wrap { width: 100%; max-width: none; margin: 0 auto; padding: 16px; box-sizing: border-box; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
h1 { margin: 0 0 8px; font-size: 22px; }
h2 { margin: 0 0 10px; font-size: 17px; }
p.muted { margin: 0; color: var(--muted); }
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
}
.layout > section {
  min-width: 0;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
.menu button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}
.menu button.active {
  border-color: #ced9fb;
  background: #f3f6ff;
  color: #2f4fc9;
  font-weight: 600;
}
/*
 * 按钮语义（管理端统一，勿混用）：
 * - .btn（主色，蓝）：当前界面上的**主路径正向动作**——会提交/创建/启动主流程，如「保存」「新建」「登录」「生成」「查询」、工具栏主 CTA。
 * - .btn.secondary（中性灰）：**辅助或低风险动作**——取消、关闭、返回上一级列表、仅导航或不改写关键数据的操作，如「取消」「← 返回」「目录」「章节」「试播」「上一页」（分页）等。
 * 同一行多个操作时：通常最多一个主按钮；其余用 .secondary，避免视觉竞争。
 */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
textarea { width: 100%; min-height: 120px; font-family: ui-monospace, monospace; }
.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn.secondary { background: #64748b; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.flash {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.flash.err { background: #fee2e2; color: #7f1d1d; }
.flash.ok { background: #dcfce7; color: #14532d; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}
/* 操作列：勿用 .row（含 margin-top，且 flex 直接作用在 td 上易产生双边线感与行高错位） */
table.data td.td-actions {
  vertical-align: middle;
}
table.data .td-actions-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
}
table.data th { background: #f8fafc; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #e2e8f0; }
.badge.on { background: #dcfce7; color: #14532d; }
.badge.off { background: #fee2e2; color: #7f1d1d; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal-backdrop[data-busy='1'] {
  cursor: wait;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--border);
  max-height: 90vh;
  overflow-y: auto;
}
.modal.wide { max-width: 720px; }
.modal.xwide { max-width: 1200px; }
.modal h3 { margin-top: 0; }
.es-bbox-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: 16px;
  align-items: start;
}
.es-bbox-grid > div {
  min-width: 0;
}
.es-select-grid-2x2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
@media (max-width: 760px) {
  .es-select-grid-2x2 {
    grid-template-columns: 1fr;
  }
}
.es-bbox-coords {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.es-bbox-question-text {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 140px;
  overflow: auto;
}
.es-bbox-coord-row {
  display: grid;
  grid-template-columns: 4.5em 1fr;
  gap: 10px;
  align-items: center;
}
.es-bbox-coord-row label {
  margin: 0;
}
.es-bbox-coord-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}
.es-bbox-crop-preview {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
}
.es-bbox-crop-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
}
@media (max-width: 900px) {
  .es-bbox-grid { grid-template-columns: 1fr; }
}
.es-bbox-stage-wrap {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px;
  overflow: auto;
  width: 100%;
  max-width: 100%;
}
.es-bbox-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}
.es-bbox-stage img {
  display: block;
  max-width: 100%;
  height: auto;
}
.es-bbox-overlay {
  position: absolute;
  border: 2px solid #e11d48;
  box-sizing: border-box;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}
.es-analyze-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}
.es-analyze-group-head { display: block; margin-bottom: 4px; }
.es-analyze-group-desc {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}
.es-qgroup {
  margin-top: 14px;
}
.es-inline-detail {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
.es-qgroup-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}
.es-qgroup-desc {
  margin: 0 0 8px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.es-question-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  margin-top: 10px;
}
.es-question-stem {
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 14px;
}
.es-question-section {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.es-question-label {
  font-weight: 600;
  margin-right: 6px;
}
.es-math-inline .katex {
  font-size: 1em;
}
.es-math-block {
  margin: 6px 0;
  overflow-x: auto;
}
.es-math-block .katex-display {
  margin: 0;
}
.es-math-fallback {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.es-sub-question-row {
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px dashed #dbe3ef;
  border-radius: 6px;
  background: #fbfdff;
}
.es-question-images-grid {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.es-question-image-item {
  display: block;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  padding: 0;
  cursor: zoom-in;
  width: 100%;
}
.es-question-image {
  display: block;
  width: 100%;
  height: 120px;
  object-fit: contain;
}
.es-question-empty {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.es-image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 24px;
}
.es-image-lightbox-inner {
  max-width: min(1200px, 95vw);
  max-height: min(90vh, 900px);
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.es-image-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 32px);
  width: auto;
  height: auto;
  object-fit: contain;
}
.form-grid { display: grid; gap: 10px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
pre.raw {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  max-height: 240px;
}
.ai-log-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
/* AI 调用日志：筛选与分页分两行，分页独占一行 */
.ai-log-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
.ai-log-toolbar .ai-log-filters {
  flex: none;
  width: 100%;
}
.ai-log-pager-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}
.ai-log-pager-row .ai-log-pager {
  flex: 0 0 auto;
}
.ai-log-filters {
  flex: 1 1 auto;
  min-width: 0;
}
.ai-log-pager {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 0 0 auto;
  align-items: center;
}
.ai-log-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-width: 1000px;
  align-items: end;
}
.ai-log-filters-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.ai-log-filter-row {
  display: grid;
  gap: 12px 16px;
  align-items: center;
  width: 100%;
}
.ai-log-filter-row.ai-log-filter-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.ai-log-filter-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ai-log-filter-field label {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 12px;
}
.ai-log-filter-field input,
.ai-log-filter-field select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.ai-log-pager .ai-log-limit-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.ai-log-pager .ai-log-limit-inline input {
  width: 4.5rem;
  min-width: 0;
}
@media (max-width: 900px) {
  .ai-log-filter-row.ai-log-filter-cols-3 {
    grid-template-columns: 1fr;
  }
}
/* 英文短文列表：筛选、分页、紧凑单行表格 */
.ep-list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
.ep-list-filters {
  width: 100%;
}
.ep-filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px 12px;
  align-items: center;
}
.ep-filter-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ep-filter-field label {
  flex: 0 0 auto;
  margin-bottom: 0;
  white-space: nowrap;
  font-size: 12px;
}
.ep-filter-field select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.ep-list-pager-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}
.ep-list-pager {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}
.ep-limit-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}
.ep-limit-inline input {
  width: 4rem;
  min-width: 0;
}
.ep-page-meta {
  font-size: 12px;
  white-space: nowrap;
}
@media (max-width: 1100px) {
  .ep-filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.table-wrap-ep {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}
table.data.english-passages {
  table-layout: fixed;
  width: 100%;
  min-width: 920px;
}
table.data.english-passages th,
table.data.english-passages td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  padding: 6px 8px;
}
table.data.english-passages td.ep-col-preview {
  max-width: 120px;
  width: 120px;
}
table.data.english-passages td.ep-col-topic {
  max-width: 88px;
  width: 88px;
}
table.data.english-passages td.ep-col-id,
table.data.english-passages td.ep-col-ver,
table.data.english-passages td.ep-col-lex,
table.data.english-passages td.ep-col-cefr,
table.data.english-passages td.ep-col-cat,
table.data.english-passages td.ep-col-flag {
  width: 56px;
  max-width: 72px;
}
table.data.english-passages td.td-actions.ep-col-actions {
  width: 108px;
  max-width: 108px;
  overflow: visible;
}
table.data.english-passages .td-actions-inner {
  flex-wrap: nowrap;
}
.table-wrap-ai {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
}
table.data.ai-logs {
  min-width: 520px;
  table-layout: auto;
}
table.data.ai-logs th,
table.data.ai-logs td {
  white-space: nowrap;
}
table.data.ai-logs td.ai-wrap {
  white-space: normal;
  min-width: 220px;
  max-width: min(420px, 36vw);
}
table.data.ai-logs tr.ai-log-detail td {
  padding: 0 !important;
  vertical-align: top;
  background: #f1f5f9;
  border-top: 1px dashed var(--border);
}
table.data.audit-logs tr.audit-log-detail td {
  padding: 0 !important;
  vertical-align: top;
  background: #f1f5f9;
  border-top: 1px dashed var(--border);
}
tr.ai-log-main,
tr.audit-log-main {
  cursor: pointer;
}
tr.ai-log-main:hover,
tr.audit-log-main:hover {
  background: #f1f5f9;
}
tr.ai-log-main.ai-log-open,
tr.audit-log-main.ai-log-open {
  background: #e2e8f0;
}
.ai-detail-text {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}
table.data.ai-log-detail-inner {
  width: 100%;
  margin: 0;
  table-layout: fixed;
  border: 0;
  background: transparent;
}
table.data.ai-log-detail-inner th[scope='row'] {
  width: 10.5rem;
  min-width: 7rem;
  max-width: 12rem;
  white-space: normal;
  word-break: break-word;
  vertical-align: top;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  background: #e8edf5;
  border-bottom: 1px solid var(--border);
}
table.data.ai-log-detail-inner td.ai-detail-td {
  white-space: normal;
  padding: 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
pre.ai-detail-pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: #f8fafc;
  border: 0;
}
details.ai-fold {
  margin: 6px 0;
}
details.ai-fold > summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  list-style: none;
}
details.ai-fold > summary::-webkit-details-marker { display: none; }
details.ai-fold > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.12s ease;
}
details.ai-fold[open] > summary::before { transform: rotate(90deg); }
pre.ai-fold-pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.4;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
@media (max-width: 700px) { .kpis { grid-template-columns: 1fr; } }
.kpi { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { margin-top: 6px; font-size: 22px; font-weight: 700; }

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  margin-top: 4px;
}
.radio-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: normal;
}
.radio-line input[type="radio"] {
  margin: 0;
}
