:root {
    --ae-primary: #0da69f;
    --ae-primary-hover: #078983;
    --rz-primary: var(--ae-primary);
    --rz-primary-dark: #078983;
    --rz-primary-darker: #066d68;
    --rz-primary-light: #34bcb5;
    --rz-primary-lighter: rgba(13, 166, 159, 0.16);
    --rz-on-primary: #fff;
    --rz-on-primary-dark: #fff;
    --rz-on-primary-darker: #fff;
    --rz-on-primary-light: #fff;
    --rz-on-primary-lighter: #076f6a;

    /* Material-3 direction: larger shape + system Roboto-first stack.
       The Radzen Material themes ship Roboto in their font token; this keeps
       body text aligned without a webfont download. */
    --rz-border-radius: 12px;

    /* Every dialog's title bar. Radzen's Material themes give the title bar the same
       background as the dialog body, so a dialog reads as one flat panel with no header,
       and in dark mode its close button is black on near-black. This is the app's own
       scheme instead, applied to every dialog: the deep blue of the brand mark (#1f28db,
       sampled from brand-logo.png), which carries white text in light mode.
       Deliberately not --rz-secondary: that is not one color - #e31c65 in light and
       #01a299 in dark - where a title bar wants the same identity in both themes. */
    --ae-dialog-titlebar-bg: #1f28db;
    --ae-dialog-titlebar-fg: #ffffff;
    --ae-dialog-footer-bg: color-mix(in srgb, #fff 86%, var(--ae-primary));
    --ae-dialog-footer-border: color-mix(in srgb, #fff 72%, var(--ae-primary));
    --ae-dialog-close-bg: color-mix(in srgb, #fff 82%, var(--ae-primary));
    --ae-dialog-close-border: color-mix(in srgb, #fff 58%, var(--ae-primary));
    --ae-dialog-close-fg: #075b57;
}

/* Dark mode uses muted blue and teal tints for the dialog chrome, kept close to the
   body surface so the header and footer remain low contrast. */
:root[data-theme="dark"] {
    --ae-dialog-titlebar-bg: #303b50;
    --ae-dialog-titlebar-fg: #e4e4e4;
    --ae-dialog-footer-bg: #293533;
    --ae-dialog-footer-border: #35413f;
    --ae-dialog-close-bg: var(--rz-base-700);
    --ae-dialog-close-border: var(--rz-base-500);
    --ae-dialog-close-fg: var(--rz-text-color);
}


html, body {
    font-family: Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--rz-body-background-color, var(--rz-base-background-color));
    color: var(--rz-text-color);
}

h1:focus {
    outline: none;
}

a {
    color: var(--ae-primary-hover);
}

.content {
    padding-top: 1.1rem;
}

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

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

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

    #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+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4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azor-error-boundary::after {
        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: var(--ae-primary);
            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;
}

/* -----------------------------------------------------------------------------
   Shared page chrome (used by every feature page).
   ----------------------------------------------------------------------------- */
.page-title {
    margin: 0;
    font-size: 1.6rem;
}

.page-subtitle {
    margin: 0.25rem 0 0;
    opacity: 0.7;
}

/* A page's command bar: the row of filters and buttons that sits under, or beside, its heading.
   Defined once here rather than page by page, because it is the same rule everywhere - and because
   it has to reach inside Radzen components, where a page-scoped rule cannot go: the input is rendered
   by RadzenDatePicker or RadzenTextBox, not by our markup.

   Radzen sizes a control's text from --rz-input-font-size and --rz-label-font-size, and both default
   to the body size (1rem), where a small button is 0.75rem. Left alone, a bar therefore reads as a row
   of fields set two sizes larger than the buttons beside them. The label is in here for the same
   reason: left alone it stands a third size above the field it labels. */
.command-bar .rz-inputtext,
.command-bar .rz-dropdown-label,
.command-bar .rz-label {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.page-error {
    border-left: 4px solid #d13438;
}

/* -----------------------------------------------------------------------------
   Dialog chrome (all dialogs, both themes).
   The title bar is what makes a panel read as a dialog rather than as part of the
   page behind it, and Radzen's themes leave it the same color as the dialog body.
   This is the app's own scheme: the brand blue with white text, laid out like a
   desktop dialog - title and close button on one line, centerd in the bar.

   The colors come from --ae-dialog-titlebar-bg / -fg, set once in :root.
   ----------------------------------------------------------------------------- */
.rz-dialog-titlebar {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    background-color: var(--ae-dialog-titlebar-bg);
    color: var(--ae-dialog-titlebar-fg);
}

.rz-dialog-titlebar .rz-dialog-title {
    /* Centerd against the close button rather than sitting on the bar's baseline. */
    color: inherit;
    align-self: center;
    line-height: 1.4;
}

/* The glyph is an element of its own (.rzi-times) and the theme gives it its own gray,
   which is what left the close button looking absent until it was hovered - the button
   had inherited a readable color and the icon inside it had not. Set both. */
.rz-dialog-titlebar-close,
.rz-dialog-titlebar-close .rzi,
.rz-dialog-titlebar-close i,
.rz-dialog-titlebar-close span,
.rz-dialog-titlebar-close svg {
    color: inherit;
    fill: currentColor;
}

.rz-dialog-titlebar-close:hover {
    background-color: rgba(255, 255, 255, 0.18);
}

/* A shell dialog owns its own padding: the body carries it and the footer is a
   full-bleed bar, so the dialog content itself must not inset either. Keyed off
   the shell class so any data dialog built the standard way inherits this
   without being listed here. */
.rz-dialog-content:has(.ae-dialog-shell) {
    padding: 0;
}

/* -----------------------------------------------------------------------------
   Dialog shell: the reusable data-dialog layout, global so any dialog can use the
   same two-row grid, scrolling body and themed footer. A page that opens a dialog
   puts .ae-dialog-shell on the dialog's root element, .ae-dialog-body on the
   scrolling body and .ae-dialog-footer on the action row. The View dialog is
   70vh; the Edit dialog is 72vh with a denser body gap. Set --rz-input-height /
   --rz-input-font-size on the shell so the fields are dense without
   InputSize="InputSize.Small" on every control.
   ----------------------------------------------------------------------------- */
.ae-dialog-shell {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    row-gap: 1.25rem;
    overflow: hidden;

    /* Dense edit controls. Radzen re-declares these on itself, so they must be
       set on the shell (an ancestor that reaches the input), not on each
       control. See UI-STANDARDS "Fields are dense". */
    --rz-input-height: 2.125rem;
    --rz-input-font-size: 0.8125rem;
}

.ae-dialog-shell--view {
    height: 70vh;
    max-height: 70vh;
}

.ae-dialog-shell--edit {
    height: 72vh;
    max-height: 72vh;
}

/* A dialog that sizes to its content but must not outgrow the screen: the body is a list whose
   length the tenant decides. An imposed height would leave a band of empty dialog under a short
   list, and no height at all would run a long one off the bottom of the screen - so it is capped
   rather than set. */
.ae-dialog-shell--capped {
    max-height: 72vh;
}

.ae-dialog-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem 1.5rem 0;
    width: 100%;
}

.ae-dialog-body--dense {
    gap: 0.6rem;
}

/* A child's own bottom margin at the end of the body is 3-8px of phantom scroll: enough to raise a
   scrollbar on a dialog that otherwise fits exactly. The body's padding is the space below the last
   field. */
.ae-dialog-body > :last-child {
    margin-bottom: 0;
}

.ae-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex: 0 0 auto;
    min-height: 3.25rem;
    padding: 0.6rem 1.5rem;
    width: 100%;
    border-top: 1px solid var(--ae-dialog-footer-border);
    background: var(--ae-dialog-footer-bg);
}

/* A footer action that belongs on the leading edge rather than with the closing pair - "Add line"
   on a form, which adds to the body above it. The footer is a right-aligned row, so the lead item
   is what pushes the rest over. */
.ae-dialog-footer-lead {
    margin-right: auto;
}

/* Close / Cancel button shared by every dialog footer. */
.ae-dialog-close {
    background-color: var(--ae-dialog-close-bg) !important;
    border: 1px solid var(--ae-dialog-close-border) !important;
    color: var(--ae-dialog-close-fg) !important;
}

.ae-dialog-close:hover {
    filter: brightness(1.08);
}

/* -----------------------------------------------------------------------------
   Dialog chrome and portal-level styles are global because Radzen renders its
   dialogs outside the page tree. Individual dialog components use scoped styles
   for their own native markup.
   ----------------------------------------------------------------------------- */
.dialog-error {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border-left: 4px solid #d13438;
    background: #fdecea;
    color: #b71c1c;
}

/* A grid cell that opens the row it belongs to. A real button rather than an anchor, because
   opening a record is a page action and not a link a reader can middle-click into a new tab. */
.data-grid-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ae-primary-hover);
    cursor: pointer;
    font-weight: 600;
    text-align: left;
}

