html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Before the theme provider has rendered the variable is undefined, so the boot screen falls back to dark. */
html, body {
    background-color: var(--mud-palette-background, #0a0f1c);
    color: var(--mud-palette-text-primary, #8ea0ba);
}

.boot {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: #8ea0ba;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: .06em;
}

.boot-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #1e2a40;
    border-top-color: #22d3ee;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: .75rem;
        top: .5rem;
    }

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pre-wrap {
    white-space: pre-wrap;
}

.recovery-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.05rem;
    letter-spacing: .04em;
}

.qr svg {
    width: 220px;
    height: 220px;
}

.clickable-row {
    cursor: pointer;
}

/* ===== Digital theme ===== */
:root {
    --mono: ui-monospace, "Cascadia Code", SFMono-Regular, Menlo, Consolas, monospace;
    --radius: 6px;
}

/* Faint circuit-grid behind the page; follows the theme's primary colour in light and dark. */
.mud-main-content {
    background-image: linear-gradient(rgba(var(--mud-palette-primary-rgb), .06) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--mud-palette-primary-rgb), .06) 1px, transparent 1px);
    background-size: 32px 32px;
}

/* Monospace for headings, buttons, nav and table headers; body text stays in the readable system font. */
.mud-typography-h1, .mud-typography-h2, .mud-typography-h3, .mud-typography-h4, .mud-typography-h5, .mud-typography-h6,
.mud-button-root, .mud-nav-group > .mud-nav-link, .mud-tab, .mud-simple-table thead th, .mud-table-head .mud-table-cell,
.mud-typography-overline {
    font-family: var(--mono);
}

.mud-typography-h4, .mud-typography-h5, .mud-typography-h6 {
    letter-spacing: .02em;
}

.mud-button-root {
    letter-spacing: .06em;
}

.mud-simple-table thead th, .mud-table-head .mud-table-cell {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .08em;
    color: var(--mud-palette-text-secondary);
}

/* App bar: dark bar with a cyan hairline glow, brand with a blinking cursor, digital clock. */
.mud-appbar {
    border-bottom: 1px solid rgba(34, 211, 238, .45);
    box-shadow: 0 0 18px rgba(34, 211, 238, .18) !important;
}

.brand-mark {
    font-family: var(--mono);
    font-weight: 700;
    letter-spacing: .04em;
}

.brand-sub {
    font-family: var(--mono);
    opacity: .7;
    letter-spacing: .04em;
}

.brand-cursor {
    color: #22d3ee;
    animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

.digital-clock {
    font-family: var(--mono);
    font-size: .85rem;
    letter-spacing: .08em;
    color: #22d3ee;
    padding: 2px 10px;
    border: 1px solid rgba(34, 211, 238, .35);
    border-radius: var(--radius);
    background: rgba(34, 211, 238, .07);
    font-variant-numeric: tabular-nums;
}

/* Drawer / navigation */
.mud-drawer {
    border-right: 1px solid var(--mud-palette-lines-default);
}

.mud-nav-link {
    border-left: 3px solid transparent;
}

    .mud-nav-link.active:not(.mud-nav-link-disabled) {
        border-left-color: var(--mud-palette-primary);
        background: rgba(var(--mud-palette-primary-rgb), .10);
    }

    .mud-nav-link:hover:not(.mud-nav-link-disabled) {
        background: rgba(var(--mud-palette-primary-rgb), .07);
    }

/* Surfaces, inputs, buttons */
.mud-paper {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--radius);
}

.mud-appbar.mud-paper, .mud-drawer.mud-paper {
    border-radius: 0;
}

.mud-input-outlined-border {
    border-radius: var(--radius);
}

.mud-input-control:focus-within .mud-input-outlined-border {
    box-shadow: 0 0 0 3px rgba(var(--mud-palette-primary-rgb), .18);
}

.mud-button-filled {
    border-radius: var(--radius);
}

.mud-button-filled-primary:hover {
    box-shadow: 0 0 14px rgba(var(--mud-palette-primary-rgb), .55);
}

.mud-chip {
    font-family: var(--mono);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--mud-palette-primary-rgb), .35);
    border-radius: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* Sign-in / public pages */
