/* ============================================================
   Nexus 管理台 · 样式
   设计纪律（.admin/system.md）：
   - 方向：安静的工作台；深色石墨 + 单一青瓷强调色
   - 深度策略：borders-only，仅弹层用一层阴影
   - 密度：8px 基准；行高紧凑；侧栏与画布同色，仅 1px 边框
   - 文本四级：text / dim / mute / disabled
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --sp: 8px;
  --dur: .16s;
}

html[data-theme="dark"] {
  --accent: #6fa8a0;
  --accent-soft: rgba(111, 168, 160, 0.13);
  --ok: #4fa97c;
  --warn: #d9a441;
  --danger: #d96a57;
  --bg: #0c0e10;
  --bg-elev: #14171a;
  --bg-inset: #090b0d;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(111, 168, 160, 0.13);
  --border: rgba(255, 255, 255, 0.09);
  --border-soft: rgba(255, 255, 255, 0.055);
  --text: #e7e9ea;
  --text-dim: #9ca2a6;
  --text-mute: #6a7075;
  --text-off: #454b50;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="light"] {
  --accent: #3f7f76;
  --accent-soft: rgba(63, 127, 118, 0.10);
  --ok: #3d8b64;
  --warn: #b07f1f;
  --danger: #c05a48;
  --bg: #f6f6f4;
  --bg-elev: #ffffff;
  --bg-inset: #f0f0ee;
  --bg-hover: rgba(20, 23, 26, 0.045);
  --bg-active: rgba(63, 127, 118, 0.10);
  --border: rgba(20, 23, 26, 0.11);
  --border-soft: rgba(20, 23, 26, 0.06);
  --text: #14171a;
  --text-dim: #5a6166;
  --text-mute: #8b9296;
  --text-off: #b6bcc0;
  --shadow-pop: 0 10px 26px rgba(20, 23, 26, 0.12);
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ============================ 布局骨架 ============================ */
.shell { display: flex; height: 100vh; height: 100dvh; }

/* 侧栏：与画布同色，只靠一条边框分隔 */
.nav {
  width: 216px; flex: none;
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 16px 12px 12px;
}
.nav-brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 18px; }
.nav-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 11px; color: #fff;
  background: var(--accent);
}
.nav-brand-text { line-height: 1.25; }
.nav-brand-text strong { display: block; font-size: 13.5px; letter-spacing: .2px; }
.nav-brand-text span { font-size: 10.5px; color: var(--text-mute); }

.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-dim); text-align: left; font-size: 12.5px;
  transition: background var(--dur), color var(--dur);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); font-weight: 550; }
.ni-ico { width: 16px; text-align: center; color: var(--text-mute); font-size: 11px; }
.nav-item.active .ni-ico { color: var(--accent); }
.ni-badge {
  margin-left: auto; min-width: 18px; height: 17px; padding: 0 5px;
  border-radius: 999px; font-size: 9.5px; font-weight: 600;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.ni-badge.soft { background: var(--bg-hover); color: var(--text-mute); }

.nav-foot { border-top: 1px solid var(--border-soft); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-foot-btn {
  padding: 7px 10px; border-radius: var(--r-sm); font-size: 11.5px;
  color: var(--text-mute); text-align: left; text-decoration: none;
  transition: background var(--dur), color var(--dur);
}
.nav-foot-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-ver { padding: 4px 10px 0; font-size: 9.5px; color: var(--text-off); font-family: var(--mono); }

/* ============================ 内容区 ============================ */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 54px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--border-soft);
}
.tb-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tb-left h1 { margin: 0; font-size: 15px; letter-spacing: -.2px; font-weight: 600; }
.tb-sub { font-size: 11.5px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 12px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-mute); }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.status-dot.on i { background: var(--ok); }
.status-dot.err i { background: var(--danger); }

.view-scroll { overflow-y: auto; }
.view { display: none; padding: 20px 26px 34px; max-width: 1120px; }
.view.active { display: block; }

/* ============================ 组件 ============================ */
.card {
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-elev);
  padding: 14px 16px; margin-bottom: 12px;
}
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 12.5px; font-weight: 600; }
.card-hint { font-size: 10.5px; color: var(--text-mute); }
.card-link { margin-left: auto; font-size: 11.5px; color: var(--accent); text-decoration: none; }
.card-link:hover { text-decoration: underline; }
.duo { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; align-items: stretch; }
.duo .card { margin-bottom: 12px; }

