/* =====================================================================
   TokenMark 共享设计系统（UI-DESIGN.md D1：原生无构建）
   复用 public/index.html 的 CSS 变量，保证营销页 / 管理后台 / 客户门户
   三套界面品牌一致。**v2：所有界面统一为浅色主题**（白底深字，对齐 marketing 站）。

   排版规范（对齐 docs/UI-IA-SPEC.md §3 设计系统）：
   - 间距节奏：4px 基准（--sp-1..--sp-7），区块纵向节奏 16px / 24px
   - 圆角：卡片 14px，按钮/输入 10px，徽标/胶囊 999px
   - 阴影：卡片用 --shadow-sm，浮层（弹窗/选择器）用 --shadow-md
   - 层级：h1(22) > panel h2(16) > body(14) > 辅助(12.5) > 脚注(11.5)
   ===================================================================== */
:root {
  /* 色彩（浅色主题 v2） */
  --bg: #ffffff;                /* 主背景 白 */
  --bg-2: #f7f8fa;              /* 侧栏 / 次级背景 浅灰 */
  --surface: #ffffff;           /* 面板 白 */
  --surface-2: #f1f3f6;         /* 输入 / 次级面板 浅灰 */
  --border: #e5e7eb;            /* 边框 浅灰 */
  --border-2: #d1d5db;
  --text: #1a2233;              /* 主文字 深蓝近黑 */
  --muted: #6b7280;             /* 辅助文字 灰 */
  --faint: #9ca3af;             /* 更弱辅助文字 浅灰 */
  --accent: #4f8cff;            /* 主强调色 蓝（保持品牌色） */
  --accent-2: #7c5cff;
  --primary: var(--accent);
  --accent-soft: rgba(79, 140, 255, 0.10);
  --accent-border: rgba(79, 140, 255, 0.28);
  /* 悬浮 tooltip 专用：实色不透明浅蓝，彻底挡住卡片底层文字（之前 18% alpha 仍透字重叠）；
     边框用品牌实色蓝，清晰区分弹窗边界 */
  --tooltip-bg: #dde8ff;
  --tooltip-border: #4f8cff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #2563eb;

  /* 圆角 */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  /* 阴影（浅色 → 用浅色阴影） */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);

  /* 间距（4px 基准） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --topnav-h: 76px;
}

/* 深色主题：覆盖变量即可，组件样式零改动 */
[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-2: #11151f;
  --surface: #151a23;
  --surface-2: #1d2430;
  --border: #232a36;
  --border-2: #2e3744;
  --text: #e6eaf2;
  --muted: #9aa4b2;
  --faint: #6b7280;
  --accent: #5b9bff;
  --accent-2: #a48bff;
  --accent-soft: rgba(91, 155, 255, 0.14);
  --accent-border: rgba(91, 155, 255, 0.35);
  /* 深色模式 tooltip：实色深蓝 + 实色蓝边，深底上稳定可见 */
  --tooltip-bg: #1e2d4a;
  --tooltip-border: #5b9bff;
  --green: #4ade80;
  --red: #ff6b6f;
  --amber: #f5b042;
  --blue: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

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

.mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* 全局细滚动条（深色下更精致） */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-2); background-clip: padding-box; }

/* ---------- 应用骨架（顶部一级栏 + 侧栏二级 + 主区） ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* 顶部横排一级目录栏（v3：与 marketing 站首页顶栏完全对齐） */
.topnav {
  height: var(--topnav-h);
  flex: 0 0 var(--topnav-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}
.topnav .brand {
  display: flex; align-items: center;
  text-decoration: none;
  cursor: pointer;
}
.topnav .brand:hover { opacity: .85; }
.topnav .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.topnav .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.topnav .brand .logo img { width: 100%; height: 100%; display: block; }
/* 横向版 Logo（标准源 SVG，由 CSS 显示尺寸控制；与首页 48px 完全一致） */
.topnav .brand .logo-horizontal {
  height: 48px; width: auto; display: block;
}
.topnav .toplevel {
  display: flex; align-items: center; gap: 2px;
  flex: 0 1 auto;
  margin-left: 8px;
  overflow-x: auto;
}
.topnav .toplevel a {
  padding: 8px 14px; border-radius: 10px;
  color: var(--muted); font-size: 15px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.topnav .toplevel a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav .toplevel a.active { color: var(--text); background: transparent; box-shadow: none; font-weight: 500; }
/* 右侧身份/操作区不可被压缩：基础规则默认 flex-shrink:1，窄屏（实测 561~860px）时它被
   `.toplevel` 挤出宽度，按钮文字折成多行把盒子撑到 92px（顶栏固定 76px）→ 上下都溢出。
   固定 `flex: 0 0 auto` 后，宽度不足由 `.toplevel` 自己横向滚动承担（它本就 overflow-x:auto）。 */
.topnav .topnav-right { margin-left: auto; flex: 0 0 auto; display: flex; align-items: center; gap: 20px; }

/* 主题切换器（纯文字三段，无图标；激活态加粗，风格与全站一致） */
.theme-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.theme-switch button { border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-family: inherit; transition: background-color .15s, color .15s; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: var(--shadow-sm); }

/* 身份胶囊（顶部栏右侧昵称） */
.who {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* ---------- 中间层：侧栏 + 主区（flex 行） ---------- */
.layout { display: flex; flex: 1 1 auto; min-height: 0; }

/* 侧栏（仅当前域二级子目录） */
.sidebar {
  width: 228px;
  flex: 0 0 228px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topnav-h);
  height: calc(100vh - var(--topnav-h));
  overflow-y: auto;
}
.sidebar .sg {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--faint); margin: 4px 12px 10px; font-weight: 600;
}
.sidebar .subnav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .s-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  text-decoration: none; margin-bottom: 2px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.sidebar .s-item:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sidebar .s-item.active {
  color: var(--text); font-weight: 600;
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar .s-item .ic { width: 18px; text-align: center; }

/* ---------- 侧边栏底部 ---------- */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-home-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-legal {
  margin-top: 8px;
  padding: 0 14px;
  font-size: 11.5px;
  color: var(--faint);
}
.sidebar-legal a {
  color: var(--muted);
  text-decoration: none;
}
.sidebar-legal a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---------- 主内容区（居中限宽，内部滚动） ---------- */
.main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 56px;
  display: flex;
  flex-direction: column;
}
/* 单级域（无侧栏）时内容区更宽 */
.main.no-sidebar { max-width: 1520px; }
#view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---------- 卡片 / 面板 ---------- */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
}
.panel { margin-bottom: 16px; }
.panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 650; letter-spacing: -.1px; }
.panel h3 { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); font-weight: 600; }

