:root {
  --accent: #e25822;
  --bg: #f7f5f2;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #777;
  --border: #ddd;
  --error: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 1rem;
  max-width: 1100px;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

h1 { margin: 0.2rem 0; }

.home-link { color: var(--muted); text-decoration: none; }
.home-link:hover { color: var(--accent); }

.plan-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.plan-bar select {
  padding: 0.3rem 0.5rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
}

.plan-bar button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  cursor: pointer;
}

.plan-bar button:hover { border-color: var(--accent); color: var(--accent); }

.pinned {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  padding: 0.25rem 0 0.5rem;
}

.chart-wrap {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  height: 320px;
}

#btn-flip {
  position: absolute;
  bottom: 0.55rem;
  right: 0.55rem;
  z-index: 10;
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

#btn-flip:hover { color: var(--accent); border-color: var(--accent); }

.info {
  display: inline-block;
  position: relative;
  margin-left: 0.3rem;
  color: #aaa;
  cursor: help;
  font-style: normal;
}

.info:hover, .info:focus { color: var(--accent); outline: none; }

.info .tip {
  display: none;
  position: absolute;
  left: 0;
  top: 1.5em;
  z-index: 100;
  width: 280px;
  padding: 0.6rem 0.75rem;
  background: #2b2b2b;
  color: #f3f3f3;
  font-size: 0.8rem;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.info:hover .tip, .info:focus .tip { display: block; }

.section-title {
  margin: 1rem 0 0.5rem;
  font-size: 1.05rem;
}

.chart-wrap.income { height: 300px; }

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 0.6rem 1.2rem;
  margin-top: 0.5rem;
}

.field {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.field .label-row {
  display: flex;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field .row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field input[type="text"] {
  width: 110px;
  padding: 0.25rem 0.4rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.field input[type="text"].invalid {
  border-color: var(--error);
  background: #fdecea;
}

.field input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.methodology {
  margin: 1.5rem 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}

.methodology summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.05rem;
}

.methodology code {
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.methodology pre {
  background: var(--bg);
  padding: 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
}

/* ---------------------------------------------------------------------------
   PDF report (#report) — never shown on screen; when exporting, the body gets
   .printing-report and print shows ONLY the report.
--------------------------------------------------------------------------- */

.report { display: none; }

@media print {
  @page { margin: 12mm; }

  body.printing-report {
    max-width: none;
    padding: 0;
    background: #fff;
  }

  body.printing-report > :not(.report) { display: none !important; }

  body.printing-report .report {
    display: block;
    font-size: 10pt;
    line-height: 1.4;
  }

  .report h1 { font-size: 16pt; margin: 0 0 0.1rem; }
  .report h2 {
    font-size: 11.5pt;
    margin: 0.8rem 0 0.35rem;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.12rem;
  }
  .report-meta { color: #555; margin: 0 0 0.5rem; font-size: 9.5pt; }

  /* Page 1: the two plots stacked, x-axes aligned (both canvases share the
     same width and a fixed y-axis width — see afterFit in app.js) */
  .report-charts-row { display: flex; flex-direction: column; gap: 1.5mm; }
  .report-charts-row figure { margin: 0; }
  .report-charts-row figcaption {
    font-size: 9pt;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.1rem;
  }
  .report-charts-row img { width: 100%; display: block; }

  /* Outcome facts strip */
  .report-facts { display: flex; gap: 3mm; }
  .report-facts .fact {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    text-align: center;
  }
  .report-facts .fact span { display: block; font-size: 8pt; color: #555; }
  .report-facts .fact b { font-size: 9.5pt; white-space: nowrap; }

  /* Explicit inputs list */
  .report-kvs { column-count: 2; column-gap: 8mm; }
  .report-kvs .kv {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    break-inside: avoid;
    padding: 0.1rem 0;
    border-bottom: 1px solid #eee;
    font-size: 9pt;
  }
  .report-kvs .kv span { color: #555; }

  /* Page 2: methodology */
  .report-methodology-page { break-before: page; }
  .report-methodology {
    font-size: 7.5pt;
    line-height: 1.2;
    column-count: 2;
    column-gap: 7mm;
  }
  .report-methodology h1 { display: none; } /* the section already has a heading */
  .report-methodology h1 + p { display: none; } /* repo-maintenance preamble, not report content */
  .report-methodology h2 { font-size: 9pt; border: none; margin: 0.35rem 0 0.1rem; break-after: avoid; }
  .report-methodology p, .report-methodology ul { margin: 0.18rem 0; }
  .report-methodology ul { padding-left: 1.1rem; }
  .report-methodology pre, .report-methodology code {
    font-size: 7.2pt;
    background: #f4f4f4;
  }
  .report-methodology pre {
    margin: 0.18rem 0;
    padding: 0.25rem;
    break-inside: avoid;
    white-space: pre-wrap; /* code lines wider than a column wrap, not clip */
  }
}
