/*
 * Modal
 *
 * Shared modal shell and reusable modal layout primitives.
 * Page-specific content should be styled by the consuming component/page.
 */

:is(.modal, .foundation-modal) {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

:is(.modal, .foundation-modal).open {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

:is(.modal-backdrop, .foundation-modal-backdrop) {
    position: absolute;
    inset: 0;
    background: rgba(12, 28, 35, .42);
}

:is(.modal-dialog, .foundation-modal-dialog) {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    max-height: 90vh;
    max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
    overflow: auto;
    background: #fff;
    border: 1px solid #cbd7dc;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(12, 28, 35, .22);
}

:is(.modal-wide, .foundation-modal-wide) {
    width: min(820px, 100%);
}

:is(.modal-header, .foundation-modal-header) {
    padding: 24px 28px 20px;
    border-bottom: 1px solid #dce6e8;
}

:is(.modal-eyebrow, .foundation-modal-eyebrow) {
    margin: 0 0 5px;
    color: var(--app-primary);
    font-family: var(--nav-font);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .1em;
    line-height: 1.2;
    text-transform: uppercase;
}

:is(.modal-title, .foundation-modal-title) {
    margin: 0 42px 5px 0;
    color: #203740;
    font-size: 23px;
    font-weight: 800;
    line-height: 1.2;
}

:is(.modal-title-variable, .foundation-modal-title-variable) {
    color: var(--app-primary);
}

:is(.modal-title, .foundation-modal-title) .foundation-status {
    margin-left: 8px;
    vertical-align: middle;
}

:is(.modal-subheading, .foundation-modal-subheading) {
    margin: 0;
    color: #71858c;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

:is(.modal-close, .foundation-modal-close) {
    position: absolute;
    right: 18px;
    top: 17px;
    z-index: 2;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #536970;
    background: transparent;
    text-decoration: none;
    font-size: 25px;
    line-height: 1;
}

:is(.modal-close, .foundation-modal-close):hover,
:is(.modal-close, .foundation-modal-close):focus-visible {
    color: #17262e;
    background: #eef3f4;
    border-color: #dce6e8;
    text-decoration: none;
}

:is(.modal-body, .foundation-modal-body) {
    padding: 0 28px;
}

:is(.modal-section, .foundation-modal-section) {
    padding: 20px 0;
    border-bottom: 1px solid #dce6e8;
}

:is(.modal-section, .foundation-modal-section):first-child {
    padding-top: 20px;
}

:is(.modal-section, .foundation-modal-section):last-child {
    border-bottom: 0;
}

:is(.modal-section-header, .foundation-modal-section-header) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 14px;
    padding: 8px 11px;
    border: 1px solid color-mix(in srgb, var(--app-primary) 10%, #fff);
    border-radius: 10px;
    background: color-mix(in srgb, var(--app-primary) 10%, #fff);
}

:is(.modal-section-header, .foundation-modal-section-header) h3 {
    margin: 0;
    color: #203740;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

:is(.modal-section-header, .foundation-modal-section-header) p {
    margin: 3px 0 0;
    color: #71858c;
    font-size: 12px;
    line-height: 1.4;
}

:is(.modal-detail-list, .foundation-modal-detail-list) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
}

:is(.modal-detail-item, .foundation-modal-detail-item) {
    min-width: 0;
    padding: 12px 14px;
    background: #fff;
}

:is(.modal-detail-item, .foundation-modal-detail-item) small {
    display: block;
    margin-bottom: 4px;
    color: var(--app-accent-ink, var(--app-accent));
    font-family: var(--nav-font);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}

:is(.modal-detail-item, .foundation-modal-detail-item) strong {
    display: block;
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

:is(.modal-detail-item, .foundation-modal-detail-item) a {
    color: var(--app-primary);
    text-decoration: none;
}

:is(.modal-detail-item, .foundation-modal-detail-item) a:hover {
    color: var(--app-accent);
}


:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 4px;
}

:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button {
    background: color-mix(in srgb, var(--app-primary) 12%, #fff);
    border-color: color-mix(in srgb, var(--app-primary) 35%, #fff);
    color: color-mix(in srgb, var(--app-primary) 82%, #17262e);
    padding: 7px 11px;
    font-size: 12px;
    line-height: 1.2;
}

:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button:hover,
:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button:focus-visible {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: var(--app-primary-text, #fff);
}

:is(.modal-intro, .foundation-modal-intro) {
    margin: 8px 0 22px;
    color: #71858c;
    font-size: 13px;
    line-height: 1.45;
}

:is(.modal-action-row, .foundation-modal-action-row) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding: 14px 28px;
    border-bottom: 1px solid #dce6e8;
    background: #fbfcfc;
}

:is(.modal-action-row, .foundation-modal-action-row) .secondary-button {
    background: color-mix(in srgb, var(--app-primary) 12%, #fff);
    border-color: color-mix(in srgb, var(--app-primary) 35%, #fff);
    color: color-mix(in srgb, var(--app-primary) 82%, #17262e);
    padding: 7px 11px;
    font-size: 12px;
    line-height: 1.2;
}

:is(.modal-action-row, .foundation-modal-action-row) .secondary-button:hover,
:is(.modal-action-row, .foundation-modal-action-row) .secondary-button:focus-visible {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: var(--app-primary-text, #fff);
}

:is(.modal-dependent-list, .foundation-modal-dependent-list) {
    border-top: 1px solid #dce6e8;
}

:is(.modal-dependent-item, .foundation-modal-dependent-item) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 2px;
    border-bottom: 1px solid #dce6e8;
}

:is(.modal-dependent-item, .foundation-modal-dependent-item):last-child {
    border-bottom: 0;
}

:is(.modal-dependent-item, .foundation-modal-dependent-item) strong {
    display: block;
    color: #304b55;
    font-size: 13px;
    line-height: 1.35;
}

:is(.modal-dependent-item, .foundation-modal-dependent-item) small {
    display: block;
    margin-top: 3px;
    color: #87979d;
    font-family: var(--nav-font);
    font-size: 11px;
    line-height: 1.35;
}

:is(.modal-empty, .foundation-modal-empty) {
    padding: 13px 2px;
    color: #71858c;
    font-size: 13px;
}

:is(.modal-footer, .foundation-modal-footer) {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 28px;
    border-top: 1px solid #dce6e8;
    background: #fbfcfc;
}

:is(.modal-footer, .foundation-modal-footer) .primary-button,
:is(.modal-footer, .foundation-modal-footer) .secondary-button {
    margin: 0;
}

/* Existing lifecycle controls can use the shared modal action treatment. */
:is(.modal-lifecycle-actions, .foundation-modal-lifecycle-actions) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid #dce6e8;
}

:is(.modal-lifecycle-actions, .foundation-modal-lifecycle-actions) .small-action-button {
    margin-left: 0;
}

:is(.modal-lifecycle-top, .foundation-modal-lifecycle-top) {
    margin: 0;
    padding: 14px 28px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid #dce6e8;
    background: #fbfcfc;
}

:is(.modal-lifecycle-button, .foundation-modal-lifecycle-button) {
    font-size: 13px;
    padding: 7px 11px;
}

@media (max-width: 700px) {
    :is(.modal, .foundation-modal) {
        padding: 8px;
        align-items: flex-end;
    }

    :is(.modal-dialog, .foundation-modal-dialog),
    :is(.modal-wide, .foundation-modal-wide) {
        width: 100%;
        max-height: 90vh;
        max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
        border-radius: 14px 14px 0 0;
    }

    :is(.modal-header, .foundation-modal-header) {
        padding: 20px 18px 17px;
    }

    :is(.modal-close, .foundation-modal-close) {
        right: 12px;
        top: 12px;
    }

    :is(.modal-title, .foundation-modal-title) {
        margin-right: 38px;
        font-size: 21px;
    }

    :is(.modal-body, .foundation-modal-body) {
        padding: 0 18px;
    }

    
:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 4px;
}

:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button {
    background: color-mix(in srgb, var(--app-primary) 12%, #fff);
    border-color: color-mix(in srgb, var(--app-primary) 35%, #fff);
    color: color-mix(in srgb, var(--app-primary) 82%, #17262e);
    padding: 7px 11px;
    font-size: 12px;
    line-height: 1.2;
}

:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button:hover,
:is(.modal-predecessor-actions, .foundation-modal-predecessor-actions) .secondary-button:focus-visible {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: var(--app-primary-text, #fff);
}

:is(.modal-intro, .foundation-modal-intro) {
    margin: 8px 0 22px;
    color: #71858c;
    font-size: 13px;
    line-height: 1.45;
}

:is(.modal-action-row, .foundation-modal-action-row) {
        padding: 12px 18px;
    }

    :is(.modal-footer, .foundation-modal-footer) {
        padding: 13px 18px;
    }

    :is(.modal-detail-list, .foundation-modal-detail-list) {
        grid-template-columns: 1fr;
    }

    :is(.modal-section, .foundation-modal-section) {
        padding: 17px 0;
    }

    :is(.modal-lifecycle-top, .foundation-modal-lifecycle-top) {
        padding: 12px 18px 14px;
    }
}

/* Related record details use the shared modal detail treatment. */
:is(.modal-record-list, .foundation-modal-record-list) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

:is(.modal-record-list, .foundation-modal-record-list) :is(.modal-detail-item, .foundation-modal-detail-item) {
    min-height: 78px;
}

:is(.modal-detail-meta, .foundation-modal-detail-meta) {
    display: block;
    margin-top: 5px;
    color: #71858c;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
}

:is(.modal-detail-meta, .foundation-modal-detail-meta) .foundation-status {
    margin-left: 7px;
    vertical-align: middle;
}

:is(.modal-action-row, .foundation-modal-action-row) .accent-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 12px;
    border: 1px solid var(--app-accent);
    border-radius: 8px;
    background: var(--app-accent);
    color: #fff;
    font-family: var(--nav-font);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    min-height: 40px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
}

:is(.modal-action-row, .foundation-modal-action-row) .accent-button:hover,
:is(.modal-action-row, .foundation-modal-action-row) .accent-button:focus-visible {
    background: color-mix(in srgb, var(--app-accent) 82%, #000);
    border-color: color-mix(in srgb, var(--app-accent) 82%, #000);
    color: #fff;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu) {
    position: relative;
    margin-right: auto;
}

:is(.modal-manage-row, .foundation-modal-manage-row) .inline-form {
    margin-left: auto;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu) summary {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border: 1px solid #cbd7dc;
    border-radius: 8px;
    background: #fff;
    color: #304b55;
    font-family: var(--nav-font);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    min-height: 40px;
    cursor: pointer;
    list-style: none;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu) summary::-webkit-details-marker {
    display: none;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu) summary:hover,
:is(.modal-manage-menu, .foundation-modal-manage-menu) summary:focus-visible {
    background: #f4f8fa;
    border-color: #aebfc5;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu) summary i:last-child {
    margin-left: 2px;
    font-size: 10px;
}

:is(.modal-manage-menu, .foundation-modal-manage-menu)[open] summary i:last-child {
    transform: rotate(180deg);
}

:is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 10;
    min-width: 190px;
    padding: 5px;
    border: 1px solid #cbd7dc;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(12, 28, 35, .16);
}

:is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) a {
    display: block;
    padding: 11px 12px;
    border-radius: 6px;
    color: #304b55;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    text-decoration: none;
    white-space: nowrap;
}

:is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) a:hover,
:is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) a:focus-visible {
    background: #f0f5f6;
    color: var(--app-primary);
}

@media (max-width: 700px) {
    :is(.modal-record-list, .foundation-modal-record-list) {
        grid-template-columns: 1fr;
    }

    :is(.modal-action-row, .foundation-modal-action-row) {
        align-items: stretch;
        justify-content: stretch;
    }

    :is(.modal-action-row, .foundation-modal-action-row) .secondary-button,
    :is(.modal-action-row, .foundation-modal-action-row) .accent-button,
    :is(.modal-action-row, .foundation-modal-action-row) .inline-form,
    :is(.modal-manage-menu, .foundation-modal-manage-menu) {
        width: calc((100% - 8px) / 2);
    }

    :is(.modal-action-row, .foundation-modal-action-row) .inline-form {
        display: block;
        margin-left: 0;
    }

    :is(.modal-action-row, .foundation-modal-action-row) .inline-form .accent-button {
        width: 100%;
    }

    :is(.modal-manage-menu, .foundation-modal-manage-menu) {
        margin-right: 0;
    }

    :is(.modal-manage-menu, .foundation-modal-manage-menu) summary {
        width: 100%;
        justify-content: center;
    }

    :is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) {
        left: 0;
        right: 0;
        min-width: 0;
    }

    :is(.modal-manage-menu-list, .foundation-modal-manage-menu-list) a {
        white-space: normal;
    }
}

/* Scrollable modal variant used for long-form content. */
:is(.modal-dialog--fixed, .foundation-modal-view-user) {
    width: min(600px, 100%);
    height: min(760px, 90vh);
    height: min(760px, 90dvh); /* 1.21.0: visible height on tablets/phones */
    max-height: 90vh;
    max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

:is(.modal-dialog--fixed, .foundation-modal-view-user) > :is(.modal-header, .foundation-modal-header),
:is(.modal-dialog--fixed, .foundation-modal-view-user) > :is(.modal-action-row, .foundation-modal-action-row),
:is(.modal-dialog--fixed, .foundation-modal-view-user) > :is(.modal-footer, .foundation-modal-footer) {
    flex: 0 0 auto;
}

:is(.modal-body--scroll, .foundation-modal-view-user-body) {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 22px;
}

:is(.modal-manage-row, .foundation-modal-manage-row) {
    padding: 12px 22px;
}

:is(.modal-identity, .foundation-modal-identity) {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 18px 0 8px;
    padding: 18px 20px;
    border-radius: 9px;
    background: #f4f8fa;
}

:is(.modal-avatar, .foundation-modal-avatar) {
    flex: 0 0 84px;
    width: 84px;
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e5edf1;
    color: #526b75;
    font-family: var(--nav-font);
    font-size: 25px;
    font-weight: 800;
}

:is(.modal-identity-details, .foundation-modal-identity-details) {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #304b55;
    font-size: 13px;
}

:is(.modal-identity-name-row, .foundation-modal-identity-name-row) {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

:is(.modal-identity-name-row, .foundation-modal-identity-name-row) strong {
    color: #203740;
    font-size: 20px;
    font-weight: 800;
    line-height: 1.25;
}

:is(.modal-highlight-field, .foundation-modal-identity-company) {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 2px 10px 1px 10px;
    border: 1px solid #b9dce9;
    border-radius: 999px;
    background: #dff1f7;
    color: #2f6475;
    font-family: var(--nav-font);
    font-size: 13px;
    font-weight: 800;
    line-height: 2;
}

:is(.modal-identity-email, .foundation-modal-identity-email) {
    color: #304b55;
    overflow-wrap: anywhere; /* 1.25.0: long addresses stay inside on phones */
}

:is(.modal-identity-details, .foundation-modal-identity-details) small {
    color: #71858c;
    font-size: 12px;
}

:is(.modal-section, .foundation-modal-view-section) {
    padding: 18px 0;
}

:is(.modal-section, .foundation-modal-view-section) :is(.modal-section-header, .foundation-modal-section-header) {
    margin-bottom: 10px;
}

:is(.modal-section, .foundation-modal-view-section) :is(.modal-section-header, .foundation-modal-section-header) h3 {
    font-size: 16px;
}

:is(.modal-detail-list, .foundation-modal-view-details) {
    display: grid;
    grid-template-columns: minmax(130px, .72fr) minmax(0, 1.28fr);
    row-gap: 11px;
    column-gap: 18px;
    padding: 0 16px;
}

:is(.modal-detail-list, .foundation-modal-view-details) > div {
    display: contents;
}

:is(.modal-detail-list, .foundation-modal-view-details) span:first-child {
    color: #71858c;
    font-size: 13px;
    line-height: 1.45;
}

:is(.modal-detail-list, .foundation-modal-view-details) strong {
    min-width: 0;
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

:is(.modal-detail-list, .foundation-modal-view-details) strong small {
    display: block;
    margin-top: 3px;
    color: #87979d;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
}

:is(.modal-detail-list, .foundation-modal-view-details) strong small .foundation-status {
    display: inline-flex;
    margin-left: 6px;
    vertical-align: middle;
}

:is(.modal-detail-list--single, .foundation-modal-view-details-single) {
    grid-template-columns: minmax(130px, .72fr) minmax(0, 1.28fr);
}

:is(.modal-footer-left, .foundation-modal-footer-left) {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
}

@media (max-width: 700px) {
    :is(.modal-dialog--fixed, .foundation-modal-view-user) {
        height: 90vh;
        height: 90dvh; /* 1.21.0: visible height on tablets/phones */
        max-height: 90vh;
        max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
    }

    :is(.modal-body--scroll, .foundation-modal-view-user-body) {
        padding: 0 18px;
    }

    :is(.modal-manage-row, .foundation-modal-manage-row) {
        padding: 12px 18px;
    }

    :is(.modal-identity, .foundation-modal-identity) {
        margin-top: 14px;
        padding: 15px;
        gap: 13px;
    }

    :is(.modal-avatar, .foundation-modal-avatar) {
        flex-basis: 68px;
        width: 68px;
        height: 68px;
        font-size: 21px;
    }

    :is(.modal-identity-name-row, .foundation-modal-identity-name-row) strong {
        font-size: 17px;
    }

    :is(.modal-detail-list, .foundation-modal-view-details),
    :is(.modal-detail-list--single, .foundation-modal-view-details-single) {
        grid-template-columns: 1fr;
        row-gap: 3px;
        padding: 0 5px;
    }

    :is(.modal-detail-list, .foundation-modal-view-details) > div {
        display: grid;
        grid-template-columns: minmax(105px, .72fr) minmax(0, 1.28fr);
        gap: 12px;
        padding: 7px 0;
        border-bottom: 1px solid #edf1f2;
    }

    :is(.modal-detail-list, .foundation-modal-view-details) > div:last-child {
        border-bottom: 0;
    }

    :is(.modal-footer-left, .foundation-modal-footer-left) {
        margin-right: 0;
    }
}


/* Legacy foundation-modal class names remain supported while existing pages are migrated. */


/*
 * Multi-section modal navigation.
 *
 * Three or more sections should use the shared section navigation. The
 * navigation remains vertical on desktop and becomes a horizontal,
 * scrollable tab row on narrow screens.
 */
.modal-section-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px;
    border-right: 1px solid #dce6e8;
    background: #f4f8fa;
}

.modal-section-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #304b55;
    font-family: var(--nav-font);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
}

.modal-section-nav-item i {
    width: 18px;
    color: #526b75;
    text-align: center;
    flex: 0 0 18px;
}

.modal-section-nav-item:hover,
.modal-section-nav-item:focus-visible {
    background: #eaf1f4;
    color: #173b49;
    outline: none;
}

.modal-section-nav-item.is-active {
    background: color-mix(in srgb, var(--app-primary) 12%, #fff);
    color: var(--app-primary-ink, var(--app-primary));
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--app-primary);
}

.modal-section-nav-item.is-active i {
    color: var(--app-primary-ink, var(--app-primary));
}

.modal-section-nav-item:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary) 25%, transparent);
}

.modal-edit-action-row {
    min-height: 64px;
}

.modal-edit-layout {
    display: grid;
    grid-template-columns: 154px minmax(0, 1fr);
    min-height: 420px;
}

.modal-edit-content {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    max-height: 54vh;
    max-height: 54dvh; /* 1.21.0: visible height on tablets/phones */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-edit-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Any shared modal using the edit/section layout gets the same fixed-height
   shell as Edit User. Only its content region is allowed to scroll. */
.modal-dialog:has(.modal-edit-layout) {
    width: min(820px, 100%);
    height: min(760px, 90vh);
    height: min(760px, 90dvh); /* 1.21.0: visible height on tablets/phones */
    max-height: 90vh;
    max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog:has(.modal-edit-layout) > .modal-header {
    flex: 0 0 auto;
}

.modal-dialog:has(.modal-edit-layout) > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-dialog:has(.modal-edit-layout) .modal-edit-layout {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-dialog:has(.modal-edit-layout) .modal-edit-content {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-dialog:has(.modal-edit-layout) .modal-edit-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.modal-dialog:has(.modal-edit-layout) .modal-footer {
    flex: 0 0 auto;
}

.modal-edit-content > .user-ajax-errors {
    margin: 16px 24px 0;
}

.modal-edit-section {
    padding: 18px 24px 24px;
    border-bottom: 0;
}

.modal-edit-section .modal-section-header {
    margin-bottom: 18px;
    padding: 0 0 13px;
    border: 0;
    border-bottom: 1px solid #dce6e8;
    border-radius: 0;
    background: transparent;
}

.modal-edit-section .modal-section-header h3 {
    font-size: 17px;
}

.modal-edit-section .modal-section-header p {
    margin-top: 4px;
}

/* Edit forms use the same two-column label/value alignment as view modals. */
.modal-edit-field-list {
    display: grid;
    grid-template-columns: minmax(130px, .72fr) minmax(0, 1.28fr);
    row-gap: 0;
    column-gap: 18px;
}

.modal-edit-field-list > div {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: center;
    min-height: 58px;
    padding: 9px 16px;
    border-bottom: 1px solid #edf1f2;
}

.modal-edit-field-list > div:last-child {
    border-bottom: 0;
}

.modal-edit-field-list label,
.modal-edit-field-list > div > span:first-child {
    color: #71858c;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
}

.modal-edit-field-list input,
.modal-edit-field-list select,
.modal-edit-field-list textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd7dc;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #304b55;
    font: inherit;
}

.modal-edit-field-list textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.45;
}

.modal-edit-field-list input:focus,
.modal-edit-field-list select:focus,
.modal-edit-field-list textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--app-primary) 25%, transparent);
    border-color: var(--app-primary);
}

.modal-edit-field-list strong {
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.modal-edit-field-list small {
    display: block;
    margin-top: 5px;
    color: #87979d;
    font-size: 11px;
    line-height: 1.4;
}

/*
 * Shared modal content field list.
 *
 * The component is intentionally shell-neutral in markup. Its presentation
 * is selected by whether the containing modal has section navigation.
 * Navigation modals use the established form-field presentation; standard
 * modals use the established detail-field presentation.
 */
.modal-fields {
    display: grid;
    grid-template-columns: minmax(130px, .72fr) minmax(0, 1.28fr);
    row-gap: 0;
    column-gap: 18px;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields > div {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: center;
    min-height: 58px;
    padding: 9px 16px;
    border-bottom: 1px solid #edf1f2;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields > div:last-child {
    border-bottom: 0;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields label,
:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields > div > span:first-child {
    color: #71858c;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields input,
:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields select,
:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd7dc;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #304b55;
    font: inherit;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.45;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields input:focus,
:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields select:focus,
:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--app-primary) 25%, transparent);
    border-color: var(--app-primary);
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields strong {
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

:is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields small {
    display: block;
    margin-top: 5px;
    color: #87979d;
    font-size: 11px;
    line-height: 1.4;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields {
    row-gap: 11px;
    padding: 0 16px;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields > div {
    display: contents;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields label,
:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields > div > span:first-child {
    color: #71858c;
    font-size: 13px;
    line-height: 1.45;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields input,
:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields select,
:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd7dc;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #304b55;
    font: inherit;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.45;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields strong {
    min-width: 0;
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}


.modal-edit-option-list {
    display: block;
}

.modal-edit-option-item {
    display: block;
    min-height: 58px;
    padding: 9px 16px;
    border-bottom: 1px solid #edf1f2;
}

.modal-edit-option-item:last-child {
    border-bottom: 0;
}

.modal-edit-option-item > label {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    cursor: pointer;
}

.modal-edit-option-item > label > input {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 21px;
    width: 21px;
    height: 21px;
    margin: 0;
    border: 2px solid #9aabb1;
    border-radius: 5px;
    background: #fff;
    position: relative;
    cursor: pointer;
}

.modal-edit-option-item > label > input:checked {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.modal-edit-option-item > label > input:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.modal-edit-option-item > label > input:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--app-primary) 25%, transparent);
    outline-offset: 2px;
}

.modal-edit-option-item > label > span {
    min-width: 0;
}

.modal-edit-option-item strong {
    display: block;
    color: #304b55;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.modal-edit-option-item small {
    display: block;
    margin-top: 3px;
    color: #87979d;
    font-size: 11px;
    line-height: 1.4;
}

.modal-detail-list-spacer {
    display: block;
}


.modal-edit-footer {
    justify-content: space-between;
    min-height: 68px;
}

.modal-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.modal-actions-menu {
    margin-right: 0;
}

.modal-action-menu-button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #304b55;
    font: 600 14px/1.35 var(--nav-font);
    text-align: left;
    cursor: pointer;
}

.modal-action-menu-button:hover,
.modal-action-menu-button:focus-visible {
    background: #f0f5f6;
    color: var(--app-primary);
    outline: none;
}

.modal-action-menu-button--danger {
    color: #b52e2e;
}

.modal-action-menu-button--danger:hover,
.modal-action-menu-button--danger:focus-visible {
    background: #fff0f0;
    color: #b52e2e;
}

.modal-action-menu .modal-manage-menu-list {
    min-width: 170px;
}

.modal-edit-section[hidden] {
    display: none !important;
}

@media (max-width: 700px) {
    .modal-edit-layout {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .modal-section-nav {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 2px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 5px 10px;
        border-right: 0;
        border-bottom: 1px solid #dce6e8;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .modal-section-nav::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    .modal-section-nav-item {
        flex: 0 0 auto;
        width: auto;
        min-width: max-content;
        min-height: 38px;
        height: 38px;
        padding: 7px 11px;
        text-align: center;
        justify-content: center;
    }

    .modal-section-nav-item.is-active {
        box-shadow: inset 0 -3px 0 var(--app-primary);
    }

    .modal-edit-content {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-y: scroll;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .modal-edit-content::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    .modal-edit-section {
        padding: 16px 18px 20px;
    }

    :is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields {
        grid-template-columns: minmax(105px, .72fr) minmax(0, 1.28fr);
        column-gap: 12px;
    }

    :is(.modal-dialog, .foundation-modal-dialog):has(.modal-section-nav) .modal-fields > div {
        padding: 8px 5px;
    }

    .modal-edit-field-list {
        grid-template-columns: minmax(105px, .72fr) minmax(0, 1.28fr);
        column-gap: 12px;
    }

    .modal-edit-field-list > div,
    .modal-edit-option-item {
        padding: 8px 5px;
    }

    .modal-edit-footer {
        align-items: center;
        padding: 13px 18px;
    }

    .modal-footer-actions {
        gap: 8px;
    }

    .modal-footer-actions .secondary-button,
    .modal-footer-actions .primary-button {
        padding: 9px 12px;
        font-size: 13px;
    }
}


/*
 * Edit user fixed-height layout.
 *
 * The dialog keeps a stable maximum height regardless of which section is
 * active. Only the section content scrolls; header, action row, navigation
 * and footer remain fixed.
 */
.modal-dialog.foundation-modal-edit-user {
    width: min(820px, 100%);
    height: min(760px, 90vh);
    height: min(760px, 90dvh); /* 1.21.0: visible height on tablets/phones */
    max-height: 90vh;
    max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-dialog.foundation-modal-edit-user > .modal-header {
    flex: 0 0 auto;
}

.modal-dialog.foundation-modal-edit-user > .foundation-user-edit-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-action-row {
    flex: 0 0 auto;
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 18px;
    justify-content: initial;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-context {
    min-width: 0;
    margin-right: 0;
    display: grid;
    grid-template-columns: minmax(0, max-content) max-content;
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    color: #304b55;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-context > strong {
    min-width: 0;
    color: #203740;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-context .foundation-status {
    justify-self: start;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-context-company {
    grid-column: 1 / -1;
    color: #71858c;
    font-size: 12px;
    line-height: 1.35;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-layout {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-content {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: scroll;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.modal-dialog.foundation-modal-edit-user .modal-section-nav {
    flex: 0 0 45px;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.modal-dialog.foundation-modal-edit-user .modal-section-nav::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.modal-dialog.foundation-modal-edit-user .modal-edit-footer {
    flex: 0 0 auto;
}

/* The action menu must not participate in the modal's layout width. */
.modal-dialog.foundation-modal-edit-user .modal-actions-menu {
    position: relative;
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: 0;
}

.modal-dialog.foundation-modal-edit-user .modal-actions-menu summary {
    border-color: var(--app-accent);
    background: var(--app-accent);
    color: #fff;
}

.modal-dialog.foundation-modal-edit-user .modal-actions-menu summary:hover,
.modal-dialog.foundation-modal-edit-user .modal-actions-menu summary:focus-visible {
    border-color: color-mix(in srgb, var(--app-accent) 82%, #000);
    background: color-mix(in srgb, var(--app-accent) 82%, #000);
    color: #fff;
}

.modal-dialog.foundation-modal-edit-user .modal-actions-menu .modal-manage-menu-list {
    left: auto;
    right: 0;
    z-index: 100;
    min-width: 170px;
    max-width: min(220px, calc(100vw - 32px));
}

/* View User role/location lists are read-only rows with no repeated field
   labels and no artificial left-hand spacer column. */
.modal-detail-list--view-list {
    display: block;
    padding: 0 16px;
}

.modal-detail-list--view-list > div {
    display: block;
    min-width: 0;
    padding: 10px 0;
    border-bottom: 1px solid #edf1f2;
}

.modal-detail-list--view-list > div:last-child {
    border-bottom: 0;
}

.modal-detail-list--view-list strong {
    display: block;
    min-width: 0;
}

.modal-detail-list--view-list strong small {
    display: block;
}

/* Keep the action menu inside the modal width on narrow screens while
   retaining right alignment. */
@media (max-width: 700px) {
    .modal-dialog.foundation-modal-edit-user {
        width: 100%;
        height: 90vh;
        height: 90dvh; /* 1.21.0: visible height on tablets/phones */
        max-height: 90vh;
        max-height: 90dvh; /* 1.21.0: visible height on tablets/phones */
        border-radius: 14px 14px 0 0;
    }

    .modal-dialog.foundation-modal-edit-user .modal-edit-action-row {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        column-gap: 10px;
    }

    .modal-dialog.foundation-modal-edit-user .modal-edit-context {
        min-width: 0;
        grid-template-columns: max-content max-content;
        column-gap: 8px;
        row-gap: 2px;
    }

    .modal-dialog.foundation-modal-edit-user .modal-edit-context > strong {
        font-size: 13px;
    }

    .modal-dialog.foundation-modal-edit-user .modal-edit-context-company {
        font-size: 11px;
    }

    .modal-dialog.foundation-modal-edit-user .modal-actions-menu {
        width: auto;
        margin-left: 0;
    }

    .modal-dialog.foundation-modal-edit-user .modal-actions-menu summary {
        width: auto;
        min-width: 0;
        justify-content: center;
    }

    .modal-dialog.foundation-modal-edit-user .modal-actions-menu .modal-manage-menu-list {
        right: 0;
        left: auto;
        width: max-content;
        max-width: calc(100vw - 36px);
    }

    .modal-detail-list--view-list {
        padding: 0 5px;
    }

    .modal-detail-list--view-list > div {
        padding: 8px 0;
    }
}

/* Shared modal form presentation for simple one-section forms. */
:is(.modal-form-grid, .foundation-modal-form-grid) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    padding: 28px 0;
}

:is(.modal-form-grid, .foundation-modal-form-grid) > .full {
    grid-column: 1 / -1;
}

:is(.modal-form-grid, .foundation-modal-form-grid) label {
    display: block;
    margin: 0 0 7px;
    color: #71858c;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

:is(.modal-form-grid, .foundation-modal-form-grid) input,
:is(.modal-form-grid, .foundation-modal-form-grid) select,
:is(.modal-form-grid, .foundation-modal-form-grid) textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd7dc;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: #304b55;
    font: inherit;
}

:is(.modal-form-grid, .foundation-modal-form-grid) input,
:is(.modal-form-grid, .foundation-modal-form-grid) select {
    min-height: 42px;
}

:is(.modal-form-grid, .foundation-modal-form-grid) textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.45;
}

:is(.modal-form-grid, .foundation-modal-form-grid) input:focus,
:is(.modal-form-grid, .foundation-modal-form-grid) select:focus,
:is(.modal-form-grid, .foundation-modal-form-grid) textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--app-primary) 25%, transparent);
    border-color: var(--app-primary);
}

@media (max-width: 700px) {
    :is(.modal-form-grid, .foundation-modal-form-grid) {
        grid-template-columns: 1fr;
    }

    :is(.modal-form-grid, .foundation-modal-form-grid) > .full {
        grid-column: auto;
    }
}


/* Stacked field presentation for forms where wide selection controls benefit
   from the label and supporting text sitting above the control. */
.modal-edit-field-list--stacked {
    display: block;
}

.modal-edit-field-list--stacked > div {
    display: block;
    min-height: 0;
    padding: 10px 12px 14px;
}

.modal-edit-field-list--stacked label {
    display: block;
    margin-bottom: 3px;
}

.modal-edit-field-list--stacked small {
    margin: 0 0 8px;
}

.modal-edit-field-list--stacked .foundation-multi-select {
    margin-top: 2px;
}

/* ==========================================================================
   Shared modal (RenderModal)
   ========================================================================== */

/* Errors returned for a modal form are shown inside the modal. */
.modal-errors {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid #e8b8b8;
    border-radius: 6px;
    background: #fff0f0;
    color: #9b2c2c;
    font-size: 13px;
    line-height: 1.45;
}

.modal-errors[hidden] {
    display: none;
}

.modal-errors ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

.modal-errors li {
    margin: 3px 0;
}

.modal-errors-field {
    font-weight: 700;
}

.modal-edit-content > .modal-errors {
    margin: 16px 24px 0;
}

.modal-body--scroll > .modal-errors {
    margin: 16px 0 0;
}

/* A form inside the fixed (no section navigation) dialog: keep the header and
   footer pinned and let only the body scroll, as the navigation layout does. */
.modal-dialog--fixed > form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal-dialog--fixed > form > :is(.modal-action-row, .modal-footer) {
    flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   Field rows
   Every row is its own subgrid: the label sits in column 1 and everything else
   in column 2 of the same row. An extra element dropped into a row (password
   manager and autofill extensions add one next to name-like fields) can then
   no longer push the rows after it out of alignment.
   -------------------------------------------------------------------------- */
:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields > div {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: center;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields > div > * {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields > div > :is(label, span:first-of-type) {
    grid-column: 1;
}

/* Multi-line controls: align the label with the first line of the control.
   The prefix matches the centring rules above so this wins in both layouts. */
:is(.modal-dialog, .foundation-modal-dialog):is(:has(.modal-section-nav), :not(:has(.modal-section-nav))) .modal-fields > div:has(> textarea) {
    align-items: start;
}

:is(.modal-dialog, .foundation-modal-dialog):is(:has(.modal-section-nav), :not(:has(.modal-section-nav))) .modal-fields > div:has(> textarea) > label {
    padding-top: 11px;
}

/* --------------------------------------------------------------------------
   Shared edit modal action row (matches Edit User)
   Summary on the left, accent Actions button on the right.
   -------------------------------------------------------------------------- */
.modal--edit .modal-edit-action-row {
    flex: 0 0 auto;
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 18px;
    justify-content: initial;
}

/* Without section navigation the body is inset 22px; keep the row in line. */
.modal--edit .modal-dialog:not(:has(.modal-section-nav)) .modal-edit-action-row {
    padding: 12px 22px;
}

.modal--edit .modal-edit-context {
    min-width: 0;
    margin-right: 0;
    display: grid;
    grid-template-columns: minmax(0, max-content) max-content;
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    color: #304b55;
}

.modal--edit .modal-edit-context > strong {
    min-width: 0;
    color: #203740;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.modal--edit .modal-edit-context .foundation-status {
    justify-self: start;
}

.modal--edit .modal-edit-context-company {
    grid-column: 1 / -1;
    color: #71858c;
    font-size: 12px;
    line-height: 1.35;
}

.modal--edit .modal-actions-menu {
    position: relative;
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: 0;
}

.modal--edit .modal-actions-menu summary {
    border-color: var(--app-accent);
    background: var(--app-accent);
    color: #fff;
}

.modal--edit .modal-actions-menu summary:hover,
.modal--edit .modal-actions-menu summary:focus-visible {
    border-color: color-mix(in srgb, var(--app-accent) 82%, #000);
    background: color-mix(in srgb, var(--app-accent) 82%, #000);
    color: #fff;
}

.modal--edit .modal-actions-menu .modal-manage-menu-list {
    left: auto;
    right: 0;
    z-index: 100;
    min-width: 170px;
    max-width: min(220px, calc(100vw - 32px));
}

/* --------------------------------------------------------------------------
   Record lists with a trailing badge, and switch groups
   -------------------------------------------------------------------------- */
.modal-detail-list--view-list > div.modal-record--badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-detail-list--view-list > div.modal-record--child {
    padding-left: 18px;
}

.modal-toggle-groups {
    display: grid;
    gap: 12px;
}

.modal-toggle-group {
    border: 1px solid #dfe6e8;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.modal-toggle-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 15px;
    background: #f4f7f8;
}

.modal-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 15px 11px 28px;
    border-top: 1px solid #e5ecee;
}

.modal-toggle-group-head strong,
.modal-toggle-row strong {
    display: block;
    color: #173b49;
    font-size: 14px;
}

.modal-toggle-group-head small,
.modal-toggle-row small {
    display: block;
    margin-top: 3px;
    color: #71858c;
    font-size: 11px;
    line-height: 1.4;
}

.modal-toggle-group .switch {
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   Stacked fields: label and help above a full-width control (multi-selects)
   -------------------------------------------------------------------------- */
:is(.modal-dialog, .foundation-modal-dialog) .modal-fields.modal-fields--stacked {
    display: block;
    padding: 0;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields.modal-fields--stacked > div {
    display: block;
    min-height: 0;
    padding: 10px 12px 14px;
    border-bottom: 0;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields.modal-fields--stacked label {
    display: block;
    margin-bottom: 3px;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields.modal-fields--stacked small {
    margin: 0 0 8px;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields.modal-fields--stacked .foundation-multi-select {
    margin-top: 2px;
}

/* --------------------------------------------------------------------------
   The text-input styling for .modal-fields must not reach checkboxes, radios
   or the controls inside the shared multi-select, or they stretch to fill
   their row and squeeze the label out.
   -------------------------------------------------------------------------- */
:is(.modal-dialog, .foundation-modal-dialog) .modal-fields input:is([type="checkbox"], [type="radio"]) {
    width: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
}

:is(.modal-dialog, .foundation-modal-dialog) .modal-fields .foundation-multi-select-option input {
    width: 15px;
    height: 15px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--app-primary);
}

/* --------------------------------------------------------------------------
   Auto-height window (RenderModal 'height' => 'auto', 018-007): sized to its
   content, still capped at 90% of the screen with the body scrolling.
   -------------------------------------------------------------------------- */
.modal-dialog--fixed.modal-dialog--auto {
    height: auto;
}

@media (max-width: 700px) {
    .modal-dialog--fixed.modal-dialog--auto {
        height: auto;
    }
}

/* 020-025: company "who decides which people use these Apps" choice. */
.app-access-mode {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid #d7e2e6;
    border-radius: 10px;
    background: #f7fafb;
}
.app-access-mode legend {
    padding: 0 6px;
    font-size: 13px;
    font-weight: 700;
}
.app-access-mode p {
    margin: 4px 0 0;
}
.app-access-mode-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 6px 0;
    cursor: pointer;
}
.app-access-mode-option input {
    margin-top: 3px;
    flex: none;
}
.app-access-mode-option span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.app-access-mode-option small {
    color: #5c7178;
    line-height: 1.4;
}
.app-access-mode-extra {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px dashed #d7e2e6;
}

/* 020-054: on narrow screens the Actions button in an Edit window kept a
   half-width rule meant for paired buttons and was squeezed to ~43px, so
   "Actions" ran out of it. It sizes to its label instead. */
@media (max-width: 700px) {
    :is(.modal-action-row, .foundation-modal-action-row) .modal-actions-menu {
        width: auto;
        flex: 0 0 auto;
        margin-left: auto;
    }

    :is(.modal-action-row, .foundation-modal-action-row) .modal-actions-menu summary {
        width: auto;
        white-space: nowrap;
    }
}

/* --------------------------------------------------------------------------
   020-067: View windows show the record's name at the top (same summary strip
   as Edit, a little larger), with the Manage / Actions menus beside it.
   -------------------------------------------------------------------------- */
.modal--view .modal-edit-action-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}

.modal--view .modal-dialog:not(:has(.modal-section-nav)) .modal-edit-action-row {
    padding: 12px 22px;
}

.modal--view .modal-edit-context {
    flex: 1 1 260px;
    min-width: 0;
    margin-right: 0;
    display: grid;
    grid-template-columns: minmax(0, max-content) max-content;
    align-items: center;
    column-gap: 10px;
    row-gap: 2px;
    color: #304b55;
}

.modal--view .modal-edit-context > strong {
    min-width: 0;
    color: #203740;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.modal--view .modal-edit-context .foundation-status {
    justify-self: start;
}

.modal--view .modal-edit-context-company {
    grid-column: 1 / -1;
    color: #71858c;
    font-size: 13px;
    line-height: 1.35;
}

@media (max-width: 700px) {
    .modal--view .modal-edit-context > strong {
        font-size: 16px;
    }
}

/* 020-068: with the name strip on the left, the menus sit at the right edge,
   so the last menu (Actions, or Manage on its own) opens leftwards and stays
   inside the window, as in Edit windows. */
.modal--view .modal-edit-action-row .modal-manage-menu {
    position: relative;
    flex: 0 0 auto;
}

.modal--view .modal-edit-action-row .modal-manage-menu:last-of-type .modal-manage-menu-list {
    left: auto;
    right: 0;
    z-index: 100;
    max-width: min(260px, calc(100vw - 32px));
}

/* 1.19.0: two field groups one after the other (e.g. Add Asset's Vendors, then
   Make, then Dates) keep the same space between them as between fields. */
.modal-fields + .modal-fields { margin-top: 11px; }

/* 1.19.0: a short note beside a window's buttons ('note' in the footer). */
.modal-footer-note { margin: 0; flex: 1 1 260px; max-width: 460px; color: #687d84; font-size: 12.5px; line-height: 1.45; }
.modal-footer-note i { color: var(--app-primary); margin-right: 3px; }
.modal-footer:has(.modal-footer-note) { flex-wrap: wrap; gap: 10px 16px; }

/* 1.21.0: short landscape screens (tablets): less space around and inside the
   window's header and footer, so more of the window's content shows. */
@media (max-height: 860px) and (min-width: 700px) {
    :is(.modal, .foundation-modal) { padding: 12px; }
    :is(.modal-header, .foundation-modal-header) { padding: 16px 24px 14px; }
    .modal-edit-footer { min-height: 58px; }
}

/* 1.35.0: windows on phones. The name column is narrower so the boxes get the
   room, and multi-line boxes (tasks, notes) take the full width under their name. */
@media (max-width: 560px) {
    :is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields {
        grid-template-columns: minmax(84px, .5fr) minmax(0, 1.5fr);
        column-gap: 12px;
        padding: 0 4px;
    }

    :is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields > div:has(> textarea) > label {
        grid-column: 1 / -1;
        padding-top: 0;
    }

    :is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields > div:has(> textarea) > :not(label) {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

/* --------------------------------------------------------------------------
   1.54.1: field names line up with the middle of their box (select, text,
   date…), not with the middle of the whole field, so a help line under the
   box no longer pushes the name down. Rows with only text (View windows) or a
   tick box keep the name at the top. Multi-line boxes keep their own rule.
   -------------------------------------------------------------------------- */
:is(.modal-dialog, .foundation-modal-dialog) {
    --modal-control-height: 41px;
}

:is(.modal-dialog, .foundation-modal-dialog):is(:has(.modal-section-nav), :not(:has(.modal-section-nav))) .modal-fields > div:has(small, .help-text) {
    align-items: start;
}

:is(.modal-dialog, .foundation-modal-dialog):is(:has(.modal-section-nav), :not(:has(.modal-section-nav))) .modal-fields > div:has(small, .help-text):has(select, input:not([type="checkbox"], [type="radio"], [type="hidden"])):not(:has(> textarea)) > :is(label, span:first-of-type) {
    padding-top: calc((var(--modal-control-height) - 1.45em) / 2);
}

/* 1.54.1: a thin line between fields in simple windows (Settings, Add …), as
   the windows with a side menu already have. */
:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) {
    row-gap: 0;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) > div {
    padding: 12px 0;
    border-bottom: 1px solid #edf1f2;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) > div:first-child {
    padding-top: 2px;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) > div:last-child {
    border-bottom: 0;
}

/* Two field groups one after the other: a line between them instead of a gap (both layouts). */
:is(.modal-dialog, .foundation-modal-dialog) .modal-fields:not(.modal-fields--stacked) + .modal-fields:not(.modal-fields--stacked) {
    margin-top: 0;
    border-top: 1px solid #edf1f2;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) + .modal-fields {
    margin-top: 0;
    border-top: 1px solid #edf1f2;
    padding-top: 0;
}

:is(.modal-dialog, .foundation-modal-dialog):not(:has(.modal-section-nav)) .modal-fields:not(.modal-fields--stacked) + .modal-fields > div:first-child {
    padding-top: 12px;
}
