:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --primary: #1a5276;
    --primary-light: #2980b9;
    --accent: #e74c3c;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --border: #dfe6e9;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 8px;
    --font: 'Sarabun', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a5276 0%, #2980b9 100%);
    color: #fff;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: none;
    width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    width: 52px;
    height: 52px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid rgba(255,255,255,0.4);
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
}

.header-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.meta-label {
    font-size: 0.75rem;
    opacity: 0.8;
}

.meta-value {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Filter bar */
.filter-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    max-width: none;
    width: 100%;
    margin: 0 auto;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.filter-group select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 0.9rem;
    min-width: 180px;
    background: #fff;
}

.filter-checkbox {
    justify-content: flex-end;
}

.filter-checkbox label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}

.filter-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: #e53935;
}

.btn-reset, .btn-refresh {
    padding: 0.45rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset:hover { background: #f8f9fa; }
.btn-refresh {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-refresh:hover { background: var(--primary-light); }

/* Dashboard grid — แผนที่ | สรุป แบ่งครึ่งจอ */
.dashboard {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    overflow: hidden;
}

.panel.full-width { grid-column: 1 / -1; }

.panel-map,
.panel-summary {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.panel-map .map-container,
.panel-summary .daily-chart-wrap {
    flex: 1;
    min-height: 520px;
}

.daily-chart-wrap {
    position: relative;
    width: 100%;
    height: 520px;
}

.chart-note {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chart-note a {
    color: var(--primary);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
    flex-wrap: wrap;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}

.source-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: #f8f9fa;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

/* Map */
.map-container {
    position: relative;
    height: 420px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border);
}

#map {
    width: 100%;
    height: 100%;
}

.map-legend {
    position: absolute;
    bottom: 28px;
    right: 12px;
    left: auto;
    background: rgba(255,255,255,0.95);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    z-index: 1000;
    box-shadow: var(--shadow);
    max-width: 200px;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.15rem 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.hotspot-marker {
    background: transparent;
    border: none;
}

.hotspot-dot {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffeb3b 0%, #ff5722 45%, #b71c1c 100%);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(183,28,28,0.5), 0 2px 6px rgba(0,0,0,0.35);
    animation: hotspot-pulse 1.8s ease-out infinite;
}

.legend-hotspot-dot {
    width: 14px;
    height: 14px;
    animation: none;
    flex-shrink: 0;
}

@keyframes hotspot-pulse {
    0% { box-shadow: 0 0 0 0 rgba(229,57,53,0.55), 0 2px 6px rgba(0,0,0,0.35); }
    70% { box-shadow: 0 0 0 8px rgba(229,57,53,0), 0 2px 6px rgba(0,0,0,0.35); }
    100% { box-shadow: 0 0 0 0 rgba(229,57,53,0), 0 2px 6px rgba(0,0,0,0.35); }
}

.map-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.health-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #fff8e1;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    border-left: 3px solid #ffc107;
}

/* PM2.5 Trend Board — ตามแบบ Data Studio EOC */
.panel-trend {
    padding: 0.75rem 1rem 1rem;
}

.panel-trend .panel-header {
    margin-bottom: 0.5rem;
}

.pm25-board {
    --pm25-province-w: 132px;
    --pm25-gap: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    font-family: var(--font);
}

.pm25-board-district {
    --pm25-province-w: 148px;
}

#panel-district-trend[hidden] {
    display: none !important;
}

.pm25-board-header,
.pm25-row {
    display: grid;
    /* จังหวัด + 6 วันย้อนหลัง + วันนี้ + 3 วันพยากรณ์ — สัดส่วนช่องวันเท่ากัน */
    grid-template-columns: var(--pm25-province-w) 6fr 1fr 3fr;
    gap: var(--pm25-gap);
    align-items: stretch;
}

.pm25-board-header {
    min-height: 56px;
}

.pm25-header-province,
.pm25-header-history,
.pm25-header-today {
    background: linear-gradient(180deg, #1f6b5e 0%, #185549 100%);
    color: #fff;
}

.pm25-header-province {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
}

.pm25-header-history {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
}

.pm25-header-today {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.25rem;
    background: linear-gradient(180deg, #26c6da 0%, #00838f 100%);
    border: 3px solid #ffee58;
    border-bottom: none;
    z-index: 2;
    box-sizing: border-box;
}

.pm25-clock {
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.pm25-title-main {
    font-size: 1.2rem;
    font-weight: 700;
    color: #d4e157;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    text-align: center;
    line-height: 1.2;
    padding: 0 0.35rem;
}

.pm25-title-main sub,
.pm25-title-forecast sub {
    font-size: 0.72em;
}

.pm25-today-badge {
    position: relative;
    background: linear-gradient(180deg, #fff59d 0%, #ffee58 45%, #fbc02d 100%);
    color: #bf360c;
    font-weight: 900;
    font-size: 0.95rem;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
    box-shadow:
        0 0 0 2px rgba(255,255,255,0.85),
        0 0 14px rgba(255,235,59,0.95),
        0 3px 8px rgba(0,0,0,0.25);
    letter-spacing: 1px;
    white-space: nowrap;
    animation: today-badge-pulse 1.8s ease-in-out infinite;
}

.pm25-today-badge::before,
.pm25-today-badge::after {
    content: '✦';
    position: absolute;
    top: -7px;
    color: #ff1744;
    font-size: 0.65rem;
    text-shadow: 0 0 4px rgba(255,23,68,0.8);
}

.pm25-today-badge::before { left: 3px; }
.pm25-today-badge::after { right: 3px; }

@keyframes today-badge-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.06); filter: brightness(1.08); }
}

.pm25-header-forecast {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.5rem;
    background: linear-gradient(180deg, #e91e8c 0%, #c2185b 100%);
    color: #fff;
}

.pm25-title-forecast {
    font-size: 1.05rem;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.25);
    text-align: center;
    line-height: 1.2;
}

.pm25-board-body {
    background: #fff;
    padding: 0;
}

.pm25-row-head {
    background: linear-gradient(180deg, #1f6b5e 0%, #185549 100%);
}

.pm25-row-head .pm25-province {
    background: transparent;
}

.pm25-row-head .pm25-province-label {
    justify-content: center;
    color: #d4e157;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.pm25-row-head .pm25-date {
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 0.95rem;
    padding: 0.35rem 0.1rem;
}

.pm25-row-head .pm25-date-today {
    background: linear-gradient(180deg, #4dd0e1 0%, #26c6da 100%);
    color: #004d40;
    font-weight: 800;
    font-size: 1rem;
}

.pm25-row-head .pm25-group-today {
    background: #b2ebf2;
    border-top: 3px solid #ffee58;
}

.pm25-row-head .pm25-date-forecast {
    background: #f48fb1;
    color: #880e4f;
    font-weight: 700;
}

.pm25-row-head .pm25-group-forecast {
    background: #fce4ec;
}

.pm25-province {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.5rem;
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
    background: linear-gradient(180deg, #1f6b5e 0%, #185549 100%);
    min-height: 46px;
    text-align: center;
    line-height: 1.25;
}

.pm25-group {
    display: grid;
    gap: 0;
    padding: 0;
    min-width: 0;
}

.pm25-group-past {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.pm25-group-today {
    grid-template-columns: minmax(0, 1fr);
    background: #e0f7fa;
    border-left: 3px solid #ffee58;
    border-right: 3px solid #ffee58;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.pm25-board-body .pm25-row:last-of-type .pm25-group-today {
    border-bottom: 3px solid #ffee58;
}

.pm25-group-today .pm25-cell {
    min-height: 50px;
    font-size: 1.15rem;
    font-weight: 800;
    border-right: none;
    box-shadow: none;
}

.pm25-group-forecast {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: #fff5f8;
}

.pm25-date {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #444;
    padding: 0.35rem 0.1rem;
    line-height: 1.25;
    white-space: normal;
    overflow: hidden;
    min-width: 0;
    min-height: 46px;
    hyphens: auto;
}

.pm25-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    border-right: 1px solid rgba(0,0,0,0.06);
    min-width: 0;
}

.pm25-group-forecast .pm25-cell:last-child,
.pm25-group-past .pm25-cell:nth-child(6),
.pm25-group-today .pm25-cell {
    border-right: none;
}

.pm25-cell-forecast {
    font-size: 1rem;
}

.pm25-cell:hover {
    filter: brightness(1.05);
    z-index: 1;
}

.pm25-board-footer {
    font-size: 0.75rem;
    color: #78909c;
    text-align: right;
    padding: 0.4rem 0.75rem;
    background: #eceff1;
}

.pm25-forecast-note {
    color: #e65100;
    font-style: italic;
}

.trend-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

@media (max-width: 1100px) {
    .pm25-board {
        overflow-x: auto;
    }
    .pm25-board-header,
    .pm25-row {
        min-width: 900px;
    }
}

/* Level cards */
.level-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.level-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: #f8f9fa;
    border-left: 4px solid;
}

.level-card .count {
    font-size: 1.4rem;
    font-weight: 700;
    min-width: 2rem;
}

.level-card .label {
    font-size: 0.85rem;
    flex: 1;
}

.level-card .sublabel {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.top10-chart {
    height: 280px;
    position: relative;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    position: sticky;
    top: 0;
    background: var(--primary);
    color: #fff;
    z-index: 1;
}

th, td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover { background: #f0f7ff; }

.pm25-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
    color: #333;
}

.pheoc-open {
    color: #e74c3c;
    font-weight: 600;
    font-size: 0.8rem;
}

.pheoc-closed {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.kpi-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.kpi-value.danger { color: var(--accent); }
.kpi-value.success { color: #27ae60; }

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Measures */
.measures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.measure-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    border-top: 4px solid var(--primary);
}

.measure-card h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.measure-card .title {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.measure-progress {
    background: #ecf0f1;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.measure-progress-bar {
    height: 100%;
    background: var(--primary-light);
    border-radius: 4px;
    transition: width 0.5s;
}

.measure-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.measure-status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.status-active { background: #d5f5e3; color: #1e8449; }
.status-watch { background: #fdebd0; color: #b7950b; }
.status-ready { background: #ebf5fb; color: #2980b9; }

/* Health */
.health-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.health-kpi {
    text-align: center;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.health-kpi .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.health-kpi .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.proactive-total {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #1a5276, #2980b9);
    color: #fff;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.proactive-total .number {
    font-size: 2.2rem;
    font-weight: 700;
}

.proactive-activities {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.85rem;
}

/* Footer & Policy Section */
.policy-section {
    background: linear-gradient(180deg, #1a5c52 0%, #144a42 100%);
    padding: 1.5rem 1rem 1.75rem;
    width: 100%;
}

/* Disease + PM2.5 charts */
.panel-disease {
    grid-column: 1 / -1;
}

.disease-note {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.disease-chart-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.75rem;
}

.disease-chart-card {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.55rem 0.4rem;
    min-width: 0;
}

.disease-chart-title {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
}

.disease-chart-sub {
    margin: 0.15rem 0 0.35rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.disease-chart-wrap {
    position: relative;
    height: 260px;
}

@media (max-width: 1400px) {
    .disease-chart-grid {
        grid-template-columns: repeat(5, minmax(180px, 1fr));
        overflow-x: auto;
    }
}

@media (max-width: 900px) {
    .disease-chart-grid {
        grid-template-columns: 1fr;
    }
    .disease-chart-wrap {
        height: 240px;
    }
}

/* Population summary */
.panel-population {
    grid-column: 1 / -1;
}

.panel-population .population-wrap {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
}

.population-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.9rem;
    background: #fff;
}

.population-table col.col-province { width: 14%; }
.population-table col.col-num { width: 10.5%; }
.population-table col.col-date { width: 12%; }

.population-table thead {
    position: static !important;
}

.population-table th,
.population-table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.population-table thead th {
    background: linear-gradient(180deg, #1f6b5e 0%, #185549 100%);
    color: #fff !important;
    font-weight: 600;
}

.population-table thead th:nth-child(1),
.population-table tbody td:nth-child(1),
.population-table tfoot th:nth-child(1) {
    text-align: left;
}

.population-table thead th:nth-child(n+2):nth-child(-n+8),
.population-table tbody td:nth-child(n+2):nth-child(-n+8),
.population-table tfoot th:nth-child(n+2):nth-child(-n+8) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.population-table thead th:nth-child(9),
.population-table tbody td:nth-child(9),
.population-table tfoot th:nth-child(9) {
    text-align: center;
}

.population-table tbody td.num-total {
    font-weight: 700;
    color: #185549;
}

.population-table tbody tr:hover {
    background: #f1f8f6;
}

.population-table tfoot th {
    background: #e8f5f1;
    color: #185549;
    font-weight: 700;
    border-top: 2px solid #1f6b5e;
}

.population-table tbody td.trend-loading {
    text-align: center !important;
    white-space: normal;
}

.panel-policy {
    padding: 0;
    overflow: hidden;
    border: none;
    box-shadow: none;
    background: transparent;
}

.policy-section-inline {
    border-radius: 0;
}

.policy-title {
    text-align: center;
    color: #d4e157;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.policy-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: none;
    margin: 0;
    align-items: stretch;
}

.policy-card {
    background: #fff;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 2px dotted rgba(255,255,255,0.6);
    display: flex;
    flex-direction: column;
}

.policy-card h3 {
    margin: 0;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1565c0;
    background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 100%);
    text-align: center;
    border-bottom: 1px solid #90caf9;
}

.policy-card ol {
    margin: 0;
    padding: 0.85rem 0.85rem 0.85rem 1.5rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #333;
    flex: 1;
}

.policy-card li {
    margin-bottom: 0.4rem;
}

.policy-card li:last-child {
    margin-bottom: 0;
}

.policy-card ul {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
    list-style: disc;
}

.policy-card ul li {
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
}

/* Report export header — แบนเนอร์ สคร.3 / กรมควบคุมโรค */
.report-export-header {
    display: none;
    width: 100%;
    overflow: hidden;
    font-family: 'Kanit', 'Sarabun', sans-serif;
}

.report-export-header[hidden] {
    display: none !important;
}

.report-export-header:not([hidden]) {
    display: block;
}

.report-banner {
    width: 100%;
    background: #fff;
}

.report-banner-main {
    display: grid;
    grid-template-columns: minmax(240px, 1.05fr) minmax(320px, 1.6fr) minmax(180px, 0.85fr);
    align-items: stretch;
    min-height: 168px;
    background:
        radial-gradient(ellipse 55% 90% at 88% 70%, rgba(255, 120, 40, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse 40% 70% at 92% 20%, rgba(60, 70, 80, 0.45) 0%, transparent 50%),
        linear-gradient(105deg, #2fd4d0 0%, #14b8b4 28%, #0a9e9a 55%, #067a78 78%, #045e5c 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.report-banner-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 78% 85%, rgba(255, 160, 40, 0.25) 0%, transparent 35%),
        radial-gradient(circle at 95% 10%, rgba(40, 45, 50, 0.35) 0%, transparent 28%);
    pointer-events: none;
}

.report-banner-left,
.report-banner-center,
.report-banner-right {
    position: relative;
    z-index: 1;
}

.report-banner-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.55rem 0.7rem 0.5rem 0.85rem;
}

.report-banner-logos {
    line-height: 0;
    flex-shrink: 0;
}

.report-banner-logos img {
    display: block;
    height: clamp(48px, 6.5vw, 70px);
    width: auto;
    max-width: 100%;
    object-fit: contain;
    object-position: left top;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12));
}

.report-banner-org {
    line-height: 1.22;
    color: #0b3d2e;
}

.report-banner-org-th {
    font-size: clamp(0.7rem, 1.1vw, 0.92rem);
    font-weight: 700;
}

.report-banner-org-en {
    font-size: clamp(0.52rem, 0.8vw, 0.68rem);
    font-weight: 500;
    opacity: 0.88;
    margin-top: 0.05rem;
}

.report-banner-hotline {
    margin-top: 0.15rem;
    font-size: clamp(0.66rem, 1vw, 0.86rem);
    font-weight: 600;
    color: #0a3a6b;
}

.report-banner-hotline strong {
    font-weight: 800;
    letter-spacing: 0.03em;
}

.report-banner-datetime {
    margin-top: auto;
    padding-top: 0.2rem;
    font-size: clamp(0.78rem, 1.25vw, 1.05rem);
    font-weight: 700;
    color: #0a3a6b;
    letter-spacing: 0.01em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.report-banner-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0.5rem 0.4rem;
    line-height: 1.1;
}

.report-banner-title1 {
    font-size: clamp(1rem, 1.9vw, 1.55rem);
    font-weight: 700;
    color: #ffe600;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.25);
}

.report-banner-title2 {
    font-size: clamp(1.35rem, 2.8vw, 2.35rem);
    font-weight: 800;
    color: #ffe600;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px rgba(0, 0, 0, 0.28);
    letter-spacing: 0.01em;
}

.report-banner-title3 {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    gap: 0.35rem 0.55rem;
    margin-top: 0.2rem;
}

.report-banner-case {
    font-size: clamp(1.05rem, 2vw, 1.65rem);
    font-weight: 700;
    color: #ffe600;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.report-banner-pm {
    font-size: clamp(1.55rem, 3.3vw, 2.75rem);
    font-weight: 800;
    color: #111111;
    letter-spacing: 0.01em;
    line-height: 1;
    /* ขอบขาวหนาแบบแบนเนอร์ต้นแบบ — ใช้ text-shadow ให้ html2canvas จับได้ */
    -webkit-text-stroke: 0;
    text-shadow:
        -3px -3px 0 #fff,
         3px -3px 0 #fff,
        -3px  3px 0 #fff,
         3px  3px 0 #fff,
        -3px  0   0 #fff,
         3px  0   0 #fff,
         0   -3px 0 #fff,
         0    3px 0 #fff,
        -2px -2px 0 #fff,
         2px -2px 0 #fff,
        -2px  2px 0 #fff,
         2px  2px 0 #fff,
         0  4px 6px rgba(0, 0, 0, 0.35);
}

.report-banner-pm-sub {
    font-size: 0.72em;
    vertical-align: -0.08em;
    margin-left: 0.05em;
}

.report-banner-zone {
    font-size: clamp(0.95rem, 1.7vw, 1.4rem);
    font-weight: 700;
    color: #ffe600;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.report-banner-right {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    overflow: hidden;
    isolation: isolate;
    position: relative;
}

.report-banner-right::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 28%;
    z-index: 2;
    background: linear-gradient(90deg, rgba(6, 122, 120, 0.95) 0%, rgba(4, 94, 92, 0) 100%);
    pointer-events: none;
}

.report-banner-mascot {
    display: block;
    height: 100%;
    min-height: 168px;
    width: 100%;
    max-width: none;
    object-fit: cover;
    object-position: 72% bottom;
    transform: scale(1.08);
    transform-origin: right bottom;
    filter: drop-shadow(-4px 2px 6px rgba(0, 0, 0, 0.25));
}

.report-banner-detail {
    background: linear-gradient(180deg, #0f5f5c 0%, #0a4745 100%);
    color: #e8fffc;
    padding: 0.55rem 1rem 0.65rem;
    border-top: 2px solid rgba(255, 230, 0, 0.55);
    line-height: 1.35;
}

.report-banner-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    align-items: baseline;
}

.report-banner-detail-row + .report-banner-detail-row {
    margin-top: 0.3rem;
    padding-top: 0.3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.report-banner-detail-item {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.45rem;
    align-items: baseline;
    min-width: 0;
}

.report-banner-detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #9ef0e8;
    white-space: nowrap;
}

.report-banner-detail-label::after {
    content: ':';
}

.report-banner-detail-value {
    font-size: 0.8rem;
    font-weight: 500;
    color: #fff;
}

.report-banner-detail-sources .report-banner-detail-value {
    font-size: 0.74rem;
    opacity: 0.95;
}

@media (max-width: 900px) {
    .report-banner-main {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .report-banner-right {
        justify-content: center;
        max-height: 140px;
    }

    .report-banner-mascot {
        min-height: 120px;
        max-height: 140px;
    }
}

.site-footer-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

.site-footer {
    background: linear-gradient(180deg, #144a42 0%, #0f3d36 100%);
    color: #fff;
    padding: 1.25rem 1.5rem 1.5rem;
}

.site-footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2rem;
    align-items: start;
}

.site-footer-sources h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #fff;
}

.site-footer-sources ol {
    margin: 0 0 0.85rem 1.25rem;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.65;
}

.site-footer-sources a {
    color: #80deea;
    text-decoration: underline;
}

.site-footer-sources a:hover {
    color: #b2ebf2;
}

.site-footer-credit {
    font-size: 0.95rem;
    font-weight: 600;
    color: #d4e157;
    margin: 0.5rem 0 0.25rem;
}

.site-footer-version {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.65);
    margin: 0;
}

.site-footer-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    min-width: 160px;
}

.site-footer-qr {
    background: #fff;
    padding: 4px;
    border-radius: 6px;
}

.site-footer-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.55rem 1rem;
    background: linear-gradient(180deg, #4fc3f7 0%, #29b6f6 100%);
    color: #fff;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: filter 0.15s;
}

.site-footer-btn:hover {
    filter: brightness(1.08);
    color: #fff;
}

.footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.footer a { color: var(--primary-light); }

@media (max-width: 1100px) {
    .policy-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .policy-grid {
        grid-template-columns: 1fr;
    }
    .site-footer-inner {
        grid-template-columns: 1fr;
    }
    .site-footer-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .site-footer-btn {
        width: auto;
        min-width: 140px;
    }
}

@media print {
    .policy-section,
    .site-footer {
        break-inside: avoid;
    }
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Leaflet popup */
.leaflet-popup-content {
    font-family: var(--font);
    font-size: 0.85rem;
    margin: 0.5rem 0.75rem;
}

.popup-pm25 {
    font-size: 1.2rem;
    font-weight: 700;
}

/* ป้ายชื่อจังหวัดบนแผนที่ */
.province-map-label {
    background: transparent;
    border: none;
}

.province-map-label .map-tip {
    font-family: var(--font);
    font-size: 0.78rem;
    line-height: 1.35;
    padding: 0.4rem 0.55rem;
    text-align: center;
    min-width: 88px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    color: #222;
    white-space: nowrap;
}

.province-map-label .map-tip strong {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 0.15rem;
}

.province-map-label .map-tip-pm25 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0.1rem 0;
}

/* Responsive */
@media (max-width: 1100px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .panel-map .map-container,
    .panel-summary .daily-chart-wrap {
        min-height: 320px;
        height: 320px;
    }
}

@media (max-width: 600px) {
    .header-inner { flex-direction: column; align-items: flex-start; }
    .header-meta { text-align: left; }
    .meta-item { text-align: left; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-group select { min-width: 100%; }
}
