* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #222;
}

a { color: #d6301c; }
a:hover { color: #b5271a; }
/* Leaflet's own CSS colors in-map links (attribution) blue via a more specific
   selector, so override it to match. */
.leaflet-container a { color: #d6301c; }
.leaflet-container a:hover { color: #b5271a; }

#layout { display: flex; height: 100vh; }
#map { flex: 1; }

#panel {
  width: 380px;
  padding: 1.4rem 1.4rem 2rem;
  border-left: 1px solid #ddd;
  overflow-y: auto;
  background: #fafafa;
}

/* Phones / narrow windows: stack the map above the panel and let the whole page
   scroll, instead of the fixed side-by-side row (which squeezes the map down to
   a sliver next to the 380px panel). */
@media (max-width: 760px) {
  html, body { height: auto; }
  #layout { flex-direction: column; height: auto; }
  #map {
    flex: none;
    height: 45vh;
    height: 45dvh; /* dvh avoids jumps as iOS Safari's toolbar shows/hides */
    min-height: 300px;
  }
  #panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid #ddd;
    overflow-y: visible;
    padding-bottom: 2.5rem;
  }
}

h1 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #b5271a;
}
.hint { color: #666; font-size: 0.85rem; margin-bottom: 1.1rem; line-height: 1.45; }
[hidden] { display: none !important; }

form label {
  display: block;
  margin-bottom: 0.8rem;
  font-size: 0.82rem;
  color: #444;
  font-weight: 500;
}
form input {
  display: block;
  width: 100%;
  padding: 0.45rem 0.55rem;
  margin-top: 0.25rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}
form input:focus { outline: none; border-color: #d6301c; box-shadow: 0 0 0 2px #fce8e4; }

.cost-details {
  margin-bottom: 0.6rem;
  border-top: 1px solid #eee;
  padding-top: 0.7rem;
}
.cost-details summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: #888;
  font-weight: 600;
  margin-bottom: 0.7rem;
  user-select: none;
}
.cost-details summary:hover { color: #d6301c; }

#status {
  margin: 0.4rem 0 1rem;
  font-size: 0.82rem;
  min-height: 1.1em;
}
#status.loading { color: #b5271a; }
#status.error { color: #c0392b; font-weight: 600; }

/* --- Result card --- */
.headline {
  background: #fff;
  border: 1px solid #eadada;
  border-top: 3px solid #d6301c;
  border-radius: 6px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.headline .build {
  font-size: 1.35rem;
  font-weight: 700;
  color: #222;
  line-height: 1.3;
}
.headline .build .unit { font-weight: 500; color: #666; font-size: 0.9rem; }
.headline .plus { color: #d6301c; margin: 0 0.3rem; }
.headline .cost {
  font-size: 1.7rem;
  font-weight: 800;
  color: #b5271a;
  margin-top: 0.6rem;
}
.headline .per-load {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 0.5rem;
}
.headline .cost .sub { font-size: 0.8rem; font-weight: 500; color: #888; }

dl.detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.8rem;
  font-size: 0.84rem;
  margin-top: 0.2rem;
}
dl.detail dt { color: #777; }
dl.detail dd { text-align: right; color: #333; font-variant-numeric: tabular-nums; }

.note { font-size: 0.75rem; color: #999; margin-top: 0.8rem; line-height: 1.4; }
.warnings {
  background: #fff7e6;
  border: 1px solid #ffe1a8;
  border-radius: 5px;
  padding: 0.6rem 0.7rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: #8a6d1a;
  line-height: 1.4;
}
.infeasible {
  background: #fdecea;
  border: 1px solid #f5c6c0;
  border-radius: 5px;
  padding: 0.8rem;
  font-size: 0.85rem;
  color: #b5271a;
}

/* --- Average-year charts --- */
#charts { margin-top: 1.4rem; border-top: 1px solid #eee; padding-top: 1rem; }
.charts-title { font-size: 1rem; color: #333; margin-bottom: 0.2rem; }
.charts-hint { font-size: 0.75rem; color: #999; margin-bottom: 1rem; line-height: 1.4; }
.chart-block { margin-bottom: 1.1rem; }
.chart-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.2rem;
}
.chart-label .cl-unit { font-weight: 400; color: #999; }
.chart { width: 100%; }
.chart .u-title { display: none; }
/* Pin each legend series to its own line. uPlot's inline legend otherwise wraps a
   different number of rows once values populate on hover (— → real numbers), and
   that height change shifts every chart up/down as the cursor moves on and off. */
.chart .u-legend .u-series { display: block; text-align: left; }
