:root {
  --bg: #ffffff;
  --bg-alt: #fafafa;
  --bg-accent: #eef2ea;
  --surface: #ffffff;
  --surface-soft: #f8faf6;
  --border: #e4e4e7;
  --text: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --accent-green: #7a9a68;
  --accent-green-light: #98b384;
  --accent-warm: #d4a74a;
  --accent-red: #d97777;
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-soft: 0 8px 30px -22px rgba(24, 24, 27, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 92% -8%, rgba(122, 154, 104, 0.18), transparent 30%),
    radial-gradient(circle at -10% 14%, rgba(152, 179, 132, 0.14), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fcfcfb 100%);
}

.ambient::before,
.ambient::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
  border-radius: 50%;
}

.ambient::before {
  width: 32vmax;
  height: 32vmax;
  top: 14vmax;
  left: -14vmax;
  background: rgba(152, 179, 132, 0.12);
}

.ambient::after {
  width: 34vmax;
  height: 34vmax;
  top: 56vmax;
  right: -15vmax;
  background: rgba(122, 154, 104, 0.1);
}

.page {
  width: min(1200px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.hero {
  padding: clamp(26px, 4vw, 40px);
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-lg) + 4px);
  background: linear-gradient(145deg, #ffffff 0%, #f8faf6 100%);
  box-shadow: var(--shadow-soft);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font: 600 11px/1.2 "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  color: var(--accent-green);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 16px 0 0;
  max-width: 72ch;
  color: var(--text-secondary);
}

.eyebrow-link {
  color: var(--accent-green);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 140ms ease;
}

.eyebrow-link:hover {
  border-bottom-color: var(--accent-green);
}

.hero-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-muted);
  font: 500 12px/1.4 "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

.hero-links {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-secondary);
  font: 500 13px/1.4 "Inter", sans-serif;
  text-decoration: none;
  transition: border-color 140ms ease, color 140ms ease;
}

