h1:focus {
    outline: none;
}

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

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

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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;
}

/* === Admin shell === */
:root {
    --bg: #f6f7fb;
    --surface: #fff;
    --text: #101828;
    --muted: #667085;
    --border: #e4e7ec;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: rgba(79, 70, 229, .1);
    --danger: #b42318;
    --row-hover: #f9fafb;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0f1a;
        --surface: #131a2a;
        --text: #f2f4f7;
        --muted: #98a2b3;
        --border: #263044;
        --accent: #7c83ff;
        --accent-hover: #9aa0ff;
        --accent-soft: rgba(124, 131, 255, .14);
        --danger: #fda29b;
        --row-hover: #18213a;
    }
}

body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; margin: 0; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }

.shell { display: grid; grid-template-columns: 16rem minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem .85rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: 0 .5rem; font-weight: 650; letter-spacing: .01em; color: var(--text); text-decoration: none; }
.sidebar-logo {
    width: 2.25rem; height: 2.25rem; padding: .45rem; box-sizing: border-box; border-radius: .65rem;
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }

.nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: .65rem;
    color: var(--muted); font-weight: 500; text-decoration: none; transition: background-color .15s, color .15s;
}
.nav-item svg { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--row-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item:focus-visible, .logout:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 1px; }

.sidebar-footer { display: flex; flex-direction: column; gap: .5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar-footer form { margin: 0; }
.sidebar-user { display: flex; align-items: center; gap: .65rem; padding: 0 .5rem; min-width: 0; }
.avatar { width: 2rem; height: 2rem; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.sidebar-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.logout { width: 100%; padding: .5rem .75rem; text-align: left; font: inherit; font-size: .875rem; color: var(--muted); background: none; border: 0; border-radius: .6rem; cursor: pointer; }
.logout:hover { background: var(--row-hover); color: var(--danger); }

main { max-width: 60rem; width: 100%; box-sizing: border-box; margin: 0; padding: 2.25rem 2.5rem; }
main h1 { margin: 0 0 1rem; font-size: 1.65rem; font-weight: 650; line-height: 1.25; }
main h2 { margin: 2rem 0 .75rem; font-size: 1.1rem; font-weight: 600; }

button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
button.link:hover { text-decoration: underline; }

main button[type=submit]:not(.link), main button[data-passkey], a.button {
    padding: .55rem 1rem; font: inherit; font-weight: 600; color: #fff; background: var(--accent);
    border: 0; border-radius: .6rem; cursor: pointer; transition: background-color .15s, transform .05s;
}
main button[type=submit]:not(.link):hover, main button[data-passkey]:hover, a.button:hover { background: var(--accent-hover); }
main button[type=submit]:not(.link):active, a.button:active { transform: translateY(1px); }
a.button { display: inline-block; color: #fff; text-decoration: none; }
a.button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 2px; }

.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: .3rem; font-size: .875rem; font-weight: 500; }
.field input:not([type]), .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=date], .field select, .field textarea {
    width: 100%; max-width: min(26rem, 100%); padding: .6rem .75rem; box-sizing: border-box; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: .6rem; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.field input.valid.modified:not([type=checkbox]) { outline: none; }
.field input.invalid { outline: none; border-color: var(--danger); }
.validation-message { color: var(--danger); font-size: .8125rem; }
.hint { color: var(--muted); font-size: .85rem; }
.error { color: var(--danger); }

.secret { padding: 1rem 1.25rem; border: 1px solid #e5b93c; border-radius: .75rem; background: color-mix(in srgb, #f5c542 14%, var(--surface)); }
.secret code { user-select: all; word-break: break-all; }

table { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: .85rem; overflow: hidden; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--row-hover); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--row-hover); }
code { font-size: .85em; }

.menu-toggle, .menu-toggle-input { display: none; }

