/*
 * genspark2api 管理面板样式。
 *
 * 分层：1 设计令牌 → 2 重置 → 3 布局 → 4 组件 → 5 页面特性 → 6 响应式。
 *
 * 调色板依赖 color-mix(in oklab, …)：色阶混合用 oklab 插值才自然，
 * 换成 srgb 会明显偏灰。令牌顺序不可调换 —— 暗色块靠源码顺序覆盖
 * 同特异性的亮色块。
 */

/* ------------------------------------------------------------------ 1 令牌 */

:root {
  --brand: #006eff;
  --brand-ink: #ffffff;
  --brand-soft: color-mix(in oklab, var(--brand) 11%, transparent);
  --brand-line: color-mix(in oklab, var(--brand) 32%, transparent);

  --ok: #17935b;
  --warn: #b0740b;
  --err: #d33a3a;
  --info: #5b5bd6;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --control-h: 34px;
  --control-h-sm: 28px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --shadow-1: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-2: 0 8px 24px rgb(16 24 40 / 0.1), 0 2px 6px rgb(16 24 40 / 0.05);
  --shadow-3: 0 20px 56px rgb(16 24 40 / 0.22);

  --sidebar-w: 224px;
  --topbar-h: 60px;

  /* 下拉箭头随主题换色：参考实现把它写死成浅灰，暗色下几乎看不见。 */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868c96' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

:root,
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-sunken: #eef0f3;
  --bg-hover: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #d0d5dd;
  --ink: #16181d;
  --ink-soft: #525964;
  --ink-faint: #868c96;
  --surface: var(--bg-elevated);
  --line: var(--border);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1014;
  --bg-elevated: #161920;
  --bg-sunken: #0b0d11;
  --bg-hover: #1e222a;
  --border: #252a33;
  --border-strong: #343a45;
  --ink: #e8ebf0;
  --ink-soft: #a3aab6;
  --ink-faint: #6e7784;
  --surface: var(--bg-elevated);
  --line: var(--border);
  /* 11% 的品牌色在近黑背景上几乎不可见，暗色下加深到 20%。 */
  --brand-soft: color-mix(in oklab, var(--brand) 20%, transparent);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 8px 24px rgb(0 0 0 / 0.5);
  --shadow-3: 0 20px 60px rgb(0 0 0 / 0.6);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7784' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* 跟随系统：亮色系统下 auto 命中 :root 的亮色值，暗色系统下覆盖为暗色。 */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg: #0e1014;
    --bg-elevated: #161920;
    --bg-sunken: #0b0d11;
    --bg-hover: #1e222a;
    --border: #252a33;
    --border-strong: #343a45;
    --ink: #e8ebf0;
    --ink-soft: #a3aab6;
    --ink-faint: #6e7784;
    --surface: var(--bg-elevated);
    --line: var(--border);
    --brand-soft: color-mix(in oklab, var(--brand) 20%, transparent);
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 8px 24px rgb(0 0 0 / 0.5);
    --shadow-3: 0 20px 60px rgb(0 0 0 / 0.6);
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e7784' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ 2 重置 */

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 18px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
svg { flex: none; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------- 3 布局：外壳 */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-3);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px;
  height: 30px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand), color-mix(in oklab, var(--brand) 55%, #7b5bff));
  box-shadow: var(--shadow-1);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 14px; }
.brand-text small {
  color: var(--ink-faint);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: var(--space-4); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  padding: 0 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav a:hover { background: var(--bg-hover); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-icon { display: inline-flex; width: 18px; height: 18px; flex: none; }
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--err);
  background: color-mix(in oklab, var(--err) 13%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: var(--space-3) var(--space-1) 0;
  border-top: 1px solid var(--border);
}
.sidebar-foot .version {
  margin-left: auto;
  padding-right: 4px;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.scrim { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--topbar-h);
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg-elevated) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}
.topbar-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.topbar-title p { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex: none; }

/* .btn 在文件后面才设 display，因此这里必须用复合选择器提高特异性。 */
.btn.menu-toggle { display: none; }

.view {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ------------------------------------------------------------ 3 布局：原语 */

.col, .stack { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.stack { gap: var(--space-4); }
.col.tight { gap: 2px; }

.row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.row-between { display: flex; align-items: center; gap: var(--space-2); min-width: 0; justify-content: space-between; }
.row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }

.grid { display: grid; gap: var(--space-4); align-items: start; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: var(--space-4);
  align-items: start;
}
.split-main, .split-side { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 2px 0;
}
.section-head h2 { font-size: 13px; font-weight: 650; color: var(--ink); }
.section-head p { font-size: 12px; color: var(--ink-faint); }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--ink-faint);
  padding: var(--space-6);
}

/* ------------------------------------------------------------------ 4 工具类 */

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.err { color: var(--err); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------- 卡片 */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  min-height: 50px;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
}
.card-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.card-title > strong { font-size: 14px; font-weight: 650; }
.card-title > span { font-size: 12px; color: var(--ink-faint); }
.card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.card-body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.card-body.tight { gap: var(--space-2); }
.card-body.flush { padding: 0; gap: 0; }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border-top: 1px solid var(--border);
}

