﻿/*
 * Vazirmatn, Farsi-Digits variant. SIL Open Font License 1.1, see fonts/Vazirmatn-OFL.txt.
 *
 * This variant draws the Latin digits 0-9 with the Persian numerals, so every number in the app
 * reads as Persian without the underlying text changing. Values stay Latin in the DOM, which keeps
 * binding, search and copy working on real digits. Swap these files for the plain Vazirmatn build
 * to go back to Latin numerals.
 */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-FD-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-FD-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-FD-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-FD-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/*
 * Inter, the variable build's Latin subset (every weight in one file). SIL Open Font License 1.1, see
 * fonts/Inter-OFL.txt. It leads the stack when the app runs in English (AppTheme.FontFamily, and
 * html[lang="en"] below for the loading screen), so letters and digits are Latin; Persian text in a
 * value falls back to Vazirmatn. The joiners (U+200C, U+200D) are left out of its range so they stay
 * with the Persian letters around them.
 */
@font-face {
    font-family: 'Inter';
    src: url('../fonts/Inter-Variable-Latin.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-200B, U+200E-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html,
body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}

html[lang="en"],
html[lang="en"] body {
    font-family: 'Inter', 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

/* Thin scrollbars in the palette's line colour, so a scrolling drawer or table doesn't draw a grey slab beside it. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--mud-palette-lines-inputs) transparent;
}

#app,
#blazor-error-ui {
    font-family: inherit;
}

/*
 * The login screen. The card is held in the middle of the window over a quiet wash of the primary
 * colour, and every colour here is taken from the MudBlazor palette variables so the screen follows
 * the light and dark themes rather than fixing its own shades.
 */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: radial-gradient(900px 480px at 50% -8%, rgba(var(--mud-palette-primary-rgb), 0.16), transparent 65%), var(--mud-palette-background);
}

.login-card {
    width: 100%;
    max-width: 26rem;
    border: 1px solid var(--mud-palette-lines-default);
}

/*
 * The frame around every page: the bar at the top, the drawer beside it and the ground they sit on.
 * Colours come from the palette variables, so the same rules serve the light and the dark theme.
 */
.app-bar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
    width: 100%;
    background-color: color-mix(in srgb, var(--mud-palette-appbar-background) 86%, transparent) !important;
    -webkit-backdrop-filter: saturate(1.6) blur(12px);
    backdrop-filter: saturate(1.6) blur(12px);
}

.app-drawer {
    border-inline-end: 1px solid var(--mud-palette-lines-default);
}

/* The ground under the pages: the background with a faint wash of the primary colour at the top. */
.mud-main-content {
    background: radial-gradient(1100px 380px at 50% -160px, rgba(var(--mud-palette-primary-rgb), 0.07), transparent 70%), var(--mud-palette-background);
}

/* Cards: a hairline border and a soft shadow rather than the stock lift, in both themes. */
.mud-main-content .mud-paper.mud-elevation-1 {
    border: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.04);
}

