#modal-root {
    position: relative;
    z-index: var(--z-modal);
}

#modal-stack {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body.is-page-scroll-locked {
    overflow: hidden;
}

[hidden] {
    display: none !important;
}

.app-modal__nonmodal {
    z-index: var(--z-local-popover);
}

.app-modal {
    --app-modal-edge-gap: 28px;
    --app-modal-vertical-gap: 56px;
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: var(--app-modal-edge-gap);
    pointer-events: auto;
}

.app-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(14, 20, 28, 0.2);
    opacity: 0;
    transition: opacity 160ms ease;
}

.app-modal__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(var(--app-modal-width, 560px), 100%);
    max-height: min(calc(100dvh - var(--app-modal-vertical-gap)), 880px);
    overflow: hidden;
    background: var(--panel, #fff);
    border: 1px solid var(--panel-border, #d4dde6);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 160ms ease, transform 160ms ease;
}

.app-modal__panel.has-open-autocomplete {
    overflow: visible;
}

.app-modal__panel.has-open-autocomplete > form,
.app-modal__panel.has-open-autocomplete .app-modal__body {
    overflow: visible;
}

.app-modal[data-modal-position="anchor"] {
    display: block;
    padding: 0;
}

.app-modal[data-modal-position="anchor"] .app-modal__backdrop {
    background: transparent;
}

.app-modal[data-modal-position="anchor"] .app-modal__panel {
    position: absolute;
    top: var(--app-modal-anchor-top);
    left: var(--app-modal-anchor-left);
    transform-origin: top right;
}

.app-modal[data-modal-position="anchor"][data-modal-anchor-placement="above"] .app-modal__panel {
    transform-origin: bottom right;
}

.app-modal--topbar-menu {
    --app-modal-edge-gap: 10px;
    --app-modal-vertical-gap: 20px;
    place-items: start center;
    padding-top: 60px;
}

.app-modal--topbar-menu .topbar-more-menu {
    width: min(430px, calc(100vw - 20px));
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
}

@media (min-width: 761px) {
    .app-modal--topbar-menu .topbar-more-menu {
        width: min(480px, calc(100vw - 20px));
    }
}

.app-modal--topbar-menu[data-modal-position="anchor"] .app-modal__backdrop {
    background: rgba(14, 20, 28, 0.12);
}

.app-modal--sm {
    --app-modal-width: 420px;
}

.app-modal--md {
    --app-modal-width: 560px;
}

.app-modal--lg {
    --app-modal-width: 760px;
}

.app-modal--xl {
    --app-modal-width: 980px;
}

.app-modal.is-open .app-modal__backdrop {
    opacity: 1;
}

.app-modal.is-open .app-modal__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.app-modal.is-closing .app-modal__backdrop {
    opacity: 0;
}

.app-modal.is-closing .app-modal__panel {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
}

.app-modal.is-inactive .app-modal__backdrop {
    pointer-events: none;
}

.app-modal.is-inactive .app-modal__panel {
    transform: translateY(0) scale(0.985);
}

.app-modal__header,
.app-modal__footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
}

.app-modal__header {
    justify-content: space-between;
    border-bottom: 1px solid #e6e9ef;
}

.app-modal__heading {
    min-width: 0;
}

.app-modal__title {
    margin: 0;
    color: #17202c;
    font-size: var(--font-lg, 1.12rem);
    line-height: 1.25;
}

.app-modal__subtitle {
    margin: 3px 0 0;
    color: #667085;
    font-size: var(--font-sm, 0.86rem);
    font-weight: 650;
    line-height: 1.3;
}

.app-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--control-height-sm, 34px);
    height: var(--control-height-sm, 34px);
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 5px);
    background: transparent;
    color: #5d6675;
    cursor: pointer;
}

.app-modal__close:hover {
    background: var(--control-bg-hover, #eef7fd);
    color: #1f2937;
}

.app-modal__close::before {
    content: "";
    width: 18px;
    height: 18px;
    background: currentColor;
    mask-image: url("/icons/ui/x.svg");
    mask-position: center;
    mask-repeat: no-repeat;
    mask-size: 18px 18px;
    -webkit-mask-image: url("/icons/ui/x.svg");
    -webkit-mask-position: center;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-size: 18px 18px;
}

.app-modal__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.app-modal__panel > form {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
}

.app-modal__footer {
    justify-content: flex-end;
    border-top: 1px solid #e6e9ef;
    background: #fbfcfd;
}

.app-modal__footer-left {
    margin-right: auto;
}

.app-modal--danger .app-modal__header {
    border-bottom-color: #f1c8c3;
}

.app-modal--danger .app-modal__title {
    color: #9f1d14;
}

.app-modal__panel:focus,
.app-modal__close:focus,
.app-modal button:focus {
    outline: 0;
}

.app-modal__close:focus-visible,
.app-modal button:focus-visible {
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(23, 105, 168, 0.24));
}

