.dashboard-loading-screen {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: grid;
    place-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right))
        max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
    background:
        radial-gradient(ellipse at 50% 0%, rgba(37, 99, 235, 0.19), transparent 42%),
        radial-gradient(ellipse at 100% 100%, rgba(124, 58, 237, 0.16), transparent 38%),
        #080b14;
    color: #f8fafc;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.dashboard-loading-screen::before {
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
    background-size: 48px 48px;
    content: "";
    pointer-events: none;
    mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.dashboard-loading-screen.is-ready {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.dashboard-loading-card {
    position: relative;
    width: min(100%, 800px);
    margin: auto;
    padding: clamp(1.5rem, 5vw, 3.5rem);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 30px;
    background:
        linear-gradient(145deg, rgba(23, 29, 45, 0.96), rgba(12, 17, 29, 0.96));
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.48), inset 0 1px rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(22px);
}

.dashboard-loading-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    margin: 0 auto clamp(1.5rem, 4vh, 2.5rem);
    text-align: center;
}

.dashboard-loading-logo {
    position: relative;
    display: block;
    width: clamp(180px, 28vw, 260px);
    height: clamp(136px, 24vh, 194px);
    flex: 0 0 auto;
    border-radius: 0;
    background: transparent;
    filter: drop-shadow(0 14px 32px rgba(14, 165, 233, 0.3));
    object-fit: contain;
    padding: 0;
    transition: opacity 0.2s ease, transform 0.3s ease;
}

.dashboard-loading-logo.is-unavailable {
    display: none;
}

.dashboard-loading-brand strong {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(1.35rem, 2.8vw, 1.75rem);
    font-weight: 700;
    letter-spacing: 0.015em;
}

.dashboard-loading-brand span {
    display: block;
    margin-top: 0.25rem;
    color: #aab5c8;
    font-size: 0.86rem;
}

.dashboard-loading-message {
    min-height: 1.5rem;
    margin: 0.75rem 0 1.6rem;
    color: #aab5c8;
    text-align: center;
    font-size: clamp(0.88rem, 2vw, 1rem);
    line-height: 1.5;
}

.dashboard-loading-progress {
    height: 9px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
}

.dashboard-loading-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22d3ee, #3b82f6 52%, #a78bfa);
    box-shadow: 0 0 22px rgba(99, 102, 241, 0.56);
    transition: width 0.45s ease;
}

.dashboard-loading-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
}

.dashboard-loading-step {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid rgba(148, 163, 184, 0.11);
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.045);
    color: #8793a8;
    font-size: 0.84rem;
    line-height: 1.35;
    transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.dashboard-loading-step::before {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border: 2px solid currentColor;
    border-radius: 50%;
    content: "";
}

.dashboard-loading-step.is-active {
    border-color: rgba(56, 189, 248, 0.28);
    background: rgba(14, 165, 233, 0.09);
    color: #7dd3fc;
}

.dashboard-loading-step.is-active::before {
    animation: dashboard-loading-pulse 1.2s ease-in-out infinite;
}

.dashboard-loading-step.is-done {
    border-color: rgba(74, 222, 128, 0.16);
    color: #86efac;
}

.dashboard-loading-step.is-done::before {
    border-color: currentColor;
    background: currentColor;
}

.dashboard-loading-error {
    display: none;
    margin: 1.25rem 0 0;
    color: #fca5a5;
    text-align: center;
    font-size: 0.88rem;
    line-height: 1.5;
}

.dashboard-loading-screen.has-error .dashboard-loading-error {
    display: block;
}

.dashboard-loading-retry {
    display: none;
    min-height: 44px;
    justify-content: center;
    margin: 1rem auto 0;
    padding: 0.65rem 1.15rem;
    border: 1px solid rgba(125, 211, 252, 0.45);
    border-radius: 12px;
    background: rgba(14, 165, 233, 0.14);
    color: #bae6fd;
    cursor: pointer;
    font: inherit;
    font-weight: 650;
}

