/* wild-work 管理面板 — 现代浅色风格，响应式，无外部依赖 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #1f2329;
  --muted: #8a919f;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

#app { max-width: 960px; margin: 0 auto; padding: 20px 16px 60px; }

/* 顶部 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.logo { width: 40px; height: 40px; border-radius: 8px; }
.brand-text .title { font-size: 18px; font-weight: 700; line-height: 1.2; }
.brand-text .ver { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.brand-text .sub { font-size: 11px; color: var(--muted); }

.top-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; flex: 1; max-width: 480px; }
.info-cell { display: flex; align-items: center; gap: 8px; }
.info-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.info-value {
  font-size: 12px; color: var(--muted); background: #f0f2f5; padding: 4px 10px;
  border-radius: 6px; font-family: ui-monospace, monospace; cursor: pointer;
  display: inline-flex; align-items: center; overflow: hidden; min-width: 0; flex: 1;
}
.info-value:hover { color: var(--primary); background: #e0e7ff; }
.info-value .val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; flex-shrink: 1; }

.top-icons { display: flex; gap: 8px; flex-shrink: 0; }
.icon-link.gear { font-size: 18px; }
.icon-link {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--muted);
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; cursor: pointer; transition: all .15s;
}
.icon-link:hover { border-color: var(--primary); color: var(--primary); }

/* 面板区块 */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.panel-head h2 { font-size: 16px; font-weight: 600; }

/* 账号管理按钮区：外层 wrap 分三段 —— 左组(刷新/签到) + 弹性空白 + 右组(渠道三列 grid)。
   左组整体靠左、右组整体靠右，中间空白自动伸缩；左组窄时 wrap 换行不溢出。 */
.panel-actions-wrap { display: flex; align-items: center; flex: 1; min-width: 0; }
.pa-spacer { flex: 1; }
.pa-left { display: flex; flex-direction: column; gap: 8px; }
.pa-left .btn { white-space: nowrap; align-self: flex-start; }
.pa-right {
  display: grid;
  grid-template-columns: repeat(6, auto);
  gap: 8px 10px;
}
.pa-right .btn { justify-self: stretch; white-space: nowrap; }
/* 摆位与列配对由 DOM 顺序（行主序）决定：同列上下 = 同渠道的国内/国际版
   （WorkBuddyCN/WorkBuddyAI、QoderCN/QoderCOM），Cline 占第一行末位、
   第二行第 6 列留空（见 index.html 内注释与 ui-static-check 的顺序断言）。 */
/* 紧凑档：比标准按钮小两号（14px/8px14px → 12px/6px10px），
   PC 默认宽度下一行能放下 6 个渠道按钮（实测阈值见下方媒体查询注释）。 */
.panel-actions-wrap .btn { font-size: 12px; padding: 6px 10px; }