.cards-grid {
  display: grid; gap: 14px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.cards-grid.two-col { grid-template-columns: 1fr 1fr; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 页签 / 告警条 ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  padding: 8px 15px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
  font-family: inherit; transition: border-color .15s, color .15s, background .15s;
}
.tab:hover { border-color: var(--accent-border); color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(79,140,255,.3); }
.alert-bar { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; font-weight: 600; }
.alert-bar.red { background: rgba(255,93,108,.1); border: 1px solid rgba(255,93,108,.4); color: #ff9b9b; }
.alert-bar.green { background: rgba(61,220,132,.1); border: 1px solid rgba(61,220,132,.4); color: #8be0a8; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-size: 12.5px; word-break: break-all; }
/* 时间戳等定长内容：必须横向一行完整展示，不参与折行 */
.table .mono.nowrap { white-space: nowrap; word-break: normal; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
/* 紧凑表（行高小、按钮组不换行）：多列表格用，如供应商 11 列 */
.table.dense th, .table.dense td { padding: 6px 10px; font-size: 13px; }
.table.dense th { font-size: 11px; }
.table.dense .btn-row { flex-wrap: nowrap; gap: 6px; }

/* Key 列表优化 */
.keys-table th, .keys-table td { vertical-align: middle; }
.keys-table th.actions-cell,
.keys-table td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.keys-table th.label-cell,
.keys-table td.label-cell { min-width: 120px; max-width: 220px; }
.keys-table td.label-cell { font-weight: 600; font-size: 14px; word-break: break-all; }
.keys-table th.key-cell,
.keys-table td.key-cell { min-width: 180px; }
.keys-table th.points-cell,
.keys-table td.points-cell { width: 1%; white-space: nowrap; text-align: right; }
.keys-table th.validity-cell,
.keys-table td.validity-cell { width: 1%; white-space: nowrap; }
.keys-table th.ip-cell,
.keys-table td.ip-cell { width: 1%; min-width: 80px; max-width: 140px; }
.keys-table td.ip-cell .ip-pill { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-value-wrap { display: flex; align-items: center; gap: 6px; }
.key-value-wrap .mono { font-size: 12px; color: var(--muted); word-break: break-all; }
.actions-cell { white-space: nowrap; }
.action-links { display: inline-flex; align-items: center; }
.action-links a { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.action-links a:hover { color: var(--accent); text-decoration: underline; }
.action-links a.danger { color: var(--red); }
.action-links a.danger:hover { color: #ff7a85; }
.action-links a + a::before { content: '|'; margin: 0 10px; color: var(--border); pointer-events: none; }
.points-cell .limit-wrap { display: inline-flex; align-items: center; gap: 8px; }
.points-cell .inline-action { font-size: 12px; color: var(--muted); text-decoration: none; }
.points-cell .inline-action:hover { color: var(--accent); text-decoration: underline; }
/* 移动端：表格横向滚动，避免窄屏挤压列 / 整页横向溢出 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table { min-width: 560px; }
.keys-table { min-width: 720px; }
/* 调用日志：列多，保证时间列横向完整展示（窄屏靠横向滚动，不挤压折行） */
.logs-table { min-width: 900px; }

/* 扣费分解行内展开（transactions.billing_breakdown 不可变快照，admin 调用日志/客户详情共用） */
.billing-detail-row > td { background: var(--surface-2); padding: 10px 14px; }
.bd-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 4px 24px;
  border-left: 3px solid var(--accent-border);
  padding: 2px 0 2px 12px;
  font-size: 12.5px;
  color: var(--text);
}
/* 允许换行：早前 white-space:nowrap 会让超出单元格的长行（缓存分段/缓存单价/缓存让利）
   溢出格子盖住邻列文字（2026-09-20 修复）。 */
.bd-line { line-height: 1.75; white-space: normal; overflow-wrap: break-word; }
.bd-k { display: inline-block; min-width: 78px; color: var(--muted); }
.bd-muted { color: var(--faint); font-size: 11.5px; }
/* 长文本行独占整行（缓存分段/缓存单价/缓存让利等带长括注的行） */
.bd-wide { grid-column: 1 / -1; }
.bd-sum { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: 6px; margin-top: 2px; }
.bd-formula {
  grid-column: 1 / -1;
  color: var(--muted); font-size: 11.5px; line-height: 1.6; white-space: normal;
  border-top: 1px dashed var(--border); padding-top: 6px;
}

/* 模型管理表格 */
.models-table { min-width: 560px; }
.models-table th, .models-table td { vertical-align: middle; }
.models-table td:first-child, .models-table th:first-child { white-space: nowrap; word-break: normal; min-width: 140px; }
.models-table td.scope-cell, .models-table th.scope-cell { white-space: nowrap; }
/* 模型目录：除「模型」列外居中 */
.models-table th, .models-table td { text-align: center; }
.models-table th.left, .models-table td.left { text-align: left; }
.models-table .mname { font-weight: 600; color: var(--text); }
.models-table .mid { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; display: block; }
.models-table .model-list-name { line-height: 1.35; }
.models-table .model-list-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  white-space: normal;
}
.models-table .model-list-tag {
  display: inline-flex;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
}
/* 模型目录：启用/停用开关 */
.switch { display: inline-block; width: 32px; height: 18px; border-radius: 999px; background: var(--border-2); position: relative; cursor: pointer; transition: background .15s, box-shadow .15s; vertical-align: middle; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 16px; }
.switch:hover { box-shadow: 0 0 0 3px rgba(61,220,132,.18); }
.switch:not(.on):hover { background: #465061; }
/* 模型目录：行内展开详情 */
.models-table tr.mrow { cursor: pointer; }
.models-table tr.mexp > td { padding: 0; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.models-table .mexp-body { padding: 16px 20px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; text-align: left; }
.models-table .mexp-body .k { font-size: 11px; color: var(--faint); margin-bottom: 4px; }
.models-table .mexp-body .v { font-size: 13px; color: var(--text); }
.models-table .mexp-acts { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--border); }
.margin.high { color: var(--green); font-weight: 600; }
.margin.mid { color: var(--amber); font-weight: 600; }
.margin.low { color: var(--red); font-weight: 600; }
/* 毛利/倍率单元格：用 inline-flex 让粗体数字与同行常规字精确居中（规避 font-weight:600 character box 视觉下沉） */
.models-table td.margin, .models-table td.mult { padding: 0 !important; vertical-align: middle; }
.models-table td.mult { font-weight: 500; color: var(--text); }
.models-table .m-val { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 4px; line-height: 1; font-weight: 600; }
.models-table .m-val.high { color: var(--green); }
.models-table .m-val.mid { color: var(--amber); }
.models-table .m-val.low { color: var(--red); }
/* 启用状态文字（行内只读展示；调整放展开区） */
.status-text { font-weight: 500; font-size: 13px; }
.status-text.on { color: var(--green); }
.status-text.off { color: var(--muted); }

/* ---------- 表单 / 输入 / 按钮 ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.form .row { display: grid; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); }
.form .help { font-size: 12px; color: var(--faint); margin-top: 2px; }
/* 分组头（openModal 的 section 字段类型）：把平铺字段按职责分区 */
.form .form-sec { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--text); }
.form .form-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form .form-sec .form-sec-sub { display: block; font-weight: 400; color: var(--faint); margin-top: 2px; }
/* 必填标记与行内错误提示（通用模态表单） */
.form label .req { color: var(--red); margin-left: 2px; font-weight: 600; }
.form .row input.err, .form .row select.err, .form .row textarea.err { border-color: var(--red); }
.form .field-err { color: var(--red); font-size: 12px; margin-top: 3px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 14px; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.textarea { min-height: 78px; resize: vertical; font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--text); }
.checkbox input { width: 16px; height: 16px; min-width: 16px; min-height: 16px; flex: 0 0 16px; accent-color: var(--accent); margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
}
.btn:hover { border-color: var(--accent-border); box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff;
  box-shadow: 0 2px 10px rgba(79, 140, 255, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 4px 16px rgba(79, 140, 255, 0.36); }
.btn.danger { color: var(--red); border-color: rgba(255,93,108,.4); }
.btn.danger:hover { background: rgba(255,93,108,.12); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 个人资料页 ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 980px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-grid .panel {
  margin-bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.profile-grid .panel > .profile-section:last-child { margin-bottom: 0; flex: 1 1 auto; }

.profile-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; flex: 0 0 52px;
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.3);
}
.profile-meta { flex: 1 1 auto; min-width: 0; }
.profile-meta .name { font-size: 16px; font-weight: 600; }
.profile-meta .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.profile-section { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.profile-section.first { border-top: none; padding-top: 0; margin-top: 0; }
.profile-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--text); font-weight: 600; }
.profile-section h3.muted { color: var(--muted); }

.profile-edit-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.input.readonly {
  background: transparent; border-color: transparent; padding-left: 0;
  color: var(--muted); cursor: default;
}
.input.readonly:focus { border-color: transparent; box-shadow: none; }

.profile-hint { font-size: 12px; color: var(--faint); margin-top: 4px; line-height: 1.45; }
.profile-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.profile-actions + .profile-actions { margin-top: 10px; }
.form.compact { gap: 12px; max-width: none; }

.info-list { display: flex; flex-direction: column; gap: 16px; }
.info-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.info-main { display: flex; flex-direction: column; gap: 4px; }
.info-label { font-size: 12.5px; color: var(--muted); }
.info-value { font-size: 14.5px; color: var(--text); font-weight: 500; }
.info-value.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }

/* ---------- 徽章 / 状态 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.badge.on { color: var(--green); border-color: rgba(22,163,74,.35); background: rgba(22,163,74,.08); }
.badge.off { color: var(--red); border-color: rgba(220,38,38,.35); background: rgba(220,38,38,.08); }
.badge.warn { color: var(--amber); border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.08); }
/* 多供应商徽标：模型目录两视图里标识「另有 N 家供应商也在卖」 */
.sup-multi { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11px; line-height: 16px; border-radius: 999px; color: var(--accent); border: 1px solid rgba(90,120,180,.35); background: rgba(90,120,180,.10); white-space: nowrap; flex-shrink: 0; vertical-align: middle; }
/* 归属标记：供应商视图里「本家仅供货、目录归属在别家」的模型，用中性灰 ↳ 归属 X 提示 */
.sup-owner { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11px; line-height: 16px; border-radius: 999px; color: var(--muted); border: 1px solid rgba(140,140,150,.30); background: rgba(140,140,150,.10); white-space: nowrap; flex-shrink: 0; vertical-align: middle; }
/* 供给数小字：供应商列表「模型数」列里目录归属数之外的「供 N」（真实供给，含转供+隐藏 down） */
.sup-supply { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: middle; }

/* 供应商列表：压缩信息列，右侧操作始终可见。
   操作列宽度 = 5 个 .btn.sm（编辑/轮换/同步/迁移模型/删除）实测内容宽 234px + dense 单元格左右内边距 20px，
   取 256px 留一点余量 —— 加宽它是 2026-09-20「上游密钥」页合并进来后多出的「轮换」按钮，不是随手调的。 */
.sup-table-scroll { position: relative; }
.sup-table { table-layout: fixed; min-width: 800px; }
.sup-table th, .sup-table td { vertical-align: middle; }
.sup-table .sup-table-id { width: 122px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-table .sup-table-name { width: 112px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-table .sup-table-kind { width: 70px; white-space: nowrap; }
.sup-table .sup-table-url { width: auto; min-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sup-table .sup-table-health { width: 62px; white-space: nowrap; }
.sup-table .sup-table-count { width: 82px; white-space: nowrap; }
.sup-table .sup-table-price { width: 96px; white-space: nowrap; }
.sup-table .sup-table-rate { width: 52px; white-space: nowrap; }
.sup-table .sup-table-actions {
  position: sticky; right: 0; z-index: 2; width: 256px; min-width: 256px;
  white-space: nowrap; background: var(--surface);
  box-shadow: -10px 0 16px -14px rgba(0,0,0,.8);
}
.sup-table thead .sup-table-actions { z-index: 3; }
.sup-table tbody tr:hover .sup-table-actions { background: var(--surface-2); }
.sup-table-actions-inner { display: inline-flex; align-items: center; gap: 4px; }
.sup-table-actions-inner .btn.sm { padding: 4px 7px; font-size: 11.5px; }

/* 密钥体检（原「上游密钥」页顶部的配置率总览，2026-09-20 合并进供应商页）：
   页头一行摘要 + 轮换弹窗里的通道 Key 列表。未配主 Key 是硬故障，用红字而不是普通 muted。 */
.sup-key-summary { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sup-key-summary b { font-weight: 500; color: var(--text); }
.sup-key-summary b.ok { color: var(--green); }
.sup-key-summary b.miss { color: var(--red); }
.sup-ch-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }

/* 模型统计区一级 summary 标题颜色（健康绿 / 异常赤 / 未测中性） */
.stat-summary > summary b.t-healthy { color: var(--green); }
.stat-summary > summary b.t-unknown { color: var(--muted); }
.stat-summary > summary b.t-issue { color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tag.green { color: var(--green); border-color: rgba(61,220,132,.4); }
.tag.red { color: var(--red); border-color: rgba(255,93,108,.4); }
.tag.blue { color: var(--accent); border-color: rgba(79,140,255,.4); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(3,6,12,.68);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 18px; }
.modal .close:hover { color: var(--text); }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 22px; right: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.ok {
  border-left-color: var(--green);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(61,220,132,.15);
}
.toast.err {
  border-left-color: var(--red);
  background: rgba(255,93,108,.08);
  color: #ffb3b9;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,93,108,.2);
  font-weight: 600;
}

/* ---------- 找回密码步骤指示器 ---------- */
.ff-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 16px 0 24px;
}
.ff-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: .4;
  transition: opacity .3s;
}
.ff-step.active { opacity: 1; }
.ff-step.done { opacity: .7; }
.ff-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: all .3s;
}
.ff-step.active .ff-step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(79,140,255,.5);
}
.ff-step.done .ff-step-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.ff-step-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ff-step.active .ff-step-label { color: var(--accent); font-weight: 600; }
.ff-step.done .ff-step-label { color: var(--green); }
.ff-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 40px;
  max-width: 60px;
  margin-bottom: 16px;
  transition: background .3s;
}

/* ---------- 登录屏 ---------- */
.login-wrap { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login {
  width: 100%; max-width: 460px; padding: 36px 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.login .brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login .brand .logo { width: 28px; height: 28px; border-radius: 8px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }

/* ---------- 图表 ---------- */
.chart { width: 100%; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.profit { fill: var(--green); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dotpt { fill: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .main { max-width: none; }
  .main.no-sidebar { max-width: none; }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .topnav { padding: 0 14px; gap: 12px; }
  .topnav .toplevel { gap: 2px; }
  .topnav .toplevel a { padding: 8px 10px; font-size: 13px; }
  .topnav-right .btn.sm { padding: 5px 9px; font-size: 12.5px; }
  .sidebar {
    width: 100%; flex-basis: auto; height: auto; position: static;
    display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; align-items: center;
  }
  .sidebar .sg { display: none; }
  .sidebar .subnav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sidebar .s-item { margin: 0; padding: 8px 10px; }
  .sidebar-footer { display: none; }
  .chat-sidebar { flex-basis: 200px; max-width: 200px; }
  .chat-main { padding: 12px 14px; }
  .main { padding: 20px 18px 50px; }
}
@media (max-width: 560px) {
  .cards-grid { grid-template-columns: 1fr; }
  .cards-grid.two-col { grid-template-columns: 1fr; }
  .btn-row { gap: 8px; }
  .main { padding: 16px 12px 40px; }
  .card, .panel { padding: 14px 16px; }
  .panel h2 { font-size: 15px; margin-bottom: 12px; }
  /* 窄屏顶栏换成两行（品牌行 + 一级目录行），必须显式放开基础规则的固定 `flex: 0 0 var(--topnav-h)`：
     flex-basis 不是 auto 时 `height: auto` 不参与主轴计算，盒子会被钉死在 76px，
     实测内容 156px 溢出 81px 盖在正文上（顶栏是 sticky + z-index:40）。
     2026-09-27：改为 flex-basis:auto，让盒子随换行后的内容自然增高。 */
  .topnav { flex: 0 0 auto; height: auto; min-height: 60px; flex-wrap: wrap; padding: 8px 12px; }
  .topnav .brand { font-size: 15px; }
  .topnav .toplevel { order: 3; width: 100%; flex-basis: 100%; padding-top: 4px; border-top: 1px solid var(--border); }
  .sidebar { padding: 8px 12px; }
  .sidebar .s-item { padding: 6px 8px; font-size: 12.5px; }
  .modal-mask { padding: 12px; }
  .modal { padding: 18px; }
  /* chat */
  .chat-app { flex-direction: column; }
  .chat-sidebar { flex: none; max-width: none; border-right: none; border-bottom: 1px solid var(--border); }
  .chat-sidebar-list { max-height: 132px; }
  .chat-usage { border-bottom: 1px solid var(--border); }
  .chat-main { padding: 12px 14px; }
  .chat-toolbar { gap: 8px; }
  .chat-toolbar .select { min-width: 0; flex: 1 1 120px; font-size: 13px; }
  .chat-toolbar .input { min-width: 0; flex: 1 1 100%; font-size: 13px; }
  .chat-bal { font-size: 12px; padding: 5px 10px; flex: 1 1 auto; text-align: center; }
  .chat-toolbar .btn.sm { padding: 5px 10px; font-size: 12px; }
  .chat-input { gap: 8px; padding-top: 10px; }
  .chat-input .textarea { padding: 12px 14px; font-size: 16px; }
  .chat-input .send { width: 48px; height: 48px; }
  .bubble { font-size: 15px; padding: 10px 12px; }
  /* Key 列表在手机上进一步紧凑：隐藏 IP 列、减小列宽、操作换行 */
  .keys-table { min-width: 0; }
  .keys-table th.key-cell,
  .keys-table td.key-cell { min-width: 0; }
  .keys-table th.label-cell,
  .keys-table td.label-cell { min-width: 80px; max-width: 140px; }
  .keys-table th.ip-cell,
  .keys-table td.ip-cell { display: none; }
  .keys-table .action-links { flex-direction: column; align-items: flex-start; gap: 4px; }
  .keys-table .action-links a + a::before { content: none; }
  .key-ops-help { font-size: 12px; padding: 10px 12px; }
  /* 模型管理：手机上隐藏厂家与单价列，模型 ID 不再被挤成竖排 */
  .table-scroll > .table.models-table { min-width: 0; }
  .models-table th.vendor-cell,
  .models-table td.vendor-cell,
  .models-table th.price-cell,
  .models-table td.price-cell { display: none; }
  .models-table td:first-child, .models-table th:first-child { min-width: 0; }
  .stat .hint { display: none; }
}

/* ---------- 客户注册引导 ---------- */
.auth-lead { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.7; }
.auth-lead b { color: var(--accent); }
.reg-steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.reg-step { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.reg-step .n { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }

/* ---------- 对话（Chat） ---------- */
.chat-app { display: flex; flex-direction: row; align-items: stretch; height: 100%; max-height: 100%; overflow: hidden; }
.chat-sidebar { flex: 0 0 248px; max-width: 248px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); overflow: hidden; min-height: 0; }
.chat-sidebar-head { display: block; padding: 12px 12px 4px; }
.chat-sidebar-title { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; padding: 8px 14px 2px; text-transform: uppercase; letter-spacing: .5px; }
.chat-new-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 10px 12px; font-size: 14px; font-weight: 600; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 9px; cursor: pointer; transition: filter .15s, transform .1s; }
.chat-new-btn:hover { filter: brightness(1.06); }
.chat-new-btn:active { transform: scale(.98); }
.chat-new-plus { font-size: 16px; line-height: 1; font-weight: 700; }
/* 旧类保留：无 JS 引用残留（chat-sidebar-new 已由 chat-new-btn 取代） */
.chat-usage { padding: 4px 14px 10px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-sidebar-list { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 8px; overscroll-behavior: contain; }
.chat-sidebar-empty { padding: 18px 12px; font-size: 12px; color: var(--muted); text-align: center; }
.chat-conv { display: flex; width: 100%; align-items: flex-start; gap: 6px; padding: 9px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; margin-bottom: 2px; transition: background .12s, border-color .12s; }
.chat-conv:hover { background: var(--surface-2); }
.chat-conv.on { background: var(--surface-2); border-color: var(--border); }
.chat-conv-main { flex: 1 1 auto; min-width: 0; text-align: left; border: 0; padding: 0; background: transparent; cursor: pointer; color: inherit; font: inherit; }
.chat-conv .chat-conv-title { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv .chat-conv-meta { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.chat-conv .chat-conv-pin { color: var(--accent); font-weight: 700; }
.chat-conv-actions { display: none; gap: 4px; flex: 0 0 auto; align-self: flex-start; padding-top: 4px; }
.chat-conv:hover .chat-conv-actions,
.chat-conv:focus-within .chat-conv-actions { display: inline-flex; }
.chat-conv-action { font-size: 11px; padding: 3px 7px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 5px; cursor: pointer; font-family: inherit; line-height: 1.2; white-space: nowrap; }
.chat-conv-action:hover { color: var(--text); border-color: var(--accent); }
.chat-conv-action.danger:hover { color: var(--red); border-color: var(--red); }
.chat-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 16px 18px; overflow: hidden; min-height: 0; }
.chat-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.chat-toolbar .select { width: auto; min-width: 150px; }
.chat-toolbar .input { width: auto; min-width: 0; flex: 1 1 320px; }
.chat-toolbar .spacer { flex: 1; }
.chat-bal { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 7px 13px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-bal b { color: var(--text); }
.chat-msgs { flex: 1 1 auto; overflow-y: auto; padding: 8px 4px 16px; display: flex; flex-direction: column; gap: 16px; }
.bubble { max-width: 80%; padding: 12px 15px; border-radius: 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; box-shadow: var(--shadow-sm); }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .role { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.bubble.assistant .role { color: var(--accent); }
.bubble .usage { margin-top: 8px; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; font-variant-numeric: tabular-nums; }
.bubble .msg-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.bubble .msg-act { font-size: 12px; padding: 4px 10px; border: 1px solid var(--border); background: transparent; color: var(--muted); border-radius: 5px; cursor: pointer; transition: all .12s ease; display: inline-flex; align-items: center; gap: 5px; }
.bubble .msg-act-icon { flex: 0 0 auto; }
.bubble .msg-act:hover { color: var(--text); background: var(--surface-2); border-color: var(--accent); }
.bubble .md { white-space: normal; }
.bubble .md p { margin: 0 0 8px; }
.bubble .md p:last-child { margin-bottom: 0; }
.bubble .md h1, .bubble .md h2, .bubble .md h3 { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.bubble .md ul, .bubble .md ol { margin: 0 0 8px; padding-left: 20px; }
.bubble .md li { margin-bottom: 4px; }
.bubble .md strong { font-weight: 600; }
.bubble .md table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 13.5px; border: 1px solid var(--border); }
.bubble .md table:last-child { margin-bottom: 0; }
.bubble .md th, .bubble .md td { padding: 8px 10px; text-align: left; border: 1px solid var(--border); vertical-align: top; }
.bubble .md thead { background: var(--surface-2); }
.bubble .md th { font-weight: 600; color: var(--text); }
.bubble .md tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 360px; }
.chat-empty h3 { color: var(--text); font-size: 17px; margin: 0 0 8px; }
.chat-input { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 16px; }
.chat-input .textarea { flex: 1; min-height: 56px; max-height: 160px; padding: 15px 18px; border-radius: var(--radius); line-height: 1.5; font-size: 14px; }
.chat-input .send {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.35);
}
.chat-input .send:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 140, 255, 0.45); }
.chat-input .send:disabled { opacity: 0.6; transform: none; box-shadow: none; }
.bubble.chat-typing::after { content: '▋'; margin-left: 2px; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
/* ---------- 对话页模型选择器（POE 风格） ---------- */
.chat-model-bar { position: relative; display: flex; align-items: center; margin: 0 0 10px; }
.model-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 13px; font-size: 13.5px; cursor: pointer;
  transition: border-color .15s, background .15s; max-width: 100%;
  box-shadow: var(--shadow-sm);
}
.model-trigger:hover { border-color: var(--accent); background: var(--surface-2); }
.model-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-trigger-icon {
  width: 18px; height: 18px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 14px; line-height: 1;
}
.model-trigger-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.model-trigger-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-trigger-caret { color: var(--muted); flex: 0 0 auto; }
.model-picker {
  position: fixed;
  width: 380px; max-width: calc(100vw - 48px);
  /* 重做悬浮窗底色：整面板淡 accent tint + 顶部 accent 渐变（覆盖 head 区）+ 品牌描边，深浅色自适应 */
  background:
    linear-gradient(180deg, var(--accent-soft) 0%, color-mix(in srgb, var(--accent) 6%, var(--surface)) 72px),
    color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 100; display: none; overflow: hidden;
}
.model-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; color: var(--text);
}
.model-picker-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.model-picker-close:hover { color: var(--text); }
.model-picker-search { padding: 8px 12px 6px; border-bottom: 1px solid var(--border); }
.model-picker-search input {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; font-size: 13.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.model-picker-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.model-picker-search input::placeholder { color: var(--muted); }
.model-picker-body { max-height: 280px; overflow-y: auto; padding: 6px; }
.model-picker-empty { padding: 18px 12px; color: var(--muted); text-align: center; font-size: 13.5px; }
.model-group { margin-bottom: 6px; }
.model-group:last-child { margin-bottom: 0; }
.model-group-title {
  padding: 8px 10px 6px; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
.model-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 11px; margin-bottom: 3px; cursor: pointer; color: var(--text);
  transition: background .12s, border-color .12s;
}
.model-option:last-child { margin-bottom: 0; }
.model-option:hover { background: var(--surface-2); border-color: var(--border); }
.model-option.active { background: var(--accent-soft); border-color: var(--accent); }
.model-option-name { font-size: 14px; font-weight: 500; }
.model-option-id { font-size: 11.5px; color: var(--muted); }
/* 模型选择器增强：场景分组 / 收藏 / 折叠全部 */
.model-option-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; }
.model-option-main { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; flex: 1 1 auto; }
.model-option-logo {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); -webkit-user-select: none; user-select: none;
}
.model-option-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.model-option-logo .logo-fallback {
  width: 100%; height: 100%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; font-weight: 600; color: var(--text);
}
.model-option.active .model-option-logo { border-color: var(--accent); }
.model-option-fav {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; transition: all .12s; -webkit-user-select: none; user-select: none;
}
.model-option-fav:hover { color: var(--amber); border-color: var(--amber); }
.model-option-fav.faved { color: var(--amber); border-color: var(--amber); background: rgba(245,181,10,0.12); }
.model-option-fav.placeholder { visibility: hidden; pointer-events: none; }
.model-option-hide {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1; transition: all .12s; -webkit-user-select: none; user-select: none;
}
.model-option-hide:hover { color: var(--red); border-color: var(--red); background: rgba(255,93,108,0.08); }
.model-option-restore {
  flex: 0 0 auto; padding: 3px 10px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  cursor: pointer; font-size: 12px; transition: all .12s; -webkit-user-select: none; user-select: none;
}
.model-option-restore:hover { background: var(--surface-2); }
.model-showall {
  width: 100%; text-align: center; background: transparent; border: 1px dashed var(--border);
  color: var(--accent); border-radius: 10px; padding: 9px; margin-top: 4px;
  cursor: pointer; font-size: 13px; transition: background .12s;
}
.model-showall:hover { background: var(--surface-2); }
/* 快照版折叠到主模型「更多版本 ▾」：主模型+折叠钮+版本列表包成一组，避免虚线错误分割 */
.model-option-wrap {
  border-bottom: 1px dashed var(--border);
  margin-bottom: 4px;
  padding-bottom: 2px;
}
.model-option-wrap > .model-option {
  margin-bottom: 0;
  border-radius: 10px 10px 0 0;
}
.model-option-wrap > .model-option:hover,
.model-option-wrap > .model-option.active {
  border-radius: 10px 10px 0 0;
}
.model-versions-toggle {
  width: 100%; text-align: left; background: transparent; border: none;
  color: var(--muted); border-radius: 0 0 10px 10px;
  /* 左对齐到主模型 Logo 左边缘：model-option padding-left = 11 */
  padding: 4px 12px 5px 11px; margin: 0;
  cursor: pointer; font-size: 12px; transition: color .12s, background .12s;
}
.model-versions-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.model-versions { padding-left: 10px; padding-bottom: 2px; }
/* 小版本 Logo 左边缘 = padding-left 10 + border-left 2 = 12，与主模型 Logo（border 1 + padding 11 = 12）对齐 */
.model-option.sub { padding-left: 0; background: rgba(127,127,127,0.04); border-left: 2px solid var(--border); }
.model-option.sub .model-option-name { font-size: 13px; }
/* ===== 树形模型选择器（地铁配色） ===== */
.model-picker-body { max-height: 360px; }
.scn { display: flex; margin: 5px 8px; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-sm); }
.scn-pillar { width: 5px; background: var(--c); flex: 0 0 auto; }
.scn-main { flex: 1; min-width: 0; }
.scn-hd { display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; background: var(--c); color: #fff; -webkit-user-select: none; user-select: none; }
.scn-hd:hover { filter: brightness(1.06); }
.scn-dot { width: 20px; height: 20px; border-radius: 6px; background: rgba(255,255,255,.32); flex: 0 0 auto; }
.scn-txt { flex: 1; min-width: 0; }
.scn-name { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.scn-desc { font-size: 11px; opacity: .82; margin-top: 1px; }
.scn-cnt { font-size: 12px; opacity: .82; }
.scn-chev { font-size: 11px; opacity: .82; transition: transform .15s; }
.scn.collapsed .scn-chev { transform: rotate(-90deg); }
.scn-body { background: var(--c); background: color-mix(in srgb, var(--c) 86%, #ffffff); color: #fff; }
.scn.collapsed .scn-body { display: none; }
.sup-g { margin-left: 18px; padding-left: 10px; border-left: 2px solid rgba(255,255,255,.3); }
.sup-g.collapsed .sup-b { display: none; }
.sup-h { display: flex; align-items: center; gap: 6px; padding: 7px 10px; cursor: pointer; border-radius: 6px; }
.sup-h:hover { background: rgba(255,255,255,.1); }
.sup-d { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.55); flex: 0 0 auto; }
.sup-n { font-size: 12px; font-weight: 500; opacity: .92; }
.sup-c { font-size: 9px; opacity: .5; }
.sup-b { padding: 2px 0 6px; }

/* 顶级家族块：中性底 + 品牌色圆点 + 可折叠（客户侧按模型家族分组，不展示供应商） */
.fam-block { border: 1px solid var(--border); border-radius: 8px; margin: 6px 4px; overflow: hidden; background: var(--surface); }
.fam-block.collapsed .fam-block-body { display: none; }
.fam-block-hd { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; -webkit-user-select: none; user-select: none; border-bottom: 1px solid transparent; transition: background .12s, border-color .12s; }
.fam-block-hd:hover { background: var(--hover, rgba(0,0,0,.04)); }
.fam-block.collapsed .fam-block-hd { border-bottom-color: transparent; }
.fam-block:not(.collapsed) .fam-block-hd { border-bottom-color: var(--border); }
.fam-block-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.fam-block-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fam-block-cnt { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.fam-block-chev { font-size: 10px; color: var(--muted); flex: 0 0 auto; transition: transform .15s; }
.fam-block.collapsed .fam-block-chev { transform: rotate(-90deg); }
.fam-block-body { padding: 4px 4px 6px; }
/* .fam-block 下用 .mr：覆盖原白字样式为深字（场景色 .scn 已不再渲染，但保留 .scn 兜底） */
.fam-block .mr { color: var(--text); }
.fam-block .mr:hover { background: var(--hover, rgba(0,0,0,.05)); }
.fam-block .mr.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.fam-block .mr .mn { color: var(--text); }
.fam-block .mr .mm { color: var(--muted); opacity: 1; }
.fam-block .mr .tg { background: var(--accent-soft, rgba(0,0,0,.05)); color: var(--text); }
.fam-block .mr .mhide { color: var(--muted); }
.fam-block .mr .mhide:hover { color: var(--text); }
.fam-block .mr-versions-toggle { color: var(--muted); }
.fam-block .mr-versions-toggle:hover { color: var(--text); }

.mr { display: flex; align-items: center; gap: 9px; padding: 8px 12px; cursor: pointer; border-radius: 7px; margin: 1px 4px; color: #fff; }
.mr:hover { background: rgba(255,255,255,.16); }
.mr.active { background: rgba(255,255,255,.3); }
.mr .mlogo { width: 28px; height: 28px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex: 0 0 auto; overflow: hidden; background: transparent; }
.mr .mlogo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.mr .mi { flex: 1; min-width: 0; }
.mr .mn { font-size: 13px; font-weight: 500; color: #fff; }
.mr .mm { font-size: 11px; opacity: .78; }
.mr .tg { font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 5px; background: rgba(255,255,255,.22); color: #fff; }
/* 实测健康度角标：degraded（波动/限流/上游不稳）时给模型打 ⚠；主 down 有 fallback 时仍可见 */
.mr .mh-badge { font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 5px; background: rgba(245,181,10,.22); color: #ffce4d; border: 1px solid rgba(245,181,10,.45); white-space: nowrap; }
.model-option .mh-badge { font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 6px; background: rgba(214,134,11,.16); color: var(--amber); border: 1px solid rgba(214,134,11,.35); vertical-align: middle; }
.model-trigger.warn { border-color: rgba(214,134,11,.6); }
.model-trigger.warn .model-trigger-text { color: var(--amber); }
.mr .mfav { color: var(--amber); font-size: 14px; width: 22px; text-align: center; flex: 0 0 auto; cursor: pointer; }
.mr .mfav.dim { opacity: .3; }
.mr .mhide { color: rgba(255,255,255,.7); font-size: 15px; width: 22px; text-align: center; flex: 0 0 auto; cursor: pointer; }
.mr .mhide:hover { color: #fff; }
.mr.sub { margin-left: 22px; }
.mr-versions-toggle { width: 100%; text-align: left; background: transparent; border: none; color: rgba(255,255,255,.82); padding: 4px 12px 5px; cursor: pointer; font-size: 12px; }
.mr-versions { padding-left: 6px; }

@media (max-width: 560px) {
  .chat-app { height: 100%; max-height: 100%; }
  .bubble { max-width: 90%; }
  .model-picker { border-radius: var(--radius-sm); }
  .model-picker-body { max-height: 220px; }
  .model-trigger { padding: 6px 11px; font-size: 13px; }
}

/* 对话页桌面端：锁高防止整页滚动，左右两列各自独立 scroll */
@media (min-width: 769px) {
  .chat-app {
    height: calc(100vh - var(--topnav-h));
    min-height: 520px;
    max-height: calc(100vh - var(--topnav-h));
  }
  .main:has(.chat-app) { overflow: hidden; padding-bottom: 24px; }
}

/* ==================== 订阅页（P1-④ 循环订阅） ==================== */
.pkg-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.pkg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.pkg-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-md);
}
.pkg-card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.pkg-price { font-size: 26px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.pkg-price .pkg-per { font-size: 14px; font-weight: 500; color: var(--muted); }
.pkg-pts { font-size: 14px; color: var(--accent); font-weight: 600; }
.pkg-bonus { display: inline-block; font-size: 13px; font-weight: 700; color: var(--green); margin-top: 2px; }
.pkg-feats { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pkg-feats li { font-size: 13px; color: var(--muted); padding-left: 14px; position: relative; }
.pkg-feats li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.pkg-card .btn.primary { margin-top: auto; justify-content: center; }

.sub-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-card:last-child { margin-bottom: 0; }
.sub-head { display: flex; align-items: center; gap: 10px; font-size: 15.5px; }
.sub-head b { font-weight: 700; }
.sub-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 模型管理页：启用/停用开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); transition: .2s; border-radius: 22px; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* 模型管理页：目录视图（供应商视图 / 模型视图共用同一张表，只是分组维度不同）*/
.stat-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
/* 模型名（上）+ 模型 ID（下）两行各自独立省略：两行都是 block，必须自己带 overflow/ellipsis，
   否则块级子元素溢出时只会在 td 边界被硬切（半个字），而不是出「…」。 */
.stat-mname {
  display: block; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat-sup { color: var(--text); }
.cat-kind { white-space: nowrap; }
.stat-mult-val { cursor: pointer; padding: 0 4px; border-radius: 4px; font-weight: 600; }
.stat-mult-val:hover { background: var(--accent); color: #fff; }
.stat-mult-input { width: 64px; padding: 1px 4px; font-size: 13px; border-radius: 4px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); }
/* ===== 模型目录统一行（供应商视图 / 模型视图共用，11 列） ===== */
.supv-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.supv-tab {
  font-size: 13px; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.supv-tab.on { border-color: var(--accent); background: rgba(90,120,180,.12); color: var(--accent); font-weight: 500; }
.supv-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; background: var(--surface); }
.supv-group-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  list-style: none; cursor: pointer; -webkit-user-select: none; user-select: none;
}
.supv-group-head .caret { color: var(--muted); font-size: 11px; width: 14px; display: inline-block; transition: transform .15s; }
.supv-group-head::-webkit-details-marker { display: none; }
.supv-group[open] > .supv-group-head .caret { transform: rotate(90deg); }
.supv-sup-name { font-weight: 600; font-size: 14px; color: var(--text); }
.supv-sup-id { font-size: 12px; color: var(--faint); font-family: var(--mono, monospace); }
.supv-sup-stat { font-size: 12.5px; color: var(--muted); margin-left: 2px; }
/* ===== 模型目录「行三态」分组：只有中间那组（未关闭但不可售）要人去处理，故只给它上橙色 =====
   组框 / 组名 / 组头底色一起走 --amber（浅色主题 #d97706、深色主题 #f5b042），不写死色值，
   两个主题都跟着变量走；已关闭组保持中性灰，在售组保持默认，三组一眼可分。 */
.supv-group.attn { border-color: var(--amber); }
.supv-group.attn > .supv-group-head {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface-2));
  border-bottom-color: var(--amber);
}
.supv-group.attn .supv-sup-name { color: var(--amber); }
.supv-group.attn .supv-sup-stat { color: var(--amber); }
/* 行级同步标出：待处理行左侧一道橙边；已关闭行仍走 .supv-row.off 的灰底，两者不混。 */
.supv-row.hold td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
/* 供应商视图：在售（启用）行按行态权重连续排在表首，整段用绿框围成一个矩形 ——
   首行顶边 + 末行底边 + 每行左右竖边（每行都有一条左/右竖边，堆叠起来就是连续的一条边）。
   边一律 1px；顶边用 inset 阴影而不是 border-top：表格是 border-collapse，1px 的 border-top 会与
   表头上那条 1px 灰底线压在同一个格线上，按「同宽同款式取更靠左上的一条」的规则灰线会胜出、
   绿顶边被吃掉，故顶边改用单元格内阴影（等于边，不参与格线争用）。 */
.cat-table .supv-row.onblk-first td { box-shadow: inset 0 1px 0 var(--green); }
.cat-table .supv-row.onblk-last td { border-bottom: 1px solid var(--green); }
.cat-table .supv-row.onblk td:first-child { border-left: 1px solid var(--green); }
.cat-table .supv-row.onblk td:last-child { border-right: 1px solid var(--green); }
.supv-holdStat { color: var(--amber); font-weight: 600; }
.supv-sup-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.supv-search { margin-left: 10px; }
.supv-search input {
  width: 160px; padding: 4px 10px; font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.supv-search input:focus { outline: none; border-color: var(--accent); }
.supv-search input::placeholder { color: var(--faint); }
/* 模型目录页面级总搜索（供应商视图 / 模型视图共用，放在 Tab 行下方）：
   输入即模糊过滤两个视图的所有分组行，命中分组自动展开、整组无命中则整组隐藏；
   输入框右侧紧邻一枚「搜索」钮（同一过滤实现，点击重跑一次，等价回车）。 */
.cat-global-search { display: flex; flex-direction: column; margin-bottom: 12px; }
.cat-global-search .cat-global-row { display: flex; align-items: center; gap: 8px; }
.cat-global-search .supv-search { margin-left: 0; }
.cat-global-search .supv-search input { width: 320px; }
.cat-global-search .supv-empty { padding: 10px 2px; color: var(--muted); font-size: 12.5px; }
/* 目录总计条（供应商视图 / 模型视图各一份，两份数字同源：行 = 供应商 × 模型）：
   「启用 / 关闭」与各分组头的「启用 X / 关闭 Y」逐组相加一致；close 的成因见条内 title。 */
.cat-totals {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12.5px; color: var(--muted);
}
.cat-totals-label { font-weight: 600; color: var(--text); }
.cat-totals-main { color: var(--muted); }
.cat-totals-main b { font-weight: 600; }
.cat-totals-main .t-on { color: var(--green); }
.cat-totals-main .t-hold { color: var(--amber); }
.cat-totals-main .t-off { color: var(--red); }
.cat-totals-sub { margin-left: auto; color: var(--faint); }
/* 统一表格：固定列宽 + 表头/行同一套单元格类 → 表头与每行逐列对齐；超长文本省略，不溢出边界 */
.cat-table-wrap { overflow-x: auto; }
/* 列宽：**只给「模型」列留弹性（width:auto 吸收剩余宽度），其余 10 列一律写死 px**。
   为什么不再用百分比（2026-09-21 改，对应用户诉求「整页展示全，不要左右滑动才看全」）：
   11 列里只有模型列「越宽越有用」—— 线上模型 ID 最长 56 字符
   （cognitivecomputations/dolphin-mistral-24b-venice-edition，实测），其余 10 列的内容长度是固定值
   （数值 / 徽章 / 按钮，不会因为屏幕变宽而变长）。百分比方案把宽屏多出来的宽度按比例摊给**所有**列
   （模型列只拿 21%），窄屏又整体等比缩小直到 min-width 撑出横向滚动 —— 两头都不讨好。
   定宽 + auto 之后：宽屏多出的宽度全进模型列（1440 下 348px，41 字符的模型 ID 能整条放下），
   窄屏则停在各列自己的实测需求上、不再继续缩。
   px 取值全部来自真机实测（Chrome + 真实 CSS），最坏样本：56 字符模型 ID、`AWS Bedrock` 供应商、
   「故障·上游拒绝」健康徽章、「1234.56」两位数值、「供应商/已下架」两行成因徽章；
   **不是按字符数估算**（按字符数算会系统性偏小 20~30%）。
   min-width 960px = 10 个固定列合计 798 + 模型列最小 162（≈23 字符）：这是「非模型列全都不被裁」的
   可用下限，低于它才落到 .cat-table-wrap 横向滚动兜底。
   ⇒ 视口 ≥1252px（228 侧栏 + 64 内容内边距 + 960）整行完整展示、无横向滚动；1280（含纵向滚动条占位
   的 1265）实测均 OVER=false。1152 及以下（如 1440 屏按 125% 缩放）仍会横向滚动 —— 那需要再砍列。 */
.cat-table { width: 100%; min-width: 960px; table-layout: fixed; border-collapse: collapse; }
.cat-table col.c-model  { width: auto; }  /* 模型：名称 + 上游 ID 两行；唯一的弹性列，吸收全部剩余宽度 */
.cat-table col.c-sup    { width: 78px; }  /* 供应商（「AWS Bedrock」这类长名会出「…」，有 title 可悬停） */
.cat-table col.c-kind   { width: 73px; }  /* 分类：4 字 tag 固有宽 60 + 内边距 12 = 72，留 1px */
.cat-table col.c-health { width: 86px; }  /* 健康：徽章折行成「故障·上游 / 拒绝」两行（实测 4+3 要 80px、5+2 要 86px） */
.cat-table col.c-buy    { width: 91px; }  /* 买价 In/Out 两行（实测内容宽 88，留 3px） */
.cat-table col.c-state  { width: 82px; }  /* 状态：「供应商/已下架」两行成因徽章（实测 80） */
.cat-table col.c-act    { width: 101px; } /* 操作：两枚按钮并排（见下方 .supv-act） */
.cat-table th, .cat-table td {
  padding: 8px 6px; text-align: center; vertical-align: middle;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.cat-table th:first-child, .cat-table td:first-child { padding-left: 8px; }
.cat-table th:last-child, .cat-table td:last-child { padding-right: 8px; }
.cat-table tbody tr:last-child td { border-bottom: none; }
.cat-table thead th { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface); padding-top: 8px; padding-bottom: 8px; }
.supv-row { cursor: pointer; }
.supv-row.off td { background: var(--surface-2); }
.supv-row.off .stat-mname { color: var(--muted); }
.supv-row.nocost td { background: rgba(224, 148, 70, .06); }
.supv-row:hover td { background: var(--surface-2); }
.supv-head { cursor: default; }
.supv-head:hover td { background: var(--surface); }
/* 列对齐：<th> 与 <td> 共用下面这些类，表头与数据的对齐方式不可能不一致。
   本表统一居中（表头名称与列内数值/徽章/按钮同轴），故数值列不再单独右对齐。
   唯一例外是「模型」列（2026-09-19 起左对齐）：模型名是整行最长文本，居中会让
   长短不一的名称左右参差、首字母对不齐，左对齐后按首字母扫读才成列。 */
.cat-table .stat-name-cell { text-align: left; }
.supv-buy, .supv-sell, .supv-margin { font-variant-numeric: tabular-nums; white-space: nowrap; }
.supv-buy, .supv-sell { color: var(--muted); }
.supv-buy-val { color: var(--muted); cursor: pointer; }
.supv-buy-val:hover { color: var(--accent); }
.supv-buy-val.nocost { color: var(--amber); }
.supv-mult { text-align: center; color: var(--text); font-variant-numeric: tabular-nums; }
.cat-kind, .supv-health, .supv-state, .supv-act { text-align: center; }
.supv-margin { font-weight: 600; }
.supv-margin.g { color: var(--green); }
.supv-margin.a { color: var(--amber); }
.supv-margin.r { color: var(--red); }
.supv-inout { line-height: 1.4; }
.supv-inout .lbl, .supv-inout-edit .lbl { color: var(--faint); font-size: 10px; }
.supv-nc { display: inline-block; font-weight: 600; line-height: 1.35; }
.supv-row.nocost .supv-nc { color: var(--amber); }
.supv-inout-edit input { width: 56px; padding: 1px 4px; font-size: 13px; border-radius: 4px; border: 1px solid var(--accent); background: var(--surface); color: var(--text); margin-right: 2px; }
.supv-noCostStat { color: var(--amber); font-weight: 600; }
.supv-health, .supv-state { white-space: nowrap; }
.supv-act .btn + .btn { margin-left: 6px; }
/* 「操作」列：两枚按钮**恒并排，永不折行**（诉求原文：「测试」和「关闭」钮平行放）。
   2026-09-21 之前这里是 white-space: normal + 百分比列宽 —— 窄屏下列宽缩到 95px < 按钮实测需求 96px，
   两枚按钮就折成上下两行（真机实测：1280 视口下三行**全部**换行，正是用户报的现象）。
   改为 nowrap + 列宽写死 101px：按钮 39×2 + 间距 4 + 单元格内边距 14 = 96，留 5px 余量。
   宽度不够时宁可整表横向滚动，也不让按钮折行 —— 折行会改行高，比滚动条更难看，且此前正是它撑出了滚动条。 */
.cat-table .supv-act { white-space: nowrap; }
.cat-table .supv-act .btn.sm { padding: 3px 7px; font-size: 11.5px; border-radius: 5px; }
.cat-table .supv-act .btn + .btn { margin-left: 4px; }
/* 徽章同样收一档：健康「故障·上游拒绝」、状态「供应商已下架」是各列最长的取值，
   按 12px 排会顶破列宽（在 td 里被 ellipsis 切掉半个字），收成 11.5px/更紧内边距即可整枚放下。 */
.cat-table .badge { font-size: 11.5px; padding: 2px 8px; gap: 4px; }
/* 状态列的「不可售成因」是两行短词（列宽只够每行 4 字）：.badge 默认 inline-flex + nowrap，flex 容器里 <br> 不换行，
   故本列单独改回 inline-block 并允许折行；两行总高 34px，仍在模型列（名称+ID）已有的两行内容高度内，不会撑高行。 */
.cat-table .supv-state .badge { display: inline-block; white-space: normal; line-height: 1.3; padding: 2px 7px; }
/* 健康列同理：「故障·上游拒绝」「降级·上游超时」是 healthText 的上限（8 字），整枚放下要 114px ——
   那是 11 列里最贵的一列。允许折行后每行 5 字、列宽只需 86px，省下的 28px 全部让给模型列；
   行高不变（模型列本来就是「名称 + 上游 ID」两行，健康徽章折成两行仍在同一高度内）。 */
.cat-table .supv-health .badge { display: inline-block; white-space: normal; line-height: 1.3; padding: 2px 7px; }
.cat-table .tag { font-size: 11px; padding: 2px 7px; }
/* 供应商列收一档字号：名称是次要信息（行身份在模型列），13px 已足够辨认，
   换来「google-vertex / aliyun-bailian」这类 13~14 字符的上游 ID 连同「供」标记一起放下。 */
.cat-table .stat-sup { font-size: 13px; }
/* 模型详情抽屉 */
.model-scrim { position: fixed; inset: 0; background: rgba(15,23,42,.32); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 50; }
.model-scrim.show { opacity: 1; pointer-events: auto; }
.model-drawer { position: fixed; top: 0; right: 0; height: 100%; width: 400px; max-width: 92vw; background: var(--surface); box-shadow: var(--shadow-md); transform: translateX(100%); transition: transform .22s ease; z-index: 51; display: flex; flex-direction: column; }
.model-drawer.show { transform: translateX(0); }
.model-drawer header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.model-drawer header h3 { margin: 0; font-size: 16px; }
.model-drawer .x { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }
.model-drawer .body { padding: 18px; overflow: auto; }
.model-drawer .kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.model-drawer .kv .k { color: var(--muted); flex-shrink: 0; }
.model-drawer .kv .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
/* 多行块（标签在上、值在下）：用于长说明与逐条明细，避免右侧被挤压成乱断行 */
.model-drawer .kv.block { display: block; }
.model-drawer .kv.block .k { margin-bottom: 4px; }
.model-drawer .kv.block .v { text-align: left; font-weight: 500; }
.model-drawer .kv .v .sub { color: var(--faint); font-weight: 400; font-size: 12px; }
.model-drawer .kv.block .v .sub { display: block; margin-top: 3px; line-height: 1.55; }
.model-drawer .drawer-edit { margin-top: 16px; }
.model-drawer .drawer-edit .btn { width: 100%; }
/* 详情抽屉四区折叠块（A 身份与状态 / B 供给与路由 / C 行情快照 / D 运营） */
.model-drawer .dz-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.model-drawer .dz-h { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 12px; background: var(--surface-2); border: 0; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--text); text-align: left; font-family: inherit; }
.model-drawer .dz-h .dz-arrow { color: var(--muted); transition: transform .15s; }
.model-drawer .dz-group.collapsed .dz-b { display: none; }
.model-drawer .dz-group.collapsed .dz-arrow { transform: rotate(-90deg); }
.model-drawer .dz-b { padding: 2px 12px 8px; }
.model-drawer .dz-b .kv:last-child { border-bottom: 0; }
.model-drawer .dz-links { display: flex; gap: 8px; margin-top: 10px; }
.model-drawer .dz-links a { flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; text-decoration: none; font-weight: 600; }
