/* ==================================================================
   APPLICATION DESIGN LAYER
   ==================================================================
   Surfaces, frame, titles, cards, tables, forms, dialogs and status pills of the
   platform, loaded after application-shell.css. Every colour derives from the
   active theme tokens, so all themes, light/dark modes and contrast levels follow.

   Model: a quiet canvas, cards one step above it, nested rows one step above the
   cards. Dark themes read by tone alone; light themes add a soft shadow. */

:root {
    --ui-line: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
    --ui-line-strong: color-mix(in srgb, var(--md-sys-color-on-surface) 18%, transparent);
    /* Field borders: the field fill is almost the same tone as its card, so the border is what shows the field.
       25% at rest and 45% under the pointer (about 1.9 to 2.2:1 and 3.1 to 3.9:1); medium and high contrast raise them further. */
    --ui-field-border: color-mix(in srgb, var(--md-sys-color-on-surface) 25%, transparent);
    --ui-field-border-hover: color-mix(in srgb, var(--md-sys-color-on-surface) 45%, transparent);
    --ui-text2: var(--md-sys-color-on-surface-variant);
    --ui-primary-soft: color-mix(in srgb, var(--md-sys-color-primary) 14%, transparent);
    /* Coloured text on a tint keeps the theme hue but moves toward the text colour,
       so it stays readable even with bright primaries such as yellow or orange. */
    --ui-primary-text: color-mix(in srgb, var(--md-sys-color-primary) 45%, var(--md-sys-color-on-surface));
    /* The other status colours keep their palette value in the standard look; medium and high contrast move them toward
       the text colour (see the blocks near --ui-control-border) so text on a tint of its own colour reaches 4.5:1. */
    --ui-primary-tint-text: var(--mud-palette-primary);
    --ui-secondary-text: var(--mud-palette-secondary);
    --ui-info-text: var(--mud-palette-info);
    --ui-success-text: var(--mud-palette-success);
    --ui-warning-text: var(--mud-palette-warning);
    --ui-error-text: var(--mud-palette-error);
    /* The feedback survey block is lilac (user choice, 9 November 2026): a colour of its own beside the blue lesson, red exam
       and green group blocks. The text variant follows the other status colours in medium and high contrast. */
    --ui-survey: #9575cd;
    --ui-survey-text: var(--ui-survey);
    --ui-hover: color-mix(in srgb, var(--md-sys-color-on-surface) 6%, transparent);
    --ui-radius: 1rem;
    --ui-shadow: none;
}

:root[data-bs-theme="dark"] {
    --ui-survey: #b39ddb;
    --ui-canvas: var(--md-sys-color-surface-container-lowest);
    --ui-bar: var(--md-sys-color-surface);
    --ui-card: var(--md-sys-color-surface-container-low);
    --ui-card2: var(--md-sys-color-surface-container);
}

:root[data-bs-theme="light"] {
    --ui-canvas: var(--md-sys-color-surface-container);
    --ui-bar: var(--md-sys-color-surface-container-lowest);
    --ui-card: var(--md-sys-color-surface-container-lowest);
    --ui-card2: var(--md-sys-color-surface-container-low);
    --ui-shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 14px rgb(15 23 42 / .04);
}

/* MudBlazor reads these palette variables, so dialogs, menus, tables and inputs
   follow the same surfaces as the shell. */
/* Only the administration area uses the platform card surfaces; the user area keeps the theme palette. */
:root:has(.shell-area-admin)[data-bs-theme][data-theme]:not([data-contrast="none"]) {
    --mud-palette-background: var(--ui-canvas);
    --mud-palette-surface: var(--ui-card);
    --mud-palette-lines-default: var(--ui-line);
    --mud-palette-table-lines: var(--ui-line);
    --mud-palette-divider: var(--ui-line);
}

/* ---------- Shell frame ---------- */
.blazor-shell {
    background: var(--ui-canvas);
}

.blazor-shell:has(.sidebar) .blazor-page-content {
    --mud-palette-background: var(--ui-canvas);
}

.topbar,
.blazor-footer {
    background: var(--ui-bar);
}

.blazor-footer {
    border-top: 0;
    border-radius: var(--shell-radius, .5rem);
}

/* ---------- Sidebar ---------- */
.blazor-shell .sidebar {
    --sidebar-bg: var(--ui-canvas);
    --sidebar-item-active-bg: var(--ui-primary-soft);
    --sidebar-item-active-color: var(--ui-primary-text);
}

.sidebar .menu-label.menu-label-title {
    font-size: .72rem;
    color: var(--ui-text2);
}

.sidebar .menu-item-inner:hover,
.sidebar:not(.collapsed) .submenu-item:hover {
    background: var(--ui-card2);
}

.sidebar .menu-item.active,
.sidebar:not(.collapsed) .submenu-item.active {
    font-weight: 650;
}

.sidebar:not(.collapsed) .submenu-item {
    border-inline-start: 1px solid var(--ui-line);
}

/* ---------- Page titles ---------- */
.page-surface--compact .page-heading h1 {
    font-weight: 700;
    letter-spacing: -.02em;
}

.page-surface--compact .page-heading .page-heading__eyebrow {
    margin-bottom: .125rem;
    font-size: .78rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ui-text2);
}

/* ---------- Cards ---------- */
.page-body .page-panel,
.page-body .mud-table,
.record-form {
    border: 0;
    border-radius: var(--ui-radius);
    background: var(--ui-card);
    box-shadow: var(--ui-shadow);
}

.page-body .mud-table {
    overflow: hidden;
}

/* ---------- Tables ---------- */
.mud-table .mud-table-root .mud-table-head .mud-table-cell {
    background: var(--ui-card2);
    color: var(--ui-text2);
    font-size: .75rem;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.mud-table .mud-table-body .mud-table-row:hover > .mud-table-cell {
    background: color-mix(in srgb, var(--md-sys-color-primary) 5%, transparent);
}

@media (min-width: 961px) {
    .mud-table .mud-table-head .mud-table-cell {
        padding: .75rem 1.25rem;
    }

    .mud-table .mud-table-body .mud-table-cell {
        padding: .875rem 1.25rem;
        border-bottom: 1px solid var(--ui-line);
    }

    .mud-table .mud-table-body .mud-table-row:last-child > .mud-table-cell {
        border-bottom: 0;
    }
}

/* ---------- Forms ---------- */
.page-surface--compact .page-body .form-section-heading {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-size: .9375rem;
    font-weight: 650;
}

.page-surface--compact .page-body .form-section-heading :is(h2, h3, .form-section-title) {
    font-size: .9375rem;
    font-weight: 650;
}

.record-form {
    overflow: hidden;
}

/* Phone-only controls of the event program builder: arrows to move an element among its siblings and buttons that add
   elements, because dragging with a finger is hard. They are hidden from the layout (and from assistive technology)
   everywhere else, where the toolbox is dragged from. */
.builder-phone-only {
    display: none;
}

@media (max-width: 48rem) {
    span.builder-phone-only {
        display: inline-flex;
        align-items: center;
    }

    div.builder-phone-only {
        display: block;
    }

    .builder-add-row {
        margin-top: .5rem;
        margin-bottom: .5rem;
    }

    .builder-add-row .mud-button-root,
    .builder-add-row .mud-menu {
        width: 100%;
    }

    /* Touch targets of the arrows and the add buttons. */
    .builder-add-row .mud-button-root {
        min-height: 2.75rem;
    }

    .builder-move .mud-icon-button {
        min-width: 2.5rem;
        min-height: 2.5rem;
    }
}

/* Pages holding the event or report builder keep their toolbox sticky, which a scroll-container
   ancestor would stop (position: sticky follows the nearest one, even when it grows with its content and never
   scrolls). The surface only grows with its content, so clipping instead of scrolling changes nothing visible. */
.blazor-page-content .page-surface:has(.event-builder),
.blazor-page-content .page-surface:has(.report-composer) {
    overflow: clip;
}

.record-form-section + .record-form-section {
    border-top-color: var(--ui-line);
}

.page-surface--compact .record-actions {
    background: var(--ui-card2);
    border-top: 1px solid var(--ui-line);
}

.mud-input-outlined .mud-input-outlined-border {
    border-radius: .75rem;
}

/* Checkbox rows are compact where a fine pointer is available (a 36px target is still above the 24px minimum);
   touch devices keep the 48px target. The grid item rule only applies to a checkbox that stands alone in its grid
   cell, so rows of fields keep their spacing. */
@media (pointer: fine) {
    .mud-checkbox .mud-button-root.mud-icon-button {
        padding: .375rem;
    }

    .mud-grid > .mud-grid-item:has(> .mud-input-control-boolean-input:only-child .mud-checkbox) {
        padding-top: .25rem;
    }
}

/* ---------- Buttons ---------- */
.mud-button-root {
    border-radius: .625rem;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
}

.mud-button-outlined.mud-button-outlined-primary,
.mud-button-outlined.mud-button-outlined-default {
    border-color: var(--ui-line-strong);
    color: var(--md-sys-color-on-surface);
}

.mud-button-outlined.mud-button-outlined-primary:hover,
.mud-button-outlined.mud-button-outlined-default:hover {
    background: var(--ui-hover);
}

/* ---------- Status pills ---------- */
.mud-chip.mud-chip-filled {
    height: auto;
    padding: .125rem .625rem;
    border-radius: 99px;
    font-size: .78rem;
    font-weight: 650;
}

.mud-chip.mud-chip-filled::before {
    content: "";
    width: .375rem;
    height: .375rem;
    margin-right: .375rem;
    border-radius: 50%;
    background: currentColor;
}

.mud-chip.mud-chip-filled.mud-chip-color-primary,
.mud-chip.mud-chip-filled.mud-chip-color-info {
    background: color-mix(in srgb, var(--md-sys-color-primary) 16%, transparent);
    color: var(--ui-primary-text);
}

.mud-chip.mud-chip-filled.mud-chip-color-success {
    background: color-mix(in srgb, var(--mud-palette-success) 16%, transparent);
    color: color-mix(in srgb, var(--mud-palette-success) 50%, var(--md-sys-color-on-surface));
}

.mud-chip.mud-chip-filled.mud-chip-color-warning {
    background: color-mix(in srgb, var(--mud-palette-warning) 18%, transparent);
    color: color-mix(in srgb, var(--mud-palette-warning) 45%, var(--md-sys-color-on-surface));
}

.mud-chip.mud-chip-filled.mud-chip-color-error {
    background: color-mix(in srgb, var(--mud-palette-error) 16%, transparent);
    color: color-mix(in srgb, var(--mud-palette-error) 50%, var(--md-sys-color-on-surface));
}

/* ---------- Dialogs and menus ---------- */
.mud-dialog {
    border-radius: 1.25rem;
    background: var(--ui-card);
    box-shadow: 0 24px 60px rgb(0 0 0 / .4);
}

.mud-dialog .mud-dialog-title {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--ui-line);
}

