/* ────────────────────────────────────────────────────────────────
   Hy 翻译网关 · 面板样式
   设计令牌对齐 workbuddy2api / Agent2API 面板：
   浅蓝灰侧栏 + 主色实心选中项 + 13px 正文 + 14px 面板圆角。
   ──────────────────────────────────────────────────────────────── */

:root {
  --font-sans: 'Public Sans', 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
  --font-mono: 'SF Mono', Consolas, 'Cascadia Mono', ui-monospace, monospace;

  --bg: oklch(0.978 0.00265 286.35);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.9767 0.00265 286.35);
  --surface-3: oklch(0.95 0 0);
  --surface-inset: oklch(0.93517 0.00535 286.3);
  --row-hover: oklch(0.9767 0.00265 286.35);

  --border: oklch(0.145 0 0 / 10%);
  --border-strong: oklch(0.145 0 0 / 20%);
  --hairline: oklch(0.145 0 0 / 8%);

  --text: oklch(0.145 0 0);
  --text-2: oklch(0.37 0 0);
  --text-3: oklch(0.49 0 0);

  --primary: oklch(0.603 0.218 257.3);
  --primary-hover: oklch(0.543 0.218 257.3);
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
  --primary-fg: oklch(0.48 0.2 257.3);
  --primary-bd: color-mix(in srgb, var(--primary) 28%, white);

  --ok: oklch(0.596 0.145 163.225);
  --ok-soft: color-mix(in srgb, var(--ok) 10%, white);
  --ok-bd: color-mix(in srgb, var(--ok) 28%, white);
  --warn: oklch(0.681 0.162 75.834);
  --warn-soft: color-mix(in srgb, var(--warn) 12%, white);
  --warn-bd: color-mix(in srgb, var(--warn) 32%, white);
  --danger: oklch(0.577 0.245 27.325);
  --danger-soft: color-mix(in srgb, var(--danger) 10%, white);
  --danger-bd: color-mix(in srgb, var(--danger) 28%, white);
  --info: oklch(0.588 0.158 241.966);
  --info-soft: color-mix(in srgb, var(--info) 10%, white);
  --info-bd: color-mix(in srgb, var(--info) 28%, white);

  --control: oklch(0.95815 0 0);
  --control-hover: oklch(0.93214 0.00536 286.3);
  --control-border: oklch(0.145 0 0 / 14%);
  --control-border-hover: oklch(0.145 0 0 / 24%);

  --sidebar-bg: oklch(0.92123 0.0046 258.33);
  --sidebar-border: oklch(0.145 0 0 / 10%);
  --sidebar-fg: oklch(0.43287 0.01676 258.37);
  --sidebar-muted: oklch(0.512 0.02088 261.29);
  --nav-hover: oklch(0.145 0 0 / 5%);

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --shadow-1: 0 1px 2px oklch(0.145 0 0 / 5%);
  --shadow-2: 0 1px 3px oklch(0.145 0 0 / 6%), 0 10px 26px -16px oklch(0.145 0 0 / 20%);
  --shadow-3: 0 2px 8px oklch(0.145 0 0 / 7%), 0 22px 54px -22px oklch(0.145 0 0 / 26%);
  --glow: 0 1px 2px oklch(0.145 0 0 / 6%), 0 10px 22px -12px color-mix(in srgb, var(--primary) 45%, transparent);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);

  --sidebar-w: 216px;
  --topbar-h: 56px;
}

