:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --paper: #ffffff;
  --paper-soft: #fbfcf8;
  --ink: #1d211c;
  --muted: #657063;
  --line: #d9ded5;
  --grid: #e6eae2;
  --green: #167c62;
  --green-soft: #dcefe8;
  --red: #e62020;
  --red-soft: #fee2df;
  --gold: #b0791c;
  --black: #151515;
  --shadow: 0 18px 48px rgba(29, 33, 28, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

html {
  scroll-behavior: smooth;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  padding: 30px clamp(18px, 3vw, 42px) 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-bottom: 14px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 760;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(29, 33, 28, 0.05);
}

.back-link:hover {
  border-color: rgba(22, 124, 98, 0.45);
  background: var(--green-soft);
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 1080px;
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.4vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: 18px;
  align-items: start;
  padding: 24px clamp(18px, 3vw, 42px) 42px;
}

.dashboard-content {
  min-width: 0;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: min(430px, 100%);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.summary-band {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.summary-intro-grid {
  display: grid;
  grid-template-columns: minmax(170px, 0.34fr) minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: stretch;
}

.summary-stat-stack {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.summary-copy,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.summary-copy {
  padding: 20px;
}

.parameter-card {
  background: linear-gradient(180deg, #fff 0%, var(--paper-soft) 100%);
}

.summary-copy p:last-child {
  margin-bottom: 0;
  color: #354034;
  font-size: 1rem;
  line-height: 1.58;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-height: 112px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-count,
.card-drawdown {
  min-height: 112px;
}

.summary-stat-stack .stat-card {
  min-height: 0;
}

.summary-stat-stack .stat-value {
  font-size: clamp(1.28rem, 1.75vw, 1.76rem);
}

.summary-stat-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  min-width: 0;
}

.summary-stat-controls h2 {
  margin: 0;
}

.summary-stat-controls .segmented-control {
  margin-bottom: 1px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 720;
  line-height: 1.25;
}

.stat-value {
  margin-top: 10px;
  color: var(--ink);
  font-size: clamp(1.14rem, 1.42vw, 1.54rem);
  font-weight: 820;
  line-height: 1.05;
  letter-spacing: 0;
}

.value-positive {
  color: var(--green);
}

.value-negative {
  color: #b3261e;
}

.value-zero {
  color: var(--ink);
}

.stat-value-benchmark {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px rgba(22, 124, 98, 0.2);
}

.stat-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  overflow: hidden;
  scroll-margin-top: 18px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.summary-band {
  scroll-margin-top: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 18px 0;
}

.panel-heading {
  flex: 1 1 auto;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.panel-heading .section-kicker {
  margin-bottom: -1px;
}

.panel-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.share-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  white-space: nowrap;
  min-height: 26px;
  padding: 5px 9px;
  border: 1px solid rgba(22, 124, 98, 0.26);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--green);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 780;
  line-height: 1;
  cursor: pointer;
}

.share-button:hover,
.share-button:focus-visible {
  border-color: rgba(22, 124, 98, 0.48);
  background: var(--green-soft);
  outline: none;
}

.share-button.is-copied {
  border-color: rgba(22, 124, 98, 0.38);
  background: var(--green);
  color: #fff;
}

.share-button.is-error {
  border-color: rgba(179, 38, 30, 0.35);
  background: var(--red-soft);
  color: #8b1a16;
}

.segmented-control {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
}

.segmented-button {
  min-height: 24px;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 780;
  line-height: 1;
  cursor: pointer;
}

.segmented-button:hover,
.segmented-button:focus-visible {
  color: var(--green);
  outline: none;
}

.segmented-button.is-active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 10px rgba(22, 124, 98, 0.18);
}

.toc-panel {
  position: sticky;
  top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 36px rgba(29, 33, 28, 0.07);
}

.toc-kicker {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toc-nav {
  display: grid;
  gap: 3px;
}

.toc-nav a {
  display: block;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 690;
  line-height: 1.2;
  text-decoration: none;
}

.toc-nav a:hover,
.toc-nav a:focus-visible {
  background: var(--green-soft);
  color: var(--green);
  outline: none;
}

.signal-select-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.signal-select {
  min-height: 30px;
  max-width: 210px;
  padding: 5px 26px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 720;
}

.signal-select:hover,
.signal-select:focus-visible {
  border-color: rgba(22, 124, 98, 0.45);
  outline: none;
}

.help-button {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-soft);
  color: var(--green);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
}

.help-button:hover,
.help-button:focus-visible {
  border-color: rgba(22, 124, 98, 0.45);
  background: var(--green-soft);
  outline: none;
}

.chart {
  width: 100%;
  min-height: 320px;
  padding: 8px 12px 16px;
  overflow-x: auto;
}

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

.chart-tall {
  min-height: 430px;
}

.chart-large {
  min-height: 430px;
}

.chart-medium {
  min-height: 330px;
}

.summary-matrix-wrap {
  padding: 16px 18px 18px;
}

.summary-callouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-callout {
  min-height: 82px;
  padding: 2px 12px 2px 14px;
  border-left: 3px solid var(--green);
}

.summary-callout-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: uppercase;
}

.summary-callout-value {
  margin-top: 8px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 840;
  line-height: 1.05;
}

.summary-callout-detail {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

.summary-table-wrap {
  overflow-x: auto;
}

.summary-table {
  min-width: 920px;
}

.summary-table td:first-child {
  min-width: 190px;
}

.summary-signal-row td:first-child {
  color: var(--ink);
  font-weight: 800;
}

.axis,
.axis text,
.axis-label,
.legend text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 620;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.axis-line {
  stroke: #b9c0b4;
  stroke-width: 1;
}

.tooltip {
  position: fixed;
  z-index: 20;
  width: min(320px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 12px 14px;
  border: 1px solid rgba(29, 33, 28, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 34px rgba(29, 33, 28, 0.16);
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.42;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 120ms ease;
}

.tooltip strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
  padding: 12px 18px 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--green);
  color: #fff;
  text-align: center;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

thead th:first-child,
tbody td:first-child {
  text-align: left;
}

th,
td {
  min-width: 92px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

td:first-child {
  min-width: 210px;
  font-weight: 700;
}

.signal-row td:first-child {
  text-align: center;
  font-weight: 500;
}

.stat-row td:first-child {
  font-weight: 800;
}

tr.note-row td {
  color: var(--muted);
  text-align: left;
  white-space: normal;
}

.positive-fill {
  background: #c6efce;
  color: #115c3f;
}

.negative-fill {
  background: #ffc7ce;
  color: #8b1a16;
}

.benchmark-win {
  font-weight: 850;
}

.z-alert {
  color: var(--ink);
}

.page-footer {
  padding: 0 clamp(18px, 3vw, 42px) 42px;
}

.page-footer .back-link {
  margin-bottom: 18px;
}

.disclaimer {
  max-width: 1120px;
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.55;
}

.report-bug-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 10px 14px;
  border: 1px solid rgba(22, 124, 98, 0.28);
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 820;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 16px 34px rgba(29, 33, 28, 0.16);
  cursor: pointer;
}

.report-bug-button:hover,
.report-bug-button:focus-visible {
  background: #105f4b;
  outline: none;
}

@media (max-width: 1180px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    display: none;
  }

  .cards-grid {
    grid-template-columns: repeat(4, minmax(128px, 1fr));
  }

  .summary-callouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1760px) {
  .summary-intro-grid {
    grid-template-columns: minmax(190px, 0.34fr) minmax(300px, 0.9fr) minmax(380px, 0.85fr);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .meta-strip {
    justify-content: flex-start;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(132px, 1fr));
  }

  .summary-callouts {
    grid-template-columns: 1fr;
  }

  .summary-intro-grid {
    grid-template-columns: minmax(132px, 0.56fr) repeat(2, minmax(0, 1fr));
  }

  .summary-stat-stack {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .parameter-card {
    grid-column: auto;
  }

  .panel-actions {
    flex-wrap: wrap;
  }

  .chart {
    padding-left: 4px;
    padding-right: 4px;
  }

  .chart svg {
    min-width: 720px;
  }
}

@media (max-width: 520px) {
  .dashboard-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .summary-stat-stack {
    grid-template-columns: 1fr;
  }

  .summary-intro-grid {
    grid-template-columns: 1fr;
  }

  .parameter-card {
    grid-column: auto;
  }

  th,
  td {
    min-width: 78px;
    padding: 9px 8px;
  }
}
