/* ==========================================================================
   HemaCore — Application styles
   Design tokens, refined Bootstrap overrides, and component polish.
   ========================================================================== */

:root {
    /* Brand palette (extracted from the HemaCore logo) */
    --hc-primary:        #1b6ec2;
    --hc-primary-dark:   #134e8a;
    --hc-primary-soft:   #e8f1fb;
    --hc-accent:         #9E2A2B;
    --hc-accent-soft:    #fbeaea;
    --hc-deep-blue:      #264267;

    /* Neutral palette */
    --hc-surface:        #ffffff;
    --hc-bg:             #f5f7fa;
    --hc-border:         #e3e7ed;
    --hc-text:           #1f2d3d;
    --hc-muted:          #6b7785;

    /* Effects */
    --hc-shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --hc-shadow-md:      0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --hc-shadow-lg:      0 10px 20px -3px rgba(15, 23, 42, 0.08), 0 4px 8px -4px rgba(15, 23, 42, 0.06);
    --hc-radius:         0.65rem;
    --hc-radius-lg:      1rem;
    --hc-transition:     150ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Bootstrap overrides */
    --bs-primary:        var(--hc-primary);
    --bs-primary-rgb:    27, 110, 194;
    --bs-body-bg:        var(--hc-bg);
    --bs-body-color:     var(--hc-text);
    --bs-border-color:   var(--hc-border);
}

/* --------------------------------------------------------------------------
   Base layout
   -------------------------------------------------------------------------- */
html, body {
    font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--hc-bg);
    color: var(--hc-text);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
}

a, .btn-link {
    color: var(--hc-primary);
    text-decoration: none;
    transition: color var(--hc-transition);
}

    a:hover, .btn-link:hover {
        color: var(--hc-primary-dark);
    }

.text-primary {
    color: var(--hc-primary) !important;
}

.brand-blue {
    color: var(--hc-deep-blue) !important;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.01em;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    transition: transform var(--hc-transition), box-shadow var(--hc-transition), background-color var(--hc-transition), border-color var(--hc-transition), color var(--hc-transition);
    font-weight: 500;
}

    .btn:active {
        transform: translateY(1px);
    }

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--hc-primary);
    --bs-btn-border-color: var(--hc-primary);
    --bs-btn-hover-bg: var(--hc-primary-dark);
    --bs-btn-hover-border-color: var(--hc-primary-dark);
    --bs-btn-active-bg: var(--hc-primary-dark);
    --bs-btn-active-border-color: var(--hc-primary-dark);
    box-shadow: 0 1px 2px rgba(27, 110, 194, 0.18);
}

    .btn-primary:hover {
        box-shadow: 0 4px 12px rgba(27, 110, 194, 0.28);
    }

.btn-outline-primary {
    --bs-btn-color: var(--hc-primary);
    --bs-btn-border-color: var(--hc-primary);
    --bs-btn-hover-bg: var(--hc-primary);
    --bs-btn-hover-border-color: var(--hc-primary);
    --bs-btn-active-bg: var(--hc-primary-dark);
}

.btn-light {
    --bs-btn-bg: var(--hc-surface);
    --bs-btn-hover-bg: #f1f4f8;
    border-color: var(--hc-border);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(27, 110, 194, 0.18);
    border-color: var(--hc-primary);
    outline: none;
}

/* --------------------------------------------------------------------------
   Cards — premium feel
   -------------------------------------------------------------------------- */
.card {
    border-color: var(--hc-border);
    box-shadow: var(--hc-shadow-sm);
    transition: box-shadow var(--hc-transition), transform var(--hc-transition);
}

    .card.shadow-sm {
        box-shadow: var(--hc-shadow-sm) !important;
    }

    .card.shadow {
        box-shadow: var(--hc-shadow-md) !important;
    }

    .card.shadow-lg {
        box-shadow: var(--hc-shadow-lg) !important;
    }

.card-header {
    background-color: var(--hc-surface);
    border-bottom-color: var(--hc-border);
}