/* 深色：与参考面板同一套 oklch 取值 */
:root[data-theme='dark'] {
  --bg: oklch(0 0 0);
  --surface: oklch(0.19212 0.00399 286.02);
  --surface-2: oklch(0.28254 0.00726 285.93);
  --surface-3: oklch(0.32737 0.0105 285.81);
  --surface-inset: oklch(0.215 0.005 286);
  --row-hover: oklch(0.235 0.005 286);

  --border: oklch(1 0 0 / 10%);
  --border-strong: oklch(1 0 0 / 20%);
  --hairline: oklch(1 0 0 / 8%);

  --text: oklch(0.965 0 0);
  --text-2: oklch(0.85 0 0);
  --text-3: oklch(0.66 0 0);

  --primary: oklch(0.623 0.206 255.3);
  --primary-hover: oklch(0.68 0.206 255.3);
  --primary-soft: oklch(0.623 0.206 255.3 / 15%);
  --primary-fg: oklch(0.75 0.12 255.3);
  --primary-bd: oklch(0.623 0.206 255.3 / 38%);

  --ok: oklch(0.696 0.17 162.48);
  --ok-soft: oklch(0.696 0.17 162.48 / 14%);
  --ok-bd: oklch(0.696 0.17 162.48 / 32%);
  --warn: oklch(0.769 0.188 70.08);
  --warn-soft: oklch(0.769 0.188 70.08 / 14%);
  --warn-bd: oklch(0.769 0.188 70.08 / 32%);
  --danger: oklch(0.704 0.191 22.216);
  --danger-soft: oklch(0.704 0.191 22.216 / 14%);
  --danger-bd: oklch(0.704 0.191 22.216 / 32%);
  --info: oklch(0.613 0.14 239.919);
  --info-soft: oklch(0.613 0.14 239.919 / 14%);
  --info-bd: oklch(0.613 0.14 239.919 / 32%);

  --control: oklch(0.36572 0.0085 285.97);
  --control-hover: oklch(0.40758 0.00993 285.95);
  --control-border: oklch(1 0 0 / 15%);
  --control-border-hover: oklch(1 0 0 / 25%);

  --sidebar-bg: oklch(0.145 0.004 286);
  --sidebar-border: oklch(1 0 0 / 10%);
  --sidebar-fg: oklch(0.85 0.01 258);
  --sidebar-muted: oklch(0.66 0.014 261);
  --nav-hover: oklch(1 0 0 / 6%);

  --shadow-1: 0 1px 2px oklch(0 0 0 / 40%);
  --shadow-2: 0 1px 3px oklch(0 0 0 / 45%), 0 10px 26px -16px oklch(0 0 0 / 60%);
  --shadow-3: 0 2px 8px oklch(0 0 0 / 45%), 0 22px 54px -22px oklch(0 0 0 / 70%);
  --glow: 0 1px 2px oklch(0 0 0 / 40%), 0 10px 22px -12px color-mix(in srgb, var(--primary) 55%, transparent);
}

/* ── 基础 ─────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }

/* 图标是 24×24 的描边图标（symbol/use）。fill/stroke 属于可继承属性，
   写在 svg 上即可透传到 <use> 的影子树里；不写的话默认 fill:black，
   所有图标会变成实心色块。 */
svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--primary-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── 骨架 ─────────────────────────────────────────────────────── */

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 10px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  min-width: 0;
}
.brand-logo {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #9ec5ff));
  color: #fff;
  box-shadow: var(--glow);
}
.brand-logo svg { width: 17px; height: 17px; }
.brand-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 13px; font-weight: 650; white-space: nowrap; }
.brand-text span { font-size: 10.5px; color: var(--sidebar-muted); font-variant-numeric: tabular-nums; }

.nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  padding: 10px 8px 5px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--sidebar-muted);
}
.nav-label:first-child { padding-top: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding: 6px 8px;
  border-radius: var(--r-md);
  color: var(--sidebar-fg);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.25;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--nav-hover); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; box-shadow: 0 1px 2px oklch(0 0 0 / 12%); }
.nav-item svg { width: 15px; height: 15px; flex: 0 0 auto; opacity: .9; }
.nav-item .nav-count {
  margin-left: auto;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  background: oklch(0.145 0 0 / 8%);
  border-radius: 99px;
  padding: 1px 7px;
  color: var(--sidebar-muted);
}
.nav-item.active .nav-count { background: oklch(1 0 0 / 22%); color: #fff; }

.sidebar-foot { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--sidebar-border); }
.side-status {
  border: 1px solid var(--sidebar-border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-radius: var(--r-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
}
.side-status .line { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--sidebar-fg); }
.side-status .line .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.side-status .line .val { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }
.side-user { display: flex; align-items: center; gap: 6px; padding: 0 2px; color: var(--sidebar-muted); font-size: 11.5px; }
.side-user .spacer { flex: 1; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: .12s;
}
.icon-btn:hover { background: var(--nav-hover); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

/* ── 主区 ─────────────────────────────────────────────────────── */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 5;
}
.topbar-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.topbar-title h1 { font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.topbar-title .sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }

.content { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; scroll-behavior: smooth; }
.page { display: none; max-width: 1240px; margin: 0 auto; padding-bottom: 24px; }
.page.active { display: block; animation: page-in .18s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── 卡片 ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hairline);
  min-height: 48px;
}
.card-title { font-size: 13px; font-weight: 600; letter-spacing: -.005em; }
.card-sub { font-size: 11.5px; color: var(--text-3); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

/* ── 统计卡 ───────────────────────────────────────────────────── */

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { padding: 15px 17px 14px; position: relative; overflow: hidden; }
.stat .k { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-3); }
.stat .k svg { width: 13px; height: 13px; }
.stat .v { margin-top: 6px; font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.12; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 4px; }
.stat .sub { margin-top: 4px; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.stat .spark { position: absolute; right: 12px; bottom: 10px; opacity: .5; }

/* ── 图表 ─────────────────────────────────────────────────────── */

.chart { display: flex; align-items: flex-end; gap: 3px; height: 148px; padding-top: 8px; }
.chart .bar-wrap { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; position: relative; min-width: 0; }
.chart .bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 1px 1px;
  background: color-mix(in srgb, var(--primary) 78%, white);
  transition: background .12s;
}
.chart .bar.zero { background: var(--surface-inset); }
.chart .bar.err { background: var(--danger); }
.chart .bar-wrap:hover .bar { background: var(--primary); }
.chart-axis { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--text-3); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ── 表格 ─────────────────────────────────────────────────────── */

