/* Page CSS: only what sits inside the calculator's windows and the kit lacks. Tokens come from system.css. */
:root {
  /* chart series (dataviz reference palette, slots 1-5) */
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600; --s5: #ee7fac;
  --win: #ffffff; --bad: #a3261f;
}
.section-head.head { margin-bottom: var(--s-6); gap: var(--s-2); }
.section-head .head__note { font-size: var(--t-body); max-width: 80ch; }
.section-head.head h2 { max-width: none; }

/* ---------- hero window: the model's own output for the example project ---------- */
.peek { background: var(--win); color: var(--p-ink); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; text-align: left; }
.peek__bar { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); font-size: var(--t-small); font-weight: 500; white-space: nowrap; }
.peek__bar span + span { font-weight: 400; color: var(--p-muted); }
.peek__plot { padding: var(--s-3) var(--s-4) var(--s-1); }
.peek__facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.peek__facts span { display: grid; gap: 2px; padding: var(--s-2) var(--s-4) var(--s-3); font-size: var(--t-small); }
.peek__facts span + span { border-left: 1px solid var(--line); }
.peek__facts b { font: var(--display-weight) var(--t-h3)/1.2 var(--font-display); letter-spacing: var(--display-tracking); font-variant-numeric: tabular-nums; }
@media (max-width: 639px) {
  .peek__bar span + span { display: none; }
  .peek__plot { padding: var(--s-2) var(--s-2) 0; }
  .peek__plot .legend { display: none; }
  .peek__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .peek__facts span { padding: var(--s-1) var(--s-3) var(--s-2); font-size: var(--t-label); }
  .peek__facts span:nth-child(odd) { border-left: 0; }
}
.hero .hero__lead { color: var(--ink); }
.btn.btn--secondary { box-shadow: inset 0 0 0 1px var(--p-muted); border-color: var(--p-muted); }
.nav__link[aria-current] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 8px; }
/* ---------- the calculator window ---------- */
.app { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; background: var(--win); border: 1px solid var(--line-strong); border-radius: var(--r-lg); overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-4); align-items: center; margin-bottom: var(--s-4); }
.pick { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-small); font-weight: 500; }
.toolbar__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-left: auto; }
.toolbar select, .app select, .app input[type=number] { font: 400 var(--t-body)/1.2 var(--font-text); color: var(--ink); background: var(--win); border: 1px solid var(--line-strong); border-radius: var(--r-sm); min-height: 44px; padding: 0 10px; width: 100%; min-width: 0; }
.pick select { width: auto; }
.toolbar button:disabled { opacity: .45; cursor: not-allowed; }
/* the divider sits so the results' text starts on the page's split column */
.app__body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: calc((100% + 2px - 264px) * 5 / 12 + 95px) minmax(0, 1fr); }
.inputs { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--win); }
.intabs { display: flex; gap: var(--s-1); padding: 0 var(--s-3); border-bottom: 1px solid var(--line); }
.intabs button { flex: 1; min-height: 44px; background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; font: 500 var(--t-small)/1 var(--font-text); color: var(--muted); padding: 0 var(--s-1); }
.intabs button:hover { color: var(--ink); }
.intabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--action); }
.intabs button.has-error { color: var(--bad); }
#form { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--s-4); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); align-content: start; }
.f { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.f label { font-size: var(--t-small); font-weight: 500; line-height: 1.3; }
.f label span { font-weight: 400; color: var(--muted); }
.f__control { margin-top: auto; }
.f input[type=checkbox], .check input { width: 20px; height: 20px; accent-color: var(--action); margin: 0; }
.f--bool .f__control { min-height: 44px; display: flex; align-items: center; }
.f__tag { font-size: var(--t-label); color: var(--muted); }
.f__err { font-size: var(--t-label); color: var(--bad); }
.f.invalid input { border-color: var(--bad); }
.inputs__foot { display: grid; gap: var(--s-1); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); background: var(--win); }
.source-line { font-size: var(--t-label); line-height: 1.4; min-height: 2.8em; color: var(--muted); }
.check { display: flex; align-items: center; gap: var(--s-2); min-height: 44px; font-size: var(--t-small); font-weight: 500; }
.results { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4) var(--s-5); min-width: 0; min-height: 0; background: var(--win); }
.status:empty { display: none; }
.status { font-size: var(--t-small); font-weight: 500; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; }
.metric { grid-column: span 2; display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-3) var(--s-3) 0; border-bottom: 1px solid var(--line); }
.metric:nth-child(n+4) { grid-column: span 3; }
.metric:nth-child(n+6) { grid-column: span 3; }
.metric dt { font-size: var(--t-small); font-weight: 500; }
.metric dd { margin: 0; }
.metric__v { font: var(--display-weight) var(--t-stat)/1.1 var(--font-display); letter-spacing: var(--display-tracking); font-variant-numeric: tabular-nums; }
.metric__v.bad { color: var(--bad); }
.metric__h { font-size: var(--t-label); line-height: 1.35; color: var(--muted); }
.mix { display: grid; gap: var(--s-2); margin-top: auto; }
.mix__title { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-small); font-weight: 500; }
.mix__bar { display: block; width: 100%; height: 20px; border-radius: 4px; }

