/* ============================================================
   AI 讨论组 · 管理后台样式
   ============================================================ */
:root {
  --bg: #08090c;
  --bg-soft: #0a0c11;
  --surface: #0e1015;
  --surface-2: #12151c;
  --surface-3: #171b23;
  --border: rgba(255, 255, 255, 0.065);
  --border-2: rgba(255, 255, 255, 0.12);
  --text: #eceef3;
  --text-2: #9ba3b5;
  --muted: #5e6577;
  --brand: #6c8cff;
  --brand-2: #9b8cff;
  --gold: #f5b942;
  --green: #4ade80;
  --red: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden 必须能压住 display:flex，否则登录框会一直盖在后台上面 */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(760px 420px at 50% -10%, rgba(108, 140, 255, 0.14), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 26px 24px;
  box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.95);
}
/* Logo 是 img：高度固定、宽度自适应，横版长图也不会把布局撑开 */
.lg-mark {
  height: 40px;
  width: auto;
  max-width: 200px;
  min-width: 40px;
  display: block;
  object-fit: contain;
  margin-bottom: 16px;
}
.login-card h1 { font-size: 20px; letter-spacing: -0.3px; }
.lg-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; margin-bottom: 22px; }
.login-card label {
  display: block;
  font-size: 11.5px;
  color: var(--text-2);
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}
.login-card input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.15); }
.lg-err { color: var(--red); font-size: 12px; min-height: 18px; margin: 8px 0 4px; }
.lg-hint { color: var(--muted); font-size: 11.5px; margin-top: 14px; text-align: center; line-height: 1.6; }

