/* ============================================================
   AGIVA Design Tokens — FSPEC-033 Navigation Refactor
   ============================================================ */

/* Sidebar nav layout — global so NavLink <a> outputs inherit block layout
   regardless of Blazor CSS isolation scope propagation */
.nav-section {
    display: flex !important;
    flex-direction: column !important;
}

.nav-item {
    display: flex !important;
    align-items: center;
    width: 100% !important;
    box-sizing: border-box;
    text-decoration: none !important;
}

/* Tile sidebar (NavMenu) — global so NavLink <a> gets column layout (scoped CSS does not apply). */
.nav-sidebar--tiles .nav-tile,
.nav-sidebar--tiles a.nav-tile {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    width: 100% !important;
    box-sizing: border-box;
    text-decoration: none !important;
    white-space: normal !important;
}

.nav-sidebar--tiles .nav-tile__icon {
    display: block !important;
    flex-shrink: 0;
    color: #ffffff !important;
}

.nav-sidebar--tiles .nav-tile--active .nav-tile__icon,
.nav-sidebar--tiles a.nav-tile--active .nav-tile__icon {
    color: #9ed4ff !important;
}

.nav-sidebar--tiles .nav-tile__label {
    display: block !important;
    width: 100%;
    text-align: center;
    line-height: 1.2;
    white-space: normal !important;
    word-break: break-word;
    color: #ffffff !important;
}

.nav-sidebar--tiles .nav-tile--active .nav-tile__label,
.nav-sidebar--tiles a.nav-tile--active .nav-tile__label {
    color: #9ed4ff !important;
}

/* Collapsed desktop rail — icons only (overrides label display:block !important above). */
.nav-sidebar--tiles.nav-sidebar--collapsed .nav-tile,
.nav-sidebar--tiles.nav-sidebar--collapsed a.nav-tile {
    gap: 0 !important;
    min-height: 56px !important;
    padding: 10px 4px !important;
}

.nav-sidebar--tiles.nav-sidebar--collapsed .nav-tile__label {
    display: none !important;
}

.nav-sidebar--tiles.nav-sidebar--collapsed .nav-tile__icon {
    font-size: 1.65rem !important;
}

/* Mobile drawer title — keep white on the dark panel (MudText used to paint it dark). */
.mobile-drawer__title {
    color: #ffffff !important;
}

/* Machines browse toolbar — 2×2 on desktop, stacked on mobile.
   Dense outlined Mud fields use margin-top:8px (label clearance) and often keep a
   helper-text slot. Bottom-aligning a bare 40px button against that taller box
   dropped Search below the Filter input — match Mud’s margins and align from the top. */
.portal-machines-toolbar__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    align-items: start;
}

.portal-machines-toolbar__customer,
.portal-machines-toolbar__serial,
.portal-machines-toolbar__filter {
    min-width: 0;
    width: 100%;
}

