:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1d23;
  --muted: #5b6472;
  --border: #dde1e6;
  --accent: #1f6f5c;
  --accent-contrast: #ffffff;
  --backup: #d97a3d;
  --demand: #8a94a3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2025;
    --text: #e8eaed;
    --muted: #9aa3af;
    --border: #2c3038;
    --accent: #4fb59a;
    --accent-contrast: #0b1210;
    --backup: #e3945b;
    --demand: #6b7480;
  }
}

* { box-sizing: border-box; }

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

header, main, footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 { margin-bottom: 0.25rem; font-size: 1.6rem; }
.subtitle { color: var(--muted); margin-top: 0; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
}

legend { padding: 0 0.5rem; font-weight: 600; }

form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
}

fieldset > label:last-child { margin-bottom: 0; }

input[type="text"], input[type="number"], select {
  font-size: 1rem;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem !important;
}
.checkbox-label input[type="checkbox"] { width: auto; }

.ground-info {
  margin-top: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sub-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.sub-block h4 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

fieldset .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.4rem 0 0.8rem;
}

.heatpump-list { display: flex; flex-direction: column; gap: 0.6rem; }

.heatpump-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.heatpump-option input { margin-top: 0.2rem; }

.heatpump-option .meta { color: var(--muted); font-size: 0.85rem; }

button[type="submit"] {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:disabled { opacity: 0.6; cursor: default; }

.status {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-top: 1.25rem;
}
.status.error { border-color: #c0392b; color: #c0392b; }

.results { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.result-card h3 { margin-top: 0; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.metric { padding: 0.6rem 0.75rem; background: var(--bg); border-radius: 8px; }
.metric .label { font-size: 0.75rem; color: var(--muted); }
.metric .value { font-size: 1.15rem; font-weight: 600; }

.chart-legend { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; }

.location-info { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }

footer { color: var(--muted); font-size: 0.8rem; }
footer a { color: var(--accent); }