/* KPI / clickable cards lift gently */
.card[style*="cursor:pointer"]:hover,
.card[role="button"]:hover {
    transform: translateY(-2px);
    box-shadow: var(--hc-shadow-md) !important;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-control, .form-select {
    border-color: var(--hc-border);
    transition: border-color var(--hc-transition), box-shadow var(--hc-transition);
}

.form-label {
    color: var(--hc-text);
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.field-error {
    outline: 1px solid #e50000 !important;
    outline-offset: -1px;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
    font-size: 0.85rem;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --------------------------------------------------------------------------
   Tables — clean, with hover affordance
   -------------------------------------------------------------------------- */
.table {
    --bs-table-bg: transparent;
    color: var(--hc-text);
}

    .table > thead {
        background-color: #f8fafc;
    }

    .table > thead th {
        font-weight: 600;
        font-size: 0.8rem;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--hc-muted);
        border-bottom: 1px solid var(--hc-border);
    }

    .table-hover > tbody > tr:hover > * {
        background-color: var(--hc-primary-soft);
        --bs-table-accent-bg: var(--hc-primary-soft);
    }

    .table > tbody > tr {
        transition: background-color var(--hc-transition);
    }

/* --------------------------------------------------------------------------
   Badges — refined
   -------------------------------------------------------------------------- */
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.35em 0.65em;
}

/* --------------------------------------------------------------------------
   Top-row + content polish
   -------------------------------------------------------------------------- */
article.content {
    min-height: calc(100vh - 3.5rem);
}

/* --------------------------------------------------------------------------
   Global Message (toast banner) — slide-in animation
   -------------------------------------------------------------------------- */
.hemacore-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: min(560px, 92vw);
    z-index: 2000;
    border-radius: var(--hc-radius);
    box-shadow: var(--hc-shadow-lg);
    border: 1px solid transparent;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: hc-toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

    .hemacore-toast.alert-success {
        background-color: rgba(212, 237, 218, 0.96);
        border-color: rgba(38, 176, 80, 0.35);
        color: #0f5132;
    }

    .hemacore-toast.alert-danger {
        background-color: rgba(248, 215, 218, 0.96);
        border-color: rgba(220, 53, 69, 0.35);
        color: #842029;
    }

    .hemacore-toast.alert-warning {
        background-color: rgba(255, 243, 205, 0.96);
        border-color: rgba(255, 193, 7, 0.45);
        color: #664d03;
    }

    .hemacore-toast.alert-light {
        background-color: rgba(255, 255, 255, 0.96);
        border-color: var(--hc-border);
        color: var(--hc-text);
    }

@keyframes hc-toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, -16px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* --------------------------------------------------------------------------
   Global Spinner — THE app's only loading indicator (Components/GlobalSpinner.razor).
   Pages must not draw their own; they call SpinnerService.Show()/Hide().

   Transparent by design (Mishal, 2026-08-12): the page stays readable underneath and the
   spinner looks the same everywhere. It still covers the viewport, so it also blocks
   clicks while work is in flight.
   -------------------------------------------------------------------------- */
.hemacore-spinner-overlay {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: hc-fade-in 160ms ease-out;
}

@keyframes hc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}



.hemacore-loading-text {
    color: var(--hc-accent);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0%   { opacity: 0.5; }
    50%  { opacity: 1; }
    100% { opacity: 0.5; }
}

/* --------------------------------------------------------------------------
   Modal polish — soft blur backdrop
   -------------------------------------------------------------------------- */
.modal .modal-content {
    border-radius: var(--hc-radius-lg);
    border: 1px solid var(--hc-border);
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Misc.
   -------------------------------------------------------------------------- */
.cursor-pointer { cursor: pointer; }

/* Grid rows that open one thing: the whole row is clickable AND the row ends
   with an eye button doing the same (the button is the cue on touch screens,
   which have no hover). Other buttons/links inside the row stop propagation. */
tr.row-open { cursor: pointer; }
tr.row-open:hover > * { --bs-table-bg-state: var(--bs-table-hover-bg); }

/* Blazor error boundary — keep as-is from template */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }


/* ==========================================================================
   Auto-collapse sidebar
   --------------------------------------------------------------------------
   Default state (desktop): a 64px icon rail. It expands to the full 250px on
   hover, while pinned (.sidebar-pinned, persisted in localStorage), while a
   group's side panel is open (.flyout-open, so the panel never jumps when the
   mouse leaves the rail) and while the KEYBOARD is in it (:focus-visible, not
   :focus-within: a link clicked with the mouse keeps focus after navigating,
   and the rail would then never collapse). Clicking a link in the unpinned
   rail adds .rail-rest (sidebar.js), which collapses it under the mouse until
   the pointer leaves the sidebar.
   Mobile (<641px) is unaffected — the existing hamburger menu still applies.
   The `:not(:hover, ...)` selectors below are the collapsed state.
   ========================================================================== */
@media (min-width: 641px) {
    /* The rail */
    .page > .sidebar {
        width: 62px !important;
        transition: width 220ms cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        position: sticky;
        top: 0;
        z-index: 1020;
    }

    .page > .sidebar:hover:not(.rail-rest),
    .page > .sidebar.sidebar-pinned,
    .page > .sidebar.flyout-open,
    .page > .sidebar:has(:focus-visible) {
        width: 250px !important;
    }

    /* Inner content keeps its full width so hover-reveal doesn't reflow text. */
    .page > .sidebar .top-row,
    .page > .sidebar .nav-scrollable {
        width: 250px;
        min-width: 250px;
    }

    /* When collapsed, zero the nav-link font-size so the localized label
       text node disappears entirely (labels are raw text nodes inside the
       link, so there's no <span> to opacity-fade). The icon's font-size is
       restored below so the Bootstrap glyph stays visible at full size. */
    .page > .sidebar:not(:hover:not(.rail-rest), .sidebar-pinned, .flyout-open, :has(:focus-visible)) .nav-link {
        font-size: 0;
    }

    .page > .sidebar:not(:hover:not(.rail-rest), .sidebar-pinned, .flyout-open, :has(:focus-visible)) .nav-link .nav-icon {
        font-size: 1rem;
        margin-right: 0;
        margin-left: 0;
    }

    /* Fade the brand text + dropdown caret when the rail is collapsed. */
    .page > .sidebar .navbar-brand,
    .page > .sidebar .nav-caret {
        transition: opacity 180ms ease;
    }

    .page > .sidebar:not(:hover:not(.rail-rest), .sidebar-pinned, .flyout-open, :has(:focus-visible)) .navbar-brand,
    .page > .sidebar:not(:hover:not(.rail-rest), .sidebar-pinned, .flyout-open, :has(:focus-visible)) .nav-caret {
        opacity: 0;
        pointer-events: none;
    }

    /* When collapsed, fade out the auth/account block (name + sign out) so
       only icons are visible — the rail is narrow and the labels would clip. */
    .page > .sidebar:not(:hover:not(.rail-rest), .sidebar-pinned, .flyout-open, :has(:focus-visible)) .nav-divider {
        opacity: 0;
    }

    /* Pin button — sits in the top-right of the rail header. Visible on hover
       or when pinned. Hidden in the collapsed-resting state so the rail stays
       clean. */
    .sidebar-pin-btn {
        position: absolute;
        top: 0.6rem;
        inset-inline-end: 0.55rem;
        background: transparent;
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: rgba(255, 255, 255, 0.7);
        cursor: pointer;
        padding: 0.2rem 0.45rem;
        border-radius: 6px;
        font-size: 0.85rem;
        transition: background-color 150ms ease, color 150ms ease,
                    transform 220ms cubic-bezier(0.4, 0, 0.2, 1), opacity 180ms ease;
        opacity: 0;
        z-index: 2;
    }

    .page > .sidebar:hover:not(.rail-rest) .sidebar-pin-btn,
    .page > .sidebar.sidebar-pinned .sidebar-pin-btn {
        opacity: 1;
    }

    .sidebar-pin-btn:hover {
        background-color: rgba(255, 255, 255, 0.12);
        color: #fff;
    }

    /* When pinned, rotate the pin icon to convey the "stuck" state. */
    .page > .sidebar.sidebar-pinned .sidebar-pin-btn {
        color: #cfe2ff;
        transform: rotate(-45deg);
        background-color: rgba(255, 255, 255, 0.06);
    }

}