/* ---------------- 骨架 ---------------- */
.app { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.side-mark {
  height: 30px;
  width: auto;
  max-width: 150px;
  min-width: 30px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.side-brand-txt { min-width: 0; }
.side-brand b {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-brand span { font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; }
.side-brand-name[hidden] { display: none; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-2);
  font-size: 13.5px;
  padding: 9px 11px;
  border-radius: 9px;
  text-align: left;
  transition: 0.16s;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on {
  background: linear-gradient(180deg, rgba(108, 140, 255, 0.16), rgba(108, 140, 255, 0.08));
  color: #c3cffd;
  box-shadow: inset 0 0 0 1px rgba(108, 140, 255, 0.22);
}
.nav button .ni { width: 16px; height: 16px; opacity: 0.85; flex-shrink: 0; }
.nav button .nbadge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
}
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 14px; border-top: 1px solid var(--border); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head h1 { font-size: 21px; letter-spacing: -0.4px; font-weight: 650; }
.head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.tag.ok i { background: var(--green); box-shadow: 0 0 8px rgba(74, 222, 128, 0.7); }
.tag.warn i { background: var(--gold); }
.tag.bad i { background: var(--red); }

/* ---------------- 通用组件 ---------------- */
.view { display: flex; flex-direction: column; gap: 16px; max-width: 1080px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h2 { font-size: 14.5px; font-weight: 650; letter-spacing: -0.1px; }
.card-h p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  transition: 0.16s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, 0.2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #6c8cff, #5b78ee);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px -12px rgba(108, 140, 255, 0.9);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn.danger { color: #fca5a5; border-color: rgba(248, 113, 113, 0.28); background: rgba(248, 113, 113, 0.08); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.16); }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.stat .sl { font-size: 11.5px; color: var(--muted); letter-spacing: 0.03em; }
.stat .sv { font-size: 26px; font-weight: 700; letter-spacing: -0.8px; margin-top: 6px; line-height: 1.1; }
.stat .sd { font-size: 11.5px; color: var(--text-2); margin-top: 3px; }
.stat.accent .sv { background: linear-gradient(90deg, #8ea6ff, #c0b6ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

.warnbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  background: rgba(245, 185, 66, 0.08);
  border: 1px solid rgba(245, 185, 66, 0.24);
  color: #f0d08a;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 16px;
}
.warnbar.bad { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.24); color: #fca5a5; }
.warnbar a { text-decoration: underline; text-underline-offset: 2px; }

/* 表单 */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 11.5px; color: var(--text-2); margin-bottom: 6px; letter-spacing: 0.02em; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.55; }
.inp {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.13); }
.inp::placeholder { color: #4a5164; }
textarea.inp { resize: vertical; min-height: 68px; line-height: 1.6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Logo 设置 */
.logo-preview-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.lp > span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.lp-stage {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 64px;
  overflow: hidden;
}
/* 高度锁死，宽度自适应：横版长图也不会把这一格撑开 */
.lp-stage img {
  height: 26px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
  flex: none;
}
.lp-stage b {
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-stage b[hidden] { display: none; }
.lp-stage.lp-admin img { height: 30px; }
.lp-stage.lp-fav {
  background: #1b1e26;
  border-radius: 9px 9px 0 0;
  border-bottom-color: transparent;
  align-self: stretch;
  padding: 11px 14px;
}
.lp-fav img { height: 15px; max-width: 15px; }
.lp-fav em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-fav em[hidden] { display: none; }

.preset-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.preset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 11px 4px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.preset img { width: 30px; height: 30px; display: block; }
.preset span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.preset:hover { border-color: rgba(108, 140, 255, 0.45); }
.preset.on {
  border-color: var(--brand);
  background: rgba(108, 140, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(108, 140, 255, 0.16);
}
.preset.on span { color: var(--text); }

.upload-row { display: flex; gap: 12px; align-items: flex-start; }
.upload-thumb {
  height: 46px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 5px 8px;
  flex: none;
}
.upload-thumb[hidden] { display: none; }
.upload-btns { flex: 1; min-width: 0; }
.upload-line { display: flex; gap: 8px; }

.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--border-2);
  border-radius: 9px;
}
.seg button {
  background: transparent;
  border: 0;
  color: var(--text-2);
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.seg button.on { background: rgba(108, 140, 255, 0.16); color: var(--text); }
.seg button:disabled { opacity: 0.38; cursor: not-allowed; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: rgba(255, 255, 255, 0.017); }
.tbl .q { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tbl .dim { color: var(--muted); }
.tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--text-2); }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 12.5px; }

.dot-state { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; }
.dot-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.dot-state.done::before { background: var(--green); }
.dot-state.running::before { background: var(--gold); animation: pulse 1.2s infinite; }
.dot-state.error::before { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* 行内操作按钮 */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* 席位列：一行显示，超长省略 */
.tbl .seat {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 模型卡片 */
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pcard.off { opacity: 0.62; }
.pc-head { display: flex; align-items: center; gap: 10px; }
.pc-avatar {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--c, #6c8cff);
  flex-shrink: 0;
  box-shadow: 0 6px 16px -8px var(--c, #6c8cff);
}
.pc-title { min-width: 0; flex: 1; }
.pc-title b { font-size: 13.5px; font-weight: 650; display: block; }
.pc-title span { font-size: 11px; color: var(--muted); }
.pc-title span.on { color: var(--green); }
.pc-title span.warn { color: var(--gold); }

.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i {
  position: absolute; inset: 0;
  background: #262b36;
  border-radius: 999px;
  transition: 0.2s;
}
.switch i::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #8b93a7;
  transition: 0.2s;
}
.switch input:checked + i { background: rgba(108, 140, 255, 0.85); }
.switch input:checked + i::after { left: 18px; background: #fff; }

.pc-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-msg { font-size: 11.5px; margin-left: auto; color: var(--muted); }
.pc-msg.ok { color: var(--green); }
.pc-msg.err { color: var(--red); }

/* 模型名说明（官方 id 对照） */
.pc-hint { font-size: 11px; line-height: 1.7; color: var(--muted); margin-top: 6px; }
.pc-hint .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; color: var(--text-2); }

/* 额度条 */
.qbar { height: 6px; border-radius: 999px; background: #1a1e27; overflow: hidden; margin: 10px 0 4px; }
.qbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 999px; transition: width 0.4s; }

/* 弹窗 */
.mask {
  position: fixed; inset: 0;
  background: rgba(4, 5, 8, 0.7);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 60;
}
.mask[hidden] { display: none; }
.modal {
  width: 100%; max-width: 400px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 40px 90px -40px #000;
}
.modal h3 { font-size: 15px; margin-bottom: 8px; }
.modal p { font-size: 12.5px; color: var(--text-2); line-height: 1.7; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 14px);
  background: #1b202a;
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 90;
  box-shadow: 0 20px 40px -20px #000;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.toast.ok { border-color: rgba(74, 222, 128, 0.35); color: #a7f3c4; }

/* 响应式 */
@media (max-width: 1080px) {
  .pgrid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .side {
    width: 100%; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--border);
    padding: 12px 12px 10px;
  }
  .side-brand { padding: 0 4px 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; }
  .nav button { width: auto; white-space: nowrap; padding: 7px 12px; flex: 0 0 auto; }
  .nav button .nbadge { display: none; }
  .side-foot { flex-direction: row; border-top: 0; padding-top: 8px; gap: 8px; }
  .main { padding: 18px 14px 50px; }
  .head h1 { font-size: 18px; }
  .head-right .tag { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .logo-preview-row { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
  .upload-row { flex-direction: column; }
  .upload-thumb { max-width: 100%; }
  .tbl .q { max-width: 150px; }
  .tbl .hide-sm { display: none; }
}
