/* 控制台外壳样式（web/console/*.html 共用）。
   视觉延续 2026-10 全站浅色极简：token 取值与 styles.css 浅色主题一致，
   组件类（summary-card / stats-table / login-gate 等）自 nodes.html / usage.html
   内联样式收拢而来，取值不变。console 页面只依赖本文件，不加载 styles.css。 */
:root {
  color-scheme: light;
  /* 与 studio 浅色极简最终层（styles.css 2026-10 改版）同值：白底、近黑强调，
     绿色只留给状态指示（--ok）。 */
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f9f9f9;
  --surface: #f4f4f4;
  --surface-2: #ececec;
  --line: #e6e6e6;
  --line-strong: #d4d4d4;
  --text: #0d0d0d;
  --muted: #5d5d5d;
  --muted-2: #8f8f8f;
  --mint: #0d0d0d;
  --mint-2: #262626;
  --violet: #7658d6;
  --ok: #12a150;
  --danger: #e5484d;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  font-family: Inter, "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); }

body { overflow: auto; font-size: 16px; }

button, textarea, input, select { font: inherit; }

button { color: inherit; }

button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

/* ---- 顶部导航 ---- */
.console-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  min-height: 58px; padding: 0 clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid #e9edf2;
}
.console-brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); text-decoration: none; font-size: 14.5px; font-weight: 700;
  flex: none;
}
.console-brand img { display: block; height: 26px; width: auto; }
/* 站点标识：站点标题不是默认的 zLLM 时显示在品牌图右侧（图内已含 zLLM 字样）。 */
.console-site-name {
  padding-left: 9px; border-left: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 650; color: var(--text); white-space: nowrap;
}
@media (max-width: 600px) { .console-site-name { display: none; } }
.console-nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.console-nav::-webkit-scrollbar { display: none; }
.console-nav a {
  /* 固定高度 + 居中：中文(Noto)与拉丁(Inter)行盒高度不同，基线对齐会让
     "API" 相对汉字上下偏移，按盒子中心对齐才能保证视觉齐平。 */
  display: inline-flex; align-items: center; height: 34px; padding: 0 13px;
  border-radius: 8px;
  font-size: 13px; font-weight: 550; color: #657084;
  text-decoration: none; white-space: nowrap; line-height: 1;
}
.console-nav a:hover { color: var(--text); background: var(--surface); }
.console-topbar .console-nav a.active { background: #edf3ff; color: #285bc2; font-weight: 650; }
.console-account { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.console-balance {
  font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums;
  border: 1px solid #e5eaf1; border-radius: 8px; padding: 6px 10px; background: #f8fafc;
}
.console-balance b { color: var(--text); }
.console-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; cursor: pointer;
  background: #edf3ff; color: #315a9e;
  font-size: 13px; font-weight: 700;
}
.console-identity {
  display: flex; flex-direction: column; min-width: 0; line-height: 1.25;
}
.console-identity strong {
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 650; color: var(--text);
}
.console-identity small {
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10.5px; color: var(--muted-2);
}
.console-avatar-wrap { position: relative; }
.console-user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 200px; padding: 12px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  display: flex; flex-direction: column; gap: 10px;
}
.console-user-email { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.console-auth-actions { display: flex; gap: 8px; }

/* ---- 页面容器与标题 ---- */
.console-shell { min-height: calc(100vh - 58px); padding: 28px clamp(16px, 4vw, 48px) 64px; }
.console-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 22px; }
.console-title { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.console-title small { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.console-page-head .spacer { flex: 1; }

/* ---- 共用组件（自 nodes / usage 内联样式收拢，取值不变） ---- */
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.summary-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.summary-card .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.summary-card .value { font-size: 21px; font-weight: 650; font-variant-numeric: tabular-nums; }
.summary-card .sub { font-size: 12px; color: var(--muted-2); margin-top: 3px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel-title { font-size: 14px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.panel-title .hint { font-size: 12px; font-weight: 500; color: var(--muted-2); }

.stats-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stats-table th, .stats-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.stats-table th { color: var(--muted-2); font-weight: 500; white-space: nowrap; }
.stats-table td { color: var(--text); font-variant-numeric: tabular-nums; }
.stats-table td.num, .stats-table th.num { text-align: right; }
.stats-table tr:last-child th, .stats-table tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.chip b { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.chip.on { color: var(--ok); border-color: rgba(18, 161, 80, 0.35); background: rgba(18, 161, 80, 0.07); }
.chip.on b { color: var(--ok); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--ok);
  border: 1px solid rgba(18, 161, 80, 0.35); background: rgba(18, 161, 80, 0.08);
  border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.badge.offline { color: var(--danger); border-color: rgba(229, 72, 77, 0.4); background: rgba(229, 72, 77, 0.08); }
.badge.plain { color: var(--muted); border-color: var(--line); background: var(--surface); font-weight: 500; }

.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn.primary { background: var(--mint); border-color: var(--mint); color: #ffffff; }
.btn.primary:hover:not(:disabled) { background: var(--mint-2); }
.btn.danger { color: var(--danger); border-color: rgba(229, 72, 77, 0.4); background: rgba(229, 72, 77, 0.06); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.linklike { background: none; border: none; color: var(--mint-2); font-size: 13px; cursor: pointer; padding: 0; margin-left: 6px; }
.linklike:hover { text-decoration: underline; }

/* ---- 板块侧栏：有子入口的板块（如 API 平台）在内容区左侧注入竖向导航 ---- */
.console-shell.console-sectioned { display: flex; padding: 0; align-items: stretch; }
.console-side {
  width: 200px; flex: none; padding: 24px 14px;
  background: var(--panel-2); border-right: 1px solid var(--line);
  min-height: calc(100vh - 58px);
}
.console-side-title {
  font-size: 12px; font-weight: 700; color: var(--muted-2);
  letter-spacing: 0.05em; padding: 0 12px 10px;
}
.console-side a {
  display: flex; align-items: center; height: 36px; padding: 0 12px; margin-bottom: 2px;
  border-radius: 10px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.console-side a:hover { color: var(--text); background: var(--surface); }
.console-side a.active { color: #ffffff; background: var(--text); }
.console-content { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 48px) 64px; }

.console-footer { margin-top: 28px; text-align: center; font-size: 12px; color: var(--muted-2); }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
  background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 16px;
}
.empty-state h2 { color: var(--text); font-size: 17px; margin: 0 0 10px; }
.empty-state p { margin: 4px 0; font-size: 13.5px; }
.empty-hint { text-align: center; color: var(--muted); font-size: 13.5px; padding: 26px 10px; }

/* ---- 登录 gate（取自 usage.html，未登录时替换页面主内容） ---- */
.console-gate { max-width: 420px; margin: 48px auto; text-align: center; padding: 40px 20px; }
.console-gate h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }
.console-gate p { color: var(--muted); font-size: 13.5px; margin: 6px 0 14px; }
.console-gate a { color: var(--mint-2); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 13.5px;
}
.auth-form input:focus-visible { outline: none; border-color: var(--mint-2); }
.auth-error { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 0; }
.auth-switch { font-size: 13px; color: var(--muted); margin-top: 14px; }
.auth-code-row { display: flex; gap: 8px; }
.auth-code-row[hidden] { display: none; }
.auth-code-row input { flex: 1; min-width: 0; }
.auth-code-row button { flex-shrink: 0; white-space: nowrap; }
.console-gate .auth-notice { color: var(--mint-2); font-size: 12.5px; text-align: left; }

/* ---- 快捷入口卡（取自 chat.html 右栏 entry-block，token 化） ---- */
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.entry-block {
  display: block; text-decoration: none; border-radius: 16px; padding: 18px 16px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  box-shadow: 0 8px 24px rgba(31, 48, 72, 0.06);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.entry-block:hover { border-color: var(--mint-2); transform: translateY(-1px); }
.entry-block .icon { font-size: 24px; }
.entry-block .name { font-size: 14.5px; font-weight: 700; margin-top: 10px; }
.entry-block .desc { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

/* ---- 轻提示（取自 app.js showToast 行为的简化版） ---- */
.c-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: #ffffff; border-radius: 12px;
  padding: 10px 16px; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100; max-width: min(90vw, 480px);
}
.c-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.c-toast.error { background: var(--danger); }
.c-toast strong { display: block; }
.c-toast small { opacity: 0.85; }

@media (max-width: 780px) {
  .console-topbar { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; row-gap: 6px; }
  .console-nav { order: 3; width: 100%; flex-basis: 100%; }
  /* 板块侧栏退化为内容区顶部一行横滑胶囊 */
  .console-shell.console-sectioned { flex-direction: column; }
  .console-side {
    width: 100%; min-height: 0; display: flex; gap: 6px; overflow-x: auto;
    padding: 10px 16px; border-right: none; border-bottom: 1px solid var(--line);
  }
  .console-side-title { display: none; }
  .console-side a { flex: none; margin: 0; height: 32px; padding: 0 14px; border-radius: 999px; }
  .console-content { padding: 18px 16px 48px; }
}

[hidden] { display: none !important; }


@media (max-width: 760px) {
  /* 窄屏把身份信息收回头像菜单，避免余额/导航被挤换行。 */
  .console-identity { display: none; }
}
