:root {
  --bg: #fff8ef;
  --surface: #fffdf8;
  --panel: #fffaf1;
  --panel-strong: #f8eadb;
  --border: #ead3c1;
  --text: #3b2a22;
  --muted: #7a6254;
  --brand: #bd5b3d;
  --brand-dark: #8f3f2a;
  --green: #4f8f5f;
  --yellow: #c78a22;
  --red: #b94432;
  --gray: #8f827a;
  --cyan: #6f9f8b;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(189, 91, 61, 0.14), transparent 30rem),
    linear-gradient(135deg, #fff8ef 0%, #f6dfca 100%),
    var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
  display: grid;
  grid-template-columns: 280px 1fr;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffdf8;
  color: var(--text);
  padding: 10px 12px;
}

.sidebar {
  height: 100vh;
  padding: 24px 18px;
  background: #fffdf8;
  border-right: 1px solid var(--border);
  box-shadow: 10px 0 28px rgba(82, 47, 31, 0.07);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff8ef;
  font-weight: 900;
}

.brand small,
.eyebrow,
.muted,
.date-panel small,
.card-header,
.range-row,
.metric-card p,
.actuator-info span {
  color: var(--muted);
}

.brand small {
  display: block;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 9px;
}

.nav-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 13px 14px;
  color: #5f493e;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  border-color: #d8a08b;
  background: #f9e4d8;
}

.app-shell {
  padding: 28px;
  height: 100vh;
  overflow-y: auto;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 42px);
}

.connection-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffdf8;
  padding: 9px 13px;
  color: var(--green);
  font-weight: 700;
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pulse-color, var(--green));
  box-shadow: 0 0 0 4px var(--pulse-glow, rgba(79, 143, 95, 0.13));
  animation: pulse-glow-anim 2s infinite ease-in-out;
}

@keyframes pulse-glow-anim {
  0% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 var(--pulse-glow, rgba(79, 143, 95, 0.4));
  }
  70% {
    transform: scale(1.08);
    box-shadow: 0 0 0 8px rgba(79, 143, 95, 0);
  }
  100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(79, 143, 95, 0);
  }
}

.connection-pill {
  --pulse-color: var(--green);
  --pulse-glow: rgba(79, 143, 95, 0.4);
}

.connection-pill.offline {
  --pulse-color: var(--gray);
  --pulse-glow: rgba(143, 130, 122, 0.3);
  color: var(--gray);
}

.date-panel,
.temperature-card,
.metric-card,
.actuator-section,
.panel,
.visual-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(82, 47, 31, 0.08);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-title {
  margin-bottom: 16px;
}

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

.date-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.date-panel small {
  font-size: 18px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(220px, 0.75fr));
  gap: 16px;
}

.temperature-card,
.metric-card,
.actuator-section,
.panel,
.visual-card {
  padding: 20px;
}

.temperature-card {
  min-height: 255px;
  position: relative;
  overflow: hidden;
}

.temperature-card::after,
.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -35px -55px auto;
  width: 145px;
  height: 145px;
  border-radius: 50%;
  background: rgba(189, 91, 61, 0.08);
}

.metric-card {
  position: relative;
  display: grid;
  align-content: space-between;
  min-height: 255px;
  overflow: hidden;
}

.card-header,
.range-row,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.status-pill.stable,
.status-pill.cold,
.status-pill.hot {
  background: #fffdf8;
}

.status-pill.stable {
  color: var(--green);
}

.status-pill.cold {
  color: var(--cyan);
}

.status-pill.hot {
  color: var(--red);
}

.temperature-value {
  margin: 18px 0 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--brand-dark);
  font-size: clamp(56px, 8vw, 88px);
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 0.92;
}

.temperature-value small {
  margin-top: 9px;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0;
}

.temperature-scale {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ead3c1;
}

.scale-fill {
  display: block;
  width: 55%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--brand));
}

.range-row {
  margin-top: 12px;
  font-size: 13px;
}

.metric-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--brand-dark);
  font-size: 38px;
  line-height: 1;
}

.metric-card p {
  margin: 0;
  line-height: 1.45;
}