.mud-dialog .mud-dialog-content {
    padding: 1.25rem 1.5rem;
}

.mud-dialog .mud-dialog-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--ui-line);
}

/* The help manual reader takes the whole screen on a phone, like a full-screen dialog, and leaves less padding around the book. */
@media (max-width: 599.98px) {
    .mud-dialog:has(.help-manual-reader) {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
    }

    .mud-dialog:has(.help-manual-reader) .mud-dialog-content {
        padding: .5rem;
    }
}

/* The location picker takes the whole screen on a phone, so the map keeps a usable size beside the search results. */
@media (max-width: 599.98px) {
    .mud-dialog.location-picker {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0;
    }

    .mud-dialog.location-picker .mud-dialog-content {
        padding: .75rem;
    }
}

.mud-popover {
    border-radius: var(--ui-radius);
}

/* ==================================================================
   BLOCK 2: typography, fields, nested rows, filters, menus, footer
   ================================================================== */

/* ---------- Typography ---------- */
.blazor-shell {
    font-size: .875rem;
    line-height: 1.5;
}

.topbar .topbar-brand,
.topbar .topbar-brand span {
    font-size: .9375rem;
    font-weight: 650;
}

.sidebar .menu-label,
.sidebar .menu-item-inner {
    font-size: .875rem;
    font-weight: 500;
}

.sidebar .submenu-item {
    font-size: .84rem;
}

/* ---------- Fields: label above, filled control ---------- */
.mud-input-control.mud-input-outlined-with-label {
    margin-top: .25rem;
}

/* The label sits in the flow above the control, not absolutely positioned: with enlarged text or a narrow
   screen it wraps onto more lines instead of being cut off with an ellipsis. */
.mud-input-control.mud-input-outlined-with-label > .mud-input-control-input-container {
    display: flex;
    flex-direction: column;
}

.mud-input-control.mud-input-outlined-with-label > .mud-input-control-input-container > .mud-input-label-outlined {
    position: static;
    order: -1;
    max-width: 100%;
    margin: 0 0 .375rem;
    padding: 0;
    background: transparent;
    transform: none !important;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: .8125rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ui-text2);
    pointer-events: none;
}

.mud-input.mud-input-outlined {
    border-radius: .75rem;
    background: var(--ui-card2);
}

.mud-input.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--ui-field-border);
    border-radius: .75rem;
}

.mud-input.mud-input-outlined .mud-input-outlined-border legend {
    display: none;
}

.mud-input.mud-input-outlined:hover:not(.mud-disabled):not(.mud-focused) .mud-input-outlined-border {
    border-color: var(--ui-field-border-hover);
}

.mud-input.mud-input-outlined.mud-focused .mud-input-outlined-border {
    border-color: var(--md-sys-color-primary);
}

/* ---------- Nested rows: outlined papers become tonal rows ---------- */
.mud-paper.mud-paper-outlined {
    border: 0;
    border-radius: .75rem;
    background: var(--ui-card2);
}

/* ---------- Filters and row actions ---------- */
.results-filters,
.results-filters .mud-expand-panel {
    border: 0;
    border-radius: .75rem;
    background: var(--ui-card2);
    box-shadow: none;
}

.results-filters .mud-expand-panel-header {
    font-weight: 650;
}

.table-actions-cell .mud-icon-button {
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;
    color: var(--ui-text2);
}

.table-actions-cell .mud-icon-button:hover {
    background: var(--ui-card2);
    color: var(--md-sys-color-on-surface);
}

/* ---------- Menus and popovers ---------- */
.mud-popover.mud-popover-open {
    border-radius: var(--ui-radius);
    box-shadow: 0 18px 48px rgb(0 0 0 / .35), 0 0 0 1px var(--ui-line);
}

:root[data-bs-theme="light"] .mud-popover.mud-popover-open {
    box-shadow: 0 12px 32px rgb(15 23 42 / .18), 0 0 0 1px var(--ui-line);
}

.mud-popover .mud-list {
    padding: .5rem;
}

.mud-popover .mud-menu-item,
.mud-popover .mud-list-item {
    min-height: 2.75rem;
    border-radius: .625rem;
}

.topbar-picker-menu .picker-option[aria-current="true"] {
    font-weight: 600;
}

.topbar-picker-menu .mud-menu-item:has(.picker-option[aria-current="true"]) {
    background: var(--ui-primary-soft);
}

.picker-heading {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ui-text2);
}

/* ---------- Footer ---------- */
.blazor-footer .footer-section-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ui-text2);
}

.blazor-footer .footer-sections {
    gap: 1.75rem;
}

/* ---------- HC components: row actions ---------- */
.hc-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: .25rem;
}

.hc-row-actions .hc-row-action.mud-icon-button {
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;
    color: var(--ui-text2);
}

.hc-row-actions .hc-row-action.mud-icon-button:hover {
    background: var(--ui-card2);
    color: var(--md-sys-color-on-surface);
}

.hc-row-actions .hc-row-action--primary.mud-button-root {
    min-height: 2rem;
    padding: .25rem .75rem;
    border-radius: .5rem;
    background: var(--ui-primary-soft);
    color: var(--ui-primary-text);
    font-size: .8125rem;
    font-weight: 650;
    white-space: nowrap;
}

/* ==================================================================
   BLOCK 3: measured alignment with the approved mockup (1920px canvas)
   ================================================================== */

/* Topbar 56px and collapsed footer 45px, as in the mockup. */
.blazor-shell {
    --topbar-height: 3.5rem;
}

/* Preserve the compact shell's height limit when application text is enlarged. */
@media (max-width: 599.98px) {
    .blazor-shell {
        --topbar-height: min(3.5rem, 56px);
    }
}


/* Administration header: the same coloured header as the user area, smaller - a thin accent band, a soft gradient and a compact icon tile. */
.blazor-shell .page-surface.page-surface--compact .page-heading {
    position: relative;
    overflow: hidden;
    padding: 1.125rem 1.5rem;
    border: 0;
    border-radius: var(--ui-radius);
    background:
        radial-gradient(circle at 96% 15%, color-mix(in srgb, var(--mud-palette-primary) 12%, transparent), transparent 38%),
        var(--ui-card);
    box-shadow: var(--ui-shadow);
}

.blazor-shell .page-surface.page-surface--compact .page-heading::before {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    left: 1.5rem;
    right: 1.5rem;
    height: 3px;
    border-radius: 0 0 99px 99px;
    background: var(--mud-palette-primary);
}

.blazor-shell .page-surface.page-surface--compact .page-heading .page-heading__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 2.75rem;
    border: 0;
    border-radius: .85rem;
    background: var(--ui-primary-soft);
    color: var(--ui-primary-text);
}

/* ---------- Fields and buttons: mockup sizes (44px control, 12px radius; 38px button, 10px radius) ---------- */
.blazor-shell .mud-input.mud-input-outlined {
    border-radius: .75rem;
}

.blazor-shell .mud-input.mud-input-outlined .mud-input-slot {
    padding: .75rem .875rem;
    font-size: .84375rem;
    line-height: 1.5;
}

.blazor-shell .mud-input-control.mud-input-outlined-with-label .mud-input-label {
    font-size: .78125rem;
}

@media (min-width: 961px) {
    .blazor-shell .mud-button-root.mud-button {
        min-height: 38px;
        padding: .5625rem 1rem;
        border-radius: 10px;
        font-size: .84375rem;
        font-weight: 650;
        line-height: 1.5;
    }

    .blazor-shell .page-surface--compact .record-actions {
        padding: 1rem 1.75rem;
        gap: .625rem !important;
    }
}

/* ---------- Sidebar details from the mockup ---------- */
.blazor-shell .sidebar .menu-item-title .menu-label-title {
    font-size: .71875rem;
    letter-spacing: .08em;
}

/* Dense fields: the label is in the flow now, so only a small gap above the group is needed (MudBlazor's dense margin is 8px). */
.blazor-shell .mud-input-control.mud-input-outlined-with-label {
    margin-top: .25rem;
}

/* ---------- Dialogs: mockup (18px/700 title, 38px close, tonal panels without borders) ---------- */
.mud-dialog .mud-dialog-title .mud-typography-h6 {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

@media (min-width: 961px) {
    .mud-dialog .mud-dialog-title .mud-icon-button {
        width: 38px;
        height: 38px;
        padding: 7px;
        border-radius: 10px;
    }
}

.mud-dialog .picker-panel {
    border: 0;
    background: var(--ui-card2);
}

.mud-dialog .picker-panel-heading {
    border-bottom: 0;
    background: transparent;
}

.mud-dialog .picker-panel-icon {
    background: var(--ui-primary-soft);
    color: var(--ui-primary-text);
}

.mud-dialog .area-tree-row.area-tree-row-selected,
.mud-dialog [class*="-tree-row-selected"] {
    background: var(--ui-primary-soft);
    color: var(--md-sys-color-on-surface);
}

/* ---------- File pickers: tonal drop zone and a ghost button, the native file input stays hidden but focusable ---------- */
.blazor-shell .profile-page .profile-upload {
    padding: 1.375rem;
    border-radius: .875rem;
    background: var(--ui-card2);
    box-shadow: inset 0 0 0 1.5px var(--ui-line);
}

.blazor-shell .profile-file-button,
.blazor-shell .curriculum-upload {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .5625rem 1rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--ui-line);
    color: var(--mud-palette-text-primary);
    font-size: .84375rem;
    font-weight: 650;
    cursor: pointer;
}

.blazor-shell .profile-file-button:hover,
.blazor-shell .curriculum-upload:hover {
    background: var(--ui-hover);
}

.blazor-shell .profile-file-button input[type="file"],
.blazor-shell .curriculum-upload input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-size: 0;
    cursor: pointer;
}

