:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --text: #202733;
  --muted: #5d6675;
  --line: #d7dee8;
  --green: #1f7a5a;
  --red: #b42318;
  --amber: #a16207;
  --blue: #2563eb;
  --shadow: 0 10px 28px rgba(24, 36, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 22px auto 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow,
.section-kicker,
.muted,
.hint {
  margin: 0;
  color: var(--muted);
}

.eyebrow,
.section-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-top: 3px;
  font-size: 19px;
  line-height: 1.25;
}

.status {
  width: min(100%, 320px);
  min-height: 66px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 12px 1fr;
  column-gap: 11px;
  align-items: center;
  box-shadow: 0 6px 18px rgba(24, 36, 51, 0.04);
}

.status small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
}

.status.ok .dot {
  background: var(--green);
}

.status.bad .dot {
  background: var(--red);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

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

.metric-card {
  min-height: 140px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-value {
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.metric-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

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

.tag-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
}

.command-form {
  display: grid;
  gap: 9px;
}

.command-form label {
  color: var(--muted);
  font-size: 13px;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 112px;
  gap: 10px;
}

input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: #ffffff;
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.18);
  border-color: var(--blue);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

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

#writeBtn {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
  font-weight: 650;
}

#writeBtn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.hint {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.chart-head {
  align-items: center;
}

.chart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
  align-items: center;
}

#sampleCount {
  color: var(--muted);
  font-size: 13px;
  margin-right: 4px;
}

.chart-frame {
  height: 390px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

#trendChart {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .status {
    width: 100%;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1240px);
    margin: 12px auto 22px;
  }

  h1 {
    font-size: 25px;
  }

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

  .input-row {
    grid-template-columns: 1fr;
  }

  .chart-frame {
    height: 320px;
  }
}
