:root {
    --ink: #182330;
    --muted: #657281;
    --soft: #eef2f5;
    --paper: #ffffff;
    --canvas: #f5f7f8;
    --navy: #103f61;
    --blue: #1679a6;
    --blue-light: #dceef5;
    --gold: #d5a329;
    --red: #a6403a;
    --border: #d9e0e5;
    --shadow: 0 18px 50px rgba(21, 42, 58, 0.09);
    --radius: 5px;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

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

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

.skip-link {
    position: fixed;
    z-index: 100;
    top: 8px;
    left: 8px;
    padding: 10px 14px;
    color: #fff;
    background: var(--navy);
    transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
    border-bottom: 1px solid rgba(255,255,255,.12);
    background: var(--navy);
    color: #fff;
}

.header-inner, .page-shell, .site-footer {
    width: min(1400px, calc(100% - 48px));
    margin-inline: auto;
}

.header-inner {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.7);
    color: #fff;
    font-family: Georgia, serif;
    font-size: 15px;
    letter-spacing: .08em;
}

.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-family: Georgia, serif; font-size: 19px; font-weight: 500; }
.brand-copy small { margin-top: 3px; color: #bcd0dc; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.source-link { color: #d6e4eb; font-size: 13px; text-underline-offset: 4px; }
.source-link:hover { color: #fff; }

.section-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.section-link:hover {
    border-color: rgba(255,255,255,.65);
    background: rgba(255,255,255,.08);
}

.page-shell { padding: 56px 0 72px; }

.intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 50px;
    margin-bottom: 38px;
}

.eyebrow, .step-label, .chart-kicker {
    margin: 0 0 9px;
    color: var(--blue);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.intro h1 {
    max-width: 760px;
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(42px, 5.5vw, 76px);
    font-weight: 400;
    letter-spacing: -.04em;
    line-height: .98;
}

.intro-copy { max-width: 680px; margin: 20px 0 0; color: var(--muted); font-size: 17px; }

.intro-stat {
    min-width: 190px;
    padding-left: 22px;
    border-left: 3px solid var(--gold);
    display: grid;
}
.intro-stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.intro-stat strong { margin-top: 4px; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }

.workspace {
    display: grid;
    grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
    min-height: 690px;
    border: 1px solid var(--border);
    background: var(--paper);
    box-shadow: var(--shadow);
}

.controls {
    padding: 28px;
    border-right: 1px solid var(--border);
    background: #f8fafb;
}

.control-actions, .label-row, .chart-toolbar, .chart-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.control-actions { justify-content: flex-end; margin-bottom: 15px; }

.text-button, .mini-button {
    border: 0;
    padding: 3px;
    background: transparent;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
}
.text-button:hover, .mini-button:hover { text-decoration: underline; text-underline-offset: 3px; }

.field-group { margin-bottom: 22px; }
.field-group.compact { margin-bottom: 20px; }

label {
    display: block;
    margin-bottom: 7px;
    color: #2c3944;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .03em;
}
label span { color: var(--muted); font-weight: 500; }

input, select {
    width: 100%;
    border: 1px solid #cbd4da;
    border-radius: 3px;
    outline: none;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}

input { min-height: 42px; padding: 9px 11px; }
select:not([size]) { min-height: 42px; padding: 8px 34px 8px 11px; }
select[size] { padding: 4px; font-size: 12px; line-height: 1.35; }
select[size] option { padding: 7px 8px; border-radius: 2px; }
select[size] optgroup { padding: 5px 3px; color: var(--muted); font-size: 11px; }

input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22,121,166,.13); }
.search-input { margin-bottom: 6px; }

.field-hint, .cache-note {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.45;
}

.time-period {
    min-width: 0;
    margin: 0 0 22px;
    border: 0;
    padding: 0;
}
.time-period legend {
    margin-bottom: 10px;
    color: #2c3944;
    font-size: 13px;
    font-weight: 750;
    letter-spacing: .03em;
}
.date-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.date-row label { margin: 0; }
.quick-ranges {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 11px;
}
.quick-range-button {
    min-height: 35px;
    border: 1px solid #cbd4da;
    border-radius: 3px;
    padding: 6px 7px;
    background: #fff;
    color: var(--navy);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}
.quick-range-button:hover { border-color: var(--blue); background: #f2f8fb; }
.quick-range-button:focus-visible { outline: 3px solid rgba(22,121,166,.18); outline-offset: 1px; }
.quick-range-button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue); color: #fff; }

