:root {
    color-scheme: light dark;
    --error: var(--colorStatusDangerForeground1);
    --colorBrandBackground: #217346;
    --colorBrandBackgroundHover: #1b613a;
    --colorBrandBackgroundPressed: #164f30;
    --colorBrandBackgroundSelected: #1b613a;
    --colorBrandForeground1: #217346;
    --colorBrandForeground2: #1b613a;
    --colorBrandForegroundLink: #217346;
    --colorBrandForegroundLinkHover: #1b613a;
    --colorBrandForegroundLinkPressed: #164f30;
    --colorBrandForegroundLinkSelected: #1b613a;
    --colorBrandStroke1: #217346;
    --colorBrandStroke2: #c4dfcc;
    --colorBrandBackground2: #e5f1e9;
    --colorCompoundBrandBackground: #217346;
    --colorCompoundBrandBackgroundHover: #1b613a;
    --colorCompoundBrandBackgroundPressed: #164f30;
    --colorCompoundBrandForeground1: #217346;
    --colorCompoundBrandForeground1Hover: #1b613a;
    --colorCompoundBrandForeground1Pressed: #164f30;
    --colorCompoundBrandStroke: #217346;
    --colorCompoundBrandStrokeHover: #1b613a;
    --colorCompoundBrandStrokePressed: #164f30;
}

body {
    --body-font: "Segoe UI Variable", "Segoe UI", sans-serif;
    font-family: var(--body-font);
    font-size: var(--fontSizeBase300);
    line-height: var(--lineHeightBase300);
    margin: 0;
    background: var(--colorNeutralBackground1);
    color: var(--colorNeutralForeground1);
    color-scheme: light;
}

body[data-theme="dark"] {
    color-scheme: dark;
    --colorBrandForeground1: #83d5a5;
    --colorBrandForeground2: #a5e4bf;
    --colorBrandForegroundLink: #83d5a5;
    --colorBrandForegroundLinkHover: #a5e4bf;
    --colorBrandForegroundLinkPressed: #6bc592;
    --colorBrandForegroundLinkSelected: #a5e4bf;
    --colorCompoundBrandForeground1: #83d5a5;
    --colorCompoundBrandForeground1Hover: #a5e4bf;
    --colorCompoundBrandForeground1Pressed: #6bc592;
    --colorBrandBackground2: #183c29;
    --colorBrandStroke2: #356447;
}

.validation-message {
    color: var(--colorStatusDangerForeground1);
    font-size: 0.8rem;
    margin-top: 4px;
}

.body-content {
    align-self: stretch;
    min-width: 0;
    min-height: 0;
    display: flex;
}

.content {
    padding: 20px 24px;
    align-self: stretch !important;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.manage {
    width: 100%;
}

.app-footer {
    background: var(--colorNeutralBackground4);
    color: var(--colorNeutralForeground1);
    align-items: center;
    padding: 10px 10px;
}

    .app-footer a {
        color: var(--colorNeutralForeground1);
        text-decoration: none;
    }

        .app-footer a:focus {
            outline: 1px dashed;
            outline-offset: 3px;
        }

        .app-footer a:hover {
            text-decoration: underline;
        }

.alert {
    border: 1px dashed var(--colorBrandBackground);
    padding: 5px;
}


#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    margin: 20px 0;
}

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

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE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oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

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

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/* FluentLayout owns the mobile navigation drawer and its breakpoint. */
.app-header {
    background: var(--colorBrandBackground);
    color: var(--colorNeutralForegroundOnBrand);
    padding: 12px 16px;
}

.app-footer {
    display: flex;
    gap: 12px;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    margin: 0;
}

.header-content { width: 100%; }
.app-title { flex: 1; min-width: 0; }
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--borderRadiusMedium);
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.theme-toggle:hover { background: rgb(255 255 255 / 14%); }
.theme-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.theme-sun, body[data-theme="dark"] .theme-moon { display: none; }
body[data-theme="dark"] .theme-sun { display: block; }