.blazor-shell .profile-file-button:focus-within,
.blazor-shell .curriculum-upload:focus-within {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* ---------- Numbers in tables line up; amount columns are right-aligned on desktop ---------- */
.blazor-shell .mud-table .mud-table-cell {
    font-variant-numeric: tabular-nums;
}

@media (min-width: 961px) {
    .blazor-shell .mud-table .mud-table-cell.table-amount {
        text-align: right;
    }
}

/* ---------- Topbar pickers stay compact: icon plus caret, close together (the generic 38px button rule must not widen them) ---------- */
@media (min-width: 961px) {
    .blazor-shell .topbar .topbar-picker-button {
        min-height: 40px;
        padding: .5rem .375rem;
    }

    .blazor-shell .topbar .topbar-pickers,
    .blazor-shell .topbar .topbar-nav {
        gap: .25rem;
    }
}

/* Header actions (for example the tools search) use the full width on phones. */
@media (max-width: 599.98px) {
    .blazor-shell .page-surface--compact .page-heading__actions {
        width: 100%;
    }
}

/* Section headings in record forms are weight 700 (mockup h4). */
.blazor-shell .page-surface--compact .page-body .form-section-heading,
.blazor-shell .page-surface--compact .page-body .form-section-heading :is(h2, h3, .form-section-title) {
    font-weight: 700;
}

/* ---------- Gray theme: dark mode had no medium/high contrast palettes (the contrast audit measured 1.9:1 text). They start from the standard dark palette and raise text, outline and primary. ---------- */
:root[data-theme=gray][data-bs-theme=dark]:is([data-contrast=medium], [data-contrast=high]) {
  --md-sys-color-primary: #BDBDBD;
  --md-sys-color-surface-tint: #BDBDBD;
  --md-sys-color-on-primary: #1C1C1C;
  --md-sys-color-primary-container: #424242;
  --md-sys-color-on-primary-container: #E0E0E0;
  --md-sys-color-primary-fixed: #F5F5F5;
  --md-sys-color-on-primary-fixed: #000000;
  --md-sys-color-primary-fixed-dim: #E0E0E0;
  --md-sys-color-on-primary-fixed-variant: #424242;
  --md-sys-color-secondary: #9E9E9E;
  --md-sys-color-on-secondary: #1C1C1C;
  --md-sys-color-secondary-container: #616161;
  --md-sys-color-on-secondary-container: #EEEEEE;
  --md-sys-color-secondary-fixed: #F5F5F5;
  --md-sys-color-on-secondary-fixed: #000000;
  --md-sys-color-secondary-fixed-dim: #E0E0E0;
  --md-sys-color-on-secondary-fixed-variant: #424242;
  --md-sys-color-tertiary: #E0E0E0;
  --md-sys-color-on-tertiary: #1C1C1C;
  --md-sys-color-tertiary-container: #757575;
  --md-sys-color-on-tertiary-container: #F5F5F5;
  --md-sys-color-tertiary-fixed: #FAFAFA;
  --md-sys-color-on-tertiary-fixed: #000000;
  --md-sys-color-tertiary-fixed-dim: #E0E0E0;
  --md-sys-color-on-tertiary-fixed-variant: #424242;
  --md-sys-color-error: #E8909F;
  --md-sys-color-on-error: #000000;
  --md-sys-color-error-container: #8C1D2C;
  --md-sys-color-on-error-container: #FFDAD4;
  --md-sys-color-background: #121212;
  --md-sys-color-on-background: #E0E0E0;
  --md-sys-color-surface: #121212;
  --md-sys-color-on-surface: #E0E0E0;
  --md-sys-color-surface-variant: #424242;
  --md-sys-color-on-surface-variant: #CFCFCF;
  --md-sys-color-outline: #9E9E9E;
  --md-sys-color-outline-variant: #424242;
  --md-sys-color-shadow: #000000;
  --md-sys-color-scrim: #000000;
  --md-sys-color-inverse-surface: #E0E0E0;
  --md-sys-color-inverse-on-surface: #303030;
  --md-sys-color-inverse-primary: #616161;
  --md-sys-color-surface-dim: #121212;
  --md-sys-color-surface-bright: #2C2C2C;
  --md-sys-color-surface-container-lowest: #0F0F0F;
  --md-sys-color-surface-container-low: #1A1A1A;
  --md-sys-color-surface-container: #1E1E1E;
  --md-sys-color-surface-container-high: #2A2A2A;
  --md-sys-color-surface-container-highest: #353535;
  --mud-palette-black: #000000;
  --mud-palette-white: #ffffff;
  --mud-palette-primary: #BDBDBD;
  --mud-palette-primary-rgb: 189, 189, 189;
  --mud-palette-primary-text: #1C1C1C;
  --mud-palette-primary-darken: rgb(158.76, 158.76, 158.76);
  --mud-palette-primary-lighten: rgb(199.56, 199.56, 199.56);
  --mud-palette-primary-hover: rgba(189, 189, 189, 0.08);
  --mud-palette-secondary: #9E9E9E;
  --mud-palette-secondary-rgb: 158, 158, 158;
  --mud-palette-secondary-text: #1C1C1C;
  --mud-palette-secondary-darken: rgb(132.72, 132.72, 132.72);
  --mud-palette-secondary-lighten: rgb(173.52, 173.52, 173.52);
  --mud-palette-secondary-hover: rgba(158, 158, 158, 0.08);
  --mud-palette-tertiary: #E0E0E0;
  --mud-palette-tertiary-rgb: 224, 224, 224;
  --mud-palette-tertiary-text: #1C1C1C;
  --mud-palette-tertiary-darken: rgb(188.16, 188.16, 188.16);
  --mud-palette-tertiary-lighten: rgb(228.96, 228.96, 228.96);
  --mud-palette-tertiary-hover: rgba(224, 224, 224, 0.08);
  --mud-palette-error: #E8909F;
  --mud-palette-error-rgb: 232, 144, 159;
  --mud-palette-error-text: #000000;
  --mud-palette-error-darken: rgb(194.88, 120.96, 133.56);
  --mud-palette-error-lighten: rgb(237.6, 166.5, 177.9);
  --mud-palette-error-hover: rgba(232, 144, 159, 0.08);
  --mud-palette-dark: #E0E0E0;
  --mud-palette-dark-rgb: 224, 224, 224;
  --mud-palette-dark-text: #303030;
  --mud-palette-dark-darken: rgb(188.16, 188.16, 188.16);
  --mud-palette-dark-lighten: rgb(228.96, 228.96, 228.96);
  --mud-palette-dark-hover: rgba(224, 224, 224, 0.08);
  --mud-palette-info: #81d4fa;
  --mud-palette-info-rgb: 129, 212, 250;
  --mud-palette-info-text: #002f3c;
  --mud-palette-info-darken: rgb(108.36, 178.08, 210);
  --mud-palette-info-lighten: rgb(149.16, 218.88, 250.8);
  --mud-palette-info-hover: rgba(129, 212, 250, 0.08);
  --mud-palette-success: #a5d6a7;
  --mud-palette-success-rgb: 165, 214, 167;
  --mud-palette-success-text: #0f2911;
  --mud-palette-success-darken: rgb(138.6, 179.76, 140.28);
  --mud-palette-success-lighten: rgb(179.4, 220.56, 181.08);
  --mud-palette-success-hover: rgba(165, 214, 167, 0.08);
  --mud-palette-warning: #ffcc80;
  --mud-palette-warning-rgb: 255, 204, 128;
  --mud-palette-warning-text: #3e1600;
  --mud-palette-warning-darken: rgb(214.2, 171.36, 107.52);
  --mud-palette-warning-lighten: rgb(255, 212.16, 148.32);
  --mud-palette-warning-hover: rgba(255, 204, 128, 0.08);
  --mud-palette-text-primary: #E0E0E0;
  --mud-palette-text-primary-rgb: 224, 224, 224;
  --mud-palette-text-secondary: #CFCFCF;
  --mud-palette-text-secondary-rgb: 207, 207, 207;
  --mud-palette-text-disabled: rgba(224, 224, 224, 0.38);
  --mud-palette-text-disabled-rgb: 224, 224, 224;
  --mud-palette-action-default: #CFCFCF;
  --mud-palette-action-default-hover: rgba(224, 224, 224, 0.08);
  --mud-palette-action-disabled: rgba(224, 224, 224, 0.38);
  --mud-palette-action-disabled-background: rgba(224, 224, 224, 0.12);
  --mud-palette-surface: #121212;
  --mud-palette-surface-rgb: 18, 18, 18;
  --mud-palette-background: #121212;
  --mud-palette-background-gray: #1A1A1A;
  --mud-palette-drawer-background: #1A1A1A;
  --mud-palette-drawer-text: #E0E0E0;
  --mud-palette-drawer-icon: #CFCFCF;
  --mud-palette-appbar-background: #1E1E1E;
  --mud-palette-appbar-text: #E0E0E0;
  --mud-palette-lines-default: #424242;
  --mud-palette-lines-inputs: #424242;
  --mud-palette-table-lines: #424242;
  --mud-palette-table-striped: #1A1A1A;
  --mud-palette-table-hover: #1E1E1E;
  --mud-palette-divider: #424242;
  --mud-palette-divider-rgb: 66, 66, 66;
  --mud-palette-divider-light: rgba(66, 66, 66, 0.55);
  --mud-palette-skeleton: #353535;
  --mud-palette-gray-default: #9E9E9E;
  --mud-palette-gray-light: #2A2A2A;
  --mud-palette-gray-lighter: #1A1A1A;
  --mud-palette-gray-dark: #CFCFCF;
  --mud-palette-gray-darker: #E0E0E0;
  --mud-palette-overlay-dark: rgba(0, 0, 0, 0.65);
  --mud-palette-overlay-light: rgba(255, 255, 255, 0.5);
  --mud-palette-border-opacity: 1;
  --mud-native-html-color-scheme: dark;
  color-scheme: dark;
  --mud-platform-background: #121212;
  --mud-platform-on-background: #E0E0E0;
  --mud-platform-surface-variant: #424242;
  --mud-platform-surface-lowest: #0F0F0F;
  --mud-platform-surface-high: #2A2A2A;
  --mud-platform-shadow: #000000;
}

:root[data-theme=gray][data-bs-theme=dark][data-contrast=medium] {
    --md-sys-color-primary: #D6D6D6;
    --md-sys-color-surface-tint: #D6D6D6;
    --md-sys-color-secondary: #BDBDBD;
    --md-sys-color-primary-container: #5A5A5A;
    --md-sys-color-on-surface: #F2F2F2;
    --md-sys-color-on-background: #F2F2F2;
    --md-sys-color-on-surface-variant: #E6E6E6;
    --md-sys-color-outline: #BDBDBD;
    --md-sys-color-outline-variant: #6B6B6B;
    --mud-palette-primary: #D6D6D6;
    --mud-palette-text-primary: #F2F2F2;
    --mud-palette-text-secondary: #E6E6E6;
    --mud-palette-action-default: #E6E6E6;
    --mud-palette-lines-default: #6B6B6B;
    --mud-palette-lines-inputs: #BDBDBD;
    --mud-palette-table-lines: #6B6B6B;
    --mud-palette-divider: #6B6B6B;
}

:root[data-theme=gray][data-bs-theme=dark][data-contrast=high] {
    --md-sys-color-primary: #EEEEEE;
    --md-sys-color-surface-tint: #EEEEEE;
    --md-sys-color-on-primary: #000000;
    --md-sys-color-secondary: #D6D6D6;
    --md-sys-color-primary-container: #6B6B6B;
    --md-sys-color-on-surface: #FFFFFF;
    --md-sys-color-on-background: #FFFFFF;
    --md-sys-color-on-surface-variant: #F2F2F2;
    --md-sys-color-outline: #E0E0E0;
    --md-sys-color-outline-variant: #9E9E9E;
    --mud-palette-primary: #EEEEEE;
    --mud-palette-primary-text: #000000;
    --mud-palette-text-primary: #FFFFFF;
    --mud-palette-text-secondary: #F2F2F2;
    --mud-palette-action-default: #F2F2F2;
    --mud-palette-lines-default: #9E9E9E;
    --mud-palette-lines-inputs: #E0E0E0;
    --mud-palette-table-lines: #9E9E9E;
    --mud-palette-divider: #9E9E9E;
}

/* ---------- HCFilterBar: always-visible filter row with labelled fields and the Filter button (mockup toolbar) ---------- */
.hc-filter-bar {
    padding: 0 0 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--ui-line);
}

.hc-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: 38px;
    padding: .5rem .75rem;
    border: 0;
    border-radius: 10px;
    background: var(--ui-card2);
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: .84375rem;
    font-weight: 650;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--ui-line);
}

.hc-filter-toggle:hover {
    background: var(--ui-hover);
}

.hc-filter-toggle:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.hc-filter-toggle__count {
    display: inline-grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding-inline: .3rem;
    border-radius: 99px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: .75rem;
    font-weight: 700;
}

.hc-filter-bar__body {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    margin-top: .5rem;
}

.hc-filter-bar__body[hidden] {
    display: none;
}

.hc-filter-bar__fields {
    display: contents;
}

.hc-filter-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    padding-bottom: .125rem;
}

.hc-filter-bar .hc-filter-field {
    flex: 1 1 11rem;
    min-width: 0;
    max-width: 18rem;
}

.hc-filter-bar .hc-filter-check {
    align-self: center;
}

@media (max-width: 599.98px) {
    .hc-filter-bar .hc-filter-field {
        flex-basis: 100%;
        max-width: none;
    }
}

/* ---------- Medium and high contrast: control boundaries reach 3:1 (the standard look keeps the subtle mockup borders) ---------- */
:root[data-contrast="medium"] {
    /* About 4.3 to 5.6:1 on the card, between the standard border (about 2:1) and the high contrast one (9 to 10:1). */
    --ui-control-border: color-mix(in srgb, var(--md-sys-color-on-surface) 55%, var(--md-sys-color-surface));
    /* Coloured text on a tint of its own colour: 70% of the colour reaches at least 5.2:1 in every theme. */
    --ui-primary-tint-text: color-mix(in srgb, var(--mud-palette-primary) 70%, var(--md-sys-color-on-surface));
    --ui-secondary-text: color-mix(in srgb, var(--mud-palette-secondary) 70%, var(--md-sys-color-on-surface));
    --ui-info-text: color-mix(in srgb, var(--mud-palette-info) 70%, var(--md-sys-color-on-surface));
    --ui-success-text: color-mix(in srgb, var(--mud-palette-success) 70%, var(--md-sys-color-on-surface));
    --ui-warning-text: color-mix(in srgb, var(--mud-palette-warning) 70%, var(--md-sys-color-on-surface));
    --ui-error-text: color-mix(in srgb, var(--mud-palette-error) 70%, var(--md-sys-color-on-surface));
    --ui-survey-text: color-mix(in srgb, var(--ui-survey) 70%, var(--md-sys-color-on-surface));
}

:root[data-contrast="high"] {
    --ui-control-border: color-mix(in srgb, var(--md-sys-color-on-surface) 75%, var(--md-sys-color-surface));
    /* 55% of the colour reaches at least 7:1 in every theme. */
    --ui-primary-tint-text: color-mix(in srgb, var(--mud-palette-primary) 55%, var(--md-sys-color-on-surface));
    --ui-secondary-text: color-mix(in srgb, var(--mud-palette-secondary) 55%, var(--md-sys-color-on-surface));
    --ui-info-text: color-mix(in srgb, var(--mud-palette-info) 55%, var(--md-sys-color-on-surface));
    --ui-success-text: color-mix(in srgb, var(--mud-palette-success) 55%, var(--md-sys-color-on-surface));
    --ui-warning-text: color-mix(in srgb, var(--mud-palette-warning) 55%, var(--md-sys-color-on-surface));
    --ui-error-text: color-mix(in srgb, var(--mud-palette-error) 55%, var(--md-sys-color-on-surface));
    --ui-survey-text: color-mix(in srgb, var(--ui-survey) 55%, var(--md-sys-color-on-surface));
}

/* Dialogs are rendered outside the shell, so they need their own selectors for the same borders. */
:root[data-contrast="medium"] .blazor-shell .mud-input.mud-input-outlined:not(:focus-within):not(.mud-input-error) .mud-input-outlined-border,
:root[data-contrast="high"] .blazor-shell .mud-input.mud-input-outlined:not(:focus-within):not(.mud-input-error) .mud-input-outlined-border,
:root[data-contrast="medium"] .mud-dialog .mud-input.mud-input-outlined:not(:focus-within):not(.mud-input-error) .mud-input-outlined-border,
:root[data-contrast="high"] .mud-dialog .mud-input.mud-input-outlined:not(:focus-within):not(.mud-input-error) .mud-input-outlined-border {
    border-color: var(--ui-control-border);
}

:root[data-contrast="medium"] .blazor-shell .mud-button-outlined:is(.mud-button-outlined-default, .mud-button-outlined-primary),
:root[data-contrast="high"] .blazor-shell .mud-button-outlined:is(.mud-button-outlined-default, .mud-button-outlined-primary),
:root[data-contrast="medium"] .mud-dialog .mud-button-outlined:is(.mud-button-outlined-default, .mud-button-outlined-primary),
:root[data-contrast="high"] .mud-dialog .mud-button-outlined:is(.mud-button-outlined-default, .mud-button-outlined-primary) {
    border-color: var(--ui-control-border);
}

/* The day numbers of the neighbouring months are dimmed to 60% in the standard look; that reached only 3.5:1 in medium contrast (light themes),
   so they are dimmed less (about 7:1) in the two accessibility modes. */
:root[data-contrast="medium"] .calendar-month__day.outside-month .calendar-month__day-number,
:root[data-contrast="high"] .calendar-month__day.outside-month .calendar-month__day-number {
    opacity: .85;
}

/* ---------- Profile personal data: breathing room between fields and one look for Mud and native controls ---------- */
.blazor-shell .profile-page .profile-card .mud-grid {
    width: calc(100% + 1rem);
    margin-top: -.5rem;
    margin-left: -1rem;
}

.blazor-shell .profile-page .profile-card .mud-grid > .mud-grid-item {
    padding-top: .5rem;
    padding-left: 1rem;
}

.blazor-shell .profile-page .profile-native-field {
    position: relative;
    display: block;
    margin-top: .25rem;
    margin-bottom: .25rem;
}

/* In the flow above the field, so enlarged text wraps instead of being cut off. */
.blazor-shell .profile-page .profile-native-field > label {
    display: block;
    margin: 0 0 .375rem;
    color: var(--ui-text2);
    font-size: .78125rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.blazor-shell .profile-page .profile-native-select,
.blazor-shell .profile-page .profile-native-date {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: .75rem .875rem;
    border: 1px solid var(--ui-line);
    border-radius: .75rem;
    background: var(--ui-card2);
    font-size: .84375rem;
}

.blazor-shell .profile-page .profile-native-select:focus,
.blazor-shell .profile-page .profile-native-date:focus {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 1px var(--mud-palette-primary);
}

/* ---------- Button hierarchy: a solid primary for the action, a quiet outlined secondary for back and cancel ---------- */
.blazor-shell .mud-button-filled.mud-button-filled-primary,
.blazor-shell .record-actions .mud-button-outlined.mud-button-outlined-primary,
.blazor-shell .page-heading__actions .mud-button-outlined.mud-button-outlined-primary,
.blazor-shell .dashboard-side-card .mud-button-outlined.mud-button-outlined-primary {
    border: 0;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    box-shadow: 0 1px 2px rgb(0 0 0 / .28), 0 4px 12px color-mix(in srgb, var(--mud-palette-primary) 30%, transparent);
}

.blazor-shell .mud-button-filled.mud-button-filled-primary:hover,
.blazor-shell .record-actions .mud-button-outlined.mud-button-outlined-primary:hover,
.blazor-shell .page-heading__actions .mud-button-outlined.mud-button-outlined-primary:hover,
.blazor-shell .dashboard-side-card .mud-button-outlined.mud-button-outlined-primary:hover {
    background: var(--mud-palette-primary-darken);
    box-shadow: 0 2px 4px rgb(0 0 0 / .3), 0 6px 16px color-mix(in srgb, var(--mud-palette-primary) 36%, transparent);
}

.blazor-shell .record-actions .mud-button-outlined.mud-button-outlined-default,
.blazor-shell .record-actions .mud-button-text.mud-button-text-default {
    background: transparent;
    color: var(--ui-text2);
    box-shadow: none;
}

.blazor-shell .record-actions .mud-button-outlined.mud-button-outlined-default:hover {
    background: var(--ui-hover);
    color: var(--mud-palette-text-primary);
}

.blazor-shell .mud-button.mud-button-disabled {
    box-shadow: none;
}

/* ---------- Depth: layered elevation so every surface reads as raised from the one below it ---------- */
:root[data-bs-theme="dark"] {
    --ui-shadow:
        inset 0 1px 0 rgb(255 255 255 / .06),
        0 1px 2px rgb(0 0 0 / .5),
        0 10px 28px rgb(0 0 0 / .32);
}

:root[data-bs-theme="light"] {
    --ui-shadow:
        0 1px 2px rgb(15 23 42 / .10),
        0 8px 24px rgb(15 23 42 / .08);
}

/* The shell frame floats above the canvas too. */
.blazor-shell .topbar,
.blazor-shell .blazor-footer,
.blazor-shell .sidebar {
    box-shadow: var(--ui-shadow);
}

/* Section headings carry a small accent bar, so the reader always sees which block of the page they are in. */
.blazor-shell .page-surface--compact .page-body .form-section-heading {
    position: relative;
    padding-left: .75rem;
}

.blazor-shell .page-surface--compact .page-body .form-section-heading::before {
    content: "";
    position: absolute;
    inset-block: .2rem;
    left: 0;
    width: 3px;
    border-radius: 99px;
    background: var(--mud-palette-primary);
}

/* Table headers and inner rows are a step above the card so the structure is readable at a glance. */
.blazor-shell .mud-table .mud-table-root .mud-table-head .mud-table-cell {
    box-shadow: inset 0 -1px 0 var(--ui-line);
}

/* MudSelect wraps its control in an outer .mud-select div that ignores the field class, so size that wrapper instead. */
.hc-filter-bar__fields > .mud-select {
    flex: 1 1 11rem;
    min-width: 0;
    max-width: 18rem;
}

.hc-filter-bar__fields > .mud-select .hc-filter-field {
    max-width: none;
    width: 100%;
}

/* ---------- Filter bar open/close: a short height transition instead of an instant jump ---------- */
.hc-filter-bar__collapse {
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
}

.hc-filter-bar__collapse.is-open {
    grid-template-rows: 1fr;
    visibility: visible;
    transition: grid-template-rows .28s cubic-bezier(.2, .8, .2, 1), visibility 0s;
}

.hc-filter-bar__collapse-inner {
    min-height: 0;
    overflow: hidden;
    /* Room for focus rings, which the clipping box would otherwise cut. */
    padding: .25rem;
    margin: -.25rem;
}

@media (prefers-reduced-motion: reduce) {
    .hc-filter-bar__collapse,
    .hc-filter-bar__collapse.is-open {
        transition: none;
    }
}

/* ---------- Table action column: icons sit flush right on desktop ---------- */
@media (min-width: 961px) {
    .blazor-shell .mud-table .mud-table-cell.table-actions-cell {
        width: 1%;
        text-align: right;
        white-space: nowrap;
    }

    .blazor-shell .hc-row-actions {
        justify-content: flex-end;
    }
}

/* ---------- Sidebar labels stay on one line: a wider sidebar and tighter inner padding make long names fit; an ellipsis plus the title tooltip is only the last resort ---------- */
.sidebar .submenu-item {
    display: block;
    min-height: 2.3rem;
    padding: .5rem .5rem .5rem 2.4rem;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* With enlarged text the same sidebar width holds fewer characters (the query measures it in em), so long labels wrap
   instead of being cut. At the normal size the sidebar is wider than 12em and nothing changes. */
.sidebar .sidebar-content {
    container-type: inline-size;
}

@container (max-width: 12em) {
    .sidebar .submenu-item {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        overflow-wrap: anywhere;
    }
}

.sidebar .submenu-item::before {
    left: 1.4rem;
    top: 50%;
    margin-top: -.15rem;
}

/* Text kept for screen readers only. */
.hc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* HCPrice: a price with the price it replaces struck through (the highest price tier of an event, or the price before a
   coupon). The struck amount stays readable (secondary text color, which every theme and contrast level keeps at 4.5:1
   or more) and the pair wraps instead of overflowing, so it survives text enlargement and narrow screens. Sizes are
   relative and nothing has a fixed width or height. */
.hc-price {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: .5em;
    max-width: 100%;
}

/* Currency stays atomic even inside compact cells that allow arbitrary text wrapping. */
.hc-currency,
.hc-price__previous,
.hc-price__current {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}

.hc-price__previous {
    color: var(--mud-palette-text-secondary);
    font-size: .85em;
    font-weight: 400;
    text-decoration-line: line-through;
    text-decoration-thickness: .09em;
}

/* ---------- Dashboard layout: figures, then what needs attention now in one row of cards, then the learning sections ---------- */
.dashboard-page .dashboard-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
}

.dashboard-page .dashboard-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
    align-items: stretch;
    gap: 1.5rem;
}

/* The presence button sits at the bottom of its card, so cards of different heights still look aligned. */
.dashboard-page .dashboard-actions > .dashboard-side-card {
    display: flex;
    flex-direction: column;
}

.dashboard-page .dashboard-actions > .dashboard-side-card > .mud-button-root {
    margin: auto 1rem 1rem;
    width: calc(100% - 2rem);
}

.dashboard-page .dashboard-actions > * {
    grid-column: auto;
}

.dashboard-page .dashboard-main {
    display: grid;
    gap: 1.5rem;
    align-content: start;
    grid-auto-rows: max-content;
}

/* The grid gap already spaces the sections; the old 2.5rem margin made the second one drift away. */
.dashboard-page .dashboard-main > .dashboard-section + .dashboard-section {
    margin-top: 0;
}

/* Recommended events: one card fills the row, two sit side by side at 50% each, more wrap evenly. */
.dashboard-page .events-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
    gap: 1rem;
}

/* ---------- Profile header: the same accent band and soft gradient as the other user pages ---------- */
.profile-page .profile-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 92% 15%, color-mix(in srgb, var(--mud-palette-primary) 13%, transparent), transparent 32%),
        var(--mud-palette-surface);
}

.profile-page .profile-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 2rem;
    right: 2rem;
    height: .1875rem;
    border-radius: 0 0 1rem 1rem;
    background: var(--mud-palette-primary);
}

/* Orange, medium contrast: the generated palette stayed under 4.5:1 for primary and secondary text on the page and for
   the text on the primary and secondary buttons and badges. Values keep the orange hue and reach at least 5:1. */
:root[data-theme="orange"][data-bs-theme="light"][data-contrast="medium"] {
    --md-sys-color-primary: #B23800;
    --mud-palette-primary: #B23800;
    --md-sys-color-secondary: #9A3412;
    --mud-palette-secondary: #9A3412;
}

/* Links and active labels sit on the tinted page canvas, which is darker than white: the generated primaries for orange
   (high) and red (medium) reached only 4.1:1 there. */
:root[data-theme="orange"][data-bs-theme="light"][data-contrast="high"] {
    --md-sys-color-primary: #8F2A00;
    --mud-palette-primary: #8F2A00;
}

:root[data-theme="red"][data-bs-theme="light"][data-contrast="medium"] {
    --md-sys-color-primary: #B71C1C;
    --mud-palette-primary: #B71C1C;
}

:root[data-theme="orange"][data-bs-theme="dark"][data-contrast="medium"] {
    --md-sys-color-on-primary: #4A1500;
    --mud-palette-primary-text: #4A1500;
    --md-sys-color-on-secondary: #4A1500;
    --mud-palette-secondary-text: #4A1500;
}

/* Text on the primary container (help manual covers, selected rows, picker panels): in these theme and contrast
   combinations the generated pair stayed under 4.5:1 (down to 1.7:1 for yellow in dark mode). The text takes black or
   white, whichever reads better on that container (at least 5:1). */
:root[data-theme="green"][data-bs-theme="light"][data-contrast="medium"],
:root[data-theme="orange"][data-bs-theme="light"]:is([data-contrast="medium"], [data-contrast="high"], :not([data-contrast])),
:root[data-theme="red"][data-bs-theme="light"][data-contrast="medium"],
:root[data-theme="orange"][data-bs-theme="dark"]:not([data-contrast]),
:root[data-theme="yellow"][data-bs-theme="dark"]:not([data-contrast]) {
    --md-sys-color-on-primary-container: #000000;
}

:root[data-theme="green"][data-bs-theme="dark"]:not([data-contrast]),
:root[data-theme="purple"][data-bs-theme="dark"][data-contrast="medium"],
:root[data-theme="red"][data-bs-theme="dark"]:not([data-contrast]),
:root[data-theme="gray"][data-bs-theme="dark"][data-contrast="high"] {
    --md-sys-color-on-primary-container: #ffffff;
}

/* Alerts: MudBlazor darkens the text colour of the plain alert variant, which is right on a light page but lowers the
   contrast on a dark one (gray theme, medium and high contrast: 3.3:1). On dark themes the full palette colour is used. */
:root[data-bs-theme="dark"] .mud-alert-text-error,
:root[data-bs-theme="dark"] .mud-alert-text-error .mud-alert-icon {
    color: var(--mud-palette-error);
}

:root[data-bs-theme="dark"] .mud-alert-text-warning,
:root[data-bs-theme="dark"] .mud-alert-text-warning .mud-alert-icon {
    color: var(--mud-palette-warning);
}

:root[data-bs-theme="dark"] .mud-alert-text-info,
:root[data-bs-theme="dark"] .mud-alert-text-info .mud-alert-icon {
    color: var(--mud-palette-info);
}

:root[data-bs-theme="dark"] .mud-alert-text-success,
:root[data-bs-theme="dark"] .mud-alert-text-success .mud-alert-icon {
    color: var(--mud-palette-success);
}

/* Medium and high contrast on dark themes: a little lighter again, so the text clears 4.5:1 on the tinted alert surface. */
:root[data-bs-theme="dark"]:is([data-contrast="medium"], [data-contrast="high"]) .mud-alert-text-error {
    color: color-mix(in srgb, var(--mud-palette-error) 75%, white);
}

:root[data-bs-theme="dark"]:is([data-contrast="medium"], [data-contrast="high"]) .mud-alert-text-warning {
    color: color-mix(in srgb, var(--mud-palette-warning) 75%, white);
}

:root[data-bs-theme="dark"]:is([data-contrast="medium"], [data-contrast="high"]) .mud-alert-text-info {
    color: color-mix(in srgb, var(--mud-palette-info) 75%, white);
}

:root[data-bs-theme="dark"]:is([data-contrast="medium"], [data-contrast="high"]) .mud-alert-text-success {
    color: color-mix(in srgb, var(--mud-palette-success) 75%, white);
}

/* Banner shown when the background session check cannot confirm the session; it keeps the page open. */
.session-banner {
    position: fixed;
    bottom: .75rem;
    left: 50%;
    z-index: 2000;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    max-width: min(90vw, 40rem);
    padding: .75rem 1rem;
    transform: translateX(-50%);
    border: 1px solid color-mix(in srgb, var(--mud-palette-warning) 55%, transparent);
    border-radius: .75rem;
    background: color-mix(in srgb, var(--mud-palette-warning) 18%, var(--md-sys-color-surface-container-highest, var(--mud-palette-surface)));
    color: var(--md-sys-color-on-surface);
    box-shadow: 0 6px 24px color-mix(in srgb, var(--md-sys-color-on-surface) 18%, transparent);
    font-size: .875rem;
}

.session-banner__button {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 2rem;
    padding: .25rem .75rem;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: .5rem;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.session-banner__button:hover:not(:disabled) {
    background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
}

.session-banner__button:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.session-banner__button:disabled {
    opacity: .6;
    cursor: default;
}

.session-banner__spinner {
    width: .9rem;
    height: .9rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: session-banner-spin .8s linear infinite;
}

@keyframes session-banner-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .session-banner__spinner {
        animation-duration: 2.4s;
    }
}

/* Supporting text (captions and notes written with the secondary colour) uses the secondary text colour: the brand
   secondary colour falls below 4.5:1 on some themes and contrast levels. MudBlazor's colour utility is !important. */
.mud-typography.mud-secondary-text {
    color: var(--mud-palette-text-secondary) !important;
}

/* The two stacked spin buttons of a numeric field are 20px high, under the 24px target minimum. They sit side by side
   at 24px, which fits the field height. */
.mud-input-control.mud-input-number-control .mud-input-numeric-spin {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
}

.mud-input-control.mud-input-number-control .mud-input-numeric-spin button {
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0;
}

/* The count badge of a tab sits on its top-right corner and overflows the tab by 4px, where the tab clips it (its
   ripple needs overflow hidden). The margin makes the tab wide enough to hold the whole badge. */
.mud-tab .mud-tab-badge {
    margin-inline-end: .5rem;
}

/* A link on a line of its own is a stand-alone target and keeps the 24px minimum. min-height does not apply to links
   inside a sentence, which stay inline. */