/* 统计条：数字是主角，不做渐变大卡 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-elev); padding: 12px 14px;
}
.stat b { display: block; font-size: 21px; font-weight: 650; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; color: var(--text-mute); }
.stat.hot b { color: var(--accent); }

.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar-note { font-size: 11.5px; color: var(--text-mute); }
.bar-actions { margin-left: auto; display: flex; gap: 8px; }
.ipt {
  width: 220px; padding: 7px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-inset);
  color: var(--text); outline: none; font-size: 12px;
}
.ipt:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ipt::placeholder { color: var(--text-mute); }

select.ipt { appearance: none; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%), linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 10px) 55%;
  background-size: 4px 4px; background-repeat: no-repeat;
}

.btn {
  padding: 7px 13px; border-radius: var(--r-sm); font-size: 12px;
  border: 1px solid var(--border); color: var(--text-dim);
  background: transparent;
  transition: all var(--dur);
}
.btn:hover { color: var(--text); border-color: rgba(111, 168, 160, .45); background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger:hover { color: var(--danger); border-color: rgba(217, 106, 87, .5); }
.btn.sm { padding: 4px 9px; font-size: 11px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .6px;
  color: var(--text-mute); padding: 6px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); color: var(--text-dim); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.t-title { color: var(--text); }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl tr:hover td { background: var(--bg-hover); }
.row-empty { color: var(--text-mute); text-align: center; padding: 26px 10px !important; font-size: 12px; }

/* 状态与标签 */
.tag {
  display: inline-block; font-size: 10px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--border-soft);
  color: var(--text-mute);
}
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.tag.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }

/* 开关 */
.switch { position: relative; width: 30px; height: 17px; display: inline-block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background var(--dur); }
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: #fff; transition: transform var(--dur);
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(13px); }

/* 迷你柱状图 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 6px; }
.bars.tall { height: 180px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bar-fill {
  width: 100%; max-width: 34px; border-radius: 4px 4px 2px 2px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-bottom: 2px solid var(--accent);
  min-height: 3px; position: relative;
  transition: height .3s ease;
}
.bar-col:hover .bar-fill { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.bar-col span { font-size: 9px; color: var(--text-mute); white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-tip { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  font-size: 9.5px; color: var(--text); background: var(--bg-inset); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 5px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.bar-col:hover .bar-tip { opacity: 1; }

/* 模型分布 */
.model-split { display: flex; flex-direction: column; gap: 9px; }
.ms-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ms-name { font-size: 11.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.ms-val { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-track { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--bg-inset); overflow: hidden; }
.ms-fill { height: 100%; border-radius: 3px; background: var(--accent); }
.ms-empty { font-size: 11.5px; color: var(--text-mute); text-align: center; padding: 22px 8px; }

/* 服务商卡片 */
.prov-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.prov {
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-elev); padding: 13px 15px;
}
.prov.default { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.prov-head { display: flex; align-items: center; gap: 8px; }
.prov-head strong { font-size: 13px; font-weight: 600; }
.prov-url { font-family: var(--mono); font-size: 10px; color: var(--text-mute); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov-models { font-size: 10.5px; color: var(--text-dim); line-height: 1.7; margin-top: 7px; font-family: var(--mono); word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prov-key { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.prov-key input {
  flex: 1; min-width: 0; padding: 6px 9px; border-radius: 6px; font-size: 11.5px; font-family: var(--mono);
  border: 1px solid var(--border); background: var(--bg-inset); color: var(--text); outline: none;
}
.prov-key input:focus { border-color: var(--accent); }
.prov-acts { display: flex; gap: 6px; margin-top: 10px; align-items: center; }

/* 弹层 */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 50;
}
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(480px, 92vw); max-height: 84vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: 18px 20px; transform: translateY(6px); transition: transform .18s;
}
.modal-scrim.open .modal { transform: none; }
.modal h3 { margin: 0 0 4px; font-size: 14px; }
.modal .m-sub { font-size: 11px; color: var(--text-mute); margin-bottom: 14px; line-height: 1.6; }
.m-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; font-size: 11px; color: var(--text-mute); }
.m-field input, .m-field textarea {
  padding: 8px 10px; border-radius: var(--r-sm); font-size: 12px;
  border: 1px solid var(--border); background: var(--bg-inset); color: var(--text); outline: none;
}
.m-field input:focus, .m-field textarea:focus { border-color: var(--accent); }
.m-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  padding: 9px 16px; border-radius: var(--r-sm); font-size: 12px; z-index: 99;
  background: var(--bg-inset); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow-pop);
}
.toast.err { border-color: rgba(217, 106, 87, .55); color: var(--danger); }

/* ============================ 响应式 ============================ */
@media (max-width: 1080px) {
  .prov-list { grid-template-columns: 1fr; }
  .duo { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .nav { width: 62px; padding: 12px 8px; }
  .nav-brand-text, .nav-item span:not(.ni-ico), .ni-badge, .nav-ver { display: none; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-brand { justify-content: center; padding: 0 0 14px; }
  .nav-foot { align-items: center; }
  .nav-foot-btn { display: none; }
  #adminTheme {
    display: grid; place-items: center; width: 34px; padding: 7px 0;
  }
  #adminTheme span { display: none; }
  .view { padding: 14px 12px 28px; }
  .topbar { padding: 0 14px; }
  .tb-sub { display: none; }
  .ipt { width: 140px; }
  .tbl th:nth-child(4), .tbl td:nth-child(4) { display: none; }
}
