:root {
    color-scheme: light dark;

    /* Poured concrete for the page, steel for the dark bands, safety yellow
       for anything that should catch the eye. */
    --bg: #e9e7e2;
    --bg-alt: #dddad3;
    --surface: #f6f5f2;
    --border: #c9c5bd;
    --text: #1a1a18;
    --text-muted: #57544e;
    --link: #1a1a18;
    --focus: #2f5f9e;

    --accent: #f5b301;
    --accent-hover: #ffc629;
    --accent-ink: #141413;

    --steel: #262523;
    --steel-deep: #1a1918;
    --steel-text: #eceae5;
    --steel-muted: #aaa69e;
    --steel-border: #3d3b38;

    --status-ok: #1d7a4b;
    --status-warn: #9a5800;
    --status-bad: #b3261e;
    --status-idle: #8a867f;

    /* Fine grain laid over flat colors so they read as cast concrete. */
    --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
    --hazard: repeating-linear-gradient(-45deg, var(--accent) 0 12px, var(--accent-ink) 12px 24px);

    --radius: 2px;
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: Bahnschrift, 'DIN Condensed', 'Avenir Next Condensed', 'Roboto Condensed', 'Arial Narrow', sans-serif-condensed, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', Consolas, monospace;

    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #181816;
        --bg-alt: #1f1e1c;
        --surface: #252421;
        --border: #3a3834;
        --text: #ebe9e4;
        --text-muted: #a5a199;
        --link: #ebe9e4;
        --focus: #f5b301;

        --accent: #f0ad00;
        --accent-hover: #ffc020;

        --status-ok: #4cc38a;
        --status-warn: #e5a443;
        --status-bad: #f2726a;
        --status-idle: #8a867f;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--noise), var(--bg);
}

