:root {
  --bg: #0c0f14;
  --bg-panel: #131820;
  --bg-card: #181e28;
  --border: #252d3a;
  --text: #e8ecf2;
  --text-muted: #7a8699;
  --accent-temp: #ff6b4a;
  --accent-temp-dim: rgba(255, 107, 74, 0.15);
  --accent-hum: #3db8e8;
  --accent-hum-dim: rgba(61, 184, 232, 0.15);
  --online: #3dd68c;
  --offline: #f06060;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* Header */
.header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 15, 20, 0.85);
  backdrop-filter: blur(12px);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent-hum);
}

.header__icon svg {
  width: 22px;
  height: 22px;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header__sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.header__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--online {
  background: var(--online);
  box-shadow: 0 0 10px var(--online);
  animation: pulse 2s ease infinite;
}

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

.status-dot--demo {
  background: #e8b84a;
  box-shadow: 0 0 10px #e8b84a;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main */
.main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card--temp {
  border-top: 3px solid var(--accent-temp);
}

.card--hum {
  border-top: 3px solid var(--accent-hum);
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.card__label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.card__icon {
  font-size: 1.25rem;
  opacity: 0.8;
}

.card__value {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.card__number {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  transition: color 0.3s ease;
}

.card--temp .card__number { color: var(--accent-temp); }
.card--hum .card__number { color: var(--accent-hum); }

.card__unit {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 500;
}

.card__bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.card__bar-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.card--temp .card__bar-fill {
  background: linear-gradient(90deg, var(--accent-temp-dim), var(--accent-temp));
}

.card--hum .card__bar-fill {
  background: linear-gradient(90deg, var(--accent-hum-dim), var(--accent-hum));
}

.card__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Panel */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel__badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

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

.info-item dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.info-item dd {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
}

.chart-wrap {
  position: relative;
  height: 140px;
  margin-top: 0.5rem;
}

#historyChart {
  width: 100% !important;
  height: 100% !important;
}

/* Footer */
.footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.75rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--accent-hum);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.btn-demo {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-demo:hover {
  color: var(--text);
  border-color: #e8b84a;
  background: rgba(232, 184, 74, 0.08);
}

.btn-demo.active {
  color: #e8b84a;
  border-color: #e8b84a;
  background: rgba(232, 184, 74, 0.12);
}

/* Responsive */
@media (max-width: 480px) {
  .header {
    padding: 1.25rem;
  }

  .main {
    padding: 1.25rem;
  }

  .card__number {
    font-size: 2.5rem;
  }
}