/* ---------- charts ---------- */
.plot { background: var(--win); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--card-pad); min-width: 0; }
.ground-base.plot { background: var(--win); }
.plot h3 { font: 500 var(--t-card)/1.3 var(--font-text); letter-spacing: -0.01em; margin-bottom: var(--s-3); }
.plot__note { font-size: var(--t-small); margin: calc(-1 * var(--s-2)) 0 var(--s-3); }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--p-muted); font: 400 13px var(--font-text); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--t-label); margin-bottom: var(--s-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.legend b { font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 4px; }
.tip { font-size: var(--t-label); min-height: 1.5em; margin-top: var(--s-2); }
.plot__action { display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--s-2); }

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
#table { font-size: var(--t-label); line-height: 1.25; }
#table th, #table td { padding: 3px 0 3px 8px; }
#table th:first-child, #table td:first-child { padding-left: 0; }
#table th { font-weight: 500; vertical-align: bottom; padding-bottom: var(--s-2); }
#table td { white-space: nowrap; }
.scroll { min-width: 0; }
#scenarios { font-size: var(--t-small); }
#scenarios th, #scenarios td { padding: var(--s-3) 0 var(--s-3) var(--s-3); vertical-align: top; }
#scenarios th:first-child, #scenarios td:first-child { padding-left: 0; }
#scenarios th { font-weight: 500; padding-top: 0; }
#scenarios td { white-space: nowrap; }
#scenarios td:first-child { white-space: normal; font-weight: 500; }
#scenarios small { display: block; font-size: var(--t-label); font-weight: 400; color: var(--muted); line-height: 1.4; }

/* ---------- method ---------- */
.rules { margin: 0; }
.rules > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: var(--s-4); padding: 10px 0; border-bottom: 1px solid var(--line); }
.rules dt { font-weight: 500; }
.rules dd { margin: 0; }
.sources__h { font: 500 var(--t-card)/1.3 var(--font-text); margin-bottom: var(--s-2); }
.sources a { display: flex; align-items: center; min-height: 32px; font-size: var(--t-small); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-strong); }
.sources a:hover { text-decoration-color: currentColor; }
.advice { font-size: var(--t-small); margin-top: var(--s-4); }
.feed { margin-top: auto; min-width: 0; }
.feed li { font: var(--display-weight) var(--t-h3)/1.2 var(--font-display); letter-spacing: var(--display-tracking); white-space: nowrap; }

@media (max-width: 1279px) {
  .app { flex: none; }
  #form { overflow: visible; }
}
@media (max-width: 1023px) {
  .app__body { grid-template-columns: minmax(0, 1fr); }
  .inputs { border-right: 0; border-top: 1px solid var(--line); order: 2; }
  /* phones and tablets keep the columns that matter; the CSV holds all of them */
  #table .wide { display: none; }
}
@media (max-width: 639px) {
  .pick { width: 100%; justify-content: space-between; }
  .pick select { width: 200px; }
  .toolbar { gap: var(--s-2); margin-bottom: var(--s-3); }
  .toolbar__actions { margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .intabs { overflow: hidden; padding: 0 var(--s-1); gap: 0; }
  .intabs button { font-size: var(--t-label); padding: 0; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .results { padding: var(--s-4); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric, .metric:nth-child(n+4) { grid-column: auto; }
  .metric:last-child { grid-column: 1 / -1; }
  .rules > div { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: var(--s-2) 0; }
  .sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-1) var(--s-3); }
  .sources a { min-height: 48px; line-height: 1.35; }
  #scenarios .opt { display: none; }
}
/* the full product name shares the phone's top bar with the button and menu */
@media (max-width: 439px) {
  .nav .nav__bar { gap: 8px; }
  .nav .nav__bar .nav__logo { font-size: 15px; white-space: nowrap; }
  .nav .nav__bar .nav__actions .btn { padding-inline: 10px; font-size: 13px; }
}
@media (max-width: 374px) {
  /* no room for logo, button and menu: the hero's button and the menu's Inputs link cover it */
  .nav:not(.is-open) .nav__actions { display: none; }
  .nav .nav__bar > .nav__toggle, .nav:not(.is-open) .nav__bar .nav__actions + .nav__toggle { margin-left: auto; }
  .toolbar__actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar__actions .btn { min-width: 0; padding-inline: var(--s-1); }
}
@media print {
  header.nav, .hero, footer.closing, .toolbar, .inputs, .feed, .plot__action { display: none !important; }
  main > section { height: auto !important; min-height: 0 !important; padding: 12px 0 !important; break-inside: avoid; }
  .wrap { width: 100% !important; height: auto !important; }
  .app { flex: none; border: 0; }
  .app__body { grid-template-columns: 1fr; }
  #table .wide { display: table-cell; }
  #table { font-size: 8px; }
  .ground-inverse { background: #fff; color: var(--p-ink); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