.app-modal .flight-country-mode {
    display: grid;
    gap: 12px;
    padding-top: 2px;
}

.app-modal .flight-country-mode > .field-check {
    min-height: 22px;
}

.app-modal .flight-country-preset-panel {
    display: grid;
    gap: 7px;
}

.app-modal .flight-country-manual-fields {
    --form-grid-gap: 16px;
}

.form-feedback:empty {
    display: none;
}

.form-alert {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
    margin: 0 0 18px;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-md, 8px);
    line-height: 1.35;
}

.form-alert:focus {
    outline: 0;
    box-shadow: var(--focus-ring, 0 0 0 3px rgba(23, 105, 168, 0.24));
}

.form-alert--error {
    border-color: #f1c8c3;
    background: #fff7f6;
    color: #8f1d16;
}

.form-alert--success {
    border-color: #bde3ca;
    background: #f5fbf7;
    color: #1d6b38;
}

.form-alert__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-top: 1px;
    border-radius: 50%;
    color: #fff;
    font-size: var(--font-sm, 0.86rem);
    font-weight: 850;
    line-height: 1;
}

.form-alert--error .form-alert__icon {
    background: #c0362c;
}

.form-alert--success .form-alert__icon {
    background: #2d8a4b;
}

.form-alert--success .form-alert__icon::before {
    content: "";
    width: 12px;
    height: 7px;
    border-bottom: 2px solid currentColor;
    border-left: 2px solid currentColor;
    transform: rotate(-45deg) translate(1px, -1px);
}

.form-alert__content {
    min-width: 0;
}

.form-alert__content strong {
    display: block;
    color: inherit;
    font-size: var(--font-md, 1rem);
    font-weight: 800;
}

.form-alert__content p {
    margin: 2px 0 0;
    color: inherit;
    font-size: var(--font-md, 1rem);
    font-weight: 600;
}

.app-modal .form-success,
.auth-page-panel .form-success {
    color: #24743f;
}

.app-modal .form-success,
.auth-page-panel .form-success {
    margin: 0 0 16px;
    font-weight: 650;
}

.auth-modal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.auth-modal-links .page-action {
    width: auto;
    min-width: 0;
    padding-inline: 10px;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--link, #1269a8);
    cursor: pointer;
    font-weight: 700;
    padding: 0;
}

.text-button:hover {
    text-decoration: underline;
}

.auth-page {
    min-height: 100vh;
}

.auth-page-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-page-panel {
    width: min(480px, 100%);
    opacity: 1;
    transform: none;
}

.auth-page-panel .field {
    display: grid;
    gap: 6px;
    color: #354052;
    font-weight: 650;
}

