:root {
  /* 纸感浅色体系（取自系统状态页参考风格） */
  --bg: #f5f4f0;
  --surface: #fffefb;
  --surface-2: #faf9f5;
  --border: #e8e5dd;
  --border-soft: #f0ede6;
  --ink: #1c1b18;
  --ink-soft: #6c685f;
  --ink-faint: #a39e92;
  --brand: #2f6bff;
  --ok: #2f9468;
  --ok-bg: #ebf3ee;
  --ok-halo: rgba(47, 148, 104, 0.18);
  --warn: #c2871d;
  --warn-bg: #f6efdc;
  --warn-halo: rgba(194, 135, 29, 0.18);
  --down: #c4492e;
  --down-bg: #f6e6e0;
  --down-halo: rgba(196, 73, 46, 0.18);
  --neutral: #cfcabd;
  --neutral-bg: #f0ede6;
  --shadow-sm: 0 1px 2px rgba(28, 24, 16, 0.03);
  --shadow: 0 1px 1px rgba(28, 24, 16, 0.03), 0 6px 24px -12px rgba(28, 24, 16, 0.1);
  --radius: 16px;
  --radius-sm: 11px;
  --maxw: 960px;
  --font: -apple-system, 'system-ui', 'SF Pro Text', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --mono: 'SFMono-Regular', 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
}

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  height: 46px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 30px;
  background: var(--border);
}

.brand-sub {
  color: var(--ink-soft);
  font-size: 18px;
  letter-spacing: 0.04em;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 16px;
  color: var(--ink-faint);
  font-size: 13px;
}

.topbar-meta span:not(:empty) {
  white-space: nowrap;
}

.topbar-aux {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cross-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.cross-link:hover {
  color: var(--brand);
  border-color: var(--brand);
}

/* ---------- 概览卡 ---------- */
.summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
}

.summary-text h1 {
  margin: 6px 0 8px;
  font-size: 26px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.eyebrow {
  display: inline-block;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

.subtitle {
  max-width: 460px;
  color: var(--ink-soft);
  margin: 0 0 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- 环形仪表 ---------- */
.gauge {
  position: relative;
  width: 168px;
  height: 168px;
  flex-shrink: 0;
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge .gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.gauge .gauge-arc {
  fill: none;
  stroke: var(--neutral);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.4s ease;
}

.gauge.is-good .gauge-arc {
  stroke: var(--ok);
}
.gauge.is-mid .gauge-arc {
  stroke: var(--warn);
}
.gauge.is-bad .gauge-arc {
  stroke: var(--down);
}
.gauge.is-running .gauge-arc {
  stroke: var(--brand);
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.gauge-label {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.gauge-sub {
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------- 区块标题 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 34px 2px 14px;
}

.section-head .label {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}

.section-head .label .label-soft {
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- 卡片通用 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
}

/* ---------- 指标卡 ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

.metric h2 {
  margin: 6px 0 8px;
  font-size: 23px;
  font-weight: 680;
  letter-spacing: -0.02em;
}

.metric.metric-good {
  background: var(--ok-bg);
  border-color: var(--ok-halo);
}
.metric.metric-mid {
  background: var(--warn-bg);
  border-color: var(--warn-halo);
}
.metric.metric-bad {
  background: var(--down-bg);
  border-color: var(--down-halo);
}

.label {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

/* 状态行是整句话不是标题，全大写在英文下读起来像在喊。
   中文没有大小写，所以这条在明道版上没有视觉变化。 */
#status-text {
  text-transform: none;
  letter-spacing: normal;
}

.tag {
  display: block;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.hint {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 13px;
}

/* 指标进度条 */
.bar {
  width: 100%;
  height: 8px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.fill.active {
  background: linear-gradient(90deg, var(--brand), #6f9bff, var(--brand));
  background-size: 200% 100%;
  animation: progress-wave 1.1s linear infinite;
}

/* ---------- 节点网格 ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h3 {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 650;
}

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

.node-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.node-card {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.latency {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.latency > span:first-child {
  white-space: nowrap;
  color: var(--ink);
}

.latency-bar {
  flex: 1;
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}

.latency-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--neutral);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- 状态胶囊 ---------- */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--ink-soft);
}

.state::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.state.live {
  background: var(--neutral-bg);
  color: var(--ink-soft);
}
.state.good {
  background: var(--ok-bg);
  color: var(--ok);
}
.state.mid {
  background: var(--warn-bg);
  color: var(--warn);
}
.state.bad {
  background: var(--down-bg);
  color: var(--down);
}

/* ---------- 日志 ---------- */
.log {
  height: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-soft);
}

.log-line {
  padding: 5px 0;
  border-bottom: 1px solid var(--border-soft);
}
.log-line:last-child {
  border-bottom: none;
}

/* ---------- 按钮 ---------- */
.btn {
  cursor: pointer;
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  box-shadow: 0 6px 18px -8px rgba(47, 107, 255, 0.6);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--border);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--neutral);
  box-shadow: none;
}

.btn.small {
  padding: 7px 13px;
  font-size: 13px;
}

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 27, 24, 0.32);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px -24px rgba(28, 24, 16, 0.4);
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 680;
}

.modal-text {
  margin: 0 0 18px;
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ai-modal {
  max-width: 640px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.modal-body {
  max-height: 60vh;
  overflow: auto;
  color: var(--ink);
  line-height: 1.65;
}

.modal-body h3,
.modal-body h4 {
  margin: 16px 0 6px;
  font-weight: 650;
}

.modal-body p {
  margin: 8px 0;
}

.modal-body ul {
  padding-left: 20px;
  margin: 8px 0 12px;
}

.modal-body li {
  margin: 4px 0;
}

.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 0;
  color: var(--ink-soft);
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  animation: spin 0.9s linear infinite;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -10px) scale(0.97);
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px -16px rgba(28, 24, 16, 0.35);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  min-width: 240px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 30;
}

.toast.active {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast.success {
  border-color: var(--ok-halo);
  background: var(--ok-bg);
  color: var(--ok);
}

.toast.error {
  border-color: var(--down-halo);
  background: var(--down-bg);
  color: var(--down);
}

/* ---------- 页脚 ---------- */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 40px;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---------- 动画 ---------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes progress-wave {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .summary {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 22px;
  }
  .gauge {
    justify-self: center;
  }
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .node-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 0 16px 48px;
  }
  .metrics {
    grid-template-columns: 1fr;
  }
  .hero-actions {
    width: 100%;
  }
  .hero-actions .btn {
    flex: 1;
  }
}