/* No helper copy on these filters — collapse the reserved slot so row height = input. */
.portal-machines-toolbar__grid .mud-input-control-helper-container,
.portal-machines-toolbar__grid .mud-input-helper-text {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.portal-machines-toolbar__search-wrap {
    display: flex;
    align-items: stretch;
    width: 100%;
    /* Same as .mud-input-control-margin-dense.mud-input-outlined-with-label */
    margin-top: 8px;
    margin-bottom: 4px;
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
}

.portal-machines-toolbar__search {
    width: 100%;
    height: 100%;
    min-height: 40px;
    margin: 0;
}

@media (min-width: 600px) {
    .portal-machines-toolbar__grid {
        grid-template-columns: 1fr 1fr;
    }
}

:root {
    /* Form controls — RULE-AGIVA-017 (rectangular; no pill inputs) */
    --agiva-control-radius: 4px;

    /* Portal shell compact breakpoint (px, unitless). Used by portal-narrow-layout.js.
       @media queries cannot use var() — keep the Portal shell section below on the same value. */
    --portal-shell-compact-max-px: 768;

    /* Chat POC: tabbed mobile stack below this width; technician sidebar from this width up (FSPEC-023).
       @media queries cannot use var() — keep chat POC sections on max-width: 779.98px / min-width: 780px. */
    --field-chat-compact-max-px: 780;

    /* Layout dimensions */
    --header-h:      52px;
    --subheader-h:   40px;
    --sidebar-w:     112px;
    --sidebar-sm:    72px;
    --bottom-h:      52px;
    /* Shared page inset beside the sidebar (portal-page-shell) */
    --page-pad-x:    1rem;
    --page-pad-x-md: 1.25rem;

    /* Brand colours */
    --brand:         #00678F;
    --brand-hover:   #004d6b;

    /* Sidebar / mobile drawer — Agiva blue family (match production header; no purple) */
    --sidebar-top:   #00678F;
    --sidebar-bot:   #003d56;

    /* Page background */
    --page-bg:       #f0f0f5;
}

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: var(--page-bg, #f0f0f5);
}

/* ============================================================
   RULE-AGIVA-017 — Rectangular form controls + viewport wrap
   Pill inputs waste horizontal space on mobile. Keep radius low;
   free-text fields must wrap inside the viewport (no horizontal clip).
   ============================================================ */
.mud-input-control {
    max-width: 100%;
}

.mud-input-outlined > .mud-input-outlined-border {
    border-radius: var(--agiva-control-radius, 4px) !important;
}

.mud-input.mud-input-filled,
.mud-input-filled {
    border-radius: var(--agiva-control-radius, 4px) !important;
}

.mud-input > textarea.mud-input-slot,
.mud-input textarea.mud-input-root,
textarea.mud-input-slot {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.mud-input > input.mud-input-slot {
    max-width: 100%;
}

a, .btn-link {
    color: #006bb7;
}

/* iOS Safari WebKit overrides (BUG-061, BUG-062) */
:root {
    color-scheme: light;
    --mud-palette-surface: #ffffff;
    --mud-palette-background: #f5f5f5;
}

input,
textarea,
[contenteditable] {
    -webkit-text-fill-color: var(--mud-palette-text-primary, #000);
    color: var(--mud-palette-text-primary, #000);
    background-color: var(--mud-palette-surface, #fff);
    opacity: 1;
}

input::placeholder,
textarea::placeholder {
    opacity: 1;
    color: var(--mud-palette-text-secondary, #666);
    -webkit-text-fill-color: var(--mud-palette-text-secondary, #666);
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
    opacity: 1;
    color: var(--mud-palette-text-secondary, #666);
    -webkit-text-fill-color: var(--mud-palette-text-secondary, #666);
}

.mud-card,
.mud-paper {
    background-color: var(--mud-palette-surface, #ffffff);
}

/* PWA install control lives in PwaInstallDesktopLink (child component); scoped CSS cannot reach it reliably. */
.app-header a.pwa-install-desktop-link {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
    border-radius: 8px;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s;
}

.app-header a.pwa-install-desktop-link:hover,
.app-header a.pwa-install-desktop-link:focus,
.app-header a.pwa-install-desktop-link:visited {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
}

.app-header a.pwa-install-desktop-link .material-icons,
.app-header a.pwa-install-desktop-link .app-header__install-label {
    color: #ffffff !important;
}

.app-header a.pwa-install-desktop-link .material-icons {
    font-size: 1.25rem;
}

.app-header a.pwa-install-desktop-link .app-header__install-label {
    display: none;
}

.app-header--test-env a.pwa-install-desktop-link {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.app-header--test-env a.pwa-install-desktop-link:hover,
.app-header--test-env a.pwa-install-desktop-link:focus {
    background: rgba(0, 0, 0, 0.32);
    color: #ffffff !important;
}

@media (min-width: 768px) {
    .app-header a.pwa-install-desktop-link {
        padding: 0 10px;
    }

    .app-header a.pwa-install-desktop-link .app-header__install-label {
        display: inline;
    }
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Main shell article — full bleed; pages own vertical rhythm via MudContainer etc. */
article.content {
    padding: 0 !important;
    margin: 0;
}

/* Page shell — shared inset under header + beside sidebar (all pages). */
.mud-container.portal-page-shell {
    margin-top: 0 !important;
    padding-top: 1rem !important;
    padding-left: var(--page-pad-x, 1rem) !important;
    padding-right: var(--page-pad-x, 1rem) !important;
    box-sizing: border-box;
}

@media (min-width: 600px) {
    .mud-container.portal-page-shell {
        padding-top: 1.5rem !important;
        padding-left: var(--page-pad-x-md, 1.25rem) !important;
        padding-right: var(--page-pad-x-md, 1.25rem) !important;
    }
}

/*
 * Full-bleed / viewport-locked shells stay flush
 * (machine chat hub). Article agent keeps the shared side gutters.
 */
.mud-container.portal-page-shell:has(.machine-hub-stack),
.mud-container.portal-page-shell:has(.field-chat-page--mobile-stack),
.mud-container.portal-page-shell:has(.field-chat-page--desktop-viewport) {
    padding-top: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: none !important;
    width: 100% !important;
}

.mud-container.portal-page-shell.article-agent-page--viewport {
    padding-top: 0 !important;
    max-width: none !important;
    width: 100% !important;
}

/* My machines hub — document scroll on compact shell (avoid equal-height card trap). */
@media (max-width: 768px) {
    .main-content-area:has(.portal-machines-hub) {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .main-content-area:has(.portal-machines-hub) .content {
        overflow: visible;
        min-height: 0;
    }

    .portal-page-shell.portal-machines-hub {
        overflow: visible;
        min-height: 0;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .portal-machines-hub .portal-hub-grid.mud-grid {
        overflow: visible;
    }

    .portal-machines-hub .portal-hub-grid > .mud-grid-item > .mud-card.hub-dashboard-card,
    .portal-machines-hub .portal-hub-grid > .mud-grid-item > .mud-card.portal-hub-card {
        height: auto !important;
    }

    /* Machine hub detail (/machines/{serial}) — document scroll on compact shell. */
    .main-content-area:has(.machine-hub-stack) {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .main-content-area:has(.machine-hub-stack) .content {
        overflow: visible;
        min-height: 0;
    }

    .portal-page-shell:has(.machine-hub-stack) {
        overflow: visible;
        min-height: 0;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .machine-hub-stack {
        overflow: visible;
        min-height: 0;
    }

    /* Non-chat hub tabs: grow with content; chat tab keeps viewport-locked field-chat rules. */
    .machine-hub-panel:not(:has(.machine-hub-chat-host--active)) {
        overflow: visible;
        flex: none;
    }

    .machine-hub-tab-body {
        overflow: visible;
        flex: none;
    }
}

.hub-dashboard-card {
    height: 100%;
}

/* Hub dashboards (webshop, machines, admin) — equal card size per row, buttons bottom-aligned. */
.portal-hub-grid.mud-grid {
    align-items: stretch;
}

.portal-hub-grid > .mud-grid-item {
    display: flex;
    align-items: stretch;
    align-self: stretch;
}

.portal-hub-grid > .mud-grid-item > .mud-card.portal-hub-card,
.portal-hub-grid > .mud-grid-item > .mud-card.hub-dashboard-card {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.portal-hub-card.mud-card.pa-4 {
    padding: 0 !important;
}

.portal-hub-card__body.mud-card-content {
    flex: 1 1 auto;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 1rem !important;
}

.portal-hub-card.mud-card > .mud-card-header {
    flex: 0 0 auto;
}

.portal-hub-card.mud-card > .mud-card-content:not(.portal-hub-card__body) {
    flex: 1 1 auto;
    min-height: 0;
}

.portal-hub-card__spacer {
    flex: 1 1 auto;
    min-height: 0.5rem;
}

.portal-hub-card__action.mud-button-root {
    width: 100%;
    min-height: 42px;
    flex-shrink: 0;
    margin-top: 0;
    text-transform: none;
}

.portal-hub-card__actions.mud-card-actions {
    flex: 0 0 auto;
    margin-top: auto;
    padding: 0 1rem 1rem !important;
    width: 100%;
    box-sizing: border-box;
}

.portal-hub-card__actions .portal-hub-card__action {
    margin: 0;
}

.portal-hub-card__title-row {
    min-height: 3rem;
    align-items: flex-start;
}

/* Profile page — stack logout below identity on narrow viewports */
.profile-page-header__layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

.profile-page-header__identity {
    min-width: 0;
}

.profile-page-header__name {
    word-break: break-word;
}

.profile-page-header__logout.mud-button-root {
    width: 100%;
    flex-shrink: 0;
    text-transform: none;
}

@media (min-width: 600px) {
    .profile-page-header__layout {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .profile-page-header__logout.mud-button-root {
        width: auto;
    }
}

.portal-machine-card-activity {
    border-top: 1px solid #e9ecef;
}

.portal-machine-card-activity__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.portal-machine-card-activity__row--clickable {
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 6px;
    margin: 0 -6px;
    border: none;
    background: transparent;
    width: calc(100% + 12px);
    text-align: left;
    font: inherit;
    color: inherit;
}

.portal-machine-card-activity__row--clickable:hover,
.portal-machine-card-activity__row--clickable:focus-visible {
    background-color: rgba(0, 105, 120, 0.08);
    outline: none;
}

.portal-machine-card-activity__row--clickable:focus-visible {
    box-shadow: 0 0 0 2px rgba(0, 105, 120, 0.35);
}

.portal-machine-card-activity__topic {
    line-height: 1.3;
    font-size: 0.875rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--mud-palette-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.portal-machine-card-activity__unread {
    pointer-events: none;
}

.portal-machine-card-activity__btn.mud-button-root {
    text-transform: none;
    font-weight: 600;
}

.hub-stat-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}


/* -------------------------------------------------------------------------
   Portal shell — compact viewport (drawer, bottom bar, sidebar hidden).
   Single tuning point: set --portal-shell-compact-max-px above and the two
   literals in this section to the same number (wide = max + 1).
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .main-content-area {
        margin-left: 0 !important;
    }

    /* Default compact shell: document scroll unless a page opts into viewport lock. */
    .main-content-area:not(:has(.field-chat-page--mobile-stack)):not(:has(.intervention-chat-page)):not(:has(.article-agent-page--viewport)) {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .main-content-area:not(:has(.field-chat-page--mobile-stack)):not(:has(.intervention-chat-page)):not(:has(.article-agent-page--viewport)) .content {
        overflow: visible;
        min-height: 0;
    }

    .main-content-area--with-subheader {
        margin-top: var(--header-h, 52px);
    }

    .nav-sidebar {
        display: none !important;
    }

    .app-header__logo-text {
        display: none;
    }

    /* Toasts must sit below the fixed header and above bottom nav / chat composer. */
    .mud-snackbar {
        max-width: calc(100vw - 1.5rem);
        pointer-events: auto;
    }

    .mud-snackbar-location-top-center,
    .mud-snackbar-location-top-left,
    .mud-snackbar-location-top-right {
        top: calc(var(--header-h, 52px) + env(safe-area-inset-top, 0px) + 8px) !important;
    }

    .mud-snackbar-location-bottom-right,
    .mud-snackbar-location-bottom-left,
    .mud-snackbar-location-bottom-center {
        bottom: calc(var(--bottom-h, 52px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
    }

    .main-content-area:has(.field-chat-page--mobile-stack) .mud-snackbar-location-bottom-right,
    .main-content-area:has(.field-chat-page--mobile-stack) .mud-snackbar-location-bottom-left,
    .main-content-area:has(.field-chat-page--mobile-stack) .mud-snackbar-location-bottom-center {
        bottom: calc(12.5rem + env(safe-area-inset-bottom, 0px) + var(--bottom-h, 52px)) !important;
    }
}

@media (min-width: 769px) {
    .mobile-drawer,
    .mobile-drawer__backdrop {
        display: none !important;
    }

    .bottom-nav {
        display: none;
    }
}

h1:focus {
    outline: none;
}

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

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.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."
    }

.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;
}

    .status-badge {
        display: inline-flex;
        align-items: center;
        padding: 4px 4px;
        border-radius: 25px;
        font-size: 0.8rem;
        font-weight: 500;
        border: 2px solid transparent;
    }

    .out-of-stock-badge {
        background-color: #f8d7da;
        color: #721c24;
        border-color: red;
    }

    .stock-badge {
        background-color: #e8f5e9;
        color: #2e7d32;
        border-color: #a5d6a7;
    }

    .machine-badge {
        background-color: #e3f2fd;
        color: #1565c0;
        border-color: #90caf9;
    }

/* --- Chat POC flat chrome (mobile + desktop when thread is open) --- */
.field-chat-page--flat .field-chat-thread-panel {
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

.field-chat-page--flat .field-chat-messages-scroll {
    border-radius: 0 !important;
    margin: 0 !important;
    /* Do not use padding shorthand with !important — it overrides mobile dock bottom inset on .field-chat-messages-scroll--with-dock */
    padding-top: 0.4rem !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.field-chat-page--flat .field-chat-messages-scroll:not(.field-chat-messages-scroll--with-dock) {
    padding-bottom: 0.4rem !important;
}

.field-chat-page--flat .field-chat-message {
    border-radius: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: 0.5rem !important;
    box-shadow: none !important;
    border: none !important;
    border-left: 3px solid rgba(0, 103, 143, 0.35) !important;
    background: rgba(255, 255, 255, 0.95) !important;
}

.field-chat-page--flat .field-chat-message--mine {
    border-left-color: #00678f !important;
}

.field-chat-page--flat .field-chat-composer,
.field-chat-page--flat .field-chat-composer.mud-paper {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: rgba(248, 250, 252, 0.98) !important;
}

.field-chat-page--flat:not(.field-chat-page--mobile-stack) .field-chat-composer {
    border-top: 1px solid rgba(0, 103, 143, 0.12) !important;
}

.field-chat-page--flat .field-chat-composer-field.mud-input-root .mud-input-outlined-border,
.field-chat-page--flat .field-chat-composer-field .mud-input-outlined > .mud-input-outlined-border {
    border-radius: 0 !important;
}

.field-chat-page--flat .field-chat-composer-zone .mud-input-outlined > .mud-input-outlined-border {
    border-radius: 0 !important;
}

.field-chat-page--flat .field-chat-composer-action {
    border-radius: 2px !important;
}

.field-chat-page--flat .field-chat-side-panel {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 1px solid rgba(0, 103, 143, 0.12) !important;
    background: rgba(255, 255, 255, 0.98) !important;
}

.field-chat-page--flat .field-chat-answer-outline {
    border-radius: 0 !important;
}

.field-chat-page--flat .field-chat-mobile-tabs .mud-tabs-toolbar {
    border-radius: 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(0, 103, 143, 0.14) !important;
    box-shadow: none !important;
    background: var(--mud-palette-surface, #eef2f6) !important;
}

.field-chat-page--flat .field-chat-mobile-tabs .mud-tab {
    color: rgba(0, 55, 77, 0.9) !important;
    min-height: 44px !important;
}

.field-chat-page--flat .field-chat-mobile-tabs .mud-tab.mud-tab-active {
    color: #00678f !important;
    font-weight: 700 !important;
    background: rgba(0, 103, 143, 0.09) !important;
}

/* --- Intervention Chat POC (Agiva portal look & feel) --- */
.field-chat-page {
    max-width: 56rem;
    margin-inline: auto;
}

.field-chat-page .mud-button-filled,
.field-chat-page .mud-button-outlined {
    border-radius: var(--agiva-control-radius, 4px) !important;
    text-transform: none !important;
    font-weight: 600 !important;
}

.field-chat-page .mud-button-text {
    text-transform: none !important;
    font-weight: 500 !important;
}

.field-chat-hero {
    border-radius: 25px;
    background: linear-gradient(145deg, #ffffff 0%, #eef4f9 100%);
    border: 1px solid rgba(0, 103, 143, 0.18);
    box-shadow: 0 4px 24px rgba(15, 22, 51, 0.07);
}

/* Landing (narrow layout): flush with viewport — no “card box”, minimal side gutter */
.field-chat-hero--landing-flat {
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: 1px solid rgba(0, 103, 143, 0.1) !important;
    box-shadow: none !important;
    background: #ffffff !important;
}

.field-chat-hero-title {
    color: #00678f;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.field-chat-meta-strip {
    border-radius: 20px;
    border: 1px solid rgba(53, 93, 114, 0.22);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 2px 10px rgba(15, 22, 51, 0.05);
}

.field-chat-thread-panel {
    border-radius: 25px;
    border: 1px solid rgba(0, 103, 143, 0.14);
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(15, 22, 51, 0.06);
    overflow: hidden;
}

.field-chat-messages-scroll {
    max-height: min(42vh, 320px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0.85rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f0f4f8 100%);
    border-radius: 18px;
    margin: 0.5rem;
}

.field-chat-side-panel {
    border-radius: 25px;
    border: 1px solid rgba(53, 93, 114, 0.2);
    background: #ffffff;
    box-shadow: 0 4px 18px rgba(15, 22, 51, 0.06);
}

.field-chat-side-panel--parts-fill {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
}

.field-chat-side-panel--parts-fill .field-chat-parts-strip--full-page {
    flex: 1;
    min-height: 0;
    border-bottom: none;
}

.field-chat-checklist-zone-bar {
    position: sticky;
    top: 0;
    z-index: 25;
    background: #ffffff;
    margin-bottom: 12px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e0e4ec;
}

.field-chat-side-panel .field-chat-side-scroll {
    max-height: min(38vh, 280px);
    overflow-y: auto;
}

.field-chat-composer {
    border-radius: 25px;
    border: 1px solid rgba(0, 103, 143, 0.14);
    background: #ffffff;
    box-shadow: 0 4px 18px rgba(15, 22, 51, 0.06);
}

.field-chat-composer .mud-input-outlined > .mud-input-outlined-border {
    border-radius: var(--agiva-control-radius, 4px) !important;
}

.field-chat-composer-actions {
    display: flex;
    flex-flow: row wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
}

.field-chat-page--mobile-stack .field-chat-composer--mobile-dock .field-chat-composer-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
}

/* Icon-only composer toolbar on phones and tablets (tester: iPhone / iPad). */
@media (max-width: 1199.98px) {
    .field-chat-page .field-chat-composer-action.mud-button-root {
        flex: 0 0 auto;
        min-width: 2.5rem;
        width: 2.5rem;
        max-width: 2.75rem;
        height: 2.5rem;
        min-height: 2.5rem !important;
        padding: 0 !important;
        justify-content: center;
        overflow: visible;
        border-radius: 6px !important;
    }

    /* Hide our caption span only — MudBlazor 8 nests StartIcon inside .mud-button-label. */
    .field-chat-page .field-chat-composer-action .field-chat-composer-action-label {
        display: none !important;
    }

    .field-chat-page .field-chat-composer-action .mud-button-icon-start,
    .field-chat-page .field-chat-composer-action .mud-button-label .mud-button-icon-start {
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }

    .field-chat-page .field-chat-composer-action .mud-icon-root {
        font-size: 1.25rem !important;
    }

    .field-chat-page .field-chat-composer-action .mud-icon-root svg {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* WhatsApp-style capture overlay (Chat POC) */
.mud-overlay.field-chat-wa-overlay-root,
.mud-overlay.field-chat-wa-overlay-root .mud-overlay-scrim {
    padding: 0 !important;
}
.mud-overlay.field-chat-wa-overlay-root .mud-overlay-container {
    align-items: stretch !important;
    justify-content: stretch !important;
}
.mud-overlay.field-chat-wa-overlay-root .mud-overlay-content {
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}
.field-chat-wa-shell {
    position: relative;
    width: 100%;
    /* vh must come before dvh: last wins; dvh/svh match the visible mobile viewport — vh alone clips bottom overlays */
    min-height: 100vh;
    min-height: 100dvh;
    background: #000;
    display: flex;
    flex-direction: column;
    color: #fff;
}
.field-chat-wa-shell--viewport {
    height: 100vh;
    max-height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
}
.field-chat-wa-canvas-pool-offscreen {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
    pointer-events: none;
    z-index: 0;
}
.field-chat-wa-canvas-viewport-root {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.field-chat-wa-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, transparent 100%);
}
.field-chat-wa-icon-on-dark.mud-icon-button {
    color: #fff !important;
}
.field-chat-wa-flash-dim {
    opacity: 0.45;
}
.field-chat-wa-video-feed {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    background: #0a0a0a;
}
.field-chat-wa-video-feed--hidden {
    opacity: 0;
    pointer-events: none;
}
.field-chat-wa-bottom-ui {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.08) 100%);
}
.field-chat-wa-gallery-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
}
.field-chat-wa-gallery-strip {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    padding: 4px 2px;
}
.field-chat-wa-gallery-open-wrap {
    position: relative;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(30, 30, 30, 0.85);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.field-chat-wa-gallery-open-wrap--disabled {
    opacity: 0.45;
    pointer-events: none;
}
/* iOS Safari/PWA: tap must hit the file input directly — not display:none + programmatic click. */
.field-chat-wa-gallery-open-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    font-size: 16px;
}
.field-chat-wa-gallery-open-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.field-chat-wa-gallery-open {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(30, 30, 30, 0.85);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.field-chat-wa-gallery-thumb-wrap {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.25);
    padding: 0;
    background: #111;
}
.field-chat-wa-gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.field-chat-wa-shutter-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 8px 0 14px;
}
.field-chat-wa-shutter-side {
    flex: 1 1 0;
    min-width: 0;
}
.field-chat-wa-shutter {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.85);
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    box-sizing: border-box;
}
.field-chat-wa-shutter--photo::after {
    content: "";
    display: block;
    width: 58px;
    height: 58px;
    margin: 0 auto;
    border-radius: 50%;
    background: #fff;
}
.field-chat-wa-shutter--video-ring {
    border-color: rgba(255, 80, 80, 0.95);
}
.field-chat-wa-shutter--video-ring::after {
    content: "";
    display: block;
    width: 58px;
    height: 58px;
    margin: 0 auto;
    border-radius: 50%;
    background: #ff4444;
}
.field-chat-wa-shutter--stop {
    border-radius: 12px;
    border-width: 3px;
    background: rgba(255, 68, 68, 0.95);
}
.field-chat-wa-shutter--stop::after {
    content: "";
    display: block;
    width: 28px;
    height: 28px;
    margin: 18px auto;
    border-radius: 4px;
    background: #fff;
}
.field-chat-wa-modes {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

@media (max-height: 700px) {
    .field-chat-wa-gallery-open-wrap,
    .field-chat-wa-gallery-open,
    .field-chat-wa-gallery-thumb-wrap {
        width: 44px;
        height: 44px;
    }

    .field-chat-wa-shutter-row {
        margin: 6px 0 8px;
    }

    .field-chat-wa-shutter {
        width: 64px;
        height: 64px;
    }

    .field-chat-wa-shutter--photo::after {
        width: 50px;
        height: 50px;
    }
}
.field-chat-wa-mode {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 600;
    font-size: 0.88rem;
    padding: 7px 12px;
    border-radius: 999px;
}
.field-chat-wa-mode--active {
    color: #111;
    background: rgba(255, 255, 255, 0.92);
}
.field-chat-wa-annotate-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
    background: #111;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.field-chat-wa-header-btn {
    color: #fff !important;
}
.field-chat-wa-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #f5f7fa;
    color: #102030;
}

.field-chat-wa-panel-body--annotate {
    flex: 1 1 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.field-chat-wa-panel-tools {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.field-chat-wa-canvas-slot {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.field-chat-wa-canvas-slot .field-chat-canvas-wrap {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    place-items: center;
}
.field-chat-wa-canvas-slot .field-chat-canvas-wrap canvas {
    grid-area: 1 / 1;
    display: block;
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
}
.field-chat-wa-video-slot {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.field-chat-wa-panel-footer-fields,
.field-chat-wa-panel-files {
    flex: 0 0 auto;
    padding-top: 6px;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(245, 247, 250, 0.92) 40%, #f5f7fa 100%);
    box-shadow: 0 -8px 16px rgba(245, 247, 250, 0.95);
}

.field-chat-wa-send-photo-btn {
    flex-shrink: 0;
}

.field-chat-wa-compact-field {
    margin-bottom: 4px !important;
}
.field-chat-wa-compact-field:last-of-type {
    margin-bottom: 0 !important;
}
.field-chat-wa-canvas {
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}
.field-chat-wa-recorded-video {
    border-radius: 16px;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    background: #000;
}

.field-chat-chat-video {
    width: 100%;
    max-width: 280px;
    border-radius: 12px;
    background: #000;
}

/* Photo studio overlay: scroll on short viewports so Send stays reachable (Android). */
.mud-overlay:has(.field-chat-photo-dialog) {
    align-items: flex-start !important;
    justify-content: center !important;
    overflow-y: auto !important;
    max-height: 100dvh;
    padding-top: max(0.35rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
}
.field-chat-photo-dialog {
    border-radius: 25px !important;
    border: 1px solid rgba(0, 103, 143, 0.18) !important;
    box-shadow: 0 16px 48px rgba(15, 22, 51, 0.22) !important;
    background: #ffffff !important;
    max-width: min(96vw, 520px);
    width: min(96vw, 520px);
    margin: 0.5rem auto;
    max-height: min(94dvh, 900px);
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    padding: 0 !important;
}

.field-chat-photo-dialog-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.field-chat-photo-dialog-footer {
    flex-shrink: 0;
    background: #ffffff;
    border-top: 1px solid rgba(0, 103, 143, 0.12);
    border-radius: 0 0 25px 25px;
}

.field-chat-canvas-wrap canvas {
    border-radius: 15px;
}

.field-chat-webcam-preview {
    display: block;
    max-width: 100%;
    max-height: min(40vh, 320px);
    border-radius: 15px;
    border: 1px solid rgba(0, 103, 143, 0.18);
    background: #0f1633;
}

.field-chat-messages-scroll--tabbed {
    max-height: min(48vh, 420px);
}

.field-chat-mobile-tabs {
    width: 100%;
}

.field-chat-mobile-tabs .mud-tabs-toolbar {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 103, 143, 0.14);
    box-shadow: 0 2px 10px rgba(15, 22, 51, 0.06);
    margin-bottom: 0.75rem;
}

.field-chat-mobile-tabs .mud-tab {
    text-transform: none;
    font-weight: 600;
    min-height: 48px;
}

.field-chat-mobile-tabs .mud-tabs-panels {
    background: transparent;
}

.field-chat-doc-panel {
    border-radius: 25px;
    border: 1px solid rgba(53, 93, 114, 0.2);
    background: #ffffff;
    box-shadow: 0 4px 18px rgba(15, 22, 51, 0.06);
}

.field-chat-navbar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 0;
    height: var(--subheader-h, 40px);
    min-height: var(--subheader-h, 40px);
    background: linear-gradient(180deg, #005a7a 0%, #00678f 100%);
    flex-shrink: 0;
    z-index: 8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* MudBlazor size-small fixes button height (~34px); stretch needs explicit bar height, not %. */
.field-chat-navbar .mud-icon-button,
.field-chat-navbar > .mud-tooltip-root > .mud-icon-button {
    flex-shrink: 0;
    align-self: stretch;
    width: var(--subheader-h, 40px) !important;
    min-width: var(--subheader-h, 40px) !important;
    max-width: var(--subheader-h, 40px) !important;
    height: var(--subheader-h, 40px) !important;
    min-height: var(--subheader-h, 40px) !important;
    max-height: var(--subheader-h, 40px) !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.field-chat-navbar .field-chat-nav-btn.mud-button-root {
    align-self: stretch !important;
    height: var(--subheader-h, 40px) !important;
    min-height: var(--subheader-h, 40px) !important;
    max-height: var(--subheader-h, 40px) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* MudTooltip wraps copy/help; back is a plain MudIconButton as first flex child */
.field-chat-navbar > .mud-tooltip-root {
    flex-shrink: 0;
    display: inline-flex;
    align-items: stretch;
    align-self: stretch;
}

.field-chat-navbar > .field-chat-nav-home.mud-icon-button,
.field-chat-navbar > .machine-hub-nav-back.mud-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.94) !important;
    background: transparent !important;
}

.field-chat-navbar > .field-chat-nav-home .mud-icon-root {
    font-size: 1.5rem !important;
    color: inherit !important;
}

.field-chat-nav-tabs {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
    align-items: stretch;
}

.field-chat-nav-copy {
    color: rgba(255, 255, 255, 0.95) !important;
}

.field-chat-nav-help {
    color: rgba(255, 255, 255, 0.95) !important;
}

.field-chat-navbar .field-chat-nav-help .mud-icon-root {
    color: inherit !important;
    font-size: 1.5rem !important;
}

.field-chat-navbar .field-chat-nav-copy .mud-icon-root {
    color: inherit !important;
    font-size: 1.5rem !important;
}

.field-chat-nav-copy:disabled {
    opacity: 0.45 !important;
}

.field-chat-navbar .field-chat-nav-btn {
    flex: 1 1 0;
    min-width: 0 !important;
    text-transform: none !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    border-radius: 14px !important;
    letter-spacing: -0.01em;
}

/* Mobile: icon-only intervention tabs (labels hidden via markup + flex). */
.field-chat-navbar--icon-tabs .field-chat-nav-tabs {
    flex: 1 1 auto;
    min-width: 0;
    gap: 4px;
}

.field-chat-navbar--icon-tabs .field-chat-nav-btn {
    flex: 0 0 auto !important;
    width: var(--subheader-h, 40px) !important;
    min-width: var(--subheader-h, 40px) !important;
    max-width: var(--subheader-h, 40px) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    justify-content: center !important;
    border-radius: 0 !important;
}

.field-chat-navbar--icon-tabs .field-chat-nav-btn .mud-button-icon-start {
    margin: 0 !important;
}

.field-chat-navbar--icon-tabs .field-chat-nav-btn-label {
    display: none !important;
}

.field-chat-navbar--icon-tabs .field-chat-nav-btn .mud-icon-root {
    font-size: 1.5rem !important;
}

.field-chat-system-message-shell--navigable {
    cursor: pointer;
}

.field-chat-system-message-shell--navigable .field-chat-system-message {
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.field-chat-system-message-shell--navigable:hover .field-chat-system-message,
.field-chat-system-message-shell--navigable:focus-visible .field-chat-system-message {
    box-shadow: 0 2px 10px rgba(0, 103, 143, 0.18);
    border-color: rgba(0, 103, 143, 0.45) !important;
}

.field-chat-navbar .mud-button-filled.mud-button-filled {
    color: #00678f !important;
    background: rgba(255, 255, 255, 0.96) !important;
}

.field-chat-zone-modal {
    border-radius: 22px !important;
    box-shadow: 0 12px 40px rgba(15, 22, 51, 0.2) !important;
}

.field-chat-page--flat:not(.field-chat-page--mobile-stack) .field-chat-navbar {
    border-radius: 18px;
    margin-bottom: 0.75rem;
}

.field-chat-mobile-tabs .field-chat-side-scroll {
    max-height: min(52vh, 380px);
}

.field-chat-message {
    position: relative; /* required for ::after highlight overlay */
    border-radius: 18px !important;
    border: 1px solid rgba(0, 103, 143, 0.1) !important;
    box-shadow: 0 2px 8px rgba(15, 22, 51, 0.05) !important;
}

.field-chat-message--mine {
    margin-left: 0.75rem !important;
    margin-right: 0 !important;
    border-left: 4px solid #00678f !important;
}

.field-chat-message--theirs {
    margin-right: 0.75rem !important;
    margin-left: 0 !important;
}

/* Highlight ring for navigate-to-message.
   Uses ::after so the animation runs on its OWN box-shadow — not blocked by the
   !important box-shadow on .field-chat-message which would suppress a direct animation. */
@keyframes chat-message-pulse {
    0%   { box-shadow: inset 0 0 0 0px rgba(0, 103, 143, 0); }
    20%  { box-shadow: inset 0 0 0 3px rgba(0, 103, 143, 0.85); }
    50%  { box-shadow: inset 0 0 0 2px rgba(0, 103, 143, 0.25); }
    70%  { box-shadow: inset 0 0 0 3px rgba(0, 103, 143, 0.85); }
    100% { box-shadow: inset 0 0 0 0px rgba(0, 103, 143, 0); }
}

.field-chat-message--highlight::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 18px;
    pointer-events: none;
    z-index: 1;
    animation: chat-message-pulse 2.2s ease-in-out forwards;
}

.field-chat-chat-thumb {
    max-width: 100%;
    border-radius: 15px;
    border: 1px solid rgba(0, 103, 143, 0.12);
}

.field-chat-checklist-ans {
    border-bottom: 1px solid rgba(0, 103, 143, 0.08);
}

.field-chat-checklist-ans:last-child {
    border-bottom: none;
}

/* Single-line checklist remark fields — compact height, light padding */
.field-chat-checklist-comment.mud-input-root {
    margin-top: 0 !important;
}

.field-chat-checklist-comment .mud-input-outlined > .mud-input-outlined-border {
    border-radius: var(--agiva-control-radius, 4px) !important;
}

.field-chat-checklist-comment .mud-input-slot {
    padding: 2px 8px !important;
    min-height: 1.875rem !important;
}

.field-chat-checklist-comment input.mud-input-root,
.field-chat-checklist-comment textarea.mud-input-root {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 1.25 !important;
}

.field-chat-answer-outline {
    border-radius: 16px !important;
    border-color: rgba(0, 103, 143, 0.22) !important;
    background: #fafcfe !important;
}

.field-chat-notify-banner {
    border: 1px solid rgba(53, 93, 114, 0.2);
    background: #fafcfe;
}

.field-chat-notify-inner {
    padding-right: 2.5rem;
}

.field-chat-notify-dismiss {
    position: absolute !important;
    top: 2px;
    right: 2px;
    z-index: 2;
}

.field-chat-notify-enable-btn {
    flex-shrink: 0;
    align-self: center;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--mud-palette-primary, #00678f);
    font: inherit;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: 0.01em;
    text-transform: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.field-chat-notify-enable-btn:hover {
    background: rgba(0, 103, 143, 0.08);
}

.field-chat-notify-enable-btn:active {
    background: rgba(0, 103, 143, 0.14);
}

/*
 * Chat POC technician strip (FieldChatSidebar): hide on small viewports (<600px).
 * Galaxy S25 portrait ≈360 CSS px — must not show the aside. Use a global selector:
 * scoped ::deep rules on FieldChat.razor sometimes fail to override the child component’s
 * .field-chat-sidebar { display: flex } in isolation bundles.
 */
@media (max-width: 599.98px) {
    .field-chat-sidebar {
        display: none !important;
    }
}

/* Mobile: hide site footer; chat POC = full-bleed width, viewport-locked scroll strip */
@media (max-width: 779.98px) {
    .site-footer {
        display: none !important;
    }

    /* FSPEC-033 shell: viewport lock on .main-content-area (not legacy MudLayout).
       Prefer svh so mobile browser chrome does not push the in-flow composer off-screen. */
    .main-content-area:has(.field-chat-page--mobile-stack) {
        display: flex;
        flex-direction: column;
        min-height: 0 !important;
        height: calc(100dvh - var(--header-h, 52px));
        max-height: calc(100dvh - var(--header-h, 52px));
        height: calc(100svh - var(--header-h, 52px));
        max-height: calc(100svh - var(--header-h, 52px));
        overflow: hidden;
        box-sizing: border-box;
    }

    .main-content-area:has(.field-chat-page--mobile-stack) .content {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0 2px 0 2px !important;
    }

    /* MudContainer default gutters (often ~16px/side) */
    .main-content-area:has(.field-chat-page--mobile-stack) .mud-container.field-chat-page--mobile-stack {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Machine hub chat tab: propagate flex fill through hub wrappers */
    .main-content-area:has(.field-chat-page--mobile-stack) .machine-hub-stack,
    .main-content-area:has(.field-chat-page--mobile-stack) .machine-hub-panel,
    .main-content-area:has(.field-chat-page--mobile-stack) .machine-chat-root {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Always-mounted chat keeps field-chat-page in DOM — non-chat hub tabs use document scroll (below). */
    .main-content-area:has(.field-chat-page--mobile-stack) .portal-page-shell:has(.machine-hub-stack) {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        max-width: none !important;
        width: 100% !important;
    }

    /*
     * BUG-240: Always-mounted MachineChat leaves .field-chat-page--mobile-stack in the DOM on every
     * hub tab, so the viewport-lock above would apply to Overview/Media/etc. Nested overflow-y:auto
     * is unreliable on iOS Safari — restore document scroll when Chat is not the active tab.
     */
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }

    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) .content,
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) .portal-page-shell:has(.machine-hub-stack),
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) .machine-hub-stack,
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) .machine-hub-panel,
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)) .machine-hub-tab-body {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        flex: none !important;
        min-height: 0 !important;
        display: block !important;
    }

    /* Chat POC landing (narrow): same horizontal bleed as thread mobile stack; allow normal page scroll */
    .main-content-area:has(.field-chat-page--landing-mobile) .content {
        flex: unset;
        min-height: unset;
        overflow: visible;
        padding: 0 2px 0 2px !important;
    }

    .main-content-area:has(.field-chat-page--landing-mobile) .mud-container.field-chat-page--landing-mobile {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .field-chat-page--landing-mobile {
        margin-inline: 0 !important;
        max-width: none !important;
    }

    /* Hero: hug screen edges horizontally; honour safe-area (MudPaper includes .mud-paper) */
    .field-chat-page--landing-mobile .field-chat-hero--landing-flat.mud-paper {
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
    }

    .field-chat-page.field-chat-page--mobile-stack {
        display: flex;
        flex-direction: column;
        box-sizing: border-box;
        width: 100%;
        max-width: none;
        margin-inline: 0;
        padding-bottom: max(0.25rem, env(safe-area-inset-bottom, 0px));
        flex: 1 1 auto;
        min-height: 0;
    }

    /* Teal tab bar — zero chrome padding; icons use explicit --subheader-h (see .field-chat-navbar). */
    .field-chat-page--mobile-stack .field-chat-navbar {
        gap: 0;
        padding: 0;
    }

    .field-chat-page--mobile-stack .field-chat-nav-tabs {
        gap: 0;
    }

    .field-chat-page--mobile-stack .field-chat-navbar > .field-chat-nav-home .mud-icon-root,
    .field-chat-page--mobile-stack .field-chat-navbar > .machine-hub-nav-back .mud-icon-root,
    .field-chat-page--mobile-stack .field-chat-navbar > .mud-tooltip-root .field-chat-nav-copy .mud-icon-root,
    .field-chat-page--mobile-stack .field-chat-navbar > .mud-tooltip-root .field-chat-nav-help .mud-icon-root {
        font-size: 1.5rem !important;
    }

    .field-chat-page--mobile-stack .field-chat-navbar .mud-button-root:not(.mud-icon-button) {
        border-radius: 0 !important;
        font-size: 0.75rem !important;
    }

    .field-chat-page--mobile-stack .field-chat-navbar .mud-button-icon-start {
        margin: 0 !important;
    }

    .field-chat-page--mobile-stack .field-chat-hero {
        margin-bottom: 0.75rem !important;
    }

    .field-chat-page--mobile-stack .field-chat-meta-strip {
        margin-bottom: 0.75rem !important;
    }

    .field-chat-page--mobile-stack .mud-alert.rounded-xl {
        margin-bottom: 0.75rem !important;
    }

    .field-chat-page--mobile-stack .field-chat-stack {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
    }

    .field-chat-page--mobile-stack .field-chat-panel-wrap {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        pointer-events: auto;
        touch-action: auto;
    }

    .field-chat-page--mobile-stack .field-chat-panel-wrap > .field-chat-chat-tab-stack {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        pointer-events: auto;
        touch-action: auto;
    }

    /* Checklists / Media: scroll inside tab so items are reachable (navbar stays fixed). */
    .field-chat-page--mobile-stack .field-chat-panel-wrap > .field-chat-tab-panel-body,
    .field-chat-page--mobile-stack .field-chat-panel-wrap > .field-chat-tab-panel-stack {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .field-chat-page--mobile-stack .field-chat-panel-wrap > .field-chat-tab-panel-stack {
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .field-chat-tab-panel-stack {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .field-chat-tab-panel-stack .field-chat-tab-panel-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    }

    .field-chat-page--mobile-stack .field-chat-tab-panel-stack--docked .field-chat-tab-panel-body {
        padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
        scroll-padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    .field-chat-tab-prep-dock {
        flex-shrink: 0;
        border-top: 1px solid rgba(0, 103, 143, 0.1);
        background: rgba(248, 250, 252, 0.98);
        padding: 0.35rem 2px max(0.35rem, env(safe-area-inset-bottom, 0px));
    }

    .field-chat-prep-action-bar.field-chat-composer--flat {
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
    }

    .field-chat-page--mobile-stack .field-chat-mobile-tabs {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
    }

    .field-chat-page--mobile-stack .field-chat-mobile-tabs .mud-tabs-toolbar {
        flex-shrink: 0;
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        padding: 4px 2px 2px;
        position: relative;
        z-index: 6;
        background: var(--mud-palette-background, #f5f7fb);
        border-bottom: 1px solid rgba(0, 103, 143, 0.1);
    }

    .field-chat-page--mobile-stack .field-chat-mobile-tabs .mud-tabs-panels {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .field-chat-page--mobile-stack .field-chat-mobile-tabs .mud-tab-panel,
    .field-chat-page--mobile-stack .field-chat-mobile-tabs [role="tabpanel"] {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex !important;
        flex-direction: column;
    }

    .field-chat-page--mobile-stack .field-chat-notify-row {
        flex-shrink: 0;
    }

    .field-chat-chat-tab-stack {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        gap: 0;
    }

    .field-chat-page--mobile-stack .field-chat-thread-panel--tab {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 0;
        margin-left: 0;
        margin-right: 0;
        border: none;
        box-shadow: none;
        background: transparent;
        pointer-events: auto;
        touch-action: auto;
    }

    .field-chat-page--mobile-stack .field-chat-messages-scroll--tabbed {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
        margin: 0 !important;
        /* Avoid padding shorthand — bottom reserved for composer dock (.field-chat-messages-scroll--with-dock) */
        padding-top: 0.25rem !important;
        padding-left: 4px !important;
        padding-right: 4px !important;
        border-radius: 0;
        background: transparent;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        overscroll-behavior: contain;
        pointer-events: auto;
    }

    .field-chat-page--mobile-stack .field-chat-messages-scroll--tabbed:not(.field-chat-messages-scroll--with-dock) {
        padding-bottom: 0.25rem !important;
    }

    /* Space above composer when it was fixed; in-flow dock (below) only needs a small pad. */
    .field-chat-page--mobile-stack {
        --field-chat-composer-dock-inset: max(0.5rem, env(safe-area-inset-bottom, 0px));
    }

    .field-chat-page--mobile-stack .field-chat-messages-scroll.field-chat-messages-scroll--with-dock {
        padding-bottom: var(--field-chat-composer-dock-inset) !important;
        scroll-padding-bottom: var(--field-chat-composer-dock-inset) !important;
    }

    .field-chat-page--mobile-stack .field-chat-message .field-chat-checklist-item:first-of-type {
        margin-top: 0.35rem;
    }

    .field-chat-page--mobile-stack .field-chat-message .field-chat-checklist-item + .field-chat-checklist-item {
        margin-top: 0.3rem;
    }

    .field-chat-page--mobile-stack .field-chat-message .field-chat-checklist-item .mt-1 {
        margin-top: 0.2rem !important;
    }

    .field-chat-page--mobile-stack .field-chat-checklist-post-btn {
        min-height: 40px;
    }

    /*
     * Mobile composer: in-flow flex footer (AGENT-UX-013).
     * position:fixed inside .machine-hub-stack / viewport-lock overflow:hidden gets clipped
     * when the hub fills the viewport — that is what hid composer + action buttons.
     */
    .field-chat-page--mobile-stack .field-chat-content {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        width: 100%;
    }

    .field-chat-page--mobile-stack .field-chat-panel-wrap {
        flex: 1 1 auto;
        min-height: 0;
    }

    .field-chat-mobile-composer-dock {
        position: sticky;
        left: auto;
        right: auto;
        bottom: 0;
        flex: 0 0 auto;
        width: 100%;
        z-index: 6;
        padding: 0.35rem 2px max(0.35rem, env(safe-area-inset-bottom, 0px));
        background: rgba(248, 250, 252, 0.97);
        border-top: 1px solid rgba(0, 103, 143, 0.1);
        pointer-events: auto;
        touch-action: auto;
    }

    /* Tablet / small desktop with sidebar: dock is in-flow in the main column — no left offset. */
    @media (min-width: 600px) and (max-width: 779.98px) {
        .field-chat-mobile-composer-dock {
            left: auto;
            width: 100%;
        }
    }

    .main-content-area.main-content-area--sidebar-collapsed .field-chat-mobile-composer-dock {
        left: auto;
    }

    /* Viewport-locked chats: base .field-chat-messages-scroll caps height at 42vh — override for flex fill */
    .field-chat-page--mobile-stack .field-chat-messages-scroll,
    .field-chat-page--desktop-viewport .field-chat-messages-scroll {
        max-height: none !important;
    }

    .field-chat-page--mobile-stack .field-chat-thread-panel--tab.mud-paper,
    .field-chat-page--desktop-viewport .field-chat-thread-panel {
        min-height: 0 !important;
    }

    .field-chat-composer--mobile-dock {
        margin-bottom: 0 !important;
    }

    .field-chat-page--mobile-stack .field-chat-message {
        border-radius: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 0.5rem !important;
        box-shadow: none !important;
        border: none !important;
        border-left: 3px solid rgba(0, 103, 143, 0.35) !important;
        background: rgba(255, 255, 255, 0.92) !important;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    .field-chat-page--mobile-stack .field-chat-system-message,
    .field-chat-page--mobile-stack .field-chat-system-message .mud-alert-message {
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    .field-chat-page--mobile-stack .field-chat-message--mine {
        border-left-color: #00678f !important;
    }

    .field-chat-page--mobile-stack .field-chat-composer--mobile-dock,
    .field-chat-page--mobile-stack .field-chat-composer--mobile-dock.mud-paper {
        box-shadow: none !important;
        border: none !important;
        border-top: 1px solid rgba(0, 103, 143, 0.12) !important;
        border-radius: 0 !important;
        background: rgba(248, 250, 252, 0.98) !important;
    }

    .field-chat-page--mobile-stack .field-chat-notify-banner {
        border-radius: 4px;
        margin-left: 4px;
        margin-right: 4px;
    }

    .field-chat-mobile-tabs--compact .mud-tabs-toolbar {
        min-height: 0;
        padding: 0 2px;
    }

    .field-chat-mobile-tabs--compact .mud-tabs-toolbar-inner {
        width: 100%;
        display: flex;
    }

    .field-chat-mobile-tabs--compact .mud-tabs-toolbar .mud-tooltip-root {
        flex: 1 1 0;
        min-width: 0;
    }

    .field-chat-mobile-tabs--compact .mud-tab {
        flex: 1 1 0;
        min-width: 0 !important;
        min-height: 40px;
        padding: 4px 6px;
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: none;
        letter-spacing: -0.01em;
    }

    .field-chat-mobile-tabs--compact .mud-tab .mud-icon-root {
        font-size: 1.15rem !important;
        margin-inline-end: 2px !important;
        margin-inline-start: 0 !important;
    }

    .field-chat-mobile-tabs--compact .mud-tabs-scroll-button {
        display: none !important;
    }

    .field-chat-mobile-tabs--compact .mud-tab-active {
        font-weight: 700;
    }

    .field-chat-tab-panel-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    }

    .field-chat-page--mobile-stack .field-chat-mobile-tabs .field-chat-side-scroll {
        max-height: none !important;
    }
}

/* Desktop (wide): chat POC fills viewport — only message list / tab bodies scroll; no page scroll */
@media (min-width: 780px) {
    .main-content-area:has(.field-chat-page--desktop-viewport) {
        display: flex;
        flex-direction: column;
        min-height: 0 !important;
        height: calc(100dvh - var(--header-h, 52px));
        max-height: calc(100dvh - var(--header-h, 52px));
        overflow: hidden;
        box-sizing: border-box;
    }

    .main-content-area:has(.field-chat-page--desktop-viewport) .site-footer {
        display: none !important;
    }

    .main-content-area:has(.field-chat-page--desktop-viewport) .content {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding-bottom: 0 !important;
    }

    .main-content-area:has(.field-chat-page--desktop-viewport) .mud-container.field-chat-page--desktop-viewport {
        flex: 1 1 auto;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        width: 100%;
    }

    .main-content-area:has(.field-chat-page--desktop-viewport) .machine-hub-stack,
    .main-content-area:has(.field-chat-page--desktop-viewport) .machine-hub-panel,
    .main-content-area:has(.field-chat-page--desktop-viewport) .machine-chat-root,
    .main-content-area:has(.field-chat-page--desktop-viewport) .portal-page-shell:has(.machine-hub-stack) {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Always-mounted chat: non-chat hub tabs use document/panel scroll when Chat is inactive.
       Restore min-height so the chat viewport-lock's min-height:0 does not shrink-wrap the shell. */
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)):has(.field-chat-page--desktop-viewport) {
        height: auto !important;
        max-height: none !important;
        min-height: calc(100dvh - var(--header-h, 52px)) !important;
        overflow: visible !important;
    }

    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)):has(.field-chat-page--desktop-viewport) .content,
    .main-content-area:has(.machine-hub-stack):not(:has(.machine-hub-chat-host--active)):has(.field-chat-page--desktop-viewport) .portal-page-shell:has(.machine-hub-stack) {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        flex: none !important;
    }

    .field-chat-page--desktop-viewport {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-sizing: border-box;
    }

    .field-chat-page--desktop-viewport .field-chat-stack {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        width: 100%;
    }

    .field-chat-page--desktop-viewport .field-chat-panel-wrap {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .field-chat-page--desktop-viewport .field-chat-chat-tab-stack {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .field-chat-page--desktop-viewport .field-chat-thread-panel {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .field-chat-page--desktop-viewport .field-chat-messages-scroll {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
    }

    .field-chat-page--desktop-viewport .field-chat-composer,
    .field-chat-page--desktop-viewport .field-chat-chat-tab-stack > .field-chat-composer {
        flex-shrink: 0;
    }

    .field-chat-page--desktop-viewport .field-chat-tab-panel-body,
    .field-chat-page--desktop-viewport .field-chat-tab-panel-stack {
        min-height: 0;
        overflow-y: auto;
    }

    .field-chat-page--desktop-viewport .field-chat-tab-panel-stack {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .field-chat-page--desktop-viewport .field-chat-tab-panel-stack .field-chat-tab-panel-body {
        flex: 1 1 auto;
        overflow-y: auto;
    }

    .field-chat-page--desktop-viewport .field-chat-tab-prep-dock {
        flex-shrink: 0;
    }
}

.main-content-area:has(.article-agent-page--viewport) .site-footer {
    display: none;
}

.main-content-area:has(.article-agent-page--viewport) {
    display: flex;
    flex-direction: column;
    min-height: 0 !important;
    height: calc(100dvh - var(--header-h, 52px));
    max-height: calc(100dvh - var(--header-h, 52px));
    overflow: hidden;
    box-sizing: border-box;
}

.main-content-area:has(.article-agent-page--viewport) .content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0 !important;
}

.main-content-area:has(.article-agent-page--viewport) .article-agent-page--viewport {
    flex: 1 1 auto;
    min-height: 0 !important;
    max-height: 100%;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    padding-left: var(--page-pad-x, 1rem) !important;
    padding-right: var(--page-pad-x, 1rem) !important;
}

@media (min-width: 600px) {
    .main-content-area:has(.article-agent-page--viewport) .article-agent-page--viewport {
        padding-left: var(--page-pad-x-md, 1.25rem) !important;
        padding-right: var(--page-pad-x-md, 1.25rem) !important;
    }
}

.article-agent-page--viewport .article-agent-page__shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.article-agent-page--viewport .article-agent-page__header {
    flex-shrink: 0;
}

.article-agent-page--viewport .article-agent-page__schema-panel {
    flex-shrink: 0;
    max-height: min(40vh, 320px);
    overflow-y: auto;
}

.article-agent-page--viewport .article-agent-page__chat {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.article-agent-page--viewport .article-agent-page__messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.article-agent-page--viewport .article-agent-page__composer {
    flex-shrink: 0;
    position: relative;
    border-radius: 4px;
    transition: box-shadow 0.15s ease, background-color 0.15s ease;
}

.article-agent-page__composer--drop-active {
    box-shadow: inset 0 0 0 2px var(--mud-palette-primary);
    background-color: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

.article-agent-chat-message__table-wrap {
    overflow-x: auto;
    max-width: 100%;
}

.article-agent-chat-table {
    font-size: 0.8125rem;
    width: 100%;
}

.article-agent-chat-table th {
    font-weight: 600;
    white-space: nowrap;
}

.article-agent-chat-table td {
    vertical-align: top;
}

.article-agent-chat-message__panels {
    border-radius: 8px;
}

.article-agent-chat-message__panels .mud-expand-panel-header {
    min-height: 40px;
    padding-top: 0;
    padding-bottom: 0;
}

.article-agent-chat-message__heading {
    font-weight: 600;
}

.field-chat-intervention-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.field-chat-intervention-photo-card {
    border-radius: 14px;
    border: 1px solid rgba(0, 103, 143, 0.12);
    background: rgba(248, 250, 252, 0.95);
    padding: 6px;
    overflow: hidden;
}

.field-chat-doc-photo {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 10px;
    aspect-ratio: 1;
    object-fit: cover;
}

/* Intervention chat (/machines/{serial}/interventions/{id}) — full width, single teal bar, sidebar right */
.intervention-chat-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    background: #fff;
    overflow: hidden;
}

/* Shared full-pane loading state (machines hub, intervention chat, …). */
.portal-page-loading,
.intervention-chat-page__loading {
    flex: 1 1 auto;
    min-height: calc(100svh - var(--header-h, 52px) - 4.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1.25rem;
    box-sizing: border-box;
    background:
        radial-gradient(ellipse 70% 50% at 50% 42%, rgba(0, 103, 143, 0.06) 0%, transparent 70%),
        #f7fafc;
    border-radius: var(--agiva-control-radius, 4px);
}

.portal-page-loading__title,
.intervention-chat-page__loading-title {
    margin: 0.35rem 0 0 !important;
    color: #003d56 !important;
    font-weight: 600 !important;
    text-align: center;
}

.portal-page-loading__hint,
.intervention-chat-page__loading-hint {
    margin: 0 !important;
    text-align: center;
    letter-spacing: 0.02em;
}

/* Document-style machine pages (work order detail) keep the hub back bar inside page gutters. */
.mud-container.portal-page-shell > .machine-hub-navbar {
    border-radius: var(--agiva-control-radius, 4px);
    margin-bottom: 1rem;
    overflow: hidden;
}

.intervention-chat-page__loading {
    min-height: calc(100svh - var(--header-h, 52px));
    border-radius: 0;
}

/* Phone-only narrow stack: participate in viewport-locked chat stack (composer docked to bottom) */
@media (max-width: 779.98px) {
    .intervention-chat-page {
        flex: 1 1 auto;
        min-height: 0;
    }

    .intervention-chat-page .field-chat-page--full-bleed.field-chat-page--mobile-stack {
        flex: 1 1 auto;
        min-height: 0;
    }
}

.field-chat-page--full-bleed {
    max-width: none !important;
    width: 100% !important;
    margin-inline: 0 !important;
}

.field-chat-nav-trail {
    margin-left: auto;
    min-width: 0;
    padding-right: 8px;
}

@media (min-width: 600px) {
    .main-content-area:has(.intervention-chat-page) .site-footer {
        display: none !important;
    }

    .main-content-area:has(.intervention-chat-page) {
        display: flex;
        flex-direction: column;
        min-height: 0 !important;
        height: calc(100dvh - var(--header-h, 52px));
        max-height: calc(100dvh - var(--header-h, 52px));
        overflow: hidden;
        box-sizing: border-box;
    }

    .main-content-area:has(.intervention-chat-page) .content {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0 !important;
    }

    .intervention-chat-page .mud-container.field-chat-page--full-bleed,
    .intervention-chat-page .field-chat-page--full-bleed {
        flex: 1 1 auto;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        width: 100%;
        max-width: none !important;
        padding: 0 !important;
    }

    .intervention-chat-page .field-chat-stack {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        width: 100%;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-content--sidebar-end {
        flex-direction: row !important;
        align-items: stretch;
        flex: 1 1 auto;
        min-height: 0;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-content--sidebar-end > .field-chat-panel-wrap {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        flex-direction: column;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-content--sidebar-end > .field-chat-sidebar {
        order: 2;
        flex: 0 0 320px;
        width: 320px;
        max-width: min(380px, 34vw);
        min-height: 0;
        align-self: stretch;
        border-left: 1px solid #e0e4ec;
        border-right: none;
    }

    /* Chat column: messages scroll, composer pinned at bottom (wide desktop only; narrow uses fixed dock) */
    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-panel-wrap {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-chat-tab-stack {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-chat-tab-stack > .field-chat-thread-panel {
        flex: 1 1 auto;
        min-height: 0;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-chat-tab-stack > .field-chat-composer {
        flex-shrink: 0;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .machine-chat-wo-bar {
        flex-shrink: 0;
        border-radius: 0 !important;
        margin-bottom: 0 !important;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-thread-panel,
    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-thread-panel.flex-grow-1,
    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-thread-panel--tab {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border-radius: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-messages-scroll {
        flex: 1 1 auto;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-composer {
        flex-shrink: 0;
        margin-top: 0 !important;
        border-radius: 0 !important;
        border-top: 1px solid rgba(0, 103, 143, 0.12) !important;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-composer .mud-button-root,
    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-composer-action {
        border-radius: 0 !important;
    }

    .field-chat-page--full-bleed:not(.field-chat-page--mobile-stack) .field-chat-media-tab-panel {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        padding: 0.5rem 0.75rem 1rem;
    }
}

/* Intervention chat — pinned top chrome (section nav + prep banner) */
.field-chat-top-chrome {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    z-index: 12;
}

.field-chat-prep-locked-banner {
    flex-shrink: 0;
    border-radius: 0 !important;
}

.field-chat-prep-status-bar {
    flex-shrink: 0;
}

.field-chat-prep-status-bar--nowrap {
    flex-wrap: nowrap;
}

.field-chat-prep-status-bar--nowrap .intervention-context-header {
    flex: 1 1 auto;
    min-width: 0;
}

.field-chat-mobile-nav-status {
    display: flex;
    align-items: center;
    margin-left: auto;
    min-width: 0;
    flex: 0 1 auto;
}

/* Mobile-only status strip below icon tabs — wide desktop shows status in sidebar header. */
.field-chat-mobile-status-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-shrink: 0;
    width: 100%;
    padding: 4px 8px;
    background: linear-gradient(180deg, #004d68 0%, #005a7a 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.field-chat-mobile-status-bar .field-chat-mobile-status-menu {
    width: 100%;
    max-width: 100%;
}

.field-chat-mobile-status-bar .field-chat-mobile-status-chip {
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
}

.field-chat-navbar--icon-tabs .field-chat-mobile-nav-status {
    max-width: min(42vw, 11rem);
}

.field-chat-mobile-status-chip {
    max-width: 100%;
    cursor: pointer;
}

.field-chat-mobile-status-chip .mud-chip-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-chat-mobile-status-bar .field-chat-mobile-status-chip .mud-chip-content {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

.field-chat-mobile-status-menu-topic {
    font-weight: 700 !important;
    opacity: 1 !important;
    white-space: normal;
    line-height: 1.35;
}

.field-chat-mobile-status-menu-serial,
.field-chat-mobile-status-menu-desc {
    opacity: 0.85 !important;
    white-space: normal;
    line-height: 1.35;
    font-size: 12px;
}

/* Intervention chat — flat top bar and sidebar controls (no pill tabs / rounded chips) */
.intervention-chat-page .field-chat-navbar,
.intervention-chat-page .field-chat-page--flat .field-chat-navbar {
    border-radius: 0 !important;
    margin-bottom: 0 !important;
}

.intervention-chat-page .field-chat-navbar--icon-tabs .field-chat-nav-btn {
    border-radius: 0 !important;
}

.intervention-chat-page .field-chat-navbar--icon-tabs .field-chat-nav-btn .mud-button-icon-start {
    margin: 0 !important;
}

.intervention-chat-page .field-chat-navbar--icon-tabs .field-chat-nav-btn .mud-icon-root {
    font-size: 1.5rem !important;
}

.intervention-chat-page .field-chat-navbar .field-chat-nav-btn,
.intervention-chat-page .field-chat-navbar .mud-button-root.field-chat-nav-btn,
.intervention-chat-page .field-chat-navbar .mud-button-filled.mud-button-filled {
    border-radius: 0 !important;
}

.intervention-chat-page .field-chat-navbar > .field-chat-nav-home.mud-icon-button,
.intervention-chat-page .field-chat-navbar > .field-chat-nav-home.machine-hub-nav-back {
    border-radius: 0 !important;
    padding: 0 !important;
}

.intervention-chat-page .ans-btn,
.intervention-chat-page .strip-edit-btn,
.intervention-chat-page .strip-save-btn,
.intervention-chat-page .strip-cancel-btn,
.intervention-chat-page .field-chat-timer-strip button,
.intervention-chat-page .zone-block,
.intervention-chat-page .strip-badge,
.intervention-chat-page .zone-progress {
    border-radius: 0 !important;
}

.intervention-chat-page .machine-chat-wo-bar .mud-chip-root {
    border-radius: 0 !important;
}

.intervention-chat-page .field-chat-system-message,
.intervention-chat-page .field-chat-system-message.mud-alert-root {
    border-radius: 0 !important;
    max-width: 100%;
    overflow-x: hidden;
}

.field-chat-system-message-shell,
.field-chat-system-message .mud-alert-message {
    max-width: 100%;
    min-width: 0;
}

.close-intervention-signature-wrap {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.close-intervention-signature-canvas {
    display: block;
    width: 100%;
    height: 200px;
    touch-action: none;
    cursor: crosshair;
}

/* Closing signature dialog: scroll on short viewports; keep actions above mobile chat composer */
.mud-dialog-container:has(.customer-signature-dialog) {
    z-index: calc(var(--mud-zindex-dialog, 1300) + 150);
}

body:has(.mud-dialog-container .customer-signature-dialog) .field-chat-mobile-composer-dock {
    pointer-events: none;
}

.mud-dialog:has(.customer-signature-dialog) {
    display: flex;
    flex-direction: column;
    max-height: min(94dvh, 900px);
}

.mud-dialog:has(.customer-signature-dialog) .mud-dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mud-dialog:has(.customer-signature-dialog) .mud-dialog-actions {
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* Add forfait task dialog — two equal tabs, no scroll arrows */
.add-forfait-task-tabs {
    display: flex;
    width: 100%;
}

.add-forfait-task-tabs .add-forfait-task-tab {
    flex: 1 1 50%;
    min-width: 0;
    text-transform: none;
    letter-spacing: normal;
}


.mud-dialog:has(.field-dialog-mobile-safe) {
    display: flex;
    flex-direction: column;
    max-height: min(94dvh, 900px);
    width: min(100%, 720px);
    max-width: calc(100vw - 24px);
}

.mud-dialog:has(.field-dialog-mobile-safe) .mud-dialog-title,
.mud-dialog:has(.field-dialog-mobile-safe) .mud-dialog-content,
.mud-dialog:has(.field-dialog-mobile-safe) .mud-dialog-actions {
    min-width: 0;
    max-width: 100%;
}

.mud-dialog:has(.field-dialog-mobile-safe) .mud-dialog-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mud-dialog:has(.field-dialog-mobile-safe) .mud-dialog-actions {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

@media (max-width: 600px) {
    .mud-dialog-container .mud-dialog:has(.field-dialog-mobile-safe) {
        width: calc(100vw - 16px) !important;
        max-width: calc(100vw - 16px) !important;
        margin: 8px auto !important;
    }
}

.parts-offer-suggestion-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.parts-offer-suggestion-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    margin-top: 2px;
}

.parts-offer-suggestion-ref {
    font-size: 0.8rem;
    color: #6b7280;
    overflow-wrap: anywhere;
}

.parts-offer-suggestion-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
}

.parts-offer-line-card {
    background-color: #f4f6fb;
    border-radius: 12px;
    max-width: 100%;
    overflow: hidden;
}

.parts-offer-line-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px 12px;
    min-width: 0;
    max-width: 100%;
}

.parts-offer-line-image {
    flex: 0 0 auto;
}

.parts-offer-line-body {
    flex: 1 1 140px;
    min-width: 0;
    max-width: 100%;
}

.parts-offer-line-body .mud-typography {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.parts-offer-line-actions {
    flex: 0 0 auto;
    margin-left: auto;
}

.parts-offer-thumb,
.parts-offer-thumb-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    background: #fff;
}

.parts-offer-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

.parts-offer-qty-controls,
.parts-offer-qty-readonly {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    flex-shrink: 0;
}

.parts-offer-qty-controls {
    padding: 2px 4px;
}

.parts-offer-qty-readonly {
    padding: 4px 12px;
    min-width: 2.5rem;
}

.parts-offer-qty-display {
    min-width: 2rem;
    text-align: center;
    font-weight: 600;
    margin: 0 2px;
}

.parts-offer-detail__status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.parts-offer-detail__note {
    background: #f8fafc;
    border-radius: 12px;
}

.parts-offer-detail__line-total {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-top: 2px;
}

@media (max-width: 480px) {
    .parts-offer-line-actions {
        flex: 1 1 100%;
        display: flex;
        justify-content: flex-end;
        margin-left: 0;
    }

    .parts-offer-thumb,
    .parts-offer-thumb-placeholder {
        width: 48px;
        height: 48px;
    }
}

.close-intervention-dialog .close-intervention-answers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.close-intervention-dialog .ans-btn {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    background: #fff;
    cursor: pointer;
}

.close-intervention-dialog .ans-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.close-intervention-dialog .ans-btn.active.opt-yes {
    background: #dcfce7;
    border-color: #16a34a;
    color: #166534;
}

.close-intervention-dialog .ans-btn.active.opt-no {
    background: #fee2e2;
    border-color: #dc2626;
    color: #991b1b;
}

.close-intervention-dialog .ans-btn.active.opt-na {
    background: #f3f4f6;
    border-color: #6b7280;
    color: #374151;
}

.close-intervention-mandatory {
    color: #dc2626;
}

.close-intervention-checklist-comment {
    margin-top: 4px;
}

.close-intervention-time-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Webshop hub segment bar — same chrome as machine hub nav; tabs always pack left after back */
.webshop-hub-bar {
    display: block;
    flex: none;
    min-height: 0;
    height: auto;
    overflow: visible;
    background: transparent;
    width: 100%;
}

.webshop-hub-bar .machine-hub-navbar {
    margin-bottom: 0;
    width: 100%;
    justify-content: flex-start;
    align-items: center;
}

.webshop-hub-bar .machine-hub-nav-tabs {
    justify-content: flex-start;
    flex: 0 1 auto;
}

/* Second-row webshop sub-nav (legacy machine-hub alignment; catalog/detail no longer use this row) */
.webshop-hub-subnav .machine-hub-nav-back-spacer {
    flex-shrink: 0;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
}

/* Machine hub (/machines/{serial}) — narrow top segment nav; density matches chat POC mobile stack */
.machine-hub-stack {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: #fff;
}

/* Always-mounted chat host — visible only when Chat tab is active (see MachinePageTabPanels). */
.machine-hub-panel .machine-hub-chat-host--active {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.machine-hub-panel .machine-hub-chat-host.d-none {
    display: none !important;
}

/* Desktop / tablet: fill under the fixed header. Mobile composer is in-flow now, so the old
   3.5rem bottom reserve is no longer required to keep the dock visible. */
@media (min-width: 769px) {
    .machine-hub-stack {
        height: calc(100dvh - var(--header-h, 52px));
        max-height: calc(100dvh - var(--header-h, 52px));
        height: calc(100svh - var(--header-h, 52px));
        max-height: calc(100svh - var(--header-h, 52px));
    }

    .machine-hub-panel {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    /* Work orders, interventions, overview, etc. — scroll inside the hub panel */
    .machine-hub-panel:not(:has(.machine-hub-chat-host--active)) {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .machine-hub-tab-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    /* Always-mounted chat host flex fill (desktop refinements share base host rules above) */
    .machine-hub-panel .machine-hub-chat-host--active .machine-chat-root {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .machine-hub-panel .machine-hub-chat-host--active .mud-container.field-chat-page {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .machine-hub-panel .machine-hub-chat-host--active .field-chat-stack,
    .machine-hub-panel .machine-hub-chat-host--active .field-chat-content,
    .machine-hub-panel .machine-hub-chat-host--active .field-chat-panel-wrap,
    .machine-hub-panel .machine-hub-chat-host--active .field-chat-chat-tab-stack {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .machine-hub-panel .machine-hub-chat-host--active .field-chat-thread-panel {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .machine-hub-panel .machine-hub-chat-host--active .field-chat-messages-scroll {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none !important;
        overflow-y: auto;
    }

    .machine-hub-panel .machine-hub-chat-host--active .field-chat-composer,
    .machine-hub-panel .machine-hub-chat-host--active .field-chat-chat-tab-stack > .field-chat-composer {
        flex-shrink: 0;
    }
}

.machine-hub-navbar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 0;
    height: var(--subheader-h, 40px);
    min-height: var(--subheader-h, 40px);
    background: linear-gradient(180deg, #005a7a 0%, #00678f 100%);
    flex-shrink: 0;
    z-index: 4;
}

.machine-hub-navbar .mud-icon-button,
.machine-hub-navbar > .mud-tooltip-root > .mud-icon-button {
    flex-shrink: 0;
    align-self: stretch;
    width: var(--subheader-h, 40px) !important;
    min-width: var(--subheader-h, 40px) !important;
    max-width: var(--subheader-h, 40px) !important;
    height: var(--subheader-h, 40px) !important;
    min-height: var(--subheader-h, 40px) !important;
    max-height: var(--subheader-h, 40px) !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.machine-hub-navbar > .mud-tooltip-root {
    align-self: stretch;
    display: inline-flex;
    align-items: stretch;
}

.machine-hub-navbar > .machine-hub-nav-back.mud-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.96) !important;
    background: transparent !important;
}

.machine-hub-navbar > .machine-hub-nav-back .mud-icon-root {
    font-size: 1.35rem !important;
    color: inherit !important;
}

.machine-hub-navbar .machine-hub-nav-btn.mud-button-root {
    align-self: stretch !important;
    height: var(--subheader-h, 40px) !important;
    min-height: var(--subheader-h, 40px) !important;
    max-height: var(--subheader-h, 40px) !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.machine-hub-nav-tabs {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 2px;
    align-items: stretch;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: thin;
}

.machine-hub-navbar .machine-hub-nav-btn {
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 0 !important;
    text-transform: none !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    border-radius: 0 !important;
    letter-spacing: -0.01em;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.machine-hub-navbar .mud-button-filled.mud-button-filled {
    color: #00678f !important;
    background: rgba(255, 255, 255, 0.96) !important;
}

/* Icon-only hub bar (mobile): larger touch targets, no duplicate chat tab row below */
.machine-hub-navbar--icons .machine-hub-nav-icon-btn {
    flex-shrink: 0;
    align-self: stretch;
    width: var(--subheader-h, 40px) !important;
    min-width: var(--subheader-h, 40px) !important;
    max-width: var(--subheader-h, 40px) !important;
    height: var(--subheader-h, 40px) !important;
    min-height: var(--subheader-h, 40px) !important;
    max-height: var(--subheader-h, 40px) !important;
    padding: 0 !important;
    color: rgba(255, 255, 255, 0.94) !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.machine-hub-navbar--icons .machine-hub-nav-icon-btn .mud-icon-root {
    font-size: 1.45rem !important;
}

.machine-hub-navbar--icons .machine-hub-nav-icon-btn--active {
    color: #00678f !important;
    background: rgba(255, 255, 255, 0.96) !important;
}

.machine-hub-panel .field-chat-navbar {
    display: none !important;
}

.machine-hub-navbar-crumb {
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
}

.machine-hub-navbar-crumb-link {
    color: rgba(255, 255, 255, 0.92) !important;
    flex-shrink: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.machine-hub-navbar-crumb-sep {
    color: rgba(255, 255, 255, 0.55);
    flex-shrink: 0;
}

.machine-hub-navbar-crumb-current {
    color: rgba(255, 255, 255, 0.96);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.machine-hub-nav-trail {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6px;
}

.machine-hub-nav-trail-text {
    color: rgba(255, 255, 255, 0.96) !important;
    font-weight: 600;
}

.machine-hub-panel {
    padding: 0;
    background: #fafcfd;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.machine-hub-panel:has(.machine-hub-chat-host--active) {
    overflow: hidden;
}

.machine-hub-tab-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* Photo studio from Media tab: chat stays mounted off-screen; only the studio overlay is visible. */
.field-media-photo-studio-host {
    position: fixed;
    inset: 0;
    z-index: 4500;
    pointer-events: none;
}

.field-media-photo-studio-host .machine-chat-root {
    pointer-events: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    background: transparent;
}

.field-media-photo-studio-host .field-chat-page {
    visibility: hidden;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.field-media-photo-studio-host .field-chat-wa-overlay-root {
    position: fixed !important;
    inset: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 4600 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.field-media-tab-photo-studio-hidden {
    visibility: hidden;
    pointer-events: none;
}

.machine-hub-stack > .bottom-nav {
    border-radius: 0 0 8px 8px;
}

/* Catalog / product pages: segment bar without back button */
.machine-hub-nav-tabs--solo {
    flex: 1 1 auto;
    min-width: 0;
    padding-left: 2px;
}

.machine-wo-card {
    border-radius: 8px !important;
    border: 1px solid rgba(0, 103, 143, 0.12) !important;
    background: #fff !important;
}

.machine-wo-detail-dialog-line {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* ─── Audit event detail card (InterventionAuditLogPanel + Dialog) ───────── */
.audit-detail-card {
    background: #eef3f8;
    border-left: 3px solid var(--mud-palette-primary);
    padding: 10px 16px 14px 14px;
    animation: audit-detail-in 0.12s ease-out;
}

@keyframes audit-detail-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.audit-detail-card__title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--mud-palette-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.audit-detail-card__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
}

@media (max-width: 600px) {
    .audit-detail-card__grid { grid-template-columns: 1fr; }
}

.audit-detail-card__field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.audit-detail-card__field--wide {
    grid-column: 1 / -1;
}

.audit-detail-card__label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a8a99;
}

.audit-detail-card__value {
    font-size: 0.875rem;
    color: #1a2633;
    word-break: break-word;
}

.audit-detail-card__value--sub {
    font-size: 0.75rem;
    color: #7a8a99;
    word-break: break-all;
}

.machine-chat-wo-bar {
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--mud-palette-background-grey);
}

/* Intervention request button pinned below the composer in machine chat */
.machine-chat-intervention-btn {
    flex-shrink: 0;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 0.875rem !important;
}

/* Machine Chat — scrollable thread + sticky composer on narrow layouts */
.machine-chat-root {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.machine-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.machine-chat-root--narrow .machine-chat-body {
    min-height: min(72dvh, 640px);
    max-height: calc(100dvh - 200px);
}

.machine-chat-messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.machine-chat-root--narrow .machine-chat-messages {
    flex: 1 1 auto;
    min-height: 160px;
}

.machine-chat-composer--dock {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding-top: 8px;
    margin-top: auto;
    background: linear-gradient(180deg, transparent 0%, #fafcfd 14px, #fafcfd 100%);
}

.machine-chat-empty {
    min-height: 200px;
}

.machine-chat-annotate-viewport {
    min-height: 200px;
    max-height: 44vh;
    background: #1a1a1a;
    border-radius: 10px;
}

.machine-chat-photo-dialog {
    border-radius: 14px !important;
}

.machine-wo-detail-dialog-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.machine-wo-table-row-pointer {
    cursor: pointer;
}

/* Machine hub — Interventies tab list */
.machine-interventions-tab {
    padding: 0.75rem 1.25rem 0;
}

.machine-interventions-tab__intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 1rem;
    row-gap: 0.5rem;
    margin-bottom: 1rem;
    min-width: 0;
}

.machine-interventions-tab__title {
    grid-column: 1;
    grid-row: 1;
    margin: 0 0 0.25rem !important;
}

.machine-interventions-tab__lead {
    grid-column: 1;
    grid-row: 2;
    margin: 0 !important;
    line-height: 1.5;
}

.machine-interventions-tab__create-btn {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    justify-self: end;
    max-width: 100%;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .machine-interventions-tab {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .machine-interventions-tab__intro {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.625rem;
    }

    .machine-interventions-tab__title {
        margin-bottom: 0 !important;
    }

    .machine-interventions-tab__create-btn {
        align-self: stretch;
        width: 100%;
        justify-content: center;
    }
}

.machine-interventions-tab__table-wrap {
    background: #fff;
    border: 1px solid rgba(0, 103, 143, 0.14);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.machine-interventions-tab__table-wrap .machine-interventions-table.mud-table-root {
    border-radius: 0 !important;
    box-shadow: none !important;
}

.machine-interventions-tab .mud-table-root .mud-table-container {
    border-radius: 0 !important;
}

.machine-interventions-tab .mud-table-head .mud-table-cell {
    padding: 1rem 1.125rem !important;
}

.machine-interventions-tab .mud-table-body .mud-table-row .mud-table-cell {
    padding: 0.875rem 1.125rem !important;
}

.machine-interventions-tab .mud-table-body .mud-table-row:last-child .mud-table-cell {
    padding-bottom: 1.125rem !important;
}

/* Catalog filter dialog — centered overlay on category overview */
.mud-overlay.catalog-filter-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.catalog-filter-dialog {
    width: min(28rem, calc(100vw - 32px));
    max-height: min(80dvh, 720px);
    overflow-y: auto;
}