/* 翰渊后台管理样式：复用站点色板，风格与官网保持一致 */
.admin-body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
}

/* 关键：.admin-gate / .admin-shell 自带 display，会盖过 HTML 的 hidden 属性，
   导致 JS 里 `gate.hidden = true` 之后登录卡片依然可见（表现为“登录成功但界面不切换”）。
   用 !important 强制 hidden 优先，任何 display 声明都不能再覆盖它。 */
[hidden] {
  display: none !important;
}

.admin-gate {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}

.admin-card {
  width: min(420px, 100%);
  padding: 34px 30px 26px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(120, 247, 197, 0.08);
}

.admin-brand-mark img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.admin-brand strong {
  display: block;
  font-size: 17px;
  letter-spacing: 0.06em;
}

.admin-brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.admin-card h1 {
  margin: 26px 0 6px;
  font-size: 22px;
}

.admin-hint {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.admin-field {
  display: block;
  margin-bottom: 16px;
}

.admin-field span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted-bright);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.admin-field input,
.admin-search,
.admin-table select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: rgba(6, 9, 10, 0.72);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.admin-field input:focus,
.admin-search:focus,
.admin-table select:focus {
  border-color: var(--mint-strong);
  box-shadow: 0 0 0 3px rgba(70, 223, 167, 0.14);
}

.admin-primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 0;
  border-radius: 11px;
  color: #06231a;
  background: linear-gradient(135deg, var(--mint), var(--mint-strong));
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.16s ease;
}

.admin-primary:hover {
  filter: brightness(1.06);
}

.admin-primary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.admin-foot {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.admin-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 142, 120, 0.4);
  border-radius: 10px;
  color: #ffd9d0;
  background: rgba(255, 142, 120, 0.12);
  font-size: 13px;
  line-height: 1.5;
}

.admin-error-wide {
  margin: 0 0 18px;
}