.primary-button {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    border-radius: 3px;
    padding: 0 16px;
    background: var(--navy);
    color: #fff;
    font-weight: 750;
    transition: background .15s, transform .15s;
}
.primary-button:hover { background: #0b5279; }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .65; }

.chart-panel { min-width: 0; padding: 32px 34px 24px; }
.chart-toolbar { align-items: flex-start; margin-bottom: 24px; }
.chart-heading { min-width: 0; }
.chart-heading h2 {
    margin: 0;
    font-family: Georgia, serif;
    font-size: clamp(25px, 3vw, 38px);
    font-weight: 400;
    letter-spacing: -.025em;
    line-height: 1.1;
}
.chart-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.download-menu { display: flex; gap: 7px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-button {
    min-width: 48px;
    min-height: 35px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    color: var(--navy);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
}
.toolbar-button:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-light); }
.toolbar-button:disabled { cursor: not-allowed; color: #9ca7ae; background: #f4f6f7; }

.chart-type-toggle { display: flex; gap: 0; }
.chart-type-toggle .toolbar-button { min-width: 38px; padding: 0 9px; }
.chart-type-toggle .toolbar-button:first-child { border-radius: 3px 0 0 3px; }
.chart-type-toggle .toolbar-button:last-child  { border-radius: 0 3px 3px 0; margin-left: -1px; }
.chart-type-btn[aria-pressed="true"] { border-color: var(--navy); background: var(--navy); color: #fff; z-index: 1; }
.chart-type-btn[aria-pressed="true"]:hover { border-color: var(--blue); background: var(--blue); }

.toolbar-button[aria-expanded="true"] {
    border-color: #8f1d2c;
    background: #fff2f3;
    color: #7a1724;
}

.projection-controls {
    margin: -4px 0 20px;
    border: 1px solid #dfb9bd;
    border-left: 4px solid #8f1d2c;
    border-radius: 3px;
    padding: 16px 18px 17px;
    background: #fff8f8;
}

.projection-controls[hidden] { display: none; }

.projection-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 13px;
}

.projection-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.projection-heading .step-label { margin-bottom: 3px; color: #8f1d2c; }
.projection-heading strong { flex-shrink: 0; color: #8f1d2c; font-family: Georgia, serif; font-size: 16px; font-weight: 500; }

.projection-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.projection-fields label { color: #6e252e; }
.projection-fields input { min-height: 38px; border-color: #d6b1b5; background: #fff; }

.projection-track {
    position: relative;
    height: 58px;
    margin: 2px 20px 0 54px;
    touch-action: none;
}

.projection-track[hidden] { display: none; }

.projection-rail {
    position: absolute;
    top: 13px;
    right: 0;
    left: 0;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, #e58b85, #c94d55 60%, #8f1d2c);
}

.projection-handle {
    --handle-color: #c94d55;
    position: absolute;
    z-index: 2;
    top: 4px;
    left: 0;
    width: 19px;
    height: 22px;
    margin-left: -9px;
    border: 2px solid #fff;
    border-radius: 3px 3px 10px 10px;
    padding: 0;
    background: var(--handle-color);
    box-shadow: 0 0 0 1px var(--handle-color), 0 2px 5px rgba(73, 18, 25, .25);
    cursor: ew-resize;
    transform: translateX(0);
}

.projection-handle::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 50%;
    width: 1px;
    height: 8px;
    background: var(--handle-color);
}

.projection-handle span {
    position: absolute;
    top: 32px;
    left: 50%;
    color: var(--handle-color);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
    transform: translateX(-50%);
}

.projection-handle:focus-visible { outline: 3px solid rgba(143, 29, 44, .25); outline-offset: 4px; }
.trend-start-handle { --handle-color: #e07a74; }
.trend-end-handle { --handle-color: #c94d55; }
.project-end-handle { --handle-color: #8f1d2c; }
.trend-start-handle span { left: 0; transform: translateX(0); }
.project-end-handle span { left: 100%; transform: translateX(-100%); }

.chart-wrap { position: relative; height: 500px; min-height: 360px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

.status-message {
    min-height: 42px;
    margin-bottom: 14px;
    display: none;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 9px 12px;
    background: #f8fafb;
    color: var(--muted);
    font-size: 13px;
}
.status-message.visible { display: flex; }
.status-message.error { border-color: #e3b7b3; background: #fff4f3; color: var(--red); }

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid #c8d8e1;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
.status-message.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.chart-footer {
    align-items: flex-start;
    margin-top: 15px;
    padding-top: 13px;
    border-top: 1px solid var(--soft);
    color: var(--muted);
    font-size: 11px;
}
.chart-footer p { margin: 0; }

.method-note { padding: 72px 0 10px; }
.method-note > h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(30px, 4vw, 48px); font-weight: 400; }
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 28px; margin-top: 34px; }
.method-grid article { padding-top: 18px; border-top: 1px solid #cbd4da; }
.method-grid span { color: var(--gold); font-family: Georgia, serif; }
.method-grid h3 { margin: 9px 0 6px; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.method-grid p { margin: 0; color: var(--muted); font-size: 13px; }

.site-footer {
    min-height: 120px;
    padding-top: 28px;
    padding-bottom: 28px;
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 30px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}
.site-footer strong { color: var(--navy); font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.site-footer p { margin: 5px 0 0; }

@media (max-width: 980px) {
    .workspace { grid-template-columns: 290px minmax(0, 1fr); }
    .controls { padding: 23px; }
    .chart-panel { padding: 28px 24px 22px; }
    .chart-wrap { height: 450px; }
    .method-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .header-inner, .page-shell, .site-footer { width: min(100% - 28px, 1400px); }
    .header-inner { align-items: flex-start; padding: 14px 0; }
    .header-links { width: 100%; justify-content: flex-start; }
    .page-shell { padding-top: 38px; }
    .intro { align-items: start; flex-direction: column; gap: 25px; }
    .intro-stat { min-width: 0; }
    .workspace { display: block; }
    .controls { border-right: 0; border-bottom: 1px solid var(--border); }
    .chart-panel { padding: 26px 18px 20px; }
    .chart-toolbar { flex-direction: column; }
    .download-menu { width: 100%; justify-content: stretch; }
    .toolbar-button { flex: 1; }
    .projection-heading { flex-direction: column; gap: 6px; }
    .projection-fields { grid-template-columns: 1fr; }
    .projection-track { margin-left: 32px; margin-right: 12px; }
    .chart-wrap { height: 390px; }
    .method-grid { grid-template-columns: 1fr; gap: 24px; }
    .site-footer { flex-direction: column; }
}

@media (max-width: 420px) {
    .header-inner { min-height: 68px; }
    .brand-copy small { display: none; }
    .intro h1 { font-size: 42px; }
    .chart-wrap { height: 340px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
