:root {
  --ink: #172c3a;
  --muted: #667985;
  --line: #d7e2e8;
  --soft: #edf3f6;
  --surface: #ffffff;
  --page: #f4f7f8;
  --blue: #2168ad;
  --blue-dark: #174d82;
  --red: #d9564d;
  --amber: #e6a51f;
  --teal: #369f96;
  --motion-fast: 120ms;
  --motion-ui: 240ms;
  --motion-result: 320ms;
  --ease-clinical: cubic-bezier(.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.site-header, main, footer { width: min(1480px, calc(100% - 48px)); margin-inline: auto; }
.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 48px 0 30px;
}
.eyebrow, .step {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.04em; line-height: 1.05; }
.header-note { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 15px; }

.input-card, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgb(26 55 72 / 4%);
}
.input-card { padding: 25px 28px 28px; }
.section-heading, .results-heading, .card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.section-heading { margin-bottom: 21px; }
.section-heading h2, .results-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.section-heading > p, .results-heading > p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; align-items: end; }
label { display: flex; min-width: 0; flex-direction: column; gap: 7px; color: #4c626f; font-size: 11px; font-weight: 750; }
label small { position: absolute; margin: 2px 0 0 42px; color: #8a9aa3; font-size: 10px; font-weight: 500; }
input, select {
  width: 100%; height: 44px; border: 1px solid #cbd9e0; border-radius: 9px; outline: none;
  background: #fbfcfd; padding: 0 11px; color: var(--ink); font: 650 13px inherit;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}
input:focus, select:focus { border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgb(33 104 173 / 12%); }
button {
  position: relative; height: 44px; overflow: hidden; border: 0; border-radius: 9px; background: var(--blue); padding: 0 15px;
  color: white; cursor: pointer; font: 750 12px inherit; transition: background .18s, transform .18s;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
button::after {
  position: absolute; inset: 0 auto 0 -42%; width: 36%; content: ""; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 24%), transparent);
  transform: translateX(0); opacity: 0;
}
button:hover { background: var(--blue-dark); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .78; cursor: wait; transform: none; }
.is-measuring button::after { opacity: 1; animation: measurement-sweep 720ms ease-in-out infinite; }
button b { font-size: 18px; font-weight: 400; }
.form-error { margin: 16px 0 0; color: #b43931; font-size: 13px; animation: notice-enter var(--motion-ui) var(--ease-clinical) both; }

.results { position: relative; padding: 40px 0 0; }
.results::before {
  position: absolute; top: 31px; right: 0; width: 74px; height: 2px; content: "";
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  transform: scaleX(0); transform-origin: left; opacity: 0;
}
.results.is-calculating::before { opacity: .72; animation: analysis-trace 760ms ease-in-out infinite; }
.results.is-calculating .dashboard-grid { opacity: .76; }
.dashboard-grid { transition: opacity var(--motion-fast) linear; }
.results-heading { margin-bottom: 18px; }
.dashboard-grid { display: grid; grid-template-columns: 1.25fr .82fr .9fr; gap: 14px; }
.card { min-width: 0; padding: 22px 23px; }
.probability-card { grid-column: span 2; }
.card-kicker { margin: 0; color: #506774; font-size: 13px; font-weight: 800; }
.probability-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 9px 0 12px; }
.probability-row strong { color: var(--blue); font-size: clamp(38px, 5vw, 57px); line-height: 1; letter-spacing: -.05em; }
.probability-row span { margin-bottom: 6px; border-radius: 100px; background: var(--soft); padding: 7px 11px; color: #4d6877; font-size: 12px; font-weight: 750; }
.risk-track { position: relative; height: 14px; overflow: visible; background: #e5edf2; }
.risk-track div {
  height: 100%; width: 100%; background: var(--blue); transform: scaleX(0);
  transform-origin: left; transition: transform var(--motion-result) var(--ease-clinical);
}
.risk-track i { position: absolute; top: -6px; bottom: -6px; left: 50%; border-left: 1px dashed #2f4552; }
.track-labels { display: grid; grid-template-columns: 1fr 1fr 1fr; margin-top: 8px; color: var(--muted); font-size: 11px; }
.track-labels span:nth-child(2) { text-align: center; }.track-labels span:last-child { text-align: right; }
.model-note { margin: 17px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.matrix-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 0 12px; }
.matrix-heading strong { color: var(--blue); font-size: 21px; }
.matrix-heading span { color: var(--muted); font-size: 12px; font-weight: 750; }
.matrix-track { height: 13px; overflow: hidden; border-radius: 3px; background: linear-gradient(90deg, #dcefeb, #f6d588 45%, #ef8178 72%, #bd2543); }
.matrix-track div {
  height: 100%; width: 100%; border-right: 3px solid var(--ink); background: rgb(255 255 255 / 35%);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--motion-result) var(--ease-clinical);
}
.matrix-scale { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 10px; }
.matrix-details { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 17px; }
.matrix-details span { border-radius: 100px; background: var(--soft); padding: 6px 9px; color: #4d6877; font-size: 10px; font-weight: 700; }
.class-stack { display: flex; height: 34px; margin: 18px 0; overflow: hidden; border-radius: 4px; background: var(--soft); }
.class-stack div { display: flex; min-width: 0; align-items: center; justify-content: center; color: white; font-size: 10px; font-weight: 800; }
.class-legend { display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 11px; }
.legend-row i, .mini-legend span::before, .group-name::before { display: inline-block; width: 8px; height: 8px; border-radius: 50%; content: ""; }
.legend-row b { font-size: 11px; }
.prediction-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }

.scatter-card { grid-column: span 2; }
.card-title-row h3 { margin: 4px 0 0; font-size: 16px; }
.mini-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 12px; max-width: 390px; color: var(--muted); font-size: 11px; }
.mini-legend span { white-space: nowrap; }.mini-legend span::before { margin-right: 5px; }
.red::before { background: var(--red); }.amber::before { background: var(--amber); }.teal::before { background: var(--teal); }
.canvas-wrap { position: relative; width: 100%; height: 330px; margin-top: 12px; }
canvas { width: 100%; height: 100%; }
.chart-note { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }

.context-card { display: flex; flex-direction: column; }
.percentile-block { margin-top: 28px; }
.percentile-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 9px; font-size: 12px; font-weight: 750; }
.percentile-label span:last-child { color: var(--blue); }
.percentile-track { position: relative; height: 12px; background: #e7eef2; }
.percentile-track::after { position: absolute; inset-block: -4px; left: 50%; border-left: 1px dotted #55707f; content: ""; }
.percentile-track div {
  height: 100%; width: 100%; background: var(--blue); transform: scaleX(0);
  transform-origin: left; transition: transform var(--motion-result) var(--ease-clinical);
}
.percentile-scale { display: flex; justify-content: space-between; margin-top: 7px; color: #71838d; font-size: 10px; }
.range-note { margin: auto 0 0; padding-top: 24px; color: #287a70; font-size: 12px; line-height: 1.5; }
.range-note.outside { color: #b33c34; }

.summary-card { grid-column: 1 / -1; }
.summary-caption { margin: 6px 0 16px; color: var(--muted); font-size: 11px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 9px 6px; color: var(--muted); text-align: left; font-size: 10px; font-weight: 750; }
td { padding: 14px 6px; border-top: 1px solid #edf2f4; vertical-align: middle; }
.group-name { display: flex; align-items: center; gap: 7px; min-width: 120px; }
.group-name::before { flex: 0 0 auto; background: var(--group-color); }
.group-name small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.metric-cell b, .metric-cell small { display: block; }.metric-cell small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.disclaimer { margin: 16px 0 0; border-left: 3px solid #aabac3; padding: 5px 0 5px 12px; color: #586e7a; font-size: 12px; line-height: 1.5; }

footer { display: flex; justify-content: space-between; padding: 28px 0 34px; color: #82929b; font-size: 10px; }

@keyframes measurement-sweep {
  from { transform: translateX(0); }
  to { transform: translateX(400%); }
}
@keyframes analysis-trace {
  0% { transform: translateX(-130%) scaleX(.35); }
  55% { transform: translateX(20%) scaleX(1); }
  100% { transform: translateX(130%) scaleX(.35); }
}
@keyframes notice-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .form-grid { grid-template-columns: repeat(4, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .probability-card { grid-column: auto; }
  .scatter-card { grid-column: span 2; }
}
@media (max-width: 700px) {
  .site-header, main, footer { width: min(100% - 24px, 1480px); }
  .site-header { align-items: flex-start; flex-direction: column; padding-top: 28px; }
  .input-card, .card { border-radius: 12px; padding: 18px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  button { grid-column: span 2; }
  .results { padding-top: 30px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .scatter-card { grid-column: auto; }
  .section-heading, .results-heading { flex-direction: column; gap: 4px; }
  .results-heading > p { margin: 0; }
  .card-title-row { flex-direction: column; }
  .mini-legend { justify-content: flex-start; }
  .canvas-wrap { height: 280px; }
  footer { flex-direction: column; gap: 7px; }
}
@media (max-width: 430px) {
  .form-grid { grid-template-columns: 1fr; }
  button { grid-column: auto; }
  .probability-row { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .is-measuring button::after, .results.is-calculating::before { display: none; }
}
