:root {
    color-scheme: light;
    --ink: #142537;
    --muted: #546479;
    --brand: #173656;
    --brand-hover: #23496d;
    --wash: #f4f6f8;
    --paper: #fff;
    --line: #dce4ed;
    --soft: #edf2f7;
    --teal: #145e57;
    --red: #a13850;
    --font: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body.analysis-body { margin: 0; background: var(--wash); color: var(--ink); font: 15px/1.5 var(--font); }
.analysis-body a { color: var(--brand); text-underline-offset: .22em; }
button, select, input { font: inherit; }
.analysis-body button { cursor: pointer; }
.analysis-body button:disabled { cursor: default; opacity: .55; }
.analysis-body :focus-visible { outline: 3px solid #1e67a5; outline-offset: 3px; }
.shell { width: min(1420px, 100%); margin: auto; padding-inline: clamp(16px, 4vw, 58px); }
.skip-link { position: absolute; top: -70px; left: 12px; z-index: 20; padding: 12px; background: white; }
.skip-link:focus { top: 10px; }

.analysis-header { position: sticky; top: 0; z-index: 5; background: #12273c; color: #fff; border-bottom: 3px solid #7594ad; }
.header-inner { display: flex; align-items: stretch; gap: clamp(16px, 3vw, 40px); min-height: 66px; }
.analysis-header a { color: #e8f0f8; text-decoration: none; }
.identity { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 20px; font-weight: 700; letter-spacing: -.04em; }
.identity img { width: 33px; height: 33px; border-radius: 6px; object-fit: contain; background: white; }
.analysis-nav { display: flex; gap: 4px; align-items: stretch; flex: 1; }
.analysis-nav a, .methods-link { display: flex; align-items: center; padding: 0 13px; white-space: nowrap; font-size: 14px; font-weight: 600; }
.analysis-nav a[aria-current] { background: #223b56; box-shadow: inset 0 -3px #b5d6f1; color: white; }
.analysis-nav a:hover, .methods-link:hover { background: #223b56; color: white; }

.analysis-masthead { padding: clamp(22px, 4vw, 42px) 0 17px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.analysis-masthead h1 { margin: 0; color: var(--ink); line-height: 1.05; font-size: clamp(2rem, 4vw, 3.35rem); letter-spacing: -.055em; }
.analysis-masthead p { margin: .6rem 0 0; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; border: 1px solid var(--line); border-radius: 5px; padding: 6px 12px; color: var(--brand); background: var(--paper); text-decoration: none; font-size: .82rem; font-weight: 650; white-space: nowrap; }
.button:hover { border-color: #819bb5; background: var(--soft); }
.button.primary { background: var(--brand); color: white; border-color: var(--brand); }
.button.primary:hover { background: var(--brand-hover); }

.filter-panel { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 7px; padding: 13px 15px; background: var(--paper); }
.filter-panel label, .ranking-controls label { display: flex; flex: 1 1 126px; flex-direction: column; gap: 4px; min-width: 0; color: var(--muted); font-size: .74rem; font-weight: 700; }
.filter-panel .wide { flex: 1.7 1 195px; }
.analysis-body select, .analysis-body input { min-width: 0; width: 100%; border: 1px solid #cbd7e4; border-radius: 4px; background: white; padding: 7px 9px; color: var(--ink); min-height: 38px; font-size: .86rem; font-weight: 600; }
.analysis-body select:disabled { color: var(--muted); background: var(--wash); }
.presets { margin: 12px 0 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.presets a { padding: 5px 9px; border: 1px solid #cedaea; border-radius: 4px; background: white; font-size: .82rem; font-weight: 650; text-decoration: none; }
.presets a[aria-current] { background: var(--brand); border-color: var(--brand); color: white; }
.status { margin: 8px 0; min-height: 4px; color: var(--muted); font-size: .84rem; }
.status:empty { margin: 0; }
.status.error, .notice.restriction { background: #fff4e3; padding: 10px 12px; border: 1px solid #f0d7b7; border-radius: 6px; color: #673e16; }
#analysis-result { margin-top: 18px; min-height: 420px; }
#analysis-result[aria-busy="true"] { opacity: .73; }
.results-context { display: grid; gap: 8px; margin-bottom: 12px; }
.notice, .section-note { margin: 0; }
.notice { font-size: .88rem; }
.notice strong { margin-inline-end: .46em; }
.notice a { font-weight: 650; }
.data-notes { color: var(--muted); font-size: .82rem; }
.data-notes > summary { display: list-item; width: fit-content; padding: 8px 0; cursor: pointer; color: var(--brand); font-weight: 650; }
.data-notes[open] { display: grid; gap: 10px; padding: 0 12px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.data-notes p { margin: 4px 0 0; }
.data-note-period strong { color: var(--ink); font-weight: 650; }
.result-summary { margin: 0 0 14px; color: var(--muted); font-size: .84rem; }
.empty { margin: 0; padding: 22px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 5px; }
.scope-actions { display: flex; gap: 9px; flex-wrap: wrap; margin: 12px 0 16px; }

.fact-band { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: white; margin-bottom: 16px; }
.fact { padding: 13px 15px 12px; border-right: 1px solid var(--line); min-width: 0; }
.fact:last-child { border-right: 0; }
.fact span, .fact small { display: block; color: var(--muted); font-size: .75rem; }
.fact strong { display: block; margin: 3px 0 2px; font-size: clamp(.95rem, 1.9vw, 1.46rem); line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fact strong.metric-number { white-space: nowrap; }
.fact.delta strong { font-size: clamp(1rem, 1.9vw, 1.42rem); }
.up { color: var(--teal); }
.down { color: var(--red); }

.panel-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 15px; margin: 15px 0; }
.panel-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 6px; padding: clamp(12px, 2vw, 19px); margin: 15px 0; }
.panel-grid > .panel { margin: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 0 10px; }
.panel h2, .panel summary strong { margin: 0; font-size: 1.13rem; line-height: 1.25; letter-spacing: -.025em; }
.panel h3 { margin: 10px 0 6px; font-size: .94rem; }
.panel .section-note { color: var(--muted); font-size: .8rem; margin: 0 0 12px; }
.panel summary { cursor: pointer; color: var(--brand); font-weight: 680; }
.panel details[open] > summary, details.panel[open] > summary { margin-bottom: 13px; }
.chart-zone { position: relative; min-height: 224px; height: 265px; }
.chart-zone.trend { height: 290px; }
.chart-zone.tall { height: 325px; }
.chart-zone canvas { max-width: 100%; }

.tablescroll { overflow: auto; scrollbar-color: #9caec0 #f0f4f8; }
.analysis-table { width: 100%; border-spacing: 0; font-size: .845rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.analysis-table th, .analysis-table td { text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); padding: 8px 9px; }
.analysis-table th:first-child, .analysis-table td:first-child { text-align: left; }
.analysis-table thead th { font-size: .735rem; color: var(--muted); background: #f1f5f8; }
.analysis-table tbody tr:hover td, .analysis-table tbody tr:hover th { background: #f4f7fb; }
.analysis-table tbody th { font-weight: 650; }
.analysis-table td a, .analysis-table tbody th a { font-weight: 650; }
.analysis-table .sub { display: block; font-size: .74rem; color: var(--muted); font-weight: 400; }
.analysis-table .series-mark { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 2px; }
.analysis-table.heatmap th, .analysis-table.heatmap td { text-align: center; }
.analysis-table.heatmap th:first-child { text-align: left; }
.analysis-table .not-reported { color: #5e7085; background: #eef2f7; }
.analysis-table .barcell { min-width: 130px; }
.tablebar { display: block; margin-top: 4px; margin-left: auto; height: 3px; background: var(--brand); border-radius: 2px; }
.analysis-table a:hover { color: #285b8b; }

.ranking-controls { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 0 12px; align-items: end; }
.ranking-controls label { flex: 1 1 140px; }
.ranking-controls .search { flex: 1.7 1 160px; }
.rank-actions { display: flex; gap: 6px; align-items: center; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--muted); font-size: .83rem; }
.pager > div { display: inline-flex; gap: 7px; }
#ranking-panel, .pair-maps { scroll-margin-top: 115px; }
.map-compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.comparison-map { height: clamp(230px, 31vw, 360px); background: #eef2f6; border: 1px solid #c5d4e2; border-radius: 5px; overflow: hidden; }
.map-attribution { color: var(--muted); font-size: .76rem; }
.map-legend { display: flex; align-items: center; gap: 7px 13px; flex-wrap: wrap; margin: 10px 0; font-size: .78rem; }
.map-legend span { display: flex; align-items: center; gap: 4px; }
.map-legend i { display: inline-block; width: .7rem; height: .7rem; border: 1px solid #40536d38; }
.map-selected { display: block; min-height: 25px; margin-top: 8px; }
.analysis-footer { margin-top: 28px; color: var(--muted); border-top: 1px solid var(--line); font-size: .83rem; background: #ebf0f5; }
.analysis-footer .shell { display: flex; flex-wrap: wrap; align-items: center; min-height: 60px; gap: 10px 18px; }
.analysis-footer a { margin-left: auto; }

@media (max-width: 920px) {
    .header-inner { flex-wrap: wrap; gap: 0; }
    .identity { min-height: 51px; }
    .methods-link { margin-left: auto; }
    .analysis-nav { order: 3; flex: 0 0 100%; overflow-x: auto; scrollbar-width: thin; min-height: 42px; }
}

@media (max-width: 650px) {
    .analysis-nav { gap: 1px; }
    .analysis-nav a { padding: 0 6px; font-size: .75rem; }
    .analysis-masthead { align-items: start; }
    .analysis-masthead p { font-size: .82rem; overflow-wrap: anywhere; }
    .analysis-masthead .button { font-size: .72rem; padding-inline: 8px; }
    .filter-panel { gap: 8px; padding: 10px; }
    .filter-panel label, .ranking-controls label { flex-basis: calc(50% - 8px); }
    .filter-panel .wide { flex-basis: calc(50% - 8px); }
    .analysis-body select, .analysis-body input { font-size: 16px; }
    .fact-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .fact { border-bottom: 1px solid var(--line); padding: 10px; }
    .fact:last-child { grid-column: 1 / -1; border-bottom: 0; }
    .panel-grid, .panel-grid.equal, .map-compare-grid { grid-template-columns: minmax(0, 1fr); }
    .chart-zone { height: 250px; }
    .panel-head { flex-wrap: wrap; }
    .analysis-footer a { margin-left: 0; }
}
