/* Air-quality report. Colours come from theme.css (dark/light); heatmap cells keep the PM2.5 band colours. */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ff); }
button, input, select { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.report-controls, .heatmap-card, #report-error, .report-summary { width: min(1240px, calc(100% - 2rem)); margin-inline: auto; }

.report-controls, .heatmap-card { background: var(--card); border: 1px solid var(--line); border-radius: 1rem; box-shadow: 0 8px 25px var(--shadow); }
.report-controls { margin-top: 1rem; padding: 1rem; }
.control-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.control-actions { display: flex; gap: .5rem; }
.quick-periods, .sort { display: flex; border: 1px solid var(--line-strong); border-radius: .7rem; overflow: hidden; background: var(--card); }
.quick-periods button, .sort button { min-height: 42px; padding: .4rem .9rem; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.quick-periods button + button, .sort button + button { border-left: 1px solid var(--line); }
.quick-periods button:hover, .sort button:hover { background: var(--panel-2); }
.quick-periods button[aria-pressed="true"], .sort button[aria-pressed="true"] { background: var(--head-bg); color: var(--head-ink); font-weight: 700; }
.quick-periods button:focus-visible, .sort button:focus-visible { outline-offset: -3px; }
#report-export, .filters-toggle { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; padding: .45rem .9rem; border: 1px solid var(--line-strong); border-radius: .6rem; background: transparent; color: var(--ink); font-weight: 700; cursor: pointer; }
#report-export:hover, .filters-toggle:hover { background: var(--ink); color: var(--bg); }
.filters-toggle { display: none; }
.filters-toggle::after { content: "▾"; font-weight: 400; }
.filters-toggle[aria-expanded="true"]::after { content: "▴"; }
.filter-fields { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .9rem; }
.filter-fields label { display: grid; gap: .25rem; font-size: .8rem; font-weight: 700; }
.filter-fields select, .filter-fields input { min-height: 42px; border: 1px solid var(--line-strong); border-radius: .55rem; padding: .4rem .55rem; background: var(--field); color: var(--ink); }

#report-error { margin-top: 1rem; color: var(--danger); font-weight: 700; }

.report-summary { margin-block: 1rem; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
.summary-card { background: var(--card); border: 1px solid var(--line); border-radius: .8rem; padding: .85rem 1rem; }
.summary-card small, .heatmap-heading p { display: block; margin: 0; color: var(--ink-2); font-size: .78rem; }
.summary-card small::before { content: ""; display: inline-block; width: .6rem; height: .6rem; margin-right: .4rem; border-radius: 50%; background: var(--c, var(--line-strong)); }
.summary-card strong { display: block; margin-top: .3rem; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.summary-card em { display: block; margin-top: .1rem; font-style: normal; color: var(--ink-2); font-size: .75rem; }

.heatmap-card { margin-bottom: 2rem; padding: 1rem; }
.heatmap-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .85rem; }
.heatmap-heading h2 { margin: 0 0 .15rem; font-size: 1.1rem; }
.heatmap-tools { display: grid; gap: .4rem; justify-items: end; }
.heatmap-tools .sort button { min-height: 36px; font-size: .85rem; }

.report-heatmap-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: .7rem; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.report-heatmap-scroll:focus-visible { outline-offset: 2px; }
#report-heatmap { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: .78rem; }
#report-heatmap th, #report-heatmap td { min-width: 82px; padding: .65rem .5rem; border-right: 1px solid var(--card); border-bottom: 1px solid var(--card); text-align: center; white-space: nowrap; }
#report-heatmap th { background: var(--head-bg); color: var(--head-ink); }
#report-heatmap .station-column { position: sticky; left: 0; z-index: 2; min-width: 260px; max-width: 260px; text-align: left; background: var(--card); color: var(--ink); box-shadow: 3px 0 5px var(--shadow); overflow: hidden; text-overflow: ellipsis; }
#report-heatmap thead .station-column { z-index: 3; background: var(--head-bg); color: var(--head-ink); }
#report-heatmap .station-column a { color: inherit; font-weight: 700; text-decoration: none; }
#report-heatmap .station-column a:hover, #report-heatmap .station-column a:focus-visible { text-decoration: underline; }
.heatmap-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.heatmap-cell.missing { background: var(--panel-2); color: var(--ink-2); font-weight: 400; }
#report-heatmap td.average { background: var(--panel-2); font-weight: 700; }

.report-legend { display: flex; flex-wrap: wrap; gap: .6rem 1rem; margin: 0; padding: .85rem 0 0; list-style: none; font-size: .75rem; color: var(--ink-2); }
.report-legend strong { color: var(--ink); }
.report-legend li { display: flex; align-items: center; gap: .3rem; }
.report-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--c); border: 1px solid var(--line-strong); }
#report-empty { padding: 1rem; color: var(--ink-2); }

@media (max-width: 980px) { .report-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
    .report-controls, .heatmap-card, #report-error, .report-summary { width: calc(100% - 1rem); }
    .report-controls { padding: .75rem; }
    .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .summary-card:first-child { grid-column: span 2; }
    .control-top { align-items: stretch; flex-direction: column; }
    .quick-periods { overflow-x: auto; }
    .quick-periods button { flex: 1; padding-inline: .6rem; }
    .control-actions .filters-toggle { display: inline-flex; flex: 1; }
    #report-export { min-width: 44px; min-height: 44px; padding: .45rem; }
    #report-export .label { display: none; }
    .filters-toggle { min-height: 44px; }
    .report-controls[data-collapsed="true"] .filter-fields { display: none; }
    .filter-fields > * { width: 100%; }
    .heatmap-heading { flex-direction: column; }
    .heatmap-tools { justify-items: start; }
    .report-legend { line-height: 1.5; }
    #report-heatmap .station-column { min-width: 190px; max-width: 190px; }
}

.report-heatmap-scroll.monthly-day-view { overflow-x: hidden; }
.monthly-day-view #report-heatmap { font-size: .68rem; table-layout: fixed; width: 100%; }
.monthly-day-view #report-heatmap th, .monthly-day-view #report-heatmap td { min-width: 0; width: auto; padding: .45rem .1rem; overflow: hidden; }
.monthly-day-view #report-heatmap td.heatmap-cell { font-size: .66rem; }
.monthly-day-view #report-heatmap .station-column { min-width: 190px; max-width: 190px; width: 190px; }
.monthly-day-view #report-heatmap th:last-child, .monthly-day-view #report-heatmap td:last-child { width: 48px; }
@media (max-width: 980px) {
    .report-heatmap-scroll.monthly-day-view { overflow-x: auto; }
    .monthly-day-view #report-heatmap { width: max-content; }
    .monthly-day-view #report-heatmap .station-column { min-width: 170px; max-width: 170px; width: 170px; }
}
@media (max-width: 760px) {
    .monthly-day-view #report-heatmap th, .monthly-day-view #report-heatmap td { min-width: 28px; width: 28px; }
    .monthly-day-view #report-heatmap .station-column { min-width: 170px; max-width: 170px; width: 170px; }
}
.summary-card.is-small strong { font-size: 1rem; line-height: 1.7; }
