:root {
  /* Earthy, paper-toned palette */
  --paper: #f4f1ea;
  --paper-deep: #ede8dc;
  --ink: #1f1d1a;
  --ink-soft: #4a4640;
  --ink-mute: #837e74;
  --ink-faint: #b9b3a6;
  --line: #d8d2c2;
  --line-soft: #e7e2d4;
  --card: #fbf9f3;
  --card-edge: #e7e2d4;

  /* Material accents */
  --rain: #2f5d7a;       /* ink-blue, like rain on slate */
  --rain-soft: #88a8bf;
  --rain-fill: #c8d8e3;
  --leaf: #4d6b3a;       /* sage / vegetable green */
  --leaf-soft: #94a87e;
  --soil: #8a5a2b;       /* terracotta */
  --soil-soft: #c79569;
  --warn: #b94a2b;
  --good: #466b3a;

  /* Type */
  --display: 'Fraunces', 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Helvetica Neue', sans-serif;

  --shadow-card: 0 1px 0 rgba(31,29,26,.04), 0 18px 40px -28px rgba(31,29,26,.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  /* subtle paper grain */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(120,108,80,.05) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: multiply;
  z-index: 0;
}

.canvas {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 40px 80px;
}

/* ───────── Masthead ───────── */
.masthead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 28px;
  margin-bottom: 32px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px 48px;
  align-items: end;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--rain);
}
.brand-mark {
  display: inline-flex;
  width: 28px;
  height: 36px;
  align-items: center;
  justify-content: center;
}
.brand-word {
  font-family: var(--display);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
}
.dek {
  margin: 0;
  max-width: 56ch;
  font-family: var(--display);
  font-weight: 350;
  font-size: 19px;
  line-height: 1.5;
  color: var(--ink-soft);
  letter-spacing: -0.005em;
}

/* ───────── Bands (location + climate) ───────── */
.band {
  display: grid;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 22px 0;
  margin-bottom: 0;
}
.band--location {
  grid-template-columns: 130px 1fr;
  gap: 32px;
}
.band--climate {
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  border-top: none;
  padding-top: 22px;
  padding-bottom: 28px;
  margin-bottom: 32px;
}
.band-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.location-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
}
.location-name {
  font-family: var(--display);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.1;
}
.location-meta {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.location-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  width: 360px;
  max-width: 100%;
}
.location-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.precise-loc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--rain);
  cursor: pointer;
  padding: 4px 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0;
  border-bottom: 1px dashed var(--rain-soft);
  transition: color .15s ease, border-color .15s ease;
}
.precise-loc-btn:hover { color: var(--ink); border-bottom-color: var(--ink); }
.precise-loc-btn:disabled { color: var(--ink-faint); border-bottom-color: var(--ink-faint); cursor: progress; }
.precise-loc-btn svg { flex-shrink: 0; }
.location-search input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--card);
  border-right: none;
  border-radius: 999px 0 0 999px;
  padding: 12px 18px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.location-search input::placeholder { color: var(--ink-faint); }
.location-search input:focus {
  border-color: var(--rain);
  background: #fff;
}
.location-search button {
  border: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--card);
  border-radius: 0 999px 999px 0;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.location-search button:hover { background: var(--rain); color: #fff; border-color: var(--rain); }
.location-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  z-index: 50;
  overflow: hidden;
}
.location-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.location-suggest button:hover { background: var(--paper-deep); color: var(--ink); }
.location-suggest button + button { border-top: 1px solid var(--line-soft); }
.location-suggest .sugg-meta { color: var(--ink-mute); font-size: 12px; margin-left: 8px; }

/* ───────── Climate stats band ───────── */
.climate-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.stat-value {
  font-family: var(--display);
  font-weight: 400;
  font-size: 40px;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 144;
}
.stat-unit {
  font-size: 12px;
  color: var(--ink-mute);
}

/* ───────── Grid for main cards ───────── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* ───────── Cards ───────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}
.grid .card { margin-bottom: 0; }

.card-header { margin-bottom: 18px; }
.card-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}
.card-sub {
  font-size: 13px;
  color: var(--ink-mute);
  max-width: 65ch;
}

/* ───────── Inputs ───────── */
.card--inputs .control + .control { margin-top: 22px; }
.control > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
}
.control-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
}
.control-value {
  font-family: var(--display);
  font-weight: 400;
  font-size: 26px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  min-width: 110px;
  text-align: right;
}
.control-value .unit {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-mute);
  margin-left: 4px;
  letter-spacing: 0;
}

