/* ===== 设计 token ===== */
:root {
  --bg: #0a0b0e;
  --bg-elev: #0f1116;
  --panel: #12151b;
  --panel-2: #171b23;
  --panel-3: #1d222c;
  --line: #232936;
  --line-soft: #1a1f29;
  --text: #e8ebf0;
  --text-dim: #9aa4b2;
  --text-mute: #6b7484;
  --accent: #4f7cff;
  --accent-soft: #1b2544;
  --green: #2fbf71;
  --green-soft: #10281d;
  --red: #ef5b5b;
  --red-soft: #2b1417;
  --amber: #e0a33e;
  --amber-soft: #2a2010;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 232px;
  --topbar-h: 60px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
code, .mono { font-family: var(--mono); }
::selection { background: rgba(79, 124, 255, .3); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232936; border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e3646; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .22s ease;
}
.brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #4f7cff, #8b5cf6);
  display: grid; place-items: center; flex: 0 0 auto;
  font-size: 13px; font-weight: 800; color: #fff;
}
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-tag {
  font-size: 9px; padding: 1px 5px; border-radius: 4px;
  background: var(--accent-soft); color: #8fb0ff; margin-left: auto;
  letter-spacing: .04em;
}

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); padding: 0 10px 7px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-dim); font-size: 13.5px; cursor: pointer;
  transition: .12s; margin-bottom: 2px; border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft); color: #a9c1ff;
  border-color: #253358;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.nav-item .badge {
  margin-left: auto; font-size: 10.5px; padding: 1px 6px; border-radius: 99px;
  background: var(--panel-3); color: var(--text-dim);
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--line-soft); }
.balance-mini {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; margin-bottom: 10px;
}
.balance-mini .label { font-size: 11px; color: var(--text-mute); }
.balance-mini .value {
  font-size: 19px; font-weight: 650; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.balance-mini .value span { font-size: 12px; color: var(--text-mute); font-weight: 400; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
  background: rgba(10, 11, 14, .82);
  backdrop-filter: blur(14px);
}
.page-title { font-size: 15px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text-mute); margin-left: 2px; }
.topbar-spacer { flex: 1; }

.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }

/* ===== 组件 ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-desc { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.card-body { padding: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: .13s; white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #2c3444; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #ff9a9a; border-color: #3a2226; background: var(--red-soft); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select, textarea.input {
  width: 100%; height: 36px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text);
  padding: 0 11px; font: inherit; font-size: 13.5px;
  outline: none; transition: border-color .13s;
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus { border-color: #3a4d7a; }
.input::placeholder { color: #4e5666; }
.select {
  appearance: none; cursor: pointer; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, #6b7484 50%), linear-gradient(135deg, #6b7484 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 6px; font-weight: 500;
}
.field-hint { font-size: 11.5px; color: var(--text-mute); margin-top: 5px; line-height: 1.5; }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px 17px;
  position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--text-mute); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.stat-value {
  font-size: 25px; font-weight: 650; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-value .unit { font-size: 13px; font-weight: 400; color: var(--text-mute); margin-left: 3px; }
.stat-delta { font-size: 11.5px; margin-top: 7px; display: flex; align-items: center; gap: 4px; }
.stat-delta svg { width: 12px; height: 12px; vertical-align: -1px; }
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.flat { color: var(--text-mute); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 660px; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11.5px; font-weight: 600; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--panel);
}
tbody td {
  padding: 11px 14px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .017); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; padding: 2px 8px; border-radius: 6px;
  background: var(--panel-3); color: var(--text-dim);
  white-space: nowrap;
}
.tag.green { background: var(--green-soft); color: #6ee7a8; }
.tag.red { background: var(--red-soft); color: #ff9a9a; }
.tag.amber { background: var(--amber-soft); color: #f0c078; }
.tag.blue { background: var(--accent-soft); color: #9dbaff; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: currentColor; }

/* 空状态 */
.empty { padding: 52px 20px; text-align: center; color: var(--text-mute); }
.empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 12px; }
.empty p { margin: 0; font-size: 13px; }

