:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7f4;
  color: #172016;
}

body {
  margin: 0;
  padding: 20px;
}

main {
  max-width: 900px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  font-size: 28px;
  margin: 0 0 4px;
}

p {
  margin: 0;
  color: #5f6f5d;
}

select,
button {
  min-height: 36px;
  border: 1px solid #b8c4b5;
  border-radius: 6px;
  background: #f7faf6;
  color: #172016;
  padding: 0 12px;
  font: inherit;
}

select {
  background: #ffffff;
  max-width: 100%;
}

button {
  cursor: pointer;
}

button.active {
  background: #235e46;
  border-color: #235e46;
  color: #ffffff;
}

.section {
  margin-top: 18px;
}

.card {
  background: #ffffff;
  border: 1px solid #d9e1d5;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(23, 32, 22, 0.06);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.label {
  font-size: 13px;
  color: #647062;
}

.value {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 30px;
  font-weight: 700;
  margin-top: 8px;
}

.target {
  color: #647062;
  font-size: 13px;
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
}

.alerts {
  display: grid;
  gap: 8px;
}

.alerts[hidden] {
  display: none;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e7b9b3;
  border-radius: 8px;
  background: #fff1ef;
  color: #7a2f29;
  padding: 10px 12px;
}

.system-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.status-lights {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-light {
  border-radius: 6px;
  background: #b84d4d;
  color: #ffffff;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1;
}

.status-light.ok {
  background: #2f855a;
}

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

.toggle-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid #b8c4b5;
  border-radius: 6px;
  background: #ffffff;
  color: #4e5b4c;
  padding: 0 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-button.active {
  background: #235e46;
  border-color: #235e46;
  color: #ffffff;
}

.toggle-button input,
.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.log-list {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #d9e1d5;
  border-radius: 6px;
  background: #fbfcfa;
}

.log-item {
  padding: 8px 10px;
  border-bottom: 1px solid #e6ece3;
  color: #344032;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-item:last-child {
  border-bottom: 0;
}

.chart-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.segment {
  display: inline-flex;
  border: 1px solid #b8c4b5;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.segment label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  color: #4e5b4c;
  border-left: 1px solid #d9e1d5;
}

.segment label:first-child {
  border-left: 0;
}

.segment label.active {
  background: #235e46;
  color: #ffffff;
}

.chart-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.chart-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 10px;
}

.chart-title {
  font-weight: 700;
}

.chart-readout {
  color: #4e5b4c;
  font-size: 13px;
  white-space: nowrap;
}

canvas {
  width: 100%;
  height: 170px;
  display: block;
  touch-action: none;
}

.device {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.device + .device {
  margin-top: 12px;
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #4e5b4c;
  margin-top: 4px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b7c1b4;
}

.on .dot {
  background: #2f855a;
}

.buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344032;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 560px) {
  body {
    padding: 14px;
  }

  header,
  .device {
    display: block;
  }

  .buttons {
    justify-content: flex-start;
    margin-top: 12px;
  }
}
