:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-soft: #f0f6f8;
  --ink: #10222c;
  --muted: #62727c;
  --line: #d9e3e8;
  --accent: #0f6f76;
  --accent-dark: #0a555c;
  --accent-soft: #e7f4f4;
  --navy: #163b53;
  --success: #1f7a54;
  --warning: #a76712;
  --danger: #a23b3b;
  --shadow: 0 16px 45px rgba(25, 55, 71, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.hero {
  background:
    radial-gradient(circle at 86% 18%, rgba(105, 193, 192, 0.22), transparent 30%),
    linear-gradient(135deg, #102f43 0%, #164d5a 58%, #0c686c 100%);
  color: #fff;
  padding: 58px 20px 62px;
}

.hero__inner { max-width: 1080px; margin: 0 auto; }
.eyebrow { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.15em; opacity: 0.8; margin-bottom: 14px; }
.hero h1 { margin: 0; max-width: 900px; font-size: clamp(2rem, 5vw, 3.65rem); line-height: 1.08; letter-spacing: -0.035em; }
.hero__lead { max-width: 800px; margin: 20px 0 0; font-size: clamp(1rem, 2vw, 1.18rem); color: rgba(255,255,255,.86); }
.hero__badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero__badges span { border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); border-radius: 999px; padding: 7px 12px; font-size: .86rem; }

.container { width: min(1120px, calc(100% - 30px)); margin: -22px auto 54px; position: relative; z-index: 2; }

.notice, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.research-notice { padding: 16px 20px; margin-bottom: 18px; border-left: 5px solid var(--accent); }
.panel { padding: clamp(18px, 4vw, 30px); margin-bottom: 20px; }
.panel__heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 24px; }
.panel__heading > div { display: flex; align-items: center; gap: 12px; }
.panel h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.8rem); letter-spacing: -0.02em; }
.panel h3 { margin: 0 0 14px; font-size: 1.02rem; }
.step { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 auto; border-radius: 12px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; font-size: .82rem; }

.field-group { margin-bottom: 22px; }
.field-label { display: block; font-weight: 750; margin-bottom: 9px; }
.helper { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }

.segmented { display: inline-flex; flex-wrap: wrap; background: #edf3f6; border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 9px 18px; border-radius: 9px; font-weight: 700; color: #52626d; cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--accent-dark); box-shadow: 0 2px 8px rgba(28,55,68,.10); }

.upload-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(250px, .8fr); gap: 16px; }
.drop-zone { min-height: 170px; border: 2px dashed #a9c5cb; border-radius: 16px; background: #f8fbfc; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 26px; text-align: left; transition: .2s ease; cursor: pointer; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone input { display: none; }
.drop-zone strong { display: block; font-size: 1.05rem; }
.drop-zone span { display: block; color: var(--muted); font-size: .9rem; margin-top: 4px; }
.drop-zone__icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--accent); font-size: 1.7rem; font-weight: 300; }