/* Roof status / thumbnail */
.roof-status {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(74, 107, 58, 0.06);
  border: 1px solid rgba(74, 107, 58, 0.18);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.roof-status[hidden] { display: none; }
.roof-status.warn {
  background: rgba(199, 149, 105, 0.08);
  border-color: rgba(199, 149, 105, 0.25);
}
.roof-status.error {
  background: rgba(185, 74, 43, 0.06);
  border-color: rgba(185, 74, 43, 0.25);
  color: var(--warn);
}
.roof-status-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.roof-status-tick {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  background: var(--leaf);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  align-self: center;
}
.roof-status-summary strong {
  font-family: var(--display);
  font-weight: 500;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.roof-status-meta {
  color: var(--ink-mute);
  font-size: 12px;
}
.roof-status-hint {
  color: var(--ink-mute);
  font-size: 11px;
  font-style: italic;
  margin-top: 8px;
}
.roof-map {
  position: relative;
  margin-top: 10px;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #d4cebd;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 11;
  user-select: none;
  touch-action: none;
}
.roof-map-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.roof-map-svg.is-panning { cursor: grabbing; }
.map-building {
  cursor: pointer;
  transition: fill 120ms ease, stroke 120ms ease;
}
.roof-map-hud {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 2;
}
.map-btn {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(31, 29, 26, 0.18);
  border-radius: 6px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.14);
  transition: background .15s ease, transform .1s ease;
  padding: 0;
}
.map-btn:hover { background: #fff; }
.map-btn:active { transform: scale(0.95); background: var(--paper-deep); }
.map-attr {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
  z-index: 2;
}
.map-attr a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.5);
}
.map-btn-layer {
  margin-top: 4px;
  font-size: 14px;
  border-top: 1px solid rgba(31, 29, 26, 0.18);
}

/* Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--line);
  border-radius: 4px;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--line);
  border-radius: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  width: 22px;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  margin-top: -9px;
  box-shadow: 0 2px 6px rgba(31,29,26,.18);
  transition: transform .12s ease;
}
input[type="range"]::-moz-range-thumb {
  height: 22px;
  width: 22px;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(31,29,26,.18);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.08); }
input[type="range"]:focus { outline: none; }
input[type="range"]:focus::-webkit-slider-thumb { border-color: var(--rain); }

/* Toggles */
.control--toggles { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line-soft); display: grid; gap: 22px; }
.toggle-group { display: grid; gap: 10px; }
.toggle-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 0;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-mark {
  width: 36px;
  height: 22px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  transition: background .18s ease;
  flex-shrink: 0;
}
.toggle-mark::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(31,29,26,.25);
  transition: left .18s ease;
}
.toggle input:checked + .toggle-mark { background: var(--leaf); }
.toggle input:checked + .toggle-mark::after { left: 16px; }
.toggle-text { font-size: 14px; color: var(--ink); }
.toggle-text em { color: var(--ink-mute); font-style: normal; font-size: 13px; }
.toggle-saving {
  font-family: var(--display);
  font-size: 14px;
  color: var(--leaf);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}
.toggle input:not(:checked) ~ .toggle-saving { color: var(--ink-faint); }
.toggle-summary {
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
  padding-top: 4px;
}
.toggle-summary strong { color: var(--leaf); font-style: normal; font-weight: 600; }

/* ───────── Verdict ───────── */
.verdict-headline {
  font-family: var(--display);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 6px 0 24px;
  min-height: 78px;
}
.verdict-headline .accent-good { color: var(--good); }
.verdict-headline .accent-tight { color: var(--soil); }
.verdict-headline .accent-bad { color: var(--warn); }
.verdict-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
}
.vstat { display: flex; flex-direction: column; gap: 4px; }
.vstat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.vstat-value {
  font-family: var(--display);
  font-size: 24px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ───────── Charts ───────── */
.chart-wrap { width: 100%; }
.chart-wrap--bars { padding-top: 4px; }
#tankChart, #balanceChart { width: 100%; height: auto; display: block; }
#heatmap { width: 100%; height: auto; display: block; cursor: crosshair; }

.heatmap-wrap { width: 100%; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-mute);
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-swatch { width: 16px; height: 3px; border-radius: 2px; }

/* ───────── Footer ───────── */
.colophon {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.6;
}
.colophon a { color: var(--ink-soft); }

/* ───────── Loading state ───────── */
.is-loading .stat-value,
.is-loading .verdict-headline { opacity: 0.45; }
.is-loading {
  filter: saturate(.7);
}

/* ───────── Responsive ───────── */
@media (max-width: 880px) {
  .canvas { padding: 40px 22px 60px; }
  .masthead { grid-template-columns: 1fr; gap: 16px; }
  .grid { grid-template-columns: 1fr; }
  .band--climate { grid-template-columns: 1fr 1fr; gap: 22px 18px; }
  .band--location { grid-template-columns: 1fr; gap: 12px; }
  .location-row { grid-template-columns: 1fr; gap: 18px; }
  .location-search { width: 100%; }
  .stat-value { font-size: 32px; }
  .card { padding: 22px 22px; }
}
