/* ------------------------------------------------------------------
   Tokens
   ------------------------------------------------------------------ */
:root {
  --paper: #fbfaf7;
  --card: #ffffff;
  --ink: #0d2420;
  --ink-2: #2f423d;
  --muted: #4d5c57;
  --faint: #6b7873;
  --line: #e4e1d9;
  --line-soft: #f0eee8;
  --accent: #0f766e;
  --accent-soft: #e6f2ef;
  --amber: #b45309;
  --amber-soft: #fdf3e3;
  --neg: #b91c1c;

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, 'Helvetica Neue', Arial, sans-serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(13, 36, 32, 0.04), 0 6px 18px -12px rgba(13, 36, 32, 0.18);
}

* {
  box-sizing: border-box;
}

:where(a, button, summary, select, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ------------------------------------------------------------------
   Masthead
   ------------------------------------------------------------------ */
.masthead {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 82% -20%, #f2f7f4 0%, rgba(251, 250, 247, 0) 62%),
    var(--paper);
  padding: 54px 0 44px;
}

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 14px;
}

.masthead h1 {
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.08;
  max-width: 26ch;
}

.lede {
  margin-top: 18px;
  max-width: 68ch;
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink-2);
}

/* ------------------------------------------------------------------
   Layout
   ------------------------------------------------------------------ */
.layout {
  display: grid;
  grid-template-columns: 342px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  padding-top: 30px;
  padding-bottom: 56px;
}


.output {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

/* ------------------------------------------------------------------
   Control panel
   ------------------------------------------------------------------ */
.panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px 20px 20px;
  scrollbar-width: thin;
}

.panel-block {
  padding: 17px 0;
  border-bottom: 1px solid var(--line-soft);
}

.panel-block:last-child {
  border-bottom: 0;
}

.panel-block h2 {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.2;
}

/* A small accent bar is enough to separate sections without a heavy band. */
.panel-block h2::before {
  content: '';
  width: 3px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 5px;
  transition: color 0.15s ease;
}

details > summary:hover h2 {
  color: var(--accent);
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary h2 {
  margin-bottom: 0;
}

details > summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.18s ease;
  flex: none;
}

details[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}

details[open] > summary {
  margin-bottom: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font: inherit;
  font-size: 12.5px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  text-align: left;
}

.chip:hover {
  border-color: var(--faint);
  background: #fff;
}

.chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.blurb {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.badge-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}

.path-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 12.5px;
}

.path-list li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line-soft);
  color: var(--muted);
}

.path-list li b {
  color: var(--ink);
  font-weight: 600;
}

.control {
  margin-bottom: 15px;
}

.control:last-child {
  margin-bottom: 0;
}

.control label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.control output {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.hint {
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--faint);
}

.control .hint {
  margin-top: 5px;
}

/* ------------------------------------------------------------------
   Glossary terms and popover
   ------------------------------------------------------------------ */
.term {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  display: inline;
  text-align: inherit;
  line-height: inherit;
  cursor: help;
  border-bottom: 1px dotted var(--accent);
  color: var(--accent);
}

.term:hover {
  border-bottom-style: solid;
}

.term:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.term-pop {
  position: fixed;
  z-index: 100;
  width: min(340px, calc(100vw - 16px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 18px 44px -20px rgba(13, 36, 32, 0.5);
  padding: 13px 14px 11px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
}

.term-pop[hidden] {
  display: none;
}

.term-pop-title {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 5px;
}

.term-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
}

.term-pop-foot a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.term-pop-foot a:hover {
  text-decoration: underline;
}

.term-pop-close {
  font: inherit;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}

.term-pop-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.control.is-disabled {
  opacity: 0.45;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  display: block;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.55);
}

input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}

input[type='range']::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.55);
}

input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.switch {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
  cursor: pointer;
  margin-top: 14px;
}

.switch input {
  margin: 2px 0 0;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  flex: none;
}

.select {
  font: inherit;
  font-size: 12.5px;
  width: 100%;
  margin-top: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost {
  font: inherit;
  font-size: 12.5px;
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  border-radius: 7px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 18px;
  min-width: 0;
}

.card-head {
  margin-bottom: 14px;
}

.card h2 {
  font-size: 19px;
  margin-bottom: 6px;
}

.card h3 {
  font-size: 17px;
  margin-bottom: 4px;
}

.card-head p {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 70ch;
}

.card-note {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.small {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
}

/* ------------------------------------------------------------------
   KPI strip
   ------------------------------------------------------------------ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px 11px;
  box-shadow: var(--shadow);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.kpi:hover {
  border-color: var(--faint);
}

.kpi:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.kpi.is-open {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.kpi-label,
.kpi-value,
.kpi-sub,
.kpi-cmp {
  display: block;
}

/* Push the link to the bottom so a sub-line that wraps does not misalign the row. */
.kpi-more {
  margin-top: auto;
  padding-top: 7px;
  font-size: 9.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--faint);
  transition: color 0.15s ease;
}

.kpi:hover .kpi-more,
.kpi.is-open .kpi-more {
  color: var(--accent);
}

/* KPI breakdown panel */
.kpi-detail {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 18px;
}

.kpi-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-detail h3 {
  font-size: 19px;
  margin-bottom: 6px;
}

.kpi-detail-def {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 76ch;
}

.detail-close {
  font: inherit;
  font-size: 11.5px;
  flex: none;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
}

.detail-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.brk-heading {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
  margin-bottom: 6px;
}

.brk-row {
  border-top: 1px solid var(--line-soft);
  padding: 8px 0;
}

.brk-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
}

