@layer legacy {
/* The activity editor phone layout of the card shell's own elements lives in
   EntityCardShell.razor.css and EntityCardFooterLayout.razor.css (#597). What remains:
   the editor hosts (pages, dialogs, the calendar side panel), which the shell's scoped CSS
   cannot reach; FormButtonGroup (Triolink.Components) and form content the shell does not
   render; and rules that legacy consumer CSS (products.css, testdrive.css) or the migrated
   DesktopTopContactComponent and EmbeddedActivityCard rules still override in this cascade order. */

/* Opt-in activity editor viewport, shared by the calendar host and routed tab.
   Keep the existing sections mounted; only the body scrolls. Phone viewport
   placement is separate from the narrow content layout below. */
body.is-phone-layout :is(.t-mobile-activity-editor, .t-mobile-entity-editor, .t-mobile-workspace-editor) {
    --activity-editor-top: max(var(--shell-header-height, 56px), var(--shell-visible-top, 0px));
    --activity-editor-height: 100%;
    --activity-editor-flex: 1 1 auto;
    position: fixed !important;
    top: var(--activity-editor-top);
    left: 0;
    width: 100% !important;
    height: calc(var(--shell-visible-height, 100dvh) + var(--shell-visible-top, 0px) - var(--activity-editor-top)) !important;
    min-width: 0;
    min-height: 0;
    margin: 0 !important;
    padding: 0 !important;
    /* Stay below the shell navigation/backdrop and portal menus. */
    z-index: 1000;
    background: var(--mud-palette-surface) !important;
    overflow: hidden;
    border-radius: 0 !important;
    transition: none;
}

/* Modal activity editors keep MudBlazor's stacking above their own backdrop. */
body.is-phone-layout .t-mobile-activity-editor.mud-dialog {
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    z-index: calc(var(--mud-zindex-dialog) + 2);
}

body.is-phone-layout .t-mobile-activity-editor.mud-dialog .mud-dialog-content {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Landscape phones retain the navigation rail beside the editor. */
body.is-landscape-phone :is(.t-mobile-activity-editor, .t-mobile-entity-editor, .t-mobile-workspace-editor) {
    left: var(--workspace-nav-width, var(--nav-width, 54px));
    width: calc(100% - var(--workspace-nav-width, var(--nav-width, 54px))) !important;
}

:is(body.is-phone-layout .t-mobile-activity-editor, .t-scheduler__side-panel.t-activity-editor-compact, .t-testdrive-editor) :is(
    .t-scheduler__side-panel-inner, .t-activity-form-shell,
    .t-activity-editor-size-wrapper, .t-activity-editor-size-content,
    .t-experimental-embedded-appointment-card, .t-entity-card-shell,
    .t-experimental-embedded-appointment-card__details,
    .t-experimental-embedded-appointment-card__details-clip) {
    display: flex;
    flex-direction: column;
    flex: var(--activity-editor-flex, 0 1 auto);
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: var(--activity-editor-height, auto);
    max-height: 100%;
    overflow: hidden;
    border-radius: 0;
    transition: none;
}

body.is-phone-layout .t-mobile-activity-editor .t-entity-card-shell__footer {
    flex: 0 0 auto;
    padding-block: 0 env(safe-area-inset-bottom);
    background: var(--mud-palette-surface);
}

/* Status/record information leads; overflow and primary commands trail. */
.t-entity-card-shell__footer .t-activity-form-footer {
    gap: 8px;
}

.t-entity-card-shell__footer .t-activity-form-footer > .t-bottom-card-content-text {
    flex: 1 1 0;
    min-width: 0;
}

.t-entity-card-shell__footer .t-activity-form-footer > :last-child {
    flex: 0 0 auto;
    align-items: center;
    margin-inline-start: 0 !important;
}

.t-entity-card-shell__footer .t-activity-footer-leading {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
}

.t-activity-footer-leading > :not(.t-entity-card-record-meta) {
    flex: 0 0 auto;
}

.t-activity-footer-leading > .t-entity-card-record-meta {
    flex: 1 1 auto;
}

.t-entity-card-record-meta {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--mud-palette-text-secondary);
    font-size: var(--t-entity-card-footer-font-size, .7rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-entity-card-shell__footer .t-activity-footer-menu {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

@container (max-width: 520px) {
    .t-activity-footer-leading .t-entity-card-record-meta[data-record-state="saved"] {
        display: none;
    }
}

@container (max-width: 480px) {
    .t-activity-footer-leading:has(.mud-checkbox, .t-appointment-completion-control) .t-entity-card-record-meta {
        display: none;
    }
}

/* One control row for activity list cards, tabs and calendar panels. */
body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer) {
    --t-entity-card-footer-inline-padding: 0px;
    --t-entity-card-footer-block-padding: 0px;
    --t-entity-card-footer-min-height: 32px;
    --t-entity-card-footer-button-height: 32px;
    --t-entity-card-footer-button-min-width: 76px;
    --t-entity-card-actions-gap: 4px;
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 8px 16px;
    box-sizing: border-box;
}

body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer) > * {
    flex: 1 1 0;
    min-width: 0;
}

body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer) .t-bottom-card-content {
    width: 100%;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
}

body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer) :is(.t-bottom-card-content, .t-bottom-card-content > :last-child) {
    align-items: center;
    flex-wrap: nowrap;
}

