:root {
  --ink: #17201b;
  --muted: #667069;
  --surface: #ffffff;
  --surface-soft: #f2f5f1;
  --line: #dfe5de;
  --green: #2e6f4f;
  --green-soft: #dcebe2;
  --amber: #8a5b16;
  --amber-soft: #fff0cf;
  --danger: #a43f3f;
  --danger-soft: #fff1ef;
  --shadow: 0 20px 55px rgba(32, 51, 40, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: #e8ede7;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.9), transparent 35%),
    linear-gradient(180deg, #eef2ed 0%, #e3e9e2 100%);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 28px;
}

.header,
.section-heading,
.energy-card,
.shower-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.kicker {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

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

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 7vw, 4.7rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9da69f;
  box-shadow: 0 0 0 5px rgba(157, 166, 159, 0.15);
}

.status.is-online .status-dot {
  background: #329363;
  box-shadow: 0 0 0 5px rgba(50, 147, 99, 0.15);
}

.status.is-offline .status-dot {
  background: #c35a4f;
  box-shadow: 0 0 0 5px rgba(195, 90, 79, 0.15);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  margin: 38px 0 28px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.tab {
  min-width: 108px;
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.tab:hover {
  color: var(--ink);
}

.tab:focus-visible {
  outline: 3px solid rgba(46, 111, 79, 0.35);
  outline-offset: 2px;
}

.tab.is-active {
  color: #fff;
  background: var(--green);
  box-shadow: 0 7px 20px rgba(46, 111, 79, 0.22);
}

.view {
  animation: enter 220ms ease-out;
}

.section-heading {
  margin-bottom: 18px;
}

.updated {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.temperature-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.temperature-card,
.energy-card,
.shower-card,
.chart-card,
.summary-item {
  border: 1px solid rgba(210, 219, 211, 0.95);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.temperature-card {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  padding: 22px;
  border-radius: 22px;
}

.temperature-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--accent);
  content: "";
}

.temperature-card p {
  min-height: 48px;
  margin-bottom: 22px;
  color: var(--muted);
  font-weight: 750;
}

.temperature-card strong {
  display: inline;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 5vw, 3.7rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.temperature-card span {
  margin-left: 3px;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}

.accent-red {
  --accent: #d65b55;
}

.accent-amber {
  --accent: #d4952c;
}

.accent-blue {
  --accent: #4f79bb;
}

.accent-purple {
  --accent: #8a61ba;
}

.accent-teal {
  --accent: #2f958d;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.energy-card {
  margin-top: 16px;
  padding: 20px 24px;
  border-radius: 18px;
}

.insight-grid > .energy-card {
  margin-top: 0;
}

.shower-card {
  padding: 20px 24px;
  border-radius: 18px;
}

.history-energy-card {
  margin-bottom: 14px;
}

.energy-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.energy-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}

.energy-value strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.energy-value span {
  font-weight: 800;
}

.shower-summary {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 7px;
  text-align: right;
}

.shower-status {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.shower-card[data-status="sufficient"] .shower-status {
  color: var(--green);
  background: var(--green-soft);
}

.shower-card[data-status="limited"] .shower-status {
  color: var(--amber);
  background: var(--amber-soft);
}

.shower-card[data-status="insufficient"] .shower-status {
  color: var(--danger);
  background: var(--danger-soft);
}

.shower-summary strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

#shower-count {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.energy-days {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.energy-day {
  display: grid;
  grid-template-columns: minmax(72px, 0.6fr) minmax(120px, 1fr) minmax(82px, auto);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(210, 219, 211, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.energy-day-label {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.energy-day-bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.energy-day-bar span {
  display: block;
  width: var(--energy-width);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.energy-day strong {
  font-size: 0.92rem;
  text-align: right;
}

.chart-card {
  padding: 20px;
  border-radius: 22px;
}

.chart-wrap {
  position: relative;
  height: min(50vh, 430px);
  min-height: 310px;
}

#temperature-chart {
  width: 100%;
  height: 100%;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin-bottom: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.legend-swatch {
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--swatch);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.summary-item {
  padding: 16px;
  border-radius: 16px;
}

.summary-item p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.summary-item strong {
  display: block;
  font-size: 1.05rem;
}

.empty-state {
  margin: 0;
  padding: 65px 20px;
  color: var(--muted);
  text-align: center;
}

.error-banner {
  margin-bottom: 18px;
  padding: 13px 16px;
  border: 1px solid #edc8c4;
  border-radius: 13px;
  color: var(--danger);
  background: #fff1ef;
  font-weight: 700;
}

footer {
  padding: 28px 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

footer p {
  margin-bottom: 0;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@media (max-width: 900px) {
  .temperature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 600px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding-top: 24px;
  }

  .header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .status {
    align-self: flex-start;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    margin-top: 26px;
  }

  .tab {
    min-width: 0;
    padding-inline: 10px;
  }

  .temperature-card {
    min-height: 160px;
    padding: 18px;
  }

  .temperature-card p {
    min-height: 42px;
    margin-bottom: 14px;
  }

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

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

  .shower-summary {
    align-items: flex-start;
    text-align: left;
  }

  .energy-days {
    gap: 7px;
  }

  .energy-day {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .energy-day strong {
    text-align: left;
  }

  .chart-card {
    padding: 14px 10px;
  }

  .chart-wrap {
    min-height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