/* Below the desktop width the drawer opens over the page: the page dims behind it. */
.mud-drawer-overlay.mud-drawer-overlay--open {
    background-color: rgba(10, 16, 18, 0.42);
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

/*
 * The sidebar, kept compact: rows of one line (a long name is cut short, whole on hover), small icons, and quiet
 * section headers. Its sections fold: a header (title, a count, a chevron turning to the reading direction when
 * closed) over the links, which open and close smoothly, with room for a button beside it (customizing).
 */
.app-drawer .app-nav {
    padding-block: 0.5rem;
}

/* The quick find at the top: a slim field over the sections. */
.app-drawer .nav-finder {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    margin: 0 0.5rem 0.375rem;
    padding: 0 0.625rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    background: rgba(var(--mud-palette-primary-rgb), 0.03);
    color: var(--mud-palette-text-secondary);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.app-drawer .nav-finder:focus-within {
    border-color: var(--mud-palette-primary);
    background: var(--mud-palette-surface);
}

.app-drawer .nav-finder-icon {
    flex: none;
    font-size: 1.125rem;
}

.app-drawer .nav-finder-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: 0.8125rem;
}

.app-drawer .nav-finder-input::placeholder {
    color: var(--mud-palette-text-secondary);
    opacity: 0.8;
}

.app-drawer .nav-finder-clear {
    display: flex;
    flex: none;
    padding: 2px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.app-drawer .nav-finder-clear:hover {
    color: var(--mud-palette-text-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.app-drawer .nav-finder-label {
    margin: 0.5rem 1.125rem 0.125rem;
    color: var(--mud-palette-text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.app-drawer .nav-finder-empty {
    margin: 0.75rem 1.125rem;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

/* The match Enter opens. */
.app-drawer .mud-nav-link.nav-first:not(.active) {
    box-shadow: inset 0 0 0 1px rgba(var(--mud-palette-primary-rgb), 0.35);
}

/* A section: its header and the buttons beside it on one line. */
.app-drawer .nav-section-head {
    display: flex;
    align-items: center;
    margin: 0.625rem 0.5rem 0.125rem;
}

.app-drawer .nav-section-header {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0.25rem 0.625rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: start;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-drawer .nav-section-header:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.06);
    color: var(--mud-palette-text-primary);
}

.app-drawer .nav-section-header:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

.app-drawer .nav-section-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.app-drawer .nav-section-count {
    flex: none;
    min-width: 1.25rem;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 0.625rem;
    line-height: 1.125rem;
    text-align: center;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
}

.app-drawer .nav-section-chevron {
    flex: none;
    font-size: 1.125rem;
    transition: transform 0.2s ease;
}

.app-drawer .nav-section-group.collapsed > .nav-section-head .nav-section-chevron {
    transform: rotate(-90deg);
}

.app-drawer .nav-section-group.collapsed > .nav-section-head .nav-section-chevron:dir(rtl) {
    transform: rotate(90deg);
}

/* Buttons beside a header stay quiet until wanted. */
.app-drawer .nav-section-actions {
    display: flex;
    flex: none;
    color: var(--mud-palette-text-secondary);
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.app-drawer .nav-section-head:hover .nav-section-actions,
.app-drawer .nav-section-actions:focus-within {
    opacity: 1;
}

.app-drawer .nav-section-actions .mud-icon-button {
    padding: 4px;
}

.app-drawer .nav-section-actions .mud-icon-button .mud-icon-root {
    font-size: 1.125rem;
}

/* A group within a section (forms under their group, reports under a name): its header reads as a link, by the
   group's icon, with a plain count; its links are set in beside a faint line under that icon. */
.app-drawer .nav-section-group.nested > .nav-section-head {
    margin: 1px 0.5rem;
}

.app-drawer .nav-section-group.nested > .nav-section-head > .nav-section-header {
    gap: 10px;
    min-height: 34px;
    padding: 0.3125rem 0.625rem;
    color: var(--mud-palette-text-primary);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: normal;
}

.app-drawer .nav-section-group.nested > .nav-section-head .nav-section-icon {
    color: var(--mud-palette-text-secondary);
}

.app-drawer .nav-section-group.nested > .nav-section-head .nav-section-count {
    min-width: 0;
    padding: 0;
    background: none;
    color: var(--mud-palette-text-secondary);
    font-size: 0.6875rem;
}

.app-drawer .nav-section-group.nested > .nav-section-head .nav-section-chevron {
    color: var(--mud-palette-text-secondary);
}

/* A group holding the open page: its icon in the primary colour, and the whole header tinted while it is folded. */
.app-drawer .nav-section-group.nested.active-within > .nav-section-head .nav-section-icon {
    color: var(--mud-palette-primary);
}

.app-drawer .nav-section-group.nested.active-within.collapsed > .nav-section-head > .nav-section-header {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.1);
    color: var(--mud-palette-primary);
}

.app-drawer .nav-section-items {
    margin-inline-start: 1.75rem;
    padding-inline-start: 2px;
    border-inline-start: 1px solid var(--mud-palette-lines-default);
}

.app-drawer .nav-section-items .mud-nav-link,
.app-drawer .nav-section-items .nav-section-group.nested > .nav-section-head {
    margin-inline-start: 0.25rem;
}

/* The links: one line each, as pills rather than full width bands; the open page is marked by its own tinted pill
   instead of a stripe at the edge. */
.app-drawer .mud-nav-link {
    min-height: 34px;
    margin: 1px 0.5rem;
    padding: 0.3125rem 0.625rem;
    border-radius: 7px;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.app-drawer .mud-nav-link .mud-nav-link-icon {
    flex: none;
    font-size: 1.25rem;
}

.app-drawer .mud-nav-link .mud-nav-link-text {
    min-width: 0;
    margin-inline-start: 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.app-drawer .mud-nav-link .mud-nav-link-text:has(> .nav-item) {
    margin-inline-start: 0;
}

.app-drawer .mud-nav-link:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.08);
}

.app-drawer .mud-nav-link.active {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.14);
    color: var(--mud-palette-primary);
    font-weight: 500;
}

.app-drawer .mud-nav-link.active::before,
.app-drawer .mud-nav-link.active::after {
    display: none;
}

/* A form or a report (SidebarLink): its icon, its name, and what it belongs to dimmed after it. The name keeps its room
   first; what it belongs to takes what is left. */
.app-drawer .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-drawer .nav-item-icon {
    flex: none;
}

.app-drawer .nav-item-title {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.app-drawer .nav-item-sub {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--mud-palette-text-secondary);
    font-size: 0.6875rem;
    font-weight: 400;
}

/* On a touch screen the rows keep room for a finger. */
@media (pointer: coarse) {
    .app-drawer .mud-nav-link,
    .app-drawer .nav-section-group.nested > .nav-section-head > .nav-section-header {
        min-height: 40px;
    }

    .app-drawer .nav-finder {
        height: 40px;
    }

    .app-drawer .nav-finder-input {
        font-size: 1rem;
    }
}

/* The heading that opens every page. */
.page-header-icon {
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--mud-palette-primary);
    background: linear-gradient(135deg, rgba(var(--mud-palette-primary-rgb), 0.2), rgba(var(--mud-palette-primary-rgb), 0.07));
    border: 1px solid rgba(var(--mud-palette-primary-rgb), 0.16);
}

.page-header-title {
    font-weight: 700 !important;
    line-height: 1.4 !important;
}

/* A form's pages (records, charts, reports, design) as a segmented strip; on a phone it scrolls sideways on one
   line rather than wrapping. */
.form-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.form-tabs::-webkit-scrollbar {
    display: none;
}

.form-tabs-strip {
    flex: none;
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background-gray);
}

.form-tabs .form-tab {
    flex: none;
    border-radius: 10px;
    padding-inline: 14px;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

.form-tabs .form-tab.active {
    color: var(--mud-palette-primary);
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 1px 4px rgba(16, 24, 40, 0.06);
    font-weight: 600;
}

.form-tabs .form-tabs-back {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

/* Tables read more quietly: a header that is a label rather than a shout, and rows that lift on
   hover instead of being fenced in. */
.mud-table-container .mud-table-head .mud-table-cell {
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
    background-color: var(--mud-palette-background-gray);
}

.full-width {
    width: 100%;
}

/* Shortcut cards on the dashboard lift slightly on hover. */
.dashboard-card {
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.dashboard-card:hover {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 4px 18px rgba(var(--mud-palette-primary-rgb), 0.12);
}

/*
 * Shown while the app downloads, before any MudBlazor style exists, so the colours are written out: the teal and
 * gold of the app mark (the theme's own). The mark fills itself in once (the sheet rises, its two fields are typed
 * into from the right, the button presses and its tick is drawn) and breathes while the download runs; a ring of
 * light circles it, and the bar follows Blazor's own progress (--blazor-load-percentage). Until Blazor sets it a
 * sliver sweeps across. The dark ground is chosen by the script at the top of index.html (.app-dark on the root).
 * Laid out after EMS's loading screen.
 */
.app-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #F4F6F6;
    color: #1F2A2E;
}

/* Two soft lights behind the mark, teal above and gold below, drifting slowly. */
.app-loading-glow {
    position: absolute;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
    animation: app-loading-drift 9s ease-in-out infinite alternate;
}

.app-loading-glow-teal {
    top: calc(50% - 400px);
    left: calc(50% - 360px);
    background: radial-gradient(circle, rgba(35, 147, 141, 0.32), transparent 65%);
}

.app-loading-glow-gold {
    top: calc(50% - 80px);
    left: calc(50% - 120px);
    background: radial-gradient(circle, rgba(233, 162, 59, 0.22), transparent 65%);
    animation-delay: -4.5s;
}

.app-loading-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
    text-align: center;
    animation: app-loading-in 480ms ease-out both;
}

.app-loading-halo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 132px;
    height: 132px;
    border-radius: 36px;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 18px 50px rgba(14, 77, 75, 0.18), inset 0 0 0 1px rgba(22, 110, 107, 0.08);
}

/* A ring of light circling the mark while it loads: the gradient's angle turns, not the box (a turning rounded
   square would wobble). Browsers without @property show the arc standing still. */
@property --app-loading-angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

.app-loading-halo::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 39px;
    padding: 3px;
    background: conic-gradient(from var(--app-loading-angle), transparent 0deg, rgba(233, 162, 59, 0.9) 60deg, rgba(35, 147, 141, 0.9) 120deg, transparent 180deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: app-loading-spin 2.2s linear infinite;
}

.app-loading-mark {
    width: 88px;
    height: 88px;
    overflow: visible;
    animation: app-loading-breathe 2.6s 1.6s ease-in-out infinite;
}

/* The parts of the mark move in their own boxes. */
.app-loading-mark .app-loading-back,
.app-loading-mark .app-loading-sheet,
.app-loading-mark .app-loading-value,
.app-loading-mark .app-loading-button {
    transform-box: fill-box;
}

.app-loading-back {
    transform-origin: center;
    animation: app-loading-back 520ms 80ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.app-loading-sheet {
    transform-origin: center bottom;
    animation: app-loading-sheet 560ms 180ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* The values are typed in from the start of the line, the right in Persian. */
.app-loading-value {
    transform-origin: right center;
    animation: app-loading-type 420ms 620ms ease-out both;
}

.app-loading-value-2 {
    animation-delay: 860ms;
}

.app-loading-button {
    transform-origin: center;
    animation: app-loading-press 420ms 1080ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.app-loading-tick {
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation: app-loading-draw 360ms 1280ms ease-out forwards;
}

.app-loading-name {
    margin-top: 26px;
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.3;
    background: linear-gradient(270deg, #0E4D4B, #166E6B 45%, #23938D);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #166E6B;
}

.app-loading-tagline {
    margin-top: 4px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #5B6B73;
}

.app-loading-track {
    position: relative;
    width: 200px;
    height: 5px;
    margin-top: 28px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(22, 110, 107, 0.14);
}

/* Fills from the start of the line: the right in Persian, the left in English. */
.app-loading-progress {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: var(--blazor-load-percentage, 28%);
    border-radius: 999px;
    background: linear-gradient(270deg, #166E6B, #23938D 70%, #E9A23B);
    transition: width 200ms ease-out;
}

:root:not([style*="--blazor-load-percentage"]) .app-loading-progress {
    animation: app-loading-sweep 1.3s ease-in-out infinite;
}

[dir="ltr"] .app-loading-progress {
    background: linear-gradient(90deg, #166E6B, #23938D 70%, #E9A23B);
}

:root[dir="ltr"]:not([style*="--blazor-load-percentage"]) .app-loading-progress {
    animation-name: app-loading-sweep-ltr;
}

.app-loading-text {
    margin-top: 12px;
    font-size: 0.8125rem;
    color: #5B6B73;
}

.app-loading-text::after {
    content: var(--blazor-load-percentage-text, "");
    margin-inline-start: 6px;
}

/* The stylesheet didn't load (index.html, appStyles): the app won't start, so the bar and the turning ring give way
   to a message and a reload button. */
.app-loading-failure {
    display: none;
    max-width: 320px;
    margin-top: 24px;
}

.app-styles-failed .app-loading-track,
.app-styles-failed .app-loading-text,
.app-styles-failed .app-loading-halo::before {
    display: none;
}

.app-styles-failed .app-loading-failure {
    display: block;
}

.app-loading-failure-text {
    margin: 0 0 14px;
    font-size: 0.875rem;
    line-height: 1.8;
    color: #B3261E;
}

.app-loading-retry {
    padding: 8px 22px;
    border: 0;
    border-radius: 8px;
    background: #166E6B;
    color: #FFFFFF;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.app-loading-retry:hover {
    background: #0E4D4B;
}

.app-loading-retry:focus-visible {
    outline: 2px solid #E9A23B;
    outline-offset: 2px;
}

@keyframes app-loading-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes app-loading-back {
    from { opacity: 0; transform: translate(-4px, 4px) rotate(-4deg); }
    to { opacity: 1; transform: none; }
}

@keyframes app-loading-sheet {
    from { opacity: 0; transform: translateY(10px) scale(0.9); }
    to { opacity: 1; transform: none; }
}

@keyframes app-loading-type {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes app-loading-press {
    0% { opacity: 0; transform: scale(0.6); }
    60% { opacity: 1; transform: scale(1.06); }
    80% { transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes app-loading-draw {
    to { stroke-dashoffset: 0; }
}

@keyframes app-loading-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes app-loading-spin {
    to { --app-loading-angle: 360deg; }
}

@keyframes app-loading-drift {
    from { transform: translate(0, 0); }
    to { transform: translate(40px, 24px); }
}

@keyframes app-loading-sweep {
    from { transform: translateX(110%); }
    to { transform: translateX(-200px); }
}

@keyframes app-loading-sweep-ltr {
    from { transform: translateX(-110%); }
    to { transform: translateX(200px); }
}

.app-dark .app-loading {
    background: #191C1F;
    color: #E6EAEA;
}

.app-dark .app-loading-glow {
    opacity: 0.45;
}

.app-dark .app-loading-halo {
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.app-dark .app-loading-name {
    background: linear-gradient(270deg, #3F9A95, #5FB3AF 45%, #8FD3CF);
    -webkit-background-clip: text;
    background-clip: text;
    color: #5FB3AF;
}

.app-dark .app-loading-tagline,
.app-dark .app-loading-text {
    color: #9AA5A8;
}

.app-dark .app-loading-track {
    background: rgba(95, 179, 175, 0.18);
}

.app-dark .app-loading-failure-text {
    color: #F2B8B5;
}

.app-dark .app-loading-retry {
    background: #3F9A95;
}

.app-dark .app-loading-retry:hover {
    background: #5FB3AF;
}

@media (prefers-reduced-motion: reduce) {
    .app-loading-content,
    .app-loading-glow,
    .app-loading-halo::before,
    .app-loading-mark,
    .app-loading-back,
    .app-loading-sheet,
    .app-loading-value,
    .app-loading-button,
    .app-loading-progress {
        animation: none !important;
    }

    .app-loading-tick {
        animation: none;
        stroke-dashoffset: 0;
    }
}

/* The brand in the app bar and on the sign-in card: the mark, and the name in the mark's teal. */
.app-lockup {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-brand {
    font-weight: 800 !important;
    letter-spacing: -0.01em;
    white-space: nowrap;
    background: linear-gradient(270deg, #0E4D4B, #166E6B 45%, #23938D);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #166E6B;
}

.mud-theme-dark .app-brand,
.app-dark .app-brand {
    background: linear-gradient(270deg, #3F9A95, #5FB3AF 45%, #8FD3CF);
    -webkit-background-clip: text;
    background-clip: text;
}

/* The mark on the sign-in card, lifted off it. */
.login-mark {
    width: 76px !important;
    height: 76px !important;
    filter: drop-shadow(0 10px 22px rgba(14, 77, 75, 0.28));
}

/* Blazor's error bar (index.html): a card at the foot of the window, in the app's light or dark (from EMS). */
#blazor-error-ui {
    --err-bg: #FFFFFF;
    --err-border: #FCA5A5;
    --err-text: #1F2937;
    --err-icon-bg: #FEE2E2;
    --err-icon-color: #DC2626;
    --err-btn-bg: #DC2626;
    --err-btn-bg-hover: #B91C1C;
    --err-btn-text: #FFFFFF;
    --err-dismiss-color: #6B7280;
    --err-dismiss-hover-bg: #F3F4F6;
    --err-dismiss-hover-color: #111827;
    --err-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.18), 0 4px 10px -2px rgba(220, 38, 38, 0.12);
}

.app-dark #blazor-error-ui {
    --err-bg: #18181B;
    --err-border: #7F1D1D;
    --err-text: #F4F4F5;
    --err-icon-bg: rgba(239, 68, 68, 0.18);
    --err-icon-color: #F87171;
    --err-btn-bg: #EF4444;
    --err-btn-bg-hover: #DC2626;
    --err-btn-text: #FFFFFF;
    --err-dismiss-color: #A1A1AA;
    --err-dismiss-hover-bg: rgba(255, 255, 255, 0.1);
    --err-dismiss-hover-color: #FFFFFF;
    --err-shadow: 0 16px 32px -4px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(239, 68, 68, 0.2);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    inset-inline: 0;
    width: calc(100% - 2.5rem);
    max-width: 620px;
    margin-inline: auto;
    box-sizing: border-box;
    z-index: 99999;
    padding: 0.75rem 1rem;
    background: var(--err-bg);
    color: var(--err-text);
    border: 1px solid var(--err-border);
    border-radius: 0.875rem;
    box-shadow: var(--err-shadow);
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Blazor shows it with an inline display: block; it lays out as a row. */
#blazor-error-ui[style*="display: block"] {
    display: flex !important;
    animation: blazor-toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#blazor-error-ui .error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

#blazor-error-ui .error-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    background: var(--err-icon-bg);
    color: var(--err-icon-color);
    flex-shrink: 0;
}

#blazor-error-ui .error-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
}

#blazor-error-ui .error-text {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.6;
    text-align: start;
}

#blazor-error-ui .error-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

#blazor-error-ui .reload {
    background: var(--err-btn-bg);
    color: var(--err-btn-text);
    text-decoration: none;
    padding: 0.45rem 0.9rem;
    border-radius: 0.5rem;
    font-size: 0.825rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

#blazor-error-ui .reload:hover {
    background: var(--err-btn-bg-hover);
}

#blazor-error-ui .reload:active {
    transform: scale(0.97);
}

/* MudBlazor's stylesheet pins the dismiss to the top right (over the icon, right to left); it sits in the actions. */
#blazor-error-ui .dismiss {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--err-dismiss-color);
    cursor: pointer;
    appearance: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#blazor-error-ui .dismiss svg {
    width: 1.1rem;
    height: 1.1rem;
    display: block;
}

#blazor-error-ui .dismiss:hover {
    background: var(--err-dismiss-hover-bg);
    color: var(--err-dismiss-hover-color);
}

@keyframes blazor-toast-in {
    from { opacity: 0; transform: translateY(0.75rem) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
    #blazor-error-ui[style*="display: block"] {
        flex-direction: column;
        align-items: stretch;
    }

    #blazor-error-ui .error-actions {
        justify-content: flex-end;
        padding-top: 0.25rem;
    }
}

.parent-grow {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* The area that stands in for a file input, so it reads as something to click or drop a file on (from GuardList). */
.file-drop {
    transition: border-color 120ms ease, background-color 120ms ease;
}

.file-drop:hover,
.file-drop.file-drop-active {
    border-color: var(--mud-palette-primary);
    background-color: rgba(var(--mud-palette-primary-rgb), 0.06);
}

/* Leave parts on the register page are reordered by dragging their grip onto another part. */
.register-part {
    position: relative;
}

.register-part .drag-handle {
    display: inline-flex;
    cursor: grab;
    color: var(--mud-palette-text-secondary);
}

.register-part .drag-handle[draggable="false"] {
    cursor: default;
    opacity: 0.4;
}

.register-part .drag-handle:active {
    cursor: grabbing;
}

.part-dragging {
    opacity: 0.45;
}

/* A line in the gap on the side the dragged part will land. */
.part-drop-before::before,
.part-drop-after::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 2px;
    background-color: var(--mud-palette-primary);
    pointer-events: none;
}

.part-drop-before::before {
    top: -8px;
}

.part-drop-after::after {
    bottom: -8px;
}

/* The file input covering the drop zone: invisible, but it is what receives the click and the dropped file. */
.file-drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* A field that can't be changed (a computed total, a value a rule locks) still has to be read: its value is the
   secondary text colour rather than the faint disabled one. */
.mud-input.mud-disabled > input,
.mud-input.mud-disabled > textarea {
    color: var(--mud-palette-text-secondary);
    -webkit-text-fill-color: var(--mud-palette-text-secondary);
}

/* A link's input with its "add a record" button beside it: the button sits on the input's line, not the label's. */
.link-editor {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.link-editor:has(.mud-input-control-helper-container) {
    align-items: center;
}

.link-editor > .mud-tooltip-root {
    flex: none;
    margin-bottom: 2px;
}

/* A field whose value reads left to right (a leave number such as 05-12) in the right-to-left page: only the
   typed text flips, the label and outline stay put. */
.ltr-value input {
    direction: ltr;
    text-align: end;
}

.ltr-content {
    direction: ltr !important;
    text-align: end !important;
}

/* A code (a leave type's, a tenant's): the app's font, not the browser's monospace, on a light chip, written left to
   right in the right-to-left page. */
code {
    font-family: inherit;
    font-size: 0.85em;
    direction: ltr;
    unicode-bidi: isolate;
    padding: 0.1em 0.45em;
    border-radius: 4px;
    color: var(--mud-palette-text-primary);
    background-color: var(--mud-palette-action-default-hover);
    border: 1px solid var(--mud-palette-lines-default);
    white-space: nowrap;
}

/* MudBlazor has no no-wrap utility; the pages use this one for cells that must stay on one line (a leave number,
   the row's buttons). */
.text-nowrap {
    white-space: nowrap;
}

/* MudBlazor lays the pager's "1 تا 10 از 120" out left to right, which scrambles it in a right-to-left page: it
   follows the page direction instead. */
.mud-table-pagination-caption .mud-table-page-number-information {
    direction: inherit;
}

/* Phones: every dialog opens as a sheet from the bottom of the screen (the mobile side of the admin client's
   ResponsiveDialog): full width, rounded top corners, at most 90% of the height. The title and the buttons stay in
   view; only the content between them scrolls. A full-screen dialog keeps its own layout. */
@media (max-width: 599.98px) {
    .mud-dialog-container {
        align-items: flex-end !important;
        justify-content: center !important;
        padding: 0 !important;
    }

    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) {
        position: relative;
        inset: auto;
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        max-height: 90dvh;
        margin: 0;
        border-radius: 16px 16px 0 0;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom);
        animation: leave-dialog-sheet-up 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
    }

    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) > * {
        min-height: 0;
    }

    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) .mud-dialog-title {
        padding: 16px;
    }

    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) .mud-dialog-content {
        min-height: 0;
        padding: 8px 16px;
    }

    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) .mud-dialog-actions {
        padding: 10px 16px 16px;
        border-top: 1px solid var(--mud-palette-lines-default);
        gap: 8px;
    }

    /* A sheet's grip, so it reads as something pulled up from the bottom. */
    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen)::before {
        content: "";
        flex: none;
        display: block;
        width: 36px;
        height: 4px;
        margin: 8px auto 0;
        border-radius: 2px;
        background: var(--mud-palette-lines-inputs);
    }

    /* The buttons share the sheet's width and are tall enough for a thumb. */
    .mud-dialog-container .mud-dialog:not(.mud-dialog-fullscreen) .mud-dialog-actions > .mud-button-root {
        flex: 1 1 0;
        min-height: 44px;
        margin: 0 !important;
    }
}

@keyframes leave-dialog-sheet-up {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

/* The org chart (Z.Blazor.Diagrams): the canvas lays nodes out left to right, the text inside them stays RTL. */
.org-chart-canvas {
    height: calc(100vh - 240px);
    min-height: 420px;
    direction: ltr;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background-color: var(--mud-palette-background-gray);
    overflow: hidden;
}

.org-chart-canvas .diagram-canvas {
    width: 100%;
    height: 100%;
}

.org-node {
    width: 200px;
    height: 88px;
    box-sizing: border-box;
    padding: 8px 10px;
    direction: rtl;
    text-align: center;
    border-radius: 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-top: 4px solid var(--mud-palette-primary);
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: var(--mud-elevation-1);
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.org-node.selected {
    outline: 3px solid var(--mud-palette-secondary);
}

.org-node.is-default {
    border-top-color: var(--mud-palette-success);
}

.org-node .org-node-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.org-node .org-node-code {
    font-size: 0.7rem;
    color: var(--mud-palette-text-secondary);
    line-height: 1.1;
}

.org-node .org-node-meta {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    display: flex;
    justify-content: space-between;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
}

/* ---------------------------------------------------------------- approval flows */
.flow-canvas {
    height: calc(100vh - 330px);
    min-height: 420px;
    direction: ltr;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background-color: var(--mud-palette-background-gray);
    overflow: hidden;
}

.flow-canvas.flow-canvas-view {
    height: 340px;
    min-height: 0;
}

.flow-canvas .diagram-canvas {
    width: 100%;
    height: 100%;
}

.flow-canvas .diagram-link path {
    stroke-width: 2px;
}

.flow-node {
    position: relative;
    width: 180px;
    height: 76px;
    box-sizing: border-box;
    padding: 8px 10px;
    direction: rtl;
    text-align: center;
    border-radius: 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-top: 4px solid var(--mud-palette-primary);
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: var(--mud-elevation-1);
}

.flow-node.selected {
    outline: 3px solid var(--mud-palette-secondary);
}

.flow-node.is-mine {
    outline: 2px dashed var(--mud-palette-secondary);
    outline-offset: 2px;
}

.flow-node.state-waiting {
    border-top-color: var(--mud-palette-lines-default);
}

.flow-node.state-open {
    border-top-color: var(--mud-palette-warning);
}

.flow-node.state-approved {
    border-top-color: var(--mud-palette-success);
}

.flow-node.state-rejected {
    border-top-color: var(--mud-palette-error);
}

.flow-node.state-skipped {
    border-top-color: var(--mud-palette-text-disabled);
    opacity: 0.75;
}

.flow-node .flow-node-state {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-node .diagram-port {
    position: absolute;
    width: 14px;
    height: 14px;
    margin: -7px;
    border-radius: 50%;
    border: 2px solid var(--mud-palette-primary);
    background-color: var(--mud-palette-surface);
    cursor: crosshair;
    left: 50%;
}

.flow-node .diagram-port.top {
    top: 0;
}

.flow-node .diagram-port.bottom {
    bottom: 0;
}

.flow-node .diagram-port:hover,
.flow-node .diagram-port.has-links {
    background-color: var(--mud-palette-primary);
}

.flow-canvas-view .flow-node .diagram-port {
    visibility: hidden;
}

.flow-row-mine td {
    font-weight: 600;
}

/* The problems and warnings of an imported file. */
.transfer-list {
    margin: 0;
    padding-inline-start: 1.25rem;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.875rem;
}

.alert-align-center .mud-alert-position {
    align-items: center !important;
}

/* A printed request shown in a dialog. */
.pdf-frame {
    width: 100%;
    height: 75vh;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: #fff;
}

/* The upload button of a Word template: the file picker covers it. */
.print-template-upload {
    position: relative;
    overflow: hidden;
}

.print-keys {
    max-height: 240px;
    overflow-y: auto;
}

.ltr-chip .mud-chip-content {
    direction: ltr;
}

/* A ticket's conversation: the owner's messages on the start side, support's on the end side. */
.ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-message {
    display: flex;
    max-width: 100%;
}

.ticket-message > .mud-paper {
    width: min(760px, 92%);
}

.ticket-message.customer {
    justify-content: flex-start;
}

.ticket-message.customer > .mud-paper {
    background: var(--mud-palette-background-gray);
}

.ticket-message.staff {
    justify-content: flex-end;
}

.ticket-message.staff > .mud-paper {
    border-color: var(--mud-palette-primary-lighten);
}

.ticket-message-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.9;
}

/* The number of requests waiting for the user, beside a menu item. */
.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-inline-start: 8px;
    border-radius: 10px;
    background: var(--mud-palette-error);
    color: var(--mud-palette-error-text);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

/* Days off in the date pickers (AdditionalDateClassesFunc): red, like a printed calendar. */
.mud-picker .leave-holiday-date:not(.mud-selected) .mud-button-label,
.mud-picker .leave-holiday-date:not(.mud-selected) p {
    color: var(--mud-palette-error);
}

/* A run of days off between the parts of a leave, on the register page and the holidays page. */
.register-holiday-row td {
    color: var(--mud-palette-text-secondary);
    background: rgba(244, 67, 54, 0.06);
}

/* The holidays page: national days red, the major unit's own amber, weekly ones red text only. */
.mud-picker .leave-holiday-national:not(.mud-selected),
.leave-holiday-legend.national {
    background: rgba(244, 67, 54, 0.14);
}

.mud-picker .leave-holiday-tenant:not(.mud-selected),
.leave-holiday-legend.tenant {
    background: rgba(255, 152, 0, 0.18);
}

.leave-holiday-legend.weekly {
    color: var(--mud-palette-error);
}

/* The batch entry of records: a required column's head is marked, and a row the server refused is tinted. */
.batch-required::after {
    content: " *";
    color: var(--mud-palette-error);
}

.batch-row-failed > td {
    background-color: var(--mud-palette-error-hover);
}

.overflow-y-hidden.mud-table > div {
    overflow-y: hidden;
}

/* The records filter: a panel of rows read as sentences ("where … and …"). A row's conjunction sits in a column of its
   own, so the conditions line up; a nested group or an if sits in a box, and each group's actions close it. */
.filter-panel {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 12px 12px 4px;
    background: var(--mud-palette-background-gray);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.filter-conj {
    flex: 0 0 4.5rem;
    min-height: 40px;
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.filter-conj-text {
}

.filter-row-body {
    flex: 1 1 auto;
    min-width: 0;
}

.filter-condition {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Inputs without labels, one height: the field and operator pickers keep a width, the value takes the rest. */
.filter-panel .mud-input-control {
    margin: 0;
}

.filter-panel .mud-input-control > .mud-input-control-input-container > .mud-input.mud-input-outlined {
    background: var(--mud-palette-surface);
}

.filter-input {
    flex: 0 0 auto;
}

.filter-input-field {
    width: 13.2rem;
}

.filter-input-operator {
    width: 13.2rem;
}

.filter-conj .filter-input {
    width: 100%;
}

/* A field path: the steps after a link are narrower, and an option opening another step ends with a chevron. */
.filter-input-step {
    width: 10rem;
}

.filter-path-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.filter-value {
    flex: 1 1 12rem;
    min-width: 10rem;
    max-width: 24rem;
}

/* A date relative to today: how many, the unit and the way, as one part of the line. */
.filter-relative {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.filter-input-amount {
    width: 5rem;
}

.filter-input-unit {
    width: 7rem;
}

/* A condition on another form's records: a box like an if's, with its own line on top. */
.filter-related {
    border-inline-start: 3px solid var(--mud-palette-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-to {
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.filter-target .mud-button-root {
    text-transform: none;
    min-height: 40px;
}

.filter-target-hint {
    font-size: 0.75rem;
    max-width: 18rem;
    white-space: normal;
}

.filter-remove {
    margin-inline-start: auto;
}

.filter-box {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 8px 12px 0;
    background: var(--mud-palette-surface);
}

.filter-box .filter-box {
    background: var(--mud-palette-background-gray);
}

.filter-if {
    border-inline-start: 3px solid var(--mud-palette-primary);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-if-part {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.filter-if-part + .filter-if-part {
    border-top: 1px dashed var(--mud-palette-lines-default);
    padding-top: 8px;
}

.filter-if-label {
    flex: 0 0 6rem;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
}

.filter-if-body {
    flex: 1 1 auto;
    min-width: 0;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding-bottom: 4px;
}

.filter-empty {
    min-height: 40px;
    display: flex;
    align-items: center;
}

@media (max-width: 600px) {
    .filter-row,
    .filter-if-part {
        flex-direction: column;
        gap: 4px;
    }

    .filter-conj,
    .filter-if-label {
        flex-basis: auto;
        min-height: 0;
    }

    .filter-input-field,
    .filter-input-step,
    .filter-input-operator,
    .filter-value {
        width: 100%;
        max-width: none;
        flex-basis: 100%;
    }
}

/* Reports: the settings in sections, the columns as reorderable boxes, and the summary as tiles. */
.report-title {
    flex: 0 1 22rem;
}

.report-section {
    border-top: 1px solid var(--mud-palette-lines-default);
    padding-top: 12px;
}

.report-section-title {
    margin-bottom: 8px;
    color: var(--mud-palette-text-secondary);
}

.report-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.report-column {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding-inline: 4px 2px;
    background: var(--mud-palette-background-gray);
    font-size: 0.875rem;
}

/* The values a report's variables are given, above its records. */
.report-variables {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.report-variable {
    flex: 0 1 16rem;
    min-width: 12rem;
}

.report-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* A grouped summary: a table (or a pivot) that scrolls past a screen's worth of groups. */
.report-summary-table {
    max-height: 24rem;
    overflow: auto;
}

.report-stat {
    min-width: 9rem;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-background-gray);
}

.report-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.report-stat-label {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

.report-card .report-stat {
    min-width: 7rem;
    padding: 6px 10px;
}

.report-card .report-stat-value {
    font-size: 1.125rem;
}

/* A calculation: a formula (left to right, as numbers read) with its field menu, or blocks nesting their operands. */
.expression-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 18rem;
    min-width: 14rem;
}

.expression-mode {
    align-self: flex-start;
}

.expression-formula {
    display: flex;
    align-items: center;
    gap: 4px;
}

.expression-formula .expression-text {
    flex: 1 1 auto;
}

/* A formula is written left to right, as it is read: "vis * 2 + 10". */
.formula-input input {
    direction: ltr;
    text-align: left;
}

/* A field the formula menu inserts: its label, and its key (or path) apart at the line's end, each kept in its own
   direction. */
.expression-option {
    display: flex;
    align-items: baseline;
    gap: 16px;
    width: 100%;
}

.expression-option .expression-key {
    margin-inline-start: auto;
}

.expression-key {
    margin-inline-start: 8px;
    font-family: monospace;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

/* What the formula reads, fields by label: in the formula's order, left to right. */
.expression-preview {
    direction: ltr;
    text-align: left;
    unicode-bidi: isolate;
}

.expr-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.expr-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.expr-op {
    width: 14rem;
}

.expr-number {
    width: 8rem;
}

.expr-operands {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-inline-start: 12px;
    border-inline-start: 2px solid rgba(var(--mud-palette-primary-rgb), 0.35);
}

/* Taking records: a sentence of inputs. */
.take-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.take-sentence {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.take-word {
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.take-number {
    width: 6rem;
}

.take-direction {
    width: 12rem;
}

/* A report's settings fold under a header line that sums them up. */
.report-settings {
    overflow: hidden;
}

.report-settings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.report-settings-header:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.05);
}

.report-settings-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-settings-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.report-settings-chip {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
}

.report-settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8125rem;
    color: var(--mud-palette-primary);
    white-space: nowrap;
}

.report-settings-chevron {
    transition: transform 0.2s ease;
}

.report-settings-header[aria-expanded="true"] .report-settings-chevron {
    transform: rotate(180deg);
}

.report-settings-body {
    padding: 0 16px 16px;
}

.report-icon-button {
    min-width: 0;
    width: 48px;
    height: 40px;
    padding: 0;
}

/* The icon picker: a grid of tiles. */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
    max-height: 22rem;
    overflow-y: auto;
}

.icon-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.icon-tile:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.08);
}

.icon-tile.picked {
    border-color: var(--mud-palette-primary);
    background-color: rgba(var(--mud-palette-primary-rgb), 0.14);
    color: var(--mud-palette-primary);
}

/* The sidebar's own choices. */
.sidebar-choices {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;
    border-radius: 8px;
}

.sidebar-choice:hover {
    background-color: rgba(var(--mud-palette-primary-rgb), 0.05);
}

/* A group in the sidebar dialog: its header, then its items set in. */
.sidebar-choice.sidebar-group-header {
    font-weight: 500;
}

.sidebar-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-inline-start: 1.25rem;
    padding-inline-start: 4px;
    border-inline-start: 1px solid var(--mud-palette-lines-default);
}

.sidebar-choice.unpinned {
    opacity: 0.65;
}

.sidebar-choice-name {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

/* The form's rules: cards in the designer ("if … then …"), and the parts of the rule dialog. */
.rule-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rule-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-inline-start: 3px solid var(--mud-palette-primary);
    border-radius: 8px;
    padding: 8px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--mud-palette-surface);
}

.rule-card-off {
    border-inline-start-color: var(--mud-palette-lines-default);
    opacity: .7;
}

.rule-card-head {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
}

.rule-card-name {
    font-weight: 700 !important;
}

/* The roles of a user (RoleAssignmentsEditor): a card per role, its edge colored by where it applies (everywhere,
   per form, per group), and the records it reaches in each form. */
.role-card {
    border: 1px solid var(--mud-palette-lines-default);
    border-inline-start: 4px solid var(--mud-palette-primary);
    border-radius: 10px;
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(90deg, rgba(var(--mud-palette-primary-rgb), 0.05), transparent 40%), var(--mud-palette-surface);
}

[dir="rtl"] .role-card {
    background: linear-gradient(270deg, rgba(var(--mud-palette-primary-rgb), 0.05), transparent 40%), var(--mud-palette-surface);
}

.role-card-global {
    border-inline-start-color: var(--mud-palette-secondary);
}

.role-card-group {
    border-inline-start-color: var(--mud-palette-tertiary);
}

/* A role given per form or group with no group or form picked, after a save was tried. */
.role-card-invalid {
    border-color: var(--mud-palette-error);
}

.role-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-card-title {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.role-card-title .mud-typography-subtitle2 {
    font-weight: 700;
}

.role-card-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.role-card-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--mud-palette-text-secondary);
}

.role-picker-hint {
    font-size: .75rem;
}

.role-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 10px;
}

.role-records {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    overflow: hidden;
}

.role-record {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 10px;
    min-height: 40px;
}

.role-record + .role-record {
    border-top: 1px solid var(--mud-palette-lines-default);
}

.role-record-narrowed {
    background: rgba(var(--mud-palette-warning-rgb), 0.08);
    box-shadow: inset 3px 0 0 var(--mud-palette-warning);
}

[dir="rtl"] .role-record-narrowed {
    box-shadow: inset -3px 0 0 var(--mud-palette-warning);
}

.role-record-form {
    font-weight: 600;
    white-space: nowrap;
}

.role-record-text {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--mud-palette-text-secondary);
    font-size: .85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-record-actions {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

@media (max-width: 599.98px) {
    .role-record {
        flex-wrap: wrap;
        padding-block: 6px;
    }

    .role-record-text {
        flex-basis: 100%;
        order: 3;
        white-space: normal;
    }

    .role-record-actions {
        margin-inline-start: auto;
    }
}

.rule-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
}

.rule-text {
    font-size: .875rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.rule-tag {
    flex: none;
    min-width: 48px;
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    line-height: 22px;
    border-radius: 11px;
    padding: 0 8px;
}

.rule-tag-if {
    color: var(--mud-palette-info-darken);
    background: rgba(var(--mud-palette-info-rgb), .12);
}

.rule-tag-then {
    color: var(--mud-palette-success-darken);
    background: rgba(var(--mud-palette-success-rgb), .12);
}

/* A chart's number, and how it moved since the period before. */
.chart-number {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px;
}

.chart-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chart-change-up {
    color: var(--mud-palette-success);
}

.chart-change-down {
    color: var(--mud-palette-error);
}

/* A chart whose bars and slices open their records. */
/* A chart still loading: its spinner in the middle of where the chart will be. */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    flex: 1 1 auto;
    width: 100%;
}

.chart-drillable .apexcharts-bar-area,
.chart-drillable .apexcharts-pie-area,
.chart-drillable .apexcharts-marker {
    cursor: pointer;
}

/* The whole of a text a table's cell cuts short, on hover. */
.cell-full-text {
    max-width: 420px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-align: start;
}

/* A form's default order of records: "by … then by …", a row per field. */
.sort-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 760px;
}

.sort-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
}

.sort-row .sort-field {
    flex: 1 1 14rem;
    min-width: 12rem;
    max-width: 22rem;
}

.sort-tag-then {
    color: var(--mud-palette-text-secondary);
    background: var(--mud-palette-action-default-hover);
}

.sort-actions {
    display: flex;
    margin-inline-start: auto;
}

.rule-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.rule-effect {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .8125rem;
    line-height: 1.5;
    padding: 1px 10px;
    border-radius: 12px;
    background: var(--mud-palette-background-gray);
    overflow-wrap: anywhere;
}

.rule-part {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rule-part-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rule-action {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rule-action-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

.rule-action-kind {
    flex: 0 0 210px;
}

.rule-action-fields {
    flex: 1 1 260px;
    min-width: 0;
}

.rule-kind-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rule-action-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

/* The calculation's editor grows along a condition's row; here it stands in a column. */
.rule-action-body > .expression-editor {
    flex: none;
}

.rule-action-label {
    font-weight: 700 !important;
}

.rule-value-mode {
    align-self: flex-start;
}

.batch-hidden {
    display: block;
    text-align: center;
    color: var(--mud-palette-text-disabled);
}

/* A chart image's preview: the chart drawn at the image's size, scaled down, framed as the image will be cut. */
.chart-image-preview {
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 4px;
    margin: 0 auto;
}

/* A transparent image's preview shows the checks it will be laid on. */
.chart-image-transparent {
    background: repeating-conic-gradient(#E8E8E8 0 25%, #FFFFFF 0 50%) 0 0 / 16px 16px;
}

/* A chart's colors: a palette's first few as small dots, and a color input per series. */
.chart-swatches {
    display: inline-flex;
    gap: 2px;
    margin-inline-end: 6px;
}

.chart-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.chart-color-input {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

/* A record exported as a PDF, shown to print or save. */
.pdf-frame {
    width: 100%;
    height: 75vh;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: #fff;
}

/* A PDF's first page as an image, drawn by the server where the browser shows no PDF in a frame (image-viewer.js): one
   finger scrolls, two zoom (the image widens, so the view scrolls over it). */
.pdf-preview {
    position: relative;
}

.pdf-preview-view {
    height: 75vh;
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    padding: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    background: var(--mud-palette-background-gray);
}

.pdf-preview-page {
    display: block;
    width: 100%;
    max-width: none;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    user-select: none;
    -webkit-user-drag: none;
}

.pdf-zoom {
    position: absolute;
    bottom: 12px;
    inset-inline-end: 12px;
    display: flex;
    border-radius: 999px;
    background: var(--mud-palette-surface);
    box-shadow: var(--mud-elevation-4);
}

/* A group of a form's exports: its options are cards inside it, in order. */
.export-group {
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-group-name {
    max-width: 320px;
}

.export-placeholders {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

/* A field of several values: its input, then its values as chips. */
.multi-value-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.multi-value.dense .multi-value-chips {
    margin-top: 2px;
}

/* The rows of a list entered with the record (an invoice's lines): a table that scrolls sideways when wide. */
.record-details-table {
    overflow-x: auto;
}

.record-details-table td {
    min-width: 8rem;
    vertical-align: top;
}

.record-details-table .record-details-index {
    min-width: 2rem;
    width: 2rem;
    color: var(--mud-palette-text-secondary);
}

/* ---------------------------------------------------------------- phones and touch */

/* A finger needs more than the stock 30px of a small icon button. */
@media (pointer: coarse) {
    .mud-icon-button.mud-icon-button-size-small {
        padding: 8px;
    }
}

/* The button that adds to a page's list (a record), floating at the bottom on the end side, where a thumb reaches. */
.page-fab {
    position: fixed !important;
    inset-inline-end: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 1100;
    box-shadow: 0 6px 18px rgba(var(--mud-palette-primary-rgb), 0.35), 0 2px 6px rgba(0, 0, 0, 0.12) !important;
}

/* A wide table scrolls sideways; its row buttons stay pinned to the end edge, so they never scroll out of reach. */
@media (min-width: 601px) {
    .mud-table-body .mud-table-cell.row-actions {
        position: sticky;
        inset-inline-end: 0;
        z-index: 1;
        background-color: var(--mud-palette-surface);
        box-shadow: inset 1px 0 0 var(--mud-palette-table-lines);
    }

    /* The row's stripe and hover are see-through tints: the pinned cell lays the same tint over its own ground. */
    .mud-table-striped .mud-table-body .mud-table-row:nth-of-type(odd) .mud-table-cell.row-actions {
        background-image: linear-gradient(var(--mud-palette-table-striped), var(--mud-palette-table-striped));
    }

    .mud-table-hover .mud-table-body .mud-table-row:hover .mud-table-cell.row-actions {
        background-image: linear-gradient(var(--mud-palette-table-hover), var(--mud-palette-table-hover));
    }
}

/* MudTable's phone layout (each row's cells under one another, at 600px and below) turned into a card per row: the
   cells as a list of labels and values, the first one (with .titled-rows) as the card's heading, and the row's
   buttons (.row-actions) as a bar along its foot. */
@media (max-width: 600px) {
    .mud-xs-table .mud-table-root,
    .mud-xs-table .mud-table-root .mud-table-body {
        display: block;
        width: 100%;
    }

    .mud-xs-table .mud-table-body {
        border-top: 0 !important;
    }

    .mud-xs-table .mud-table-root .mud-table-body .mud-table-row {
        display: block;
        margin-bottom: 12px;
        padding: 6px 0;
        border: 1px solid var(--mud-palette-lines-default);
        border-radius: 14px;
        background-color: var(--mud-palette-surface) !important;
        box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.04);
        overflow: hidden;
    }

    .mud-xs-table .mud-table-root .mud-table-body .mud-table-row:last-child {
        margin-bottom: 4px;
    }

    .mud-xs-table .mud-table-body .mud-table-row .mud-table-cell,
    .mud-xs-table.mud-table-dense .mud-table-body .mud-table-row .mud-table-cell {
        display: grid;
        grid-template-columns: minmax(5.5rem, 34%) minmax(0, 1fr);
        column-gap: 12px;
        align-items: baseline;
        padding: 7px 16px;
        border: 0;
        font-size: 0.9375rem;
        overflow-wrap: anywhere;
    }

    .mud-xs-table .mud-table-body .mud-table-row .mud-table-cell:last-child {
        border-bottom: 0;
    }

    .mud-xs-table .mud-table-body .mud-table-cell::before {
        grid-column: 1;
        padding: 0 !important;
        font-size: 0.8125rem;
        font-weight: 400;
        color: var(--mud-palette-text-secondary);
    }

    .mud-xs-table .mud-table-body .mud-table-cell > * {
        grid-column: 2;
        min-width: 0;
        max-width: 100%;
    }

    /* The heading: the first cell's label small above its value, set larger, a line under it. */
    .mud-xs-table.titled-rows .mud-table-body .mud-table-row .mud-table-cell:first-child {
        display: block;
        padding: 6px 16px 10px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--mud-palette-divider-light);
        font-size: 1.0625rem;
        font-weight: 600;
    }

    .mud-xs-table.titled-rows .mud-table-body .mud-table-cell:first-child::before {
        display: block;
        margin-bottom: 2px;
        font-size: 0.75rem;
    }

    /* The row's buttons: a bar on the card's foot, each a round tinted target, from the start side (the floating
       add button keeps to the end corner, where it would cover them). */
    .mud-xs-table .mud-table-body .mud-table-row .mud-table-cell.row-actions {
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 6px;
        margin-top: 4px;
        padding: 8px 12px 4px;
        border-top: 1px solid var(--mud-palette-divider-light);
    }

    .mud-xs-table .mud-table-body .mud-table-cell.row-actions::before {
        display: none;
    }

    .mud-xs-table .row-actions > div {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px;
    }

    .mud-xs-table .row-actions .mud-icon-button {
        width: 40px;
        height: 40px;
        padding: 8px;
        background-color: color-mix(in srgb, currentColor 9%, transparent);
    }

    /* Sorting, which the column heads do on a desktop, as a select above the cards. */
    .mud-xs-table .mud-table-smalldevices-sortselect {
        padding: 0 0 12px !important;
    }

    .mud-xs-table .mud-table-pagination {
        border-top: 0;
    }

    .mud-xs-table .mud-table-pagination-toolbar {
        flex-wrap: wrap;
        justify-content: center;
        padding-inline: 0;
    }

    /* A list's card loses its own frame on a phone, so the rows' cards stand on the page rather than in a box. */
    .list-surface {
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .list-surface .mud-table,
    .list-surface .mud-table-container {
        background: transparent;
    }
}

/* MudSimpleTable has no phone layout of its own: with .stack-table each row becomes a card, a cell per line, the
   cell's data-label above it. A .stack-head cell (the row's name or number) and a .stack-actions cell (its buttons)
   share the card's first line. */
@media (max-width: 599.98px) {
    .stack-table,
    .stack-table .mud-table-container {
        min-width: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    /* A row the server refused (batch entry): the whole card is marked. */
    .stack-table tbody tr.batch-row-failed {
        border-color: var(--mud-palette-error);
        background: var(--mud-palette-error-hover);
    }

    .stack-table tbody tr.batch-row-failed > td {
        background: transparent;
    }

    .stack-table table,
    .stack-table table > tbody {
        display: block !important;
        width: 100%;
        min-width: 0 !important;
    }

    .stack-table table > thead {
        display: none !important;
    }

    .stack-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 8px;
        row-gap: 6px;
        margin-bottom: 10px;
        padding: 10px 14px 12px;
        border: 1px solid var(--mud-palette-lines-default);
        border-radius: 14px;
        background: var(--mud-palette-surface);
    }

    .stack-table tbody td {
        display: block;
        grid-column: 1 / -1;
        min-width: 0 !important;
        width: auto !important;
        padding: 0 !important;
        border: 0 !important;
        white-space: normal;
    }

    .stack-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 0.75rem;
        color: var(--mud-palette-text-secondary);
    }

    .stack-table tbody td.stack-head {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        font-weight: 600;
        color: var(--mud-palette-text-primary);
    }

    .stack-table tbody td.stack-head[data-label]::before {
        display: inline;
        margin-inline-end: 4px;
        font-size: inherit;
        font-weight: 400;
    }

    .stack-table tbody td.stack-actions {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        text-align: end;
    }

    .stack-table tbody td.stack-actions::before {
        display: none;
    }
}

/* Phones: the page heading shrinks a step, its buttons share the row under it, a list's toolbar tightens, and a page
   with a floating button keeps room under its end for it. */
@media (max-width: 599.98px) {
    .page-header-icon {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 11px;
    }

    .page-header-title {
        font-size: 1.3rem !important;
    }

    /* Buttons take a row of their own; a lone menu (⋮) stays beside the title. */
    .page-header-actions:has(> .mud-button-root:not(.mud-fab), > .mud-button-group-root) {
        flex: 1 1 100%;
    }

    /* The form's pages share the width: the way back to the forms is in the drawer. */
    .form-tabs .form-tabs-back {
        display: none;
    }

    .form-tabs-strip {
        flex: 1 1 auto;
    }

    .form-tabs .form-tab {
        flex: 1 1 0;
        min-width: 0;
        padding-inline: 6px;
        font-size: 0.8125rem;
    }

    .form-tabs .form-tab .mud-button-icon-start {
        margin-inline: 0 4px;
    }

    .list-toolbar > .list-search {
        flex: 1 1 100%;
    }

    /* A button's words stay on one line; the heading beside it wraps instead. */
    .mud-button-root .mud-button-label {
        white-space: nowrap;
    }

    .mud-button-root {
        flex-shrink: 0;
    }

    /* A report's settings header: the name and the toggle on the first line, what it sums up (chips) under them. */
    .report-settings-header {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .report-settings-title {
        flex: 1 1 0;
        min-width: 0;
    }

    .report-settings-chips {
        order: 3;
        flex-basis: 100%;
    }

    /* A card's head row (a rule's, an export group's) wraps its buttons under its name rather than overflowing. */
    .rule-card-head {
        flex-wrap: wrap;
    }

    .rule-card-head .export-group-name {
        flex: 1 1 100%;
        max-width: none;
    }

    .page-header-actions > .mud-button-root,
    .page-header-actions > .mud-button-group-root {
        flex: 1 1 auto;
    }

    .list-toolbar .mud-button-root {
        padding-inline: 12px;
        font-size: 0.8125rem;
    }

    .has-fab {
        padding-bottom: 72px;
    }
}

/* The forms page (Forms/Index): the search with the tree's buttons and the view switch beside it, then the forms under
   their groups. */
.forms-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 8px;
}

.forms-toolbar .forms-search {
    flex: 1 1 260px;
    margin: 0;
}

.forms-toolbar-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.forms-view-switch {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    margin-inline-start: 4px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
}

.forms-view-switch .selected {
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
}

/* A row of the tree: a group or a form, set in by its level. */
.forms-tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 4px 8px;
    padding-inline-start: calc(var(--depth, 0) * 24px + 4px);
    border-radius: 8px;
    transition: background-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.forms-tree-row:hover {
    background: var(--mud-palette-action-default-hover);
}

.forms-tree-row[draggable="true"] {
    cursor: grab;
}

.forms-tree-main {
    flex: 1 1 auto;
    min-width: 0;
}

.forms-tree-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
}

.forms-tree-name {
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.forms-tree-group .forms-tree-name {
    font-weight: 600;
}

button.forms-tree-name:disabled {
    cursor: inherit;
}

a.forms-tree-name:hover,
a.forms-tree-name:focus-visible {
    color: var(--mud-palette-primary);
    text-decoration: underline;
}

/* How many forms a group holds, at any depth. */
.forms-tree-count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    line-height: 18px;
    text-align: center;
}

.forms-tree-tags {
    display: inline-flex;
    gap: 4px;
}

.forms-tree-tags .mud-chip {
    margin: 0;
}

.forms-tree-description {
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.forms-tree-meta {
    display: flex;
    flex: none;
    gap: 16px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

.forms-tree-actions {
    display: flex;
    flex: none;
    align-items: center;
}

/* The chevron opening a group, and the room it takes in rows without one. It points down while the group is open,
   towards the end of the line while it is folded. */
.forms-tree-spacer,
.forms-tree-chevron {
    flex: none;
    width: 30px;
}

.forms-tree-chevron .mud-icon-root {
    transition: transform 150ms ease;
}

.forms-tree-chevron.closed .mud-icon-root {
    transform: rotate(-90deg);
}

[dir="rtl"] .forms-tree-chevron.closed .mud-icon-root {
    transform: rotate(90deg);
}

/* Dragging a form or a group: what is dragged fades, the group it would go into is outlined. A row's parts take no
   pointer events meanwhile, so moving over them doesn't count as leaving the row. */
.forms-tree.dragging .forms-tree-row * {
    pointer-events: none;
}

.forms-tree-row.dragged {
    opacity: 0.45;
}

.forms-tree-row.drop-target {
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
    box-shadow: inset 0 0 0 2px var(--mud-palette-primary);
}

.forms-tree-drop-root {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 12px;
    border: 2px dashed var(--mud-palette-lines-inputs);
    border-radius: 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.forms-tree-drop-root * {
    pointer-events: none;
}

.forms-tree-drop-root.drop-target {
    border-color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
    color: var(--mud-palette-primary);
}

/* A name changed in place: the field with its tick and cross on one line. */
.inline-rename {
    display: flex;
    align-items: center;
    gap: 2px;
    max-width: 420px;
}

.inline-rename .mud-input-control {
    margin: 0;
}

/* On a phone the levels step in less, and the fields and last change give their room to the name. */
@media (max-width: 599.98px) {
    .forms-tree-row {
        padding-inline-start: calc(var(--depth, 0) * 14px + 2px);
    }

    .forms-tree-meta {
        display: none;
    }
}

/* Touch screens don't drag: the hint about it goes. */
@media (pointer: coarse) {
    .forms-tree-hint {
        display: none;
    }
}

/*
 * Dashboards, as Grafana draws them: a header with the dashboard's group, title and tools; a bar of its variables;
 * then its panels on a grid of 24 columns and 30px rows (gridstack places them; dashboard-grid.js). A panel is a card
 * with a slim header over what it shows. Edit mode lines the grid, and the headers become handles.
 */
.dash-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.dash-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

.dash-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.dash-heading-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.dash-heading-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dash-crumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
}

.dash-crumbs a {
    color: inherit;
    text-decoration: none;
}

.dash-crumbs a:hover {
    color: var(--mud-palette-primary);
}

.dash-crumb-sep:dir(ltr) {
    transform: scaleX(-1);
}

.dash-title {
    margin: 0;
    overflow: hidden;
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dash-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.dash-title-badge {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

.dash-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.dash-description {
    margin: -4px 0 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
}

/* The variables: a strip of inputs under the header, as Grafana sets them, each as wide as a value needs. */
.dash-variables .report-variables {
    gap: 8px 12px;
}

.dash-variables .report-variable {
    flex: 0 1 15rem;
    min-width: 11rem;
}

.dash-edit-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.05);
    font-size: 0.8125rem;
}

.dash-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 56px 16px;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 16px;
    text-align: center;
    background: var(--mud-palette-surface);
}

.dash-empty-icon {
    width: 56px !important;
    height: 56px !important;
    color: rgba(var(--mud-palette-primary-rgb), 0.55);
}

/* The grid: panels sit in cells with a 6px margin; while editing, its ground shows the rows. */
.dash-grid {
    min-height: 40px;
    margin-inline: -6px;
}

.dash-page.editing .dash-grid {
    border-radius: 12px;
    background-image: linear-gradient(to bottom, rgba(var(--mud-palette-primary-rgb), 0.05) 1px, transparent 1px);
    background-size: 100% 30px;
}

.dash-grid > .grid-stack-item > .grid-stack-item-content {
    inset: 6px;
    overflow: visible;
}

.grid-stack-placeholder > .placeholder-content {
    border: 2px dashed rgba(var(--mud-palette-primary-rgb), 0.5) !important;
    border-radius: 12px;
    background: rgba(var(--mud-palette-primary-rgb), 0.08) !important;
}

/* A panel: a card, its header over its body. */
.dash-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.04);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.dash-panel:hover {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.35);
}

.dash-panel-head {
    display: flex;
    flex: none;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding-block: 0;
    padding-inline: 10px 6px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.dash-panel-icon {
    flex: none;
    color: var(--mud-palette-primary);
}

.dash-panel-titles {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.dash-panel-title {
    overflow: hidden;
    font-size: 0.875rem;
    font-weight: 600;
    text-overflow: ellipsis;
}

.dash-panel-sub {
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    text-overflow: ellipsis;
}

.dash-panel-info {
    flex: none;
    color: var(--mud-palette-text-secondary);
    cursor: help;
}

.dash-panel-spinner {
    width: 16px !important;
    height: 16px !important;
}

.dash-panel-head .mud-icon-button {
    padding: 4px;
}

/* The menu stays quiet until the panel is pointed at (always there for a finger). */
.dash-panel-menu {
    opacity: 0.55;
    transition: opacity 0.15s ease;
}

.dash-panel:hover .dash-panel-menu,
.dash-panel-menu:focus-within {
    opacity: 1;
}

@media (pointer: coarse) {
    .dash-panel-menu {
        opacity: 1;
    }
}

.dash-panel-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.dash-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    padding: 12px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    text-align: center;
}

/* While editing: the card lifts a little, and its header is the handle that drags it. */
.dash-panel.editing {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.35);
}

.dash-panel.editing .dash-panel-handle {
    cursor: move;
    background: rgba(var(--mud-palette-primary-rgb), 0.05);
    user-select: none;
}

.dash-panel-grip {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

.grid-stack-item.ui-draggable-dragging .dash-panel,
.grid-stack-item.ui-resizable-resizing .dash-panel {
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
}

.dash-grid .ui-resizable-se,
.dash-grid .ui-resizable-sw {
    width: 18px;
    height: 18px;
    background: none;
}

.dash-grid .ui-resizable-se::after,
.dash-grid .ui-resizable-sw::after {
    position: absolute;
    bottom: 10px;
    width: 8px;
    height: 8px;
    border-bottom: 2px solid rgba(var(--mud-palette-primary-rgb), 0.6);
    content: "";
}

.dash-grid .ui-resizable-se::after {
    right: 10px;
    border-right: 2px solid rgba(var(--mud-palette-primary-rgb), 0.6);
}

.dash-grid .ui-resizable-sw::after {
    left: 10px;
    border-left: 2px solid rgba(var(--mud-palette-primary-rgb), 0.6);
}

/* What panels show: a compact table, a report's summary over it, a chart filling the body. */
.dash-table.mud-table {
    background: transparent;
}

.dash-table .mud-table-cell {
    padding: 6px 10px;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.dash-table .mud-table-pagination-toolbar {
    min-height: 40px;
    height: 44px;
    padding: 0 6px;
}

.dash-report {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.dash-report-summary {
    flex: none;
    overflow: auto;
    padding: 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.dash-chart {
    height: 100%;
    padding: 8px;
}

.dash-chart .chart-number {
    justify-content: center;
    min-height: 100%;
}

/*
 * On a phone (the grid's one column, gs-1) a panel of tiles (a number chart's several values, a numbers panel) takes
 * the height its tiles need: they wrap to more rows than on the wide grid, which the panel's own height would cut off.
 * dashboard-grid.js fits the grid's cell to it (resizeToContent), and the wide grid keeps the heights it was given.
 */
.dash-grid.gs-1 .dash-panel:has(.chart-stats, .dash-numbers) {
    height: auto;
}

/* Once measured, it fills its cell (whole rows), as every other panel does. */
.dash-grid.gs-1 > .grid-stack-item.fit-fill > .grid-stack-item-content > .dash-panel {
    min-height: 100%;
}

.dash-grid.gs-1 .dash-panel:has(.chart-stats, .dash-numbers) .dash-panel-body {
    flex: none;
    height: auto !important;
}

.dash-grid.gs-1 .dash-chart:has(> .chart-stats),
.dash-grid.gs-1 .dash-chart > .chart-stats,
.dash-grid.gs-1 .dash-numbers {
    height: auto;
}

.dash-grid.gs-1 .dash-numbers {
    overflow: visible;
}

/* A narrow panel gives its title the room: what it shows is named on hover. */
.dash-panel {
    container-type: inline-size;
}

@container (max-width: 340px) {
    .dash-panel-sub {
        display: none;
    }
}

/* A panel alone over the window. */
.dash-view-content {
    padding: 8px !important;
}

.dash-panel-full {
    border-radius: 14px;
}

.dash-kind-toggle {
    width: 100%;
}

.dash-kind-toggle .mud-toggle-item {
    flex: 1 1 0;
}

.dash-variable-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
}

.dash-variable-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.dash-variable-label {
    font-weight: 600;
}

.dash-variable-sub {
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dash-variables-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px;
    color: var(--mud-palette-text-secondary);
}

.add-dash-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.07);
}

.add-dash-item .mud-typography {
    color: var(--mud-palette-text-primary);
}

/* The list of dashboards: by group, each a card. */
.dash-list-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.dash-list-find {
    flex: 1 1 260px;
    max-width: 420px;
}

.dash-list-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dash-list-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.dash-list-count {
    min-width: 1.25rem;
    padding: 0 6px;
    border-radius: 9px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
    font-size: 0.6875rem;
    line-height: 1.125rem;
    text-align: center;
}

.dash-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.dash-card {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 14px;
    color: inherit;
    background: var(--mud-palette-surface);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.dash-card:hover {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.45);
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.08);
    transform: translateY(-1px);
}

.dash-card:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.dash-card-icon {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.dash-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.dash-card-title {
    display: flex;
    align-items: center;
    font-weight: 600;
}

.dash-card-text {
    display: -webkit-box;
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.dash-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
}

.dash-card-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dash-card-meta .mud-icon-root {
    font-size: 0.95rem;
}

/* A phone: the title wraps, the tools take a row of their own, the grid is one column (gridstack's). */
@media (max-width: 599.98px) {
    .dash-title {
        font-size: 1.125rem;
        white-space: normal;
    }

    .dash-heading-icon {
        width: 38px;
        height: 38px;
    }

    .dash-actions {
        width: 100%;
    }

    .dash-variables {
        flex-direction: column;
    }

    .dash-variables-icon {
        display: none;
    }
}

/* In the sidebar, dashboards read apart by their icon's colour. */
.app-drawer .nav-kind-dashboard .nav-item-icon {
    color: var(--mud-palette-primary);
}

/*
 * A dashboard on A4 paper (DashboardPrint): on screen, a bar over a white sheet; printed, the sheet alone. The sheet
 * is the paper less its margins (the component's @page), 190mm wide in portrait and 277mm in landscape, never narrower,
 * so the panels are laid out on screen as they print, on a phone as on a desktop. Its panels sit in bands: grids of 24
 * columns and 30px rows, as the dashboard's, each kept whole on one page.
 */
.dash-print {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100vh;
    padding: 12px 16px 32px;
    background: var(--mud-palette-background-gray);
}

.dash-print-bar {
    position: sticky;
    top: 8px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    width: 100%;
    max-width: 297mm;
    margin-inline: auto;
    padding: 8px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    background: var(--mud-palette-surface);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

.dash-print-scale.mud-input-control {
    flex: none;
    width: 140px;
    margin: 0;
}

.dash-print-reading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

.dash-print-hint {
    max-width: 297mm;
    margin: 0 auto;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

/* A sheet wider than the window scrolls sideways: it never narrows, so what prints is what shows. */
.dash-print-scroll {
    overflow-x: auto;
    padding-block: 8px;
}

.dash-sheet {
    box-sizing: content-box;
    width: 190mm;
    margin-inline: auto;
    padding: 10mm;
    color: var(--mud-palette-text-primary);
    background: #fff;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12), 0 8px 24px rgba(16, 24, 40, 0.08);
}

.dash-sheet.landscape {
    width: 277mm;
}

.dash-sheet-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.dash-sheet-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-sheet-title-row .dash-heading-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.dash-sheet-titles {
    flex: 1 1 auto;
    min-width: 0;
}

.dash-sheet-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.4;
}

.dash-sheet-date {
    flex: none;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    direction: ltr;
    unicode-bidi: isolate;
}

.dash-sheet-description {
    margin: 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    white-space: pre-line;
}

/* The values the dashboard was printed with: read, not changed. */
.dash-sheet .dash-variables .mud-input.mud-disabled,
.dash-sheet .dash-variables .mud-input-label.mud-disabled {
    color: var(--mud-palette-text-primary);
}

.dash-band {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Columns run left to right, as gridstack lays the dashboard out (.grid-stack-rtl), so paper isn't the screen's mirror;
   what the panels show keeps the page's direction. */
.dash-band,
.dash-page-grid {
    direction: ltr;
}

[dir="rtl"] .dash-band > .dash-band-cell,
[dir="rtl"] .dash-page-grid > .dash-band-cell {
    direction: rtl;
}

/* A band taller than a page (staggered panels) breaks between panels, never through one. */
.dash-band-cell {
    display: flex;
    min-width: 0;
    padding: 6px;
    break-inside: avoid;
    page-break-inside: avoid;
}

/* On paper a panel fills its cell, and grows (its band with it) to hold a report's summary in full. */
.dash-panel.printing {
    flex: 1 1 auto;
    min-width: 0;
    height: auto;
}

.dash-panel.printing,
.dash-panel.printing:hover {
    border-color: var(--mud-palette-lines-default);
    box-shadow: none;
}

.dash-panel.printing .dash-report {
    height: auto;
}

.dash-panel.printing .dash-report-summary {
    overflow: visible;
}

/* Nothing scrolls on paper: no scrollbars on the sheet. */
.dash-sheet,
.dash-sheet * {
    scrollbar-width: none;
}

.dash-sheet ::-webkit-scrollbar {
    display: none;
}

/* Where a page ends, on screen. */
.dash-page-break {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-block: 10mm 4px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.6875rem;
}

.dash-page-break::before,
.dash-page-break::after {
    content: "";
    flex: 1 1 auto;
    border-top: 1px dashed var(--mud-palette-lines-inputs);
}

@media print {
    html,
    body,
    .mud-layout,
    .mud-main-content {
        background: #fff !important;
    }

    .dash-print {
        display: block;
        min-height: 0;
        padding: 0;
        background: none;
    }

    .dash-print-bar,
    .dash-print-hint {
        display: none !important;
    }

    .dash-print-scroll {
        overflow: visible;
        padding: 0;
    }

    /* The page has no margins (the browser prints nothing around it): the sheet keeps them, its top on the first
       page, and a band starting a page (DashboardPrint works out which) on the others. */
    .dash-sheet,
    .dash-sheet.landscape {
        width: auto;
        margin: 0;
        padding: 10mm 10mm 0;
        box-shadow: none;
    }

    .dash-page-break {
        display: none;
    }

    .dash-band.page-start {
        break-before: page;
        page-break-before: always;
        padding-top: 10mm;
    }

    .dash-sheet-head {
        break-after: avoid;
    }

    .dash-sheet,
    .dash-sheet * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

}

/*
 * A print layout (DashboardPrintPages, and DashboardPrintEditor while it is edited): a sheet per A4 page, exactly a
 * page's height, a grid of 24 columns and 30px rows; the first page's top rows hold the header (held to its rows: what doesn't fit
 * is cut, the description on one line).
 */
.dash-print-page-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 28px;
    margin: 6px auto 2px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
}

.dash-sheet.paged {
    height: 277mm;
    overflow: hidden;
}

.dash-sheet.paged.landscape {
    height: 190mm;
}

.dash-page-grid {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
}

.dash-sheet-head.dash-sheet-head-rows {
    box-sizing: border-box;
    margin-bottom: 0;
    overflow: hidden;
}

.dash-sheet-head.dash-sheet-head-rows .dash-sheet-description {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-sheet-head.dash-sheet-head-rows .dash-variables .report-variables {
    flex-wrap: nowrap;
    overflow: hidden;
}

/* The editor: the panels that print on the side, the pages beside them. */
.dash-print-editor {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.dash-print-editor > .dash-print-scroll {
    flex: 1 1 auto;
    min-width: 0;
}

.dash-print-side {
    position: sticky;
    top: 76px;
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 8px;
    width: 240px;
    max-height: calc(100vh - 96px);
    padding: 12px;
    overflow: auto;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    background: var(--mud-palette-surface);
}

.dash-print-side-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.dash-print-side-hint {
    margin: 0;
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
}

.dash-print-source {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    background: var(--mud-palette-surface);
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.dash-print-source:hover {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.5);
}

.dash-print-source.placed {
    opacity: 0.6;
    cursor: default;
}

/* The copy dragged onto a page. */
.dash-print-source.ui-draggable-dragging {
    z-index: 2000;
    width: 216px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
    cursor: grabbing;
}

/* A thumbnail of the panel: its kind's icon in its shape on the dashboard. */
.dash-print-thumb {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 56px;
    min-height: 16px;
    max-height: 56px;
    overflow: hidden;
    border: 1px solid rgba(var(--mud-palette-primary-rgb), 0.3);
    border-radius: 6px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
}

.dash-print-source-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.dash-print-source-title {
    overflow: hidden;
    font-size: 0.8125rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-print-source-sub {
    color: var(--mud-palette-text-secondary);
    font-size: 0.6875rem;
}

.dash-print-source-check {
    flex: none;
}

/* A page's grid while it is edited: its rows lined, as the dashboard's in edit mode. */
.dash-print-grid {
    background-image: linear-gradient(to bottom, rgba(var(--mud-palette-primary-rgb), 0.06) 1px, transparent 1px);
    background-size: 100% 30px;
}

.dash-print-grid > .grid-stack-item > .grid-stack-item-content {
    inset: 6px;
    overflow: visible;
}

.dash-print-add-page {
    display: flex;
    justify-content: center;
    padding: 8px 0 24px;
}

@media (max-width: 959.98px) {
    .dash-print-editor {
        flex-direction: column;
        align-items: stretch;
    }

    .dash-print-side {
        position: static;
        flex-direction: row;
        width: auto;
        max-height: none;
        overflow-x: auto;
    }

    .dash-print-source {
        flex: none;
        width: 200px;
    }
}

/* On paper, after the screen's rules above: a page laid out by the user is a page of paper, its margins its own (a
   hair short, so it never spills over), and its label goes. */
@media print {
    .dash-print-page-label {
        display: none;
    }

    .dash-sheet.paged,
    .dash-sheet.paged.landscape {
        box-sizing: border-box;
        width: auto;
        height: calc(297mm - 0.5mm);
        margin: 0;
        padding: 10mm;
        break-after: page;
        page-break-after: always;
    }

    .dash-sheet.paged.landscape {
        height: calc(210mm - 0.5mm);
    }

    .dash-sheet.paged.last {
        break-after: auto;
        page-break-after: auto;
    }
}

/*
 * The sidebar of a phone or a tablet (MobileSidebar): a sheet wider than the desktop's, in rows a finger hits, with
 * the user and the look at hand. The drawer opens over the page below the desktop width.
 */
@media (max-width: 959.98px) {
    .app-drawer.mud-drawer {
        width: min(88vw, 360px) !important;
        --mud-drawer-width-left: min(88vw, 360px);
        --mud-drawer-width-right: min(88vw, 360px);
        border-inline-end: 0;
        box-shadow: 0 0 40px rgba(10, 16, 18, 0.25);
    }

    .app-drawer.mud-drawer .mud-drawer-content {
        height: 100%;
    }
}

.m-nav {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--mud-palette-surface);
}

.m-nav-head {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    padding-block: 14px 6px;
    padding-inline: 18px 14px;
}

.m-nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.m-nav-app {
    color: var(--mud-palette-primary);
    font-size: 1.0625rem;
    font-weight: 700;
}

.m-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    color: var(--mud-palette-text-secondary);
    background: transparent;
    cursor: pointer;
}

.m-nav-close:active {
    background: rgba(var(--mud-palette-primary-rgb), 0.12);
}

.m-nav-user {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
    margin: 6px 12px 10px;
    padding: 10px 12px;
    border-radius: 16px;
    color: inherit;
    background: linear-gradient(135deg, rgba(var(--mud-palette-primary-rgb), 0.14), rgba(var(--mud-palette-primary-rgb), 0.04));
    text-decoration: none;
}

.m-nav-avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    background: var(--mud-palette-primary);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.m-nav-user-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.m-nav-user-name {
    overflow: hidden;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.m-nav-user-sub {
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

.m-nav-chevron {
    flex: none;
    color: var(--mud-palette-text-secondary);
}

.m-nav-chevron:dir(ltr) {
    transform: scaleX(-1);
}

/* The body scrolls between the fixed head and foot. */
.m-nav-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 12px;
    overscroll-behavior: contain;
}

.app-drawer .m-nav .nav-finder {
    height: 48px;
    margin: 4px 12px 12px;
    padding: 0 14px;
    border-radius: 14px;
    background: rgba(var(--mud-palette-primary-rgb), 0.05);
}

.app-drawer .m-nav .nav-finder-input {
    font-size: 1rem;
}

.app-drawer .m-nav .nav-finder-icon {
    font-size: 1.375rem;
}

.app-drawer .m-nav .nav-finder-label {
    margin: 14px 20px 4px;
    font-size: 0.8125rem;
}

/* Shortcuts: tiles two by two, each an icon by its name. */
.m-nav-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 12px 6px;
}

.m-nav-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 14px;
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-surface);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.m-nav-tile .mud-icon-root {
    flex: none;
    color: var(--mud-palette-primary);
    font-size: 1.5rem;
}

.m-nav-tile span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.m-nav-tile:active {
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.m-nav-tile.active {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.5);
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.m-nav-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 18px 20px 8px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.m-nav-label-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 18px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.m-nav-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 24px);
    min-height: 52px;
    margin: 12px;
    padding: 0 14px;
    border: 1px dashed var(--mud-palette-lines-default);
    border-radius: 14px;
    color: var(--mud-palette-primary);
    background: transparent;
    font: inherit;
    cursor: pointer;
}

/* The tree, for fingers: rows of 48px, larger icons and text, groups as cards. */
.app-drawer .m-nav .mud-nav-link {
    min-height: 48px;
    margin: 2px 12px;
    padding: 0.5rem 0.875rem;
    border-radius: 12px;
    font-size: 0.9375rem;
}

.app-drawer .m-nav .nav-item {
    gap: 14px;
}

.app-drawer .m-nav .nav-item-icon {
    width: 24px !important;
    height: 24px !important;
}

.app-drawer .m-nav .nav-item-sub {
    font-size: 0.75rem;
}

.app-drawer .m-nav-tree .nav-section-group.nested {
    margin: 6px 12px;
    overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 16px;
    background: var(--mud-palette-surface);
}

.app-drawer .m-nav-tree .nav-section-group.nested .nav-section-group.nested {
    margin: 6px 8px;
    border-radius: 12px;
    background: rgba(var(--mud-palette-primary-rgb), 0.025);
}

.app-drawer .m-nav-tree .nav-section-group.nested > .nav-section-head {
    margin: 0;
}

.app-drawer .m-nav-tree .nav-section-group.nested > .nav-section-head > .nav-section-header {
    gap: 12px;
    min-height: 52px;
    padding: 0.5rem 0.875rem;
    border-radius: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.app-drawer .m-nav-tree .nav-section-group.nested > .nav-section-head .nav-section-icon {
    flex: none;
    width: 34px !important;
    height: 34px !important;
    padding: 6px;
    border-radius: 10px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
}

.app-drawer .m-nav-tree .nav-section-group.nested > .nav-section-head .nav-section-count {
    min-width: 1.5rem;
    padding: 0 7px;
    border-radius: 11px;
    color: var(--mud-palette-primary);
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
    font-size: 0.75rem;
    line-height: 1.375rem;
}

.app-drawer .m-nav-tree .nav-section-group.nested > .nav-section-head .nav-section-chevron {
    font-size: 1.5rem;
}

.app-drawer .m-nav-tree .nav-section-items {
    margin: 0;
    padding: 0 0 6px;
    border: 0;
}

.app-drawer .m-nav-tree .nav-section-items .mud-nav-link {
    margin: 2px 8px;
}

.app-drawer .m-nav-tree .nav-section-group.nested.active-within.collapsed > .nav-section-head > .nav-section-header {
    background: rgba(var(--mud-palette-primary-rgb), 0.08);
}

.app-drawer .m-nav .mud-nav-link.active {
    background: rgba(var(--mud-palette-primary-rgb), 0.14);
}

/* The foot stays put: the look in three, then signing out. */
.m-nav-foot {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

.m-nav-theme {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(var(--mud-palette-primary-rgb), 0.06);
}

.m-nav-theme-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    color: var(--mud-palette-text-secondary);
    background: transparent;
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.m-nav-theme-option.selected {
    color: var(--mud-palette-primary);
    background: var(--mud-palette-surface);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12);
    font-weight: 600;
}

.m-nav-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 14px;
    color: var(--mud-palette-error);
    background: transparent;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
}

.m-nav-logout:active {
    background: rgba(var(--mud-palette-error-rgb), 0.08);
}

/* The sidebar dialog: a group of forms, its items set in under it. */
.sidebar-choice-group + .sidebar-choice-group {
    margin-top: 4px;
}

/*
 * Number charts colored by their thresholds (--stat-color): the number tinted, or its tile filled with the color and the
 * number written in white. Several values sit side by side as tiles, as Grafana's stat panel lays them out.
 */
.chart-number {
    border-radius: 12px;
}

.chart-number.tinted .chart-number-value {
    color: var(--stat-color);
}

.chart-number.filled {
    color: #fff;
    background: var(--stat-color);
}

.chart-number.filled .chart-change,
.chart-number.filled .chart-change-since {
    color: rgba(255, 255, 255, 0.85);
}

.chart-number-value {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.chart-stats {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    height: 100%;
    align-content: stretch;
}

.chart-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 10px 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    text-align: center;
}

.chart-stat-label {
    max-width: 100%;
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chart-stat-value {
    font-size: clamp(1.25rem, 2.6vw, 2.25rem);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    line-height: 1.2;
}

.chart-stat.tinted .chart-stat-value {
    color: var(--stat-color);
}

.chart-stat.filled {
    border-color: transparent;
    color: #fff;
    background: var(--stat-color);
}

.chart-stat.filled .chart-stat-label {
    color: rgba(255, 255, 255, 0.85);
}

/*
 * Gauges (ChartGauge): a dial scaled to its box, a tile each when there are several, as the number's tiles. The arc's
 * dash and the needle's turn move to a new value, at once on a dashboard refreshing itself (still).
 */
.chart-gauges {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    height: 100%;
}

.chart-gauges.single {
    grid-template-columns: 1fr;
}

.chart-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    min-height: 0;
}

.chart-gauges:not(.single) .chart-gauge {
    padding: 6px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
}

/* A heatmap's cells parted by the panel's own ground (ApexCharts draws white lines, glaring in the dark theme). */
.apexcharts-heatmap-rect {
    stroke: var(--mud-palette-surface);
}

.chart-gauge-label {
    flex: none;
    max-width: 100%;
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chart-gauge-dial {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    max-height: var(--gauge-height, 320px);
}

.chart-gauge-track,
.chart-gauge-value,
.chart-gauge-band {
    fill: none;
}

.chart-gauge-track {
    stroke: var(--mud-palette-action-disabled-background);
    stroke-width: 18;
}

.chart-gauge-value {
    stroke-width: 18;
    transition: stroke-dasharray 0.6s ease, stroke 0.6s ease;
}

.chart-gauge-band {
    stroke-width: 5;
}

.chart-gauge-needle {
    transform-box: view-box;
    transform-origin: 100px 100px;
    transition: transform 0.6s ease;
}

.chart-gauge.still .chart-gauge-value,
.chart-gauge.still .chart-gauge-needle {
    transition: none;
}

.chart-gauge-text {
    fill: var(--mud-palette-text-primary);
    font-size: 30px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    text-anchor: middle;
    dominant-baseline: middle;
}

.chart-gauge-end {
    fill: var(--mud-palette-text-secondary);
    font-size: 10px;
    text-anchor: middle;
}

.dash-number .chart-gauges {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 6px;
}

/* A field an aggregate groups by or measures (AggregateFieldPicker): its label over a select per link of its path. */
.aggregate-field {
    display: flex;
    flex: 1 1 14rem;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.aggregate-field.dense {
    flex: 0 1 auto;
}

.aggregate-field-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* A measure of a chart (ChartMeasureEditor): a card of its function, field and name, then its condition, derivation
   and series drawing. */
.chart-measure {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
}

.chart-measure-main,
.chart-measure-more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.chart-measure-function {
    flex: 0 1 10rem;
}

.chart-measure-label {
    flex: 1 1 10rem;
}

.chart-measure-derive {
    flex: 0 1 13rem;
}

.chart-measure-scale {
    flex: 0 1 7rem;
}

.chart-measure-condition {
    padding-top: 4px;
    border-top: 1px dashed var(--mud-palette-lines-default);
}

/* The thresholds editor: a step per row, its value then its color. */
.threshold-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.threshold-row .chart-color-input {
    flex: none;
}

/* A numbers panel: its charts side by side, each a cell with its title over its number or tiles. */
.dash-numbers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    height: 100%;
    padding: 8px;
    overflow: auto;
}

.dash-number {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
    overflow: hidden;
}

.dash-number-title {
    flex: none;
    padding: 6px 10px 0;
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dash-number-error {
    padding: 10px;
    color: var(--mud-palette-text-secondary);
    font-size: 0.8125rem;
}

/* A number alone fills its cell; its tiles lose their own frame inside it. */
.dash-number .chart-number {
    flex: 1 1 auto;
    justify-content: center;
    padding: 8px;
    border-radius: 0;
}

.dash-number .chart-number .mud-typography-h3 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
}

/* How it moved, under the number of a narrow cell: centred lines rather than a ragged wrap. */
.dash-number .chart-change {
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 4px;
    row-gap: 0;
    font-size: 0.75rem;
    text-align: center;
}

.dash-number .chart-stats {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 6px;
}

/* The dialog's picks: a form, then its number chart. */
.dash-number-pick {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    align-items: center;
    gap: 8px;
}

@media (max-width: 599.98px) {
    .dash-number-pick {
        grid-template-columns: 1fr auto auto;
    }

    .dash-number-pick > :nth-child(2) {
        grid-row: 2;
        grid-column: 1 / -1;
    }
}

/* A form picked (FormSelect): its groups as headings over their forms, set in by level. The popover is never
   narrower than a phone allows nor than a readable list, even under a narrow filter input. */
.form-select-popover {
    min-width: min(20rem, calc(100vw - 32px));
}

.form-select-popover .mud-list-item-disabled {
    color: var(--mud-palette-text-secondary) !important;
    padding-block: 2px;
}

.form-select-group,
.form-select-form {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.form-select-group {
    font-size: 0.8125rem;
    font-weight: 600;
    padding-top: 4px;
}

.form-select-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pickers on a touch screen (ResponsiveAutocomplete): the field is read only (no keyboard) and opens PickerDialog, on a
   phone a sheet from the bottom as every dialog there (above). It fits its rows, and stands tall while its search has
   the focus, so the search stays above the keyboard with the first rows under it. LoadMoreTrigger closes a list that
   reads pages, in the dialog as in a desktop popover. */
.picker-field input {
    cursor: pointer;
    caret-color: transparent;
}

.mud-dialog.picker-dialog {
    display: flex;
    flex-direction: column;
    max-height: min(640px, 80vh);
}

.mud-dialog-container .mud-dialog.picker-dialog .picker-dialog-head {
    flex: none;
    padding: 8px 16px 12px;
}

.picker-dialog-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
}

.picker-dialog-title {
    flex: 1;
    min-width: 0;
    font-weight: 600 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-dialog-search .mud-input-outlined-border {
    border-radius: 12px;
    border-color: rgba(var(--mud-palette-primary-rgb), 0.45);
}

.picker-dialog-search .mud-input-adornment .mud-icon-root {
    color: var(--mud-palette-primary);
}

.picker-dialog-search.mud-input-control {
    margin-top: 4px;
}

.mud-dialog-container .mud-dialog.picker-dialog .picker-dialog-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 0 8px 8px;
    border-top: 2px solid rgba(var(--mud-palette-primary-rgb), 0.35);
}

.picker-dialog-progress {
    position: sticky !important;
    top: 0;
    z-index: 2;
    margin-inline: -8px;
}

.picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
}

/* Each row a card: its border tinted, its start edge in the row's own colour (--picker-tone, by its text), the colour
   mixed with the theme's text so it reads on light and dark grounds alike. */
.picker-row {
    --picker-tone: var(--mud-palette-primary);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--picker-tone) 28%, transparent);
    border-inline-start: 4px solid var(--picker-tone);
    border-radius: 12px;
    background-color: color-mix(in srgb, var(--picker-tone) 5%, var(--mud-palette-surface));
    font-size: 0.9375rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.12s, border-color 0.12s, transform 0.12s;
}

.picker-row:active {
    background-color: color-mix(in srgb, var(--picker-tone) 14%, var(--mud-palette-surface));
    border-color: color-mix(in srgb, var(--picker-tone) 55%, transparent);
    transform: scale(0.99);
}

/* The one picked: the primary colour all round. */
.picker-row-selected {
    border-color: var(--mud-palette-primary);
    border-inline-start-color: var(--mud-palette-primary);
    background-color: rgba(var(--mud-palette-primary-rgb), 0.12);
    box-shadow: 0 0 0 1px var(--mud-palette-primary);
    color: var(--mud-palette-primary);
    font-weight: 500;
}

/* A heading among the rows (a group of forms): small, in the primary colour, kept in view over its rows. */
.picker-row-disabled {
    position: sticky;
    top: 0;
    z-index: 1;
    min-height: 32px;
    margin-top: 4px;
    padding: 8px 4px 2px;
    border: none;
    border-radius: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
    background-color: var(--mud-palette-surface);
    cursor: default;
}

.picker-row-disabled:active {
    background-color: var(--mud-palette-surface);
    transform: none;
}

.picker-badge {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--picker-tone) 40%, transparent);
    background-color: color-mix(in srgb, var(--picker-tone) 16%, transparent);
    color: color-mix(in srgb, var(--picker-tone) 75%, var(--mud-palette-text-primary));
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1;
}

.picker-row-content {
    flex: 1;
    min-width: 0;
}

.picker-row-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.picker-mark {
    background-color: transparent;
    color: var(--mud-palette-primary);
    font-weight: 600;
}

.picker-row-check {
    flex-shrink: 0;
}

.picker-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--mud-palette-text-secondary);
}

.picker-more {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

@media (max-width: 599.98px) {
    .mud-dialog-container .mud-dialog.picker-dialog {
        max-height: 85vh;
        max-height: 85dvh;
    }

    .mud-dialog-container .mud-dialog.picker-dialog:has(.picker-dialog-search input:focus) {
        height: 85vh;
        height: 85dvh;
    }

    .mud-dialog-container .mud-dialog.picker-dialog .picker-dialog-head {
        padding: 8px 16px 12px;
    }

    .mud-dialog-container .mud-dialog.picker-dialog .picker-dialog-list {
        padding: 0 8px 8px;
    }
}

/* The language menu on the sign-in pages (AuthenticationLayout, roadmap plan 04): at the top's end corner. */
.app-auth-language {
    position: fixed;
    top: 8px;
    inset-inline-end: 8px;
    z-index: 10;
}