/* 日志/密钥行 */
.kv { display: flex; align-items: center; gap: 8px; }
.key-mask {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 5px 9px; border-radius: 7px; color: #b9c4d4;
  letter-spacing: .02em;
}
.copy-btn {
  background: transparent; border: none; color: var(--text-mute);
  cursor: pointer; padding: 4px; border-radius: 5px; display: grid; place-items: center;
}
.copy-btn:hover { color: var(--accent); background: var(--panel-2); }
.copy-btn svg { width: 14px; height: 14px; }

/* 模型广场 */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-item { min-width: 150px; }
.filter-item label { display: block; font-size: 11.5px; color: var(--text-mute); margin-bottom: 5px; }

.group-block { margin-bottom: 18px; }
.group-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.group-name { font-size: 14px; font-weight: 600; }
.group-rate {
  font-size: 11.5px; padding: 1px 7px; border-radius: 5px;
  background: var(--accent-soft); color: #9dbaff; font-weight: 600;
}
.group-desc { font-size: 12px; color: var(--text-mute); flex: 1 1 100%; }

.price-cell { font-variant-numeric: tabular-nums; }
.price-main { font-size: 13px; color: var(--text); }
.price-old { font-size: 11.5px; color: var(--text-mute); text-decoration: line-through; }

/* 图表 */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none;
  background: #0b0e14; border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; font-size: 12px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .1s;
  white-space: nowrap; z-index: 5;
}
.chart-tip.show { opacity: 1; }

/* 模态 */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 5, 8, .7);
  backdrop-filter: blur(3px); z-index: 100;
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: 100%; max-width: 460px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98) } to { opacity: 1; transform: none } }
.modal-head { padding: 18px 20px 0; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-desc { font-size: 12.5px; color: var(--text-mute); margin-top: 4px; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: flex-end; gap: 9px;
}

/* toast */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-3); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 15px; font-size: 13px;
  box-shadow: var(--shadow); animation: slide .2s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { border-color: #1e4a33; }
.toast.err { border-color: #4a2228; }
@keyframes slide { from { opacity: 0; transform: translateX(20px) } to { opacity: 1; transform: none } }

/* 代码块 */
pre.code {
  margin: 0; background: #0b0e14; border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: #c3cddb;
  position: relative;
}
pre.code .cmt { color: #5d6675; }
pre.code .k { color: #8fb0ff; }
pre.code .s { color: #86d99f; }

.tabs-narrow { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); padding: 3px; border-radius: 9px; }
.tabs-narrow button {
  flex: 1; height: 28px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 6px; font-size: 12.5px; cursor: pointer; transition: .12s;
}
.tabs-narrow button.active { background: var(--panel-3); color: var(--text); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line-soft); }
.pager .info { font-size: 12px; color: var(--text-mute); }
.pager .spacer { flex: 1; }

/* 移动端 */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 0 14px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 21px; }
  .stat-delta { font-size: 11px; }
}

.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  z-index: 35; display: none;
}
.scrim.show { display: block; }
@media (min-width: 901px) { .scrim { display: none !important; } }

/* 登录页 */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-left {
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px; border-right: 1px solid var(--line-soft);
  background:
    radial-gradient(600px 400px at 20% 20%, rgba(79,124,255,.10), transparent 60%),
    radial-gradient(500px 400px at 80% 80%, rgba(139,92,246,.08), transparent 60%),
    var(--bg-elev);
}
.auth-right { display: grid; place-items: center; padding: 40px 20px; }
.auth-form { width: 100%; max-width: 360px; }
.auth-title { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-sub { font-size: 13px; color: var(--text-mute); margin: 0 0 26px; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 40px; }
.auth-h { font-size: 30px; font-weight: 680; letter-spacing: -.03em; line-height: 1.25; margin: 0 0 16px; }
.auth-p { font-size: 14px; color: var(--text-dim); line-height: 1.7; margin: 0 0 28px; max-width: 380px; }
.auth-list { display: flex; flex-direction: column; gap: 13px; }
.auth-li { display: flex; gap: 10px; font-size: 13.5px; color: var(--text-dim); align-items: flex-start; }
.auth-li svg { width: 16px; height: 16px; color: var(--green); flex: 0 0 auto; margin-top: 3px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-left { display: none; }
}

.hr { height: 1px; background: var(--line-soft); margin: 20px 0; border: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-mute); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb0 { margin-bottom: 0; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }
