:root {
    --mud-shape-border-radius: 10px !important;
    --bnav-height: 62px;
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    /* Keep these — they make Inter look exceptionally crisp on high-res monitors */
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.pwa {
    user-select: none;
    -webkit-user-select: none;
    /* Installed app, not a web page: no long-press "Copy / Share / Look Up"
       callout over app chrome. Opt back in per region with .allow-pwa-select. */
    -webkit-touch-callout: none;
}

body.pwa .allow-pwa-select, body.pwa .allow-pwa-select * {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
}

/* =========================================================================
   TOUCH BEHAVIOUR — a tap means "activate", never "zoom"
   =========================================================================
   An installed app that zooms because someone tapped twice in a hurry feels
   broken: the layout jumps and the bottom nav slides off-screen. Phones and
   tablets are the primary target here, so tapping has to be app-like on every
   screen — while nothing else the platform does for the user is taken away.

   1. `touch-action: manipulation` allows panning and pinch-zoom but refuses
      double-tap-to-zoom. It is also what removes the legacy 300 ms click
      delay, so buttons respond immediately.
      The universal selector is deliberate: zero specificity. MudBlazor ships
      more specific rules of its own and they keep winning, e.g.
        .mud-slider, .mud-picker-time-clock, .mud-picker-color-picker
                                   { touch-action: pinch-zoom }
        .mud-swipearea, [draggable="true"]
                                   { touch-action: none }
      so sliders, swipe-to-open drawers and drag handles are untouched.
      Because `touch-action` is resolved by intersecting an element with its
      ancestors, nothing that is restricted more tightly than `manipulation`
      can be loosened here either.

   2. `-webkit-text-size-adjust: 100%` stops iOS from inflating type when a
      phone is rotated to landscape, which would re-flow the whole shell.

   3. The 16 px floor for text entry, further down, kills iOS's *other*
      accidental zoom: focusing a field smaller than 16 px zooms the page in
      and leaves it there.

   iOS Safari versions that predate WebKit's double-tap fix ignore point 1, so
   js/zoomGuard.js implements the same rule in script as a second layer. Keep
   the two in step: this is the declarative half of one fix.

   Opt out per region with `data-allow-double-tap` (native double-tap keeps
   working there), and — if pinch-zoom should go too, for a full app-like zoom
   lock — flip OPTIONS.lockAllZoom in js/zoomGuard.js.
   ========================================================================= */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body, * {
    touch-action: manipulation;
}

/* iOS zooms the page in when a focused text field is smaller than 16 px, and
   does not zoom back out on its own. The cart/order grids render MudBlazor
   fields inside 13 px table cells and the rich-text editor's canvas is 13 px,
   so on any tappable device real text entry is pinned to the threshold.
   `!important` is deliberate: MudBlazor's `font: inherit` on the input root is
   loaded after this file, and a specificity race would silently re-break the
   fix in exactly the dense components where it matters most.
   Non-typing controls (buttons, chips, checkboxes) are deliberately untouched. */
@media (any-pointer: coarse) {
    input,
    textarea,
    select,
    [contenteditable="true"] {
        font-size: 16px !important;
    }
}

/* =========================================================================
   NUMERIC INPUTS — Suppress browser native spin buttons & stepper arrows
   ========================================================================= */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

input[type="number"] {
    -moz-appearance: textfield !important;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--mud-palette-primary);
}

/* =========================================
   #APP — stable positioning for initial loader & Blazor content
   ========================================= */
#app {
    position: relative;
    min-height: 100vh;
}

/* iOS Safari (esp. standalone PWA) measures the viewport inconsistently with
   100vh — the dynamic viewport height tracks the visible area as the browser
   chrome or keyboard appears/disappears, so the layout never over/under-flows. */
@supports (height: 100dvh) {
    #app {
        min-height: 100dvh;
    }
}

/* BootStrap Classes*/
.position-relative{
    position:relative !important;
}

/* =========================================
   FONT WEIGHT UTILITIES
   ========================================= */
.font-weight-400 { font-weight: 400 !important; }
.font-weight-500 { font-weight: 500 !important; }
.font-weight-600 { font-weight: 600 !important; }
.font-weight-700 { font-weight: 700 !important; }


/* =========================================
   CUSTOM LOADERS & UTILITIES
   ========================================= */
.min-height-loading{
    min-height: 60px;
}

/* Full-screen shell boot screen — replaces the different white flashes after login.
   Reuses the brand primary spinner so the transition stays a single, continuous
   loading experience (never "layout flash → loader → layout"). */
.app-shell-loading{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--mud-palette-background, #ffffff);
}

.shell-spinner{
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(40, 37, 57, 0.2);
    border-top-color: var(--mud-palette-primary, #282539);
    animation: shell-spin 0.9s linear infinite;
}

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

/* Initial HTML loader (matches MudBlazor MudProgressCircular style) */
.loader{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
}

.loader svg{
    animation: loader-rotate 1.4s linear infinite;
    width: 40px;
    height: 40px;
}

.loader svg circle{
    animation: loader-dash 1.4s ease-in-out infinite;
    stroke: var(--mud-palette-primary, #282539);
    stroke-dasharray: 1,200;
    stroke-dashoffset: 0;
    fill: none;
}

@keyframes loader-rotate{
    100%{ transform: rotate(360deg); }
}

@keyframes loader-dash{
    0%{ stroke-dasharray: 1,200; stroke-dashoffset: 0; }
    50%{ stroke-dasharray: 89,200; stroke-dashoffset: -35; }
    100%{ stroke-dasharray: 89,200; stroke-dashoffset: -124; }
}


.bg-primary {
    background-color: var(--mud-palette-primary) !important;
}

.bg-secondary{
    background-color: var(--mud-palette-secondary) !important;
}

.c-surface {
    color: var(--mud-palette-surface) !important;
}

.c-primary {
    color: var(--mud-palette-primary) !important;
}

.c-secondary {
    color: var(--mud-palette-secondary) !important;
}

.bg-surface {
    background-color: var(--mud-palette-surface) !important;
}

.bg-background {
    background-color: var(--mud-palette-background) !important;
}

.border-default {
    border: 1px solid var(--mud-palette-lines-default) !important;
}


/* =========================================
   CARD & ACCENT VARIANTS
   ========================================= */
.card-accent-primary-hover {
    background-color: var(--mud-palette-primary-hover) !important;
    cursor: pointer;
}

.card-accent-primary-filled {
    background: var(--mud-palette-primary) !important;
    cursor: pointer;
}


/* =========================================
   ICON & STAT UTILITIES
   ========================================= */
.stat-icon {
    background-color: var(--mud-palette-surface) !important;
    color: var(--mud-palette-primary) !important;
    pointer-events: none;
}

.icon-decorative {
    pointer-events: none;
}


/* =========================================
   CALENDAR / TOOLTIP COMPONENTS
   ========================================= */
.calendar-popup-card {
    padding: 0 !important;
    background-color: transparent !important;
    color: var(--mud-palette-text-primary) !important;
    box-shadow: none !important;
}

.calendar-tooltip-container {
    min-width: 260px;
    max-width: 300px;
    background-color: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-primary) !important;
    border-radius: var(--mud-default-borderradius) !important;
    box-shadow: var(--mud-elevation-8) !important;
    text-align: left;
}


/* =========================================
   DATAGRID STYLING
   ========================================= */
.custom-datagrid {
    overflow: hidden;
}

.custom-datagrid .mud-table-head { background-color: var(--mud-palette-secondary-lighten) !important; }
.custom-datagrid .column-header { color: var(--mud-palette-primary) !important; }
.custom-datagrid .mud-table-pagination-toolbar { background-color: var(--mud-palette-secondary-lighten) !important; }
.custom-datagrid .mud-table-cell { padding: 5px 12px !important; }
.custom-datagrid .mud-table-toolbar { background-color: var(--mud-palette-secondary-lighten) !important; }
.custom-datagrid .mud-table-cell .input-rent-cell { min-width: 100px !important; }
.custom-datagrid .mud-table-cell .input-time-cell { min-width: 170px !important; }
.custom-datagrid .mud-table-cell .input-size-cell { min-width: 100px !important; }

/* Column alignment classes (§7.1, §7.2) */
.text-right,
.custom-datagrid th.text-right,
.custom-datagrid td.text-right {
    text-align: right !important;
}
.custom-datagrid th.text-right .mud-table-cell-text,
.custom-datagrid th.text-right .column-header,
.custom-datagrid th.text-right .column-header-content {
    justify-content: flex-end !important;
    text-align: right !important;
}

.text-center,
.custom-datagrid th.text-center,
.custom-datagrid td.text-center {
    text-align: center !important;
}
.custom-datagrid th.text-center .mud-table-cell-text,
.custom-datagrid th.text-center .column-header,
.custom-datagrid th.text-center .column-header-content {
    justify-content: center !important;
    text-align: center !important;
}

.text-left,
.custom-datagrid th.text-left,
.custom-datagrid td.text-left {
    text-align: left !important;
}

/* ============================================================
   MudDataGrid PAGER — RESPONSIVE
   ============================================================ */
@media (max-width: 700px) {
    .mud-data-grid .mud-table-pagination .mud-table-pagination-toolbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 52px;
        padding-top: 4px;
        padding-bottom: 4px;
        row-gap: 2px;
    }

    /* On narrow screens the spacer must not claim a full row of its own */
    .mud-data-grid .mud-table-pagination .mud-table-pagination-toolbar .mud-table-pagination-spacer {
        flex: none;
    }

    /* Navigation buttons align to the end (their own row when wrapped) */
    .mud-data-grid .mud-table-pagination .mud-table-pagination-toolbar .mud-table-pagination-actions {
        margin-left: auto;
    }
}

@media (max-width: 600px) {
    .mud-xs-table td.mud-table-cell[colspan] {
        justify-content: flex-start !important;
    }
}

/* Sharp, dense typography specifically for data cells and headers */
.mud-table-root .mud-table-head .mud-table-cell {
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
}

.mud-table-root .mud-table-body .mud-table-cell {
    font-size: 0.8125rem !important;
}

tr.mud-table-row td.mud-table-child-content:empty {
    display: none;
}

td.mud-table-child-content[colspan="1000"]:empty {
    border-top: none;
    padding: 0 !important;
    height: 0;
}

td.mud-table-cell.mud-table-child-content {
    min-width: 100%;
    justify-content: center;
    border-left: 3px solid var(--mud-palette-secondary);
}


/* =========================================
   LAYOUT COMPONENTS (Cards, Panels, Nav)
   ========================================= */
.custom-paper {
    overflow: hidden;
}

.custom-expansion-panel {
    margin-bottom: 5px !important;
}

.custom-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.custom-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/*.custom-card-primary-border-radius { background-color: var(--mud-palette-primary) !important; }*/
/*.custom-card-secondary-border-radius { background-color: var(--mud-palette-secondary) !important; }*/
/*.custom-card-success-border-radius { background-color: var(--mud-palette-success-hover) !important; }*/
/*.custom-card-error-border-radius { background-color: var(--mud-palette-error-hover) !important; }*/
/*.custom-card-primary-hover-border-radius { background-color: var(--mud-palette-primary-hover) !important; }*/
.custom-card-primary-border-radius { background-color: var(--mud-palette-primary) !important; }
.custom-card-secondary-border-radius { background-color: var(--mud-palette-secondary) !important; }
.custom-card-success-border-radius { background-color: rgb(0, 255, 0, 0.2) !important; }
.custom-card-error-border-radius { background-color: rgb(255, 0, 0, 0.2) !important; }
.custom-card-primary-hover-border-radius { background-color: var(--mud-palette-primary-hover) !important; }

/* =========================================
   NAVIGATION MENU
   ========================================= */
.active {
    background-color: var(--mud-palette-surface) !important;
    border-top-left-radius: var(--mud-shape-border-radius) !important;
    border-bottom-left-radius: var(--mud-shape-border-radius) !important;
    margin-left: 0.7vw;
}

.mud-nav-link.active {
    color: var(--mud-palette-primary) !important;
    font-weight: 600;
}
.mud-nav-link.active .mud-nav-link-icon-default {
    color: var(--mud-palette-primary) !important;
}
.navbar-toggler {
    background-color: rgba(255, 255, 255, 0.1);
}
.top-row {
    height: 3.5rem;
    background-color: rgba(0,0,0,0.4);
}
.navbar-brand {
    font-size: 1.1rem;
}
.oi {
    width: 2rem;
    font-size: 1.1rem;
    vertical-align: text-top;
    top: -2px;
}
.nav-item {
    font-size: 0.9rem;
    padding-bottom: 0.5rem;
}
.nav-item:first-of-type {
    padding-top: 1rem;
}
.nav-item:last-of-type {
    padding-bottom: 1rem;
}
.nav-item ::deep a {
    color: #d7d7d7;
    border-radius: 4px;
    height: 3rem;
    display: flex;
    align-items: center;
    line-height: 3rem;
}
.nav-item ::deep a.active {
    background-color: rgba(255,255,255,0.25);
    color: white;
}
.nav-item ::deep a:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}
@media (min-width: 641px) {
    .navbar-toggler {
        display: none;
    }

    .collapse {
        display: block;
    }

    .nav-scrollable {
        height: calc(100vh - 3.5rem);
        overflow-y: auto;
    }
}


/* =========================================
   MUDBLAZOR COMPONENT OVERRIDES
   ========================================= */
/* ── Timeline ─────────────────────────────────────────────────────────── */
/* Connector line: thin solid accent, subtle line color                   */
.mud-timeline-vertical::before {
    background-color: transparent;
    border-left: 2px solid var(--mud-palette-lines-default) !important;
}

.mud-timeline-horizontal::before {
    background-color: transparent;
    border-top: 2px solid var(--mud-palette-lines-default) !important;
}

/* Timeline dots: squarish with rounded corners across ALL sizes & elements */
.mud-timeline-item-dot,
.mud-timeline-item-dot-inner,
.mud-timeline-item-dot .mud-timeline-item-dot-inner,
.mud-timeline-dot-fill {
    border-radius: 8px !important;
    box-shadow: none !important;
}

/* Proportional rounded corners per dot size */
.mud-timeline-dot-size-small,
.mud-timeline-dot-size-small.mud-timeline-item-dot,
.mud-timeline-dot-size-small .mud-timeline-item-dot-inner {
    border-radius: 6px !important;
}

.mud-timeline-dot-size-medium,
.mud-timeline-dot-size-medium.mud-timeline-item-dot,
.mud-timeline-dot-size-medium .mud-timeline-item-dot-inner {
    border-radius: 8px !important;
}

.mud-timeline-dot-size-large,
.mud-timeline-dot-size-large.mud-timeline-item-dot,
.mud-timeline-dot-size-large .mud-timeline-item-dot-inner {
    border-radius: 10px !important;
}

/* Proportionate icon sizing inside dots so icons fit cleanly and never overflow */
.mud-timeline-item-dot-inner .mud-icon-root,
.mud-timeline-item-dot-inner svg {
    display: block;
    margin: auto;
}

.mud-timeline-dot-size-small .mud-timeline-item-dot-inner .mud-icon-root,
.mud-timeline-dot-size-small .mud-timeline-item-dot-inner svg,
.history-dot-icon {
    font-size: 13px !important;
    width: 13px !important;
    height: 13px !important;
}

.mud-timeline-dot-size-medium .mud-timeline-item-dot-inner .mud-icon-root,
.mud-timeline-dot-size-medium .mud-timeline-item-dot-inner svg {
    font-size: 18px !important;
    width: 18px !important;
    height: 18px !important;
}

.mud-timeline-dot-size-large .mud-timeline-item-dot-inner .mud-icon-root,
.mud-timeline-dot-size-large .mud-timeline-item-dot-inner svg {
    font-size: 24px !important;
    width: 24px !important;
    height: 24px !important;
}

/*Divider*/
.mud-divider{
    border-color:var(--mud-palette-primary) !important;
}

/* In dark mode dividers fall back to the neutral line color instead of the
   bright accent so they stay subtle. */
.theme-dark .mud-divider{
    border-color:var(--mud-palette-lines-default) !important;
}