a.mud-link,
dd > a:only-child,
.status-card__body > a {
    min-height: 1.5rem;
}

dd > a:only-child,
.status-card__body > a {
    display: inline-block;
}

/* The remove button of a closable chip is 18px; it keeps the 24px target minimum inside the 32px chip. */
.mud-chip .mud-chip-content > .mud-icon-button {
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0;
}

/* ── HCHelpButton: the contextual help dot and its reading and editing windows ─────────────────────────────── */

.hc-help-button {
    margin-inline-start: .25rem;
    vertical-align: middle;
}

/* HCSearchSelect wraps its autocomplete in an element that only carries the outside-press script: it draws no box. */
.hc-search-select {
    display: contents;
}

/* A form field with its help dot (HCHelpButton): the dot sits inside the field's right edge, so the field keeps the width
   of its neighbours, and the text never runs under it. */
.hc-field-help {
    position: relative;
}

/* The dot is wrapped by its tooltip, so the wrapper is what is placed. */
.hc-field-help > .mud-tooltip-root {
    position: absolute;
    inset-inline-end: .5rem;
    /* The label sits above the input box (1.4375rem), and the dot is centred on the 44px box (9px = (44 - 26) / 2). */
    top: calc(1.4375rem + 9px);
    z-index: 1;
}

.hc-field-help .hc-help-button {
    margin: 0;
}

.hc-field-help .mud-input-slot {
    padding-inline-end: 2.75rem;
}

.hc-help-dialog__title {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    min-width: 0;
}

.hc-help-dialog__heading {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hc-help-dialog__subtitle {
    font-style: italic;
    color: var(--mud-palette-text-secondary);
}

.hc-help-dialog__tag {
    display: block;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    color: var(--mud-palette-text-secondary);
    overflow-wrap: anywhere;
}

/* The authored HTML keeps to the window and to the platform's type, whatever the author pasted. */
.hc-help-dialog__body {
    line-height: 1.7;
    overflow-wrap: break-word;
    min-width: 0;
}

.hc-help-dialog__body :is(p, ul, ol, dl, blockquote, pre, table, figure) {
    margin: 0 0 1em;
}

.hc-help-dialog__body :is(h1, h2, h3, h4, h5, h6) {
    margin: 1.25em 0 .5em;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
}

.hc-help-dialog__body :is(ul, ol) {
    padding-inline-start: 1.5rem;
}

.hc-help-dialog__body :is(img, video, iframe, canvas) {
    max-width: 100%;
}

.hc-help-dialog__body :is(img, video) {
    height: auto;
    border-radius: .5rem;
}

.hc-help-dialog__body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.hc-help-dialog__body :is(td, th) {
    padding: .4rem .6rem;
    border: .0625rem solid var(--md-sys-color-outline-variant);
}

.hc-help-dialog__body blockquote {
    padding: .25rem 1rem;
    border-inline-start: .25rem solid var(--md-sys-color-outline-variant);
    color: var(--mud-palette-text-secondary);
}

.hc-help-dialog__body :is(pre, code) {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9em;
}

.hc-help-dialog__body a {
    color: var(--mud-palette-primary);
    text-decoration: underline;
    text-underline-offset: .15em;
}

.hc-help-editor-dialog {
    overflow-y: auto;
}

/* Keep title, editor and actions reachable together when enlarged text fills the viewport. */
.hc-help-editor-dialog .mud-dialog-content {
    flex: 0 0 auto;
    overflow: visible;
}

.hc-help-editor-dialog .mud-dialog-actions {
    flex-wrap: wrap;
    gap: .5rem;
}

.hc-help-editor-dialog .mud-dialog-actions > .mud-button-root {
    flex-shrink: 0;
    max-width: 100%;
    margin: 0;
    white-space: normal;
    overflow-wrap: anywhere;
}

.hc-help-editor {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

/* A page title with its help dot (HelpTag on HCPageHero, PageSurface and AccountCard): the dot stays on the title's
   line and wraps with it on narrow screens. */
.hc-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: .25rem;
    min-width: 0;
}

.hc-title-row > h1 {
    min-width: 0;
}

.hc-title-row .hc-help-button {
    margin-inline-start: 0;
}

/* The editor's menus and windows are attached to the page body: keep them above the dialog that hosts the editor.
   The skin sets 1300 on `.tox.tox-tinymce-aux`, so the rule needs both classes to win. */
.tox.tox-tinymce-aux {
    z-index: 2000;
}

/* Reset remains usable with long translations and enlarged text on a narrow screen. */
.admin-form-reset-dialog .mud-dialog-actions {
    flex-wrap: wrap;
    gap: .5rem;
}

.admin-form-reset-dialog .mud-dialog-actions .mud-button-root {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    overflow-wrap: anywhere;
    white-space: normal;
}

.admin-form-reset-dialog .mud-alert-message {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .mud-dialog.admin-form-reset-dialog {
        width: calc(100% - 1rem);
        max-width: calc(100% - 1rem);
        max-height: calc(100dvh - 1rem);
        margin: .5rem;
    }

    .admin-form-reset-dialog .mud-dialog-content,
    .admin-form-reset-dialog .mud-dialog-title,
    .admin-form-reset-dialog .mud-dialog-actions {
        padding: .5rem;
    }

    .admin-form-reset-dialog .mud-alert {
        padding: .5rem;
    }
}

/* Action notices keep their message readable when text is enlarged; controls get their own row. */
.mud-snackbar.hc-action-notice {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    min-width: 0;
    width: min(28rem, calc(100vw - 2rem));
    max-width: 100%;
}

.hc-action-notice .mud-snackbar-content-action {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    padding-inline-start: 0;
}

#mud-snackbar-container:has(.hc-action-notice) {
    max-height: calc(100dvh - 1rem);
    max-width: calc(100vw - 1rem);
    overflow-y: auto;
    right: .5rem;
    bottom: .5rem;
}

/* HCStatCard: the figure tile of the dashboards (icon tile beside a small label, a large value and a hint). */
.hc-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: .875rem;
    margin-bottom: 1.5rem;
}

.hc-stat {
    --hc-stat-tone: var(--mud-palette-primary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .875rem;
    min-width: 0;
    padding: 1rem;
    border: .0625rem solid var(--mud-palette-lines-default);
    border-radius: .875rem;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.hc-stat--success {
    --hc-stat-tone: var(--mud-palette-success);
}

.hc-stat--warning {
    --hc-stat-tone: var(--mud-palette-warning);
}

.hc-stat--info {
    --hc-stat-tone: var(--mud-palette-info);
}

.hc-stat__icon {
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: .75rem;
    background: color-mix(in srgb, var(--hc-stat-tone) 12%, var(--mud-palette-surface));
    color: var(--hc-stat-tone);
}

.hc-stat__icon .mud-icon-root {
    font-size: 1.35rem;
}

.hc-stat__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.hc-stat__label {
    margin-bottom: .1rem;
    font-size: .72rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    /* Wraps instead of being cut with an ellipsis when the text is enlarged. */
    overflow-wrap: anywhere;
}

.hc-stat strong {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hc-stat small {
    margin-top: .1rem;
    font-size: .68rem;
    color: var(--mud-palette-text-secondary);
}

@media (max-width: 600px) {
    .hc-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .65rem;
    }

    .hc-stat {
        align-items: flex-start;
        flex-direction: column;
        gap: .6rem;
        padding: .85rem;
    }

    .hc-stat__icon {
        width: 2.3rem;
        height: 2.3rem;
        flex-basis: 2.3rem;
        border-radius: .6rem;
    }

    .hc-stat strong {
        font-size: 1.15rem;
    }
}

.hc-stat__body {
    flex: 1 1 8rem;
}

.hc-stat__spark {
    flex: 1 1 100%;
    width: 100%;
    height: 1.75rem;
    margin-top: .25rem;
    color: var(--hc-stat-tone);
}

.hc-stat__progress {
    flex: 1 1 100%;
    height: .375rem;
    margin-top: .5rem;
    border-radius: .1875rem;
    background: color-mix(in srgb, var(--hc-stat-tone) 14%, var(--mud-palette-surface));
    overflow: hidden;
}

.hc-stat__progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--hc-stat-tone);
    transform-origin: left center;
    animation: hc-fill .9s var(--hc-ease-bounce) .35s backwards;
}

/* HCChartCard: a panel for a chart or a ranked list, laid out in a responsive grid. */
.hc-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: .875rem;
    margin-bottom: 1.5rem;
}

.hc-chart-card {
    min-width: 0;
    padding: 1.1rem 1.25rem;
    border: .0625rem solid var(--mud-palette-lines-default);
    border-radius: .875rem;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
}

.hc-chart-card > header {
    margin-bottom: .75rem;
}

.hc-chart-card h3 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
}

.hc-chart-card p {
    margin: .15rem 0 0;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
}

/* HCBarList: ranked rows with the value, the share and a proportional bar. */
.hc-bar-list {
    display: grid;
    gap: .85rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hc-bar-list__row {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    font-size: .85rem;
}

.hc-bar-list__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hc-bar-list__row strong {
    font-variant-numeric: tabular-nums;
}

.hc-bar-list__share {
    min-width: 3.25rem;
    text-align: right;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.hc-bar-list__bar {
    height: .375rem;
    margin-top: .3rem;
    border-radius: .1875rem;
    background: color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-surface));
    overflow: hidden;
}

.hc-bar-list__bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--mud-palette-primary);
    transform-origin: left center;
    animation: hc-fill .9s var(--hc-ease-bounce) .35s backwards;
}

.hc-bar-list__empty {
    margin: 0;
    font-size: .85rem;
    color: var(--mud-palette-text-secondary);
}

/* The legend of a donut chart: colour square, name, value and share. */
.hc-legend {
    display: grid;
    gap: .5rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
    font-size: .85rem;
}