.auth-shell {
    min-height: 100vh;
    background: radial-gradient(900px 500px at 15% -10%, rgba(var(--mud-palette-primary-rgb), .18), transparent 60%), radial-gradient(700px 400px at 100% 100%, rgba(var(--mud-palette-secondary-rgb), .14), transparent 60%), linear-gradient(rgba(var(--mud-palette-primary-rgb), .06) 1px, transparent 1px), linear-gradient(90deg, rgba(var(--mud-palette-primary-rgb), .06) 1px, transparent 1px);
    background-size: auto, auto, 32px 32px, 32px 32px;
}

.auth-brand {
    font-family: var(--mono);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--mud-palette-primary);
    margin-bottom: 14px;
    text-shadow: 0 0 14px rgba(var(--mud-palette-primary-rgb), .6);
}

.auth-shell .mud-paper {
    box-shadow: 0 0 0 1px rgba(var(--mud-palette-primary-rgb), .35), 0 0 32px rgba(var(--mud-palette-primary-rgb), .14) !important;
}

/* Paper output must stay black on white, whichever theme is on screen. */
@media print {
    .no-print {
        display: none !important;
    }

    html, body, .mud-main-content, .mud-paper, .mud-layout {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    .mud-main-content {
        background-image: none !important;
        padding-top: 0 !important;
    }

    .mud-typography, .mud-table-cell, .mud-simple-table th, .mud-simple-table td {
        color: #000 !important;
    }
}

/* ===== Printable certificate ===== */
.certificate {
    background: #fff;
    color: #111;
    max-width: 800px;
    margin: 0 auto;
    padding: 48px 56px;
    border: 2px double #333;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.6;
}

.certificate-head {
    text-align: center;
    font-size: .95rem;
    line-height: 1.35;
}

.certificate-logo {
    display: block;
    margin: 0 auto 8px;
    max-height: 96px;
    max-width: 160px;
    object-fit: contain;
}

.certificate-barangay {
    font-weight: 700;
    font-size: 1.15rem;
    margin-top: 4px;
}

.certificate-office {
    font-weight: 700;
    letter-spacing: .04em;
    margin-top: 2px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

.certificate-title {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: .06em;
    margin: 28px 0 22px;
    font-family: Georgia, "Times New Roman", serif;
}

.certificate-body {
    text-align: justify;
    text-indent: 3rem;
    margin: 0 0 14px;
    font-size: 1.05rem;
    white-space: pre-line;
}

.certificate-sign {
    margin: 56px 0 0 auto;
    width: 300px;
    text-align: center;
}

.certificate-signname {
    border-top: 1px solid #111;
    padding-top: 4px;
    font-weight: 700;
}

.certificate-foot {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-top: 36px;
    font-size: .8rem;
    line-height: 1.4;
}

.certificate-qr svg {
    width: 92px;
    height: 92px;
    display: block;
}

.certificate-verify {
    word-break: break-all;
}

@media print {
    .certificate {
        border: 2px double #000;
        box-shadow: none;
        max-width: none;
        margin: 0;
        padding: 24px 32px;
    }

        .certificate * {
            color: #000 !important;
        }
}

/* ===== Preview watermark: a preview must never pass for the issued document ===== */
.certificate-preview {
    position: relative;
    overflow: hidden;
}

.certificate-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 7rem;
    font-weight: 800;
    letter-spacing: .2em;
    color: rgba(200, 0, 0, .12);
    transform: rotate(-30deg);
    pointer-events: none;
    user-select: none;
}

@media print {
    .certificate-preview {
        display: none !important;
    }
}

/* ===== Role-gating matrix ===== */
.role-matrix {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: .85rem;
}

    .role-matrix th, .role-matrix td {
        padding: 4px 10px;
        border-bottom: 1px solid var(--mud-palette-lines-default);
        white-space: nowrap;
    }

    .role-matrix thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--mud-palette-surface);
        text-align: center;
        font-family: var(--mono);
    }

.role-matrix-perm {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--mud-palette-surface);
    text-align: left !important;
    font-family: var(--mono);
}

.role-matrix thead .role-matrix-perm {
    z-index: 3;
}

.role-matrix-cell {
    text-align: center;
}

.role-matrix-count {
    font-weight: 400;
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
}

.role-matrix-module td {
    background: rgba(var(--mud-palette-primary-rgb), .10);
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .72rem;
}