/* Chart tooltip text white */
.svg-tooltip text,
.svg-tooltip tspan {
    fill: white !important;
}

/*tabs*/
.mud-tab.mud-tab-active {
    background-color: var(--mud-palette-secondary) !important;
}

/* Button */
/* Ensure icons always follow the text color in filled buttons */
/*.mud-button-filled .mud-button-icon-start,*/
/*.mud-button-filled .mud-button-icon-end {*/
/*    color: inherit !important;*/
/*}*/

/* Force high-contrast text for Primary Filled buttons in Dark Mode */
/*[data-theme='dark'] .mud-button-filled-primary {*/
/*    color: var(--mud-palette-background) !important;*/
/*}*/

/* Button utility classes */
/*.btn-icon-secondary {*/
/*    color: var(--mud-palette-secondary-text, inherit) !important;*/
/*}*/

/* Dashboard stat card icon */
/*.stat-icon {*/
/*    background-color: var(--mud-palette-surface) !important;*/
/*    color: var(--mud-palette-primary) !important;*/
/*    pointer-events: none;*/
/*}*/

/* Toggle Group */
.custom-toggle-group {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
}

/* =========================================
   SIDE DRAWER & SCROLLBAR UX
   ========================================= */
.mud-drawer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drawer container scroll styles */
.mud-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.mud-drawer-container {
    background-color: var(--mud-palette-background);
}

/* Custom scrollbar styling for better UX */
.mud-drawer-container::-webkit-scrollbar {
    width: 8px;
}

.mud-drawer-container::-webkit-scrollbar-track {
    background: var(--mud-palette-background-gray) !important;
    border-radius: 4px;
}

.mud-drawer-container::-webkit-scrollbar-thumb {
    background: var(--mud-palette-text-disabled) !important;
    border-radius: 4px;
}

.mud-drawer-container::-webkit-scrollbar-thumb:hover {
    background: var(--mud-palette-text-secondary) !important;
}

/* Firefox scrollbar */
.mud-drawer-container {
    scrollbar-width: thin;
    scrollbar-color: var(--mud-palette-text-disabled) var(--mud-palette-background-gray) !important;
}

/* Prevent body scroll when drawer is open */
body.drawer-open {
    overflow: hidden;
}

/* Ensure proper touch scrolling on mobile */
.mud-drawer-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Prevent scroll chaining to parent */
.mud-drawer-container {
    overscroll-behavior-y: contain;
}

/* =========================================
   BUSINESS LOGIC & SPECIFIC STATES
   ========================================= */
/*.error-data-grid-row { background-color: var(--mud-palette-error-hover) !important; }*/
/*.warning-data-grid-row { background-color: var(--mud-palette-warning-hover) !important; }*/

/*.cart-conflict-data-grid-row { background-color: var(--mud-palette-info-hover) !important; }*/
/*.success-data-grid-row { background-color: var(--mud-palette-success-hover) !important; }*/
/*.overdue-data-grid-cell { background-color: var(--mud-palette-error-hover) !important; font-weight: 600; }*/
.error-data-grid-row { background-color: rgba(255, 0, 0, 0.3) !important; }
.warning-data-grid-row { background-color: rgba(255, 255, 0, 0.3) !important; }

.cart-conflict-data-grid-row { background-color: rgba(33, 150, 243, 0.15) !important; }
.success-data-grid-row { background-color: rgba(0, 255, 0, 0.1) !important; }
.info-data-grid-row { background-color: rgba(33, 150, 243, 0.15) !important; }
.selected-data-grid-row { background-color: var(--mud-palette-primary-hover, rgba(25, 118, 210, 0.12)) !important; }
.custom-datagrid.clickable-rows tbody tr { cursor: pointer; }
.overdue-data-grid-cell { background-color: rgba(255, 0, 0, 0.3) !important; font-weight: 600; }

.has-bottom-nav {
    padding-top: 0px !important;
    padding-bottom: calc(var(--bnav-height) + env(safe-area-inset-bottom, 0px)) !important;
}

/* PWA standalone on iPad (home-screen installed): the viewport now extends under
   the home indicator (viewport-fit=cover), so the fixed bottom nav is flush with
   the true screen edge. Keep the shell spanning the full dynamic height too. */
@supports (height: 100dvh) {
    body.pwa #app {
        min-height: 100dvh;
    }
}

@media (max-width: 959.98px) {
    .mud-layout {
        padding-top: 0px !important;
    }
}

/*.no-data-container {*/
/*    display: flex;*/
/*    align-items: center;*/
/*    justify-content: center;*/
/*    min-height: 240px;*/
/*    width: 100%;*/
/*    background-color: var(--mud-palette-surface) !important;*/
/*    border-radius: 4px;*/
/*}*/

/*.no-data-content {*/
/*    text-align: center;*/
/*    padding: 24px;*/
/*    max-width: 300px;*/
/*}*/

/*.item-conflict{*/
/*    background: var(--mud-palette-surface) !important;*/
/*    border-left: 3px solid var(--mud-palette-primary) !important;*/
/*}*/
/*.item-check-availability{*/
/*    background: var(--mud-palette-secondary) !important;*/
/*    border-left: 3px solid var(--mud-palette-primary) !important;*/
/*}*/

/* Chip */
.custom-mud-chip{
    border-radius: var(--mud-shape-border-radius) !important;
}

.cart-item-selected {
    color: var(--mud-palette-primary-text) !important;
}
.cart-item-selected .mud-chip.mud-chip-outlined {
    color: var(--mud-palette-primary-text) !important;
    border-color: var(--mud-palette-primary-text) !important;
}
.cart-item-selected .mud-typography {
    color: var(--mud-palette-primary-text) !important;
}

/* No data content*/
.no-data-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2.5rem 1.25rem;
    gap: 0.25rem;
}

.no-data-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: var(--mud-shape-border-radius);
    background-color: var(--mud-palette-primary-hover, rgba(25, 118, 210, 0.08));
    margin-bottom: 0.75rem;
}

.no-data-icon ::deep svg {
    width: 28px;
    height: 28px;
    opacity: 0.9;
}

.no-data-title {
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.no-data-subtitle {
    color: var(--mud-palette-text-secondary);
    font-size: 0.875rem;
    max-width: 360px;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.no-data-action {
    margin-top: 1rem;
}

@media (max-width: 600px) {
    .no-data-container {
        padding: 1.75rem 1rem;
    }

    .no-data-icon {
        width: 52px;
        height: 52px;
    }

    .no-data-icon ::deep svg {
        width: 24px;
        height: 24px;
    }
}

/* Header */
.sticky-page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--mud-palette-background);
    --header-px: 16px;
    width: calc(100% + (var(--header-px) * 2));
    margin-left: calc(var(--header-px) * -1);
    padding-left: var(--header-px);
    padding-right: var(--header-px);
}

/*!* The Fading Shade Zone *!*/
/*.sticky-page-header::after {*/
/*    content: '';*/
/*    position: absolute;*/
/*    left: 0;*/
/*    width: 100%;*/
/*    bottom: -15px;*/
/*    height: 15px;*/
/*    background: linear-gradient(to bottom, var(--mud-palette-background) 0%, transparent 100%);*/
/*    pointer-events: none;*/
/*}*/

@media (min-width: 960px) {
    .sticky-page-header {
        top: var(--mud-appbar-height, 64px);
        --header-px: 24px;
    }
}

/* =========================================
   ERROR DISPLAY (fallback shell)
   ========================================= */

/*
 * Full-screen fallback shown only when the app itself cannot run (fatal boot
 * error / failed download). Deliberately white and calm - no red, no alarming
 * color. Content is always centered both horizontally and vertically.
 */
#blazor-error-ui {
    position: fixed;
    inset: 0;
    z-index: 999999;
    margin: 0;
    box-sizing: border-box;
    background: #ffffff !important;
    color: #1f2937;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/*
 * The Blazor framework tries to show this overlay itself on ANY startup/unhandled
 * error by setting display:flex inline. While the app is starting it is suppressed
 * with `!important` (beats the framework's inline style) and is revealed ONLY
 * through `.show` (driven by our boot watchdog / fatal handlers).
 */
body:not(.blazor-booted) #blazor-error-ui {
    display: none !important;
}

