:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d8dee8;
  --accent: #0f766e;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

button {
  cursor: pointer;
}

button.active {
  border-color: var(--accent);
  background: #e6f4f1;
  color: #07544e;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.status-card {
  padding: 14px;
  min-width: 0;
}

.label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.value {
  font-size: 18px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.status-online {
  color: var(--accent);
}

.status-offline {
  color: var(--danger);
}

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

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

.led-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
}

.led-controls {
  display: grid;
  grid-template-columns: 120px repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.led-controls label {
  display: grid;
  gap: 8px;
}

.color-control input {
  width: 100%;
  height: 40px;
  padding: 2px;
}

input[type="range"] {
  width: 100%;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.chart-panel {
  height: 680px;
  padding: 16px;
}

.notice {
  color: var(--muted);
  margin: 10px 0 0;
  min-height: 20px;
}

@media (max-width: 760px) {
  .page {
    width: min(100vw - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .led-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .led-controls {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    height: 520px;
    padding: 10px;
  }
}