.brk-row-head span {
  color: var(--ink-2);
}

.brk-row-head b {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.brk-add {
  color: var(--accent);
}

.brk-sub {
  color: var(--neg);
}

.brk-nil,
.brk-level {
  color: var(--faint);
}

.brk-row p {
  font-size: 11.8px;
  line-height: 1.5;
  color: var(--faint);
  margin-top: 3px;
  max-width: 82ch;
}

.brk-total .brk-row-head {
  font-weight: 700;
}

.brk-total .brk-row-head b {
  color: var(--ink);
  font-size: 14.5px;
}

.kpi-detail-reading {
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--ink-2);
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

@media (max-width: 620px) {
  .kpi-detail {
    padding: 16px 15px 14px;
  }
  .kpi-detail-head {
    flex-direction: column;
    gap: 10px;
  }
}

.kpi-label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

.kpi-value {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.15;
  margin-top: 5px;
  letter-spacing: -0.015em;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

.kpi-cmp {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dotted var(--line-soft);
}

.kpi.down .kpi-value {
  color: var(--amber);
}

/* A one-line steer for people who have just landed on the page. */
.start-hint {
  margin: 0;
  padding: 12px 15px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
}

.compare-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: -4px 0 0 2px;
  min-height: 0;
}

.compare-note .cmp {
  color: var(--accent);
  font-weight: 600;
}

/* ------------------------------------------------------------------
   Insight
   ------------------------------------------------------------------ */
.insight-card {
  border-left: 3px solid var(--accent);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
}

.insight {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-2);
  margin-top: 8px;
}

.insight b {
  color: var(--ink);
}

/* ------------------------------------------------------------------
   Charts
   ------------------------------------------------------------------ */
.chart {
  position: relative;
  width: 100%;
}

.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart-axis-label {
  font-family: var(--sans);
  font-size: 10.5px;
  fill: var(--faint);
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 6px;
  min-height: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.legend-item i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}

.legend-item.is-dashed i {
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.9) 0 2.5px,
    rgba(255, 255, 255, 0) 2.5px 5px
  );
}

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 8px 24px -14px rgba(13, 36, 32, 0.4);
  padding: 7px 9px;
  font-size: 11.5px;
  line-height: 1.5;
  min-width: 120px;
  white-space: nowrap;
}

.tip-head {
  display: block;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 3px;
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.tip-row b {
  margin-left: auto;
  color: var(--ink);
  font-weight: 600;
  padding-left: 10px;
}

.tip-row i {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex: none;
}

/* ------------------------------------------------------------------
   T-accounts
   ------------------------------------------------------------------ */
.scrub {
  margin-bottom: 16px;
}

.acct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 16px;
}

.acct-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 13px 14px 11px;
  background: #fdfdfc;
}

.acct-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.acct-card h4 {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.acct-total {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}

.acct-side {
  margin-bottom: 9px;
}

.acct-side-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  margin-bottom: 4px;
}

.acct-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.acct-row {
  display: grid;
  grid-template-columns: 1fr 44px 46px;
  align-items: center;
  gap: 7px;
  padding: 1.5px 0;
  font-size: 11.8px;
  color: var(--ink-2);
}

.acct-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
}

.acct-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
}

.acct-bar.asset i {
  background: var(--accent);
  opacity: 0.6;
}

.acct-bar.liability i {
  background: var(--amber);
  opacity: 0.55;
}

.acct-value {
  text-align: right;
  font-weight: 600;
  font-size: 11.8px;
}

.acct-row.in-m2 .acct-label {
  color: var(--ink);
  font-weight: 600;
}

.acct-row.in-m2 .acct-bar.asset i {
  background: var(--accent);
  opacity: 1;
}

.m2-tag {
  font-style: normal;
  font-size: 8.5px;
  letter-spacing: 0.05em;
  padding: 1px 3px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  flex: none;
}

.acct-net {
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px dashed var(--line-soft);
  padding-top: 7px;
  margin-top: 3px;
}

.acct-footnote {
  font-size: 11.5px;
  color: var(--faint);
  line-height: 1.5;
  margin-top: 14px;
}

/* ------------------------------------------------------------------
   Prose
   ------------------------------------------------------------------ */
.prose ul {
  margin: 12px 0 0;
  padding-left: 0;
  list-style: none;
}

.prose li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 11px;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--ink-2);
}

.prose li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}

.prose b {
  color: var(--ink);
}

.footnote {
  padding-bottom: 60px;
}

.footnote p {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.6;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  max-width: 90ch;
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */
@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  /* One column: lead with the results. The panel stays first in the document so
     that a stale stylesheet falls back to the two-column layout rather than
     dropping the output into the narrow column. */
  .layout > .output {
    order: -1;
  }
  .panel {
    position: static;
    max-height: none;
  }
  .masthead {
    padding: 38px 0 30px;
  }
}

@media (max-width: 900px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .wrap {
    padding: 0 16px;
  }
  body {
    font-size: 14.5px;
  }
  .card {
    padding: 16px 15px 14px;
  }
  .kpi-value {
    font-size: 21px;
  }
  .lede {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
