:root {
  color-scheme: light;
  --bg: #f4f5fa;
  --bg-soft: #eceef5;
  --card: rgba(255, 255, 255, 0.88);
  --card-solid: #ffffff;
  --line: rgba(23, 30, 54, 0.08);
  --line-strong: rgba(23, 30, 54, 0.16);
  --text: #1b1f2d;
  --muted: #5a6072;
  --dim: #8b90a2;
  --accent: #6d4aff;
  --accent-2: #0891b2;
  --accent-soft: rgba(109, 74, 255, 0.09);
  --ok: #059669;
  --warn: #b45309;
  --err: #be123c;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 20px 46px -30px rgba(23, 30, 54, 0.35);
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* display 声明会覆盖 [hidden] 的默认值，统一兜底 */
[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- 背景光晕（浅色柔彩） ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.aurora i {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}
.aurora i:nth-child(1) { width: 560px; height: 560px; top: -180px; left: -120px; background: #d9cdff; }
.aurora i:nth-child(2) { width: 480px; height: 480px; top: 20%; right: -160px; background: #c8ecf6; opacity: 0.42; }
.aurora i:nth-child(3) { width: 520px; height: 520px; bottom: -240px; left: 34%; background: #e3dbff; opacity: 0.4; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #8b6cff, #5b3ff0);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.5px;
  box-shadow: 0 8px 18px -8px rgba(109, 74, 255, 0.65);
}
.brand-mark span { font-size: 11px; margin-left: 1px; transform: translateY(-3px); }
.brand-text { display: flex; align-items: baseline; gap: 2px; font-size: 17px; font-weight: 650; letter-spacing: -0.2px; }
.brand-text > span { color: var(--muted); font-weight: 500; }
.brand-text small { margin-left: 10px; font-size: 11px; color: var(--dim); font-weight: 400; letter-spacing: 0.3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}
.status-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px rgba(5, 150, 105, 0.8); }

/* ---------- 布局 ---------- */
.page {
  position: relative;
  z-index: 1;
  width: min(1180px, 100% - 32px);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 52px) 0 72px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 22px;
  align-items: start;
}

/* ---------- 登录卡 ---------- */
.login-card { padding: clamp(24px, 3vw, 38px); }
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.step-no { font-family: var(--mono); font-size: 11px; letter-spacing: 1.4px; color: var(--dim); }
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(109, 74, 255, 0.3);
  background: var(--accent-soft);
  color: #6d4aff;
  font-size: 11px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.key-icon {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  margin-bottom: 16px;
  border-radius: 14px;
  border: 1px solid rgba(109, 74, 255, 0.22);
  background: linear-gradient(150deg, rgba(109, 74, 255, 0.12), rgba(8, 145, 178, 0.06));
  color: var(--accent);
}
.key-icon svg { width: 22px; height: 22px; }
.login-card h1 { margin: 0 0 8px; font-size: clamp(24px, 3vw, 31px); line-height: 1.25; letter-spacing: -0.6px; }
.login-card h1 em {
  font-style: normal;
  background: linear-gradient(92deg, #6d28d9, #0e7490);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--muted); margin: 0; }
.small-text { font-size: 13px; }

.field-label {
  display: flex; align-items: baseline; gap: 8px;
  margin: 26px 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #3a4054;
}
.field-label span { font-family: var(--mono); font-size: 10px; letter-spacing: 1px; color: var(--dim); font-weight: 400; }

.input-wrap {
  display: flex; align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.input-wrap:focus-within { border-color: rgba(109, 74, 255, 0.55); box-shadow: 0 0 0 4px rgba(109, 74, 255, 0.1); }
.input-icon { padding: 0 4px 0 14px; color: var(--dim); font-size: 14px; }
.input-wrap input {
  flex: 1;
  min-width: 0;
  padding: 13px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.6px;
  outline: none;
}
.input-wrap input::placeholder { color: #b3b8c7; letter-spacing: 0.4px; }
.reveal {
  margin-right: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s;
}
.reveal:hover { color: var(--text); border-color: rgba(23, 30, 54, 0.28); }

.form-options {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin: 14px 0 20px;
  font-size: 12.5px;
}
.checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; user-select: none; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.text-btn {
  border: 0; padding: 0; background: none;
  color: var(--accent); font-size: 12.5px; cursor: pointer;
  text-decoration: underline; text-decoration-color: rgba(109, 74, 255, 0.35); text-underline-offset: 3px;
}
.text-btn:hover { color: #5b3ff0; text-decoration-color: currentColor; }

.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #8b6cff, #5b3ff0);
  color: #fff;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 12px 24px -12px rgba(109, 74, 255, 0.8);
  transition: transform 0.14s, filter 0.14s, opacity 0.14s;
}
.primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.primary:active:not(:disabled) { transform: translateY(0); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.primary.wide { width: 100%; }
.primary.small { padding: 8px 14px; font-size: 12.5px; }
.primary span { font-size: 15px; }

.ghost-btn {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #ffffff;
  color: #3f4557;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.ghost-btn:hover:not(:disabled) { background: var(--bg-soft); border-color: rgba(23, 30, 54, 0.3); color: var(--text); }
.ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost-btn.small { padding: 6px 11px; font-size: 12px; }
.ghost-btn.danger:hover:not(:disabled) { border-color: rgba(190, 18, 60, 0.4); color: var(--err); background: rgba(190, 18, 60, 0.05); }

.privacy-note {
  display: flex; gap: 10px;
  margin-top: 20px; padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(23, 30, 54, 0.02);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}
.privacy-note span { color: var(--accent); }
.privacy-note p { margin: 0; }
.login-bottom {
  display: flex; align-items: center; gap: 8px;
  margin-top: 16px;
  color: var(--dim);
  font-size: 11.5px;
}
.login-bottom i { font-style: normal; opacity: 0.5; }

/* ---------- 引导卡 ---------- */
.intro-card { padding: clamp(24px, 3vw, 34px); display: flex; flex-direction: column; }
.intro-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tiny-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 1.4px; color: var(--dim); }
.intro-spark { color: var(--accent); font-size: 15px; }
.intro-card h2 { margin: 0 0 22px; font-size: clamp(20px, 2.4vw, 25px); line-height: 1.35; letter-spacing: -0.4px; }
.intro-card h2 span { color: var(--muted); }

.start-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.start-steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.start-steps b {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(109, 74, 255, 0.28);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
}
.start-steps strong { display: block; font-size: 13.5px; font-weight: 600; }
.start-steps p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

.start-note {
  margin-top: 22px; padding: 13px 15px;
  border-left: 2px solid rgba(109, 74, 255, 0.55);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
}
.start-note strong { font-size: 12.5px; color: #5b3ff0; }
.start-note p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.flow-hint {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: auto; padding-top: 22px;
  color: var(--dim); font-size: 11.5px;
}
.flow-hint span {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}
.flow-hint i { font-style: normal; color: #a8adbd; }
.flow-hint.vertical { flex-direction: column; align-items: flex-start; }

/* ---------- 控制台 ---------- */
#dashboard { display: grid; gap: 18px; }

.session-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 20px;
}
.session-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px rgba(5, 150, 105, 0.7); flex: none; }
.session-id { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.session-id strong { font-family: var(--mono); font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.session-id small { color: var(--dim); font-size: 11.5px; }
.session-actions { display: flex; gap: 8px; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat.primary { background: linear-gradient(150deg, rgba(109, 74, 255, 0.12), rgba(255, 255, 255, 0.92)); border-color: rgba(109, 74, 255, 0.3); }
.stat-label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.3px; }
.stat-value { font-size: clamp(20px, 2.4vw, 26px); font-weight: 650; letter-spacing: -0.6px; line-height: 1.2; }
.stat-value.cost { background: linear-gradient(92deg, #6d28d9, #0e7490); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-foot { font-size: 11px; color: var(--dim); }

.panel { padding: 20px clamp(16px, 2.4vw, 24px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 14.5px; font-weight: 620; letter-spacing: -0.2px; }
.panel-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 1.2px; color: var(--dim); }

.usage-bars { display: grid; gap: 16px; }
.usage-row { display: grid; gap: 7px; }
.usage-caption { display: flex; align-items: baseline; justify-content: space-between; font-size: 12.5px; color: #3a4054; }
.usage-caption b { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text); }
.track { height: 7px; border-radius: 99px; background: rgba(23, 30, 54, 0.08); overflow: hidden; }
.track > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #7c5cff, #22d3ee); transition: width 0.5s ease; }
.track > div.over-limit { background: linear-gradient(90deg, #f43f5e, #f59e0b); }
.usage-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--dim); }

.model-table table, .detail-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.model-table th, .detail-table th {
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.model-table td, .detail-table td {
  padding: 11px 10px;
  border-bottom: 1px solid rgba(23, 30, 54, 0.05);
  color: #3f4557;
  font-variant-numeric: tabular-nums;
}
.model-table tr:last-child td, .detail-table tr:last-child td { border-bottom: 0; }
.detail-table tbody tr:hover { background: rgba(23, 30, 54, 0.03); }
.align-right { text-align: right; }
.empty { padding: 26px 10px !important; text-align: center; color: var(--dim); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 14px; }
.filter-tabs { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: rgba(23, 30, 54, 0.04); }
.filter-tabs button {
  padding: 6px 13px;
  border: 0; border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.filter-tabs button.selected { background: #ffffff; color: var(--accent); box-shadow: 0 1px 4px rgba(23, 30, 54, 0.14); }
.filters select, .filters input, textarea {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.filters select:focus, .filters input:focus, textarea:focus { border-color: rgba(109, 74, 255, 0.55); box-shadow: 0 0 0 3px rgba(109, 74, 255, 0.1); }

.detail-summary { margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: rgba(23, 30, 54, 0.015); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; font-size: 12px; color: var(--muted); }

.type-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(5, 150, 105, 0.3);
  background: rgba(5, 150, 105, 0.08);
  color: #047857;
  font-size: 11px;
  white-space: nowrap;
}
.type-tag.over { border-color: rgba(180, 83, 9, 0.32); background: rgba(245, 158, 11, 0.12); color: #92400e; }

.switch-panel textarea { width: 100%; margin-top: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.7; resize: vertical; background: #ffffff; }
.switch-actions { display: flex; gap: 9px; margin-top: 12px; }
.hint { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12.5px; color: var(--muted); }
.hint summary { cursor: pointer; color: var(--accent); list-style: none; }
.hint summary::-webkit-details-marker { display: none; }
.hint summary::before { content: "＋ "; }
.hint[open] summary::before { content: "－ "; }
.hint ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 5px; }

.guide-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.8fr); gap: 26px; }
.guide-grid h4 { margin: 18px 0 6px; font-size: 13px; color: #2a3042; }
.guide-grid h4:first-child { margin-top: 0; }
.guide-grid p, .guide-grid li { font-size: 12.5px; color: var(--muted); }
.guide-grid ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 5px; }
.guide-grid b { color: #3f4557; font-weight: 600; }
.guide-side { border-left: 1px solid var(--line); padding-left: 22px; }

/* ---------- 图文步骤 ---------- */
.guide-figures { display: grid; gap: 20px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.fig-title { margin: 0; font-size: 14px; font-weight: 620; color: #2a3042; }
.guide-figures figure { margin: 0; display: grid; gap: 8px; }
.guide-figures a { display: block; border-radius: 12px; transition: box-shadow 0.16s, transform 0.16s; }
.guide-figures a:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -18px rgba(23, 30, 54, 0.45); }
.guide-figures img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}
.guide-figures figcaption { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.guide-figures figcaption b { font-size: 13px; color: #2a3042; white-space: nowrap; }
.guide-figures figcaption span { font-size: 12.5px; color: var(--muted); }

code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: #5b3ff0;
  font-family: var(--mono);
  font-size: 11.5px;
}

/* ---------- 消息 / toast ---------- */
.message {
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.message.error { border-color: rgba(190, 18, 60, 0.25); background: rgba(190, 18, 60, 0.06); color: #be123c; }
.message.warning { border-color: rgba(180, 83, 9, 0.28); background: rgba(245, 158, 11, 0.08); color: #92400e; }
.message.success { border-color: rgba(5, 150, 105, 0.28); background: rgba(5, 150, 105, 0.07); color: #047857; }
#login-error { margin-bottom: 14px; }
#quota-warning { margin: 0; }
#detail-error { margin-bottom: 12px; }
#switch-message { margin-top: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 16px 36px -16px rgba(23, 30, 54, 0.4);
  animation: toast-in 0.24s ease;
  max-width: min(92vw, 520px);
}
.toast.error { border-color: rgba(190, 18, 60, 0.4); color: #be123c; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .login-layout, .guide-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-side { border-left: 0; border-top: 1px solid var(--line); padding: 18px 0 0; }
  .brand-text small { display: none; }
}
@media (max-width: 620px) {
  .topbar { padding: 13px 16px; }
  .status-chip { display: none; }
  .page { width: calc(100% - 24px); padding-top: 20px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .form-options { flex-direction: column; align-items: flex-start; gap: 8px; }
  .session-bar { align-items: flex-start; }
  .filters { gap: 7px; }
  .filters select, .filters input { flex: 1 1 120px; }
}