.data-grid-link:hover,
.data-grid-link:focus-visible {
    text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   The shared list-page shape. A list page is a heading band - the page's h1, with
   its filters and its one action on the same row - over a grid that is the page
   itself: neither sits in a card, because the viewport is the budget and a card
   spends it on chrome. The grid takes what the band leaves, so at HD its footer
   and its pager are in view and the rows get the height.

   `.ae-list-page` is the column that owns the viewport, `.ae-list-header` the
   heading row, `.ae-list-actions` the filter group that sits at its right end,
   `.ae-list-grid` the grid, and `.ae-list-footer-count` the quieter figure beside
   the word that introduces the grid's footer ("Totals  3 tenants  12 users").
   -------------------------------------------------------------------------- */
.ae-list-page {
    box-sizing: border-box;
    height: calc(100dvh - 7.125rem);
    min-height: 0;
}

.ae-list-header {
    display: flex;
    width: 100%;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ae-list-actions {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: flex-end;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ae-list-grid {
    flex: 1 1 0;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 0.75rem;
}

.ae-list-grid .rz-data-grid-data {
    min-height: 0;
}

.ae-list-grid .rz-grid-table thead th {
    padding-block: 0;
    background: var(--ae-dialog-footer-bg);
}

.ae-list-grid .rz-grid-table thead th > div:first-child {
    padding-block: 0.2rem;
}

/* The footer rides at the foot of the grid, directly above the pager, and stays there while the
   rows scroll behind it - so the figures are read with the columns they belong to and neither the
   footer nor the pager costs a band above the data.

   The counts are set a size below the label that introduces them and are expected to fit the first
   column: an empty footer cell beside them is still an opaque cell, so text that overflowed would be
   painted over by its neighbour rather than read. */
.ae-list-grid .rz-grid-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--ae-dialog-footer-bg);
    font-weight: 600;
    padding-block: 0.2rem;
    border-top: 1px solid var(--rz-grid-cell-border-color, rgba(0, 0, 0, 0.12));
    white-space: nowrap;
}

.ae-list-footer-count {
    margin-left: 0.6rem;
    font-weight: 400;
    font-size: 0.78rem;
    opacity: 0.75;
}

.ae-list-grid .rz-pager {
    padding-block: 0.25rem;
}

.ae-list-grid .rz-pager .rz-pager-element {
    min-width: 2rem;
    min-height: 2rem;
    height: 2rem;
    padding: 0;
}

.ae-list-grid .rz-pager-page {
    line-height: 2rem;
}

/* A band whose heading and filters belong together at the leading edge, with the page's one action at
   the far end: used where a list page carries its h1 in the same row as its filters. */
.ae-list-band {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
}

/* The empty state and the live-state note that some lists carry under their band. Both are body
   text rather than balloons: the empty state says what to do next, and the note changes with the
   rows on screen, so neither can hide in a title attribute. */
.ae-list-empty {
    margin: 0;
    opacity: 0.75;
}

.ae-list-note {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.7;
}

@media (max-width: 900px) {
    .ae-list-actions {
        flex-basis: 100%;
    }
}

@media (max-width: 640.98px) {
    .ae-list-page {
        height: calc(100dvh - 5.125rem);
    }
}

/* ---------------------------------------------------------------------------
   Sign-in
   Centerd card rather than the app shell: there is no tenant, no navigation and
   no data yet at this point, so showing the sidebar would be a lie.
   --------------------------------------------------------------------------- */

/* Shown while the session is read back from sessionStorage, before the Router
   renders. A slow storage read would otherwise flash text into a corner. */
.session-loading {
    padding: 2rem;
    color: #6c757d;
}

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 24rem;
    padding: 2rem;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background-color: #fff;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.06);
}