.table-scroll { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  font-size: 11px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-family: var(--font-mono); font-size: 11.5px; }
.cell-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cell-main .t1 { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.cell-main .t2 { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.actions { display: flex; gap: 2px; justify-content: flex-end; }

/* ── 徽标 ─────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
}
.badge.ok { background: var(--ok-soft); color: color-mix(in srgb, var(--ok) 82%, black); border-color: var(--ok-bd); }
.badge.err { background: var(--danger-soft); color: color-mix(in srgb, var(--danger) 82%, black); border-color: var(--danger-bd); }
.badge.warn { background: var(--warn-soft); color: color-mix(in srgb, var(--warn) 74%, black); border-color: var(--warn-bd); }
.badge.info { background: var(--info-soft); color: color-mix(in srgb, var(--info) 82%, black); border-color: var(--info-bd); }
.badge.muted { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge.primary { background: var(--primary-soft); color: var(--primary-fg); border-color: var(--primary-bd); }
:root[data-theme='dark'] .badge.ok { color: var(--ok); }
:root[data-theme='dark'] .badge.err { color: var(--danger); }
:root[data-theme='dark'] .badge.warn { color: var(--warn); }
:root[data-theme='dark'] .badge.info { color: var(--info); }

/* ── 按钮 ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--control-border);
  background: var(--control);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn:hover { background: var(--control-hover); border-color: var(--control-border-hover); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: var(--shadow-1); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-bd); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--nav-hover); color: var(--text); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.loading { color: transparent !important; position: relative; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: #fff;
  animation: spin .7s linear infinite;
}
.btn:not(.primary).loading::after { color: var(--text-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 表单 ─────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 10.5px; color: var(--text-3); line-height: 1.5; }
.input, .select, textarea.input {
  height: 32px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; line-height: 1.65; resize: vertical; }
.input:hover, .select:hover { border-color: var(--control-border-hover); }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input.mono { font-family: var(--font-mono); font-size: 12px; }
.select { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 34px; height: 20px; border-radius: 99px; background: var(--surface-inset); border: 1px solid var(--border); transition: .15s; flex: 0 0 auto; position: relative; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px oklch(0 0 0 / 25%); transition: .15s; }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }
.switch .label { font-size: 12.5px; color: var(--text); }

/* ── 页头 ─────────────────────────────────────────────────────── */

.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .txt h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.page-head .txt p { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.page-head .actions { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.toolbar .search { position: relative; flex: 0 1 240px; }
.toolbar .search .input { padding-left: 30px; }
.toolbar .search svg { position: absolute; left: 9px; top: 9px; width: 14px; height: 14px; color: var(--text-3); }
.toolbar .grow { flex: 1 1 auto; }
.filter-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ── 空态 / 提示条 ────────────────────────────────────────────── */

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 30px; height: 30px; opacity: .45; margin-bottom: 10px; }
.empty .t { font-size: 13px; color: var(--text-2); font-weight: 500; }
.empty .d { font-size: 11.5px; margin-top: 4px; }
.empty .btn { margin-top: 14px; }

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.65;
}
.notice svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; color: var(--text-3); }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-bd); color: color-mix(in srgb, var(--warn) 60%, var(--text)); }
.notice.warn svg { color: var(--warn); }
.notice.info { background: var(--info-soft); border-color: var(--info-bd); }
.notice.info svg { color: var(--info); }

/* ── 调试台 ───────────────────────────────────────────────────── */