/* -------------------------------------------------------------- 指标条 */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  overflow: hidden;
  padding: 0;
}
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  min-width: 0;
}
.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}
.stat-value {
  font-size: 24px;
  font-weight: 660;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-hint {
  font-size: 12px;
  color: var(--ink-faint);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-cell.is-alert .stat-value { color: var(--err); }
.stat-cell.is-good .stat-value { color: var(--ok); }

/* --------------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 12px;
  font: inherit;
  font-weight: 550;
  font-size: 13px;
  line-height: 1;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  flex: none;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: color-mix(in oklab, var(--brand) 88%, black); }
.btn-danger {
  color: var(--err);
  border-color: color-mix(in oklab, var(--err) 40%, var(--border));
}
.btn-danger:hover:not(:disabled) { background: color-mix(in oklab, var(--err) 9%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--ink); }
.btn-sm { height: var(--control-h-sm); padding: 0 9px; font-size: 12.5px; gap: 5px; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-block { width: 100%; }

/* --------------------------------------------------------------------- 徽标 */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
  flex: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill-ok { color: var(--ok); background: color-mix(in oklab, var(--ok) 12%, transparent); }
.pill-warn { color: var(--warn); background: color-mix(in oklab, var(--warn) 14%, transparent); }
.pill-err { color: var(--err); background: color-mix(in oklab, var(--err) 12%, transparent); }
.pill-info { color: var(--info); background: color-mix(in oklab, var(--info) 12%, transparent); }
.pill-brand { color: var(--brand); background: var(--brand-soft); }
.pill-muted { color: var(--ink-soft); background: var(--bg-sunken); }
.pill-plain { color: var(--ink-soft); border-color: var(--border); }
.pill-plain::before, .pill.no-dot::before { display: none; }
.pill.no-dot { display: inline-block; line-height: 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  font-size: 11px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-family: var(--mono);
  white-space: nowrap;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--ink-faint);
  min-width: 0;
}
.facts > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 550;
  background: var(--bg-sunken);
  white-space: nowrap;
}
th.num, td.num { font-variant-numeric: tabular-nums; text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > .row { justify-content: flex-end; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------------------- 表单 */

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-soft);
}

input, select, textarea {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  width: 100%;
  min-width: 0;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input, select { height: var(--control-h); }
input:hover, select:hover, textarea:hover {
  border-color: color-mix(in oklab, var(--ink-faint) 60%, var(--border-strong));
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
input[readonly] { background: var(--bg-sunken); }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--brand);
  flex: none;
  cursor: pointer;
}
textarea {
  padding: 8px 10px;
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 15px;
  cursor: pointer;
}

.field-hint { font-weight: 400; color: var(--ink-faint); font-size: 12px; line-height: 1.5; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
label.field.field-inline { flex-direction: row; align-items: center; gap: var(--space-2); }
label.field.field-inline > span { margin: 0; white-space: nowrap; }
label.field.field-inline > select,
label.field.field-inline > input { width: auto; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  min-width: 0;
}
.switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.15s ease;
}
.switch input[type="checkbox"]:checked { background: var(--brand); }
.switch input[type="checkbox"]:checked::after { transform: translateX(14px); }
.switch input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: none;
}
.switch-field { display: flex; flex-direction: column; gap: 3px; }
.switch-field .field-hint { padding-left: 42px; }

.search { position: relative; display: flex; align-items: center; min-width: 0; }
.search svg { position: absolute; left: 10px; color: var(--ink-faint); pointer-events: none; }
.search input { padding-left: 32px; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
.toolbar > select, .toolbar .toolbar-group > select { width: auto; min-width: 120px; }
.toolbar > .search { flex: 1 1 240px; }
.toolbar > .spacer { flex: 1 1 auto; }
.toolbar-group { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }

/* --------------------------------------------------------------- 键值展示 */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: var(--space-3);
  margin: 0;
  font-size: 12.5px;
}
.kv-grid > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv-grid .k { color: var(--ink-faint); font-size: 11.5px; }
.kv-grid .v {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kv-list { display: flex; flex-direction: column; margin: 0; }
.kv-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  min-width: 0;
}
.kv-list > div:last-child { border-bottom: none; }
.kv-list .k { color: var(--ink-soft); white-space: nowrap; }
.kv-list .v {
  min-width: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------- 进度条 */

.bar { height: 6px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width 0.3s ease; }
.bar.is-warn > span { background: var(--warn); }
.bar.is-full > span { background: var(--err); }

.hbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--bg-sunken); gap: 2px; }
.hbar > span { display: block; height: 100%; min-width: 4px; }
.hbar .ok { background: var(--ok); }
.hbar .warn { background: var(--warn); }
.hbar .err { background: var(--err); }
.hbar .muted { background: var(--border-strong); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-soft); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; background: var(--border-strong); }
.legend i.ok { background: var(--ok); }
.legend i.warn { background: var(--warn); }
.legend i.err { background: var(--err); }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------- 提示 */

.callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid color-mix(in oklab, var(--info) 30%, var(--border));
  background: color-mix(in oklab, var(--info) 6%, var(--bg-elevated));
  font-size: 13px;
}
.callout > svg { margin-top: 1px; color: var(--info); }
.callout-warn {
  border-color: color-mix(in oklab, var(--warn) 35%, var(--border));
  background: color-mix(in oklab, var(--warn) 7%, var(--bg-elevated));
}
.callout-warn > svg { color: var(--warn); }
.callout-err {
  border-color: color-mix(in oklab, var(--err) 35%, var(--border));
  background: color-mix(in oklab, var(--err) 6%, var(--bg-elevated));
}
.callout-err > svg { color: var(--err); }
.callout-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 auto; }
.callout-item { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.callout-item strong { font-weight: 600; }
.callout-item a { font-size: 12.5px; font-weight: 550; white-space: nowrap; }

.error-line {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--err) 8%, transparent);
  color: var(--err);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------- 菜单 */

.menu { position: relative; display: inline-flex; flex: none; }
.menu-pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 180px;
  display: none;
  flex-direction: column;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}
.menu.is-open .menu-pop { display: flex; }
.menu.is-up .menu-pop { top: auto; bottom: calc(100% + 4px); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--bg-hover); outline: none; }
.menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.menu-item svg { color: var(--ink-faint); }
.menu-item.is-danger { color: var(--err); }
.menu-item.is-danger svg { color: currentColor; }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }

/* ------------------------------------------------------------------- 模态框 */

.modal {
  border: none;
  padding: 0;
  background: transparent;
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 48px);
  overflow: visible;
}
.modal.is-wide { width: min(780px, calc(100vw - 32px)); }
.modal::backdrop { background: rgb(10 12 16 / 0.5); backdrop-filter: blur(2px); }
.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}
.modal-card > h2 { padding: var(--space-4) var(--space-5) 0; }
.modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  overflow-y: auto;
  min-height: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --------------------------------------------------------------------- 吐司 */

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 100;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding: 8px 8px 8px 12px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  box-shadow: var(--shadow-2);
  animation: toast-in 0.16s ease;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------------ 空状态 */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-soft);
}
.empty-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-1);
  border-radius: 12px;
  color: var(--ink-faint);
  background: var(--bg-sunken);
}
.empty h3 { color: var(--ink); }
.empty > p { max-width: 460px; }
.empty > .row, .empty > .row-wrap, .empty > .btn { margin-top: var(--space-2); }

/* ------------------------------------------------------------- 代码与复制 */

pre.code {
  margin: 0;
  padding: var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 60vh;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.copy-row { display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.copy-row input { font-family: var(--mono); font-size: 12px; }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklab, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ------------------------------------------------------------ 5 页面特性 */

/* 流量柱状图：用 SVG 绘制，颜色取自主题变量。 */
.traffic { width: 100%; height: 180px; display: block; }

/* 账号额度单元格：数值 + 套餐，纵向紧凑排列。 */
.quota-cell { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.quota-cell strong { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.quota-cell span { font-size: 11.5px; color: var(--ink-faint); }

/* 档位映射：标签 → 请求值，箭头是重点。 */
.variant-map { display: inline-flex; align-items: center; gap: 4px; }
.variant-map .arrow { color: var(--ink-faint); }

/* 日志行：时间 + 内容两栏。 */
.log-line {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-3);
  padding: 6px var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.log-line:last-child { border-bottom: none; }
.log-line:hover { background: var(--bg-hover); }
.log-line .log-time { font-family: var(--mono); color: var(--ink-faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.log-line .log-msg { min-width: 0; overflow-wrap: anywhere; }

/* 登录页：居中卡片。 */
.login { max-width: 380px; margin: 12vh auto; }

/* 节流开关行：标签 + 开关 + 说明。 */
.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ 6 响应式 */

@media (min-width: 1680px) {
  .view { max-width: 1560px; }
  .split { grid-template-columns: minmax(0, 2.2fr) minmax(340px, 1fr); }
}

@media (max-width: 1240px) {
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}

/* 侧边栏转为抽屉。 */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(270px, 84vw);
    height: 100%;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-3);
  }
  .shell.nav-open .sidebar { transform: none; }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgb(10 12 16 / 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .shell.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .btn.menu-toggle { display: inline-flex; }
}

@media (max-width: 680px) {
  .view { padding: var(--space-3); gap: var(--space-3); }
  .topbar { padding: 8px var(--space-3); gap: var(--space-2); }
  .topbar-title p { display: none; }
  .grid-2, .grid-3, .field-row { grid-template-columns: minmax(0, 1fr); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > .stat-cell:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .card-head, .card-body, .card-foot { padding-left: var(--space-3); padding-right: var(--space-3); }
  .log-line { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
  .toolbar > select, .toolbar .toolbar-group > select { flex: 1 1 140px; }
  .modal-card > h2, .modal-body, .modal-actions { padding-left: var(--space-4); padding-right: var(--space-4); }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