.hero-link:hover {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.hero-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.hero-link-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

code {
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f4f4f5;
  color: #52525b;
  font: 500 0.9em/1.4 "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

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

.metric-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  cursor: default;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.metric-card[data-tooltip] {
  cursor: help;
}

.metric-card[data-tooltip]:hover,
.metric-card[data-tooltip]:focus-visible,
.metric-card.is-tooltip-active {
  border-color: rgba(122, 154, 104, 0.5);
  box-shadow:
    0 18px 30px -24px rgba(24, 24, 27, 0.52),
    0 0 0 3px rgba(152, 179, 132, 0.18);
  transform: translateY(-1px);
}

.metric-card[data-tooltip]:focus-visible {
  outline: none;
}

.tip {
  position: fixed;
  left: 0;
  top: 0;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(155deg, rgba(39, 39, 42, 0.98), rgba(24, 24, 27, 0.98));
  color: #fafafa;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  border-radius: 10px;
  z-index: 1100;
  pointer-events: none;
  box-shadow: 0 18px 36px -24px rgba(24, 24, 27, 0.9);
  opacity: 0;
  transform: translateY(4px) scale(0.985);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.tip::after {
  content: "";
  position: absolute;
  left: var(--tip-anchor, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
}

.tip[data-placement="top"]::after {
  top: 100%;
  border-top-color: rgba(24, 24, 27, 0.98);
}

.tip[data-placement="bottom"]::after {
  bottom: 100%;
  border-bottom-color: rgba(39, 39, 42, 0.98);
}

.tip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.metric-title {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.metric-value {
  margin: 10px 0 4px;
  font-size: clamp(1.65rem, 3vw, 1.95rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.metric-detail {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.panel,
.insight-panel {
  margin-bottom: 16px;
  padding: clamp(16px, 2.3vw, 22px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.panel {
  background: var(--surface);
}

.insight-panel {
  background: linear-gradient(160deg, #ffffff 0%, var(--surface-soft) 100%);
}

.panel h2,
.insight-panel h2 {
  margin: 0 0 10px;
  font-size: clamp(1.08rem, 2.1vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.panel h3,
.insight-panel h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.panel-intro {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.source-panel {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
}

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

a:hover {
  color: #5f7e4f;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--bg-alt);
}

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

th {
  color: var(--text-secondary);
  font-weight: 600;
}

tbody tr:hover {
  background: #fcfcfc;
}

td code {
  word-break: break-word;
}

.downloads {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.downloads a {
  color: var(--accent-green);
  text-decoration: none;
  border-bottom: 1px solid rgba(122, 154, 104, 0.3);
}

.performance-image {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

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

.chart-panel {
  display: flex;
  flex-direction: column;
}

.chart-panel h2 {
  margin-bottom: 12px;
}

.chart-frame {
  position: relative;
  width: 100%;
  height: clamp(260px, 34vh, 340px);
}

.chart-frame canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.chart-frame.chart-frame-square {
  width: min(100%, 360px);
  height: auto;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.chart-frame.chart-frame-wide {
  height: clamp(460px, 70vh, 720px);
}

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

.grading-modes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.grading-modes-grid .mode-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-green);
  background: #ffffff;
}

.grading-modes-grid .mode-card.accent-coral {
  border-left-color: var(--accent-red);
}

.grading-modes-grid .mode-card.accent-teal {
  border-left-color: var(--accent-green);
}

.grading-modes-grid .mode-card.accent-sun {
  border-left-color: var(--accent-warm);
}

.grading-modes-grid .mode-card h3 {
  margin: 0 0 6px;
}

.grading-modes-grid .mode-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.invariant-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 2px solid rgba(122, 154, 104, 0.5);
  background: rgba(238, 242, 234, 0.65);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.takeaway-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: takeaway;
}

.takeaway-list li {
  position: relative;
  margin: 0;
  padding: 10px 0 10px 34px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  counter-increment: takeaway;
}

.takeaway-list li:last-child {
  border-bottom: none;
}

.takeaway-list li::before {
  content: counter(takeaway);
  position: absolute;
  left: 0;
  top: 11px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

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

.insight-list,
.reporting-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  margin-bottom: 8px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--accent-green);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.insight-list.weaknesses li {
  border-left-color: var(--accent-red);
}

.reporting-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font: 400 14px/1.55 "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

.reporting-list li:last-child {
  border-bottom: none;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sortable-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.sortable-table th[data-sort]::after {
  content: " \2195";
  font-size: 11px;
  opacity: 0.45;
}

.row-perfect {
  background: rgba(152, 179, 132, 0.12);
}

.row-struggling {
  background: rgba(217, 119, 119, 0.1);
}

.cell-zero {
  color: #b45353;
  font-weight: 600;
}

.cell-perfect {
  color: #4f7a41;
  font-weight: 600;
}

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

.rescue-stat {
  text-align: center;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-alt);
}

.rescue-stat .lift-value {
  margin: 4px 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--accent-green);
}

.rescue-stat p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.chart-annotation {
  margin: -4px 0 10px;
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
}

@media (max-width: 1080px) {
  .page {
    width: min(100%, calc(100vw - 32px));
  }

  .source-panel,
  .grading-modes-grid,
  .reporting-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page {
    padding-top: 24px;
    width: min(100%, calc(100vw - 24px));
  }

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

  .charts,
  .sw-grid,
  .rescue-grid {
    grid-template-columns: 1fr;
  }

  .chart-frame {
    height: 250px;
  }

  .chart-frame.chart-frame-wide {
    height: 420px;
  }

  .chart-frame.chart-frame-square {
    width: min(100%, 320px);
  }

  th,
  td {
    padding: 9px;
    font-size: 13px;
  }
}

@media (max-width: 520px) {
  .cards {
    grid-template-columns: 1fr;
  }

  .hero {
    border-radius: var(--radius-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .metric-card,
  .tip {
    transition: none;
  }
}