.hc-legend li {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.hc-legend__swatch {
    width: .75rem;
    height: .75rem;
    flex: 0 0 .75rem;
    border-radius: .1875rem;
}

.hc-legend__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.hc-legend strong,
.hc-legend__share {
    font-variant-numeric: tabular-nums;
}

.hc-legend__share {
    min-width: 3.25rem;
    text-align: right;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
}

/* Dashboard placeholders: grey shapes with the size of the finished tile or chart, replaced by the real one with a short entrance. */
.hc-stat--loading .hc-stat__icon {
    overflow: hidden;
    background: transparent;
}

.hc-stat--loading .hc-stat__body {
    gap: .4rem;
}

.hc-stat__spark--loading {
    height: 1.75rem;
}

.hc-stat--loading .hc-stat__progress {
    background: transparent;
}

@keyframes hc-rise {
    from {
        opacity: 0;
        transform: translateY(.5rem);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.hc-stat:not(.hc-stat--loading),
.hc-chart-card:not(.hc-chart-card--loading) {
    animation: hc-rise .4s ease-out both;
}

.hc-stat-grid > :nth-child(2),
.hc-chart-grid > :nth-child(2) {
    animation-delay: .05s;
}

.hc-stat-grid > :nth-child(3),
.hc-chart-grid > :nth-child(3) {
    animation-delay: .1s;
}

.hc-stat-grid > :nth-child(4),
.hc-chart-grid > :nth-child(4) {
    animation-delay: .15s;
}

.hc-stat-grid > :nth-child(n + 5) {
    animation-delay: .2s;
}

@media (prefers-reduced-motion: reduce) {
    .hc-stat:not(.hc-stat--loading),
    .hc-chart-card:not(.hc-chart-card--loading) {
        animation: none;
    }
}

/* On a phone the tile stacks its parts in a column: they must not wrap into a second column, which would overflow the tile. */
@media (max-width: 600px) {
    /* Two columns while they fit; one column as soon as enlarged text or a very narrow screen leaves less than 9rem per tile. */
    .hc-stat-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
    }

    .hc-stat {
        flex-wrap: nowrap;
    }

    .hc-stat .hc-stat__body,
    .hc-stat .hc-stat__spark,
    .hc-stat .hc-stat__progress {
        flex: 0 0 auto;
        align-self: stretch;
        min-width: 0;
    }
}

/* With enlarged text the value and the share of a legend or ranked row move to a second line instead of overflowing the panel. */
.hc-legend li,
.hc-bar-list__row {
    flex-wrap: wrap;
}

.hc-legend__name,
.hc-bar-list__name {
    flex: 1 1 6rem;
}

/* The monthly trend of a tile: the line, one dot per month and the month names under it. */
.hc-stat {
    container-type: inline-size;
}

.hc-stat__trend {
    flex: 1 1 100%;
    margin-top: .25rem;
    padding-inline: .5rem;
    color: var(--hc-stat-tone);
}

.hc-stat__spark-wrap {
    position: relative;
    height: 2rem;
}

.hc-stat__line {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: hc-draw .9s var(--hc-ease-out) .35s backwards;
}

.hc-stat__dot {
    position: absolute;
    width: .5rem;
    height: .5rem;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: .125rem solid currentColor;
    border-radius: 50%;
    background: var(--mud-palette-surface);
    cursor: pointer;
    transition: scale 140ms ease, background-color 140ms ease;
    translate: -50% 50%;
    animation: hc-pop .5s var(--hc-ease-bounce) backwards;
    /* A dot appears when the eased line reaches it: the line covers 1 - (1 - t)^3 of the width at time t. */
    animation-delay: calc(.35s + (1 - pow(1 - var(--hc-i, 0) / 11, .3333)) * .9s);
}

/* The dot is small to look at, but its click area is a 1.25rem square. */
.hc-stat__dot::after {
    content: "";
    position: absolute;
    inset: -.375rem;
}

.hc-stat__dot:hover,
.hc-stat__dot.is-selected {
    scale: 1.5;
    background: currentColor;
}

.hc-stat__dot:focus-visible {
    outline: .125rem solid var(--mud-palette-primary);
    outline-offset: .125rem;
}

.hc-stat__months {
    position: relative;
    height: .85rem;
    margin-top: .2rem;
    font-size: .6rem;
    color: var(--mud-palette-text-secondary);
}

.hc-stat__months span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

.hc-stat__months b {
    font-weight: 500;
}

.hc-stat__month-short {
    display: none;
}

/* A narrow tile shows the initial of each month instead of its three letters. */
@container (max-width: 19rem) {
    .hc-stat__month-full {
        display: none;
    }

    .hc-stat__month-short {
        display: inline;
    }
}

.hc-stat__spark--loading {
    height: 3rem;
}

@media (max-width: 600px) {
    .hc-stat .hc-stat__trend {
        flex: 0 0 auto;
        align-self: stretch;
        min-width: 0;
    }
}

/* Every tile of a grid has the height of the tallest one, and its content always starts at the top, so the tiles read alike. */
.hc-stat-grid {
    grid-auto-rows: 1fr;
}

.hc-stat {
    align-content: flex-start;
    align-items: flex-start;
}

/* HCStatGroup: a titled card that gathers the related figures of a dashboard, so ten tiles are not read as one block. */
.hc-stat-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
    gap: .875rem;
    margin-bottom: 1.5rem;
}

.hc-stat-group {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-width: 0;
    padding: 1rem 1.1rem 1.1rem;
    border: .0625rem solid var(--mud-palette-lines-default);
    border-radius: 1rem;
    background: color-mix(in srgb, var(--mud-palette-primary) 4%, var(--mud-palette-surface));
    color: var(--mud-palette-text-primary);
}

.hc-stat-group > header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .15rem .75rem;
}

.hc-stat-group > header h3 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
}

.hc-stat-group > header p {
    margin: 0;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
}

/* The tiles inside a group keep the surface colour, so they stand out from the tinted card. */
.hc-stat-group .hc-stat-grid {
    /* The tiles keep one short height in every group: a taller neighbour makes the group card taller, never the tiles. */
    flex: 0 0 auto;
    align-content: start;
    grid-auto-rows: minmax(11.5rem, auto);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .hc-stat-group .hc-stat-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
    }
}

/* Depth of the dashboards: soft shadows and a small lift, never a tilt or an extrusion, so the proportions of a chart stay true. */
:root {
    --hc-depth-shadow: rgb(15 23 42 / .2);
    --hc-depth-shadow-strong: rgb(15 23 42 / .32);

    /* Entrance easing of the charts and figures: fast start and a soft stop, or a small overshoot that settles back (about 0.8 to 1 second in all). */
    --hc-ease-out: cubic-bezier(.33, 1, .68, 1);
    --hc-ease-bounce: cubic-bezier(.34, 1.45, .64, 1);
}

:root[data-bs-theme="dark"] {
    --hc-depth-shadow: rgb(0 0 0 / .55);
    --hc-depth-shadow-strong: rgb(0 0 0 / .7);
}

.hc-stat,
.hc-chart-card {
    box-shadow: 0 .0625rem .1875rem var(--hc-depth-shadow);
    transition: box-shadow 180ms ease;
}

.hc-stat:hover,
.hc-chart-card:hover {
    box-shadow: 0 .25rem .9rem -.125rem var(--hc-depth-shadow-strong);
}

/* The donut casts one soft shadow, and the slice under the pointer grows a little from the centre of the ring. */
.hc-chart-card .mud-chart-donut {
    filter: drop-shadow(0 .4rem .45rem var(--hc-depth-shadow));
}

.hc-chart-card .mud-chart-donut .mud-chart-serie {
    transform-box: view-box;
    transform-origin: center;
    transition: transform 180ms ease;
}

.hc-chart-card .mud-chart-donut .mud-chart-serie:hover {
    transform: scale(1.04);
}

/* Bars stand on a soft shadow and rise a little under the pointer. */
.hc-chart-card .mud-charts-bar-series path {
    filter: drop-shadow(0 .15rem .15rem var(--hc-depth-shadow));
    transform-box: fill-box;
    transition: transform 180ms ease, filter 180ms ease;
}

.hc-chart-card .mud-charts-bar-series path:hover {
    transform: translateY(-.15rem);
    filter: drop-shadow(0 .3rem .3rem var(--hc-depth-shadow-strong));
}

/* The lines get a shadow, and the dots a ring of the card colour, so they read as lying on the card. */
.hc-chart-card .mud-chart-line {
    filter: drop-shadow(0 .25rem .2rem var(--hc-depth-shadow));
}

.hc-chart-card .mud-chart-point {
    stroke: var(--mud-palette-surface);
    stroke-width: 2;
}

/* Medium and high contrast, and forced colours, keep the plain flat look. */
:root[data-contrast="medium"] .hc-stat,
:root[data-contrast="high"] .hc-stat,
:root[data-contrast="medium"] .hc-chart-card,
:root[data-contrast="high"] .hc-chart-card {
    box-shadow: none;
}

:root[data-contrast="medium"] .hc-chart-card .mud-chart-donut,
:root[data-contrast="high"] .hc-chart-card .mud-chart-donut,
:root[data-contrast="medium"] .hc-chart-card .mud-charts-bar-series path,
:root[data-contrast="high"] .hc-chart-card .mud-charts-bar-series path,
:root[data-contrast="medium"] .hc-chart-card .mud-chart-line,
:root[data-contrast="high"] .hc-chart-card .mud-chart-line {
    filter: none;
}

@media (forced-colors: active) {
    .hc-stat,
    .hc-chart-card {
        box-shadow: none;
    }

    .hc-chart-card .mud-chart-donut,
    .hc-chart-card .mud-charts-bar-series path,
    .hc-chart-card .mud-chart-line {
        filter: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hc-stat,
    .hc-chart-card,
    .hc-chart-card .mud-chart-donut .mud-chart-serie,
    .hc-chart-card .mud-charts-bar-series path {
        transition: none;
    }

    .hc-chart-card .mud-chart-donut .mud-chart-serie:hover,
    .hc-chart-card .mud-charts-bar-series path:hover {
        transform: none;
    }
}

/* HCAreaChart: monthly lines with a gradient under them, the values on the left and the months under the plot. */
.hc-area {
    /* How long the line takes to cross the chart; the dots and the label follow its pace. */
    --hc-draw: .9s;

    container-type: inline-size;
}

.hc-area__body {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr);
    grid-template-rows: 12rem auto;
    column-gap: .25rem;
    padding-top: 1.25rem;
}

.hc-area__yaxis {
    position: relative;
    font-size: .65rem;
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.hc-area__yaxis span {
    position: absolute;
    right: .25rem;
    transform: translateY(50%);
    white-space: nowrap;
}

.hc-area__plot {
    position: relative;
    margin-inline: .5rem;
}

.hc-area__grid i {
    position: absolute;
    left: 0;
    right: 0;
    border-top: .0625rem dashed var(--mud-palette-lines-default);
}

.hc-area__svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    /* The line is revealed from left to right, so it looks drawn; the area under it appears with it. */
    animation: hc-draw var(--hc-draw) var(--hc-ease-out) .35s backwards;
}

.hc-area__series--0 {
    color: var(--mud-palette-primary);
}

.hc-area__series--1 {
    color: var(--mud-palette-text-secondary);
}

.hc-area__series--1 .hc-area__line {
    stroke-dasharray: 5 4;
}

.hc-area__line {
    filter: drop-shadow(0 .2rem .15rem var(--hc-depth-shadow));
}

.hc-area__dot {
    position: absolute;
    width: .5rem;
    height: .5rem;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: .125rem solid currentColor;
    border-radius: 50%;
    background: var(--mud-palette-surface);
    cursor: pointer;
    translate: -50% 50%;
    transition: scale 140ms ease, background-color 140ms ease;
    animation: hc-pop .5s var(--hc-ease-bounce) backwards;
    animation-delay: calc(.35s + (1 - pow(1 - var(--hc-i, 0) / 11, .3333)) * var(--hc-draw));
}