@media (max-width: 48rem) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .75rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); }

    /* The hamburger: a checkbox kept in the layout (for keyboard focus) but invisible, and its label as the button. */
    .menu-toggle-input { display: block; position: absolute; width: 1px; height: 1px; opacity: 0; }
    .menu-toggle { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; margin-left: auto; border-radius: .65rem; color: var(--text); cursor: pointer; }
    .menu-toggle svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
    .menu-toggle:hover { background: var(--row-hover); }
    .menu-toggle-input:focus-visible + .menu-toggle { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 1px; }
    .menu-toggle-input:checked + .menu-toggle { background: var(--accent-soft); color: var(--accent); }

    /* Collapsed until the hamburger is checked. */
    .sidebar-nav, .sidebar-footer { display: none; flex: 1 1 100%; }
    .menu-toggle-input:checked ~ .sidebar-nav { display: flex; order: 3; }
    .menu-toggle-input:checked ~ .sidebar-footer { display: flex; order: 4; padding-top: .75rem; }
    .sidebar-footer { flex-direction: row; align-items: center; justify-content: space-between; }
    .logout { width: auto; }
    main { min-width: 0; padding: 1.5rem 1rem; overflow-wrap: anywhere; }
    /* A wide table scrolls inside itself instead of widening the page. */
    table { display: block; overflow-x: auto; }
    .field input[type=date] { min-width: 0; }
}


#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: .6rem 1.25rem; background: #ffffe0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* === Sign-in pages (AuthLayout) === */
.auth-page {
    --auth-bg: #f4f6fb;
    --auth-card: #fff;
    --auth-text: #101828;
    --auth-muted: #667085;
    --auth-border: #d0d5dd;
    --auth-accent: #4f46e5;
    --auth-accent-hover: #4338ca;
    --auth-danger: #b42318;
    --auth-danger-bg: #fef3f2;
    --auth-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 32px rgba(16, 24, 40, .08);

    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-sizing: border-box;
    color: var(--auth-text);
    background:
        radial-gradient(60rem 30rem at 15% -10%, rgba(79, 70, 229, .16), transparent 60%),
        radial-gradient(50rem 28rem at 100% 110%, rgba(14, 165, 233, .14), transparent 60%),
        var(--auth-bg);
}

@media (prefers-color-scheme: dark) {
    .auth-page {
        --auth-bg: #0b0f1a;
        --auth-card: #131a2a;
        --auth-text: #f2f4f7;
        --auth-muted: #98a2b3;
        --auth-border: #2b3548;
        --auth-accent: #7c83ff;
        --auth-accent-hover: #9aa0ff;
        --auth-danger: #fda29b;
        --auth-danger-bg: rgba(240, 68, 56, .12);
        --auth-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .45);
    }
}

.auth-card {
    width: 100%;
    max-width: 24rem;
    padding: 2rem 2rem 2.25rem;
    box-sizing: border-box;
    background: var(--auth-card);
    border: 1px solid var(--auth-border);
    border-radius: 1rem;
    box-shadow: var(--auth-shadow);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.75rem;
    font-weight: 600;
    letter-spacing: .01em;
}

.auth-logo {
    width: 2.25rem;
    height: 2.25rem;
    padding: .45rem;
    box-sizing: border-box;
    border-radius: .65rem;
    background: var(--auth-accent);
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-title { margin: 0 0 .25rem; font-size: 1.5rem; line-height: 1.25; font-weight: 650; }
.auth-subtitle { margin: 0 0 1.5rem; color: var(--auth-muted); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-field { display: flex; flex-direction: column; gap: .35rem; }
.auth-field label { font-size: .875rem; font-weight: 500; }

.auth-field input:not([type]),
.auth-field input[type=text],
.auth-field input[type=email],
.auth-field input[type=password],
.auth-field input[type=date] {
    width: 100%;
    padding: .65rem .8rem;
    box-sizing: border-box;
    font: inherit;
    color: var(--auth-text);
    background: transparent;
    border: 1px solid var(--auth-border);
    border-radius: .6rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.auth-field input::placeholder { color: var(--auth-muted); opacity: .7; }

.auth-field input:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 25%, transparent);
}

/* Replace the default validation outlines with a border colour. */
.auth-field input.valid.modified:not([type=checkbox]) { outline: none; }
.auth-field input.invalid { outline: none; border-color: var(--auth-danger); }
.auth-field .validation-message { color: var(--auth-danger); font-size: .8125rem; }

.auth-check { display: flex; align-items: center; gap: .5rem; font-size: .875rem; color: var(--auth-muted); cursor: pointer; }
.auth-check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--auth-accent); }

