:root {
    --ink: #18352f;
    --muted: #71817b;
    --green: #267b62;
    --green-dark: #185b49;
    --green-light: #e9f3ee;
    --line: #e3eae5;
    --surface: #ffffff;
    --background: #f5f8f5;
    --warning: #a76b20;
    --warning-bg: #fff4df;
    --danger: #a33e3e;
    --shadow: 0 8px 30px rgba(25, 55, 43, .055);
}

* {
    box-sizing: border-box;
}

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

button, input, select {
    font: inherit;
}

button {
    cursor: pointer;
}

.site-header {
    height: 72px;
    padding: 0 max(5vw, 24px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 17px;
    font-weight: 750;
    text-decoration: none;
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    color: white;
    background: var(--green);
    font-size: 23px;
}

.header-label, .eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .13em;
}

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

.hero {
    padding: 66px 0 42px;
}

.hero h1 {
    margin: 12px 0;
    font-size: clamp(38px, 6vw, 60px);
    line-height: 1.08;
    letter-spacing: -.045em;
    font-weight: 750;
}

.hero-copy {
    max-width: 570px;
    color: var(--muted);
    font-size: 17px;
}

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

.controls {
    padding: 24px;
}

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

h2 {
    margin: 3px 0;
    font-size: 23px;
    letter-spacing: -.025em;
}

.control-heading p, .chart-heading p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.pollutant-tag {
    background: var(--green-light);
    color: var(--green-dark);
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.range-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 22px 0 17px;
}

.range-button {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 15px;
    background: white;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.range-button:hover, .range-button.active {
    background: var(--green-light);
    border-color: #b7d5c5;
    color: var(--green-dark);
}

.date-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 13px;
}

.date-controls label, .city-picker {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

input[type="date"], select {
    min-height: 41px;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 10px;
    background: #fff;
    color: var(--ink);
}

.primary-button {
    min-height: 41px;
    padding: 9px 18px;
    border: 0;
    border-radius: 9px;
    background: var(--green);
    color: white;
    font-weight: 700;
}

.primary-button:hover {
    background: var(--green-dark);
}

.results-section {
    padding: 54px 0 28px;
}

.section-heading {
    margin-bottom: 20px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.ranking-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.city-card {
    padding: 21px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: white;
    box-shadow: var(--shadow);
    min-width: 0;
}

.city-card.ranked {
    border-top: 3px solid var(--green);
}

.city-card.insufficient {
    background: #fbfcfb;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.city-name {
    font-size: 18px;
    font-weight: 750;
}

.rank-label {
    color: var(--green);
    font-size: 12px;
    font-weight: 750;
}

.status-label {
    display: inline-block;
    border-radius: 20px;
    padding: 4px 9px;
    background: var(--warning-bg);
    color: var(--warning);
    font-size: 10px;
    font-weight: 750;
}

.city-value {
    margin: 17px 0 0;
    font-size: 34px;
    font-weight: 750;
    letter-spacing: -.04em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

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

.coverage-track {
    height: 6px;
    overflow: hidden;
    margin: 17px 0 8px;
    border-radius: 10px;
    background: #edf0ed;
}

.coverage-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}

.city-card.insufficient .coverage-fill {
    background: #d49b4d;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
}

.chart-section {
    margin: 30px 0;
    padding: 25px;
}

.chart-heading {
    align-items: end;
}

.city-picker select {
    min-width: 175px;
}

.chart-summary {
    margin-top: 22px;
    font-size: 13px;
    color: var(--muted);
}

.chart-wrap {
    width: 100%;
    margin-top: 15px;
    overflow: hidden;
}

.chart-wrap svg {
    display: block;
    width: 100%;
    height: auto;
}

.chart-legend {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 11px;
    margin-top: 10px;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    background: var(--green);
}

.message {
    padding: 18px;
    color: var(--muted);
    font-size: 13px;
}

.error-message {
    color: var(--danger);
    font-size: 12px;
}

.methodology {
    margin: 30px 0 50px;
    padding: 28px;
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin: 25px 0;
}

.method-number {
    color: var(--green);
    font-size: 12px;
    font-weight: 800;
}

.method-grid h3 {
    margin: 7px 0;
    font-size: 15px;
}

.method-grid p, .method-note {
    color: var(--muted);
    font-size: 13px;
}

.method-note {
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    padding: 23px max(5vw, 24px);
    background: #fff;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.hidden {
    display: none !important;
}

@media (max-width: 760px) {
    .ranking-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .method-grid {
        grid-template-columns: 1fr;
        gap: 13px;
    }

    .hero {
        padding-top: 45px;
    }
}

@media (max-width: 520px) {
    .header-label {
        display: none;
    }

    .container {
        width: min(100% - 28px, 1120px);
    }

    .controls, .chart-section, .methodology {
        padding: 18px;
    }

    .control-heading, .chart-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .ranking-grid {
        grid-template-columns: 1fr;
    }

    .date-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: end;
    }

    .date-controls input {
        width: 100%;
    }

    .date-controls .primary-button {
        grid-column: 1 / -1;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-footer {
        flex-direction: column;
    }
}
