:root {
    color-scheme: dark;
    --bg: #0a0c10;
    --bg-elevated: #12151c;
    --bg-card: #161a22;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #eef1f6;
    --text-muted: #8b93a7;
    --text-dim: #5c6478;
    --accent: #5b9cff;
    --accent-warm: #c4883a;
    --inside: #5b9cff;
    --inside-dash: #b8d9ff;
    --outside: #d4896a;
    --good: #00e400;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    --sensor-time: #b8bfcc;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

canvas {
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

.dashboard {
    max-width: 920px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2.5rem;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 1rem;
}

.aqi-legend {
    display: flex;
    height: 5px;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}

.aqi-legend span { flex: 1; }

.dashboard-title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 650;
    letter-spacing: -0.02em;
}

.dashboard-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.dashboard-section { margin-bottom: 1.1rem; }

.section-heading {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.section-desc {
    margin: 0 0 0.65rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chart-legend {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chart-legend > * + *::before {
    content: "·";
    margin-right: 0.5rem;
    color: var(--text-dim);
}

.chart-legend-desc {
    flex-shrink: 0;
    white-space: nowrap;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.chart-legend-marker {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
}

.chart-legend-marker--inside {
    border-radius: 50%;
    background: var(--inside);
}

.chart-legend-marker--outside {
    border-radius: 2px;
    background: var(--outside);
}

.chart-legend-hint {
    font-size: 0.92em;
    letter-spacing: 0.02em;
}

.chart-legend-item--inside .chart-legend-label,
.chart-legend-item--inside .chart-legend-hint {
    color: var(--inside);
}

.chart-legend-item--outside .chart-legend-label,
.chart-legend-item--outside .chart-legend-hint {
    color: var(--outside);
}

.chart-legend-line {
    width: 21px;
    height: 2px;
    border: none;
    flex-shrink: 0;
}

.chart-legend-line--dashed {
    background: repeating-linear-gradient(
        to right,
        var(--inside) 0 2px,
        transparent 2px 9px
    );
}

.chart-legend-line--solid {
    background: var(--outside);
}

.chart-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.4rem 0.25rem;
}

.chart-wrap {
    position: relative;
    width: 100%;
    min-height: 220px;
}

@media (max-width: 520px) {
    .chart-wrap { min-height: 260px; }
}

.sensor-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 700px) {
    .sensor-grid:not(.sensor-grid--single) {
        flex-direction: row;
        align-items: flex-start;
        flex-wrap: wrap;
    }
    .sensor-grid:not(.sensor-grid--single) .sensor-card {
        flex: 1 1 280px;
        max-width: calc(50% - 0.25rem);
    }
}

.sensor-grid--single {
    max-width: calc(50% - 0.25rem);
    margin: 0 auto;
}

@media (max-width: 699px) {
    .sensor-grid--single { max-width: 100%; }
}

.sensor-card {
    background: #000000;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.65rem;
}

.sensor-card--dotted { border-style: dashed; }
.sensor-card--solid  { border-style: solid; }
.sensor-card--inside { border-color: var(--inside); }
.sensor-card--outside { border-color: var(--outside); }

.sensor-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.sensor-row--meta { margin-bottom: 0.35rem; font-size: 1rem; }

.sensor-row--main {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
}

.sensor-name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sensor-card--inside .sensor-series-marker {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--inside);
    flex-shrink: 0;
}

.sensor-card--outside .sensor-series-marker {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--outside);
    flex-shrink: 0;
}

.sensor-card--inside .sensor-name { color: var(--inside); }
.sensor-card--outside .sensor-name { color: var(--outside); }

.sensor-time { color: var(--sensor-time); white-space: nowrap; }
.sensor-stale { width: 14px; height: 14px; vertical-align: middle; }

.aqi-badge {
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.aqi-level { font-size: 1rem; font-weight: 600; white-space: nowrap; }
.aqi-primary { display: flex; align-items: center; gap: 0.55rem; min-width: 0; width: 100%; }
.sensor-meta-right { display: inline-flex; align-items: center; gap: 0.45rem; flex-shrink: 0; margin-left: auto; }
.sensor-icons { display: inline-flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.sensor-trend img { width: 28px; height: 28px; display: block; }
.sensor-filter { width: 28px; height: 28px; }

.sensor-peak {
    font-size: 1rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sensor-peak strong {
    font-size: inherit;
    font-weight: 700;
}

.sensor-card--empty {
    text-align: center;
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 520px) {
    .sensor-peak { white-space: normal; }
}

.pge-section--empty {
    text-align: center;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.pge-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
}

.pge-card__title { margin: 0 0 0.2rem; font-size: 1rem; font-weight: 600; }
.pge-card__subtitle { margin: 0 0 0.65rem; color: var(--text-muted); font-size: 0.82rem; }

.pge-tier-bar {
    display: flex;
    height: 1.75rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
}

.pge-tier-bar__t1, .pge-tier-bar__t2 {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0a0c10;
}

.pge-tier-bar__t1 { background: #00e5e5; }
.pge-tier-bar__t2 { background: #004444; color: #ccc; }
.pge-tier-bar__t2--over { background: #dc143c; color: #fff; }

.pge-tier-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
}

.pge-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.5rem;
}

.pge-stat {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.55rem;
}

.pge-stat__label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 0.15rem;
}

.pge-stat__value { font-size: 1rem; font-weight: 600; }
.pge-stat__value--export { color: #7dcea0; }
.pge-stat__value--import { color: #f1948a; }
.pge-stat__value--warn { color: #f5b041; }
.pge-stat__value--ok { color: #7dcea0; }

.pge-stat__sub {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.2rem;
    font-size: 0.75rem;
}

.pge-stat__sub img { width: 16px; height: 16px; }

.uv-list,
.uv-section .uv-list,
.uv-section .uv-block {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.uv-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    overflow: hidden;
}

.uv-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.uv-card__title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.uv-card__flag { width: 22px; height: 22px; flex-shrink: 0; }
.uv-card__location { font-weight: 600; font-size: 1rem; }

.uv-card__meta {
    text-align: right;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.uv-card__temp strong { color: var(--text); }
.uv-card__time { display: block; font-size: 0.75rem; color: var(--text-dim); }

.uv-card__night {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-bottom: 0.55rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.uv-card__night-time--end { color: #5b9cff; }
.uv-card__night-time--start { color: #e6c200; }

.uv-weather {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.1rem 0.35rem;
    margin-bottom: 0.55rem;
}

.uv-weather__sun { font-size: 0.72rem; font-weight: 600; white-space: nowrap; padding-bottom: 0.15rem; }
.uv-weather__sun--rise { color: #e6c200; }
.uv-weather__sun--set { color: #5b9cff; }

.uv-weather__axis {
    display: flex;
    flex-direction: column;
    font-size: 0.58rem;
    color: var(--text-dim);
    line-height: 1.15;
    padding-bottom: 0.2rem;
}

.uv-weather__hours {
    display: flex;
    min-width: 0;
    gap: 0.12rem;
    flex-wrap: nowrap;
}

.uv-weather__hour {
    flex: 1 1 0;
    min-width: 1.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.12rem;
}

.uv-weather__hour-num {
    font-size: 0.58rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.uv-weather__hour-temp {
    font-size: 0.62rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.uv-weather__cloud-icon { width: 18px; height: 18px; display: block; flex-shrink: 0; }

@media (max-width: 720px) {
    .uv-weather {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 0.15rem 0.25rem;
    }

    .uv-weather__axis { display: none; }

    .uv-weather__sun { font-size: 0.65rem; }

    body:not(.display-kiosk) .uv-weather__hours {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.2rem;
        padding-bottom: 0.1rem;
    }

    body:not(.display-kiosk) .uv-weather__hours::-webkit-scrollbar { display: none; }

    body:not(.display-kiosk) .uv-weather__hour {
        flex: 0 0 2.35rem;
        flex-shrink: 0;
        width: 2.35rem;
        min-width: 2.35rem;
    }

    body:not(.display-kiosk) .uv-weather__hour-num { font-size: 0.56rem; }
    body:not(.display-kiosk) .uv-weather__hour-temp { font-size: 0.6rem; }
    body:not(.display-kiosk) .uv-weather__cloud-icon { width: 16px; height: 16px; }

    .uv-timeline__time { font-size: 0.52rem; }
    .uv-timeline__level { font-size: 0.55rem; }
    .uv-timeline__icon { width: 16px; height: 16px; }
}

.display-kiosk .uv-card { padding: 0.45rem 0.55rem; }
.display-kiosk .uv-weather { grid-template-columns: auto minmax(0, 1fr) auto; }
.display-kiosk .uv-weather__axis { display: none; }
.display-kiosk .uv-weather__hours {
    overflow-x: hidden;
    gap: 0.15rem;
}
.display-kiosk .uv-weather__hour {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    gap: 0.1rem;
}
.display-kiosk .uv-weather__cloud-icon { width: 16px; height: 16px; }
.display-kiosk .uv-weather__hour-num { font-size: 0.62rem; }
.display-kiosk .uv-weather__hour-temp { font-size: 0.68rem; }
.display-kiosk .uv-weather__sun { font-size: 0.72rem; }
.display-kiosk .uv-timeline { min-height: 2.35rem; }
.display-kiosk .uv-timeline__time { font-size: 0.58rem; }
.display-kiosk .uv-timeline__level { font-size: 0.62rem; }
.display-kiosk .uv-timeline__icon { width: 16px; height: 16px; }

.uv-timeline {
    display: flex;
    width: 100%;
    min-height: 2.75rem;
    border-radius: 8px;
    overflow: hidden;
    align-items: stretch;
}

.uv-timeline__seg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    padding: 0.25rem 0.2rem;
    color: #0a0c10;
    min-width: 0;
}

.uv-timeline__seg--now {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
    z-index: 1;
}

.uv-timeline__icon { width: 18px; height: 18px; flex-shrink: 0; }

.uv-timeline__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    line-height: 1.1;
    min-width: 0;
}

.uv-timeline__label--now { align-items: flex-start; text-align: left; }
.uv-timeline__time { font-size: 0.58rem; font-weight: 600; opacity: 0.9; }
.uv-timeline__level { font-size: 0.62rem; font-weight: 700; white-space: normal; word-break: break-word; }
.uv-timeline__label--now .uv-timeline__level { font-size: 0.64rem; }

.blink_img { animation: blinker 2s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }
.darken-image { filter: brightness(50%); }

.aqi-legend--uv span:nth-child(1) { background: #97D700; }
.aqi-legend--uv span:nth-child(2) { background: #FCE300; }
.aqi-legend--uv span:nth-child(3) { background: #FF8200; }
.aqi-legend--uv span:nth-child(4) { background: #EF3340; }
.aqi-legend--uv span:nth-child(5) { background: #9063CD; }

@media (max-width: 480px) {
    .dashboard { padding: 0.75rem 0.6rem 1.5rem; }
}
