:root {
  color-scheme: dark;
  --bg: #10151d;
  --panel: #18222e;
  --panel-2: #121a24;
  --line: #2c3745;
  --text: #eef2f7;
  --muted: #9ca9b8;
  --green: #56d69b;
  --blue: #4aa3ff;
  --orange: #ffb15f;
  --danger: #ff6b6b;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(86, 214, 155, 0.12), transparent 34rem),
    var(--bg);
  color: var(--text);
}

button, select, input {
  font: inherit;
}

button, .link-button {
  border: 0;
  border-radius: 14px;
  background: #283747;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.active, button.on {
  background: #2dab78;
  box-shadow: 0 0 0 2px rgba(86, 214, 155, 0.25) inset;
}

.link-button.small {
  font-size: 0.85rem;
  min-height: 36px;
  padding: 0 14px;
}

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px;
}

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

.hero-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eyebrow {
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1, h2, p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 1;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.subtitle, .muted {
  color: var(--muted);
}

.subtitle {
  margin-bottom: 0;
}

.status-pill {
  border: 1px solid rgba(86, 214, 155, 0.35);
  border-radius: 999px;
  color: var(--green);
  padding: 8px 12px;
  white-space: nowrap;
}

.status-pill.offline {
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--danger);
}

.card, .reading {
  background: rgba(24, 34, 46, 0.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.card {
  margin-top: 16px;
  padding: 22px;
}

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

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

select {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111923;
  color: var(--text);
  padding: 0 14px;
}

.readings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.reading {
  padding: 16px;
}

.reading span {
  color: var(--muted);
  display: block;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.reading strong {
  font-size: clamp(1.4rem, 6vw, 2rem);
}

.history-card {
  min-height: min(100vh, 760px);
  display: flex;
  flex-direction: column;
}

.history-controls, .mode-grid {
  display: grid;
  gap: 10px;
}

.history-controls {
  grid-template-columns: repeat(4, 1fr);
}

.mode-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

canvas {
  width: 100%;
  background: var(--panel-2);
  border-radius: 14px;
}

#historyChart {
  flex: 1;
  min-height: 320px;
  margin-top: 16px;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.legend-item {
  background: transparent;
  min-height: auto;
  padding: 6px 8px;
}

.legend-item::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 7px;
}

.legend-item.temp::before { background: var(--orange); }
.legend-item.humidity::before { background: var(--blue); }
.legend-item.vpd::before { background: var(--green); }

.legend-item:not(.active) {
  opacity: 0.38;
}

.big-value {
  color: var(--green);
  font-size: 2rem;
}

input[type="range"] {
  accent-color: var(--green);
}

.slider-marks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 6px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: center;
}

.login-card {
  width: min(100%, 420px);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form label {
  display: grid;
  gap: 7px;
}

.login-form label span {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form input {
  background: #111923;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  min-height: 46px;
  padding: 0 14px;
  width: 100%;
}

.error-message {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 14px;
  color: #ffb3b3;
  margin-top: 18px;
  padding: 12px 14px;
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }

  .hero, .card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    align-items: flex-start;
  }

  .status-pill {
    width: fit-content;
  }

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

  .history-card {
    min-height: calc(100vh - 24px);
  }

  .history-controls, .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
