.formcommand-loading-overlay {
    position: fixed;
    z-index: 30000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    visibility: hidden;
    opacity: 0;
    background: rgba(10, 29, 23, .64);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    transition: opacity .16s ease, visibility .16s ease;
    box-sizing: border-box;
}

.formcommand-loading-overlay.active {
    visibility: visible;
    opacity: 1;
}

.formcommand-loading-panel {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 220px;
    max-width: min(430px, calc(100vw - 48px));
    padding: 19px 23px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 12px;
    color: #fff;
    background: #12372a;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
    box-sizing: border-box;
}

.formcommand-loading-overlay.pipeline .formcommand-loading-panel {
    width: min(860px, calc(100vw - 48px));
    max-width: min(860px, calc(100vw - 48px));
    align-items: flex-start;
    gap: 20px;
    padding: 28px 30px;
}

.formcommand-loading-overlay.pipeline .formcommand-loading-spinner {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    margin-top: 4px;
}

.formcommand-loading-overlay.pipeline .formcommand-loading-copy { width: 100%; }

.formcommand-loading-copy { display: grid; gap: 8px; }
.formcommand-pipeline-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin-bottom: 16px; }
.formcommand-pipeline-heading p { margin: 0; color: #fff; font-size: 1.2rem; font-weight: 750; }
.formcommand-pipeline-heading strong { color: #a9dfc4; font-size: .8rem; white-space: nowrap; }
.formcommand-pipeline-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: rgba(255, 255, 255, .13); }
.formcommand-pipeline-facts div { min-width: 0; padding: 12px 14px; background: #174332; }
.formcommand-pipeline-facts dt { color: rgba(255, 255, 255, .62); font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.formcommand-pipeline-facts dd { margin: 3px 0 0; color: #fff; font-size: .88rem; font-weight: 650; overflow-wrap: anywhere; }
.formcommand-pipeline-progress { height: 7px; margin-top: 16px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .18); }
.formcommand-pipeline-progress div { height: 100%; width: 0; border-radius: inherit; background: #71c69b; transition: width .2s ease; }

.formcommand-loading-overlay.diagnostic-failure { padding: 18px; }
.formcommand-loading-overlay.diagnostic-failure .formcommand-loading-panel {
    display: block;
    width: min(1120px, calc(100vw - 36px));
    max-width: min(1120px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 26px 28px;
    border-top: 5px solid #e8884b;
}
.formcommand-loading-overlay.diagnostic-failure .formcommand-loading-spinner,
.formcommand-loading-overlay.diagnostic-failure .formcommand-loading-copy { display: none; }
.formcommand-ai-diagnostic-failure { width: 100%; }
.formcommand-ai-diagnostic-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.formcommand-ai-diagnostic-heading span { color: #a9dfc4; font-size: .68rem; font-weight: 800; letter-spacing: .1em; }
.formcommand-ai-diagnostic-heading h2 { margin: 3px 0 0; color: #fff; font: 700 1.55rem/1.2 Georgia, serif; }
.formcommand-ai-diagnostic-heading strong { color: #ffd3b7; font-size: .78rem; white-space: nowrap; }
.formcommand-ai-diagnostic-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 18px; background: rgba(255, 255, 255, .14); }
.formcommand-ai-diagnostic-facts div { min-width: 0; padding: 10px 12px; background: #174332; }
.formcommand-ai-diagnostic-facts .wide { grid-column: 1 / -1; }
.formcommand-ai-diagnostic-facts dt { color: rgba(255, 255, 255, .62); font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.formcommand-ai-diagnostic-facts dd { margin: 3px 0 0; color: #fff; font: 650 .86rem/1.4 Inter, "Segoe UI", Arial, sans-serif; overflow-wrap: anywhere; white-space: pre-wrap; }
.formcommand-ai-diagnostic-failure h3 { margin: 17px 0 7px; color: #fff; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.formcommand-ai-diagnostic-failure pre { max-height: 34vh; margin: 0; overflow: auto; padding: 15px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 6px; color: #edf4ef; background: #091f17; font: 12px/1.5 Consolas, "Courier New", monospace; overflow-wrap: normal; white-space: pre; }
.formcommand-ai-diagnostic-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.formcommand-ai-diagnostic-actions [data-copy-diagnostic-status] { color: #a9dfc4; font-size: .8rem; }

.formcommand-loading-spinner {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: 2px solid rgba(255, 255, 255, .28);
    border-top-color: #71c69b;
    border-right-color: #ed7c3b;
    border-radius: 50%;
    animation: formcommand-loading-spin .8s linear infinite;
}

.formcommand-loading-message {
    color: #fff;
    font: 700 15px/1.4 Inter, "Segoe UI", Arial, sans-serif;
    overflow-wrap: anywhere;
}

html.formcommand-is-loading,
body.formcommand-is-loading,
body.formcommand-modal-open {
    overflow: hidden;
}

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

.toast-region {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 29000;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    width: min(390px, calc(100vw - 2rem));
    pointer-events: none;
}

.app-toast {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .8rem;
    align-items: start;
    padding: 1rem;
    border: 1px solid #d8dcd7;
    border-left: 4px solid #1f6b4b;
    background: #fff;
    color: #17201d;
    box-shadow: 0 16px 42px rgba(20, 38, 30, .2);
    transform: translateY(12px);
    opacity: 0;
    transition: transform .18s ease, opacity .18s ease;
    pointer-events: auto;
    box-sizing: border-box;
}

.app-toast.visible { transform: none; opacity: 1; }
.app-toast.information { border-left-color: #39778a; }
.app-toast.warning { border-left-color: #c5632f; }
.app-toast.error { border-left-color: #b74733; }
.app-toast-marker {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e9f2ed;
    color: #1f6b4b;
    font-size: .72rem;
    font-weight: 900;
}
.app-toast.information .app-toast-marker { background: #e8f1f4; color: #39778a; }
.app-toast.warning .app-toast-marker { background: #fff0e7; color: #a95429; }
.app-toast.error .app-toast-marker { background: #f9e9e6; color: #b74733; }
.app-toast strong { display: block; margin: .05rem 0 .18rem; font-size: .82rem; }
.app-toast p { margin: 0; color: #63706a; font-size: .76rem; line-height: 1.45; }
.app-toast-close { border: 0; background: transparent; color: #78817c; font-size: 1rem; padding: 0; cursor: pointer; }

.formcommand-modal {
    position: fixed;
    z-index: 31000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(12, 28, 22, .62);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-sizing: border-box;
}

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

.formcommand-modal-dialog {
    width: min(540px, calc(100vw - 40px));
    border: 1px solid rgba(31, 107, 75, .24);
    border-radius: 12px;
    background: #fff;
    color: #17201d;
    box-shadow: 0 28px 80px rgba(10, 24, 18, .34);
    overflow: hidden;
    box-sizing: border-box;
}

.formcommand-modal-accent { height: 4px; background: #39778a; }
.formcommand-modal[data-type="success"] .formcommand-modal-accent { background: #1f6b4b; }
.formcommand-modal[data-type="warning"],
.formcommand-modal[data-type="confirmation"] { --modal-tone: #a95429; --modal-soft: #fff0e7; }
.formcommand-modal[data-type="warning"] .formcommand-modal-accent,
.formcommand-modal[data-type="confirmation"] .formcommand-modal-accent { background: #ed7c3b; }
.formcommand-modal[data-type="error"] { --modal-tone: #b74733; --modal-soft: #f9e9e6; }
.formcommand-modal[data-type="error"] .formcommand-modal-accent { background: #b74733; }
.formcommand-modal[data-type="success"] { --modal-tone: #1f6b4b; --modal-soft: #e9f2ed; }
.formcommand-modal[data-type="information"] { --modal-tone: #39778a; --modal-soft: #e8f1f4; }

.formcommand-modal-content {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding: 1.65rem;
}

.formcommand-modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--modal-soft, #e8f1f4);
    color: var(--modal-tone, #39778a);
    font-weight: 900;
}

.formcommand-modal-type {
    display: block;
    color: #748079;
    font-size: .62rem;
    font-weight: 850;
    letter-spacing: .1em;
}

.formcommand-modal h2 {
    margin: .25rem 0 .55rem;
    color: #17201d;
    font: 700 1.5rem/1.2 Georgia, "Times New Roman", serif;
}

.formcommand-modal p {
    margin: 0;
    color: #63706a;
    font: 400 .86rem/1.65 Inter, "Segoe UI", Arial, sans-serif;
    white-space: pre-line;
}

.formcommand-modal-content > div { min-width: 0; }
.formcommand-modal [data-modal-advanced] { margin-top: .8rem; font-size: .82rem; }
.formcommand-modal [data-modal-advanced] pre {
    max-height: 16rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.formcommand-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .65rem;
    padding: .95rem 1.65rem 1.05rem;
    border-top: 1px solid #dcded8;
    background: #f7f8f5;
}

.formcommand-modal-actions .btn {
    min-width: 94px;
    padding: .68rem 1.05rem;
    border: 1px solid #1f6b4b;
    border-radius: 6px;
    background: #1f6b4b;
    color: #fff;
    font: 700 .84rem/1 Inter, "Segoe UI", Arial, sans-serif;
    cursor: pointer;
}

.formcommand-modal-actions .btn:hover,
.formcommand-modal-actions .btn:focus { background: #15523a; border-color: #15523a; }
.formcommand-modal-actions .btn-outline-dark { background: #fff; border-color: #aeb7b1; color: #26352e; }
.formcommand-modal-actions .btn-outline-dark:hover,
.formcommand-modal-actions .btn-outline-dark:focus { background: #eef1ed; border-color: #77847c; color: #17201d; }
.formcommand-modal-actions .btn-danger { background: #a83f31; border-color: #a83f31; color: #fff; }
.formcommand-modal-actions .btn-danger:hover,
.formcommand-modal-actions .btn-danger:focus { background: #883226; border-color: #883226; }
.formcommand-modal-actions .btn:focus { outline: 0; box-shadow: 0 0 0 3px rgba(31, 107, 75, .2); }

[data-loading-submitted="true"] [type="submit"] { cursor: wait; }

@media (max-width: 480px) {
    .formcommand-loading-overlay,
    .formcommand-modal { padding: 18px; }
    .formcommand-loading-panel { min-width: min(220px, calc(100vw - 36px)); max-width: calc(100vw - 36px); padding: 17px 19px; }
    .formcommand-loading-overlay.pipeline .formcommand-loading-panel { width: calc(100vw - 36px); max-width: calc(100vw - 36px); padding: 20px; }
    .formcommand-pipeline-facts { grid-template-columns: 1fr; }
    .formcommand-pipeline-heading { align-items: flex-start; flex-direction: column; }
    .formcommand-loading-overlay.diagnostic-failure .formcommand-loading-panel { padding: 18px; }
    .formcommand-ai-diagnostic-heading { flex-direction: column; }
    .formcommand-ai-diagnostic-heading strong { white-space: normal; }
    .formcommand-ai-diagnostic-facts { grid-template-columns: 1fr; }
    .formcommand-ai-diagnostic-facts .wide { grid-column: auto; }
    .formcommand-modal-dialog { width: calc(100vw - 36px); }
    .formcommand-modal-content { padding: 1.35rem; }
    .formcommand-modal-actions { padding: .85rem 1.35rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .formcommand-loading-overlay,
    .app-toast { transition: none; }
    .formcommand-loading-spinner { animation: none; }
}
/* Status communication problems are not pipeline diagnostic failures. */
.formcommand-loading-overlay.pipeline.progress-monitor .formcommand-loading-panel { max-height: calc(100vh - 48px); overflow: auto; }
.formcommand-progress-communication { margin-bottom: 1rem; padding: 1rem; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .07); color: #fff; overflow-wrap: anywhere; }
.formcommand-progress-communication p { margin: .5rem 0; }
.formcommand-progress-recovery { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.formcommand-progress-actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.formcommand-progress-actions .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem; margin: 0; vertical-align: top; }