/* Section targets clear the sticky header when a link jumps to them. */
[id] {
    scroll-margin-top: 120px;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-stretch: condensed;
    line-height: 1.05;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

h1 {
    font-size: clamp(2.5rem, 4vw + 1.25rem, 4.25rem);
}

h2 {
    font-size: clamp(1.875rem, 2vw + 1.125rem, 2.75rem);
}

h3 {
    font-size: 1.3125rem;
}

/* FocusOnNavigate moves focus to the page's h1 for screen readers; no ring needed. */
h1:focus {
    outline: none;
}

p {
    margin: 0;
}

a {
    color: var(--link);
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

button {
    font: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 14px;
    cursor: pointer;
}

button:not(.btn):hover:not(:disabled) {
    border-color: var(--text-muted);
}

button:disabled {
    color: var(--text-muted);
    cursor: default;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* ---- Layout helpers ---------------------------------------------------- */

.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 24px;
}

.section {
    padding-block: clamp(56px, 7vw, 104px);
}

.section-alt {
    background: var(--noise), var(--bg-alt);
}

/* A dark steel band. Its own tokens, so anything inside, components
   included, picks colors that read on it. */
.steel {
    --text: var(--steel-text);
    --text-muted: var(--steel-muted);
    --border: var(--steel-border);
    --link: var(--steel-text);
    --focus: var(--accent);

    color: var(--text);
    background: var(--noise), var(--steel);
}

.hazard {
    height: 10px;
    background: var(--hazard);
}

.section-head {
    max-width: 720px;
    margin-bottom: 48px;
}

.section-head h2 + .lead {
    margin-top: 16px;
}

/* Short label above a heading: "— What we do" */
.eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 700;
    font-stretch: condensed;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.eyebrow::before {
    content: '';
    flex: none;
    width: 32px;
    height: 4px;
    background: var(--accent);
}

.steel .eyebrow {
    color: var(--accent);
}

.lead {
    max-width: 62ch;
    font-size: clamp(1.0625rem, 0.4vw + 1rem, 1.25rem);
    color: var(--text-muted);
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 26px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    font-stretch: condensed;
    line-height: 1.2;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary {
    color: var(--accent-ink);
    background: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-outline {
    color: var(--text);
    border-color: currentColor;
}

.btn-outline:hover {
    color: var(--accent-ink);
    background: var(--accent);
    border-color: var(--accent);
}

.btn-dark {
    color: var(--steel-text);
    background: var(--steel-deep);
}

.btn-dark:hover {
    background: var(--steel);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* ---- Account and admin pages ------------------------------------------- */

/* Two columns, the second narrower; one column on small screens. */
.split {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: start;
    gap: 48px;
}

.stack {
    display: grid;
    gap: 24px;
}

.panel {
    display: grid;
    gap: 20px;
    padding: 32px;
    background: var(--surface);
    border-top: 6px solid var(--accent);
}

.panel h2,
.side-note h2,
.h-small {
    font-size: 1.5rem;
}

.side-note {
    display: grid;
    gap: 12px;
    padding-top: 8px;
    color: var(--text-muted);
}

.side-note h2 {
    color: var(--text);
}

.muted {
    color: var(--text-muted);
}

.form-field {
    display: grid;
    gap: 6px;
}

.form-field label,
.form-label {
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

/* 1.0625rem keeps phones from zooming in when a box is tapped. */
.form-field input {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    font-size: 1.0625rem;
    color: var(--text);
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
}

.form-field input:focus {
    border-color: var(--accent);
}

.form-field input[aria-invalid='true'] {
    border-color: var(--status-bad);
}

.form-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.validation-message {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--status-bad);
}

.choices {
    display: grid;
    gap: 14px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.choices legend {
    margin-bottom: 4px;
}

.form-check {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-weight: 600;
    cursor: pointer;
}

.form-check input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--accent);
}

.form-check:has(input:disabled) {
    cursor: default;
}

.form-check small {
    display: block;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
}

.alert {
    padding: 12px 16px;
    font-weight: 600;
    background: var(--bg);
    border-left: 4px solid var(--status-bad);
}

.alert-ok {
    border-left-color: var(--status-ok);
}

/* A password shown once: large, and selected whole with one click. */
.secret {
    display: inline-block;
    padding: 10px 16px;
    font-size: 1.375rem;
    letter-spacing: 0.06em;
    background: var(--bg);
    border: 2px dashed var(--border);
    user-select: all;
}

.role-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.role-list li {
    display: grid;
    gap: 2px;
    padding: 14px 18px;
    background: var(--surface);
    border-left: 4px solid var(--accent);
}

.role-list span {
    color: var(--text-muted);
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.data-table th {
    padding: 12px 18px;
    font-family: var(--font-display);
    font-size: 0.8125rem;
    font-weight: 700;
    font-stretch: condensed;
    letter-spacing: 0.16em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.tag {
    display: inline-block;
    padding: 1px 8px;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    font-stretch: condensed;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    vertical-align: 0.15em;
    white-space: nowrap;
    color: var(--status-ok);
    border: 1px solid currentColor;
}

.tag[data-access='LockedOut'] {
    color: var(--status-warn);
}

.tag[data-access='TurnedOff'] {
    color: var(--status-bad);
}

.steel .tag {
    color: #4cc38a;
}

.steel .tag[data-access='LockedOut'] {
    color: #e5a443;
}

.steel .tag[data-access='TurnedOff'] {
    color: #f2726a;
}

@media (max-width: 860px) {
    .split {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

@media (max-width: 600px) {
    .panel {
        padding: 24px 20px;
    }
}

/* ---- Status ------------------------------------------------------------ */

/* Status colors, shared by the status page's badge and panel. */
[data-status='Healthy'] {
    --status-color: var(--status-ok);
}

[data-status='Degraded'] {
    --status-color: var(--status-warn);
}

[data-status='Unhealthy'],
[data-status='Unreachable'] {
    --status-color: var(--status-bad);
}

.steel [data-status='Healthy'] {
    --status-color: #4cc38a;
}

.steel [data-status='Degraded'] {
    --status-color: #e5a443;
}

.steel [data-status='Unhealthy'],
.steel [data-status='Unreachable'] {
    --status-color: #f2726a;
}

/* Blazor's bar for unhandled errors, hidden until one happens. */
#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 10px 48px 12px 20px;
    color: var(--text);
    background: var(--surface);
    border-top: 3px solid var(--status-bad);
    box-shadow: 0 -2px 8px rgb(0 0 0 / 0.15);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 8px;
    right: 16px;
    cursor: pointer;
}

.blazor-error-boundary {
    padding: 16px 20px;
    color: #ffffff;
    background: var(--status-bad);
    border-radius: var(--radius);
}

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

@media (max-width: 600px) {
    .container {
        padding-inline: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
    }
}
