/* 管理工作台：复用阅读器色彩，以紧凑的无衬线界面组织管理任务。 */
body.admin {
  --font-serif: var(--font);
  display: block; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 13px; font-weight: 400; line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
body.admin :is(button, input, select, textarea) { font-family: var(--font); }
body.admin :is(button, a, summary, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
#panels { display: flex; min-height: 100dvh; align-items: stretch; }
#panels[hidden], .tab-panel[hidden], .ai-view[hidden], #overview-health[hidden] { display: none; }

/* 固定工作区导航；窄屏改用可直接选择的分区菜单。 */
#admin-nav {
  width: 190px; flex: none; position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 24px 12px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
#admin-nav > .brand, #admin-nav > nav, #admin-nav > .nav-foot { flex-shrink: 0; }
#admin-nav .brand { display: flex; align-items: center; gap: 10px; padding: 0 9px 26px; line-height: 1.35; }
.admin-brand-mark {
  display: grid; place-items: center; flex: none; width: 32px; height: 36px;
  color: var(--accent-ink); background: var(--accent-soft); border: 1px solid var(--line); border-radius: 9px;
}
.admin-brand-mark svg { width: 21px; height: 21px; }
.admin-brand-copy { display: flex; flex-direction: column; gap: 4px; }
.admin-brand-copy strong { font-size: 16px; font-weight: 650; color: var(--ink); }
.admin-brand-copy > span { font-size: 10px; color: var(--muted); letter-spacing: .12em; }
#admin-nav nav { display: flex; flex-direction: column; gap: 3px; }
.nav-section-label { margin: 21px 10px 6px; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .08em; }
.nav-section-label:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px;
  padding: 8px 10px; border: 0; border-radius: 7px; background: transparent;
  color: var(--ink-soft); font: inherit; font-size: 13px; font-weight: 400; text-align: left;
  cursor: pointer; transition: background .12s, color .12s;
}
.nav-item:hover { color: var(--ink); background: var(--surface-2); filter: none; }
.nav-item.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.nav-item svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.nav-item .dot { display: none; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.nav-item.has-alert .dot { display: block; }
.admin-mobile-section { display: none; }
.nav-foot { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding: 18px 2px 0; color: var(--muted); font-size: 11px; }
.nav-foot a { display: flex; align-items: center; gap: 6px; padding: 7px 9px; color: var(--muted); border-radius: 6px; text-decoration: none; }
#theme-toggle .ui-icon { width: 15px; height: 15px; }
.nav-foot a:hover { color: var(--ink); background: var(--surface-2); }
#admin-who { padding: 10px 9px 7px; border-top: 1px solid var(--line); color: var(--ink-soft); overflow-wrap: anywhere; }

/* 内容骨架 */
#admin-content { flex: 1; min-width: 0; padding: 28px clamp(20px, 2.25vw, 36px) 48px; }
#admin-content > .inner { max-width: 1240px; margin: 0 auto; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading > div:first-child { min-width: 0; }
.page-title { margin: 0; font-size: 23px; font-weight: 650; letter-spacing: -.035em; line-height: 1.35; }
.page-sub { margin: 7px 0 0; max-width: 82ch; color: var(--muted); font-size: 12px; line-height: 1.65; }
.page-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.card { padding: 18px 20px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.5; }
.card h2 .badge { font-weight: 500; }
.card h3 { margin: 18px 0 12px; padding-top: 16px; border-top: 1px solid var(--line-2); color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.card > .hint { max-width: 84ch; margin-top: 0; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head > div { min-width: 0; }
.card-head .hint { margin: 4px 0 0; }
.card-head > button, .card-head > a { flex: none; }
.card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card h2 .link { margin-left: auto; }

/* 概览：数值、运行状态、用量组成一眼可扫读的工作区。 */
.overview-summary { padding: 0; border: 0; background: transparent; box-shadow: none; }
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
#overview { margin-bottom: 18px; }
.stat { min-width: 0; padding: 15px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.stat .num { color: var(--ink); font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -.035em; overflow-wrap: anywhere; }
.stat .num.num-text { padding: 6px 0; font-size: 15px; font-weight: 500; letter-spacing: 0; }
.stat .lbl { margin-top: 7px; color: var(--muted); font-size: 11px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.overview-grid > .card { margin: 0; }
.overview-grid .table-wrap { max-height: 330px; }
.overview-callout {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 0 0 18px; padding: 12px 15px; color: var(--ink-soft); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px;
}
.overview-callout strong { color: var(--ink); font-weight: 600; }
.overview-callout p { margin: 3px 0 0; }
.overview-callout a { flex: none; color: var(--accent-ink); text-decoration: none; font-size: 12px; }
.overview-callout a:hover { text-decoration: underline; }
.overview-callout.is-warning { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-ink) 20%, var(--line)); }
@media (min-width: 1180px) { .stats-row { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .overview-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }

/* 表单与按钮，尺寸由后台控制，避免阅读器文字样式渗入。 */
body.admin input:not([type="checkbox"]):not([type="radio"]), body.admin select, body.admin textarea {
  min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); background: var(--surface); font-size: 13px; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
body.admin input:not([type="checkbox"]):focus, body.admin select:focus, body.admin textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
body.admin input::placeholder, body.admin textarea::placeholder { color: var(--muted); opacity: .8; }
body.admin input[type="checkbox"], body.admin input[type="radio"] { flex: none; width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); }
body.admin input[type="hidden"] { display: none; }
body.admin button { font-size: 12px; font-weight: 500; line-height: 1.5; border-radius: 6px; }
#admin-content button:not(.link), .admin-dialog button:not(.dialog-close) { min-height: 34px; padding: 7px 12px; }
#admin-content button.mini, #admin-content button.chip, .admin-dialog button.chip { min-height: 30px; padding: 5px 9px; font-size: 11px; }
button.danger { color: var(--on-accent); background: var(--danger); border-color: transparent; }
button.danger.ghost { color: var(--danger); background: transparent; border-color: var(--danger-border); }
button.danger.ghost:hover, button.danger-action:hover { color: var(--danger); background: var(--danger-soft); filter: none; }
body.admin button.danger-action { color: var(--danger); background: transparent; border-color: transparent; }
body.admin .link { min-width: 30px; min-height: 30px; padding: 2px 7px; border: 0; color: var(--muted); background: transparent; font-size: 13px; }
body.admin .link:hover { color: var(--accent-ink); background: var(--surface-2); filter: none; }
#admin-content button.text-action { color: var(--accent-ink); background: transparent; border: 0; padding: 5px 0; }
#admin-content button.text-action:hover { text-decoration: underline; filter: none; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.row input:not([type="checkbox"]) { flex: 1; min-width: 150px; }
.grid2, .grid3 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid2 label, .grid3 label { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.grid2 input, .grid2 select, .grid3 input, .grid3 select { width: 100%; min-width: 0; }
.form-note, .field-note { margin: 0; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.6; }
.form-note { padding: 10px 12px; border-radius: 6px; background: var(--surface-2); }
.subhead { margin: 18px 0 10px; color: var(--ink); font-size: 13px; }
.setting-title { display: block; margin-bottom: 3px; color: var(--ink); font-size: 13px; font-weight: 500; }
.setting-desc { display: block; max-width: 70ch; color: var(--muted); font-size: 12px; line-height: 1.6; }
.switch-line { display: flex; align-items: center; gap: 7px; flex: none; color: var(--ink-soft); font-size: 12px; }
.setting-toggle, .settings-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 15px 0; border-bottom: 1px solid var(--line-2); }
.setting-toggle:first-child, .settings-row:first-child { padding-top: 0; }
.setting-toggle:last-child, .settings-row:last-child { padding-bottom: 0; border-bottom: 0; }
.settings-row > :is(input, select) { width: 180px; max-width: 100%; flex: none; }
.settings-stack { max-width: 920px; }
.settings-stack .card-head { margin-bottom: 17px; }
.settings-advanced { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.card.settings-advanced { padding: 0; }
.maintenance-tools { max-width: 920px; margin-top: 24px; }
.settings-advanced > summary { padding: 15px 18px; color: var(--ink-soft); font-size: 13px; font-weight: 500; cursor: pointer; }
.settings-advanced > summary .field-note { margin-left: 12px; }
.settings-advanced > summary:hover { color: var(--ink); background: var(--surface-2); border-radius: 9px; }
.settings-advanced[open] > summary { border-bottom: 1px solid var(--line-2); }
.details-body { padding: 18px; }
.details-body > .hint:first-child { margin-top: 0; }
.details-body > .card-actions:last-child { margin-bottom: 0; }
.save-bar {
  position: sticky; bottom: 16px; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 920px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); box-shadow: 0 4px 16px -8px rgba(40, 30, 20, .25);
}
.save-state { color: var(--muted); font-size: 12px; }
.save-state.is-dirty { color: var(--accent-ink); font-weight: 500; }
/* 标注参数的「实际效果」说明:把三个互相制约的分组参数翻译成一句话 */
.effective-note {
  margin: 14px 0 0; padding: 9px 12px; border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; line-height: 1.6;
}
.effective-note:empty { display: none; }

/* AI 配置分为任务路由与供应商管理。 */
.section-tabs { display: flex; align-items: center; gap: 4px; margin: 0 0 20px; padding-bottom: 0; border-bottom: 1px solid var(--line); }
#admin-content .section-tabs :is(button, a) {
  position: relative; min-height: 40px; padding: 9px 14px; border: 0; border-radius: 0;
  color: var(--muted); background: transparent; font-size: 13px; text-decoration: none;
}
#admin-content .section-tabs :is(button, a):hover { color: var(--ink); filter: none; }
#admin-content .section-tabs :is(.active, [aria-selected="true"], [aria-current="page"]) { color: var(--accent-ink); font-weight: 600; }
.section-tabs :is(.active, [aria-selected="true"], [aria-current="page"])::after { position: absolute; right: 14px; bottom: -1px; left: 14px; height: 2px; content: ""; background: var(--accent); }
.section-tabs .dot { display: none; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--danger); vertical-align: 0.15em; }
.section-tabs .has-alert .dot { display: inline-block; }
.config-intro { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.config-intro p { margin: 0; }
.config-intro a { color: var(--accent-ink); }
.default-model-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--surface-2); }
.default-model-card > div { min-width: 0; }
.default-model-card h2 { margin-bottom: 4px; }
.default-model-card .hint { margin: 0; }
#default-preset { width: min(420px, 52%); min-width: 0; flex: none; }
.quickfill-disclosure { margin-bottom: 18px; padding: 0 0 14px; border-bottom: 1px solid var(--line-2); }
.quickfill-disclosure summary { width: fit-content; color: var(--muted); cursor: pointer; font-size: 12px; }
.quickfill { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.quickfill-label { color: var(--muted); font-size: 11px; }
.chip { color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); }
.chip:hover { color: var(--accent-ink); background: var(--accent-soft); border-color: var(--accent); filter: none; }
.probe-result { align-self: center; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.probe-result.ok, .vgroup-probe.ok, .vmodel-probe.ok { color: var(--success); }
.probe-result.err, .vgroup-probe.err, .vmodel-probe.err { color: var(--danger); }
#provider-groups { display: flex; flex-direction: column; gap: 14px; }
.vgroup { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.vgroup-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 13px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.vgroup-title { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.vgroup-name { color: var(--ink); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.proto-badge { padding: 2px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft); background: var(--surface); font-size: 10px; font-weight: 500; }
.proto-badge.proto-anthropic { color: color-mix(in srgb, #c8743a 42%, var(--ink)); background: color-mix(in srgb, #c8743a 12%, var(--surface)); }
.vgroup-host, .vgroup-key { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.vgroup-host { font-family: ui-monospace, Menlo, monospace; }
.vgroup-ops { display: flex; flex: none; flex-wrap: wrap; gap: 5px; }
.vgroup-ops .mini.accent { color: var(--accent-ink); border-color: var(--line); background: var(--surface); }
.vgroup-probe { padding: 8px 14px; border-bottom: 1px solid var(--line-2); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.vmodels { display: flex; flex-direction: column; }
.vmodel { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.vmodel:last-child { border-bottom: 0; }
.vmodel-main { display: flex; align-items: baseline; flex: 1; flex-wrap: wrap; gap: 7px; min-width: 140px; }
.vmodel-name { color: var(--ink); font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.vmodel-id { padding: 1px 5px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--muted); background: var(--surface-2); font-family: ui-monospace, Menlo, monospace; font-size: 11px; overflow-wrap: anywhere; }
.vmodel-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.default-star { color: var(--accent-ink); font-size: 11px; font-weight: 500; white-space: nowrap; }
.used-tag { padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--muted); background: var(--surface-2); font-size: 10px; white-space: nowrap; }
.vmodel-ops { display: flex; flex-wrap: wrap; gap: 4px; }
.vmodel-probe { flex-basis: 100%; margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.vmodel-empty { margin: 0; padding: 22px 15px; color: var(--muted); font-size: 12px; }
.vmodel-form { padding: 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.vmodel-form-title { margin-bottom: 8px; color: var(--ink-soft); font-size: 12px; font-weight: 500; }
.vmodel-form-row { display: flex; flex-wrap: wrap; gap: 8px; }
.vmodel-form-row input { flex: 1; min-width: 150px; max-width: 100%; }
.vmodel-form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* 列表筛选和表格：横向滚动留在表格内部。 */
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-bar input:is([type="text"], [type="search"]) { flex: 0 1 240px; max-width: 100%; margin: 0; }
.filter-bar select { flex: 0 0 auto; max-width: 100%; }
.filter-bar label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 12px; cursor: pointer; white-space: nowrap; }
.filter-bar .sort-btn { margin-left: auto; }
#user-count { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.table-wrap { max-width: 100%; max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); overscroll-behavior: contain; }
.table-wrap + .form-note { margin-top: 14px; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 12px; }
#usage-table { min-width: 330px; }
#overview-models { min-width: 360px; }
#assign-table { min-width: 420px; table-layout: fixed; }
#assign-table th:first-child { width: 145px; }
#assign-table select { width: 100%; min-width: 0; max-width: 100%; }
#security-table { min-width: 640px; }
#admin-script-table { min-width: 800px; }
#audit-table { min-width: 720px; }
#user-table { min-width: 810px; }
thead th { position: sticky; top: 0; z-index: 1; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); text-align: left; font-size: 11px; font-weight: 500; white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink-soft); line-height: 1.5; vertical-align: middle; }
tbody td:first-child { color: var(--ink); }
tbody td[colspan].hint { padding: 32px 16px; color: var(--muted); text-align: center; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
tbody td a { color: var(--accent-ink); text-decoration: none; }
tbody td a:hover { text-decoration: underline; }
tbody td .hint { margin: 3px 0 0; font-size: 11px; }
.token-cell { font-family: ui-monospace, Menlo, monospace; font-size: 11px; cursor: pointer; color: var(--ink-soft); }
.token-cell:hover { color: var(--accent); }
.disabled-row { background: var(--surface-2); }
body.admin .inline-limit { width: 78px; min-height: 30px; padding: 4px 7px; background: transparent; font-size: 12px; }
body.admin .limit-input:invalid { border-color: var(--danger); }
.quota-cell { display: flex; align-items: center; gap: 7px; }
.quota-used { min-width: 38px; color: var(--muted); font-size: 11px; white-space: nowrap; }
td .mini { margin-right: 4px; white-space: nowrap; }
td .mini:last-child { margin-right: 0; }
#admin-script-table th:last-child, #admin-script-table td:last-child, #user-table th:last-child, #user-table td:last-child { white-space: nowrap; }
.tag-on { color: var(--success); font-weight: 500; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
/* 表格每行的删除按钮平时是灰字,悬停才变红:风险操作靠确认框兜底,不让整列红字刺眼 */
body.admin td button.danger-action { color: var(--muted); }
body.admin td button.danger-action:hover { color: var(--danger); }
.tag-off { color: var(--muted); }
.tag-admin { display: inline-block; margin-left: 5px; padding: 1px 5px; border-radius: 4px; color: var(--accent-ink); background: var(--accent-soft); font-size: 10px; }
.flag-danger { color: var(--danger); font-weight: 500; }
tr.row-danger { background: var(--danger-soft); }
tr.row-danger:hover { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
/* 手机上表格横向滚动时冻结第一列，看得出这一行属于谁;单元格必须给实底色，内容不透出 */
@media (max-width: 760px) {
  .table-wrap :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line-2); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
  .table-wrap thead th:first-child { z-index: 2; background: var(--surface-2); }
  .table-wrap tbody tr:hover td:first-child, .table-wrap .disabled-row td:first-child { background: var(--surface-2); }
  .table-wrap tr.row-danger td:first-child { background: var(--danger-soft); }
}

/* 原生对话框：表单独立滚动，关闭、确认按钮留在视口内。 */
.admin-dialog { width: min(600px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--surface); box-shadow: 0 20px 80px rgba(0, 0, 0, .2); }
.admin-dialog[open] { display: flex; flex-direction: column; }
.admin-dialog::backdrop { background: rgba(28, 23, 16, .4); }
#provider-dialog { width: min(640px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.dialog-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
body.admin .dialog-close { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 22px; line-height: 1; }
body.admin .dialog-close:hover { color: var(--ink); background: var(--surface-2); filter: none; }
.dialog-body { flex: 1; min-height: 0; padding: 20px; overflow-y: auto; overscroll-behavior: contain; }
.dialog-body h3 { margin: 22px 0 7px; font-size: 13px; font-weight: 600; }
.password-field { display: flex; align-items: center; gap: 7px; min-width: 0; }
.password-field input { flex: 1; min-width: 0; }
.password-field button { flex: none; }
.dialog-body > .hint:first-child, .dialog-body > .form-note:first-child { margin-top: 0; margin-bottom: 16px; }
.dialog-body > .hint:last-child { margin-bottom: 0; }
.dialog-body > .grid2 + .grid3, .dialog-body > .grid2 + .grid2 { margin-top: 18px; }
.dialog-body > .grid2 + .hint { margin-top: 14px; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; flex: none; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.dialog-foot .probe-result { flex: 1; }
.dialog-foot-start { margin-right: auto; }
.vmodel-form-actions .form-delete { margin-left: auto; }
#admin-status { position: fixed; bottom: 24px; left: 50%; z-index: 50; max-width: 90vw; transform: translateX(-50%); padding: 10px 16px; border-radius: 8px; color: var(--toast-ink); background: var(--toast-bg); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-size: 12px; }

@media (max-width: 1000px) {
  #admin-nav { width: 178px; padding-inline: 10px; }
  #admin-content { padding-inline: 20px; }
  .grid3 { gap: 12px; }
}
@media (max-width: 760px) {
  #panels { flex-direction: column; }
  #admin-nav { position: sticky; top: 0; z-index: 20; width: 100%; height: auto; overflow: visible; padding: 6px 12px 0; border-right: 0; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  #admin-nav .brand, #admin-nav nav { display: none; }
  .admin-mobile-section { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
  #admin-section-select { width: 100%; min-width: 0; min-height: 44px; background: var(--surface-2); }
  .nav-foot { display: flex; flex-direction: row; align-items: center; justify-content: flex-end; gap: 3px; margin: 0; padding: 0; }
  #admin-who { display: none; }
  .nav-foot a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 6px 7px; white-space: nowrap; }
  #admin-content { padding: 20px 14px 40px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
  .page-title { font-size: 21px; }
  .page-sub { font-size: 12px; margin-top: 6px; }
  .page-actions { margin-left: auto; }
  .card { margin-bottom: 14px; padding: 15px; border-radius: 9px; }
  .card-head { gap: 10px; margin-bottom: 12px; }
  .overview-summary { padding: 0; }
  .overview-grid { gap: 14px; }
  .stats-row { gap: 8px; }
  .stat { padding: 13px 12px; border-radius: 8px; }
  .stat .num { font-size: 23px; }
  .stat .lbl { font-size: 10px; margin-top: 6px; }
  .overview-callout { align-items: flex-start; flex-wrap: wrap; gap: 7px; padding: 12px; }
  .overview-callout a { margin-left: auto; }
  .section-tabs { margin-bottom: 16px; }
  .config-intro { align-items: flex-start; flex-direction: column; gap: 8px; }
  .default-model-card { align-items: stretch; flex-direction: column; gap: 14px; }
  #default-preset { width: 100%; }
  .grid3 { grid-template-columns: 1fr; gap: 14px; }
  .settings-row, .setting-toggle { gap: 18px; }
  .settings-row > :is(input, select) { width: 120px; }
  .save-bar { bottom: 8px; gap: 12px; padding: 10px 12px; }
  .filter-bar input:is([type="text"], [type="search"]) { flex: 1 1 170px; }
  .filter-bar .sort-btn { margin-left: 0; }
  #user-count { margin-left: 0; }
  .table-wrap { max-height: 65dvh; }
  .vgroup-head { align-items: flex-start; flex-direction: column; padding: 12px; }
  .vgroup-ops { width: 100%; }
  .vmodel { padding: 12px; }
  .vmodel-main { min-width: 0; flex-basis: 100%; }
  .vmodel-ops { margin-left: auto; }
  .admin-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 10px; }
  #provider-dialog { width: calc(100vw - 20px); }
  .dialog-head { padding: 12px 15px; }
  .dialog-body { padding: 16px 15px; }
  .dialog-foot { padding: 12px 15px; }
  .dialog-foot .probe-result { flex-basis: 100%; }
  #admin-status { bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; gap: 14px; }
  .settings-row { align-items: stretch; flex-direction: column; gap: 10px; }
  .settings-row > :is(input, select) { width: 100%; }
  .setting-toggle { gap: 12px; }
  .settings-advanced > summary { padding: 14px; }
  .details-body { padding: 15px; }
}
@media (max-width: 380px) {
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #admin-content { padding-inline: 10px; }
  .nav-foot { justify-content: space-between; }
  .nav-foot a { padding-inline: 5px; font-size: 10px; }
  .card { padding: 13px; }
  .overview-summary { padding: 0; }
}
@media (max-width: 760px), (any-pointer: coarse) {
  body.admin input:not([type="checkbox"]):not([type="radio"]), body.admin select, body.admin textarea { min-height: 44px; font-size: 16px; }
  #admin-content button:not(.link), #admin-content button.link, #admin-content button.mini, #admin-content button.chip,
  .admin-dialog button:not(.dialog-close), body.admin .dialog-close, #admin-content .section-tabs :is(button, a) { min-height: 44px; }
  body.admin .dialog-close, #admin-content button.link { min-width: 44px; }
  .filter-bar label, label.hint:has(input[type="checkbox"]), .switch-line, .nav-item, .nav-foot a { min-height: 44px; }
  .quickfill-disclosure summary { min-height: 44px; align-content: center; }
}
@media (max-height: 640px) and (min-width: 761px) {
  #admin-nav { padding-top: 16px; }
  #admin-nav .brand { padding-bottom: 18px; }
  .nav-section-label { margin-top: 14px; }
  .nav-foot { padding-top: 12px; }
  .page-heading { margin-bottom: 18px; }
}

/* 表单错误属于当前编辑器，不被原生 modal 的顶层遮住。 */
.dialog-status { flex-basis: 100%; margin: 0; color: var(--danger); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.admin-empty { padding: 38px 18px; text-align: center; color: var(--muted); }
.admin-empty strong { display: block; color: var(--ink); font-size: 15px; }
.admin-empty p { margin: 9px auto 18px; max-width: 46ch; font-size: 12px; line-height: 1.7; }
.user-role { margin-left: 6px; white-space: nowrap; }

/* 剧本标签列与标签建议表 */
.tags-cell { font-size: 12.5px; white-space: nowrap; }
.tags-cell .mini { margin-left: 4px; }
#tag-sug-table td { font-size: 13px; }

/* 示范朗读 › 预设音色库:男声/女声两组,每行可改名字、备注、男女,可试听、调顺序、移除 */
.voice-library { display: flex; flex-direction: column; gap: 14px; }
.voice-lib-group h3 { margin: 0 0 6px; color: var(--ink); font-size: 13px; font-weight: 600; }
.voice-lib-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.voice-lib-row { display: grid; grid-template-columns: minmax(7em, 11em) minmax(0, 1fr) 5.5em auto; align-items: center; gap: 6px 8px; padding: 6px 10px; border-top: 1px solid var(--line-2); }
.voice-lib-row:first-child { border-top: 0; }
body.admin .voice-lib-row input:not([type="checkbox"]), body.admin .voice-lib-row select { width: 100%; min-width: 0; }
.voice-lib-actions { display: flex; gap: 4px; }
#admin-content .voice-lib-actions button.mini { min-width: 30px; padding: 5px 8px; }
.voice-lib-empty { padding: 10px 12px; color: var(--muted); font-size: 12px; }
.pick-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.pick-field button { width: 100%; }
#tts-voice-name { margin-top: 10px; }
#tts-voice-name:empty { display: none; }

/* 声音挑选窗口(voice-picker.js):上面固定搜索与筛选,下面列表滚动 */
.admin-dialog.voice-picker { width: min(760px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px)); }
.vp-tools { display: flex; flex-direction: column; gap: 10px; flex: none; padding: 14px 20px 12px; border-bottom: 1px solid var(--line-2); }
body.admin .vp-search { width: 100%; }
.vp-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
body.admin .vp-filters select { width: 100%; min-width: 0; }
.vp-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-soft); font-size: 12px; }
.vp-count { color: var(--muted); }
.vp-meta .vp-reset { margin-left: auto; }
.vp-body { padding: 0; }
.vp-list { margin: 0; padding: 0; list-style: none; }
.vp-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; padding: 10px 20px; border-bottom: 1px solid var(--line-2); }
.vp-name { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: var(--ink); font-size: 13px; }
.vp-name .badge { padding: 1px 7px; font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); }
.vp-traits { margin-top: 2px; color: var(--ink-soft); font-size: 12px; }
.vp-desc { display: -webkit-box; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.vp-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.admin-dialog.voice-picker button.mini { min-height: 30px; padding: 5px 10px; font-size: 11px; }
.vp-empty, .vp-more { margin: 0; padding: 18px 20px; color: var(--muted); font-size: 12px; }
.vp-status { min-width: 0; margin: 0; }
@media (max-width: 560px) {
  .admin-dialog.voice-picker { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
  .vp-tools { padding: 12px 14px; }
  .vp-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vp-row { grid-template-columns: minmax(0, 1fr); padding: 10px 14px; }
  .vp-actions { justify-content: flex-start; }
}
@media (max-width: 760px), (any-pointer: coarse) {
  .admin-dialog.voice-picker button.mini { min-height: 44px; }
}
@media (max-width: 760px) {
  .voice-lib-row { grid-template-columns: minmax(0, 1fr) 5.5em; }
  .voice-lib-note, .voice-lib-actions { grid-column: 1 / -1; }
}
@media (max-width: 760px), (any-pointer: coarse) { #admin-content .voice-lib-actions button.mini { min-width: 44px; } }