/* The dot is small to look at, but its click area is a 1.5rem square. */
.hc-area__dot::after {
    content: "";
    position: absolute;
    inset: -.5rem;
}

.hc-area__dot:hover,
.hc-area__dot.is-selected {
    scale: 1.5;
    background: currentColor;
}

.hc-area__dot:focus-visible,
.hc-bars__slot:focus-visible {
    outline: .125rem solid var(--mud-palette-primary);
    outline-offset: .125rem;
}

.hc-area__peak {
    position: absolute;
    padding: .05rem .35rem;
    border-radius: .375rem;
    background: var(--mud-palette-surface);
    font-size: .7rem;
    font-weight: 700;
    white-space: nowrap;
    color: var(--mud-palette-text-primary);
    box-shadow: 0 .0625rem .25rem var(--hc-depth-shadow);
    transform: translate(-50%, -140%);
    pointer-events: none;
    animation: hc-fade .4s ease-out calc(.35s + var(--hc-draw)) backwards;
}

.hc-area__peak--start {
    transform: translate(0, -140%);
}

.hc-area__peak--end {
    transform: translate(-100%, -140%);
}

.hc-area__xaxis {
    position: relative;
    grid-column: 2;
    height: 1rem;
    margin: .35rem .5rem 0;
    font-size: .65rem;
    color: var(--mud-palette-text-secondary);
}

.hc-area__xaxis span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
}

.hc-area__xaxis b {
    font-weight: 500;
}

/* The callout of a clicked month: its name and the value of every series. */
.hc-area__tip {
    position: absolute;
    z-index: 3;
    display: grid;
    gap: .15rem;
    min-width: 7rem;
    padding: .4rem .6rem;
    border-radius: .5rem;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font-size: .75rem;
    white-space: nowrap;
    box-shadow: 0 .25rem .75rem var(--hc-depth-shadow-strong), 0 0 0 .0625rem var(--mud-palette-lines-default);
    translate: -50% -.7rem;
    pointer-events: none;
    animation: hc-fade .18s ease-out;
}

.hc-area__tip--start {
    translate: -1rem -.7rem;
}

.hc-area__tip--end {
    translate: calc(-100% + 1rem) -.7rem;
}

.hc-area__tip--below {
    translate: -50% .7rem;
}

.hc-area__tip--below.hc-area__tip--start {
    translate: -1rem .7rem;
}

.hc-area__tip--below.hc-area__tip--end {
    translate: calc(-100% + 1rem) .7rem;
}

.hc-area__tip > b {
    font-size: .8rem;
}

.hc-area__tip-row {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.hc-area__tip-row .hc-legend__swatch {
    background: currentColor;
}

.hc-area__tip-row > span,
.hc-area__tip-row > strong {
    color: var(--mud-palette-text-primary);
}

.hc-area__tip-row > strong {
    margin-inline-start: auto;
    padding-inline-start: .5rem;
    font-variant-numeric: tabular-nums;
}

.hc-area__guide {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: .0625rem dashed var(--mud-palette-primary);
    opacity: .55;
    pointer-events: none;
}

/* Columns: one clickable slot per month with a bar per series. */
.hc-bars {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.hc-bars__slot {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: .125rem;
    min-width: 0;
    margin: 0;
    padding: 0 14%;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    cursor: pointer;
    transition: background-color 140ms ease;
}

.hc-bars__slot:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

.hc-bars__slot.is-selected {
    background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent);
}

.hc-bars__bar {
    flex: 1 1 0;
    min-width: .2rem;
    max-width: 1.25rem;
    border-radius: .3rem .3rem 0 0;
    background: currentColor;
    box-shadow: 0 .15rem .3rem var(--hc-depth-shadow);
    transform-origin: bottom center;
    animation: hc-grow .8s var(--hc-ease-bounce) backwards;
    animation-delay: calc(.35s + var(--hc-i, 0) * 45ms);
}

/* The legend of a chart with lines has only a swatch and a name: they stay on one line, the items wrap among themselves. */
.hc-area__legend li {
    flex-wrap: nowrap;
}

.hc-area__legend .hc-legend__name {
    flex: 0 1 auto;
}

.hc-area__legend {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    margin-top: .75rem;
}

/* The dots show a month each: on a narrow chart the names shrink to the initial. */
@container (max-width: 28rem) {
    .hc-area .hc-stat__month-full {
        display: none;
    }

    .hc-area .hc-stat__month-short {
        display: inline;
    }
}

:root[data-contrast="medium"] .hc-area__line,
:root[data-contrast="high"] .hc-area__line,
:root[data-contrast="medium"] .hc-area__peak,
:root[data-contrast="high"] .hc-area__peak {
    filter: none;
    box-shadow: none;
}

/* Inside a group card the tile is compact: the icon sits beside the label, so a tile with a trend is no taller than the others. */
.hc-stat-group .hc-stat:not(.hc-stat--loading) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
    align-items: center;
    column-gap: .6rem;
    row-gap: .2rem;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__icon {
    grid-column: 1;
    grid-row: 1;
    width: 2.25rem;
    height: 2.25rem;
    flex: none;
    border-radius: .625rem;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__icon .mud-icon-root {
    font-size: 1.15rem;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__body {
    display: contents;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__label {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) strong {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: .4rem;
}

/* A star rating takes the row of the figure, like `strong`: without a place it falls in the icon column and squeezes the label. */
.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stars {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: .4rem;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) small {
    grid-column: 1 / -1;
    grid-row: 3;
    margin: 0;
}

.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__trend,
.hc-stat-group .hc-stat:not(.hc-stat--loading) .hc-stat__progress {
    grid-column: 1 / -1;
    grid-row: 4;
}

/* Entrance of the charts and figures: the line is drawn, the dots pop up, the bars grow and the share bars fill. */
@keyframes hc-draw {
    from {
        clip-path: inset(-25% 100% -25% -3%);
    }

    to {
        clip-path: inset(-25% -3% -25% -3%);
    }
}

@keyframes hc-pop {
    from {
        opacity: 0;
        scale: .2;
    }

    to {
        opacity: 1;
        scale: 1;
    }
}

@keyframes hc-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes hc-grow {
    from {
        scale: 1 0;
    }

    to {
        scale: 1 1;
    }
}

@keyframes hc-fill {
    from {
        scale: 0 1;
    }

    to {
        scale: 1 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hc-area__svg,
    .hc-area__dot,
    .hc-area__peak,
    .hc-area__tip,
    .hc-bars__bar,
    .hc-stat__line,
    .hc-stat__dot,
    .hc-stat__progress i,
    .hc-bar-list__bar i {
        animation: none;
    }

    .hc-area__dot,
    .hc-bars__slot {
        transition: none;
    }
}

:root[data-contrast="medium"] .hc-bars__bar,
:root[data-contrast="high"] .hc-bars__bar,
:root[data-contrast="medium"] .hc-area__tip,
:root[data-contrast="high"] .hc-area__tip {
    box-shadow: none;
}

:root[data-contrast="medium"] .hc-area__tip,
:root[data-contrast="high"] .hc-area__tip {
    outline: .0625rem solid var(--mud-palette-text-primary);
}

/* A chart card followed by a row of chart cards (the maps above the membership charts) keeps the gap of the grid. */
.hc-chart-card + .hc-chart-grid {
    margin-top: .875rem;
}

/* ---------- HCStarRating: stars from 0.5 to 5 (feedback surveys), drawn exactly and never written as a percentage ---------- */
.hc-stars {
    --hc-star-size: 1.25rem;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .15rem;
}

.hc-stars--large {
    /* Half a star is a touch target of 1.5rem (24 px), the minimum of the accessibility rules: the floor keeps it at 24 px also
       when the in-app text size is below 100% (at 75% 3rem would give 18 px). */
    --hc-star-size: max(3rem, 48px);
    gap: .25rem;
}

/* The fill of a star as a registered property, so the entrance can animate it. */
@property --hc-star-fill {
    syntax: "<percentage>";
    inherits: true;
    initial-value: 0%;
}

/* One star shape (the Material star as a mask) painted from the left: orange up to the filled part, grey for the rest, with a hard edge.
   Two stars laid over each other showed a dark rim around the orange one. */
.hc-stars__star {
    position: relative;
    display: inline-block;
    width: var(--hc-star-size);
    height: var(--hc-star-size);
    flex: 0 0 var(--hc-star-size);
}

/* The mask is on a pseudo-element, so it never clips the focus ring of the two half buttons. */
.hc-stars__star::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--mud-palette-warning) var(--hc-star-fill), var(--hc-star-empty) var(--hc-star-fill));
    -webkit-mask: var(--hc-star-mask) center / contain no-repeat;
    mask: var(--hc-star-mask) center / contain no-repeat;
}

.hc-stars {
    --hc-star-empty: color-mix(in srgb, var(--md-sys-color-on-surface) 22%, transparent);
    --hc-star-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3C/svg%3E");
}

/* Medium and high contrast keep the empty stars clearly visible (3:1 against the surface). */
:root[data-contrast="medium"] .hc-stars {
    --hc-star-empty: color-mix(in srgb, var(--md-sys-color-on-surface) 50%, transparent);
}

:root[data-contrast="high"] .hc-stars {
    --hc-star-empty: color-mix(in srgb, var(--md-sys-color-on-surface) 60%, transparent);
}

.hc-stars__half {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.hc-stars__half--left {
    left: 0;
}

.hc-stars__half--right {
    right: 0;
}

.hc-stars__half:disabled {
    cursor: default;
}

.hc-stars__half:focus-visible {
    border-radius: .25rem;
    outline: .1875rem solid var(--mud-palette-primary);
    outline-offset: -.125rem;
}

.hc-stars__value {
    margin-inline-start: .5rem;
    font-weight: 700;
}

/* Entrance like the charts and figures: the stars of a displayed average fill from the left one after the other, then the value fades in.
   The animation runs when the element appears, so choosing a star in the wizard is not animated. */
.hc-stars--readonly .hc-stars__star {
    animation: hc-stars-fill .45s var(--hc-ease-out) calc(.35s + var(--hc-star-index, 0) * .12s) backwards;
}

.hc-stars--readonly .hc-stars__star:nth-child(2) { --hc-star-index: 1; }
.hc-stars--readonly .hc-stars__star:nth-child(3) { --hc-star-index: 2; }
.hc-stars--readonly .hc-stars__star:nth-child(4) { --hc-star-index: 3; }
.hc-stars--readonly .hc-stars__star:nth-child(5) { --hc-star-index: 4; }

.hc-stars--readonly .hc-stars__value {
    animation: hc-fade .4s ease-out 1s backwards;
}

@keyframes hc-stars-fill {
    from {
        --hc-star-fill: 0%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hc-stars--readonly .hc-stars__star,
    .hc-stars--readonly .hc-stars__value {
        animation: none;
    }
}