.dashboard-loading-screen.has-error .dashboard-loading-retry {
    display: flex;
}

/* Estado: Aguardando Servidor */
.dashboard-loading-screen.is-waiting .dashboard-loading-card {
    border-color: rgba(56, 189, 248, 0.45);
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.6), 0 0 35px rgba(14, 165, 233, 0.2);
}

.dashboard-loading-screen.is-waiting .dashboard-loading-progress-bar {
    width: 100% !important;
    background: linear-gradient(90deg, #0ea5e9, #6366f1, #a855f7, #0ea5e9);
    background-size: 200% 100%;
    animation: dashboard-loading-scan 2s linear infinite;
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.5);
}

.dashboard-loading-screen.is-waiting .dashboard-loading-message {
    color: #7dd3fc;
    font-weight: 500;
}

.dashboard-loading-spinner-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border: 2px solid #38bdf8;
    border-top-color: transparent;
    border-radius: 50%;
    animation: dashboard-spin 0.8s linear infinite;
    vertical-align: middle;
}

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

@keyframes dashboard-loading-scan {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dashboard-loading-screen.is-waiting .dashboard-loading-step.is-waiting-step {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
    color: #fcd34d;
}

.dashboard-loading-screen.is-waiting .dashboard-loading-step.is-waiting-step::before {
    border-color: #f59e0b;
    background: transparent;
    animation: dashboard-loading-pulse 1.2s ease-in-out infinite;
}

.dashboard-loading-screen.is-waiting .dashboard-loading-error,
.dashboard-loading-screen.is-waiting .dashboard-loading-retry,
.dashboard-loading-screen.is-waiting #dashboardLoadingLoginBtn {
    display: none !important;
}

@keyframes dashboard-loading-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(125, 211, 252, 0); }
    50% { box-shadow: 0 0 0 5px rgba(125, 211, 252, 0.18); }
}

@media (max-width: 600px) {
    .dashboard-loading-screen {
        place-items: stretch center;
        padding: max(0.8rem, env(safe-area-inset-top)) max(0.8rem, env(safe-area-inset-right))
            max(0.8rem, env(safe-area-inset-bottom)) max(0.8rem, env(safe-area-inset-left));
    }

    .dashboard-loading-card {
        width: 100%;
        padding: clamp(1.25rem, 6vw, 1.8rem);
        border-radius: 24px;
    }

    .dashboard-loading-brand {
        gap: 0.55rem;
        margin-bottom: clamp(1.3rem, 4vh, 2rem);
    }

    .dashboard-loading-logo {
        width: clamp(164px, 52vw, 218px);
        height: clamp(120px, 19vh, 158px);
    }

    .dashboard-loading-message {
        margin-top: 0.65rem;
        margin-bottom: 1.25rem;
    }

    .dashboard-loading-brand strong {
        font-size: clamp(1.25rem, 5vw, 1.55rem);
    }

    .dashboard-loading-steps {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.55rem;
        margin-top: 1.2rem;
    }

    .dashboard-loading-step {
        min-height: 42px;
        padding: 0.55rem 0.7rem;
        font-size: 0.82rem;
    }
}

@media (max-width: 360px) {
    .dashboard-loading-card {
        padding: 1.1rem;
    }

    .dashboard-loading-logo {
        width: 150px;
        height: 112px;
    }

}

@media (max-height: 680px) and (min-width: 601px) {
    .dashboard-loading-card {
        padding-block: 1.5rem;
    }

    .dashboard-loading-brand {
        gap: 0.35rem;
        margin-bottom: 1.25rem;
    }

    .dashboard-loading-logo {
        width: 180px;
        height: 112px;
    }

    .dashboard-loading-steps {
        margin-top: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dashboard-loading-screen,
    .dashboard-loading-logo,
    .dashboard-loading-progress-bar,
    .dashboard-loading-step {
        transition: none;
    }

    .dashboard-loading-step.is-active::before {
        animation: none;
    }
}
