@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600&family=IBM+Plex+Sans:wght@400;600&family=Space+Grotesk:wght@400;600;700&display=swap");

:root {
  --bg: #f3f6f9;
  --ink: #111827;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.18);
  --oil: #c2410c;
  --pellets: #ca8a04;
  --gas: #166534;
  --heatpump: #2563eb;
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.14);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Space Grotesk", sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 55%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  min-height: 100vh;
}

.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.65;
}

.orb-a {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.22) 0%, rgba(37, 99, 235, 0) 70%);
  top: -120px;
  left: -100px;
}

.orb-b {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.18) 0%, rgba(15, 118, 110, 0) 70%);
  bottom: -140px;
  right: -120px;
}

.orb-c {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.2) 0%, rgba(59, 130, 246, 0) 70%);
  top: 35%;
  right: 12%;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
  padding: 48px 8vw 24px;
  align-items: center;
  animation: rise 0.9s ease-out;
}

.hero.simple {
  grid-template-columns: 1fr;
  padding: 36px 8vw 12px;
}

.hero.simple h1 {
  font-size: clamp(2.1rem, 4vw, 3rem);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-logo {
  width: clamp(90px, 14vw, 140px);
  height: auto;
  object-fit: contain;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 3vw, 3.2rem);
  margin: 0 0 16px;
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 520px;
}


.content {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 32px;
  padding: 0 8vw 60px;
}

.panel {
  animation: fadeIn 1.1s ease-out;
}

.card,
.result-card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.result-card.subtle {
  background: #f8fafc;
  color: var(--muted);
}

fieldset {
  border: none;
}

legend {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 18px;
}

.span-2 {
  grid-column: span 2;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.autocomplete {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  gap: 4px;
  box-shadow: 0 10px 20px rgba(27, 26, 23, 0.15);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
}

.autocomplete-results button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.8rem;
}

.autocomplete-results button:hover {
  background: var(--accent-soft);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.model-row {
  margin-bottom: 18px;
}

.model-label {
  width: 100%;
}

.model-card {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  width: 100%;
  font-family: inherit;
}

.model-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--ink);
}

.model-card p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.model-card.selected {
  border-color: var(--heatpump);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.16);
  transform: translateY(-2px);
}

.model-card.recommended {
  border-color: var(--accent);
  box-shadow: 0 10px 18px rgba(14, 165, 233, 0.2);
}

.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent);
  margin-top: 6px;
}

.inline-toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-toggle input {
  width: auto;
}

.inline-label {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  white-space: nowrap;
}

.auto-curve-panel {
  margin-top: 16px;
}

.curve-chart {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.curve-svg {
  width: 100%;
  height: 160px;
}

.curve-axis {
  stroke: rgba(27, 26, 23, 0.4);
  stroke-width: 1;
}

.curve-grid {
  stroke: rgba(27, 26, 23, 0.2);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.curve-line {
  fill: none;
  stroke: var(--heatpump);
  stroke-width: 2;
}

.curve-svg circle {
  fill: var(--accent);
}

.curve-label {
  fill: var(--muted);
  font-size: 10px;
}

.curve-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
  margin-bottom: 10px;
}

.curve-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.curve-point {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  font-size: 0.85rem;
}

.helper {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
  color: var(--ink);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.climate-chart {
  position: relative;
}

.climate-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 140px;
  padding: 6px 4px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.climate-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, rgba(42, 107, 191, 0.85), rgba(42, 107, 191, 0.25));
}

.climate-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 8px;
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.95rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(14, 165, 233, 0.25);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.radio-row label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

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

.note-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.note-label {
  font-weight: 600;
  color: var(--ink);
}

.note-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(27, 26, 23, 0.08);
}

.btn {
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 20px rgba(14, 165, 233, 0.25);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 16px rgba(27, 26, 23, 0.12);
}

.hint {
  color: var(--muted);
}

.hidden {
  display: none;
}

#results table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 12px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

#results th,
#results td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

#pdfLink {
  margin-top: 16px;
}

.chart {
  margin-top: 20px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
}

.chart h3 {
  margin: 0 0 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
}

.bivalent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.bivalent-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--oil);
  box-shadow: 0 0 0 3px rgba(194, 59, 42, 0.12);
}

.legend-item.supply .legend-dot {
  background: var(--heatpump);
  box-shadow: 0 0 0 3px rgba(42, 107, 191, 0.12);
}

.bivalent-canvas {
  display: grid;
  gap: 10px;
}

.bivalent-svg {
  width: 100%;
  height: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.55));
  border-radius: 14px;
  border: 1px solid var(--border);
}

.bivalent-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.bivalent-grid-line {
  stroke: rgba(27, 26, 23, 0.08);
  stroke-dasharray: 4 6;
}

.bivalent-area-demand {
  fill: rgba(194, 59, 42, 0.12);
}

.bivalent-area-supply {
  fill: rgba(42, 107, 191, 0.12);
}

.bivalent-line-demand {
  fill: none;
  stroke: var(--oil);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bivalent-line-supply {
  fill: none;
  stroke: var(--heatpump);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bivalent-point {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2;
}

.bivalent-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.bivalent-label {
  font-size: 0.7rem;
  fill: var(--muted);
}

.bivalent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bivalent-pill {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(192, 101, 45, 0.12);
  color: var(--ink);
  border: 1px solid rgba(192, 101, 45, 0.2);
}

.bivalent-pill.muted {
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  border: 1px solid var(--border);
}

#bivalentChart {
  padding: 12px;
}

#bivalentChart .bivalent-svg {
  height: 180px;
}

#bivalentChart .bivalent-meta {
  gap: 6px;
}

#bivalentChart .bivalent-pill {
  padding: 5px 8px;
  font-size: 0.72rem;
}

#bivalentChart .hint {
  margin-top: 6px;
}

.chart-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 130px;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

.chart-label {
  font-weight: 600;
  color: var(--ink);
}

.chart-track {
  flex: 1;
  height: 10px;
  background: rgba(27, 26, 23, 0.12);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(27, 26, 23, 0.12);
}

.chart-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.chart-bar.negative {
  background: #b4472a;
}

.chart-bar.bar-oil {
  background: var(--oil);
}

.chart-bar.bar-pellets {
  background: var(--pellets);
}

.chart-bar.bar-gas {
  background: var(--gas);
}

.chart-bar.bar-heatpump {
  background: var(--heatpump);
}

.chart-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#warnings {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(166, 74, 43, 0.08);
  border: 1px solid rgba(166, 74, 43, 0.18);
  color: #a64a2b;
}

#warnings h3 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
}

#warnings ul {
  margin: 0;
  padding-left: 18px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .content {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .chart-row {
    grid-template-columns: 1fr;
  }
  .chart-value {
    text-align: left;
  }
}
