/* ================= 账户中心与管理后台页面样式 ================= */

body {
  min-width: 320px;
  background: var(--ground, #fefefe);
}

.admin-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 0;
  height: 2px;
  background: #8dd7b0;
  opacity: 0;
  pointer-events: none;
  transition: width 0.5s ease;
}
.admin-loading-bar:not(.is-active):not(.is-complete) {
  transition: none;
}
.admin-loading-bar.is-active {
  opacity: 1;
}
.admin-loading-bar.is-complete {
  opacity: 0;
  transition: width 0.5s ease, opacity 0.3s ease 1s;
}
@media (prefers-reduced-motion: reduce) {
  .admin-loading-bar { transition: none; }
}

#admin-app {
  display: flex;
  height: 100vh;
  background: var(--ground, #fefefe);
}

/* ---- 左侧导航 ---- */
#admin-nav {
  width: 240px;
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px 12px;
  overflow-y: auto;
}

#back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  height: 32px;
  margin: 12px 0 10px;
  padding: 0 4px;
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  font-size: 14px;
  text-decoration: none;
}
#back-link svg {
  width: 18px;
  height: 18px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-title {
  padding: 16px 10px 4px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
  user-select: none;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text, rgba(0, 0, 0, 0.9));
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: rgba(0, 0, 0, 0.75);
}
.nav-item:hover {
  background: var(--sb-hover, rgba(0, 0, 0, 0.04));
}
.nav-item.active {
  background: var(--sb-active, rgba(0, 0, 0, 0.06));
  font-weight: 500;
}

/* ---- 主区：白色圆角卡片 ---- */
#admin-main {
  flex: 1;
  min-width: 0;
  margin: 8px 8px 8px 0;
  padding: 48px 32px 72px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  background: #fff;
}

.admin-page {
  display: none;
  width: min(100%, 780px);
  margin: 0 auto;
}
.admin-page.wide {
  width: min(100%, 1350px);
}
.admin-page.active {
  display: block;
  animation: page-in 0.2s ease both;
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-title {
  margin: 0 0 24px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--text, rgba(0, 0, 0, 0.9));
}
.title-hint {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.section-caption {
  margin: 28px 0 8px;
  padding: 0 4px;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.page-title + .section-caption {
  margin-top: 0;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
}
.page-head .page-title {
  margin: 0;
}

/* ---- 账号头部：大头像 + 名称 + 黑色角色徽章 ---- */
.account-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  text-align: center;
}
.account-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}
.account-name {
  margin-top: 4px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--text, rgba(0, 0, 0, 0.9));
}

