:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --ink: #101828;
    --muted: #667085;
    --border: #dfe4ec;
    --accent: #2563eb;
    --positive: #067647;
    --negative: #b42318;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font: 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

.layout {
    width: min(1320px, calc(100% - 40px));
    margin: 0 auto;
}

.page-header {
    padding: 28px 0 24px;
    color: #fff;
    background: linear-gradient(120deg, #101828, #1d2939 58%, #243b68);
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    color: #c7d7fe;
    text-decoration: none;
    font-size: 13px;
}

.back-link:hover { color: #fff; }

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

h1 {
    margin-bottom: 6px;
    font-size: clamp(25px, 3vw, 36px);
    letter-spacing: -0.035em;
}

.page-header p {
    margin-bottom: 4px;
    color: #d0d5dd;
}

.page-header .intro {
    max-width: 780px;
    margin-top: 12px;
    color: #eaecf0;
}

main { padding: 24px 0 48px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(16, 24, 40, 0.04);
}

.controls-card, .data-card { padding: 22px 24px; }

.section-heading, .chart-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.eyebrow {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

h2 {
    margin-bottom: 0;
    font-size: 20px;
    letter-spacing: -.02em;
}

.result-count, .unit {
    color: var(--muted);
    font-size: 12px;
}

.model-selector {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.selector-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    color: #344054;
    font-size: 12px;
}

.selector-heading.profile-heading { margin-top: 16px; }

.text-button {
    padding: 2px 7px;
    color: var(--accent);
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
}

.text-button:hover { text-decoration: underline; }

.model-button {
    min-height: 54px;
    padding: 9px 12px;
    color: #344054;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.model-button:hover { border-color: #98a2b3; }

.model-button.active {
    color: #fff;
    background: var(--model-color);
    border-color: var(--model-color);
    box-shadow: 0 3px 8px rgb(16 24 40 / .18);
}

.profile-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.profile-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    color: #475467;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
}

.profile-button.active {
    color: var(--ink);
    background: #eef4ff;
    border-color: #84adff;
}

.profile-line-sample,
.dash-sample {
    width: 25px;
    height: 0;
    border-top: 3px solid currentColor;
}

.profile-legend {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr);
    gap: 12px 24px;
    margin-top: 14px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.model-config {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.legend-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    min-width: 0;
}

.legend-group > strong {
    width: 100%;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.compact-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475467;
    cursor: default;
    font-size: 11px;
}

.compact-legend-item i:not(.dash-sample),
.table-model i {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
}

.compact-legend-item .dash-sample {
    width: 22px;
    color: #475467;
    border-top-width: 2px;
}

.scale-control,
.metric-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.scale-control { margin-top: 14px; }

.scale-control > span {
    margin-right: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.scale-button,
.metric-button {
    padding: 5px 10px;
    color: #475467;
    background: #f2f4f7;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
}

.scale-button.active,
.metric-button.active {
    color: #fff;
    background: var(--accent);
}

.scale-button:disabled {
    cursor: not-allowed;
    opacity: .42;
}

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

.chart-card { padding: 22px 22px 16px; }

.curve-chart {
    margin-top: 14px;
    overflow-x: auto;
}

.curve-chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    aspect-ratio: 680 / 370;
}

.grid-line {
    stroke: #e4e7ec;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.grid-line.vertical { stroke: #f0f2f5; }
.grid-line.zero-line { stroke: #98a2b3; stroke-width: 1.5; }

.axis-label {
    fill: var(--muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.axis-title {
    fill: #475467;
    font-size: 11px;
    font-weight: 600;
}

.curve-line {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.error-bar {
    stroke-width: 1.5;
    opacity: .65;
    vector-effect: non-scaling-stroke;
}

.curve-point {
    stroke: #fff;
    stroke-width: 1.5;
    cursor: help;
    vector-effect: non-scaling-stroke;
}

.curve-point:focus { outline: none; stroke: var(--ink); stroke-width: 2.5; }

.curve-series { transition: opacity .14s ease; }
.has-highlight .curve-series { opacity: .12; }
.has-highlight .curve-series.highlighted { opacity: 1; }

.empty-state {
    padding: 90px 20px;
    color: var(--muted);
    text-align: center;
}

.data-card { margin-top: 18px; }
.table-scroll { overflow-x: auto; margin-top: 16px; }

table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

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

th {
    background: #f2f4f7;
    font-size: 12px;
}

.scenario-cell { width: 120px; background: #fafbfc; }
.scenario-cell strong, .scenario-cell small { display: block; }
.scenario-cell small { color: var(--muted); }

.table-model {
    min-width: 220px;
    font-size: 12px;
    font-weight: 600;
}

.table-model i {
    display: inline-block;
    margin-right: 7px;
}

.numeric-cell,
.delta-cell {
    text-align: right;
    white-space: nowrap;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.delta-cell { font-weight: 700; }
.positive { color: var(--positive); }
.negative { color: var(--negative); }

.method-note {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 980px) {
    .model-selector { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid { grid-template-columns: 1fr; }
    .profile-legend { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .layout { width: min(100% - 24px, 1320px); }
    .page-header { padding-top: 20px; }
    .controls-card, .data-card, .chart-card { padding: 18px 14px; }
    .model-selector { grid-template-columns: 1fr; }
    .profile-legend { display: grid; }
    .curve-chart { margin-left: -8px; margin-right: -4px; }
    .curve-chart svg { min-width: 540px; }
}