body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer) :is(.t-appointment-embedded-footer-meta, .t-activity-editor-footer-meta) {
    gap: 4px;
}

.t-entity-card-shell__footer .t-activity-form-footer .mud-tooltip-root {
    display: inline-flex;
}

.t-entity-card-shell__footer .t-activity-form-footer .t-appointment-completion-checkbox .mud-checkbox {
    padding: 0;
}

body.is-phone-layout .t-mobile-activity-editor .t-entity-card-shell__footer:has(.t-activity-form-footer) {
    min-height: calc(52px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

body.is-phone-layout .t-mobile-activity-editor .t-activity-editor-notes {
    min-height: 7rem;
}

body.is-phone-layout .t-mobile-activity-editor :is(input, textarea) {
    font-size: 16px !important;
}

body.is-phone-layout .t-mobile-activity-editor .t-entity-card-shell__header * {
    transition-property: transform, opacity;
}

/* An opaque editor covers the calendar, but also remove its controls from
   keyboard navigation while the mobile editor is visible. */
body.is-phone-layout .daybook-viewport:has(.t-mobile-activity-editor) :is(.daybook-header, .daybook-action-bar, .t-scheduler__main) {
    visibility: hidden;
}

.t-appointment-shell-fields > .t-appointment-field-row.t-appointment-narrow-assignee {
    display: none;
}

.t-activity-editor-menu {
    display: none;
}

body.is-phone-layout .t-task-phone-actions { display: inline-flex; }

.t-activity-editor-footer-meta {
    display: flex;
    align-items: center;
    gap: 4px;
}

body.is-phone-layout .t-mobile-activity-editor .t-entity-card-footer-actions {
    width: 100%;
    justify-self: stretch;
}

body.is-phone-layout .t-mobile-activity-editor .t-bottom-card-content {
    width: 100%;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

body.is-phone-layout .t-mobile-activity-editor .t-bottom-card-content > :last-child {
    align-items: center;
    flex: 0 0 auto;
    flex-wrap: nowrap;
}

body.is-phone-layout .t-mobile-activity-editor .t-bottom-card-content-text {
    flex: 1 1 auto;
    min-width: 0;
}

/* Completion and its menu must not add a second footer row on a 320px phone. */
body.is-phone-layout .t-mobile-activity-editor .t-appointment-embedded-footer-meta {
    flex-wrap: nowrap;
}

body.is-phone-layout .t-mobile-activity-editor .t-appointment-completion-control {
    width: auto;
    min-width: 0;
}

body.is-phone-layout .t-mobile-activity-editor .t-activity-editor-menu {
    display: inline-flex;
}

body.is-phone-layout .t-mobile-activity-editor .t-activity-editor-menu .mud-icon-button {
    width: 44px;
    height: 32px;
}

body.is-phone-layout .t-mobile-activity-editor :is(.t-activity-editor-size-wrapper, .t-activity-editor-size-content) {
    flex: 1 0 auto;
    height: auto !important;
    max-height: none;
    overflow: visible !important;
    transition: none !important;
}

/* The pilot also uses this compact content layout in a narrow desktop panel.
   Its viewport placement remains phone-only; wide appointment tabs keep their
   existing heading, assignee and two-column fields. */
@container (max-width: 950px) {
    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-appointment-shell-fields > .t-appointment-field-row.t-appointment-narrow-assignee {
        display: block;
    }

    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-appointment-embedded-footer-meta {
        gap: 4px;
    }

    /* Avoid an inline baseline gap and checkbox padding overflowing its 32px frame. */
    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-appointment-embedded-footer-meta .mud-tooltip-root {
        display: inline-flex;
    }

    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-appointment-completion-control .t-appointment-completion-checkbox .mud-checkbox {
        padding: 0;
    }

    /* Keep compact button geometry, with a 44px hit area inside the footer. */
    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-entity-card-shell__footer button {
        overflow: visible;
    }

    :is(body.is-phone-layout .t-mobile-activity-editor, .t-activity-editor-compact) .t-entity-card-shell__footer button::after {
        content: "";
        position: absolute;
        inset: -6px 0;
        border-radius: inherit;
    }
}

/* Let notes consume spare viewport height, but keep a useful minimum and body
   scrolling when the keyboard or landscape leaves less room than the fields. */
:is(body.is-phone-layout .t-mobile-activity-editor, .t-scheduler__side-panel.t-activity-editor-compact, .t-testdrive-editor) .t-activity-editor-body {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    gap: 16px;
    padding: 0;
}

body.is-phone-layout .t-mobile-activity-editor .t-activity-editor-body > :is(.t-form-input, .t-form-input-label-and-icon) {
    width: 100%;
    min-width: 0;
    margin: 0;
}

:is(body.is-phone-layout .t-mobile-activity-editor, .t-scheduler__side-panel.t-activity-editor-compact, .t-testdrive-editor) .t-activity-editor-notes {
    flex: 1 0 7rem;
    padding-inline: 0;
    border: 0;
}

body.is-phone-layout .t-mobile-activity-editor .t-activity-editor-notes :is(
    .t-mention-wrap, .mud-input-control, .mud-input-control-input-container, .mud-input) {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin: 0;
}

:is(body.is-phone-layout .t-mobile-activity-editor, .t-scheduler__side-panel.t-activity-editor-compact, .t-testdrive-editor) .t-activity-editor-notes .mud-input-filled {
    align-items: stretch;
}

:is(body.is-phone-layout .t-mobile-activity-editor, .t-scheduler__side-panel.t-activity-editor-compact, .t-testdrive-editor) .t-activity-editor-notes textarea.mud-input-slot {
    align-self: stretch;
    height: 100% !important;
}


/* Shared phone surface for contact actions and product facts. */
body.is-phone-layout .t-mobile-entity-editor :is(.t-entity-mobile-actions .mud-button-root, .t-entity-mobile-summary-item) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: var(--t-entity-mobile-surface-height, 44px);
    min-width: var(--t-entity-mobile-control-min-width, 0);
    padding: var(--t-entity-mobile-surface-padding, 6px);
    border: 0;
    border-radius: var(--t-entity-mobile-surface-radius, 8px) !important;
    background: var(--t-entity-mobile-surface-background, var(--mud-palette-action-default-hover));
    color: var(--t-entity-mobile-surface-color, var(--mud-palette-primary));
    box-shadow: none;
    font-size: var(--t-entity-mobile-surface-font-size, 13px);
    font-weight: 500;
    line-height: var(--t-entity-mobile-surface-line-height, 1.75);
    text-transform: none;
}

/* Compact entity footers share 32px buttons with a 44px touch target. */
@media (max-width: 900px), (max-width: 950px) and (max-height: 500px) {
    :is(.t-mobile-activity-editor .t-entity-card-shell__footer, .t-activity-action-bar,
        :where(body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer)),
        :where(body.is-phone-layout) .t-entity-compact-actions) button {
        height: 32px;
        min-height: 32px;
        padding-block: 0;
        overflow: visible;
        position: relative;
    }

    :is(.t-mobile-activity-editor .t-entity-card-shell__footer, .t-activity-action-bar,
        :where(body.is-phone-layout .t-entity-card-shell__footer:has(.t-activity-form-footer)),
        :where(body.is-phone-layout) .t-entity-compact-actions) button::after {
        content: "";
        position: absolute;
        inset: -6px 0;
        border-radius: inherit;
    }

    :is(.t-activity-action-bar, body.is-phone-layout .t-entity-compact-actions) .mud-icon-button {
        width: 44px;
        min-width: 44px;
        padding: 4px;
    }

}


/* Shared entity form frame. Opt in the owning EntityCardShell with MobileEntity
   and mark only its non-layout wrappers as t-entity-mobile-structure. Contact,
   sale and product use this same geometry; their field/summary layouts remain local. */
body.is-phone-layout .t-mobile-entity-editor {
    display: block !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    padding: 0 0 calc(var(--t-entity-footer-height, 80px) + 16px) !important;
    scroll-padding-block: 88px calc(var(--t-entity-footer-height, 80px) + 24px);
    --t-input-text-max-width: none;
    --t-input-standard-text-max-width: none;
}
body.is-phone-layout .t-mobile-entity-editor :is(.t-entity-mobile-structure, .t-entity-mobile-card) { display: contents !important; }
/* Workspace headers reuse the entity header without adopting entity-owned scrolling. */
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-areas: "identity actions";
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    min-height: 60px;
    background: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    --t-entity-card-icon-size: 36px;
    --t-entity-card-action-size: 44px;
    --t-entity-card-action-edge-inset: 0px;
    --t-entity-card-identity-gap: 14px;
    --t-entity-card-title-font-size: 16px;
}
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header :is(.t-entity-card-shell__summary, .t-entity-card-shell__subtitle) { display: none; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .t-entity-card-shell__identity { align-items: center; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .t-entity-card-shell__titles { display: block; width: 100%; max-width: none; height: auto; min-height: 36px; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header :is(.t-entity-card-shell__title, .t-entity-card-title-fields, .t-entity-card-title-field, .t-form-input__readonly) {
    height: auto;
    min-height: 36px;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
    align-items: center;
    font-size: 16px;
}
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .t-form-input__readonly { display: flex; line-height: 1.35 !important; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header input { font-size: 16px; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .t-entity-card-shell__actions { margin: 0; padding: 0; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .mud-icon-button { width: 44px; height: 44px; min-width: 44px; padding: 10px; }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .mud-icon-button:not(.mud-disabled) { color: var(--mud-palette-text-secondary); }
body.is-phone-layout :is(.t-mobile-entity-editor .t-entity-mobile-card, .t-entity-mobile-header) > .t-entity-card-shell__header .mud-icon-button:not(.mud-disabled):hover { color: var(--mud-palette-text-primary); }

/* Product/contact opt in together; sale and other activity headers retain their layout. */
.t-entity-header-metadata { display: none; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card.t-entity-card-shell--compact-identity > .t-entity-card-shell__header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "identity";
    min-height: 80px;
    padding: 12px;
    --t-entity-card-icon-size: 40px;
    --t-entity-card-identity-gap: 12px;
    --t-entity-card-title-editor-inline-padding: 0;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header .t-entity-card-shell__titles {
    flex: 1 1 0;
    min-height: 0;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header .t-entity-card-shell__title {
    width: 100%;
    min-height: 0;
    overflow: visible;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header .t-entity-compact-title {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    height: auto;
    min-height: 0;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header :is(.t-entity-header-name, .t-entity-header-name .t-entity-card-title-field, .t-entity-header-name .t-form-input__readonly) {
    min-height: 24px;
    height: auto;
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: visible;
    line-height: 1.35;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header .t-entity-header-name {
    padding-inline-end: 40px;
    box-sizing: border-box;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-shell--compact-identity > .t-entity-card-shell__header > .t-entity-card-shell__actions {
    position: absolute;
    inset-block-start: 2px;
    inset-inline-end: 4px;
    align-self: start;
    grid-area: auto;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-header-metadata {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    min-height: 24px;
    width: 100%;
    white-space: normal;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-header-chip {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    min-height: 24px;
    padding: 2px 6px;
    border: 1px solid var(--t-header-chip-border, var(--t-chip-neutral-border));
    border-radius: 6px;
    background: var(--t-header-chip-background, var(--t-chip-neutral-background));
    color: var(--t-header-chip-text, var(--t-chip-neutral-text));
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    white-space: normal;
    overflow-wrap: anywhere;
    box-sizing: border-box;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-header-chip--status { margin-inline-start: auto; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-header-chip .mud-icon-root { flex: 0 0 14px; font-size: 14px; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-header-chip > span { min-width: 0; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__navigation,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-activity-card-navigation { padding: 0; overflow: visible; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__navigation::after,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-activity-card-navigation::after { display: none; }
body.is-phone-layout .rw-phone-navigation .t-entity-card-tabs,
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__navigation .t-entity-card-tabs:not(.t-entity-card-tabs--desktop-mobile),
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-activity-card-navigation .t-entity-card-tabs:not(.t-entity-card-tabs--desktop-mobile) {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: 48px;
    gap: 0;
    padding: 0 8px;
    border-block: 1px solid var(--mud-palette-lines-default);
}
/* Tab look: EntityCardTabs.razor.css. Here only the band's placement and size. */
body.is-phone-layout .rw-phone-navigation .t-entity-card-tabs .t-entity-card-tab,
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__navigation .t-entity-card-tabs:not(.t-entity-card-tabs--desktop-mobile) .t-entity-card-tab,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-activity-card-navigation .t-entity-card-tabs:not(.t-entity-card-tabs--desktop-mobile) .t-entity-card-tab {
    width: 100%;
    min-width: 0;
    height: 48px;
    min-height: 48px;
}
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__body,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-sale-section-panel { padding: 6px 16px 10px; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-size-wrapper { height: auto !important; max-height: none !important; overflow: visible !important; transition: none !important; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__footer {
    position: fixed;
    left: 0;
    bottom: max(0px, calc(100dvh - var(--shell-visible-height, 100dvh) - var(--shell-visible-top, 0px)));
    z-index: 4;
    width: 100%;
    padding: 0 0 env(safe-area-inset-bottom);
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
}
body.is-landscape-phone .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__footer { left: var(--workspace-nav-width, var(--nav-width, 54px)); width: calc(100% - var(--workspace-nav-width, var(--nav-width, 54px))); }
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-footer-row,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-entity-card-footer-row { display: flex; flex-wrap: nowrap; gap: 8px; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-footer-meta,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-entity-card-footer-meta { display: block !important; flex: 1; min-width: 0; font-size: .7rem; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-card-footer-actions,
body.is-phone-layout .t-activity-entity-card.t-sale-card .t-entity-card-footer-actions { display: flex; flex: 0 0 auto; width: auto; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-commands { display: flex; align-items: center; gap: 8px; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-commands .mud-icon-button { min-width: 44px; }
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__navigation .t-entity-card-tabs--desktop-mobile { width: 100%; min-width: 0; height: 48px; padding: 0 12px; overflow-x: auto; }
/* ActivityFormShell may wrap a footer which already owns its metadata row. */
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__footer > .t-entity-card-footer-row--full-width-actions,
body.is-phone-layout .t-mobile-entity-editor .t-entity-mobile-card > .t-entity-card-shell__footer > .t-entity-card-footer-row--full-width-actions > .t-entity-card-footer-actions { display: contents; }

/* Shared field surfaces for contact history and inventory groups. */
body.is-phone-layout .t-mobile-entity-editor .t-entity-field-card {
    display: flex;
    flex-direction: column;
    gap: var(--t-entity-field-card-gap, 4px);
    min-width: 0;
    padding: var(--t-entity-field-card-padding, 10px 12px);
    border: var(--t-entity-field-card-border, 1px solid var(--mud-palette-lines-default));
    border-radius: var(--t-entity-field-card-radius, 10px);
    background: var(--t-entity-field-card-background, var(--mud-palette-action-default-hover));
}
}