/* 按钮 */
.btn { border: 1px solid var(--border); background: var(--card); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; transition: all .15s; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary.alt { background: #0891b2; border-color: #0891b2; }
.btn.primary.alt:hover { background: #0e7490; }
.btn.primary.alt.qoder { background: #7c3aed; border-color: #7c3aed; }
.btn.primary.alt.qoder:hover { background: #6d28d9; }
.btn.primary.alt.qodercn { background: #6d28d9; border-color: #6d28d9; }
.btn.primary.alt.qodercn:hover { background: #5b21b6; }
.btn.primary.alt.qodercom { background: #b45309; border-color: #b45309; }
.btn.primary.alt.qodercom:hover { background: #92400e; }
/* 智谱清言：清言品牌蓝 */
.btn.primary.alt.glm { background: #1d4ed8; border-color: #1d4ed8; }
.btn.primary.alt.glm:hover { background: #1e40af; }
/* 智谱清言登录弹层步骤列表 */
.glm-steps { margin: 4px 0 8px; padding-left: 20px; font-size: 13px; line-height: 1.9; }
.glm-steps code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.glm-steps a { color: var(--primary); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.tiny { padding: 2px 8px; font-size: 11px; border-radius: 6px; color: var(--primary); }
.btn.tiny:hover { background: #eef2ff; border-color: var(--primary); }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 模型映射编辑器 */
.map-editor {
  margin-top: 8px; padding: 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: #fafbfc;
}
.map-text {
  width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  line-height: 1.6; padding: 6px 8px; resize: vertical; box-sizing: border-box;
}
.map-editor .preset { display: inline-block; margin: 0 4px 4px 0; }

/* 渠道积分汇总条（账号卡片上方，数据与卡片同源） */
.credit-summary {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center;
  margin-bottom: 12px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.cs-title { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.cs-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 4px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); font-size: 12px; white-space: nowrap;
}
.cs-chip .badge { font-size: 10px; }
.cs-n { color: var(--muted); font-size: 11px; }
.cs-num { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cs-exp { color: var(--danger); font-weight: 600; font-size: 11px; }
.cs-unu { color: var(--muted); font-size: 11px; }
.cs-stale { color: var(--warn); font-size: 11px; }
.cs-total { background: #eef4ff; border-color: #c7d9ff; }
.cs-total .cs-title { color: var(--primary); }
/* 渠道 chip 可点击筛选账号：整条作为按钮，选中态加边高亮 */
.cs-chip.clickable { cursor: pointer; }
.cs-chip.clickable:hover { border-color: var(--primary); }
.cs-chip.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.cs-chip.clickable.on { border-color: var(--primary); background: #eff6ff; }
.cs-chip.cs-all { padding: 3px 10px; }
.cs-chip.cs-all .cs-n { color: var(--primary); }
/* 账号筛选后隐藏的卡片（applyAcctFilter 控制） */
.acct-grid .acct-card.hidden { display: none; }

/* 账号卡片网格 */
.acct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acct-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--card);
}
.acct-card.disabled { opacity: 0.5; background: #f9fafb; }
.acct-card .acct-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.acct-card .acct-name { font-weight: 600; font-size: 14px; }
.acct-card .acct-uid { font-size: 11px; color: var(--muted); }
.acct-card .acct-mid { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.acct-card .acct-credits { font-size: 18px; font-weight: 700; cursor: pointer; white-space: nowrap; }
/* 可用/不可用/临期拆分：主数字黑色正常字号，不可用降级为次要色，临期红色醒目提示优先消耗。 */
.acct-card .acct-credits span { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.acct-card .acct-credits .credit-num { font-size: 18px; font-weight: 700; color: var(--text); margin-left: 0; }
.acct-card .acct-credits .credit-sep { margin: 0 3px; color: var(--border); }
.acct-card .acct-credits .credit-unusable { font-size: 13px; font-weight: 600; color: var(--muted); }
.acct-card .acct-credits .credit-expiring { font-size: 13px; font-weight: 600; color: var(--danger); }
/* 旧版 state 文件读入后余额口径不可信：显示待刷新而非旧值 */
.acct-card .acct-credits .credit-stale {
  font-size: 13px; font-weight: 600; color: var(--muted);
  animation: stale-pulse 1.6s ease-in-out infinite;
}
@keyframes stale-pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.acct-card .acct-checkin { font-size: 11px; }
.acct-card .acct-ops { display: flex; gap: 4px; justify-content: flex-end; }

.badge { font-size: 10px; padding: 2px 7px; border-radius: 10px; color: #fff; white-space: nowrap; }
.badge.wb { background: var(--primary); }
.badge.wbai { background: #0d9488; }
.badge.trae { background: #0891b2; }
/* TraeCode 与 TraeWork 共用账号但模型集不同，配色刻意区分以免混淆 */
.badge.traecode { background: #2563eb; }
.badge.qoder { background: #7c3aed; }
.badge.qodercn { background: #6d28d9; }
.badge.qodercom { background: #b45309; }

.tag { font-size: 10px; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.tag.bad { background: #fee2e2; color: var(--danger); }
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.neutral { background: #f0f2f5; color: var(--muted); }

/* 图标操作按钮 */
.icon-op {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 14px;
  transition: all .15s; margin: 0 1px;
}
.icon-op:hover { color: var(--primary); border-color: var(--primary); background: #eff6ff; }
.icon-op.danger:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; }
.icon-op.warn:hover { color: var(--warn); border-color: var(--warn); background: #fffbeb; }
.icon-op.off { cursor: not-allowed; color: #cbd5e1; opacity: .55; }
.icon-op.off:hover { color: #cbd5e1; border-color: var(--border); background: var(--card); }
/* 帮助图标：正常亮度可 hover，不可点击（无 onclick），tooltip 展示说明 */
.icon-op.help { cursor: help; color: var(--muted); font-weight: 600; }
.icon-op.help:hover { color: var(--primary); border-color: var(--primary); background: #eff6ff; }

/* 冷却标签 + 冷却卡片（账号被挑号跳过时给出可见提示，避免"积分很多却报错"的困惑） */
.tag.warn { background: #fef3c7; color: var(--warn); }
.acct-card.cooling { border-left: 3px solid var(--warn); }

/* 智谱清言弹层顶部风险告知（体验渠道） */
.glm-warn {
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.glm-warn-title { font-size: 13px; font-weight: 700; color: var(--warn); margin-bottom: 4px; }
.glm-warn ol { margin: 0; padding-left: 18px; }
.glm-warn li { font-size: 12.5px; color: #92400e; line-height: 1.7; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; font-size: 14px; }
.hidden { display: none !important; }

/* 配置网格（签到 + 开机自启左右布局） */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.config-right { padding-left: 20px; border-left: 1px solid var(--border); }

/* 表单行 */
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.row.wrap { flex-wrap: wrap; }
.lbl { font-size: 13px; color: var(--muted); width: 44px; }
.input { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 14px; outline: none; }
.input:focus { border-color: var(--primary); }
.input.port { width: 80px; }
.input.grow { flex: 1; min-width: 120px; }
/* 弹层里独立成行的输入框（不套在 .row 弹性容器里）：.grow 的 flex:1 不生效，
   浏览器会按默认 size 属性渲染成一个窄框（就是 Cline 的 API-Key 输入框过短的原因）。
   凡是直接位于 .cfg-section 下的 .input.grow 一律撑满宽度。 */
.cfg-section > .input.grow { flex: none; width: 100%; box-sizing: border-box; }
.select { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 14px; background: var(--card); outline: none; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.risk-tip { font-size: 12px; color: var(--warn); background: #fefce8; border: 1px solid #fde68a; padding: 8px 10px; border-radius: 8px; margin-top: 8px; }

/* 必填标记（管理密码 label 后的红点）：监听非本机地址时显示 */
.req { color: var(--danger); font-weight: 700; margin-left: 3px; }

/* 签到时间（设置弹层内） */

/* 签到时间 */
.times { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary); padding: 5px 10px; border-radius: 16px; font-size: 13px; cursor: pointer; }
.time-chip:hover { background: #dbeafe; text-decoration: line-through; }
.icon-btn { border: 1px dashed var(--border); background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* 费率表 */
.fees { font-size: 13px; }
.fees table { width: 100%; border-collapse: collapse; }
.fees th, .fees td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.fees th { color: var(--muted); font-weight: 500; font-size: 12px; }
.fees .ch-header td {
  background: #f8fafc; font-weight: 600; font-size: 13px;
  padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.fees .ch-header.wb td { color: var(--primary); }
.fees .ch-header.wbai td { color: #0d9488; }
.fees .ch-header.trae td { color: #0891b2; }
.fees .ch-header.traecode td { color: #2563eb; }
.fees .ch-header.qoder td { color: #7c3aed; }
.fees .ch-header.qodercn td { color: #6d28d9; }
.fees .ch-header.qodercom td { color: #b45309; }
.btn.alt.wbai { background: #0d9488; border-color: #0d9488; color: #fff; }
.fees .note { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* 模型查找入口：标题行内的放大镜按钮（比默认 icon-btn 小一号，避免抬胀标题行） */
.panel-head h2 .search-btn {
  width: 24px; height: 24px; font-size: 13px; border-radius: 6px;
  vertical-align: middle; margin-left: 4px; padding: 0; line-height: 1;
}

/* 模型查找对话框：紧凑固定尺寸（不随结果跳变/变高，避免位置困扰）。
   结果上限 12 条（见 app.js MODEL_SEARCH_MAX），故列表高度按上限预留即可。 */
.modal.modal-search {
  width: 460px; max-width: 94vw;
  height: 460px; max-height: 86vh;
  display: flex; flex-direction: column;
}
.modal-search .modal-title { margin-bottom: 10px; }
.modal-search #modelSearchInput { width: 100%; box-sizing: border-box; margin-bottom: 8px; flex: none; }
.ms-list { flex: 1 1 auto; min-height: 0; overflow: hidden; }
.ms-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; line-height: 1.5;
}
.ms-row:hover { background: #eff6ff; }
.ms-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.ms-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
.ms-tags { flex: none; color: var(--muted); font-size: 11px; }
.ms-rate { flex: none; font-weight: 600; font-size: 12px; color: var(--primary); font-variant-numeric: tabular-nums; }
.ms-empty { color: var(--muted); font-size: 13px; padding: 14px 8px; text-align: center; }
.ms-foot { flex: none; margin-top: 6px; color: var(--muted); font-size: 12px; min-height: 18px; }

/* 渠道多标签：收束长费率表（每渠道一个 tab，panel 内双列布局不变） */
.fees-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  padding-bottom: 6px;
}
.fees-tab {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.fees-tab:hover { color: var(--primary); border-color: var(--primary); }
.fees-tab.active {
  color: var(--primary);
  border-color: var(--primary);
  background: #eff6ff;
  font-weight: 600;
}
.fees-tab .fees-tab-n {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--border);
  border-radius: 999px;
  padding: 0 5px;
  line-height: 15px;
}
.fees-tab.active .fees-tab-n { color: var(--primary); background: #dbeafe; }
/* 渠道积分余额角标：tab 内显示该渠道可用积分合计（与汇总条同源） */
.fees-tab .fees-tab-bal {
  font-size: 10.5px;
  color: #15803d;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
}
/* 模型名可点击复制（整段 code 作为按钮） */
.fees code.fee-model-copy {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 2px;
}
.fees code.fee-model-copy:hover { background: #eff6ff; color: var(--primary); }
.fees code.fee-model-copy:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.fees td.dim { color: var(--muted); font-size: 12px; }
/* Cline 弹层的「免费模型参数」实测表：紧凑排版（与弹层其它表格一致） */
.cline-caps { font-size: 12.5px; }
.cline-caps th, .cline-caps td { padding: 5px 8px; }
.cline-caps code { font-size: 11.5px; }
.cline-caps td.dim { color: var(--muted); font-size: 11.5px; }
@media (max-width: 700px) {
  /* 窄屏：备注列折行，不让表格溢出弹层 */
  .cline-caps { word-break: break-all; }
  .cline-caps th, .cline-caps td { padding: 5px 5px; }
}
/* 倍率显示：Free 高亮 / 已定价 / 未知（带 tooltip） */
.fees .rate-free {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: #dcfce7; color: #15803d; font-weight: 600; font-size: 12px;
  border: 1px solid #86efac; cursor: default;
}
.fees .rate-paid { font-variant-numeric: tabular-nums; }
.fees .rate-unknown {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: #f1f5f9; color: #94a3b8; font-size: 12px;
  border: 1px dashed var(--border); cursor: help;
}
.fees .rate-note { color: #d97706; font-size: 11px; }
/* 能力图标：模型 ID 后的小标记，hover 显示文字说明（title） */
.fees .cap-icons { display: inline-flex; gap: 2px; margin-left: 2px; vertical-align: middle; }
.fees .cap-icon {
  display: inline-block; font-size: 11px; line-height: 1;
  opacity: .75; cursor: help; filter: saturate(.85);
}
.fees .cap-icon:hover { opacity: 1; }

/* 上下文窗口标记：模型 ID 后的 (1M)/(180K) 小字标 */
.fees .ctx-tag {
  font-size: 11px; color: var(--muted); margin-left: 2px;
  font-variant-numeric: tabular-nums; cursor: help;
}
.fees code + .ctx-tag { vertical-align: baseline; }
/* 本工具实测值（带 *）：用警示色区分，避免与上游官方声明混淆 */
.fees .ctx-tag.hand { color: var(--warn); border-bottom: 1px dotted var(--warn); }

/* 思考档位标记（issue #96）：模型 ID 后的 [low·high·max] 小字标 */
.fees .effort-tag {
  font-size: 11px; color: #7c3aed; margin-left: 2px;
  font-family: ui-monospace, monospace; cursor: help;
}
.fees code + .effort-tag { vertical-align: baseline; }
/* 模型搜索框同款（复用紫色区分于上下文灰字） */
.ms-eff { color: #7c3aed; font-family: ui-monospace, monospace; cursor: help; }

/* 完整模型ID：费率表每行模型下方显示「渠道/模型」，点击即复制（客户端该填的模型名） */
.fees .mcell { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.fees .mline { display: inline-flex; align-items: baseline; flex-wrap: wrap; }
.fees .full-id {
  display: inline-block; font-family: ui-monospace, monospace; font-size: 11px;
  color: var(--muted); background: #f0f2f5; padding: 1px 6px; border-radius: 4px;
  cursor: pointer; user-select: all; line-height: 1.5; white-space: nowrap;
}
.fees .full-id:hover { color: var(--primary); background: #e0e7ff; }

/* 配置说明 */
.docs { font-size: 13px; }
.docs p { margin-bottom: 8px; }
.docs code { background: #f0f2f5; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 12px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 24px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* 弹层 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--card); border-radius: 12px; padding: 20px 22px; width: 400px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
/* 宽弹层：统一设置 / 帮助（风险声明多，需宽松排版） */
.modal.modal-wide { width: 720px; max-width: 94vw; max-height: 86vh; display: flex; flex-direction: column; }
.modal-wide .modal-body { overflow-y: auto; min-height: 0; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 14px; color: var(--text); margin-bottom: 14px; word-break: break-all; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.login-buttons { display: flex; gap: 8px; margin-top: 14px; }

/* 统一设置弹层内部分区 */
.settings-body { word-break: normal; }
.cfg-section { padding: 12px 0 4px; border-top: 1px solid var(--border); }
.cfg-section:first-child { border-top: none; padding-top: 2px; }
.cfg-heading { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.lbl.wide { width: 90px; flex-shrink: 0; white-space: nowrap; }

/* 渠道代理行 */
.proxy-list { display: flex; flex-direction: column; gap: 6px; }
.proxy-row { margin-bottom: 0; }
.proxy-row .input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

/* 账号名可点击编辑 */
.acct-name.editable { cursor: pointer; border-bottom: 1px dashed transparent; }
.acct-name.editable:hover { color: var(--primary); border-bottom-color: var(--primary); }

/* 帮助弹层风险警告块 */
.risk-block {
  margin-top: 12px; padding: 10px 14px; border: 1px solid #fde68a;
  background: #fffbeb; border-radius: 8px; word-break: normal;
}
.risk-title { font-weight: 700; color: var(--warn); margin-bottom: 6px; font-size: 13px; }
.risk-list { padding-left: 18px; font-size: 12px; color: #7c5b10; }
.risk-list li { margin-bottom: 4px; }

/* toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: rgba(31,35,41,.92); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,.2); max-width: 80vw; }

/* 积分明细浮层：点击积分标签打开，✕ / 点击浮层外 / Esc 关闭（桌面与触屏同一套交互）。
   为什么不再用 hover：① 浮窗开着时后台 loadState() 会重建卡片 DOM，被替换的元素不再派发
   mouseleave ⇒ 浮窗残留关不掉；② 触屏没有 mouseenter/mouseleave，手机上根本关不掉。
   位置固定（水平居中、距顶 12vh）而不贴被点卡片：重渲染/滚动都不会飘走。 */
.credit-tip {
  position: fixed; display: none; z-index: 150;
  left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px)); /* 窄屏自适应：手机竖屏不再溢出屏幕 */
  max-height: 72vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 12px;
  box-sizing: border-box;
}
.credit-tip .detail-head {
  display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center;
  gap: 6px; margin-bottom: 6px;
}
.credit-tip .detail-title { font-weight: 600; text-align: right; }
.credit-tip .detail-count { font-weight: 400; color: var(--muted); font-size: 11px; }
/* 关闭按钮：固定最右一列，与顶部翻页器互不干扰 */
.credit-tip .detail-close {
  width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1; padding: 0;
}
.credit-tip .detail-close:hover { color: var(--danger); border-color: var(--danger); background: #fef2f2; }
/* 积分标签变成点击入口：给出可点暗示 */
.acct-card .acct-credits.clickable { cursor: pointer; }
.acct-card .acct-credits.clickable:hover { text-decoration: underline dotted; text-underline-offset: 3px; }
.acct-card .acct-credits.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* 翻页器在浮窗顶部居中：鼠标从卡片过来路径最短，不跨出浮窗 */
.detail-pager { display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.detail-pg {
  cursor: pointer; padding: 0 8px; border: 1px solid var(--border);
  border-radius: 5px; color: var(--text); line-height: 1.5; font-size: 13px;
}
.detail-pg:hover { background: #f0f2f5; }
.detail-pg.off { opacity: .35; cursor: default; }
.detail-pg.off:hover { background: transparent; }
.detail-pg-info { color: var(--muted); font-size: 11px; }
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th, .detail-table td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.detail-table th { color: var(--muted); font-weight: 500; font-size: 11px; }
.detail-table td:nth-child(2), .detail-table td:nth-child(3), .detail-table td:nth-child(4) { text-align: right; }
.detail-table td:last-child { font-weight: 600; min-width: 112px; }
/* 套餐名列收窄，把空间让给有效期列（否则日期+临期红章会被 ellipsis 截断） */
.detail-table td:first-child { max-width: 130px; }
/* 不可用额度整行淡显 + 角标 */
.detail-table tr.detail-unusable { color: var(--muted); }
.detail-tag {
  font-size: 10px; padding: 1px 5px; margin-left: 5px; border-radius: 8px;
  background: #f0f2f5; color: var(--muted);
}
/* 临期额度（阈值内到期，与汇总条/卡片临期同口径同色系）：整行淡红底 + 到期日红字 + 临期红章 */
.detail-table tr.detail-exp-row { background: #fef2f2; }
.detail-table td.detail-exp { color: var(--danger); }
.detail-exp-tag {
  font-size: 10px; padding: 1px 5px; margin-left: 5px; border-radius: 8px;
  background: var(--danger); color: #fff; font-weight: 600;
}
.detail-sum {
  display: flex; gap: 14px; margin-top: 7px; padding-top: 6px;
  border-top: 1px solid var(--border); color: var(--muted);
}
.detail-sum b { color: var(--text); font-weight: 600; }
.detail-sum-unusable b { color: var(--muted); }

.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }

/* 顶栏/账号卡片的窄屏规则已上移到 779/679 两个断点块（与按钮断点统一），
   此处只保留与顶栏无关的设置项两列布局。 */
@media (max-width: 640px) {
  .config-grid { grid-template-columns: 1fr; }
  .config-right { padding-left: 0; border-left: none; border-top: 1px solid var(--border); padding-top: 14px; }
}
/* qwenwork 千问办公渠道色（与 qoder 紫系区分，用青蓝） */
.btn.primary.alt.qwenwork { background: #0e7490; border-color: #0e7490; }
.btn.primary.alt.qwenwork:hover { background: #155e75; }
.badge.qwenwork { background: #0e7490; }
.fees .ch-header.qwenwork td { color: #0e7490; }
.badge.glm { background: #1d4ed8; }
.fees .ch-header.glm td { color: #1d4ed8; }

/* monkeycode MonkeyCode 平台托管模型渠道色（琥珀棕，与紫/蓝/青系区分） */
.btn.primary.alt.monkeycode { background: #b45309; border-color: #b45309; }
.btn.primary.alt.monkeycode:hover { background: #92400e; }
.badge.monkeycode { background: #b45309; }
.fees .ch-header.monkeycode td { color: #b45309; }

/* raccoon 小浣熊渠道色（取客户端 branding 的紫罗兰 #8E6BF2） */
.btn.primary.alt.raccoon { background: #8e6bf2; border-color: #8e6bf2; }
.btn.primary.alt.raccoon:hover { background: #7c56e8; }
.badge.raccoon { background: #8e6bf2; }
.fees .ch-header.raccoon td { color: #8e6bf2; }

/* loomy 讯飞 Loomy 渠道色（讯飞蓝） */
.btn.primary.alt.loomy { background: #1d4ed8; border-color: #1d4ed8; }
.btn.primary.alt.loomy:hover { background: #1e40af; }
.badge.loomy { background: #1d4ed8; }
.fees .ch-header.loomy td { color: #1d4ed8; }

/* oczen：OpenCodeZen 匿名通道（暗灰蓝，与其它紫/青系区分，弱化「固定账号」观感） */
.badge.oczen { background: #475569; }
.fees .ch-header.oczen td { color: #475569; }
/* credit-na 积分「不适用」文案（匿名通道无积分） */
.credit-na { color: var(--muted, #94a3b8); font-style: italic; }

/* ---------- 用量与流水面板 ---------- */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: var(--card); padding: 5px 14px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary); color: #fff; }

.usage-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.ucard { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.ucard-label { font-size: 11px; color: var(--muted); }
.ucard-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.ucard-value.ok { color: var(--ok); }
.ucard-value.warn { color: var(--warn); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.tab { border: 0; background: transparent; padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.chart-box { width: 100%; height: 260px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty-cell { text-align: center; color: var(--muted); padding: 18px; }

/* 主面板双 Tab（账号管理 / 用量与流水） */
.main-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.mtab { border: 0; background: transparent; padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mtab.active { color: var(--primary); border-bottom-color: var(--primary); }

.pager { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; justify-content: center; }
.pager .pg-info { font-size: 12px; color: var(--muted); min-width: 48px; text-align: center; }
.pager .btn[disabled] { opacity: .4; cursor: default; }

.recent { display: flex; flex-direction: column; gap: 2px; }
.rline { display: flex; gap: 10px; align-items: baseline; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.rline:nth-child(odd) { background: var(--bg); }
.rline .rtime { color: var(--muted); width: 76px; flex-shrink: 0; }
.rline.earn .ramount { color: var(--ok); font-weight: 600; }
.rline.spend .ramount { color: var(--warn); font-weight: 600; }
.rline.expire .ramount { color: var(--danger); font-weight: 600; }
.rline .ramount { width: 90px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.rline .rname { color: var(--muted); flex-shrink: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rline .racct { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rline .rbal { color: var(--muted); flex-shrink: 0; }

.muted { color: var(--muted); }

@media (max-width: 640px) {
  .usage-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 运行统计面板（第三个主 tab，数据来自 /api/stats） ---------- */
#mtabStats { font-size: 13px; line-height: 1.6; color: var(--text); }

/* 区块卡片：白色圆角卡（观感对齐 .panel，边距收窄适配多区块纵排） */
#mtabStats .st-panel,
#mtabStats .st-block {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
#mtabStats > .st-panel:first-child,
#mtabStats > .st-block:first-child,
#mtabStats > .st-rotation:first-child,
#mtabStats > .st-expiry:first-child,
#mtabStats > .st-abnormal:first-child { margin-top: 0; }
#mtabStats .st-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: #52525b;
}
#mtabStats .st-sec-info {
  /* 里程碑计数靠右（Token 多天行插在标题与它之间，用 margin-left:auto 推右） */
  margin-left: auto;
  padding-left: 12px;
  font-size: 11px;
  font-weight: 400;
  color: #a1a1aa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 更新角标紧贴里程碑左侧（auto 由里程碑吸收，角标不吃剩余空间） */
#mtabStats #stUpdated { margin-left: 0; padding-left: 8px; }
/* 拉取失败：数据停止更新的可见警示（陈旧数据无感知是运营面板大忌） */
#mtabStats #stUpdated.st-stale { color: var(--danger); font-weight: 600; }
#mtabStats .st-block-title { font-size: 13px; font-weight: 600; color: #52525b; margin-bottom: 6px; }
#mtabStats .st-hint { font-weight: 400; color: #a1a1aa; margin-left: 8px; }

/* 数值列等宽数字（纵向按位对齐，跨行可比） */
#mtabStats .st-plat-accts,
#mtabStats .st-plat-credits,
#mtabStats .st-plat-in,
#mtabStats .st-plat-out,
#mtabStats .st-plat-tokens,
#mtabStats .st-plat-exp,
#mtabStats .st-plat-no,
#mtabStats .st-sum-val,
#mtabStats .st-token .st-tk-val,
#mtabStats .st-idx,
#mtabStats .st-mono,
#mtabStats .st-ex-tag,
#mtabStats .st-ex-date,
#mtabStats .st-logbox { font-variant-numeric: tabular-nums; }

/* 全局汇总横条：标签 + 等宽数值 + 小字注解横向排布，点号分隔，窄屏换行 */
#mtabStats .st-sum {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 0;
  margin-top: 7px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f8fa;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}
#mtabStats .st-sum > .st-sum-item { white-space: nowrap; }
#mtabStats .st-sum > .st-sum-item::after { content: "·"; color: #d4d8e0; margin: 0 9px; }
#mtabStats .st-sum > .st-sum-item:last-child::after { content: ""; margin: 0; }
#mtabStats .st-sum-val { margin-left: 5px; font-size: 13px; font-weight: 600; color: var(--text); }
#mtabStats .st-sum-val.ok { color: var(--ok); }    /* 收入积分 */
#mtabStats .st-sum-val.warn { color: var(--warn); }  /* 消耗积分 / Token */
#mtabStats .st-sum-val.pur { color: #7c3aed; }     /* 总额度（资产） */
#mtabStats .st-sum-val.risk { color: var(--danger); } /* 今日到期（今晚作废） */
#mtabStats .st-sum-sub { font-size: 10px; color: #a1a1aa; }
#mtabStats .st-sum-sub::before { content: "（"; }
#mtabStats .st-sum-sub::after { content: "）"; }

/* 平台表：grid 固定列宽 + 满高右边框做竖线。
   中列按内容量收窄（固定 px）、末列弹性吸收剩余并左对齐——避免「数字浮在空白里」。
   不要用 grid 的 auto 列：各列按各行内容独立解析，跨行会错位。 */
#mtabStats .st-plat { margin-top: 8px; }
#mtabStats .st-plat-row {
  display: grid;
  grid-template-columns: 28px 150px 52px 100px 80px 80px 112px 84px 84px 1fr;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
}
#mtabStats .st-plat-row > span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  padding: 5px 10px;
  overflow: hidden;
  border-right: 1px solid rgba(23, 23, 23, 0.06);
}
/* 末列（7日内到期）：吸收剩余宽度、左对齐、不画右边框 */
#mtabStats .st-plat-row > span:last-child { justify-content: flex-start; border-right: none; }
#mtabStats .st-plat-row.st-plat-head > span { padding: 4px 10px; }
#mtabStats .st-plat-row.st-plat-head .st-plat-slot,
#mtabStats .st-plat-row.st-plat-head .st-plat-accts,
#mtabStats .st-plat-row.st-plat-head .st-plat-credits,
#mtabStats .st-plat-row.st-plat-head .st-plat-in,
#mtabStats .st-plat-row.st-plat-head .st-plat-out,
#mtabStats .st-plat-row.st-plat-head .st-plat-tokens,
#mtabStats .st-plat-row.st-plat-head .st-plat-exp {
  color: #a1a1aa;
  font-size: 11.5px;
  font-weight: 500;
}
#mtabStats .st-plat-row > .st-plat-no { justify-content: center; color: #a1a1aa; font-size: 11.5px; }
/* 平台列左对齐（徽章靠左），其余列右对齐；选择器带 > span 提特异性防覆盖 */
#mtabStats .st-plat-row > .st-plat-slot { justify-content: flex-start; }
#mtabStats .st-plat-slot .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#mtabStats .st-plat-accts { color: #52525b; font-size: 11.5px; }
#mtabStats .st-plat-credits,
#mtabStats .st-plat-in,
#mtabStats .st-plat-out,
#mtabStats .st-plat-tokens,
#mtabStats .st-plat-exp { font-size: 11.5px; }
#mtabStats .st-plat-credits { color: var(--text); font-size: 12px; font-weight: 600; }
#mtabStats .st-plat-in { color: var(--ok); }
#mtabStats .st-plat-out { color: var(--warn); }
#mtabStats .st-plat-tokens { color: #52525b; }
#mtabStats .st-plat-exp { color: #52525b; }
#mtabStats .st-plat-exp.st-risk { color: var(--danger); font-weight: 600; }
/* 零值置灰（放各列配色之后，靠后覆盖） */
#mtabStats .st-plat-zero { color: #c8ccd4; font-weight: 400; }
#mtabStats .st-plat-row.st-plat-sum-row {
  border-bottom: none;
  border-top: 1px solid rgba(23, 23, 23, 0.08);
  font-weight: 600;
}
#mtabStats .st-plat-row.st-plat-sum-row .st-plat-slot { color: #52525b; }

/* Token 多天行（标题右侧，虚线分隔，数值蓝色等宽） */
#mtabStats .st-token {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 0;
  margin-left: 14px;
  padding-left: 12px;
  border-left: 1px dashed var(--border);
  min-width: 0;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.5;
}
#mtabStats .st-token > .st-tk-item { white-space: nowrap; }
#mtabStats .st-token > .st-tk-item::after { content: "·"; color: var(--border); margin: 0 6px; }
#mtabStats .st-token > .st-tk-item:last-child::after { content: ""; margin: 0; }
#mtabStats .st-token .st-tk-val { color: var(--primary); font-size: 11px; }

/* 运行日志容器（4 行高度，自动吸底） */
#mtabStats .st-logbox {
  margin-top: 8px;
  height: 88px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: #f7f8fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  line-height: 1.5;
  user-select: text;
  cursor: text;
}
#mtabStats .st-logline { margin-bottom: 2px; word-break: break-all; }
#mtabStats .st-log-time { color: #a1a1aa; margin-right: 6px; }
#mtabStats .st-log-info { color: var(--text); }
#mtabStats .st-log-warn { color: var(--warn); }
#mtabStats .st-log-err { color: var(--danger); }

/* 列表/表格通用 */
#mtabStats .st-scroll { max-height: 260px; overflow: auto; scrollbar-gutter: stable; }
/* 请求日志/模型消耗限高：表头 + 4 行 */
#mtabStats .st-scroll-4 { max-height: 141px; }
/* 最近临期限高（与 st-scroll-4 同视觉预算） */
#mtabStats .st-ex-scroll { max-height: 143px; }
#mtabStats table.st-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
#mtabStats table.st-table th,
#mtabStats table.st-table td { padding: 4px 8px; text-align: left; border-bottom: 1px solid rgba(23, 23, 23, 0.08); }
#mtabStats table.st-table th { color: #a1a1aa; font-weight: 500; position: sticky; top: 0; background: var(--card); }
#mtabStats table.st-table tr:hover td { background: #f7f8fa; }
#mtabStats .st-mono { font-size: 11.5px; }
#mtabStats .st-empty { color: #a1a1aa; text-align: center; padding: 10px 0; }
#mtabStats .st-bad { color: var(--danger); font-weight: 600; }

/* 模型消耗表：table-layout:fixed 防内容撑列；模型列定宽、末列弹性左对齐 */
#mtabStats table.st-models { table-layout: fixed; }
#mtabStats table.st-models th:nth-child(1) { width: 36px; }
#mtabStats table.st-models th:nth-child(2) { width: 240px; }
#mtabStats table.st-models th:nth-child(3) { width: 60px; }
#mtabStats table.st-models th:nth-child(4) { width: 92px; }
#mtabStats table.st-models th:nth-child(5) { width: 84px; }
#mtabStats table.st-models th,
#mtabStats table.st-models td { border-right: 1px solid rgba(23, 23, 23, 0.06); }
#mtabStats table.st-models tr > *:last-child { border-right: none; }
#mtabStats .st-idx { color: #a1a1aa; font-size: 11.5px; }
#mtabStats table.st-models td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
#mtabStats table.st-models th:nth-child(n+3):not(:last-child),
#mtabStats table.st-models td:nth-child(n+3):not(:last-child) { text-align: right; }
#mtabStats table.st-models th:last-child,
#mtabStats table.st-models td:last-child { text-align: left; }

/* 最近临期（块级单元格 + 满高右边框竖线，末列弹性左对齐） */
#mtabStats .st-ex-row {
  display: grid;
  grid-template-columns: 30px 110px 168px 100px 96px 1fr;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
}
#mtabStats .st-ex-row > span {
  min-width: 0;
  padding: 5px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(23, 23, 23, 0.06);
}
#mtabStats .st-ex-row > span:last-child { border-right: none; }
#mtabStats .st-ex-tag { color: #a1a1aa; font-size: 11.5px; }
#mtabStats .st-ex-row.st-ex-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  color: #a1a1aa;
  font-weight: 500;
  font-size: 11.5px;
}
#mtabStats .st-ex-row.st-ex-head > span { padding: 4px 10px; }
#mtabStats .st-ex-name { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
#mtabStats .st-ex-plat-slot { overflow: hidden; }
#mtabStats .st-ex-date { color: #52525b; font-size: 11.5px; }
#mtabStats .st-ex-days { color: #52525b; }
#mtabStats .st-ex-amt { color: #52525b; overflow: hidden; text-overflow: ellipsis; }
#mtabStats .st-ex-row.st-risk { color: var(--danger); font-weight: 600; }
#mtabStats .st-ex-row.st-risk .st-ex-tag,
#mtabStats .st-ex-row.st-risk .st-ex-days,
#mtabStats .st-ex-row.st-risk .st-ex-date,
#mtabStats .st-ex-row.st-risk .st-ex-amt { color: var(--danger); }

/* 使用中 / 接棒顺序 */
#mtabStats .st-rot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  padding: 4px 2px;
  font-size: 12px;
  border-bottom: 1px solid rgba(23, 23, 23, 0.06);
  white-space: nowrap;
}
#mtabStats .st-rot-cur { color: #52525b; }
#mtabStats .st-rot-cur b { color: var(--text); }
#mtabStats .st-rot-none { color: #a1a1aa; }
#mtabStats .st-rot-nexts { color: #a1a1aa; }
#mtabStats .st-rot-next { margin-right: 6px; }

/* 异常账号（无异常时整块隐藏；填充后 JS 补挂 st-block 卡片样式） */
#mtabStats .st-ab-sums { margin-left: auto; display: inline-flex; gap: 6px; }
#mtabStats .st-ab-sum {
  padding: 1px 8px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  border: 1px solid transparent;
}
#mtabStats .st-ab-scroll { max-height: 156px; overflow-y: auto; }
#mtabStats .st-ab-row {
  display: grid;
  grid-template-columns: 30px 76px 110px 150px 1fr 96px 84px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  border-bottom: 1px solid rgba(23, 23, 23, 0.08);
}
#mtabStats .st-ab-row > span {
  min-width: 0;
  padding: 5px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid rgba(23, 23, 23, 0.06);
}
#mtabStats .st-ab-row > span:last-child { border-right: none; }
#mtabStats .st-ab-row.st-ab-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  color: #a1a1aa;
  font-weight: 500;
  font-size: 11.5px;
}
#mtabStats .st-ab-row.st-ab-head > span { padding: 4px 10px; color: #a1a1aa; }
#mtabStats .st-ab-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  border: 1px solid transparent;
}
#mtabStats .st-ab-idx { color: #a1a1aa; font-size: 11.5px; text-align: center; }
#mtabStats .st-ab-name { font-weight: 500; }
#mtabStats .st-ab-plat-slot { overflow: hidden; }
#mtabStats .st-ab-reason { color: #52525b; }
#mtabStats .st-ab-until { color: #52525b; font-size: 11.5px; }
#mtabStats .st-ab-credit { color: #52525b; font-size: 11.5px; }
/* 三级配色：停用=红（需人工）· 整号冷却=橙 · 错误累计=灰黄（预警） */
#mtabStats .st-ab-disabled .st-ab-tag { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }
#mtabStats .st-ab-disabled .st-ab-tag-slot { border-right-color: rgba(185, 28, 28, 0.18); }
#mtabStats .st-ab-sum.st-ab-disabled { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }
#mtabStats .st-ab-cool .st-ab-tag { color: #c2410c; background: #ffedd5; border-color: #fed7aa; }
#mtabStats .st-ab-cool .st-ab-tag-slot { border-right-color: rgba(194, 65, 12, 0.18); }
#mtabStats .st-ab-sum.st-ab-cool { color: #c2410c; background: #ffedd5; border-color: #fed7aa; }
#mtabStats .st-ab-err .st-ab-tag { color: #a16207; background: #fef9c3; border-color: #fde68a; }
#mtabStats .st-ab-err .st-ab-tag-slot { border-right-color: rgba(161, 98, 7, 0.18); }
#mtabStats .st-ab-sum.st-ab-err { color: #a16207; background: #fef9c3; border-color: #fde68a; }

@media (max-width: 640px) {
  #mtabStats .st-plat-row { grid-template-columns: 24px 96px 40px 76px 60px 60px 84px 64px 64px 1fr; font-size: 11px; }
  #mtabStats .st-ex-row { grid-template-columns: 24px 88px 120px 96px 88px 1fr; font-size: 11px; }
  #mtabStats .st-ab-row { grid-template-columns: 24px 64px 88px 110px 1fr 76px 64px; font-size: 11px; }
}

/* cline：Cline 免费池渠道（深绿，与既有紫/青/蓝系均不冲突） */
.btn.primary.alt.cline { background: #15803d; border-color: #15803d; }
.btn.primary.alt.cline:hover { background: #166534; }
.badge.cline { background: #15803d; }
.fees .ch-header.cline td { color: #15803d; }

/* ==========================================================================
   响应式适配（手机/平板竖屏）
   —— 原实现只有「卡片改单列 / 使用卡 2 列」两条窄屏规则，其余区块在手机竖屏
   都会水平溢出（实测 390px 视口下 scrollWidth=711px）。溢出除本身难看外还有个
   隐蔽后果：.overlay{position:fixed;inset:0} 的包含块是 ICB（=scrollWidth），
   页面一溢出，所有弹层（设置/帮助/添加账号）都会整体偏移到屏外。
   原则：所有新规则都关在 max-width 媒体查询里，≥900px 完全走原桌面样式。
   ========================================================================== */

/* 1) 账号管理按钮区 + 顶栏：≤779px 改上下两段/换行
   —— 渠道按钮早期是 repeat(5,auto) + 内联 grid-column:1..5，390px 下宽 598px、溢出 321px；
   现为 6 列（摆位全归 CSS）+ 紧凑档字号，6 列需视口 ≥ 约 780px。
   顶栏同期问题：.top-info 的 1fr 隐含下界是 min-content（接口地址/API-Key 文本不收缩），
   实测 650–750px 区间顶栏图标被推出视口（最大 102px），而换行断点原先是 640 太低。
   两者统一卡在 779：≤779 顶栏换行（品牌+图标一行、接口信息独占一行）、按钮改自适应列。 */
@media (max-width: 779px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .brand { order: 1; }
  .top-icons { order: 2; margin-left: auto; }
  .top-info { order: 3; flex: none; width: 100%; }
  .panel-actions-wrap { flex-direction: column; align-items: stretch; gap: 8px; }
  .pa-spacer { display: none; }
  .pa-left { flex-direction: row; flex-wrap: wrap; }
  .pa-right { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); width: 100%; }
  .pa-right .btn { justify-self: stretch; padding: 8px 10px; }
}

/* 2) 顶栏接口信息：≤479px 单列。两列时 1fr 的 min-content 下界仍会撑破
   （接口地址/API-Key 文本不收缩），minmax(0,1fr) 解除后单元格可收缩、长文本走 ellipsis。 */
@media (max-width: 479px) {
  .top-info { grid-template-columns: minmax(0, 1fr); }
}

/* 3) 账号卡片：1fr 轨道的 min 是 min-content，操作按钮行（4×28px ≈ 365px）
   在窄屏会撑破卡片并被 .panel 裁掉（实测 660px 视口溢出 16px）。 */
@media (max-width: 679px) {
  .acct-grid { grid-template-columns: minmax(0, 1fr); }
  .acct-card { min-width: 0; }
  .acct-card .acct-top,
  .acct-card .acct-mid { flex-wrap: wrap; }
}

/* 4) 费率表：4 列（模型|倍率|模型|倍率）必然溢出（390px 下 634px）。
   实测 700px 时残余 4px、720px 已为 0，故 719px 以下只留「模型|倍率」两列。 */
@media (max-width: 719px) {
  .fees table th:nth-child(n+3),
  .fees table td:nth-child(n+3) { display: none; }
  .fees .full-id { white-space: normal; word-break: break-all; }
}

/* 5) 运行统计：平台表/临期表/异常表是固定 N 列 grid。平台表实测最小内容宽度 790px
   （区块可用宽 = 视口 − 65），实测 vw ≤ 880 时单元格越出卡片被裁、vw ≥ 900 时恰好为 0
   （由于页面本身在更窄处就有滚动，且单元格会被 .panel 裁掉，所以这是「直接视口看不出来」
   的隐蔽截断）。≤899px 给容器横向滚动；≥900px 走原样，保持与旧版逐像素一致。
   统计列都有信息量，横向滚动比隐藏列更可接受。 */
@media (max-width: 899px) {
  #mtabStats .st-plat,
  #mtabStats .st-ex-scroll,
  #mtabStats .st-ab-scroll,
  #mtabStats .st-scroll { max-width: 100%; overflow-x: auto; }
}

/* 6) 用量与流水：模型表压缩内边距（列内文字可折行），流水行宽度写死会在窄屏被裁。 */
@media (max-width: 640px) {
  .table th, .table td { padding: 7px 6px; }
  #tabToken { overflow-x: auto; }
  .rline { flex-wrap: wrap; }
  .rline .rtime,
  .rline .ramount,
  .rline .rname { width: auto; max-width: none; }
}

/* 7) 触控目标：图标按钮 28×28、图标链 32×32 都低于 44px 的触控建议值。
   只在「无 hover + 粗指针」设备放大，桌面鼠标设备不受影响。 */
@media (hover: none) and (pointer: coarse) {
  .icon-op { width: 34px; height: 34px; font-size: 15px; }
  .icon-link { width: 38px; height: 38px; }
  .fees-tab { padding: 7px 12px; }
  .credit-tip .detail-close { width: 30px; height: 30px; }
}

/* 缓存利用率单元格（用量与流水 / 运行统计）：三态渲染见 app.js 的 cacheCell。
   有样本 → 等宽数字便于纵向比对；无样本 → 沿用 .muted 的「—」低对比显示。 */
.cache-pct { font-variant-numeric: tabular-nums; }