.template-card { padding: 20px; border-radius: 16px; background: #142f3e; color: #fff; display: grid; gap: 7px; align-content: start; }
.template-card__title { color: rgba(255,255,255,.66); text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 800; margin-bottom: 5px; }
.template-card code { background: rgba(255,255,255,.08); border-radius: 7px; padding: 5px 8px; font-size: .82rem; overflow-wrap: anywhere; }

.action-row, .run-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.file-name, .run-message { color: var(--muted); font-size: .9rem; }

.button { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 760; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:active { transform: translateY(1px); }
.button--primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(15,111,118,.2); }
.button--primary:hover { background: var(--accent-dark); }
.button--secondary { background: #e9f0f3; color: var(--navy); }
.button--ghost { background: transparent; color: var(--accent-dark); border: 1px solid #b8ced2; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.status-box { border-radius: 12px; padding: 13px 15px; margin-top: 18px; font-size: .93rem; border: 1px solid var(--line); }
.status-box--neutral { background: #f7fafb; color: var(--muted); }
.status-box--success { background: #ebf7f1; color: #175e42; border-color: #b9e0cf; }
.status-box--warning { background: #fff7e9; color: #875713; border-color: #ead1a4; }
.status-box--danger { background: #fff0f0; color: #8d3333; border-color: #e7bcbc; }

.metric-grid { display: grid; gap: 12px; margin-bottom: 20px; }
.metric-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid--five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric { border: 1px solid var(--line); border-radius: 14px; padding: 15px; background: #fbfdfe; min-width: 0; }
.metric__label { display: block; font-size: .78rem; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.metric__value { display: block; font-size: clamp(1.18rem, 2.4vw, 1.5rem); font-weight: 820; color: var(--navy); overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #e7eef1; white-space: nowrap; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: #65747d; background: #f6f9fa; }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap--compact td:nth-child(2) { font-variant-numeric: tabular-nums; }

.result-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; margin-top: 22px; }
.subpanel { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: #fbfdfe; }
.equation-card { background: linear-gradient(145deg, #143649, #0e5b61); color: #fff; }
.equation { font-family: Georgia, "Times New Roman", serif; text-align: center; font-size: clamp(1rem, 2.4vw, 1.25rem); line-height: 2; padding: 18px 6px; overflow-x: auto; }
.equation__plus { line-height: 1; opacity: .75; }
.equation--small { border-top: 1px solid rgba(255,255,255,.15); padding-top: 12px; }

.chart-card { border: 1px solid var(--line); border-radius: 16px; background: #fff; padding: 14px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: .82rem; color: var(--muted); padding: 4px 4px 12px; }
.chart-legend span { display: flex; align-items: center; gap: 7px; }
.legend-line { width: 22px; height: 3px; border-radius: 999px; background: var(--accent); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; background: #d05b58; }
.chart { width: 100%; min-height: 360px; overflow: hidden; }
.chart svg { width: 100%; height: 360px; display: block; }
.chart text { font-family: inherit; fill: #6c7b84; font-size: 11px; }

.target-card { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); gap: 14px; margin-top: 16px; }
.target-card__field, .target-result { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fbfdfe; }
.target-card__field label { display: block; font-weight: 750; margin-bottom: 8px; }
select { width: 100%; border: 1px solid #bfcfd5; background: #fff; color: var(--ink); border-radius: 10px; padding: 10px 12px; }
.target-result { display: flex; align-items: center; font-size: 1rem; }
.target-result strong { color: var(--accent-dark); font-size: 1.35rem; }

.limitations details { border-radius: 12px; }
.limitations summary { cursor: pointer; font-weight: 800; color: var(--navy); }
.limitations__body { color: var(--muted); }

.hidden { display: none !important; }

footer { text-align: center; color: #75838c; font-size: .84rem; padding: 0 20px 32px; }

@media (max-width: 900px) {
  .metric-grid--five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .hero { padding-top: 42px; }
  .container { width: min(100% - 20px, 1120px); }
  .panel { padding: 18px 15px; }
  .panel__heading { align-items: flex-start; flex-direction: column; }
  .panel__heading > div { align-items: flex-start; }
  .upload-grid, .target-card { grid-template-columns: 1fr; }
  .metric-grid--three, .metric-grid--five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drop-zone { min-height: 145px; }
  .chart { min-height: 310px; }
  .chart svg { height: 310px; }
}

@media (max-width: 430px) {
  .hero h1 { font-size: 2rem; }
  .metric-grid--three, .metric-grid--five { grid-template-columns: 1fr 1fr; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; }
  .segmented span { text-align: center; padding-inline: 10px; }
}

/* =========================================================
   Enhanced charts + independent validation
   ========================================================= */

.chart-card--enhanced {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 8%, rgba(15, 111, 118, 0.07), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #fbfdfe 100%);
}

.chart-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 4px 12px;
}

.chart-heading-row h3 {
  margin: 0 0 3px;
  color: var(--navy);
  font-size: 1rem;
}

.chart-heading-row p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.chart--interactive {
  position: relative;
  min-height: 390px;
}

.chart--interactive svg,
.chart--scatter svg {
  width: 100%;
  height: 390px;
  display: block;
}

.chart--scatter { min-height: 390px; }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 150px;
  max-width: 220px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(16, 34, 44, 0.94);
  color: #fff;
  font-size: .78rem;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(16, 34, 44, .24);
  transform: translate(10px, -50%);
  opacity: 0;
  transition: opacity .08s ease;
}

.chart-tooltip strong { display: block; margin-bottom: 2px; }
.chart-tooltip.is-visible { opacity: 1; }

.legend-line--validation { background: #5069a8; }
.legend-dot--train { background: #0f6f76; }
.legend-dot--test { background: #d05b58; }

.validation-panel { overflow: hidden; }

.validation-explainer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid #cce0e4;
  background: linear-gradient(135deg, #f4fbfb 0%, #f8fbfd 100%);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.validation-explainer__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
}

.validation-explainer p {
  margin: 3px 0 0;
  color: var(--muted);
}

.validation-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, .6fr);
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.validation-control,
.validation-action {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px;
  background: #fbfdfe;
}

.validation-control label {
  display: block;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-row output {
  min-width: 58px;
  text-align: center;
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
}

.validation-action {
  display: flex;
  flex-direction: column;
  gap: 9px;
  justify-content: center;
}

.metric-grid--validation {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 8px;
}

.validation-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
  gap: 16px;
  margin-top: 16px;
}

.validation-table-panel { margin-top: 16px; }

.validation-cutoff-label {
  font-size: 11px;
  font-weight: 800;
  fill: #6d7b86;
}

@media (max-width: 980px) {
  .validation-chart-grid { grid-template-columns: 1fr; }
  .metric-grid--validation { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .chart-heading-row { flex-direction: column; }
  .chart-heading-row .chart-legend { padding-top: 0; }
  .validation-controls { grid-template-columns: 1fr; }
  .metric-grid--validation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart--interactive,
  .chart--scatter { min-height: 330px; }
  .chart--interactive svg,
  .chart--scatter svg { height: 330px; }
}

/* =========================================================
   Workflow + final model + application stage
   ========================================================= */

.panel--compact { padding-block: 16px; }
.workflow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.workflow-chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #edf4f8;
  border: 1px solid #d3e0e7;
  color: var(--navy);
  font-size: .82rem;
  font-weight: 760;
}

.run-row--stackable { align-items: center; }
.panel__heading--tight { margin: 10px 0 14px; }

.final-model-panel,
.application-panel { overflow: hidden; }

.final-model-callout,
.application-intro {
  border: 1px solid #d7e6ea;
  background: linear-gradient(135deg, #f6fbfc 0%, #fdfefe 100%);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.final-model-callout p,
.application-intro p { margin: 0; color: var(--muted); }

.result-grid--single-top {
  align-items: start;
}

.final-state-summary {
  display: grid;
  gap: 12px;
}
.final-state-summary .metric-inline {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  background: #fff;
}
.final-state-summary .metric-inline strong {
  display: block;
  color: var(--navy);
  margin-bottom: 4px;
}
.final-state-summary .metric-inline span {
  color: var(--muted);
  font-size: .92rem;
}

.application-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.application-config-card h3 { color: var(--navy); }
.drop-zone--compact {
  min-height: 132px;
  padding: 20px;
}
.field-group--compact { margin-bottom: 16px; }
.checkbox-row {
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfe;
  padding: 12px 13px;
}
.checkbox-label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  cursor: pointer;
}
.checkbox-label input { margin-top: 4px; }
.checkbox-label span {
  color: var(--ink);
  font-size: .93rem;
}

.panel-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #d6e1e6 14%, #d6e1e6 86%, transparent);
  margin: 8px 0 18px;
}

.legend-line--application { background: #8b5cf6; }
.action-row--tight { margin-top: 12px; }

.application-panel .status-box { margin-top: 12px; }

@media (max-width: 980px) {
  .application-config-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .workflow-strip { gap: 8px; }
  .workflow-chip { width: 100%; text-align: center; }
}