.app-modal .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-height-md, 36px);
    padding: 0 14px;
    border: 1px solid var(--control-border, #b9c6d2);
    border-radius: var(--radius-sm, 5px);
    background: var(--control-bg, #f8fbfd);
    color: #1d2730;
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.app-modal .btn-primary {
    background: var(--control-primary, #1873b5);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--control-primary-shadow, 0 2px 6px rgba(18, 83, 132, 0.18));
}

.app-modal .btn-danger {
    background: #b42318;
    border-color: #981b14;
    color: #fff;
}

.app-modal .btn-secondary {
    background: var(--control-bg, #f8fbfd);
}

.app-modal .btn:hover {
    border-color: var(--control-border-hover, #82a9c8);
    background: var(--control-bg-hover, #eef7fd);
}

.app-modal .btn-primary:hover {
    border-color: transparent;
    background: var(--control-primary-hover, #0f5f99);
}

.app-modal .btn-danger:hover {
    border-color: #981b14;
    background: #981b14;
}

.htmx-indicator {
    display: none;
    color: #64748b;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline;
}

.shared-files-modal .app-modal__panel {
    overflow: visible;
}

.shared-files-modal .app-modal__header,
.shared-files-modal .app-modal__footer,
.shared-files-modal .app-modal__body {
    background: var(--panel, #fff);
}

.shared-files-modal .app-modal__header {
    border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
}

.shared-files-modal .app-modal__footer {
    border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
}

.shared-files-body {
    padding: 12px 14px;
}

.shared-files-list {
    display: grid;
    gap: 4px;
}

.shared-file-row-wrap {
    border: 1px solid transparent;
    border-radius: 8px;
    transition: border-color 160ms ease, background 160ms ease;
}

.shared-file-row-wrap.is-highlighted {
    border-color: #78add2;
    background: #eef8ff;
}

.shared-file-row {
    width: 100%;
    min-height: 62px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #17202c;
    cursor: pointer;
    text-align: left;
}

.shared-file-row:hover,
.shared-file-row:focus-visible,
.shared-file-row[aria-expanded="true"] {
    background: #f2f7fb;
}

.shared-file-row:focus-visible {
    outline: 2px solid var(--focus, #2f80c1);
    outline-offset: -2px;
}

.shared-file-format-icon {
    position: relative;
    width: 38px;
    height: 42px;
    display: grid;
    place-items: center;
    color: #2f6f9e;
}

.shared-file-format-icon > .ui-icon {
    width: 34px;
    height: 34px;
    opacity: 0.78;
}

.shared-file-format-icon > small {
    position: absolute;
    right: -3px;
    bottom: 0;
    max-width: 42px;
    padding: 1px 3px;
    overflow: hidden;
    border: 1px solid #c7d8e6;
    border-radius: 3px;
    background: #fff;
    color: #35536b;
    font-size: 0.52rem;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

.shared-file-row__identity {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.shared-file-row__identity strong {
    min-width: 0;
    overflow: hidden;
    font-size: 0.94rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shared-file-row__meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shared-file-row__meta code,
.shared-file-details-list code {
    flex: 0 0 auto;
    padding: 2px 5px;
    border: 1px solid #d5e0e8;
    border-radius: 4px;
    background: #f6f9fb;
    color: #315169;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.shared-file-row__date {
    color: #667085;
    font-size: 0.82rem;
    white-space: nowrap;
}

.shared-file-row__chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid #8395a4;
    border-bottom: 2px solid #8395a4;
    transform: rotate(45deg) translateY(-2px);
}

.shared-file-menu {
    position: absolute;
    z-index: calc(var(--z-local-popover) + 2);
    width: min(260px, calc(100vw - 20px));
    padding: 6px;
    border: 1px solid #d7e0e8;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 38px rgba(15, 23, 42, 0.2);
}

.shared-file-menu > button,
.shared-file-menu > a {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #213142;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
    text-align: left;
    text-decoration: none;
}

.shared-file-menu > button:hover,
.shared-file-menu > button:focus-visible,
.shared-file-menu > a:hover,
.shared-file-menu > a:focus-visible {
    outline: 0;
    background: #eef5fa;
}

.shared-file-menu .ui-icon {
    width: 18px;
    height: 18px;
}

.shared-file-menu__separator {
    display: block;
    height: 1px;
    margin: 5px 4px;
    background: #e5e9ee;
}

.shared-file-menu > .shared-file-menu__danger {
    color: #b42318;
}

.shared-files-footer {
    display: block;
    padding: 10px 14px 12px;
}

.shared-files-upload-form {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 7px;
}

.shared-files-upload-meta {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.shared-files-quota {
    margin: 0;
    color: #5f6f7d;
    font-size: 0.86rem;
}

.shared-files-quota.is-full {
    color: #a53b2d;
    font-weight: 700;
}

.shared-files-inline-upload {
    gap: 5px;
}

.shared-files-upload-dropzone {
    min-height: 62px;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 12px;
    background: linear-gradient(180deg, #f9fbfd, #f2f7fa);
}

.shared-files-upload-dropzone .file-upload__icon {
    width: 34px;
    height: 34px;
}

.shared-files-upload-dropzone .file-upload__copy {
    gap: 2px;
}

.shared-files-upload-dropzone .file-upload__copy strong {
    font-size: 0.88rem;
    line-height: 1.2;
}

.shared-files-upload-dropzone .file-upload__copy small {
    color: #687786;
    font-size: 0.76rem;
    line-height: 1.2;
}

.shared-files-upload-dropzone .file-upload__selected {
    inset: 9px 12px;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    padding-right: 0;
}

.shared-files-upload-progress {
    color: #50677a;
    font-size: 0.76rem;
    font-weight: 600;
}

.shared-files-upload-spinner {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(24, 115, 181, 0.2);
    border-top-color: var(--control-primary, #1873b5);
    border-radius: 50%;
    animation: shared-files-upload-spin 720ms linear infinite;
}

.shared-files-upload-form.htmx-request {
    pointer-events: none;
}

.shared-files-upload-form.htmx-request .shared-files-upload-dropzone {
    border-color: #78add2;
    background: #eef7fd;
    cursor: progress;
}

.shared-files-inline-upload.is-disabled .shared-files-upload-dropzone {
    border-style: solid;
    background: #f3f5f7;
    color: #667085;
    cursor: not-allowed;
    opacity: 0.82;
}

@keyframes shared-files-upload-spin {
    to {
        transform: rotate(360deg);
    }
}

.shared-files-notice {
    margin-bottom: 10px;
    padding: 9px 11px;
    border-radius: 6px;
    font-size: 0.86rem;
}

.shared-files-notice--success {
    border: 1px solid #b6ddc7;
    background: #effaf3;
    color: #21633d;
}

.shared-files-notice--error {
    border: 1px solid #efc2bd;
    background: #fff2f0;
    color: #912018;
}

.shared-files-empty {
    min-height: 220px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    color: #647485;
    text-align: center;
}

.shared-files-empty .ui-icon {
    width: 38px;
    height: 38px;
    opacity: 0.65;
}

.shared-files-empty strong {
    color: #253747;
}

.shared-files-copy-status {
    min-height: 18px;
    margin: 5px 2px 0;
    color: #246242;
    font-size: 0.8rem;
}

.shared-file-upload-formats {
    min-width: 0;
    max-width: 58%;
    margin: 0;
    overflow: hidden;
    color: #667085;
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shared-file-details-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.shared-file-details-heading .app-modal__title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.shared-file-details-heading .shared-file-format-icon {
    flex: 0 0 auto;
}

.shared-file-details-modal .app-modal__header {
    border-bottom: 0;
}

.shared-file-details-list {
    margin: 0;
}

.shared-file-details-list > div {
    display: grid;
    grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
    gap: 14px;
    padding: 9px 0;
    border-top: 1px solid #e6ebef;
}

.shared-file-details-list dt {
    color: #687786;
    font-size: 0.82rem;
}

.shared-file-details-list dd {
    min-width: 0;
    margin: 0;
    color: #243442;
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .shared-files-modal,
    .shared-file-details-modal {
        --app-modal-edge-gap: 8px;
        --app-modal-vertical-gap: 16px;
        align-items: stretch;
        padding: 8px;
    }

    .shared-files-modal .app-modal__panel,
    .shared-file-details-modal .app-modal__panel {
        width: 100%;
        max-height: calc(100dvh - 16px);
        border-radius: 9px;
    }

    .shared-files-body {
        padding: 8px;
    }

    .shared-file-row {
        grid-template-columns: 38px minmax(0, 1fr) 14px;
        gap: 9px;
        min-height: 58px;
        padding: 7px 8px;
    }

    .shared-file-row__identity {
        grid-template-columns: minmax(0, 1fr);
        gap: 3px;
    }

    .shared-file-row__meta {
        gap: 8px;
    }

    .shared-file-row__meta code {
        width: max-content;
    }

    .shared-files-footer {
        padding: 8px;
    }

    .shared-files-upload-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .shared-file-upload-formats {
        width: 100%;
        max-width: 100%;
    }

    .shared-files-upload-dropzone {
        min-height: 62px;
        padding: 9px 10px;
    }

    .shared-files-upload-dropzone .file-upload__selected {
        inset: 9px 10px;
    }

    .shared-file-details-list > div {
        grid-template-columns: 1fr;
        gap: 3px;
    }
}

@media (max-width: 560px) {
    .app-modal {
        --app-modal-edge-gap: 0px;
        --app-modal-vertical-gap: 8dvh;
        align-items: end;
    }

    .app-modal__panel {
        width: 100%;
        border-radius: 8px 8px 0 0;
    }

    .app-modal.app-modal--topbar-menu {
        --app-modal-edge-gap: 10px;
        --app-modal-vertical-gap: 20px;
        align-items: start;
        justify-items: center;
        padding: 60px 10px 10px;
    }

    .app-modal--topbar-menu .topbar-more-menu {
        border-radius: var(--radius-md, 8px);
    }

    .app-modal__footer {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .app-modal__footer .btn {
        width: 100%;
    }

    .app-modal .form-grid--two {
        grid-template-columns: 1fr;
    }

    .shared-files-modal,
    .shared-file-details-modal {
        --app-modal-edge-gap: 8px;
        --app-modal-vertical-gap: 16px;
        align-items: stretch;
        padding: 8px;
    }

    .shared-files-modal .app-modal__panel,
    .shared-file-details-modal .app-modal__panel {
        max-height: calc(100dvh - 16px);
        border-radius: 9px;
    }

    .shared-files-upload-dropzone .file-upload__copy small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shared-files-upload-spinner {
        animation-duration: 1.6s;
    }
}