.actuator-section {
  margin-top: 16px;
}

.section-title {
  align-items: flex-end;
  margin-bottom: 16px;
}

.section-title h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.actuator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.actuator-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid #f0dccf;
  border-radius: 14px;
  background: #fff8ef;
}

.actuator-info {
  display: grid;
  gap: 5px;
}

.actuator-info strong {
  font-size: 16px;
}

.actuator-info span {
  font-size: 13px;
}

.switch {
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: #ead3c1;
}

.switch::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 2px 8px rgba(82, 47, 31, 0.16);
  transition: transform 180ms ease, background 180ms ease;
}

.actuator-card.active .switch {
  background: rgba(79, 143, 95, 0.22);
}

.actuator-card.active .switch::after {
  transform: translateX(26px);
  background: var(--green);
}

.visual-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.visual-card {
  min-height: 255px;
  position: relative;
  overflow: hidden;
}

.visual-card::after {
  content: "";
  position: absolute;
  inset: auto -35px -55px auto;
  width: 145px;
  height: 145px;
  border-radius: 50%;
  background: rgba(189, 91, 61, 0.08);
}

.temperature-visual {
  display: grid;
  grid-template-columns: 1fr 76px;
  gap: 18px;
}

.visual-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.visual-card h3 {
  font-size: 42px;
  margin: 8px 0 6px;
}

.thermometer {
  align-self: stretch;
  justify-self: end;
  width: 58px;
  min-height: 170px;
  border: 4px solid #e5c7b7;
  border-radius: 999px;
  background: #fff4ea;
  display: flex;
  align-items: flex-end;
  padding: 6px;
  position: relative;
}

.thermometer::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -23px;
  width: 76px;
  height: 76px;
  transform: translateX(-50%);
  border: 4px solid #e5c7b7;
  border-radius: 50%;
  background: #fff4ea;
  z-index: 0;
}

.thermometer span {
  width: 100%;
  min-height: 12%;
  border-radius: 999px;
  background: linear-gradient(180deg, #d76a46, var(--brand-dark));
  position: relative;
  z-index: 1;
}

.helper-text {
  color: var(--muted);
  margin: 10px 0 0;
  line-height: 1.45;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ead3c1;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--brand));
}

.history-panel {
  margin-top: 16px;
}

.trend-list,
.device-list,
.alert-list,
.settings-form {
  display: grid;
  gap: 12px;
}

.trend-row,
.device-row,
.alert-row,
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid #f0dccf;
  border-radius: 14px;
  background: #fff8ef;
}

.trend-row span,
.alert-row span {
  color: var(--muted);
}

.trend-row em,
.alert-row em {
  font-style: normal;
  font-weight: 700;
}

.device-copy {
  display: grid;
  gap: 4px;
}

.device-copy small {
  color: var(--muted);
}

.status-normal {
  color: var(--green);
}

.status-warning {
  color: var(--yellow);
}

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

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

.setting-row span {
  font-weight: 700;
}

.setting-row input,
.setting-row select {
  width: min(320px, 100%);
}

.settings-divider {
  display: grid;
  gap: 4px;
  padding: 16px 4px 4px;
}

.settings-divider small {
  color: var(--muted);
  line-height: 1.5;
}

.setting-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-button {
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff8ef;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.action-button.danger {
  background: #fff1ed;
  color: var(--red);
  border: 1px solid rgba(185, 68, 50, 0.2);
}

.card-note {
  margin-top: 14px;
  padding: 8px 12px;
  background: rgba(189, 91, 61, 0.04);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  line-height: 1.45;
}

.card-note small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.card-note strong {
  color: var(--brand-dark);
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
    height: auto;
    overflow: auto;
  }

  .sidebar {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    height: auto;
    overflow: visible;
  }

  .nav,
  .summary-grid,
  .actuator-grid,
  .visual-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 560px) {
  .app-shell,
  .sidebar {
    padding: 18px;
  }

  .date-panel,
  .card-header,
  .range-row,
  .section-title,
  .trend-row,
  .device-row,
  .alert-row,
  .setting-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .temperature-value {
    font-size: 56px;
  }
}