/* Once the app has booted (body gets .blazor-booted), the suppression is lifted:
   the framework can still surface genuine runtime crashes with our branded card. */
body.blazor-booted #blazor-error-ui {
    display: none;
}

/* Our deliberate reveal: always flex, always dead-center. `!important` guarantees
   centering even if the framework flips the display value itself. */
#blazor-error-ui.show {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.app-fatal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 440px;
    margin: auto;
    padding: 2.75rem 2.25rem 2.25rem;
    background: #ffffff;
    border: 1px solid #eef1f6;
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.10), 0 2px 8px rgba(15, 23, 42, 0.04);
    text-align: center;
    animation: fadeIn 0.3s ease-out;
    box-sizing: border-box;
}

.app-fatal-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    margin-bottom: 1.25rem;
    border-radius: 50%;
    background: #f3f6ff;
    color: #3849d8;
}

.app-fatal-logo svg {
    width: 34px;
    height: 34px;
}

.app-fatal-title {
    display: block;
    margin: 0 0 0.5rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

.app-fatal-body {
    display: block;
    margin: 0;
    max-width: 370px;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: #6b7280;
}

.app-fatal-reload {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin-top: 1.5rem;
    padding: 0 2rem;
    border: none;
    border-radius: 12px;
    background: #3849d8;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(56, 73, 216, 0.28);
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.app-fatal-reload:hover {
    background: #2f3ec0;
    box-shadow: 0 10px 24px rgba(56, 73, 216, 0.34);
}

.app-fatal-reload:active {
    transform: scale(0.98);
}

.app-fatal-reload:focus-visible {
    outline: 3px solid rgba(56, 73, 216, 0.35);
    outline-offset: 2px;
}

.app-fatal-support {
    display: block;
    margin-top: 1.25rem;
    font-size: 0.8125rem;
    color: #9ca3af;
}

.app-fatal-support a {
    color: #3849d8;
    font-weight: 500;
    text-decoration: none;
}

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

@media (max-width: 480px) {
    .app-fatal-card {
        padding: 2.25rem 1.5rem 1.75rem;
    }

    .app-fatal-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 1rem;
    }

    .app-fatal-reload {
        width: 100%;
    }
}

.error-display {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 360px;
    padding: 2rem 1rem;
    width: 100%;
}

.error-display-card {
    max-width: 480px;
    width: 100%;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background-color: transparent !important;
}

.error-display-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background-color: rgba(255, 0, 0, 0.08);
    margin-bottom: 0.5rem;
}

.error-display-title {
    font-weight: 600 !important;
    letter-spacing: -0.01em;
}

.error-display-message {
    color: var(--mud-palette-text-secondary) !important;
    max-width: 380px;
    line-height: 1.6;
}

.error-display-reference {
    font-size: 0.75rem;
    color: var(--mud-palette-text-disabled);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    letter-spacing: 0.02em;
    user-select: all;
}

.error-display-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.error-display-support {
    color: var(--mud-palette-text-disabled) !important;
    margin-top: 0.25rem;
}

.error-display-support a {
    color: var(--mud-palette-primary) !important;
    text-decoration: none;
}

.error-display-support a:hover {
    text-decoration: underline;
}

.error-display-details {
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 300px;
    overflow: auto;
    padding: 0.75rem;
    background-color: var(--mud-palette-background-gray);
    border-radius: 6px;
}


/* =========================================
   OPERATION DASHBOARD V2 - PREMIUM DESIGN
   ========================================= */

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Workflow / Card Icon Containers --- */
.workflow-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.info-bg { background: var(--mud-palette-info-hover); }
.warning-bg { background: var(--mud-palette-warning-hover); }
.success-bg { background: var(--mud-palette-success-hover); }
.primary-bg { background: var(--mud-palette-primary-hover); }

/* --- Responsive --- */
@media (max-width: 600px) {
    .date-range-picker {
        min-width: 100%;
        width: 100%;
    }

    .error-display {
        min-height: 280px;
        padding: 1.5rem 0.75rem;
    }

    .error-display-card {
        padding: 2rem 1.25rem;
    }

    .error-display-icon {
        width: 60px;
        height: 60px;
    }
}