.login-brand {
    margin: 0 auto 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    background: #fff;
}

.login-brand img {
    display: block;
    width: 100%;
    height: auto;
}

.login-sub {
    color: #6c757d;
    margin-bottom: 1.5rem;
}

.field {
    margin-bottom: 1rem;
}

.field label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.login-card .ae-input {
    display: block;
    width: 100%;
}

.input {
    display: block;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

.login-card button[type=submit] {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.45rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
}

.login-card button[type=submit]:disabled {
    opacity: 0.65;
    cursor: default;
}

/* Dark-mode companions for the sign-in card. The card is otherwise forced to a
   white surface, which on a dark theme leaves light inherited text on white. */
html[data-theme='dark'] .login-card {
    background: var(--rz-base-800);
    border-color: var(--rz-base-600);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    color: var(--rz-text-color);
}

html[data-theme='dark'] .login-sub {
    color: var(--rz-text-secondary-color);
}

html[data-theme='dark'] .login-card label {
    color: var(--rz-text-secondary-color);
}

html[data-theme='dark'] .ae-alert-error {
    color: #f5c2c7;
    background-color: rgba(209, 52, 56, 0.16);
    border-color: rgba(209, 52, 56, 0.5);
}

html[data-theme='dark'] .ae-alert-info {
    color: #b6d9e8;
    background-color: rgba(43, 130, 170, 0.16);
    border-color: rgba(43, 130, 170, 0.5);
}

html[data-theme='dark'] .error-detail {
    background-color: var(--rz-base-900);
    border-color: var(--rz-base-600);
    color: var(--rz-text-color);
}

/* Shown on a failed sign-in. role=alert in the markup is what announces it.
   Kept as .ae-alert (not Bootstrap's .alert): Radzen owns alerts elsewhere,
   and the login form stays dependency-light. */
.ae-alert {
    padding: 0.6rem 0.75rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
    border: 1px solid transparent;
}

.ae-alert-error {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

/* Shown when the shell signs the user out because the API stopped accepting their token.
   Information rather than an error: nothing has gone wrong, the session simply ran out. */
.ae-alert-info {
    color: #0b4f6c;
    background-color: #d8ecf5;
    border-color: #b6d9e8;
}

/* Shown by the ErrorBoundary in App.razor. Kept plain and wrapping: the text is
   an exception message, so its length is not predictable. */
.error-detail {
    margin: 0;
    padding: 0.6rem 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 12rem;
    overflow: auto;
}

/* --------------------------------------------------------------------------- 
   The screen between index.html arriving and Blazor starting. It is the first
   thing anyone sees, so it is centered and quiet rather than a line of default
   text in the corner.
   --------------------------------------------------------------------------- */
.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    min-height: 100vh;
    color: var(--rz-text-secondary-color);
}

.app-loading p {
    margin: 0;
    font-size: 0.9rem;
}

.app-loading__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid var(--rz-base-300, #cfd4da);
    border-top-color: var(--ae-primary);
    border-radius: 50%;
    animation: ae-spin 0.9s linear infinite;
}

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

/* A reader who asked the system to calm animation down gets a still ring rather than a
   spinner, which is the one animation on the page. */
@media (prefers-reduced-motion: reduce) {
    .app-loading__spinner {
        animation: none;
    }
}