.auth-button {
    margin-top: .25rem;
    padding: .7rem 1rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--auth-accent);
    border: 0;
    border-radius: .6rem;
    cursor: pointer;
    transition: background-color .15s, transform .05s;
}
.auth-button:hover { background: var(--auth-accent-hover); }
.auth-button:active { transform: translateY(1px); }
.auth-button:focus-visible { outline: 3px solid color-mix(in srgb, var(--auth-accent) 40%, transparent); outline-offset: 2px; }

.auth-alert {
    padding: .65rem .8rem;
    font-size: .875rem;
    color: var(--auth-danger);
    background: var(--auth-danger-bg);
    border: 1px solid color-mix(in srgb, var(--auth-danger) 35%, transparent);
    border-radius: .6rem;
}

.auth-card a { color: var(--auth-accent); }


/* === Users === */
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 500; }
.badge-on { background: #dcfae6; color: #067647; }
.badge-off { background: #fee4e2; color: #b42318; }
@media (prefers-color-scheme: dark) {
    .badge-on { background: rgba(18, 183, 106, .16); color: #6ce9a6; }
    .badge-off { background: rgba(240, 68, 56, .16); color: #fda29b; }
}
.actions { display: flex; gap: .75rem; margin: 1rem 0 1.5rem; }
.actions form { margin: 0; }

/* === Audit log === */
.nowrap { white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

/* === Tabs === */
.tabs { display: flex; gap: .25rem; margin: 1.5rem 0 1.25rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    padding: .6rem .9rem; margin-bottom: -1px; font-weight: 500; white-space: nowrap; text-decoration: none;
    color: var(--muted); border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: -3px; border-radius: .4rem; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.5rem; margin: 0 0 1.5rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.view-switch { display: flex; gap: .25rem; margin: 0 0 1.25rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; align-items: center; gap: .75rem; padding: 1.5rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: .85rem; color: var(--text); text-decoration: none; text-align: center; }
a.tile:hover { background: var(--row-hover); border-color: var(--accent); }
.tile-disabled { opacity: .6; }
.tile-name { font-weight: 600; overflow-wrap: anywhere; }

/* The whole row opens the link in it: the link stretches over the row, so it still works without script. */
tr.row-link { position: relative; cursor: pointer; }
tr.row-link a::after { content: ""; position: absolute; inset: 0; }
/* Controls inside a clickable row stay above the stretched link. */
tr.row-link .row-action { position: relative; z-index: 1; }


/* === Second factors === */
/* Passkeys need script and a browser that supports them: passkeys.js adds the class to the page when they work. */
.passkey-ui { display: none; }
.passkeys-supported .passkey-ui { display: revert; }
.passkeys-supported form.auth-form.passkey-ui { display: flex; }
[data-passkey]:disabled { opacity: .6; cursor: progress; }

.auth-divider { display: flex; align-items: center; gap: .75rem; color: var(--auth-muted); font-size: .8125rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--auth-border); }
.auth-button-secondary { color: var(--auth-text); background: transparent; border: 1px solid var(--auth-border); }
.auth-button-secondary:hover { background: var(--auth-bg); }
.auth-links { display: flex; flex-direction: column; gap: .35rem; margin: 1.25rem 0 0; font-size: .875rem; }

main button.danger:not(.link) { background: var(--danger); color: var(--surface); }
main button.danger:not(.link):hover { background: var(--danger); filter: brightness(.9); }

.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .25rem 1rem; margin: 0; padding: 0; list-style: none; }
.setup { display: flex; flex-wrap: wrap; gap: 1.5rem 2rem; align-items: flex-start; margin-bottom: 1rem; }
.qr { width: 12rem; flex: none; padding: .5rem; background: #fff; border: 1px solid var(--border); border-radius: .75rem; }
.qr svg { display: block; width: 100%; height: auto; }
.key { font-size: 1rem; user-select: all; word-break: break-all; }
form.passkey-ui { margin-top: 1.25rem; }
