/* 天一AI 系统状态页 —— 深色主题 */
:root {
  --bg: #08090b;
  --panel: #121417;
  --panel-2: #17191d;
  --border: #23262c;
  --text: #eceef2;
  --text-dim: #9aa1ad;
  --text-faint: #6b7280;
  --green: #22c55e;
  --green-dim: #16351f;
  --yellow: #eab308;
  --orange: #f97316;
  --red: #ef4444;
  --blue: #4d6bfe;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid #17191d;
  background: rgba(8, 9, 11, .92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }

.top-actions { display: flex; align-items: center; gap: 8px; }

.ghost-btn {
  background: #15171b;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.ghost-btn:hover { color: var(--text); border-color: #343841; background: #1a1d22; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 总览横幅 ---------- */
.banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid #1c3f28;
  background: linear-gradient(180deg, #0f2417 0%, #0d1f14 100%);
}
.banner[data-status="degraded"] { border-color: #4a3a12; background: linear-gradient(180deg, #251d0b 0%, #1e180a 100%); }
.banner[data-status="down"]     { border-color: #4a1d1d; background: linear-gradient(180deg, #2a1010 0%, #220d0d 100%); }
.banner[data-status="nodata"]   { border-color: #2a2d33; background: linear-gradient(180deg, #17191d 0%, #141619 100%); }

.banner-icon {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green);
  color: #07210f;
  margin-top: 1px;
}
.banner[data-status="degraded"] .banner-icon { background: var(--yellow); color: #2a1f02; }
.banner[data-status="down"] .banner-icon     { background: var(--red);    color: #2a0707; }
.banner[data-status="nodata"] .banner-icon   { background: #3a3f47;       color: #b9bec7; }

.banner-title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.banner-sub { font-size: 13px; color: #86b79b; line-height: 1.55; }
.banner[data-status="degraded"] .banner-sub { color: #c9b071; }
.banner[data-status="down"] .banner-sub     { color: #d18989; }
.banner[data-status="nodata"] .banner-sub   { color: var(--text-dim); }

/* ---------- 面板 ---------- */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
}
.panel-title { margin: 0; font-size: 14.5px; font-weight: 600; }
.panel-hint { font-size: 12.5px; color: var(--text-faint); }

.range { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; }
.range-arrow {
  background: none;
  border: none;
  color: #5f6774;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: inherit;
}
.range-arrow:hover { color: var(--text); background: #1c1f24; }
.range-label { min-width: 168px; text-align: center; color: #cfd4dc; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 6px; padding: 0 18px 12px; }
.tab {
  background: #15171b;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 7px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: #1d2536; border-color: #2f3f5e; color: #b9c9ff; }

/* ---------- 模型行 ---------- */
.models { padding: 0 18px 6px; }

.model-row {
  padding: 14px 0 15px;
  border-top: 1px solid #1a1d21;
}
.model-row:first-child { border-top: none; }

.model-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.model-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 0;
}
.model-name .dot {
  width: 15px; height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  color: #07210f;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.model-name .dot[data-state="down"] { background: var(--red); color: #2a0707; }
.model-name .dot[data-state="degraded"] { background: var(--yellow); color: #2a1f02; }
.model-name .dot[data-state="nodata"] { background: #3a3f47; color: #c8cdd5; }
.model-name .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.info-btn {
  border: none; background: none; padding: 0; margin: 0;
  color: #5b626e; cursor: help; font-size: 12px; line-height: 1;
}
.info-btn:hover { color: var(--text-dim); }

.model-metrics { display: flex; align-items: baseline; gap: 18px; white-space: nowrap; }
.metric { font-size: 13px; color: #d5d9e0; font-variant-numeric: tabular-nums; }
.metric b { font-weight: 600; }
.metric .k { color: var(--text-faint); font-size: 11.5px; margin-left: 4px; }
.metric.latency b { color: #b6bdc8; font-weight: 500; }
.metric.latency .k { color: #5d646f; }

.bar-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 12px 18px 16px;
  border-top: 1px solid #1a1d21;
  font-size: 11.5px;
  color: var(--text-faint);
}
.bar-legend .swatch {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
  background: #23262c;
}
.bar-legend .swatch[data-level="ok"] { background: var(--green); }
.bar-legend .swatch[data-level="warn"] { background: var(--yellow); }
.bar-legend .swatch[data-level="bad"] { background: var(--orange); }
.bar-legend .swatch[data-level="down"] { background: var(--red); }
.bar-legend .dim { color: #565c66; margin-left: auto; }

.bars {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 16px;
  width: 100%;
}
.bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: #23262c;
  transition: transform .1s;
}
.bar[data-level="ok"]   { background: var(--green); }
.bar[data-level="warn"] { background: var(--yellow); }
.bar[data-level="bad"]  { background: var(--orange); }
.bar[data-level="down"] { background: var(--red); }
.bar[data-level="none"] { background: #23262c; }
.bars.can-hover .bar:hover { transform: scaleY(1.25); }

.legend {
  margin-top: 9px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-faint);
}
.legend b { color: var(--text-dim); font-weight: 500; }

.empty { padding: 22px 18px 26px; color: var(--text-faint); font-size: 13px; }

/* ---------- 异常列表 ---------- */
.errors { padding: 0 18px 16px; max-height: 340px; overflow: auto; }
.err-row {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid #1a1d21;
  font-size: 12.5px;
}
.err-row:first-child { border-top: none; }
.err-time { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.err-main { color: #d7b0b0; word-break: break-word; }
.err-main .tag {
  display: inline-block;
  background: #2a1416;
  color: #e08f8f;
  border: 1px solid #43222a;
  border-radius: 5px;
  padding: 0 6px;
  margin-right: 7px;
  font-size: 11.5px;
}
.err-main .tag.probe { background: #16202a; color: #8fb4e0; border-color: #223444; }
.err-main .tag.user { background: #1d232a; color: #a7b1bd; border-color: #2c343d; }
.err-body { color: #8d949f; margin-top: 3px; }
.errors-empty { padding: 4px 0 10px; color: var(--text-faint); font-size: 12.5px; }

.foot { text-align: center; color: var(--text-faint); font-size: 12px; line-height: 1.7; }

/* ---------- 悬浮提示 ---------- */
.tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  background: #1b1e23;
  border: 1px solid #2c3138;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #dfe3e9;
  line-height: 1.6;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  max-width: 300px;
}
.tooltip b { color: #fff; }
.tooltip .dim { color: var(--text-faint); }

.is-loading { opacity: .55; transition: opacity .15s; }

@media (max-width: 680px) {
  .wrap { padding: 16px 10px 30px; }
  .model-top { flex-direction: column; align-items: flex-start; gap: 6px; }
  .model-metrics { gap: 12px; }
  .range-label { min-width: 120px; font-size: 12px; }
  .err-row { grid-template-columns: 1fr; gap: 2px; }
  .bars .bar:nth-child(-n+30) { display: none; }
}
