/* =====================================================================
   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; }
.topnav .topnav-right { margin-left: 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 .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; }

/* 模型管理表格 */
.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; }
/* 必填标记与行内错误提示（通用模态表单） */
.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; }
/* 模型统计区一级 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);
  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; }
  .topnav { 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.supplier-cell,
  .models-table td.supplier-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); 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; 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; 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; 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; 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; }

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

/* 模型管理页：健康度统计区（折叠异常 + 类别分组，浏览器原生 details）*/
.stat-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.stat-issue, .stat-cat {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); overflow: hidden;
}
.stat-issue summary, .stat-cat summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 14px; background: var(--surface-2);
}
.stat-issue summary::-webkit-details-marker, .stat-cat summary::-webkit-details-marker { display: none; }
.stat-issue summary:hover, .stat-cat summary:hover { background: var(--surface); }
.stat-issue-count, .stat-cat-count { font-size: 12.5px; color: var(--muted); margin-left: 4px; }
.stat-issue .caret, .stat-cat .caret { color: var(--muted); font-size: 11px; width: 14px; display: inline-block; transition: transform .15s; }
.stat-issue[open] .caret, .stat-cat[open] .caret { transform: rotate(90deg); }
.stat-issue-list, .stat-cat-list { padding: 8px 14px 12px 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.stat-issue-group { display: flex; align-items: center; gap: 6px; padding: 6px 0 4px 0; color: var(--muted); font-size: 12.5px; }
.stat-issue-tag { padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.stat-issue-tag.down { background: rgba(226,75,74,.12); color: #d0574f; }
.stat-issue-tag.unk { background: rgba(136,135,128,.15); color: var(--muted); }
.stat-issue-tag.rule { background: rgba(90,120,180,.12); color: var(--accent); }
.stat-cat-name { font-size: 14px; font-weight: 600; }
.stat-level > summary { font-weight: 600; }
.stat-subwrap { display: flex; flex-direction: column; gap: 8px; }
.stat-subwrap .stat-cat { border-color: var(--border); background: var(--surface-2); }
.stat-subwrap .stat-cat > summary { background: transparent; }
.stat-subwrap .stat-cat > summary:hover { background: var(--surface); }
.stat-grid { overflow-x: auto; }
.stat-row {
  display: grid;
  grid-template-columns:
    minmax(170px, 1.6fr)   /* 模型 */
    minmax(0, 1fr)         /* 供应商 */
    minmax(0, 1fr)         /* 买价 ¥/1M */
    minmax(0, 1fr)         /* 卖价 ¥/1M */
    minmax(0, 1fr)         /* 倍率 */
    minmax(0, 1fr)         /* 毛利率 */
    minmax(0, 1fr)         /* 健康 */
    minmax(0, 1fr)         /* 调用/日 */
    minmax(0, 1fr)         /* 营收/日 */
    minmax(72px, 0.75fr);  /* 操作 */
  align-items: center; gap: 12px;
  padding: 9px 14px;
  min-width: 1080px;
  border-bottom: 1px solid var(--border);
}
.stat-row:hover { background: var(--surface-2); cursor: pointer; }
.stat-name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; padding-right: 4px; }
.stat-name-cell .badge { flex-shrink: 0; }
.stat-mname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.stat-mname .stat-err { color: var(--red); margin-left: 4px; }
.stat-mname .sub { display: block; font-weight: 400; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-cost { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; white-space: nowrap; }
.stat-stack { text-align: right; font-variant-numeric: tabular-nums; line-height: 1.4; white-space: nowrap; }
.stat-stack .lbl { color: var(--faint); font-size: 10px; margin-right: 2px; }
.stat-stack .inh { color: #9aa5b1; }
.stat-sup { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.stat-mult { font-variant-numeric: tabular-nums; color: var(--text); text-align: center; }
.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); }
.stat-margin { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; white-space: nowrap; }
.stat-margin.g { color: var(--green); }
.stat-margin.a { color: var(--amber); }
.stat-margin.r { color: var(--red); }
.stat-health { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.stat-act { text-align: right; }
.stat-head { font-size: 11.5px; color: var(--muted); padding: 6px 14px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; cursor: default; }
.stat-head:hover { background: var(--surface); cursor: default; }
.stat-head .stat-name-cell, .stat-head .stat-sup { font-weight: 600; }
.stat-head .stat-cost, .stat-head .stat-mult, .stat-head .stat-stack, .stat-head .stat-margin { color: var(--muted); }
/* ===== 供应商视图（模型目录子视图，按供应商分组逐行启停） ===== */
.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);
}
.supv-group-head .caret { color: var(--muted); font-size: 11px; width: 14px; display: inline-block; transition: transform .15s; }
.supv-group-head summary { list-style: none; cursor: pointer; }
.supv-group-head summary::-webkit-details-marker { display: none; }
.supv-group-head[open] .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; }
.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); }
.supv-row {
  display: grid;
  grid-template-columns:
    minmax(160px, 1.6fr)   /* 模型 ID */
    minmax(0, 1fr)         /* 分类 */
    minmax(0, 1fr)         /* 健康 */
    minmax(0, 1fr)         /* 调用/日 */
    minmax(0, 1fr)         /* 营收/日 */
    minmax(0, 0.9fr)       /* 状态 */
    minmax(80px, 0.8fr);   /* 操作 */
  align-items: center; gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.supv-row:last-child { border-bottom: none; }
.supv-row:hover { background: var(--surface-2); }
.supv-row.off { background: var(--surface-2); }
.supv-row.off .supv-id { color: var(--muted); }
.supv-head { font-size: 11.5px; color: var(--muted); padding: 6px 14px 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.supv-head, .supv-head span { font-weight: 600; }
.supv-id { font-family: var(--mono, monospace); font-size: 12.5px; color: var(--text); display: flex; align-items: center; gap: 6px; min-width: 0; }
.supv-id-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.supv-cost { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; white-space: nowrap; }
.supv-health { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.supv-state { white-space: nowrap; }
.supv-act { text-align: right; }
/* 模型详情抽屉 */
.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 .drawer-edit { margin-top: 16px; }
.model-drawer .drawer-edit .btn { width: 100%; }