.dp-file-input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.mud-file-upload-files {
    position: relative;
    z-index: 5;
}

.mud-chip-close-button {
    position: relative;
    z-index: 6;
}

.history-filter-row {
    flex-wrap: wrap;
}

.history-filter-select {
    flex: 1 1 220px;
    min-width: 0;
}

/* ── Summary card ──────────────────────────────────────────────────────── */
.history-summary {
    overflow: hidden;
}

.history-summary-inner {
    flex-wrap: wrap;
    gap: 0;
    min-height: 60px;
    padding: 8px 0;
}

.history-summary-divider {
    height: 36px;
    align-self: center;
    border-color: var(--mud-palette-secondary) !important;
    opacity: 0.6;
}

/* ── Timeline ──────────────────────────────────────────────────────────── */
.history-timeline.mud-timeline-vertical {
    padding-top: 0 !important;
}

.history-timeline.mud-timeline-vertical::before {
    top: 14px !important;
    height: calc(100% - 28px) !important;
}

/* Increase gap between ItemContent entries */
.history-timeline .mud-timeline-item {
    padding-bottom: 24px !important;
}

.history-timeline .mud-timeline-item:last-child {
    padding-bottom: 8px !important;
}

.history-timeline-item {
    margin-bottom: 0 !important;
}

/* Align item dot to the start (top) of the item content */
.history-timeline .mud-timeline-item-divider {
    align-items: flex-start !important;
}

.history-timeline .mud-timeline-item-dot {
    margin-top: 14px !important;
}

/* Dividers inside history entries & between change groups use secondary color */
.history-entry .mud-divider,
.history-divider-secondary {
    border-color: var(--mud-palette-secondary) !important;
}

/* ── Entry card ────────────────────────────────────────────────────────── */
.history-entry {
    overflow: hidden;
}

.history-entry-header {
    /* keeps top row from growing out of the card */
}

.history-entry-top {
    flex-wrap: wrap;
}

.history-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 0.75rem !important;
}

/* ── Reason banner ─────────────────────────────────────────────────────── */
.history-reason {
    background-color: var(--mud-palette-background-gray);
}

/* ── Change row ────────────────────────────────────────────────────────── */
.history-change-row {
    flex-wrap: wrap;
}

.history-change-label {
    flex: 1 1 140px;
    min-width: 0;
}

.history-change-value {
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Old value strikethrough — visible in both light and dark               */
.history-old-value {
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
    opacity: 0.65;
}

/* Single-line truncation helper */
.text-truncate-single {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 599.98px) {
    .history-summary-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px;
        gap: 8px;
    }

    .history-summary-divider {
        display: none;
    }

    .history-change-value {
        margin-left: 0;
    }
}


/* ------------------------------------------------------------------------ */
/* Linked (extra) item cards — LinkedItemsList                              */
/* Image + details share the first line; status and rent are right aligned   */
/* on wide screens and move to their own full-width row on phones.           */
/* ------------------------------------------------------------------------ */
.linked-item-body {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.linked-item-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.linked-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}

.linked-item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 0 auto;
    gap: 2px;
    margin-left: auto;
}

.linked-item-rent {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

@media (max-width: 599.98px) {
    .linked-item-body {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    /* Let the details take the rest of the first line next to the 40px image. */
    .linked-item-main {
        flex-basis: calc(100% - 48px);
    }

    /* Long names wrap instead of being cut off on a narrow screen. */
    .linked-item-main .linked-item-name {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: break-word;
    }

    /* Status + rent become one row under the item, aligned with the text. */
    .linked-item-side {
        box-sizing: border-box;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-left: 0;
        padding-left: 48px;
        gap: 4px 8px;
    }

    /* Rent stays right aligned even when the row wraps on a very narrow screen. */
    .linked-item-rent {
        flex-direction: row;
        align-items: baseline;
        gap: 6px;
        margin-left: auto;
    }
}

/* Colour key for the structured donut-chart legend (DonutChart.razor). */
.donut-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
}

