:root {
  --ink: #17202a;
  --muted: #697586;
  --line: #e5e9ef;
  --line-strong: #d8dee7;
  --canvas: #f5f7fa;
  --paper: #fff;
  --sidebar: #17232f;
  --sidebar-hover: #223344;
  --sidebar-muted: #8fa1b3;
  --accent: #167d6b;
  --accent-hover: #116958;
  --accent-soft: #eaf6f3;
  --danger: #c34242;
  --danger-soft: #fff0f0;
  --warning: #9a681a;
  --shadow: 0 1px 2px rgba(20, 32, 45, .04), 0 6px 20px rgba(20, 32, 45, .035);
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.admin-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: 244px;
  flex-direction: column;
  overflow-y: auto;
  background: var(--sidebar);
  padding: 22px 14px 14px;
  color: #fff;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 8px; }
.brand-mark {
  flex: 0 0 auto;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(22, 125, 107, .24);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 15px; letter-spacing: .01em; }
.sidebar-brand small { margin-top: 3px; color: var(--sidebar-muted); font-size: 10px; }
.sidebar-section-label { margin: 34px 11px 9px; color: #708497; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.tabs { display: grid; gap: 4px; }
.tabs button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0 11px;
  color: #b8c5d0;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}
.tabs button:hover { background: var(--sidebar-hover); color: #fff; }
.tabs button.active { background: #26483f; color: #fff; font-weight: 650; }
.nav-icon { width: 18px; color: #8195a6; font-size: 16px; line-height: 1; text-align: center; }
.tabs button.active .nav-icon { color: #6ed3b9; }
.nav-label { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { min-width: 23px; border-radius: 10px; background: rgba(255,255,255,.08); padding: 2px 7px; color: #aebdc9; font-size: 10px; text-align: center; }
.tabs button.active .nav-count { background: rgba(110,211,185,.14); color: #9ce5d2; }
.sidebar-spacer { flex: 1 1 auto; min-height: 32px; }
.back-to-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 12px;
  color: #aebdc9;
  font-size: 12px;
  text-decoration: none;
}
.back-to-chat:hover { background: var(--sidebar-hover); color: #fff; }
.operator-card { position: relative; display: grid; grid-template-columns: 34px minmax(0,1fr) 28px; align-items: center; gap: 9px; margin-top: 8px; border-top: 1px solid rgba(255,255,255,.08); padding: 15px 4px 2px; }
.operator-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #304455; color: #d8e2ea; font-size: 12px; font-weight: 700; }
.operator-info { min-width: 0; }
.operator-info strong, .operator-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-info strong { font-size: 11px; font-weight: 650; }
.operator-info small { margin-top: 3px; color: var(--sidebar-muted); font-size: 9px; }
.operator-more { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: #8fa1b3; font-size: 11px; letter-spacing: 1px; }
.operator-more:hover, .operator-more.active { background: var(--sidebar-hover); color: #fff; }
.operator-menu { position: absolute; right: 0; bottom: 48px; display: none; width: 138px; border: 1px solid #dfe4ea; border-radius: 8px; background: #fff; padding: 5px; box-shadow: 0 14px 38px rgba(10,20,30,.2); }
.operator-menu.open { display: grid; }
.operator-menu button { height: 34px; border: 0; border-radius: 5px; background: transparent; padding: 0 10px; color: #35404b; font-size: 11px; text-align: left; }
.operator-menu button:hover { background: #f2f5f7; }
.operator-menu #logout-button { color: var(--danger); }
.sidebar-backdrop { display: none; }

.main-shell { min-height: 100vh; margin-left: 244px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 62px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  padding: 0 30px;
  backdrop-filter: blur(12px);
}
.topbar-leading { display: flex; align-items: center; gap: 12px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: #87919d; font-size: 11px; }
.breadcrumb b { color: #c3cad2; font-weight: 400; }
.breadcrumb strong { color: #384452; font-weight: 650; }
.mobile-menu-button { display: none; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
.workspace { width: min(1360px, calc(100% - 60px)); margin: 0 auto; padding: 30px 0 64px; }
.workspace-header { display: flex; min-height: 58px; align-items: flex-start; justify-content: space-between; }
.workspace-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.workspace-header p { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.notice { min-height: 0; margin: 18px 0; border: 1px solid #e4e8ec; border-radius: 8px; background: #f9fafb; padding: 10px 12px; color: var(--muted); font-size: 11px; }
.notice:empty { display: none; }
.notice.success { border-color: #cce8e0; background: var(--accent-soft); color: var(--accent); }
.notice.error { border-color: #f1cece; background: var(--danger-soft); color: var(--danger); }
.panel { display: none; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); box-shadow: var(--shadow); }
.panel.active { display: block; }
.panel-header { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding: 16px 20px; }
.panel-header h2 { font-size: 14px; font-weight: 700; }
.panel-header p { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; }

.primary-button, .secondary-button { display: inline-flex; min-height: 34px; align-items: center; justify-content: center; gap: 5px; border-radius: 7px; padding: 0 13px; font-size: 11px; font-weight: 650; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.secondary-button { border: 1px solid var(--line-strong); background: var(--paper); color: #3d4955; }
.secondary-button:hover { border-color: #c7d0d9; background: #f7f9fa; }
.refresh-button span { font-size: 15px; line-height: 1; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; min-width: 980px; border-collapse: collapse; color: #34404c; font-size: 11px; }
.data-table th, .data-table td { border-bottom: 1px solid #edf0f3; padding: 13px 16px; text-align: left; vertical-align: middle; white-space: nowrap; }
.data-table th { background: #fafbfc; color: #697586; font-size: 10px; font-weight: 700; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table strong { color: var(--ink); font-weight: 650; }
.data-table .subtle { display: block; max-width: 190px; margin-top: 4px; overflow: hidden; color: #8a95a1; font-size: 9px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.data-table .mono { color: #536171; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.data-table .truncate { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.table-actions { display: flex; gap: 6px; }
.table-action { height: 28px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; padding: 0 9px; color: #4b5966; font-size: 10px; }
.table-action:hover { border-color: #afbbc6; background: #f7f9fa; }
.table-action.danger { border-color: #efd5d5; color: var(--danger); }
.table-action.danger:hover { background: var(--danger-soft); }
.status-group { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.status-tag { border-radius: 12px; background: #eef1f4; padding: 4px 8px; color: #66717d; font-size: 9px; white-space: nowrap; }
.status-tag.success { background: var(--accent-soft); color: var(--accent); }
.status-tag.warning { background: #fff4df; color: var(--warning); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { min-width: 0; display: grid; gap: 6px; }
.field.wide { grid-column: span 2; }
.field > span, .permissions-label { color: #5f6c79; font-size: 10px; font-weight: 650; }
.field input, .field select, .field textarea { min-width: 0; width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: #fff; padding: 0 10px; color: var(--ink); font-size: 11px; transition: border-color .15s ease, box-shadow .15s ease; }
.field textarea { height: auto; min-height: 220px; padding: 10px; resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus, .quality-window select:focus { border-color: #73aa9e; box-shadow: 0 0 0 3px rgba(22,125,107,.09); }
.field .field-help { color: var(--muted); font-size: 9px; line-height: 1.45; }
.field input[readonly] { background: #f5f7f9; color: #65717d; }
.field-readonly { min-height: 36px; border: 1px solid var(--line); border-radius: 6px; background: #f5f5f3; padding: 9px 10px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.field input::placeholder { color: #aeb6bf; }
.source-specific { display: grid; grid-column: span 2; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.source-specific .field.wide { grid-column: span 2; }
.form-options, .permissions { grid-column: span 2; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; border-top: 1px dashed #e2e6eb; padding-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: #4c5966; font-size: 10px; }
.check input { accent-color: var(--accent); }
.credential { margin-left: auto; border-radius: 12px; background: #f0f2f5; padding: 4px 9px; color: var(--muted); font-size: 9px; }
.credential + .credential { margin-left: 0; }
.credential.ready { background: var(--accent-soft); color: var(--accent); }
.permissions { display: block; }
.permissions-list { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 10px; }
.model-discovery { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 7px; background: #fafaf9; padding: 12px; }
.model-discovery-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.model-discovery-header strong, .model-discovery-header small { display: block; }
.model-discovery-header strong { color: var(--ink); font-size: 11px; }
.model-discovery-header small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.available-models { color: var(--muted); font-size: 10px; line-height: 1.5; }
.available-model-summary { margin-bottom: 8px; color: var(--muted); font-size: 9px; }
.available-model-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.available-model { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; padding: 8px 9px; color: var(--ink); text-align: left; }
.available-model:hover, .available-model.selected { border-color: #8b918b; background: #f0f1ee; }
.available-model span { min-width: 0; overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.available-model small { flex: 0 0 auto; color: var(--muted); font-size: 9px; }
.available-model-error { color: var(--danger); }
.empty-records { margin: 20px; border: 1px dashed #cfd6de; border-radius: 9px; padding: 42px 20px; background: #fafbfc; color: var(--muted); text-align: center; font-size: 11px; }

.quality-window { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.quality-window select { height: 34px; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; background: #fff; padding: 0 9px; color: var(--ink); font-size: 11px; }
.quality-content { display: grid; gap: 16px; padding: 20px; }
.subsection-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 26px 0 12px; }
.subsection-header h3 { margin: 0 0 5px; font-size: 14px; }
.subsection-header p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.quality-content .empty-records { margin: 0; }
.quality-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.quality-card { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 17px; }
.quality-card span, .quality-card small { display: block; color: var(--muted); font-size: 9px; }
.quality-card strong { display: block; margin: 8px 0 6px; font-size: 23px; font-weight: 720; letter-spacing: -.02em; }
.quality-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 12px; }
.quality-agent-table { grid-column: 1 / -1; }
.quality-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 16px; }
.quality-table h3 { margin: 0 0 12px; font-size: 12px; }
.quality-table table { width: 100%; border-collapse: collapse; font-size: 10px; }
.quality-table th, .quality-table td { border-bottom: 1px solid #eceff2; padding: 9px 7px; text-align: left; white-space: nowrap; }
.quality-table tr:last-child td { border-bottom: 0; }
.quality-table th { background: #fafbfc; color: var(--muted); font-weight: 650; }
.quality-model-table { grid-column: 1 / -1; }
.quality-model-table table { min-width: 880px; }
.quality-model-table td:first-child strong, .quality-model-table td:first-child small,
.quality-model-table td:nth-child(7) strong, .quality-model-table td:nth-child(7) small { display: block; }
.quality-model-table td small { margin-top: 3px; }
.loading { cursor: progress; }
.loading .records, .loading .quality-content { opacity: .58; pointer-events: none; }

dialog { width: min(430px, calc(100% - 32px)); border: 0; border-radius: 11px; padding: 0; box-shadow: 0 24px 70px rgba(20,30,40,.25); }
dialog::backdrop { background: rgba(19,29,39,.48); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 16px; padding: 22px; }
dialog header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 14px; }
dialog header strong { font-size: 15px; }
dialog header button { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 20px; }
dialog header button:hover { background: #f2f4f6; }
dialog p { color: var(--muted); font-size: 10px; }
.editor-dialog { width: min(800px, calc(100% - 32px)); max-height: min(820px, calc(100vh - 32px)); max-height: min(820px, calc(100dvh - 32px)); overflow: hidden; }
.editor-dialog form { max-height: inherit; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0; overflow: hidden; }
.editor-dialog #editor-fields { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 16px 8px 16px 0; }
.editor-dialog header { align-items: flex-start; }
.editor-dialog header p { margin-top: 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }

/* 与分析工作台一致的 Codex 风格管理界面。 */
:root {
  --ink: #202123;
  --muted: #6f7478;
  --line: #e4e4e1;
  --line-strong: #d3d5d1;
  --canvas: #fff;
  --paper: #fff;
  --sidebar: #f5f5f3;
  --sidebar-hover: #e8e8e5;
  --sidebar-muted: #858984;
  --accent: #137b68;
  --accent-hover: #0f6959;
  --accent-soft: #e6f4f0;
  --shadow: none;
}

body { background: #fff; }
.sidebar {
  width: 248px;
  border-right: 1px solid #e5e5e2;
  background: var(--sidebar);
  padding: 10px;
  color: #30322f;
}
.sidebar-brand { min-height: 42px; gap: 9px; padding: 2px 4px; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #252724;
  box-shadow: none;
  font-size: 9px;
}
.sidebar-brand strong { color: #272926; font-size: 13px; }
.sidebar-brand small { margin-top: 2px; color: #858984; font-size: 9px; }
.sidebar-section-label { margin: 20px 9px 7px; color: #8b8e89; letter-spacing: .06em; }
.tabs { gap: 2px; }
.tabs button {
  min-height: 36px;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  border-radius: 6px;
  padding: 0 9px;
  color: #555954;
}
.tabs button:hover, .tabs button.active { background: var(--sidebar-hover); color: #20221f; }
.tabs button.active { font-weight: 650; }
.nav-icon, .tabs button.active .nav-icon { color: #858984; font-size: 13px; }
.nav-label { font-size: 12px; }
.nav-count, .tabs button.active .nav-count { background: #dfdfdc; color: #717570; }
.back-to-chat { min-height: 36px; border-radius: 6px; padding: 0 9px; color: #555954; }
.back-to-chat:hover { background: var(--sidebar-hover); color: #20221f; }
.operator-card { grid-template-columns: 30px minmax(0,1fr) 28px; border-top-color: #dfdfdb; padding-top: 11px; }
.operator-avatar { width: 30px; height: 30px; background: #e5c86f; color: #514319; font-size: 10px; }
.operator-info strong { color: #30322f; }
.operator-info small { color: #858984; }
.operator-more { color: #777b76; }
.operator-more:hover, .operator-more.active { background: var(--sidebar-hover); color: #20221f; }
.operator-menu { border-color: var(--line); box-shadow: 0 12px 30px rgba(28,30,27,.14); }
.operator-menu button:hover { background: #f3f3f1; }

.main-shell { margin-left: 248px; }
.topbar { height: 52px; border-bottom-color: #ededeb; background: rgba(255,255,255,.98); padding: 0 20px; backdrop-filter: none; }
.breadcrumb { color: #8a8e89; }
.breadcrumb strong { color: #3f423e; }
.workspace { width: min(1360px, calc(100% - 48px)); padding: 24px 0 56px; }
.workspace-header { min-height: 52px; }
.workspace-header h1 { color: #272926; font-size: 21px; font-weight: 680; }
.workspace-header p { margin-top: 5px; font-size: 11px; }
.notice { margin: 14px 0; border-color: var(--line); background: #fafaf9; }
.panel { border-color: var(--line); border-radius: 8px; box-shadow: none; }
.panel-header { min-height: 68px; padding: 14px 16px; }
.panel-header h2 { font-size: 13px; }
.primary-button, .secondary-button { min-height: 32px; border-radius: 6px; }
.primary-button { border-color: #292b28; background: #292b28; }
.primary-button:hover { border-color: #3b3e3a; background: #3b3e3a; }
.secondary-button { border-color: var(--line-strong); color: #4d514c; }
.secondary-button:hover { border-color: #bfc2bd; background: #f6f6f4; }
.data-table { color: #40443f; }
.data-table th, .data-table td { border-bottom-color: #ededeb; padding: 12px 14px; }
.data-table th { background: #fafaf9; color: #737772; }
.data-table tbody tr:hover { background: #fafaf9; }
.table-action { border-color: var(--line-strong); border-radius: 5px; color: #555954; }
.table-action:hover { border-color: #b9bdb7; background: #f6f6f4; }
.status-tag { background: #efefed; color: #676b66; }
.field > span, .permissions-label { color: #5e625d; }
.field input, .field select, .field textarea, .quality-window select { border-color: var(--line-strong); border-radius: 6px; color: #292b28; }
.field input:focus, .field select:focus, .field textarea:focus, .quality-window select:focus { border-color: #929791; box-shadow: 0 0 0 2px rgba(60,65,60,.08); }
.field input[readonly] { background: #f5f5f3; }
.empty-records { border-color: #d7d8d4; border-radius: 8px; background: #fafaf9; }
.quality-card, .quality-table { border-color: var(--line); border-radius: 8px; box-shadow: none; }
.quality-table th { background: #fafaf9; }

dialog { border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 60px rgba(28,30,27,.2); }
dialog::backdrop { background: rgba(28,30,27,.36); backdrop-filter: none; }
dialog form { padding: 20px; }
dialog header button:hover { background: #f2f2f0; }

@media (max-width: 1100px) {
  .quality-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); box-shadow: 12px 0 35px rgba(10,20,30,.2); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; border: 0; background: rgba(18,28,38,.42); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main-shell { margin-left: 0; }
  .topbar { height: 58px; padding: 0 16px; }
  .mobile-menu-button { display: inline-grid; place-items: center; }
  .workspace { width: calc(100% - 28px); padding-top: 24px; }
  .workspace-header h1 { font-size: 21px; }
  .panel-header { align-items: flex-start; }
  .quality-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .breadcrumb span, .breadcrumb b { display: none; }
  .refresh-button { width: 34px; padding: 0; font-size: 0; }
  .refresh-button span { font-size: 17px; }
  .workspace-header { min-height: 50px; }
  .panel-header { display: grid; gap: 13px; padding: 15px; }
  .panel-header .primary-button { width: fit-content; }
  .form-grid, .source-specific { grid-template-columns: 1fr; }
  .field.wide, .source-specific .field.wide, .form-options, .permissions, .source-specific { grid-column: auto; }
  .credential { width: 100%; margin-left: 0; }
  .quality-window { justify-self: start; }
  .quality-cards { grid-template-columns: 1fr; }
  .quality-content { padding: 14px; }
  .model-discovery-header { align-items: flex-start; flex-direction: column; }
  .available-model-list { grid-template-columns: 1fr; }
}