/* ==========================================================================
   Sidebar panels (a group's links open BESIDE the rail, not below it)
   --------------------------------------------------------------------------
   Markup: Components/Layout/NavMenu.razor (a .nav-group-toggle row, then its
   .nav-flyout as the next sibling). Behaviour: wwwroot/js/sidebar.js, which sets
   .open on the panel, aria-expanded on the toggle and .flyout-open on the sidebar.
   Desktop: a full-height panel at the rail's edge with a dimmed page behind it.
   Phone: the panel replaces the list (drill-down) with a Back row.
   ========================================================================== */
.nav-flyout-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    min-height: 3.5rem;
    padding-inline: 1.1rem 0.6rem;
    background: rgba(0, 0, 0, 0.18);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-flyout-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
}

    .nav-flyout-title .bi {
        color: #9ec5fe;
    }

.nav-flyout-close,
.nav-flyout-back {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.75);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

    .nav-flyout-close:hover,
    .nav-flyout-back:hover {
        background-color: rgba(255, 255, 255, 0.12);
        color: #fff;
    }

.nav-flyout-close {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.nav-flyout-back {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
}

.nav-flyout-body {
    padding: 0.35rem 0.4rem 0.75rem;
}

/* The open group's row, and the group that holds the current page. */
.page > .sidebar .nav-group-toggle[aria-expanded="true"] {
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.page > .sidebar .nav-group-toggle[aria-expanded="true"] .nav-icon,
.page > .sidebar .nav-group-toggle[aria-expanded="true"] .nav-caret {
    color: #fff;
}

.page > .sidebar .nav-item:has(+ .nav-flyout a.active) > .nav-group-toggle {
    color: #fff;
    font-weight: 600;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 100%);
}

    .page > .sidebar .nav-item:has(+ .nav-flyout a.active) > .nav-group-toggle .nav-icon {
        color: #fff;
    }

    /* Same leading bar as an active link (NavMenu.razor.css, a.active::before). */
    .page > .sidebar .nav-item:has(+ .nav-flyout a.active) > .nav-group-toggle::before {
        content: '';
        position: absolute;
        inset-inline-start: -0.45rem;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 60%;
        background: linear-gradient(180deg, #cfe2ff, #6ea8fe);
        border-radius: 2px;
    }

.nav-flyout-backdrop {
    display: none;
}

@media (min-width: 641px) {
    .page > .sidebar .nav-flyout {
        position: fixed;
        top: 0;
        bottom: 0;
        /* The rail is always 250px while a panel is open (.flyout-open above). */
        inset-inline-start: 250px;
        width: 264px;
        z-index: 3;
        display: flex;
        flex-direction: column;
        background: linear-gradient(180deg, #13294b 0%, #1a3560 100%);
        border-inline-start: 1px solid rgba(255, 255, 255, 0.07);
        box-shadow: 10px 0 28px rgba(15, 23, 42, 0.28);
        /* visibility (not display) so the slide-in can animate, and so a closed
           panel's links drop out of the Tab order. */
        visibility: hidden;
        opacity: 0;
        transform: translateX(-10px);
        transition: opacity 160ms ease, transform 180ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 180ms;
    }

    [dir="rtl"] .page > .sidebar .nav-flyout {
        transform: translateX(10px);
        box-shadow: -10px 0 28px rgba(15, 23, 42, 0.28);
    }

    .page > .sidebar .nav-flyout.open,
    [dir="rtl"] .page > .sidebar .nav-flyout.open {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 160ms ease, transform 180ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
    }

    .page > .sidebar .nav-flyout-body {
        flex: 1;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
    }

    .page > .sidebar.flyout-open .nav-flyout-backdrop {
        display: block;
        position: fixed;
        top: 0;
        bottom: 0;
        inset-inline-start: 250px;
        inset-inline-end: 0;
        z-index: 2;
        background: rgba(15, 23, 42, 0.18);
        animation: nav-backdrop-in 160ms ease;
    }
}

@keyframes nav-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Phone: drill-down. The open panel replaces the whole list. */
@media (max-width: 640.98px) {
    .page > .sidebar .nav-flyout {
        display: none;
    }

        .page > .sidebar .nav-flyout.open {
            display: block;
        }

    .page > .sidebar.flyout-open .nav-scrollable nav > :not(.nav-flyout.open) {
        display: none !important;
    }

    .nav-flyout-head {
        background: transparent;
        padding-inline: 0.75rem;
        gap: 0.25rem;
    }

    .nav-flyout-back {
        display: inline-flex;
    }

    .nav-flyout-close {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .page > .sidebar .nav-flyout,
    .page > .sidebar.flyout-open .nav-flyout-backdrop {
        transition: none !important;
        animation: none !important;
    }
}

/* Readonly-but-locked inputs (e.g. prefilled Lab Code on the login page).
   The input must stay `readonly`, not `disabled`, so its value still posts
   with the form - this class just borrows Bootstrap's disabled look. */
.form-control-locked,
.form-control-locked:focus {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
    cursor: not-allowed;
    box-shadow: none;
    border-color: var(--bs-border-color);
}

/* Login page: floating labels get a solid --bs-body-bg pill from Bootstrap
   (label::after) once they float up; keep them transparent so the label
   sits directly on the input background (white or the locked grey). */
.login-page .form-floating > .form-control:focus ~ label::after,
.login-page .form-floating > .form-control:not(:placeholder-shown) ~ label::after,
.login-page .form-floating > .form-control-plaintext ~ label::after,
.login-page .form-floating > .form-select ~ label::after {
    background-color: transparent;
}

/* Firefox variant kept separate: an unknown :-moz-* selector would
   invalidate the whole group above in other browsers. */
.login-page .form-floating > .form-control:not(:-moz-placeholder-shown) ~ label::after {
    background-color: transparent;
}

/* "Built to support" strip below the login card (ZATCA / CBAHI / ISO). */
.login-support {
    margin-top: 1.75rem;
    text-align: center;
}
.login-support-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.9rem;
}
.login-support-title::before,
.login-support-title::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--bs-border-color);
}
/* One row: SEBA, ZATCA, CBAHI, ISO, nphies; three per row on phones. */
.login-support-items {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (max-width: 575.98px) {
    .login-support-items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.login-support-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    line-height: 1.25;
}
.login-support-logo {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: #fff;
    border-radius: 0.6rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.login-support-item:hover .login-support-logo {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}
.login-support-logo img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

/* ------------------------------------------------------------------------
   Patient portal sign-in (/portal/login, /portal/verify, the lab picker).

   Patients open the portal on a phone, so these are sized for a ~360px
   viewport FIRST and only relax upward - the opposite of the staff pages.
   Kept here rather than in a <style> block per page so the three steps of
   one flow cannot drift apart.
   ------------------------------------------------------------------------ */
.portal-shell {
    max-width: 30rem;
    margin-inline: auto;
    padding: 1rem 0 3rem;
}

/* Client-portal work pages (new request, request list) need room for a form and a table. */
.portal-shell.portal-shell-wide {
    max-width: 64rem;
}

.portal-card {
    background: #fff;
    border-radius: 1.25rem;
    padding: 1.75rem 1.25rem;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .07);
}

@media (min-width: 576px) {
    .portal-shell {
        padding-top: 2.5rem;
    }

    .portal-card {
        padding: 2.5rem 2.25rem;
    }
}

/* The logo is a WIDE wordmark (2124x400 = 5.3:1). Capping only its height
   computes a ~425px width, which overflows a phone card, makes the document
   scroll sideways and leaves the logo looking oversized. Width is therefore
   the binding constraint and the height follows it. The intrinsic width/height
   attributes on the <img> reserve the right box before the PNG downloads, so
   the logo no longer pops to full size once it decodes. */
.portal-logo {
    display: block;
    margin-inline: auto;
    width: auto;
    height: auto;
    max-width: min(13rem, 100%);
    max-height: 3.25rem;
}

.portal-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
}

.portal-sub {
    color: #667085;
    font-size: .9rem;
    line-height: 1.6;
    margin-bottom: 0;
}

/* 3rem is about the smallest comfortable thumb target, and the 1rem font
   size matters as much: iOS Safari zooms the whole page when a focused
   input is smaller than 16px, which throws the layout off centre. */
.portal-field {
    min-height: 3.25rem;
    font-size: 1rem;
    border-radius: .75rem;
}

.portal-btn {
    min-height: 3rem;
    border-radius: .75rem;
    font-weight: 600;
}

/* One tracked input rather than six boxes: six needs JS focus management and
   the portal renders in static SSR with no interactivity at all. text-indent
   cancels the trailing letter-space so the digits stay optically centred. */
.portal-otp {
    letter-spacing: .6rem;
    text-indent: .6rem;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

/* Resend / use-a-different-number under the code form: two comfortable thumb
   targets side by side, wrapping onto two lines on a narrow phone. */
.portal-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .25rem .75rem;
    margin-top: .75rem;
}

.portal-secondary-actions .btn {
    min-height: 2.75rem;
    font-size: .9rem;
}

/* Staff two-factor page (Account/LoginWith2fa): the channel badge above the title
   and the resend / switch-method links under the Verify button. */
.twofa-icon {
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(13, 110, 253, .1);
    color: var(--bs-primary);
    font-size: 1.6rem;
}

.twofa-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.twofa-actions .btn {
    min-height: 2.5rem;
    font-size: .9rem;
}

/* Lab picker row - a whole-width button, not a card with a small link. */
.portal-lab {
    display: flex;
    align-items: center;
    gap: .85rem;
    width: 100%;
    min-height: 4rem;
    padding: 1rem 1.15rem;
    text-align: start;
    background: #fff;
    border: 1px solid var(--hc-border, #e3e7ed);
    border-radius: 1rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}

.portal-lab:hover,
.portal-lab:focus-visible {
    border-color: var(--bs-primary);
    box-shadow: 0 .25rem .75rem rgba(16, 24, 40, .08);
}

/* Bootstrap Icons are drawn LTR. A directional glyph (a "forward" chevron)
   has to mirror in Arabic or it points back the way the user came. */
[dir="rtl"] .rtl-flip {
    display: inline-block;
    transform: scaleX(-1);
}

/* Visit row on /portal/results - the same .portal-lab shell as the lab picker,
   so the two lists a patient meets are the same object. */
.portal-visit {
    text-decoration: none;
    color: inherit;
}

.portal-visit-main {
    flex: 1 1 auto;
    min-width: 0;
}

/* The date leads and the chip trails, but they share one wrapping line: on a
   narrow phone with a long Arabic chip the chip drops below the date instead of
   crushing it. */
.portal-visit-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .35rem .75rem;
}

.portal-visit-date {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1d2939;
}

.portal-visit-meta {
    display: block;
    margin-top: .15rem;
    color: #667085;
    font-size: .85rem;
}

/* Same palette as the result cards' zones, so a chip here means what the
   colour behind it will mean on the next screen. */
.portal-chip {
    display: inline-block;
    border-radius: 1rem;
    padding: .15rem .6rem;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.portal-chip--ok {
    background: #e7f5ea;
    color: #2f7d3c;
}

.portal-chip--warn {
    background: #fdf3e2;
    color: #8a5a10;
}

.portal-chip--info {
    background: #eef2f7;
    color: #475467;
}

/* Printing: hide the app chrome (sidebar, top bar) on every printable page
   so documents (invoice, labels, job order, reports) come out clean. */
/* Bilingual invoice labels (Components/Shared/BiLabel.razor). English on top,
   Arabic beneath at the same size — ZATCA requires Arabic to be present and not
   subordinate, so the two lines are weighted equally. `unicode-bidi: isolate`
   stops the RTL and LTR runs reordering each other.
   Independent of the UI culture — see Services/InvoiceText. */
.bilabel {
    display: inline-block;
    line-height: 1.3;
}

.bilabel-en {
    display: block;
    direction: ltr;
    unicode-bidi: isolate;
}

.bilabel-ar {
    display: block;
    direction: rtl;
    unicode-bidi: isolate;
}

/* In a right-aligned cell both lines must hug the right edge, and vice versa —
   the isolates above otherwise leave the Arabic sitting on its own baseline. */
.text-end .bilabel, .text-end .bilabel-en, .text-end .bilabel-ar { text-align: right; }

@media print {
    .page > .sidebar,
    main > .top-row,
    .no-print {
        display: none !important;
    }

    .page {
        display: block !important;
        min-height: 0 !important;
    }

    main {
        background: #fff !important;
    }

    main article.content {
        padding: 0 !important;
        margin: 0 !important;
    }

    body {
        background: #fff !important;
    }

    /* Print colours as drawn. Without this, Chrome drops every background (the result
       gauge's zones and pills, table header bands, badges) unless the person ticks
       "Background graphics" on every print — and phone browsers offer no such box, so
       a PDF saved on a phone came out with the gauge missing. */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Full-catalogue grids (Tests Master) show every row in one scrolling pane rather
   than paging, so the column headers are pinned - without that you lose track of
   which column you are reading a few hundred rows down. Height is viewport-relative
   so the search box above stays put and the page itself never scrolls. */
.grid-scroll {
    max-height: calc(100vh - 21rem);
    min-height: 18rem;
    overflow-y: auto;
}

    .grid-scroll thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        /* Must be opaque: rows scroll underneath it. Matches .table-light. */
        background-color: #f8f9fa;
    }

@media print {
    /* Printing must show the whole list, not just the scrolled-to slice. */
    .grid-scroll {
        max-height: none;
        overflow: visible;
    }
}

/* ===== Document progress tracker (purchase requisition, purchase order): steps joined by a line. ===== */
.doc-steps {
    display: flex;
    list-style: none;
    margin: 0.25rem 0 0.5rem;
    padding: 0;
}

.doc-steps li {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: 0;
    padding: 0 0.25rem;
}

/* The connecting line runs from each step to the next (logical, so it flips in Arabic). */
.doc-steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 0.8rem;
    inset-inline-start: calc(50% + 0.95rem);
    inset-inline-end: calc(-50% + 0.95rem);
    height: 2px;
    background: #dee2e6;
}

.doc-steps li.done:not(:last-child)::after { background: var(--bs-success); }

.doc-steps .dot {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: 2px solid #ced4da;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #fff;
    z-index: 1;
}

.doc-steps li.done .dot { background: var(--bs-success); border-color: var(--bs-success); }
.doc-steps li.current .dot { box-shadow: 0 0 0 4px rgba(25, 135, 84, 0.18); }
.doc-steps li.current:not(.done) .dot { border-color: var(--bs-primary); }

.doc-steps .lbl { margin-top: 0.3rem; font-size: 0.8rem; font-weight: 600; color: #6c757d; }
.doc-steps li.done .lbl, .doc-steps li.current .lbl { color: #212529; }
.doc-steps .at { font-size: 0.72rem; color: #6c757d; }

/* A cancelled requisition: the steps it reached turn grey-red. */
.doc-steps.cancelled li.done .dot { background: #adb5bd; border-color: #adb5bd; }
.doc-steps.cancelled li.done:not(:last-child)::after { background: #adb5bd; }

@media (max-width: 575.98px) {
    .doc-steps .at { display: none; }
}

/* ===== Record form top bar (Components/Shared/FormActionBar.razor): stays in view while the form scrolls. ===== */
.form-action-bar {
    position: sticky;
    top: 0; /* phones: the top row scrolls away */
    z-index: 4; /* above sticky table headers (2), below the top row (5) so its menus open over this bar */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 3.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: #fff;
    border: 1px solid var(--bs-border-color-translucent);
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

@media (min-width: 641px) {
    .form-action-bar { top: 3.5rem; } /* directly under the sticky top row */
}

/* Fields reached with the Tab key stop below the two sticky bars. */
html:has(.form-action-bar) { scroll-padding-top: 8rem; }

.form-action-bar-heading {
    flex: 0 1 auto;
    min-width: 8rem;
}

.form-action-bar-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

/* The optional second line, e.g. the patient on Results. */
.form-action-bar-details {
    overflow: hidden;
    color: var(--bs-secondary-color);
    font-size: 0.85rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.form-action-bar-details strong { color: var(--bs-body-color); }

/* The running total on New Request and New Client Request. */
.form-action-bar-total {
    font-weight: 700;
    white-space: nowrap;
    margin-inline-end: 0.5rem;
}

.form-action-bar-buttons .input-group { width: 13rem; }

.form-action-bar-parent {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
    white-space: nowrap;
}

.form-action-bar-sep {
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.form-action-bar-name {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.form-action-bar-buttons {
    display: flex;
    flex-wrap: wrap; /* a page with many actions (a requisition) wraps rather than overflows */
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-inline-start: auto;
}

/* Long pop-up windows: the header and buttons stay put and only the content scrolls. */
.modal-content {
    max-height: calc(100vh - 3.5rem);
}

.modal-content > .modal-body,
.modal-content > form > .modal-body {
    overflow-y: auto;
}

.modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.form-action-bar-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 6rem;
    justify-content: center;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 640.98px) {
    /* Room for the buttons: the page name goes, the record stays. */
    .form-action-bar-parent,
    .form-action-bar-sep { display: none; }
    .form-action-bar { padding-inline: 0.75rem; }
    .form-action-bar-buttons .btn { min-width: 0; }
}

@media print {
    .form-action-bar { display: none; }
}

/* ===== Record forms (Patients, Clients, Suppliers): a light divider and an icon heading per group of fields. ===== */
.form-section {
    padding-block: 1.25rem;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.form-section:first-of-type { padding-top: 0.5rem; }
.form-section:last-of-type { border-bottom: none; }

.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    color: var(--bs-primary);
}

.form-section-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--bs-primary-bg-subtle);
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* Initials avatar of a client / supplier in the grid and the form header. */
.org-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.6rem;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

.org-avatar-lg {
    width: 3.2rem;
    height: 3.2rem;
    font-size: 1.1rem;
}

/* A person's avatar in grids and form headers (PersonAvatar: Patients, Employees). */
.person-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--bs-secondary-bg);
    color: var(--bs-secondary-color);
}

img.person-avatar { object-fit: cover; }

.person-avatar-lg {
    width: 3.2rem;
    height: 3.2rem;
    font-size: 1.1rem;
}

.person-avatar-male {
    background: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

.person-avatar-female {
    background: var(--bs-danger-bg-subtle);
    color: var(--bs-danger-text-emphasis);
}

/* Read-only age beside the date of birth: looks computed, not editable. */
.person-age {
    background-color: var(--bs-tertiary-bg);
    font-weight: 600;
    cursor: default;
}

.person-age:focus {
    box-shadow: none;
    border-color: var(--bs-border-color);
}

/* ===== Top-bar bell: client work waiting (LabWorkBell). ===== */
/* Searchable item box (purchase requisition lines). */
.item-picker-list {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    z-index: 1030;
    min-width: 18rem;
    max-height: 18rem;
    overflow-y: auto;
}
.item-picker-list .list-group-item-action { cursor: pointer; }

.lab-bell { position: relative; }

/* Invisible layer: a click anywhere else closes the menu. */
.lab-bell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.lab-bell-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    inset-inline-end: 0;
    z-index: 1045;
    min-width: 17rem;
    max-width: calc(100vw - 2rem);
    padding-bottom: 0.35rem;
}

.lab-bell-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    color: var(--bs-body-color);
    text-decoration: none;
}

.lab-bell-item:hover,
.lab-bell-item:focus-visible { background: var(--bs-tertiary-bg); }

/* ===== Approval timeline (Components/Shared/ApprovalTimelinePanel.razor) ===== */
.approval-steps { display: flex; flex-direction: column; gap: .6rem; }
.approval-step { display: flex; gap: .6rem; align-items: flex-start; }
.approval-dot {
    flex: 0 0 1.6rem; height: 1.6rem; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bs-secondary-bg); color: var(--bs-secondary-color); font-size: .85rem;
}
.approval-step.approved .approval-dot { background: var(--bs-success); color: #fff; }
.approval-step.active .approval-dot { background: var(--bs-warning); color: #000; }
.approval-step.returned .approval-dot { background: var(--bs-secondary); color: #fff; }
.approval-step.rejected .approval-dot { background: var(--bs-danger); color: #fff; }
.approval-step.skipped { opacity: .6; }
@media print { .approval-timeline { break-inside: avoid; } }