/* One spacing system for filters, page actions, and editor fields. */
.content > :is(h1, h2, h3) { margin-top: 0; }
.page-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 16px;
}
:is(.page-toolbar, .toolbar, .log-toolbar, .report-toolbar, .picker-row) > fluent-field { margin-block: 0; }
.management-toolbar { align-items: flex-end; }
.management-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.management-actions > fluent-field { margin-block: 0; }
.management-search { flex: 0 1 24rem; min-width: 0; margin-inline-start: auto; }
.management-search > fluent-field { margin: 0; width: 100%; min-width: 0; }
@media (max-width: 1280px) {
    .management-search { flex-basis: 100%; margin-inline-start: 0; }
}
.icat-dialog-body fluent-field { margin-block: 0; min-width: 0; width: 100%; max-width: 100%; }
.icat-dialog-body form > .fluent-stack-vertical { row-gap: 16px !important; align-items: stretch !important; }
.icat-dialog-body .validation-message { margin-top: -12px; }
.icat-dialog-body :is(fluent-text-input, fluent-text-area, fluent-dropdown) { max-width: 100%; box-sizing: border-box; }
.compact-dialog fluent-field { width: 100% !important; }
.compact-dialog { overflow-wrap: anywhere; }
.compact-dialog :is(fluent-text-input, fluent-text-area, fluent-dropdown) { width: 100% !important; }
.funder-fields { display: flex; flex-direction: column; gap: 16px; }
.compact-dialog fluent-field > [slot="input"] { width: 100% !important; }
.compact-dialog fluent-field > [slot="input"] :is(fluent-text-input, fluent-text-area, fluent-dropdown) { width: 100%; }
fluent-dialog[fuib]:has(.compact-dialog)::part(dialog) { width: 440px; max-width: calc(100vw - 32px); }
fluent-dialog[fuib]:has(.icat-dialog-body)::part(dialog) { max-height: calc(100dvh - 32px); }
.icat-dialog-body > [slot="action"] { justify-content: flex-start; width: 100%; padding-top: 8px; }
.icat-dialog-body :is(h2, h3, h4) { margin-block: 0; }
.content .fluent-data-grid { max-width: 100%; }
.table-scroll { width: 100%; min-width: 0; overflow-x: auto; }
.page-filter { margin-block: 0 16px; }
.content form > fluent-field { margin-block: 0 16px; }
.content .account-form { width: 100%; }
.text-danger, .alert-danger { color: var(--colorStatusDangerForeground1); }
.alert-success { color: var(--colorStatusSuccessForeground1); }
.content :is(fluent-paginator, .fluent-paginator) { margin-top: 12px; }

@media (max-width: 600px) {
    .content { padding: 0.5rem 0.75rem; }
}

.metric-group-label {
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.report-table {
    font-size: var(--fontSizeBase200);
    width: 100%;
}

.report-table-header {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--colorNeutralStroke1);
    color: var(--colorNeutralForeground3);
    font-weight: 600;
}

.report-table-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--colorNeutralStroke2);
    color: var(--colorNeutralForeground1);
}

.report-table-total {
    display: flex;
    padding: 10px 0;
    font-weight: 600;
    color: var(--colorNeutralForeground1);
}

.report-table-col-name {
    flex: 1;
}

.report-table-col-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 120px;
}

/* ---------- Shared component styles ---------- */

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.account-form {
    max-width: 400px;
}

.icon-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Import grids: why a row won't be saved, next to its red cross */
.icon-cell .row-problem {
    color: var(--error, #b10e1c);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Numbered step list (Welcome, User Manual) */
.steps {
    counter-reset: step;
    list-style: none;
    margin: 8px 0;
    padding: 0;
}

    .steps > li {
        counter-increment: step;
        margin: 10px 0;
        padding-left: 40px;
        position: relative;
        line-height: 1.5;
    }

        .steps > li::before {
            content: counter(step) ".";
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 28px;
            height: 28px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--colorNeutralStroke1);
            font-weight: 600;
        }

/* Frosted glass card (report metric / range / table cards) */
.glass-card {
    background: var(--colorNeutralBackground1);
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusLarge);
}

/* Report Inspect panels (tables are authored in each panel, so the styles are shared here) */
.inspect-heading {
    margin: 8px 0 0;
    font-size: var(--fontSizeBase300);
    font-weight: 600;
}

.inspect-formula {
    margin: 0;
    font-size: var(--fontSizeBase200);
    color: var(--colorNeutralForeground3);
}

.inspect-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fontSizeBase200);
    font-variant-numeric: tabular-nums;
}

    .inspect-table th,
    .inspect-table td {
        padding: 6px 4px;
        border-bottom: 1px solid var(--colorNeutralStroke2);
        text-align: right;
        vertical-align: top;
    }

        .inspect-table th:first-child,
        .inspect-table td:first-child {
            text-align: left;
        }

    .inspect-table th {
        color: var(--colorNeutralForeground3);
        font-weight: 600;
    }

    .inspect-table tfoot td {
        font-weight: 600;
        border-bottom: none;
    }

.inspect-sub {
    color: var(--colorNeutralForeground3);
}

*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid transparent;
    outline-offset: 2px;
}