.admin-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(20px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 12, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-who {
  color: var(--muted-bright);
  font-size: 13px;
}

.admin-ghost {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.admin-ghost:hover {
  border-color: var(--mint-strong);
  background: rgba(120, 247, 197, 0.08);
}

.admin-main {
  width: min(1280px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 30px 0 70px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.admin-stat {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.admin-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.admin-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  font-weight: 700;
}

.admin-stat.accent strong {
  color: var(--mint);
}

.admin-block {
  margin-bottom: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.admin-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-block-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.03em;
}

.admin-search {
  width: min(280px, 45vw);
  padding: 9px 12px;
  font-size: 13px;
}

/* 头部右侧：搜索框 + 创建账号按钮 */
.admin-block-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 小号主按钮：用于区块内联（创建账号 / 提交），覆盖 .admin-primary 的整宽与上边距 */
.admin-primary-sm {
  width: auto;
  margin-top: 0;
  padding: 9px 16px;
  font-size: 13px;
  white-space: nowrap;
}

/* 创建账号表单：默认靠 [hidden] 隐藏，这里只负责展开后的外观 */
.admin-create {
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgba(6, 9, 10, 0.5);
}

.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 12px;
}

.admin-create-grid .admin-field input,
.admin-create-grid .admin-field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: rgba(6, 9, 10, 0.72);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.admin-create-grid .admin-field input:focus,
.admin-create-grid .admin-field select:focus {
  border-color: var(--mint-strong);
  box-shadow: 0 0 0 3px rgba(70, 223, 167, 0.14);
}

.admin-create-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 成功提示 */
.admin-ok {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(70, 223, 167, 0.4);
  border-radius: 10px;
  color: #c8ffe9;
  background: rgba(70, 223, 167, 0.12);
  font-size: 13px;
  line-height: 1.5;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  table-layout: auto;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

/* 让角色列有稳定宽度，避免下拉框把其他列挤成省略 */
.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
  min-width: 132px;
}

.admin-table th:nth-child(4),
.admin-table td:nth-child(4) {
  min-width: 84px;
  text-align: center;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.admin-table select {
  width: auto;
  padding: 6px 9px;
  font-size: 13px;
}

.admin-actions-col {
  text-align: right;
}

/* 操作列固定在右侧，窄屏横向滚动时按钮始终可见 */
.admin-table th:last-child,
.admin-table td:last-child {
  position: sticky;
  right: 0;
  background: var(--panel-solid);
  box-shadow: -12px 0 18px -14px rgba(0, 0, 0, 0.85);
}

.admin-table thead th:last-child {
  background: var(--panel-solid);
}

.admin-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-row-actions button {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted-bright);
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease;
}

.admin-row-actions button:hover {
  border-color: var(--mint-strong);
  color: var(--text);
}

.admin-row-actions button.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.admin-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.6;
}

.admin-badge.admin {
  color: #06231a;
  background: var(--mint);
}

.admin-badge.user {
  color: var(--muted-bright);
  background: rgba(255, 255, 255, 0.08);
}
/* 生成服务面板：让管理员一眼看到「现在走本地还是走云端」。 */
.admin-muted {
  color: var(--muted);
  font-size: 12px;
}

.admin-gen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.admin-gen-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.admin-gen-card-wide {
  grid-column: 1 / -1;
}

.admin-gen-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.admin-gen-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.admin-gen-card dl {
  margin: 0;
  display: grid;
  gap: 4px;
}

.admin-gen-card dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
}

.admin-gen-card dl > div:last-child {
  border-bottom: 0;
}

.admin-gen-card dt {
  flex: none;
  color: var(--muted);
}

.admin-gen-card dd {
  margin: 0;
  text-align: right;
  color: var(--text);
  word-break: break-word;
}

.admin-badge-ok {
  color: var(--mint);
  background: rgba(120, 247, 197, 0.12);
}

.admin-badge-warn {
  color: var(--gold);
  background: rgba(255, 207, 120, 0.12);
}

.admin-badge-bad {
  color: var(--danger);
  background: rgba(255, 142, 120, 0.12);
}

.admin-empty {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.admin-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
  margin: 0;
}

.admin-kv div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.admin-kv dt {
  color: var(--muted);
}

.admin-kv dd {
  margin: 0;
  color: var(--muted-bright);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-block-head {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-block-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-search {
    width: 100%;
  }

  .admin-create-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------------------------------------------------------------------------
   明亮模式：覆盖 admin.css 里为暗色写死的底色/描边。
   变量部分由 styles.css 的 [data-theme="light"] 统一接管。
   --------------------------------------------------------------------------- */
[data-theme="light"] .admin-field input,
[data-theme="light"] .admin-search,
[data-theme="light"] .admin-table select,
[data-theme="light"] .admin-create-grid .admin-field input,
[data-theme="light"] .admin-create-grid .admin-field select {
  background: rgba(255, 255, 255, 0.94);
}

[data-theme="light"] .admin-header {
  background: rgba(255, 255, 255, 0.86);
}

[data-theme="light"] .admin-create {
  background: rgba(14, 38, 30, 0.035);
}

[data-theme="light"] .admin-table tbody tr:hover {
  background: rgba(14, 38, 30, 0.04);
}

[data-theme="light"] .admin-table th:last-child,
[data-theme="light"] .admin-table td:last-child {
  box-shadow: -12px 0 18px -14px rgba(16, 35, 28, 0.22);
}

[data-theme="light"] .admin-ghost:hover {
  background: rgba(15, 157, 107, 0.1);
}

[data-theme="light"] .admin-badge.user {
  background: rgba(14, 38, 30, 0.07);
}

[data-theme="light"] .admin-error {
  border-color: rgba(194, 73, 47, 0.3);
  color: #8f2f1c;
  background: rgba(194, 73, 47, 0.1);
}

[data-theme="light"] .admin-ok {
  border-color: rgba(15, 157, 107, 0.3);
  color: #0b6b46;
  background: rgba(15, 157, 107, 0.1);
}

[data-theme="light"] .admin-badge-ok {
  background: rgba(15, 157, 107, 0.12);
}

[data-theme="light"] .admin-badge-warn {
  background: rgba(169, 118, 26, 0.14);
}

[data-theme="light"] .admin-badge-bad {
  background: rgba(194, 73, 47, 0.12);
}

/* 主题切换按钮：登录页和后台面板共用同一套样式。 */
.admin-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.admin-gate .admin-theme-toggle {
  position: absolute;
  top: 22px;
  right: 22px;
}
/* HANYUAN SHARED DESIGN — generated from design/tokens.css */
/* HanYuan design tokens — shared by the site, desktop workbench and connector. */
:root{color-scheme:light;--hy-bg:#ffffff;--hy-surface:#ffffff;--hy-surface-soft:#f5f7fb;--hy-ink:#101318;--hy-muted:#667085;--hy-faint:#8b95a7;--hy-line:#e4e8f0;--hy-line-strong:#cbd3e1;--hy-blue:#2563eb;--hy-blue-hover:#1d4ed8;--hy-blue-soft:#edf3ff;--hy-on-blue:#ffffff;--hy-danger:#d92d20;--hy-warning:#a56a12;--hy-radius:18px;--hy-radius-control:11px;--hy-shadow:0 18px 55px #142a4a0d;--hy-fast:160ms;--hy-normal:320ms;--hy-morph:560ms;--hy-ease:cubic-bezier(.22,1,.36,1);--hy-exit:cubic-bezier(.4,0,1,1)}
.dark,[data-theme=dark]{color-scheme:dark;--hy-bg:#101217;--hy-surface:#171c25;--hy-surface-soft:#1e2430;--hy-ink:#f4f6fa;--hy-muted:#a0aabd;--hy-faint:#707d94;--hy-line:#2a3445;--hy-line-strong:#43516a;--hy-blue:#78a3ff;--hy-blue-hover:#98b9ff;--hy-blue-soft:#1e2f50;--hy-danger:#ff867d;--hy-warning:#e7b568;--hy-shadow:0 18px 55px #0003}
button,a[role=button],input,textarea,select{transition-property:color,background-color,border-color,box-shadow,opacity,scale;transition-duration:var(--hy-fast);transition-timing-function:var(--hy-ease)}
button:not(:disabled):not([aria-disabled=true]):hover,a[role=button]:hover{scale:1.025}button:not(:disabled):not([aria-disabled=true]):active,a[role=button]:active{scale:.965}
button:focus-visible,a:focus-visible{outline:3px solid color-mix(in srgb,var(--hy-blue) 35%,transparent);outline-offset:3px}
:is([data-slot=dialog-content],[data-slot=popover-content],[data-slot=dropdown-menu-content],[data-slot=select-content],[data-slot=sheet-content]){animation-duration:var(--hy-normal)!important;animation-timing-function:var(--hy-ease)!important;border-radius:var(--hy-radius);box-shadow:var(--hy-shadow)}
:is([data-slot=dialog-content],[data-slot=popover-content],[data-slot=dropdown-menu-content],[data-slot=select-content],[data-slot=sheet-content])[data-closed]{animation-duration:180ms!important;animation-timing-function:var(--hy-exit)!important}
[data-slot=tooltip-content]{animation-duration:160ms!important;animation-timing-function:var(--hy-ease)!important}
@keyframes hy-enter{from{opacity:0;translate:0 8px}to{opacity:1;translate:0 0}}@keyframes hy-exit{from{opacity:1;translate:0 0}to{opacity:0;translate:0 -5px}}
@keyframes hy-theme{from{clip-path:circle(0 at var(--hy-theme-x,90%) var(--hy-theme-y,35px))}to{clip-path:circle(150vmax at var(--hy-theme-x,90%) var(--hy-theme-y,35px))}}
::view-transition-group(*){animation-duration:var(--hy-morph);animation-timing-function:var(--hy-ease)}::view-transition-old(root){animation:hy-exit 180ms var(--hy-exit) both}::view-transition-new(root){animation:hy-enter 340ms var(--hy-ease) both}.hy-theme-transition::view-transition-old(root){animation:none}.hy-theme-transition::view-transition-new(root){animation:hy-theme 600ms var(--hy-ease) both}
::view-transition-old(hy-workspace-header),::view-transition-new(hy-workspace-header){animation:none;height:100%;mix-blend-mode:normal}::view-transition-old(hy-active-tab),::view-transition-new(hy-active-tab){height:100%}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}::view-transition-group(*){animation-duration:.01ms!important}}

.admin-primary,[data-theme=light] .admin-primary{background:#2563eb;border-color:#2563eb;color:#fff}.admin-primary:hover{background:#1d4ed8}.admin-card,.admin-section,.admin-stat{background:var(--bg);border-color:var(--line);border-radius:var(--hy-radius);box-shadow:var(--hy-shadow)}[data-theme=light] .admin-ghost:hover,[data-theme=light] .admin-ok,[data-theme=light] .admin-badge-ok{background:var(--accent-soft);color:var(--accent);border-color:var(--line)}.admin-card{animation:hy-enter 420ms var(--hy-ease)}.admin-field input{border-radius:var(--hy-radius-control)}

/* API credentials use the shared white / black / blue design tokens. */
.admin-api-grid{display:grid;grid-template-columns:minmax(220px,.85fr) minmax(0,1.4fr);gap:24px}
.admin-api-hint{margin:8px 0 16px;color:var(--hy-muted);font-size:13px;line-height:1.7;overflow-wrap:anywhere}
.admin-api .admin-field input,.admin-api .admin-field select{width:100%;min-width:0;box-sizing:border-box;padding:11px 13px;border:1px solid var(--hy-line-strong);border-radius:var(--hy-radius-control);font:inherit;color:var(--hy-ink);background:var(--hy-surface);outline:none}
.admin-api .admin-field input:focus,.admin-api .admin-field select:focus{border-color:var(--hy-blue);box-shadow:0 0 0 3px var(--hy-blue-soft)}
.admin-api-setup,.admin-api-credential{min-width:0}
.admin-api-credential{padding:20px;border:1px solid var(--hy-line);border-radius:var(--hy-radius);background:var(--hy-surface-soft)}
.admin-api-meta{margin:0 0 18px;display:grid;gap:10px;font-size:13px}
.admin-api-meta>div{display:grid;grid-template-columns:70px minmax(0,1fr);gap:12px}
.admin-api-meta dt{color:var(--hy-muted)}.admin-api-meta dd{margin:0;overflow-wrap:anywhere}
.admin-api #apiTokenValue{font-family:ui-monospace,Consolas,monospace;letter-spacing:.025em}
.admin-api-actions{display:flex;flex-wrap:wrap;gap:8px}
.admin-api-actions button,.admin-api-form button{width:auto;margin:0;display:inline-flex;align-items:center;justify-content:center;gap:7px}
.admin-api-form{padding:0 0 18px;margin:0 0 20px;border-bottom:1px solid var(--hy-line);animation:hy-enter var(--hy-normal) var(--hy-ease)}
.admin-api code{font-size:12px;overflow-wrap:anywhere}
.admin-api button:disabled{opacity:.5;cursor:not-allowed}
.admin-api #apiTokenError,.admin-api #apiTokenStatus{margin:16px 0 0;animation:hy-enter var(--hy-fast) var(--hy-ease)}
.admin-api .admin-block-head a{flex-shrink:0;text-decoration:none;align-self:flex-start}
.admin-copy-buffer{position:fixed;left:-10000px;top:0;width:1px;height:1px;opacity:0;pointer-events:none}
@media(max-width:760px){.admin-api-grid{grid-template-columns:minmax(0,1fr);gap:20px}.admin-api-credential{padding:16px}}
@media(max-width:640px){.admin-header-right{width:100%;flex-wrap:wrap}.admin-header-right .admin-ghost{white-space:nowrap}.admin-header-right .admin-who{flex:1 1 100%;min-width:0}}
.admin-api #apiTokenHeading{scroll-margin-top:100px}
