:root {
  color-scheme: dark;
  --bg: #111316;
  --panel: #1a1d22;
  --panel-2: #20242b;
  --line: #303640;
  --text: #eef3f7;
  --muted: #9aa6b2;
  --blue: #43a1ff;
  --cyan: #30d5c8;
  --yellow: #ffd166;
  --red: #ff5c5c;
  --green: #62d26f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.topbar {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #171a1f;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 700;
}

#statusText,
#chartSub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
}

select {
  min-width: 130px;
  padding: 0 10px;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

main {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.metric,
.chart-panel,
article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  min-height: 78px;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.runtime-alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.runtime-alert.warning {
  border-color: rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.1);
  color: #ffe1a0;
}

.runtime-alert.error {
  border-color: rgba(255, 92, 92, 0.7);
  background: rgba(255, 92, 92, 0.12);
  color: #ffb4b4;
}

.chart-panel {
  padding: 12px;
}

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

.legend {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.legend-ramp {
  width: 160px;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #10151b, #164b7a, #19bfb2, #ffd166, #ff5c5c);
}

.canvas-wrap {
  position: relative;
  height: min(68vh, 720px);
  min-height: 420px;
  border: 1px solid #252b33;
  background: #0b0e12;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tooltip {
  position: absolute;
  z-index: 3;
  max-width: 280px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(17, 19, 22, 0.94);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
}

.hidden {
  display: none;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

article {
  overflow: hidden;
}

article h2 {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #252b33;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

td {
  color: #dce5ed;
}

@media (max-width: 1000px) {
  .topbar,
  .chart-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  main {
    padding: 10px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .controls,
  select,
  button {
    width: 100%;
  }

  .canvas-wrap {
    min-height: 360px;
  }
}