.role-badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.role-badge.owner { background: #111; color: #fff; }
.role-badge.admin { background: rgba(23, 131, 255, 0.1); color: var(--link, #1783ff); }

/* ---- 灰色分组卡片 ---- */
.group-card {
  padding: 0 16px;
  border-radius: 12px;
  background: var(--admin-card, #f7f7f7);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 10px 0;
  font-size: 14px;
}
.row + .row {
  border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
}
label.row { cursor: pointer; }
.row-label { color: var(--text, rgba(0, 0, 0, 0.9)); }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-desc { font-size: 12px; line-height: 18px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.row-value { display: inline-flex; align-items: center; gap: 6px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); text-align: right; }
.row-right { display: inline-flex; align-items: center; gap: 14px; }
.row-control { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.row-link { color: var(--link, #1783ff); font-size: 14px; text-decoration: none; white-space: nowrap; }
.row-link:hover { text-decoration: none; }
button.row-link { background: none; border: none; padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
button.row-link:hover { text-decoration: none; }
.unit { min-width: 44px; font-size: 13px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.num { font-variant-numeric: tabular-nums; }

.wide-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  margin-top: 32px;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--admin-card, #f7f7f7);
  color: var(--text, rgba(0, 0, 0, 0.9));
  font-size: 14px;
  cursor: pointer;
}
.wide-btn:hover { background: #efefef; }
.wide-btn.primary { background: #111; color: #fff; }
.wide-btn.primary:hover { background: #000; }

/* ---- 账单与用量 ---- */
.points-summary { padding: 20px 20px 18px; }
.summary-label { font-size: 13px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.points-big {
  margin-top: 8px;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text, rgba(0, 0, 0, 0.9));
}
.points-big.negative { color: var(--danger, #FF3849); }

.ledger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px 0;
}
.ledger-row + .ledger-row { border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06)); }
.ledger-type { font-size: 14px; color: var(--text, rgba(0, 0, 0, 0.9)); }
.ledger-meta { margin-top: 3px; font-size: 12px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.ledger-change { flex-shrink: 0; font-size: 14px; font-weight: 500; }
.ledger-hint { margin: 10px 4px 0; line-height: 1.6; }
.empty-tip { padding: 28px 0; text-align: center; font-size: 14px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }

/* ---- 兑换码 ---- */
.face-zero { color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.cell-sub { margin-top: 2px; font-size: 12px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.time-cell { font-variant-numeric: tabular-nums; color: var(--text-dim, rgba(0, 0, 0, 0.6)); }

.redeem-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.05);
}

.red-item { display: flex; gap: 12px; padding: 12px 0; }
.red-item + .red-item { border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06)); }
.red-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; color: rgba(0, 0, 0, 0.75); }
.red-main { min-width: 0; }
.red-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.red-chip {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.red-meta { margin-top: 6px; font-size: 12px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.redeem-control { display: inline-flex; align-items: center; gap: 8px; }
.redeem-control input {
  width: 230px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  transition: border-color 0.15s;
}
.redeem-control input:focus { border-color: rgba(0, 0, 0, 0.16); }

.quota-strip {
  display: flex;
  gap: 32px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
}
.quota-item { display: flex; align-items: baseline; gap: 8px; }
.quota-label { font-size: 12px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.quota-value { font-size: 13px; color: var(--text-dim, rgba(0, 0, 0, 0.6)); }

/* 筛选栏与表单控件 */
.usage-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -8px 0 16px;
}
.settings-number, .model-form input[type="text"], .model-form input[type="number"] {
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  background: #f2f2f2;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, background-color 0.15s;
}
.settings-number:focus, .model-form input:focus { border-color: rgba(0, 0, 0, 0.16); background: #fff; }
.group-card .settings-number { width: 110px; background: #fff; text-align: right; }
.group-card .settings-text { width: 220px; text-align: left; }
.mail-domain-row > .row-text { flex: 0 0 auto; }
.mail-domain-editor {
  display: flex;
  flex: 0 1 340px;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s;
}
.mail-domain-editor:focus-within { border-color: rgba(0, 0, 0, 0.16); }
.mail-domain-tags { display: contents; }
.mail-domain-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px 4px 10px;
  border-radius: 5px;
  background: #f2f2f2;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font-size: 13px;
  line-height: 20px;
}
.mail-domain-tag > span { min-width: 0; overflow-wrap: anywhere; }
.mail-domain-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
  font: inherit;
  cursor: pointer;
}
.mail-domain-remove:hover { background: #e5e5e5; color: var(--text, #111); }
.mail-domain-remove:focus-visible { outline: 2px solid rgba(23, 131, 255, 0.4); outline-offset: 1px; }
.mail-domain-remove:disabled { opacity: 0.5; cursor: default; }
.mail-domain-input {
  flex: 1 1 130px;
  min-width: 0;
  width: 130px;
  height: 28px;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
}
.mail-domain-input::placeholder { color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.admin-page.is-loading .mail-domain-editor { background: rgba(0, 0, 0, 0.05); pointer-events: none; }
.admin-page.is-loading .mail-domain-editor > * { visibility: hidden; }
@media (max-width: 520px) {
  .mail-domain-row > .mail-domain-editor { flex-basis: 100%; }
}
.usage-sep { font-size: 14px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }

.model-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--admin-card, #f7f7f7);
}
.model-form input[type="text"], .model-form input[type="number"] { background: #fff; }
.model-form input[type="text"] { width: 260px; }
.model-form input[type="number"] { width: 100px; }
.model-enabled { display: inline-flex; align-items: center; gap: 8px; margin: 0 6px; font-size: 14px; color: var(--text-dim, rgba(0, 0, 0, 0.6)); cursor: pointer; }

/* ---- 模型配置：Provider 与模型的行列表 ---- */
.mc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 8px;
}
.mc-section-head .section-caption {
  margin: 0;
  padding: 0 4px;
}
.mc-list {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  scrollbar-gutter: stable;
  transition: opacity 0.15s;
}
.mc-list.fetching {
  opacity: 0.6;
  pointer-events: none;
}
.mc-row,
.mc-sk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 16px;
}
.mc-row + .mc-row,
.mc-sk-row + .mc-sk-row {
  border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
}
.mc-provider {
  cursor: pointer;
  transition: background-color 0.15s;
}
.mc-provider:hover {
  background: rgba(0, 0, 0, 0.02);
}
.mc-row-main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}
.mc-row-title {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  color: var(--text, rgba(0, 0, 0, 0.9));
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-row-title .badge {
  vertical-align: 1px;
  margin-left: 6px;
}
.mc-row-sub {
  overflow: hidden;
  font-size: 12px;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}
.mc-chip {
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.mc-row-meta {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.mc-row-acts {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.mc-go.icon {
  width: 16px;
  height: 16px;
}
.mc-go {
  flex-shrink: 0;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.mc-sw {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  cursor: pointer;
}
.mc-empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.mc-count {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 12px;
  line-height: 18px;
}
.mc-count:empty {
  display: none;
}

/* 二级页头部与工具行 */
.mc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
}
.mc-head .page-title {
  margin: 0;
}
.mc-head .icon-btn .icon {
  width: 20px;
  height: 20px;
}
.mc-head-url {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mc-tools {
  justify-content: space-between;
}
.mc-search {
  width: 260px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  background: #f2f2f2;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, background-color 0.15s;
}
.mc-search:focus {
  border-color: rgba(0, 0, 0, 0.16);
  background: #fff;
}
.mc-tools-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.mc-fetch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #f2f2f2;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.mc-fetch-btn:hover:not(:disabled) {
  background: #ebebeb;
}
.mc-fetch-btn:active:not(:disabled) {
  background: #e2e2e2;
}
.mc-fetch-btn:focus-visible {
  outline: 2px solid rgba(23, 131, 255, 0.4);
  outline-offset: 1px;
}
.mc-fetch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.mc-fetch-btn .icon {
  width: 15px;
  height: 15px;
}
.mc-custom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  background: #f2f2f2;
  color: var(--text, rgba(0, 0, 0, 0.9));
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.mc-custom-btn:hover {
  background: #ebebeb;
}
.mc-custom-btn:active {
  background: #e2e2e2;
}
.mc-custom-btn:focus-visible {
  outline: 2px solid rgba(23, 131, 255, 0.4);
  outline-offset: 1px;
}
.mc-custom-btn.primary {
  background: #111;
  color: #fff;
}
.mc-custom-btn.primary:hover {
  background: #000;
}
.mc-custom-btn.primary:active {
  background: #1a1a1a;
}

/* 模型弹窗 */
.ui-dialog-box.mc-model-dlg {
  width: min(580px, 100%);
}
.md-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}
.md-grid-2:first-of-type {
  margin-top: 18px;
}
.md-grid-2 .ui-field {
  margin-top: 0;
}
.md-static {
  display: flex;
  align-items: center;
  height: 40px;
  box-sizing: border-box;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--admin-card, #f7f7f7);
  font-size: 14px;
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text, rgba(0, 0, 0, 0.9));
  cursor: pointer;
}
.mc-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
}
.mc-dialog-footer .md-switch-row {
  margin: 0;
  user-select: none;
}
.mc-dialog-footer .ui-dialog-actions {
  margin-top: 0;
  gap: 10px;
}

.settings-hint { font-size: 12px; color: var(--text-faint, rgba(0, 0, 0, 0.45)); }
.settings-actions { position: relative; }
.search-settings-fields { margin: 0; padding: 0; border: 0; min-width: 0; }
.search-settings-fields > .section-caption:first-child { margin-top: 0; }
.search-settings-fields:disabled { opacity: 0.6; }
#search-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* 存储页：存储类型为本地时隐藏 OSS 配置行 */
.admin-page.oss-hidden .oss-row { display: none; }
.settings-tip {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  text-align: center;
  font-size: 13px;
  color: var(--admin-green, #2fb36d);
}

/* 开关控件 */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: background-color 0.18s;
}
input.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s;
}
input.switch:checked { background: #111; }
input.switch:checked::before { transform: translateX(16px); }
input.switch:focus-visible { outline: 2px solid rgba(23, 131, 255, 0.4); outline-offset: 2px; }

.quota-inherit { color: var(--text-faint, rgba(0, 0, 0, 0.45)); }

.ref-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
}

#failure-filter .settings-number { width: min(220px, 100%); }
#failure-table { width: 100%; min-width: 0; table-layout: fixed; }
.failure-col-time, .failure-col-user { width: 18%; }
.failure-col-points, .failure-col-status { width: 12%; }
.failure-col-actions { width: 130px; }
#failure-table .failure-time { font-variant-numeric: tabular-nums; }
#failure-table .admin-btn { height: 28px; }
#failure-table .admin-btn + .admin-btn { margin-left: 10px; }
#failure-table .admin-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#failure-pager { flex-wrap: wrap; gap: 8px; }
.admin-page[data-page="failure-events"] .admin-btn:focus-visible { outline: 2px solid rgba(23, 131, 255, 0.4); outline-offset: 1px; }
.failure-detail { position: fixed; inset: 0; box-sizing: border-box; width: min(860px, calc(100vw - 32px)); max-width: none; max-height: min(84vh, 900px); margin: auto; padding: 0; border: 0; border-radius: 16px; background: #fff; color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14); outline: none; overflow: hidden; }
.failure-detail[open] { display: flex; flex-direction: column; }
.failure-detail::backdrop { background: rgba(0, 0, 0, 0.32); }
.failure-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: none; padding: 20px 24px; border-bottom: 1px solid var(--admin-border, rgba(0, 0, 0, 0.08)); }
#failure-detail-body { min-height: 0; padding: 24px; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 820px) {
  #failure-table { min-width: 700px; }
  #failure-table th:last-child, #failure-table .failure-actions { position: sticky; right: 0; background: var(--bg, #fff); }
}
@media (max-width: 480px) {
  .failure-detail { width: calc(100vw - 16px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .failure-detail-head { padding: 14px 16px; }
  #failure-detail-body { padding: 16px; }
}
.failure-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 16px 24px; margin: 0; padding: 20px; background: var(--admin-card, #f7f7f7); border-radius: 12px; }
.failure-meta > div { min-width: 0; }
.failure-meta dt { font-size: 12px; color: var(--text-faint); }
.failure-meta dd { margin: 5px 0 0; font-size: 14px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.failure-text, .failure-payload pre { margin: 0; padding: 14px 16px; border-radius: 10px; background: var(--admin-card, #f7f7f7); font-size: 13px; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.failure-payload { min-width: 0; margin-top: 18px; }
.failure-payload summary { padding: 8px 4px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.failure-payload pre { max-height: 420px; overflow-y: auto; }
.failure-detail-sk { display: block; width: 100%; height: 48px; margin: 12px 0; border-radius: 10px; }
.failure-error { font-size: 14px; color: var(--danger); overflow-wrap: anywhere; }

/* 系统设置加载中：输入框呈骨架态（无文字、脉动、不可编辑） */
.admin-page.is-loading .settings-number,
.admin-page.is-loading .settings-text,
.admin-page.is-loading input.switch {
  color: transparent;
  background: rgba(0, 0, 0, 0.05);
  pointer-events: none;
}
.admin-page.is-loading input.switch::before {
  opacity: 0;
}

.group-card .settings-number:focus { border-color: rgba(0, 0, 0, 0.16); }

/* ---- 我的知识库 ---- */
.knowledge-page { width: min(100%, 1120px); }
.knowledge-head { margin-bottom: 20px; }
.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  grid-template-areas: "main toc";
  align-items: stretch;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  background: var(--bg, #fff);
  overflow: hidden;
}
.knowledge-layout.no-toc { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
.knowledge-main { grid-area: main; min-width: 0; }
.knowledge-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface, #f5f5f5);
}
.knowledge-tab {
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  font-size: 14px;
  cursor: pointer;
}
.knowledge-tab:hover:not(:disabled) { background: var(--hover-bg, rgba(0, 0, 0, 0.04)); }
.knowledge-tab.active {
  background: var(--bg, #fff);
  color: var(--text, rgba(0, 0, 0, 0.9));
  font-weight: 500;
}
.knowledge-tab:disabled { cursor: default; }
.knowledge-content {
  min-height: 240px;
  max-height: 720px;
  padding: 28px;
  background: var(--bg, #fff);
  overflow-y: auto;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}
.knowledge-content :is(h1, h2, h3, h4) { scroll-margin-top: 24px; }
.knowledge-skeleton { display: flex; flex-direction: column; gap: 18px; }
.knowledge-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  text-align: center;
}
.knowledge-toc {
  grid-area: toc;
  max-height: 720px;
  padding: 20px 16px;
  border-left: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
  background: var(--admin-card, #f7f7f7);
  overflow-y: auto;
  font-size: 13px;
}
.knowledge-toc nav { margin-top: 4px; }
.knowledge-toc-root,
.knowledge-toc-children { margin: 0; padding: 0; list-style: none; }
.knowledge-toc-children { margin-left: 11px; }
.knowledge-toc-item { min-width: 0; }
.knowledge-toc-row {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 32px;
  border-radius: 6px;
}
.knowledge-toc-row:hover { background: var(--hover-bg, rgba(0, 0, 0, 0.04)); }
.knowledge-toc-row.active { background: var(--sb-active, rgba(0, 0, 0, 0.06)); }
.knowledge-toc-toggle,
.knowledge-toc-spacer { width: 22px; height: 32px; flex: 0 0 22px; }
.knowledge-toc-toggle {
  position: relative;
  padding: 0;
  color: var(--text-faint, rgba(0, 0, 0, 0.45));
}
.knowledge-toc-toggle::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 12px;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.knowledge-toc-parent[aria-expanded="false"] .knowledge-toc-toggle::before { transform: rotate(-45deg); }
.knowledge-toc-link {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  color: var(--text-dim, rgba(0, 0, 0, 0.6));
  line-height: 20px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
button.knowledge-toc-parent {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}
button.knowledge-toc-parent:hover { background: transparent; }
.knowledge-toc-label {
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
}
.knowledge-toc-link:hover,
.knowledge-toc-link.active { color: var(--text, rgba(0, 0, 0, 0.9)); }
.knowledge-toc-link.active { font-weight: 500; }

@media (max-width: 1100px) {
  .knowledge-page { width: min(100%, 780px); }
  .knowledge-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toc" "main"; }
  .knowledge-layout.no-toc { grid-template-areas: "main"; }
  .knowledge-toc {
    max-height: none;
    padding: 12px 16px;
    border-left: 0;
    border-bottom: 1px solid var(--admin-line, rgba(0, 0, 0, 0.06));
  }
  .knowledge-content { padding: 24px 20px; }
}

/* ---- 滚动条：与主站一致，悬停浮现 ---- */
#admin-main::-webkit-scrollbar, .table-card::-webkit-scrollbar, .mc-list::-webkit-scrollbar { width: 8px; height: 8px; }
#admin-main::-webkit-scrollbar-thumb, .table-card::-webkit-scrollbar-thumb, .mc-list::-webkit-scrollbar-thumb {
  min-height: 60px;
  min-width: 60px;
  background: transparent;
  border-radius: 999px;
}
#admin-main:hover::-webkit-scrollbar-thumb, .table-card:hover::-webkit-scrollbar-thumb, .mc-list:hover::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb, #c8c8c8); }
#admin-main::-webkit-scrollbar-thumb:hover, .table-card::-webkit-scrollbar-thumb:hover, .mc-list::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover, #a8a8a8); }

@media (max-width: 820px) {
  #admin-app { flex-direction: column; height: auto; min-height: 100vh; }
  #admin-nav {
    width: 100%;
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  #back-link { margin: 0 4px 0 0; flex-shrink: 0; }
  .nav-group { flex-direction: row; gap: 4px; }
  .nav-group-title { display: none; }
  .nav-item { height: 36px; white-space: nowrap; }
  #admin-main { flex: 1; margin: 0; padding: 28px 16px 56px; overflow: visible; border: none; border-radius: 16px 16px 0 0; }
}

@media (max-width: 520px) {
  .row { flex-wrap: wrap; }
  .group-card .settings-number { width: 96px; }
  .points-big { font-size: 28px; }
  .md-grid-2 { grid-template-columns: 1fr; gap: 14px; }
}