.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-inset); border-radius: 9px; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border: 0; background: transparent; border-radius: 7px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.tab svg { width: 14px; height: 14px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.pg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.pg-input textarea { min-height: 210px; font-size: 13px; }
.pg-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--text-3); }
.pg-out {
  min-height: 210px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 420px;
}
.pg-out:empty::before { content: '译文会出现在这里'; color: var(--text-3); font-size: 12.5px; }
.pg-out.streaming::after { content: '▍'; color: var(--primary); animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.pg-bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.counter { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-left: auto; }
.counter.over { color: var(--danger); font-weight: 600; }

.curl {
  position: relative;
  background: var(--surface-inset);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre;
}
.curl .copy { position: absolute; top: 6px; right: 6px; }

.img-drop {
  border: 1.5px dashed var(--control-border);
  border-radius: var(--r-md);
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: .15s;
  font-size: 12px;
}
.img-drop:hover, .img-drop.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-fg); }
.img-drop > svg { width: 26px; height: 26px; opacity: .6; }
.img-preview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.img-preview figure { margin: 0; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); }
.img-preview figcaption { padding: 6px 9px; font-size: 11px; color: var(--text-3); border-bottom: 1px solid var(--hairline); }
.img-preview img { display: block; width: 100%; height: auto; max-height: 320px; object-fit: contain; }

/* ── 密钥卡 / 代码块 ──────────────────────────────────────────── */

.key-reveal {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--primary-bd);
  background: var(--primary-soft);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--primary-fg);
  word-break: break-all;
}
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 7px 14px; font-size: 12.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

/* ── 对话框 ───────────────────────────────────────────────────── */

.dialog-mask {
  position: fixed;
  inset: 0;
  background: oklch(0 0 0 / 42%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
  animation: mask-in .14s ease both;
}
@keyframes mask-in { from { opacity: 0; } }
.dialog {
  width: min(480px, 100%);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: dialog-in .18s cubic-bezier(.2, .9, .3, 1) both;
}
.dialog.wide { width: min(620px, 100%); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { padding: 16px 18px 12px; display: flex; align-items: flex-start; gap: 10px; }
.dialog-head h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.dialog-head p { margin-top: 3px; font-size: 11.5px; color: var(--text-3); }
.dialog-head .icon-btn { margin-left: auto; }
.dialog-body { padding: 4px 18px 16px; overflow-y: auto; }
.dialog-foot { padding: 12px 18px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* ── 吐司 ─────────────────────────────────────────────────────── */

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  min-width: 220px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  font-size: 12.5px;
  line-height: 1.5;
  animation: toast-in .18s cubic-bezier(.2, .9, .3, 1) both;
  pointer-events: auto;
}
.toast.out { animation: toast-out .16s ease both; }
.toast svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }
.toast.info svg { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ── 登录 ─────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 70%),
    var(--bg);
}
.login-card {
  width: min(372px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 28px 26px 24px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.login-brand .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
.login-card h1 { font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.login-card .tip { margin: 6px 0 18px; font-size: 12px; color: var(--text-3); line-height: 1.65; }
.login-card .input { height: 38px; font-size: 13px; }
.login-card .btn { height: 38px; margin-top: 12px; font-size: 13px; }
.login-err { margin-top: 10px; font-size: 12px; color: var(--danger); min-height: 18px; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--hairline); font-size: 11px; color: var(--text-3); line-height: 1.6; }

/* ── 进度条 / 仪表 ────────────────────────────────────────────── */

.meter { height: 4px; border-radius: 99px; background: var(--surface-inset); overflow: hidden; width: 72px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--danger); }

/* ── 工具类 ───────────────────────────────────────────────────── */

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-3); }
.small { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.hidden { display: none !important; }
.center { text-align: center; }

/* ── 响应式 ───────────────────────────────────────────────────── */

@media (max-width: 1120px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .pg-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 64px; --topbar-h: 52px; }
  .brand { justify-content: center; padding-bottom: 10px; }
  .brand-text, .nav-label, .nav-item span.label, .side-status, .side-user .who { display: none; }
  .nav-item { justify-content: center; padding: 7px 0; }
  .nav-item .nav-count { display: none; }
  .sidebar { padding: 12px 8px 8px; }
  /* rail 模式只有 48px 可用宽度：底部两个按钮并排会被主区盖住，改成竖排 */
  .side-user { flex-direction: column; gap: 2px; padding: 0; }
  .side-user .dot, .side-user .who, .side-user .spacer { display: none; }
  .side-user .icon-btn { width: 100%; height: 28px; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .topbar-title .sub { display: none; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .img-preview { grid-template-columns: minmax(0, 1fr); }
  .page-head .txt h2 { font-size: 17px; }
  .toolbar .search { flex: 1 1 100%; }
  .topbar-actions .btn span { display: none; }
}
