/* 小浣熊网关控制台样式
   设计取向：信息密度优先的运维面板。浅色背景、白色卡片、紧凑表格；
   accent 用暖橙（对齐小浣熊品牌），状态色只用三种（绿/黄/红），不堆颜色。 */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e8ec;
  --line-strong: #d3d7de;
  --text: #1f2430;
  --text-2: #5b6474;
  --text-3: #8b93a1;
  --accent: #e2611a;
  --accent-soft: #fff2e9;
  --ok: #12805c;
  --ok-soft: #e7f7f0;
  --warn: #b06d00;
  --warn-soft: #fff6e0;
  --bad: #c0392b;
  --bad-soft: #fdecea;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 28, 40, .04), 0 8px 24px rgba(20, 28, 40, .04);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; letter-spacing: .2px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-2); }
code { font-family: var(--mono); font-size: 12px; background: #f1f3f6; padding: 1px 5px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 24px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 20px;
}
.sub { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: #f1f3f6; color: var(--text-2);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.mono { font-family: var(--mono); }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 4px; padding: 10px 24px 0;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 67px; z-index: 19;
}
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 9px 14px; font-size: 13px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 20px 24px 60px; max-width: 1440px; margin: 0 auto; }
.pane { display: none; }
.pane.active { display: block; animation: fade .16s ease; }
@keyframes fade { from { opacity: .4; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---------- 卡片 ---------- */
.cards {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card .label { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 650; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.card .foot { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.card.accent .value { color: var(--accent); }
.card.ok .value { color: var(--ok); }
.card.warn .value { color: var(--warn); }
.card.bad .value { color: var(--bad); }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions.end { justify-content: flex-end; margin-top: 10px; }
.hint { font-size: 12px; color: var(--text-3); margin: 0; line-height: 1.6; }
.panel > .hint { padding: 0 16px 12px; }
.subhead { padding: 14px 16px 6px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 12.5px;
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--text); transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #cf5413; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #f1f3f6; color: var(--text); }
.btn.mini { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.danger { color: var(--bad); border-color: #f2c9c4; }
.btn.danger:hover { background: var(--bad-soft); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.grid th {
  text-align: left; font-weight: 600; color: var(--text-3); font-size: 11.5px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fbfcfd; text-transform: uppercase; letter-spacing: .4px;
}
table.grid td {
  padding: 10px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: middle;
}
table.grid tbody tr:hover { background: #fafbfc; }
table.grid tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: var(--mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.uid { color: var(--text-3); font-size: 11px; font-family: var(--mono); }
.acct-name { font-weight: 550; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; background: #f1f3f6; color: var(--text-2);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.blue { background: #e8efff; color: var(--blue); }
.rowacts { display: flex; gap: 5px; flex-wrap: wrap; }
.err-text { color: var(--bad); font-size: 11.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 键值网格 ---------- */
.kv-grid { display: grid; gap: 0 24px; padding: 4px 16px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed #eef0f4; font-size: 12.5px; }
.kv .k { color: var(--text-3); }
.kv .v { font-weight: 550; font-variant-numeric: tabular-nums; }

/* ---------- 日志 ---------- */
.logbox {
  margin: 0; padding: 12px 16px; max-height: 62vh; overflow: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
  background: #fbfcfd; white-space: pre-wrap; word-break: break-all;
}
.logbox .lt { color: var(--text-3); margin-right: 8px; }
.switch { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }

/* ---------- 表单 ---------- */
textarea, input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 11px;
  background: #fff; outline: none;
}
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.6; }
#config-editor { min-height: 56vh; margin: 0 16px 12px; width: calc(100% - 32px); }
#config-msg { padding: 0 16px 14px; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(18, 24, 34, .38);
  display: grid; place-items: center; z-index: 50; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card); border-radius: 14px; padding: 20px 22px;
  width: min(680px, 100%); max-height: 88vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .18);
}
.modal-box.narrow { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-tabs { display: flex; gap: 6px; margin: 12px 0 16px; }
.mtab {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 12.5px;
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--text-2);
}
.mtab.active { background: var(--accent-soft); border-color: #f3c3a5; color: var(--accent); font-weight: 600; }
.mode { display: none; }
.mode.active { display: block; }
.modal-box h2 { margin-bottom: 4px; }
.modal-box input[type="password"] { margin: 12px 0 4px; }

.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 4px; }
#qr-canvas { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.qr-status { font-size: 12.5px; color: var(--text-2); }
.qr-status.ok { color: var(--ok); }
.qr-status.bad { color: var(--bad); }

/* ---------- 客户端目录扫描 / 手机号登录 ---------- */
.scan-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.scan-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfbfc;
}
.scan-item.picked { border-color: var(--accent); background: var(--accent-soft); }
.scan-item input[type="checkbox"] { margin-top: 3px; }
.scan-item .body { flex: 1; min-width: 0; }
.scan-item .who { font-size: 13px; font-weight: 600; }
.scan-item .path {
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scan-item .meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.scan-item .bad { color: var(--bad); }
.scan-item .warn { color: #b06d00; }
.field-row { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.field-row input { flex: 1; margin: 0; }

/* ---------- 模型卡片 ---------- */
.model-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 10px; padding: 4px 0 8px;
}
.model-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  background: #fff; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, box-shadow .12s;
}
.model-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.model-card.free { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.mc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mc-title {
  appearance: none; border: 0; background: transparent; padding: 0; margin: 0;
  text-align: left; cursor: copy;
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  line-height: 1.45; min-width: 0; color: var(--text);
  /* 断行优先在连字符处（模型 id 全是 - 分隔），实在放不下才任意断，
     否则会出现 "flash-101 / 7" 这种拦腰截断。 */
  word-break: normal; overflow-wrap: anywhere;
}
.mc-title:hover { color: var(--blue); text-decoration: underline dotted; }
.mc-desc {
  font-size: 11.5px; color: var(--text-3); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.mc-price { font-family: var(--mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.mc-price s { color: var(--text-3); font-weight: 400; font-size: 11px; }
.mc-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.mc-stats {
  display: flex; flex-wrap: wrap; gap: 4px 14px; padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px; color: var(--text-3);
}
/* 每项整体换行，不要拦腰折断（「上下文 100 万」被拆成两行很难读）。 */
.mc-stats > span { white-space: nowrap; }
.mc-stats b { color: var(--text-2); font-weight: 600; font-size: 12.5px; }
/* 实测耗时：>25s 提醒、>60s 警告。上游同一模型能从 5s 漂到 137s，
   不标颜色的话用户只会以为「面板卡死」。 */
.mc-stats b.lat-warn { color: var(--warn); }
.mc-stats b.lat-slow { color: var(--bad); }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

/* ---------- 配置表单 ---------- */
.seg { display: inline-flex; background: #f1f2f5; border-radius: 8px; padding: 3px; gap: 2px; margin: 6px 0 12px; }
.seg-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; color: var(--text-2);
  padding: 5px 14px; border-radius: 6px;
}
.seg-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.cfg-section { margin: 16px 0 4px; }
.cfg-section > h3 {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 16px; }
.cfg-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cfg-row.wide { grid-column: 1 / -1; }
.cfg-label { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.cfg-label code { font-size: 11px; color: var(--text-3); }
.cfg-row input[type="text"], .cfg-row input[type="password"], .cfg-row input[type="number"], .cfg-row select {
  margin: 0; width: 100%; box-sizing: border-box;
}
.cfg-row textarea { min-height: 64px; font-size: 12px; }
.cfg-row .hint { font-size: 11px; }
.cfg-bool { display: flex; align-items: center; gap: 8px; height: 34px; }

/* 别名：点一下复制 */
.tag.alias {
  appearance: none; border: 1px dashed var(--line-strong); cursor: copy;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.7;
  background: #fbfcfd; color: var(--text-2); padding: 0 6px;
}
.tag.alias:hover { border-color: var(--blue); color: var(--blue); background: #f2f6ff; }
.mc-aliases { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.mc-aliases .hint { font-size: 11px; }
.mc-note {
  font-size: 11px; color: var(--warn); background: var(--warn-soft);
  border-radius: 6px; padding: 3px 8px; line-height: 1.5;
}
/* 上游未列出 / 目录外的卡片：虚线边框，和正常可选项区分开 */
.model-card.ghost { border-style: dashed; background: #fcfcfd; }
.model-card.off { opacity: .6; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .topbar { padding: 12px 14px; }
  .brand .sub { display: none; }
  .tabs { padding: 8px 14px 0; top: 63px; overflow-x: auto; }
  main { padding: 14px 12px 50px; }
  table.grid th, table.grid td { padding: 8px 9px; }
  .hide-sm { display: none; }
}

.platform-picker{display:flex;align-items:center;gap:8px;font-size:13px}.platform-picker select,.credential-grid select{padding:8px 12px;border:1px solid var(--line,#ddd);border-radius:8px;background:var(--bg,#fff);color:inherit}.credential-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:14px 0}.credential-grid label{display:flex;flex-direction:column;gap:6px;font-size:13px}.credential-grid input{width:100%;box-sizing:border-box;padding:9px;border:1px solid #ddd;border-radius:7px}.platform-card{border-left:3px solid #e2611a}.platform-card.loomy{border-left-color:#6177d8}@media(max-width:760px){.credential-grid{grid-template-columns:1fr}.topbar{flex-wrap:wrap;gap:12px}.topbar-right{flex-wrap:wrap}}

.platform-picker{white-space:nowrap;flex-shrink:0}
