/* 运模公司 · 控制台
   风格：data-terminal —— 扁平、细线分隔、颜色只上数据
   accent 取自站标的天青色（#63b6de → #1e7395） */

:root {
  --ground: #171719;
  --surface: #131217;
  --raised: #212023;
  --border: #222224;
  --rule: #1b1a1f;
  --text: #f2f3f4;
  --muted: #8a8c92;
  --dim: #63656b;
  --accent: #6aa9c4;
  --accent-dim: #47778a;
  --positive: #44a282;
  --negative: #e5566f;
  --warning: #d9a441;

  --hit: #b7dde6;
  --miss: #6ba8bc;
  --out: #2f657a;
  --line: #4f94c7;

  --c1: #6aa9c4;
  --c2: #8e7cc3;
  --c3: #d08c60;
  --c4: #7fb069;
  --c5: #c46d7f;
  --c6: #5e7ce2;
  --c7: #b8a76a;
  --c8: #79a6a0;

  --r: 6px;
  --pad: 32px;
  --gap: 24px;
  --ctl: 34px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --sans: "Public Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 亮色：同一套令牌换值，结构不动。暖白而不是纯白，暗色下更像纸而不是屏幕。 */
:root[data-theme="light"] {
  --ground: #f6f6f7;
  --surface: #ffffff;
  --raised: #f1f1f3;
  --border: #e4e4e8;
  --rule: #ededf0;
  --text: #16171a;
  --muted: #61636a;
  --dim: #8f9198;
  --accent: #2c7891;
  --accent-dim: #8db4c2;
  --positive: #2b8264;
  --negative: #c33a50;
  --warning: #9a6c12;

  --hit: #9ecdd9;
  --miss: #4e94a9;
  --out: #1f5b6f;
  --line: #2c7891;

  --c1: #2c7891;
  --c2: #6d5aa8;
  --c3: #b06a3a;
  --c4: #5c8f45;
  --c5: #a44f63;
  --c6: #3f5bc4;
  --c7: #8e7c35;
  --c8: #4f7f79;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* 触摸板横向滑动 / 回弹：整个壳不许被拖动 */
  overscroll-behavior: none;
  overflow: hidden;
}

body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------------------------------------------------------------- 骨架 */

.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 22px 16px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}

/* ---------------------------------------------------------------- 品牌 */

.brand {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 2px 4px 0;
}

/* 站标：顶到站名上沿、底到副标题下沿，跟文字块同高 */
.brand-mark {
  height: 52px;
  width: 52px;
  flex: none;
  object-fit: contain;
  align-self: flex-start;
}

.brand-text { display: flex; flex-direction: column; justify-content: space-between; gap: 2px; min-width: 0; }

/* 站名是 svg 字形，走遮罩上色：亮暗色自动跟着主题走，不用两套图 */
.brand-name {
  display: block;
  height: 20px;
  width: 71px;
  flex: none;
  background-color: var(--text);
  -webkit-mask: url(/assets/name.svg) no-repeat left center / contain;
  mask: url(/assets/name.svg) no-repeat left center / contain;
}

.brand-tag {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--dim);
  letter-spacing: 0.01em;
}

/* ---------------------------------------------------------------- 导航 */

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  border-radius: 4px;
  transition: color 0.12s ease;
}

.nav-item svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.nav-item:hover { color: var(--text); }

.nav-label { position: relative; }

.nav-item.is-active { color: var(--text); }
.nav-item.is-active .nav-label::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--accent);
}

.nav-group { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }

.nav-group-label {
  padding: 0 4px 4px;
  font-size: 13px;
  letter-spacing: 0;
  color: var(--muted);
}

.nav-sub {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
  margin-left: 23px;
  height: 29px;
  padding: 0 2px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.nav-sub:hover { color: var(--muted); }
.nav-sub.is-active { color: var(--accent); }
.nav-sub.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: var(--accent-dim);
}

/* ---------------------------------------------------------------- 账号 */

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--raised);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.account-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { font-size: 10.5px; color: var(--dim); }

.linkbtn {
  margin-left: auto;
  background: none;
  border: 0;
  padding: 4px 2px;
  color: var(--dim);
  font-size: 11.5px;
  cursor: pointer;
}
.linkbtn:hover { color: var(--negative); }

/* ---------------------------------------------------------------- 主区 */

