:root {
  --bg: #eef2eb;
  --bg-accent: #d7e4d4;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --text: #173228;
  --muted: #597063;
  --line: rgba(23, 50, 40, 0.12);
  --bau: #7a8f84;
  --scenario: #bf5f2f;
  --success: #2b7a5c;
  --teal: #006b67;
  --teal-dark: #004d4a;
  --gold: #d9a52e;
  --shadow: 0 18px 50px rgba(23, 50, 40, 0.1);
  --radius: 24px;
  --font-head: Georgia, "Times New Roman", serif;
  --font-body: Aptos, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.6), transparent 30%),
    linear-gradient(160deg, var(--bg) 0%, #f8f5ef 48%, var(--bg-accent) 100%);
}

button, input, summary { font: inherit; }

a { color: var(--teal-dark); text-underline-offset: 3px; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--teal-dark);
}

.skip-link:focus { transform: translateY(0); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-header {
  color: white;
  background: linear-gradient(125deg, #063f42 0%, #006b67 60%, #1d5f6f 100%);
  border-bottom: 6px solid var(--gold);
}

.header-inner {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 40px;
}

.page-header .eyebrow { color: white; }

.header-lede {
  max-width: 760px;
  margin: 18px 0 0;
  color: #e8f5f3;
  font-size: clamp(1.04rem, 2vw, 1.28rem);
  line-height: 1.55;
}

.header-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  font-size: 0.84rem;
  font-weight: 700;
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

.guide-panel, .panel {
  backdrop-filter: blur(14px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.guide-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
  gap: 28px 36px;
  padding: 26px 28px;
  border-radius: 28px;
}

.guide-intro p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: guide-step;
}

.guide-steps li {
  counter-increment: guide-step;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  line-height: 1.45;
}

.guide-steps li::before {
  content: counter(guide-step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border-radius: 50%;
  color: white;
  background: var(--teal);
  font-weight: 800;
}

.guide-steps strong { color: var(--text); }

.model-boundary {
  grid-column: 1 / -1;
  margin: 0;
  padding: 13px 16px;
  border: 2px solid #cf9b31;
  border-radius: 12px;
  color: #70400f;
  background: #fff8df;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--success);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
}

h1 {
  font-size: clamp(2rem, 3.8vw, 3.7rem);
  line-height: 1.02;
  max-width: 18ch;
}

.panel-header p, .tab-panel p, small, td, th { color: var(--muted); }

.dashboard {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
  margin-top: 20px;
}

.panel {
  border-radius: var(--radius);
  padding: 22px;
}

.panel-header {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.panel-header p {
  margin: 0;
  line-height: 1.5;
}

.panel-header .timing-explanation {
  margin-top: 6px;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: #fff8e6;
  color: var(--text);
  font-size: 0.9rem;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

button {
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover, summary:hover { transform: translateY(-1px); }

button[aria-pressed="true"] {
  color: white;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.slider-block {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  padding: 16px 0 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.slider-block legend {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  font-weight: 700;
}

.slider-block legend span {
  margin-left: 12px;
  white-space: nowrap;
  font-family: var(--font-body);
  font-weight: 400;
}

.slider-block > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.timing-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.timing-row label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

.timing-row input,
.horizon-control select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

input[type="range"] {
  width: 100%;
  accent-color: #a4552d;
}

.range-limits {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.range-limits span:last-child { text-align: right; }

.assumptions {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.assumption-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}

.assumption-grid label {
  display: grid;
  gap: 8px;
}

.assumption-grid input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.full-width { grid-column: 1 / -1; }

.chart-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 250px);
  gap: 20px;
  align-items: start;
  margin-bottom: 14px;
}

.chart-heading .eyebrow { margin-bottom: 6px; }

.chart-guide {
  max-width: 76ch;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.horizon-control {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f6faf7;
}

.horizon-control > span { font-weight: 700; }

.snapshot-summary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  color: var(--muted);
  background: #edf7f4;
  line-height: 1.45;
}

.chart-shell {
  background:
    linear-gradient(180deg, rgba(122, 143, 132, 0.08), transparent 55%),
    var(--surface-strong);
  border-radius: 20px;
  border: 1px solid var(--line);
  padding: 12px 14px 18px;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.axis-line {
  stroke: #595959;
  stroke-width: 1.5;
}

.grid-line {
  stroke: #d9d9d9;
  stroke-width: 1;
}

.axis-tick {
  stroke: #595959;
  stroke-width: 1;
}

.axis-label,
.axis-title {
  fill: #4b5f55;
  font-family: var(--font-body);
  font-size: 13px;
}

.axis-title { font-weight: 700; }

.line-bau, .line-residual, .line-scenario-total {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-bau {
  stroke: var(--bau);
  stroke-dasharray: 10 8;
}
.line-residual {
  stroke: #d27a2f;
  stroke-dasharray: 3 6;
}

.line-scenario-total {
  stroke: var(--scenario);
}

.area-investment {
  fill: rgba(191, 95, 47, 0.16);
}

.chart-legend, .tab-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.chart-legend {
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--muted);
}

.chart-legend > span { min-width: max-content; }

.legend-line {
  display: inline-block;
  width: 24px;
  height: 3px;
  margin-right: 8px;
  vertical-align: middle;
}

.legend-line.bau {
  height: 0;
  border-top: 3px dashed var(--bau);
  background: transparent;
}
.legend-line.residual {
  height: 0;
  border-top: 3px dotted #d27a2f;
  background: transparent;
}
.legend-line.scenario-total { background: var(--scenario); }

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 12px;
  margin-right: 8px;
  vertical-align: middle;
}

.legend-swatch.investment {
  background: rgba(191, 95, 47, 0.16);
  border: 1px solid rgba(191, 95, 47, 0.4);
}

.cost-explanation {
  margin-top: 16px;
  padding: 16px 18px;
  border-left: 4px solid var(--scenario);
  border-radius: 0 14px 14px 0;
  background: #fff7f1;
}

.cost-explanation h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.cost-explanation p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.chart-data-details {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
}

.chart-data-details summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
}

.chart-data-details > p {
  margin: 0;
  padding: 0 16px 10px;
  color: var(--muted);
}

.chart-data-details .table-wrap {
  margin: 0 16px 16px;
  max-height: 360px;
}

.metric-grid {
  display: grid;
  gap: 12px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.88);
}

.metric-label, .metric-value, .metric-description { margin: 0; }

.metric-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.metric-value {
  margin-top: 8px;
  font-size: 1.6rem;
  font-family: var(--font-head);
}

.metric-description {
  margin-top: 8px;
  line-height: 1.45;
  color: var(--muted);
}

.lower-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 20px;
  margin-top: 20px;
}

.dashboard > *,
.lower-grid > * {
  min-width: 0;
}

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  min-width: 110px;
}

thead th {
  position: sticky;
  top: 0;
  background: #f9faf6;
  z-index: 1;
}

.confidence-pill, .evidence-type {
  display: inline-block;
  margin-right: 6px;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.confidence-pill { color: white; }
.confidence-high { background: #2f7f63; }
.confidence-medium { background: #9b7f2d; }
.confidence-low { background: #9a4f3f; }

.evidence-type {
  background: rgba(215, 228, 212, 0.9);
  color: var(--text);
}

.tab-row {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-row button[aria-pressed="true"] {
  background: #204737;
  color: white;
  border-color: #204737;
}

.tab-panel {
  min-height: 220px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.tab-panel h3 { margin-bottom: 12px; }

.error-banner {
  padding: 20px;
  border-radius: 16px;
  background: #fff4ef;
  border: 1px solid #e4b29f;
}

.site-footer {
  padding: 2rem max(1.2rem, calc((100vw - 1240px) / 2));
  border-top: 6px solid var(--gold);
  color: #d8e9e6;
  background: #173b40;
}

.site-footer p {
  max-width: 900px;
  margin: 0.3rem 0;
}

.site-footer a { color: white; }

.footer-logo-link {
  display: inline-block;
  max-width: min(360px, 78vw);
  margin: 0 0 0.85rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: white;
}

.footer-logo {
  display: block;
  width: 100%;
  height: auto;
}

.footer-brand {
  color: white;
  font-size: 1.08rem;
}

@media (max-width: 1180px) {
  .dashboard, .lower-grid { grid-template-columns: 1fr; }
  .guide-panel { grid-template-columns: 1fr; }
  .guide-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .header-inner {
    width: min(100% - 24px, 1440px);
    padding: 30px 0;
  }

  .page-shell {
    width: min(100vw - 18px, 1440px);
    margin-top: 10px;
  }

  .panel, .guide-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .guide-steps { grid-template-columns: 1fr; }
  .chart-heading { grid-template-columns: 1fr; }
  .chart-legend { justify-content: flex-start; }
  .assumption-grid { grid-template-columns: 1fr; }
  .timing-row { grid-template-columns: 1fr; }
}
