:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #101828;
    --muted: #667085;
    --border: #e6e9ee;
    --accent: #2f81f7;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f141c;
    --card: #1a212c;
    --text: #e6e9ee;
    --muted: #94a0b0;
    --border: #2b3543;
    --accent: #4d94ff;
    color-scheme: dark;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    /* Nothing should ever force the page to scroll sideways on a phone. */
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

/* Media never overflows its column. */
img, svg, video { max-width: 100%; }

.app-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: 56px;
    padding: 0 1.25rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-header__brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
}

.app-header__nav {
    display: flex;
    gap: 0.25rem;
}

.app-header__link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
}

.app-header__link:hover { background: var(--bg); color: var(--text); }

.app-header__link.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

.app-header__theme {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}
.app-header__theme:hover { background: var(--bg); }
.app-header__theme::before { content: "🌙"; }
:root[data-theme="dark"] .app-header__theme::before { content: "☀️"; }

.app-header__logout {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    white-space: nowrap;
}
.app-header__logout:hover { background: var(--bg); color: var(--text); }

/* Shown until a dashboard password is configured — an open dashboard should never be a surprise. */
.app-warning {
    background: #fff4e5;
    color: #93370d;
    border-bottom: 1px solid #f5d5a8;
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Phones: the brand + theme button keep the top row, the nav moves to its own row
   underneath and scrolls sideways if the links don't fit, so the page itself never does. */
@media (max-width: 640px) {
    .app-header {
        height: auto;
        flex-wrap: wrap;
        gap: 0.4rem 0.75rem;
        padding: 0.5rem 0.9rem;
    }

    .app-header__brand { font-size: 1rem; }

    .app-header__nav {
        order: 3;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .app-header__nav::-webkit-scrollbar { display: none; }

    .app-header__link {
        white-space: nowrap;
        padding: 0.45rem 0.65rem;
    }
}

/* An SVG scales as a whole, so its axis labels grow and shrink with the container: a viewBox sized
   for a wide screen turns to 7px text on a phone, and a narrow one to oversized text on a desktop.
   Charts that are rendered large therefore ship two variants. Each is capped near its own viewBox
   width and the switch happens where the wide one fits at roughly 1:1, which keeps the rendered
   label size in a narrow band (~10–15px) at every viewport instead of swinging with it. */
.chart-narrow { max-width: 420px; margin-inline: auto; }
.chart-wide { display: none; margin-inline: auto; }
@media (min-width: 961px) {
    .chart-narrow { display: none; }
    .chart-wide { display: block; }
}

/* Shared components (cards, buttons, inputs) used across pages */
.card {
    background: var(--card, #fff);
    border: 1px solid var(--border, #e6e9ee);
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.input {
    border: 1px solid var(--border, #e6e9ee);
    border-radius: 9px;
    padding: 0.5rem 0.7rem;
    font: inherit;
    background: var(--card, #fff);
    color: var(--text, #101828);
}

.btn {
    border: 1px solid var(--border, #e6e9ee);
    background: var(--card, #fff);
    color: var(--text, #101828);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 0.9rem;
    border-radius: 9px;
    cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--bg, #f5f7fa); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent, #2f81f7); border-color: var(--accent, #2f81f7); color: #fff; }
.btn--primary:hover:not(:disabled) { filter: brightness(1.07); background: var(--accent, #2f81f7); }
.btn--ghost { color: var(--muted, #667085); }

/* Weather chart (rendered as a markup string, so these must be global, not scoped) */
.weather-chart { width: 100%; }

.weather-chart__svg {
    width: 100%;
    height: auto;
    display: block;
}

.weather-chart__grid {
    stroke: var(--border, #e6e9ee);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

/* No font-size here on purpose: the SVG carries it (see WeatherChart.AxisFont), so the C# layout
   maths and the rendered text can never drift apart. A class selector would beat that inheritance. */
.weather-chart__axis {
    fill: var(--muted, #8a93a0);
    font-family: inherit;
}

/* Hover crosshair. Positioned by chart-hover.js; hidden until a pointer is over the plot. */
.weather-chart__cursorline {
    stroke: var(--muted, #8a93a0);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.75;
    pointer-events: none;
}
.weather-chart__cursordot {
    stroke: var(--card, #fff);
    stroke-width: 1.5;
    pointer-events: none;
}

/* The readout itself lives on <body>, so it is not clipped by the card and Blazor never touches it. */
.chart-tip {
    position: fixed;
    z-index: 1100; /* above the expanded-chart modal (z-index 1000) */
    pointer-events: none;
    background: var(--card, #fff);
    border: 1px solid var(--border, #e6e9ee);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text, #101828);
    max-width: 15rem;
}
.chart-tip[hidden] { display: none; }
.chart-tip__time {
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--muted, #667085);
    white-space: nowrap;
}
.chart-tip__row { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.chart-tip__swatch {
    width: 12px;
    height: 0;
    border-top: 2px solid var(--sw, #888);
    flex: none;
}
.chart-tip__swatch.is-band {
    height: 8px;
    border-top: none;
    border-radius: 2px;
    background: color-mix(in srgb, var(--sw, #888) 30%, transparent);
}
.chart-tip__label { color: var(--muted, #667085); }
.chart-tip__value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.weather-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem;
    margin-top: 0.35rem;
    padding-left: var(--chart-padl, 46px); /* line up with the plot area (PadL) */
    font-size: 0.78rem;
    color: var(--muted, #667085);
}
.weather-chart__legenditem { display: inline-flex; align-items: center; gap: 0.35rem; }
.weather-chart__swatch {
    width: 14px;
    height: 0;
    border-top: 2px solid var(--sw, #888);
    display: inline-block;
}
.weather-chart__swatch.is-dashed { border-top-style: dashed; }
.weather-chart__swatch.is-band {
    height: 9px;
    border-top: none;
    border-radius: 2px;
    background: color-mix(in srgb, var(--sw, #888) 22%, transparent);
}

.metric-card__actions { margin-left: auto; display: inline-flex; align-items: center; }
.metric-card__toggle {
    display: inline-flex;
    border: 1px solid var(--border, #e6e9ee);
    border-radius: 8px;
    overflow: hidden;
}
.metric-card__toggle button {
    border: 0;
    background: var(--card, #fff);
    color: var(--muted, #667085);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.22rem 0.5rem;
    cursor: pointer;
    line-height: 1.2;
}
.metric-card__toggle button + button { border-left: 1px solid var(--border, #e6e9ee); }
.metric-card__toggle button.is-active { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #b54708; }
.dash__modalhead .metric-card__toggle { margin-left: auto; }

.weather-chart__empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    color: var(--muted, #8a93a0);
    font-size: 0.85rem;
    font-style: italic;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor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kuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}