.main {
  padding: 28px var(--pad) 28px;
  max-width: none;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.page-sub {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.head-actions { display: flex; gap: 8px; align-items: center; padding-top: 2px; }

/* ---------------------------------------------------------------- 控件 */

.ctl {
  height: var(--ctl);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}

.ctl:hover { border-color: var(--hover-line); background: var(--raised); }
.ctl.is-open { border-color: var(--accent-dim); }
.ctl-key { color: var(--dim); }
.ctl-val { color: var(--text); }
.ctl svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; opacity: 0.6; }

.btn {
  height: 34px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--raised); border-color: var(--hover-line); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #0c1619;
  font-weight: 600;
}
.btn-primary:hover { background: #7cb8d1; border-color: transparent; }

.btn-danger { color: var(--negative); border-color: var(--danger-line); }
.btn-danger:hover { background: #2a1a20; border-color: #55303a; }

.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------------------------------------------------------------- 过滤条 */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}

.spacer { flex: 1 1 auto; }

/* ---------------------------------------------------------------- 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px 0;
}

.card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.card-note { font-size: 11.5px; color: var(--dim); }

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- KPI */

.kpi-strip {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.kpi {
  position: relative;
  padding: 17px 20px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}
.kpi + .kpi { box-shadow: inset 1px 0 0 var(--border); }

.kpi-label { font-size: 12px; color: var(--muted); letter-spacing: 0.01em; }
.kpi-value {
  margin-top: 7px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
}
.kpi-value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 5px; }
.kpi-delta { margin-top: 5px; font-size: 11.5px; color: var(--dim); }
.kpi-delta.is-up-bad { color: var(--negative); }
.kpi-delta.is-down-good { color: var(--positive); }

/* ---------------------------------------------------------------- 图表 */

.chart-card { margin-top: 16px; padding-bottom: 12px; }

.legend { display: flex; gap: 14px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend-dot { width: 7px; height: 7px; border-radius: 1px; flex: none; }

.plot { position: relative; padding: 6px 8px 0 4px; }
.plot svg { display: block; width: 100%; height: 232px; overflow: visible; }

.tip {
  position: absolute;
  z-index: 5;
  min-width: 132px;
  padding: 9px 11px;
  background: var(--menu-bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 11.5px;
  color: var(--muted);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.1s ease;
}
.tip.is-on { opacity: 1; }
.tip-date { color: var(--text); font-size: 12px; margin-bottom: 6px; letter-spacing: 0.01em; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; line-height: 1.7; }
.tip-row b { color: var(--text); font-weight: 500; }
.tip-dot { display: inline-block; width: 6px; height: 6px; border-radius: 1px; margin-right: 6px; vertical-align: 1px; }

/* ---------------------------------------------------------------- 表格 */

.table-card { margin-top: 16px; overflow: hidden; border-radius: var(--r); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 12px 20px 10px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--dim);
  white-space: nowrap;
}

tbody td {
  padding: 11px 20px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  vertical-align: middle;
}

tbody tr:hover td { background: #16151a; }

td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; }

.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

.model-cell { display: flex; flex-direction: column; gap: 1px; }
.model-id { font-family: var(--mono); font-size: 12.5px; }
.model-name { font-size: 11.5px; color: var(--dim); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.chip-on { color: var(--positive); border-color: #24443a; }
.chip-warn { color: var(--warning); border-color: #453a20; }
.chip-off { color: var(--dim); }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

.iconbtn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.iconbtn:hover { background: var(--raised); color: var(--text); }
.iconbtn.is-danger:hover { color: var(--negative); background: #231519; }
.iconbtn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.empty {
  padding: 44px 20px 48px;
  text-align: center;
  color: var(--dim);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- 弹层 */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(8, 8, 10, 0.66);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 22px 22px 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.modal h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.modal p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

.field { margin-top: 18px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }

.input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.input:focus { border-color: var(--accent-dim); }

.secret {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 11px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 999px;
  background: #22222a;
  border: 1px solid #33333c;
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ---------------------------------------------------------------- 日历 */

.cal-pop {
  position: fixed;
  z-index: 50;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.cal-presets {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  background: var(--strip-bg);
}

.cal-preset {
  border: 0;
  background: none;
  text-align: left;
  padding: 7px 12px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.cal-preset:hover { background: var(--raised); color: var(--text); }
.cal-preset.is-active { color: var(--accent); }

.cal-body { padding: 14px 16px 12px; }

.cal-months { display: flex; gap: 22px; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 6px;
}
.cal-title { font-size: 12.5px; font-weight: 500; letter-spacing: 0.01em; }

.cal-nav {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.cal-nav:hover { background: var(--raised); color: var(--text); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 30px); gap: 2px; }

.cal-wd {
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  color: var(--dim);
}

.cal-day {
  position: relative;
  height: 30px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink, var(--text));
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cal-day:hover { outline: 1px solid #35353c; }
.cal-day.is-out { color: var(--out-text); }
.cal-day.is-today { color: var(--text); font-weight: 600; }
.cal-day.in-range { background: rgba(106, 169, 196, 0.12); color: var(--text); }
.cal-day.is-start, .cal-day.is-end {
  background: var(--accent);
  color: #0c1619;
  font-weight: 600;
}
.cal-day.is-start:hover, .cal-day.is-end:hover { outline: 0; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--dim);
}
.cal-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
#cal-swatches { display: inline-flex; align-items: center; gap: 5px; }

.cal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--dim);
}

.skeleton {
  height: 232px;
  border-radius: 4px;
  background: var(--skeleton-bg);
  border: 1px solid var(--rule);
  animation: sk 1.4s ease-in-out infinite;
}
@keyframes sk { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.error-note {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid #3a262c;
  border-radius: var(--r);
  background: #1b1417;
  color: #e8a6b3;
  font-size: 12.5px;
}

/* ---------- 补充：预览角标、搜索框、零碎补丁类 ---------- */
.preview-tag {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  padding: 6px 12px;
  border-radius: 999px;
  background: #2a2320;
  border: 1px solid #4a3a2a;
  color: var(--warning);
  font-size: 11.5px;
}
.input.search {
  max-width: 280px;
  height: var(--ctl);
  border-radius: 999px;
  padding: 0 14px;
}
.is-default { color: var(--text); font-weight: 600; }
.tip-total { margin-top: 5px; border-top: 1px solid var(--rule); padding-top: 5px; }
.cal-legend-note { margin-left: 0; color: var(--dim); }
.cal-btns { display: flex; gap: 8px; }
.kpi-strip.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* v4：亮色下的输入框底色；模型表用固定列宽，宽了就在卡片里横滚 */
:root { --field: #0f0f11; }
:root[data-theme="light"] { --field: #fbfbfc; }
#models-wrap { overflow-x: auto; width: 100%; }
/* grid 子项默认 min-width:auto，宽表格会把整页顶宽，这里放开来 */
.main, .card, #models-wrap { min-width: 0; }
#models-wrap table { table-layout: fixed; width: 100%; min-width: 860px; }
/* 列宽唯一来源：对应 2065×1215 参考图实测 22.8/19.4/12.9/17.9/17.2/9.9
   来源列从 9.9% 提到 15%，否则「wb2api 国内号」会折成两行把行高撑开 */
#models-wrap th:nth-child(1), #models-wrap td:nth-child(1) { width: 22%; }
#models-wrap th:nth-child(2), #models-wrap td:nth-child(2) { width: 17%; }
#models-wrap th:nth-child(3), #models-wrap td:nth-child(3) { width: 11%; }
#models-wrap th:nth-child(4), #models-wrap td:nth-child(4) { width: 18%; }
#models-wrap th:nth-child(5), #models-wrap td:nth-child(5) { width: 17%; }
#models-wrap th:nth-child(6), #models-wrap td:nth-child(6) { width: 15%; white-space: nowrap; }
.up-cell, .up-main, .up-sub { white-space: nowrap; }
.price-k, .price-v { white-space: nowrap; }
.model-id { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand-tag, .nav-group-label { display: none; }
  .nav { flex-direction: row; align-items: center; gap: 14px; }
  .nav-group { margin-top: 0; flex-direction: row; align-items: center; }
  .nav-sub { margin-left: 0; }
  .sidebar-foot { margin: 0 0 0 auto; border-top: 0; padding-top: 0; }
  .main { padding: 20px 16px 40px; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi + .kpi { box-shadow: inset 0 1px 0 var(--border); }
  .cal-months { flex-direction: column; }
}

/* ---------------------------------------------------------------- v3 增补 */

.sidebar-foot { gap: 8px; }
.sidebar-foot .account-text { min-width: 0; flex: 1; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.iconbtn:hover { color: var(--text); border-color: var(--control, #3a3a3e); }
.iconbtn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn .ico-sun { display: none; }
:root[data-theme="light"] .iconbtn .ico-sun { display: block; }
:root[data-theme="light"] .iconbtn .ico-moon { display: none; }

/* 图表的形态选择器：放在 KPI 下面一条窄行里 */
.picker-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 12px;
}
.picker-hint { font-size: 11.5px; color: var(--dim); }
.chart-card .picker-hint { margin: 10px 0 0; }

.seg {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 0;
}
.seg button {
  position: relative;
  padding: 0 0 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.12s ease;
}
.seg button:hover { color: var(--text); }
.seg button.is-on { color: var(--text); }
.seg button.is-on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
}

/* 模型价格：三档竖排，标签小、数字等宽 */
.price-cell { display: grid; gap: 1px; justify-items: end; }
.price-row { display: flex; gap: 8px; align-items: baseline; }
.price-k { font-size: 10.5px; color: var(--dim); min-width: 40px; text-align: left; }
.price-v { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.price-v.is-cache { color: var(--muted); }

.up-cell { display: grid; gap: 2px; justify-items: end; }
.up-main { font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.up-sub { font-size: 10.5px; color: var(--dim); }

.offpeak-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 1px 7px;
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--accent);
  white-space: nowrap;
}
.offpeak-chip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.filters .search { max-width: 280px; }

/* 宽屏：给内容多一点呼吸，窄屏交给下面那条媒体查询 */
@media (min-width: 1600px) {
  .main { padding-left: 40px; padding-right: 40px; }
  .kpi-value { font-size: 28px; }
}

@media (min-width: 1100px) and (max-height: 760px) {
  .main { padding-top: 20px; }
  h1 { font-size: 23px; }
  .kpi { padding: 13px 18px 12px; }
  .kpi-value { font-size: 23px; margin-top: 5px; }
  .kpi-strip { margin-top: 18px; }
}

/* 亮色下浮层的投影要轻，否则像贴纸 */
:root[data-theme="light"] .cal-pop,
:root[data-theme="light"] .modal { box-shadow: 0 8px 28px rgba(20, 22, 26, 0.12); }
:root[data-theme="light"] .skeleton { background: var(--raised); }

/* ---------- v5：亮色补齐 / 滚动条 / 悬浮抖动 ---------- */

/* 站名：亮色用 #4a5561，暗色提亮一档 */
:root { --brandname: #e9ebee; }
:root[data-theme="light"] { --brandname: #4a5561; }
.brand-name { background: var(--brandname); }

/* 亮色下原来写死深色的悬浮态与浮层 */
:root[data-theme="light"] tbody tr:hover td { background: #f1f2f4; }
:root[data-theme="light"] .ctl:hover,
:root[data-theme="light"] .btn:hover { background: #f1f2f4; border-color: #d3d6db; }
:root[data-theme="light"] .btn-primary { color: #fff; background: #2c7891; border-color: transparent; }
:root[data-theme="light"] .btn-primary:hover { background: #24667c; border-color: transparent; }
:root[data-theme="light"] .btn-danger:hover { background: #fdeef1; border-color: #efc3cd; }
:root[data-theme="light"] .iconbtn:hover { background: #f0f1f3; border-color: #d3d6db; }
:root[data-theme="light"] .iconbtn.is-danger:hover { background: #fdeef1; }
:root[data-theme="light"] .cal-day:hover { outline-color: #c9cdd3; }
:root[data-theme="light"] .cal-presets { background: #fafbfc; }
:root[data-theme="light"] .skeleton { background: #eceef1; }
:root[data-theme="light"] .error-note { background: #fdf1f3; border-color: #f2c6ce; color: #ad3548; }
:root[data-theme="light"] .tip { background: #fff; border-color: #e3e5e9; box-shadow: 0 8px 24px rgba(20, 22, 26, 0.14); }
:root[data-theme="light"] .modal,
:root[data-theme="light"] .cal-pop { background: #fff; border-color: #e3e5e9; }
:root[data-theme="light"] .modal-head { border-color: #e6e8ec; }

/* 原生滚动条改成细的胶囊条，两套主题各自配色 */
* { scrollbar-width: thin; scrollbar-color: #33333a transparent; }
:root[data-theme="light"] * { scrollbar-color: #c6cad0 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background-color: #33333a;
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: #4a4a53; background-clip: content-box; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background-color: #c6cad0; background-clip: content-box; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background-color: #aab0b8; background-clip: content-box; }

/* 悬浮抖动：滚动条出现/消失会让内容区宽度跳一下，预留槽位并裁掉横向溢出 */
.main { overflow-x: clip; scrollbar-gutter: stable; }

/* 模型表：窄了就横向滚，滚动条常驻高度 */
#models-wrap { overflow: auto; max-height: none; }
#models-wrap::-webkit-scrollbar { height: 10px; }
#models-wrap table { min-width: 900px; }

/* ---------- v6：填满底部 / 列表内滚 / 日历圆形热力 / 价格对齐 ---------- */
:root { --range-band: rgba(106, 169, 196, 0.16); --heat: transparent; --heat-lo: #261014; --heat-hi: #c9485f; }
:root[data-theme="light"] { --range-band: rgba(44, 120, 145, 0.14); --heat-lo: #fbe9ec; --heat-hi: #c93a58; }

/* 视口用 dvh，缩放/改窗口高度都跟着走 */
.app { height: 100dvh; }
.main { min-height: 0; }

/* 头部与筛选条不参与压缩，只有列表/图表吸收剩余高度 */
.main > .page-head, .main > .filters, .main > .error-note { flex: 0 0 auto; }

/* 用量页：图表吃掉剩余高度（给容器一个视口高度，内部的 flex 才能分配） */
#usage-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#usage-body > * { flex: 0 0 auto; }
#usage-body > .chart-card { flex: 1 1 auto; }
.chart-card { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 180px; }
.plot-scroll { flex: 1 1 auto; min-height: 0; }
.plot { height: 100%; min-height: 160px; }
.plot-scroll { flex: 1 1 auto; min-height: 0; overflow-x: auto; overflow-y: hidden; }
.plot { height: 100%; min-height: 200px; }
.plot svg { height: 100%; display: block; }

/* 图表：左侧刻度栏固定，只有数据区 + 下方标尺横向滚动 */
.plot-row { display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; }
.plot-y { position: relative; flex: 0 0 54px; width: 54px; min-height: 0; }
.ytick {
  position: absolute;
  right: 10px;
  font-size: 10.5px;
  color: var(--tick);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

/* 模型 / 密钥列表：滚动条长在容器里，表头钉住 */
#models-wrap, #keys-wrap { overflow: auto; max-height: none; }
#models-wrap thead th, #keys-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

/* 日历：强度是小圆点，区间是连续横条，起止点是大圆 */
.cal-day { position: relative; background: none !important; isolation: isolate; }
.cal-day::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--heat, transparent);
  z-index: -1;
}
.cal-day.in-range::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 22px;
  margin-top: -11px;
  background: var(--range-band);
  z-index: -2;
}
.cal-day.is-start::after { left: 50%; }
.cal-day.is-end::after { right: 50%; }
.cal-day.is-start::before,
.cal-day.is-end::before {
  width: 27px;
  height: 27px;
  margin: -13.5px 0 0 -13.5px;
  background: var(--accent);
}
.cal-day.is-start, .cal-day.is-end { color: #fff; }
.cal-day.is-off { color: var(--dim); }
.cal-day.is-off::before { display: none; }
.cal-day.is-blank { pointer-events: none; background: none !important; }
.cal-day.is-blank::before, .cal-day.is-blank::after { display: none; }

/* 参考价格：说明在左、数值在右，两列严格对齐，折扣说明靠右不占行 */
.price-cell { display: flex; align-items: center; gap: 10px; justify-content: flex-start; }
.price-side { margin-left: 0; }
.price-rows { display: grid; grid-template-columns: 52px 64px; column-gap: 12px; row-gap: 1px; }
.price-row { display: contents; }
.price-k { text-align: left; color: var(--dim); }
.price-v { text-align: left; }
.price-rows { margin-left: 0; }
.price-side { display: flex; align-items: center; }

/* v9：让卡片真正吃掉剩余高度（.main 的直接子元素才是卡片） */
/* 列表页：卡片按内容收（不撑满窗口），内容超过可用高度时才压缩并在卡片内部滚动 */
.main > .table-card { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.main > .table-card > .table-wrap { flex: 0 1 auto; min-height: 0; overflow: auto; }

/* ---------- 来源页：左 2×2 KPI + 右账号池，下方通栏日志 ---------- */
.src-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(0, 1.22fr);
  gap: 16px;
  margin-top: 20px;
  align-items: stretch;
}
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.kpi-grid .kpi {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.kpi-grid .kpi:nth-child(2n) { border-right: 0; }
.kpi-grid .kpi:nth-child(n + 3) { border-bottom: 0; }
.kpi-grid .kpi::after { display: none; }
.src-accounts { margin-top: 0; display: flex; flex-direction: column; min-height: 0; }
.src-accounts .table-wrap, .src-logs .table-wrap { overflow: auto; max-height: calc(100dvh - 260px); }
.src-grid { align-items: start; }
.src-logs { margin-top: 16px; }
.acc-name { color: var(--text); }
.acc-note { font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.lim-model { font-size: 11px; color: var(--warning); margin-left: 8px; }
.code { font-variant-numeric: tabular-nums; }
.code-ok { color: var(--muted); }
.code-bad { color: var(--negative); font-weight: 500; }
tr.is-bad td { background: rgba(229, 86, 111, 0.05); }
.err-row td { padding-top: 0; padding-bottom: 8px; }
.err-text { font-size: 11.5px; color: var(--negative); }
@media (max-width: 1100px) { .src-grid { grid-template-columns: 1fr; } }

/* ---------- 账号显示名称（管理员可改，留空恢复原名） ---------- */
.acc-name.is-edit { cursor: text; border-radius: 3px; }
.acc-name.is-edit:hover { color: var(--accent); }
.acc-orig { font-size: 11px; color: var(--dim); margin-top: 1px; line-height: 1.30; }
.acc-table .acc-name-input { max-width: 100%; }

/* ---------- 账号备注（管理员可编辑） ---------- */
.acc-note.is-edit { cursor: text; border-radius: 3px; }
.acc-note.is-edit:hover { color: var(--text); background: var(--raised); }
.acc-note-ph { color: var(--dim); opacity: 0.75; }
.acc-note-input {
  width: 100%;
  max-width: 190px;
  background: var(--field);
  border: 1px solid var(--control);
  border-radius: 3px;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  padding: 2px 6px;
  outline: none;
}
.acc-note-input:focus { border-color: var(--accent); }

/* ---------- v9：来源页铺满视口 + KPI 与用量页统一 + 上游消耗左对齐 ---------- */
#src-body { display: flex; flex-direction: column; gap: 16px; flex: 1 1 auto; min-height: 0; }
.src-grid {
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.35fr);
  gap: 16px;
  height: clamp(200px, 31vh, 300px);
  margin-top: 0;
  align-items: stretch;
}
.src-accounts { display: flex; flex-direction: column; min-height: 0; max-height: 100%; }
.src-accounts .table-wrap,
.src-logs .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; max-height: none; }
.src-logs { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; margin-top: 0; }
.kpi-grid { gap: 0; }
.kpi-grid .kpi { padding: 17px 20px 16px; border: 0; }
.kpi-grid .kpi:nth-child(2n) { box-shadow: inset 1px 0 0 var(--border); }
.kpi-grid .kpi:nth-child(n + 3) { box-shadow: inset 0 1px 0 var(--border); }
.kpi-grid .kpi:nth-child(2n):nth-child(n + 3) {
  box-shadow: inset 1px 0 0 var(--border), inset 0 1px 0 var(--border);
}
.up-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.up-main, .up-sub { white-space: nowrap; }

/* ---------- v9b：整页不滚，列表在容器内滚 ---------- */
.main { overflow: hidden; }
#models-wrap, #keys-wrap { overflow: auto; }
.main > .table-card { min-height: 0; }

/* ---------- v9c：KPI 首格左侧粗条（两处一致） ---------- */
.kpi-strip > .kpi:first-child,
.kpi-grid > .kpi:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.kpi-strip > .kpi:nth-child(2) { box-shadow: inset 1px 0 0 var(--border); }

/* ---------- v10：四页顶部节奏统一 ---------- */
.main { gap: 16px; }
.page-head { min-height: 62px; margin: 0; }
.filters { margin-top: 0; }
.kpi-grid .kpi { justify-content: center; }

/* 亮色下补几处硬编码的深色边/底 */
:root[data-theme="light"] .chip-on { border-color: #b9ddd0; }
:root[data-theme="light"] .chip-warn { border-color: #e6d3a8; }
:root[data-theme="light"] .iconbtn.is-danger:hover { background: #fdeef1; color: #b5304a; }
:root[data-theme="light"] .acc-note.is-edit:hover { background: #f0f1f3; }
:root[data-theme="light"] .err-row td { background: rgba(201, 58, 88, 0.05); }

/* ---------- v10b：四宫格内容居中 + 亮色硬编码边色修正 ---------- */
.kpi-grid .kpi { display: flex; flex-direction: column; justify-content: center; }
:root[data-theme="light"] .ctl:hover { border-color: #d3d6db; }
:root[data-theme="light"] .btn:hover { border-color: #d3d6db; }
:root[data-theme="light"] .btn-danger { border-color: #f0c9d2; color: #b5304a; }
:root[data-theme="light"] .btn-danger:hover { background: #fdeef1; border-color: #e8a9b8; }

/* ---------- v10c：亮色下真正会坏的地方 ---------- */
:root[data-theme="light"] tbody tr:hover td { background: #f4f5f7; }
:root[data-theme="light"] .tip { background: #ffffff; border-color: #dfe2e7; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); }
:root[data-theme="light"] .cal-day:hover { outline-color: #d3d6db; }
:root[data-theme="light"] .cal-day.is-out { color: #b9bdc4; }
:root[data-theme="light"] .cal-day.in-range { background: rgba(44, 120, 145, 0.10); }
:root[data-theme="light"] .skeleton { background: #ecedf0; }

/* ---------- v11：主区子元素间距只由 .main 的 gap 决定 ---------- */
.main { gap: 12px; }
.main > * { margin-top: 0 !important; }

/* ---------- v12：用量页首块不再自带 24px 上边距 ---------- */
#usage-body > *:first-child,
#src-body > *:first-child { margin-top: 0 !important; }

/* ---------- v13：底部不留空，列表卡片撑到页面底 ---------- */
.main > .table-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.main > .table-card .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }

/* ---------- v14 ---------- */
/* 超出可用区间的日子不画起止大圆 */
.cal-day.is-off.is-start, .cal-day.is-off.is-end {
  background: transparent;
  color: var(--dim);
  font-weight: 400;
}
/* 列表卡片吸附内容高度，超出才抵住页底并内部滚动 */
.main > .table-card { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.main > .table-card .table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }

/* ---------- v15：列表卡片吃掉剩余高度，只有内容超出才滚动 ---------- */
.main > .table-card { flex: 0 1 auto; min-height: 0; }
.main > .table-card .table-wrap { min-height: 0; }

/* 底部轻提示（toast）的亮色适配 —— 原来写死了深色底 */
:root[data-theme="light"] .toast {
  background: #ffffff;
  border-color: #e3e5e9;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(20, 22, 26, 0.14);
}

/* 密钥页副标题里的 API 地址：看起来像可点的代码，点一下复制 */
.copyabel {
  border: 0; padding: 0 2px; background: none; cursor: pointer;
  font: inherit; color: var(--accent);
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
}
.copyabel:hover { color: var(--text); border-bottom-color: var(--text); }

/* 品牌区可选可复制 */
.brand{cursor:default}
.brand-text,.brand-name,.brand-tag{user-select:text;-webkit-user-select:text;cursor:text}


/* ---------- v16：端点圆照常显示 · 来源页表头固定 · 备注右移 ---------- */
.cal-day.is-off.is-start,
.cal-day.is-off.is-end {
  color: #fff;
  font-weight: 500;
}
.cal-day.is-off.is-start::before,
.cal-day.is-off.is-end::before { display: block; }

.src-accounts thead th,
.src-logs thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

.acc-table td { padding-top: 7px; padding-bottom: 7px; }
.acc-table .acc-name { line-height: 1.35; }
.acc-note { margin-top: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-table .acc-note-input { max-width: 100%; }
.ta-r { text-align: right; }


/* ---------- v17：列表风格统一 + 侧栏同级 ---------- */
/* 行高、内边距、分隔线在所有列表里取同一套 */
tbody td { padding: 9px 20px; }
.acc-table td { padding: 9px 20px; }
thead th { padding: 12px 20px 9px; }
tbody tr:hover td { background: var(--raised); }
:root[data-theme="light"] tbody tr:hover td { background: #f1f2f4; }

/* 凡是在卡片里滚动的列表，表头一律钉住，样式一致 */
.table-card thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* 侧栏第四项与前三项完全同级（原 .nav-sub 已弃用） */
.nav-item svg { flex: 0 0 auto; }


/* ---------- v18：侧栏分组线 + 来源标签 ---------- */
.nav-sep {
  height: 1px;
  margin: 12px 0 10px;
  background: var(--rule);
}
.nav .nav-group-label {
  display: block;
  padding: 0 4px 6px;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--dim);
}

/* ---------- 列表：固定表头 + 只滚表体 ---------- */
.table-wrap { display: flex; flex-direction: column; min-height: 0; overflow: hidden !important; }
.tbl { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; width: 100%; }
.tblh { flex: 0 0 auto; overflow: hidden; padding-right: var(--sbw, 0px); border-bottom: 1px solid var(--border); }
.tblb { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: auto; background: var(--surface); }
.tbl table { margin: 0; }
.tbl thead th { position: static !important; box-shadow: none !important; background: transparent; }
.tbl .tblh table { will-change: transform; }

#keys-wrap table { table-layout: fixed; width: 100%; }
#keys-wrap th:nth-child(1), #keys-wrap td:nth-child(1) { width: 26%; }
#keys-wrap th:nth-child(2), #keys-wrap td:nth-child(2) { width: 28%; }
#keys-wrap th:nth-child(3), #keys-wrap td:nth-child(3) { width: 16%; }
#keys-wrap th:nth-child(4), #keys-wrap td:nth-child(4) { width: 18%; }
#keys-wrap th:nth-child(5), #keys-wrap td:nth-child(5) { width: 12%; }

.acc-table { table-layout: fixed; width: 100%; }

.src-logs table { table-layout: fixed; width: 100%; }
.src-logs th:nth-child(1), .src-logs td:nth-child(1) { width: 14%; }
.src-logs th:nth-child(2), .src-logs td:nth-child(2) { width: 20%; }
.src-logs th:nth-child(3), .src-logs td:nth-child(3) { width: 18%; }
.src-logs th:nth-child(4), .src-logs td:nth-child(4) { width: 8%; }
.src-logs th:nth-child(5), .src-logs td:nth-child(5) { width: 10%; }
.src-logs th:nth-child(6), .src-logs td:nth-child(6) { width: 10%; }
.src-logs th:nth-child(7), .src-logs td:nth-child(7) { width: 10%; }
.src-logs th:nth-child(8), .src-logs td:nth-child(8) { width: 10%; }

/* ---------- v19：亮色补齐 ---------- */
:root {
  --hover-line: #323236;
  --line-strong: #2a2a2f;
  --menu-bg: #0e0e10;
  --strip-bg: #101013;
  --skeleton-bg: #141318;
  --danger-line: #3a262c;
  --out-text: #3c3e44;
  --tick: #63656b;
  --grid: #202024;
  --grid-strong: #2c2c31;
}
:root[data-theme="light"] {
  --hover-line: #d3d6db;
  --line-strong: #e3e5e9;
  --menu-bg: #ffffff;
  --strip-bg: #fafbfc;
  --skeleton-bg: #eceef1;
  --danger-line: #e8c6ce;
  --out-text: #b8bcc3;
  --tick: #6d7078;
  --grid: #e8eaee;
  --grid-strong: #d5d8de;
}

/* 日历：起止日落在强调色上，亮色主题下强调色更深，文字要转白 */
:root[data-theme="light"] .cal-day.is-start,
:root[data-theme="light"] .cal-day.is-end { color: #fff; }

/* 复制提示 */
.copy-hint { color: var(--dim); font-size: 11.5px; margin-left: 2px; }
.copyabel { text-decoration: none; }
.copyabel:active { opacity: .6; }

/* v20：空闲时段标签不再挤到上游列上 */
.price-side { margin-left: 0; margin-right: 10px; }
.offpeak-chip { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* v23：表头信息符号 + 上游单元格里的打折标识 */
.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 4px;
  border: 1px solid var(--control); border-radius: 50%;
  font-size: 9.5px; line-height: 1; color: var(--dim);
  cursor: help; user-select: none; vertical-align: 1px;
}
.info:hover { border-color: var(--accent); color: var(--text); }
.up-cell .offpeak-chip { margin-top: 5px; align-self: flex-start; }
.price-cell { justify-content: flex-start; }
.price-k { padding-right: 0; }

/* v24：上游单元格整体左对齐；星号绝对定位，不把数字顶偏 */
.up-cell { display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
.up-cell .offpeak-chip { margin-left: 0; }

/* v25：窄屏（<900px）顶部导航不要把字挤成竖排 */
@media (max-width: 900px) {
  .brand { gap: 10px; }
  .brand-mark { width: 34px; height: 34px; flex: 0 0 auto; }
  .brand-name { display: none; }
  .nav { flex: 1 1 auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item, .nav-sub { flex: 0 0 auto; flex-direction: row; gap: 6px; white-space: nowrap; }
  .nav-label { white-space: nowrap; }
  .nav .nav-sep, .nav .nav-group-label { display: none; }
  .sidebar-foot { flex: 0 0 auto; }
}

/* v26：星号贴着文字，数字仍对齐到同一条竖线（沿用 .price-rows 的 grid） */
.price-row { display: contents; }
.price-k { min-width: 0; padding: 0; }
.price-k .star { position: static; margin-left: 1px; }

/* ================================================================
   移动端（≤720px）：顶栏 + 可滚主区 + 表格改卡片
   ================================================================ */
@media (max-width: 720px) {

  /* ---- 壳 ---- */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--ground);
    overflow: hidden;
  }
  .brand { display: none; }
  .nav-item > svg { display: none; }

  .nav {
    flex: 1 1 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0;
    min-width: 0;
  }
  .nav-item, .nav-sub {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: row;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 10px 2px;
  }
  .nav-label { white-space: nowrap; font-size: 12.5px; }
  /* 手机上五个导航项挤在一行，来源前缀省掉，只留「国内号/国际号」 */
  .src-prefix { display: none; }
  .nav .nav-sep, .nav .nav-group-label { display: none; }

  .sidebar-foot { flex: 0 0 auto; margin: 0; padding: 0; border: 0; gap: 4px; }
  .sidebar-foot .account-text { display: none; }
  .sidebar-foot .avatar { display: none; }
  .sidebar-foot .iconbtn { width: 34px; height: 34px; }
  .sidebar-foot .avatar { width: 26px; height: 26px; }
  .sidebar-foot .linkbtn { padding: 0 6px; min-height: 34px; font-size: 12.5px; }

  .main {
    height: auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 32px;
    gap: 12px;
  }

  /* ---- 页头 ---- */
  .page-head { min-height: 0; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
  .page-title { font-size: 21px; }
  .page-sub { font-size: 12px; line-height: 1.55; }
  .filters { flex-wrap: wrap; gap: 8px; }
  .filters .search { max-width: none; flex: 1 1 100%; }

  /* ---- KPI ---- */
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-strip.four, .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 22px; letter-spacing: -0.02em; }
  .kpi-strip > .kpi:first-child { box-shadow: inset 2px 0 0 var(--accent); }
  .kpi-strip > .kpi + .kpi { box-shadow: inset 0 1px 0 var(--border); }

  /* ---- 图表 ---- */
  .chart-card { min-height: 260px; }
  .chart-card .card-head { flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 14px 14px 0; }
  .chart-card .card-title { font-size: 15px; }
  .legend { flex-wrap: wrap; gap: 10px 14px; }
  .legend-item { font-size: 11px; }
  .plot-row { min-height: 190px; }
  .plot-y { flex: 0 0 42px; width: 42px; }
  .ytick { font-size: 9.5px; }
  .ytick { right: 8px; }
  .picker-row { flex-wrap: wrap; gap: 8px; }
  .seg { overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }

  /* ---- 来源页：上下排，各自自然高度 ---- */
  .main > * { flex: 0 0 auto; }
  .src-grid {
    display: flex; flex-direction: column; gap: 12px;
    height: auto; flex: 0 0 auto;
  }
  .src-grid > .src-accounts, .src-grid > .src-logs {
    flex: 0 0 auto; height: auto; min-height: 0; overflow: visible;
  }
  .main .table-card, .main .table-wrap,
  .main .src-accounts, .main .src-logs, .main .src-grid {
    flex: 0 0 auto; height: auto; min-height: 0; overflow: visible;
  }

  /* ---- 弹窗：贴底大抽屉 ---- */
  .overlay { padding: 12px; place-items: end center; }
  .modal {
    width: 100%;
    max-height: 86dvh;
    overflow-y: auto;
    border-radius: 12px 12px 8px 8px;
  }

  /* ---- 日历：底部抽屉，只显示一个月 ---- */
  .cal-pop {
    left: 0 !important;
    right: 0;
    top: auto !important;
    bottom: 0;
    width: 100%;
    max-height: 88dvh;
    flex-direction: column;
    border-radius: 12px 12px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .cal-presets {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
    gap: 4px;
    scrollbar-width: none;
  }
  .cal-presets::-webkit-scrollbar { display: none; }
  .cal-preset { padding: 9px 12px; font-size: 13px; }
  .cal-body { overflow-y: auto; padding: 12px 12px 16px; }
  .cal-months { flex-direction: column; gap: 14px; }
  .cal-months > .cal-month:nth-child(2) { display: none; }
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .cal-day { height: 38px; }
  .cal-pop { padding-bottom: env(safe-area-inset-bottom, 0); }
  .cal-legend { flex-wrap: wrap; gap: 6px; font-size: 11.5px; }
  .cal-foot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  #cal-preview { order: 1; font-size: 13px; color: var(--text); }
  .cal-btns { order: 2; display: flex; gap: 8px; }
  .cal-btns .btn { flex: 1 1 0; min-height: 42px; font-size: 14px; }
  .cal-legend-note { order: 3; font-size: 11px; }

  /* PC 的百分比列宽会把卡片内部挤扁，这里全部作废 */
  #models-wrap th:nth-child(n), #models-wrap td:nth-child(n),
  #keys-wrap th:nth-child(n), #keys-wrap td:nth-child(n),
  .acc-table th:nth-child(n), .acc-table td:nth-child(n),
  .src-logs th:nth-child(n), .src-logs td:nth-child(n) { width: auto; }

  /* ---- 表格：整张表变卡片流 ---- */
  .table-wrap { overflow: visible; }
  .tbl { display: block; }
  .tblh { display: none; }
  .tblb { overflow: visible; }
  table { width: 100%; min-width: 0 !important; table-layout: auto; }
  colgroup, col { display: none; }
  thead { display: none; }
  tbody, tr, td { display: block; }
  tbody tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  tbody tr:last-child { border-bottom: 0; }
  body .main tbody td {
    position: relative;
    display: block;
    padding: 3px 0 3px 92px;
    font-size: 12.5px;
    text-align: left !important;
    overflow-wrap: anywhere;
    border: 0;
  }
  body .main tbody td::before {
    content: "";
    position: absolute;
    left: 0;
    top: 3px;
    width: 78px;
    font-size: 11.5px;
    color: var(--dim);
    letter-spacing: 0.01em;
  }
  tbody tr:hover td { background: none; }

  /* 模型表 */
  #models-wrap tbody td:nth-child(1) { padding: 0 0 8px; }
  #models-wrap tbody td:nth-child(2)::before { content: "档位"; }
  #models-wrap tbody td:nth-child(3)::before { content: "可用账号"; }
  #models-wrap tbody td:nth-child(4)::before { content: "参考价格"; }
  #models-wrap tbody td:nth-child(5)::before { content: "上游消耗"; }
  #models-wrap tbody td:nth-child(6)::before { content: "来源"; }
  #models-wrap .price-cell { justify-content: flex-start; gap: 0; }
  #models-wrap .price-rows { grid-template-columns: 64px minmax(0, 1fr); column-gap: 10px; }
  #models-wrap .price-side { margin-left: 0; }
  #models-wrap .up-cell { align-items: flex-start; }

  /* 密钥表 */
  #keys-wrap tbody td:nth-child(1) { padding: 0 0 8px; font-size: 13.5px; }
  #keys-wrap tbody td:nth-child(2)::before { content: "Key"; }
  #keys-wrap tbody td:nth-child(3)::before { content: "创建日期"; }
  #keys-wrap tbody td:nth-child(4)::before { content: "最近使用"; }
  #keys-wrap tbody td:nth-child(5) { padding: 8px 0 0; }
  #keys-wrap tbody td:nth-child(5)::before { content: ""; }
  #keys-wrap .row-actions { justify-content: flex-start; }
  #keys-wrap .row-actions .iconbtn { width: 36px; height: 36px; }

  /* 账号池 */
  .acc-table tbody td:nth-child(1) { padding: 0 0 6px; font-size: 13px; }
  .acc-table tbody td:nth-child(2)::before { content: "积分"; }
  .acc-table tbody td:nth-child(3)::before { content: "进行中"; }
  .acc-table tbody td:nth-child(4)::before { content: "状态"; }
  .acc-table tbody td:nth-child(5)::before { content: "备注"; }

  /* 请求日志 */
  .src-logs tbody td:nth-child(1) { padding: 0 0 6px; color: var(--muted); }
  .src-logs tbody td:nth-child(2)::before { content: "模型"; }
  .src-logs tbody td:nth-child(3)::before { content: "密钥"; }
  .src-logs tbody td:nth-child(4)::before { content: "状态"; }
  .src-logs tbody td:nth-child(5)::before { content: "输入"; }
  .src-logs tbody td:nth-child(6)::before { content: "输出"; }
  .src-logs tbody td:nth-child(7)::before { content: "耗时"; }
  .src-logs tbody td:nth-child(8)::before { content: "IP"; }
  .src-logs tbody tr.err-row { background: none; }
  tbody td .badge, tbody td .count, tbody td .pill { justify-self: start; }
  #models-wrap tbody td:nth-child(3) > * { display: inline-flex; }

  /* 触摸目标 */
  .iconbtn { width: 36px; height: 36px; }
  .btn, .seg button { min-height: 36px; }
}

/* ---------- v28：来源页双按钮 ---------- */
.head-links { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--control);
  color: var(--muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--line-strong); }
@media (max-width: 720px) {
  .head-links { width: 100%; }
  .head-links .btn { flex: 1 1 0; justify-content: center; }
}
