:root {
    --auth-navy: #0b1730;
    --auth-blue: #1769f5;
    --auth-blue-dark: #1557d6;
    --auth-ink: #12233f;
    --auth-muted: #6c83a5;
    --auth-line: #d9e3f1;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body.auth-page {
    min-height: 100vh;
    margin: 0;
    padding: 28px;
    display: grid;
    place-items: center;
    color: var(--auth-ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(55, 117, 232, .14), transparent 34%),
        radial-gradient(circle at 92% 92%, rgba(91, 142, 231, .12), transparent 32%),
        #eef3fa;
}

.auth-page .auth-shell {
    width: min(100%, 1040px);
    min-height: 600px;
    display: grid;
    grid-template-columns: 1.04fr .96fr;
    gap: 24px;
}

.auth-page .brand-panel {
    position: relative;
    overflow: hidden;
    min-height: 600px;
    padding: 38px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 30px;
    color: #fff;
    background:
        radial-gradient(circle at 15% 0%, rgba(46, 117, 244, .32), transparent 45%),
        linear-gradient(155deg, #192e56 0%, var(--auth-navy) 68%);
    box-shadow: 0 22px 52px rgba(17, 43, 83, .22);
}

.auth-page .brand-panel::after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    right: -135px;
    bottom: -145px;
    border: 1px solid rgba(112, 161, 244, .24);
    border-radius: 50%;
    box-shadow: 0 0 0 26px rgba(112,161,244,.05), 0 0 0 52px rgba(112,161,244,.04);
}

.auth-page .brand-logo {
    width: min(100%, 282px);
    height: auto;
    display: block;
    padding: 16px 20px;
    border: 1px solid rgba(255,255,255,.13);
    border-radius: 22px;
    background: rgba(255,255,255,.06);
}

.auth-page .brand-copy { max-width: 390px; }
.auth-page .brand-kicker,
.auth-page .auth-kicker {
    margin: 0 0 13px;
    color: #8fb8ff;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

.auth-page .brand-title {
    margin: 0;
    color: #fff;
    font-size: clamp(2rem, 4vw, 3.05rem);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.auth-page .brand-text {
    margin: 18px 0 0;
    color: #c2d1e8;
    font-size: 1.04rem;
    line-height: 1.65;
}

.auth-page .brand-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 28px;
}

.auth-page .brand-badge {
    padding: 9px 12px;
    border: 1px solid rgba(143,184,255,.23);
    border-radius: 999px;
    color: #d9e6fb;
    font-size: .83rem;
    background: rgba(255,255,255,.06);
}

.auth-page .brand-footer {
    position: relative;
    z-index: 1;
    margin: 32px 0 0;
    color: #8fa5c5;
    font-size: .83rem;
}

.auth-page .auth-card-wrap {
    min-height: 600px;
    display: grid;
    place-items: center;
}

.auth-page .auth-card {
    width: min(100%, 440px);
    padding: 38px 36px 32px;
    border: 1px solid rgba(255,255,255,.84);
    border-radius: 30px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 22px 52px rgba(33, 67, 112, .14);
}

.auth-page .mobile-logo { display: none; }

.auth-page .security-mark {
    width: 54px;
    height: 54px;
    margin-bottom: 20px;
    display: grid;
    place-items: center;
    border: 1px solid #bdd5ff;
    border-radius: 17px;
    color: var(--auth-blue);
    font-size: 1.5rem;
    background: #edf4ff;
}

.auth-page .auth-kicker { margin-bottom: 10px; color: var(--auth-blue-dark); }

.auth-page .auth-title {
    margin: 0;
    color: var(--auth-ink);
    font-size: clamp(1.65rem, 4vw, 2.05rem);
    line-height: 1.15;
    letter-spacing: -.035em;
}

.auth-page .auth-subtitle {
    margin: 11px 0 28px;
    color: var(--auth-muted);
    font-size: .98rem;
    line-height: 1.55;
}

.auth-page .alert {
    margin: 0 0 20px;
    padding: 12px 14px;
    border: 1px solid #b9d3ff;
    border-radius: 13px;
    color: #2454a6;
    font-size: .9rem;
    line-height: 1.45;
    background: #edf4ff;
}

.auth-page .alert.warning { border-color: #ffdc9b; color: #925c00; background: #fff8e8; }
.auth-page .alert.danger { border-color: #ffc6cf; color: #a71f36; background: #fff1f3; }
.auth-page .alert.success { border-color: #b8ebd1; color: #137444; background: #edfff5; }

.auth-page .form-label {
    display: block;
    margin: 0 0 9px;
    color: #314c74;
    font-size: .86rem;
    font-weight: 750;
}

.auth-page .form-control {
    width: 100%;
    height: 54px;
    padding: 0 16px;
    border: 1px solid var(--auth-line);
    border-radius: 15px;
    outline: none;
    color: var(--auth-ink);
    font: inherit;
    background: #fff;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.auth-page .form-control:focus {
    border-color: #6d9cff;
    box-shadow: 0 0 0 4px rgba(35, 105, 244, .14);
}

.auth-page .btn-confirm,
.auth-page .btn-primary {
    width: 100%;
    height: 54px;
    margin-top: 20px;
    border: 0;
    border-radius: 15px;
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, #2671f4, #1554d1);
    box-shadow: 0 12px 24px rgba(33, 98, 226, .24);
}

.auth-page .btn-cancel {
    width: 100%;
    height: 49px;
    border: 1px solid #ccdaec;
    border-radius: 15px;
    color: #587197;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    background: #fff;
}

.auth-page .btn-cancel:hover { border-color: #9eb9df; color: #284b7d; background: #f7faff; }
.auth-page .cancel-form { margin-top: 12px; }
.auth-page .auth-note { margin: 23px 0 0; color: #8597b1; font-size: .79rem; line-height: 1.5; text-align: center; }

@media (max-width: 860px) {
    body.auth-page { padding: 18px; }
    .auth-page .auth-shell { grid-template-columns: 1fr; min-height: 0; }
    .auth-page .brand-panel { display: none; }
    .auth-page .auth-card-wrap { min-height: 0; }
    .auth-page .auth-card { max-width: 500px; }
    .auth-page .mobile-logo { width: min(100%, 245px); display: block; margin: 0 auto 18px; }
}

@media (max-width: 420px) {
    body.auth-page { padding: 12px; }
    .auth-page .auth-card { padding: 28px 22px 24px; border-radius: 24px; }
}

/* As telas de acesso também respeitam a preferência de tema do portal.
   Elas não usam o cabeçalho comum, por isso mantêm seus próprios contrastes
   e o botão flutuante de alternância. */
html[data-theme="dark"] body.auth-page,
html[data-theme="dark"] body.login-page {
    color-scheme: dark;
    color: #e7edf7;
    background:
        radial-gradient(circle at 15% 10%, rgba(55, 117, 232, .18), transparent 34%),
        radial-gradient(circle at 92% 92%, rgba(42, 160, 105, .12), transparent 32%),
        #0b1120;
}

html[data-theme="dark"] .auth-page .auth-card,
html[data-theme="dark"] .login-page .login-card {
    background: rgba(17, 24, 39, .96) !important;
    border-color: #34445c !important;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .38) !important;
    color: #e7edf7 !important;
}

html[data-theme="dark"] .auth-page .auth-title,
html[data-theme="dark"] .login-page .login-title {
    color: #f5f8ff !important;
}

html[data-theme="dark"] .auth-page .auth-subtitle,
html[data-theme="dark"] .auth-page .auth-note,
html[data-theme="dark"] .login-page .login-subtitle,
html[data-theme="dark"] .login-page .security-note {
    color: #9aa9bf !important;
}

html[data-theme="dark"] .login-page .security-note {
    background: #172033 !important;
    border-color: #2b3950 !important;
}

html[data-theme="dark"] .auth-page .form-label,
html[data-theme="dark"] .login-page .form-label,
html[data-theme="dark"] .login-page .form-check-label {
    color: #b8c7db !important;
}

html[data-theme="dark"] .auth-page .form-control,
html[data-theme="dark"] .auth-page .code-input,
html[data-theme="dark"] .login-page .input-group {
    background: #0f172a !important;
    border-color: #34445c !important;
    color: #f1f5ff !important;
}

html[data-theme="dark"] .auth-page .form-control::placeholder,
html[data-theme="dark"] .auth-page .code-input::placeholder,
html[data-theme="dark"] .login-page .form-control::placeholder {
    color: #70819a !important;
}

html[data-theme="dark"] .auth-page .form-control:focus,
html[data-theme="dark"] .auth-page .code-input:focus,
html[data-theme="dark"] .login-page .input-group:focus-within {
    border-color: #6d9cff !important;
    box-shadow: 0 0 0 4px rgba(79, 134, 255, .2) !important;
}

html[data-theme="dark"] .auth-page .btn-cancel {
    background: #172033 !important;
    border-color: #34445c !important;
    color: #c2d0e3 !important;
}

html[data-theme="dark"] .auth-page .btn-cancel:hover {
    background: #223252 !important;
    border-color: #4a6590 !important;
    color: #e4edff !important;
}

html[data-theme="dark"] .auth-page .alert {
    background: #431b29 !important;
    border-color: #8c334b !important;
    color: #ffb1bf !important;
}

html[data-theme="dark"] .auth-page .alert.warning {
    background: #44331a !important;
    border-color: #87652d !important;
    color: #ffd38a !important;
}

html[data-theme="dark"] .auth-page .alert.success {
    background: #123b2c !important;
    border-color: #276d4e !important;
    color: #8af0b4 !important;
}

/* Mantém o controle nativo para que o estado marcado seja confiável também
   em Safari/iOS e em navegadores móveis com estilos próprios de checkbox. */
html[data-theme="dark"] .login-page .form-check-input {
    appearance: auto !important;
    -webkit-appearance: checkbox !important;
    width: 1.05rem;
    height: 1.05rem;
    margin-top: .16rem;
    border: 1px solid #60708a !important;
    background: #0f172a !important;
    background-image: none !important;
    accent-color: #4f86ff;
    cursor: pointer;
}

html[data-theme="dark"] .login-page .form-check-input:checked {
    background-color: #4f86ff !important;
    background-image: none !important;
}

html[data-theme="dark"] .login-page .form-check-input:focus {
    border-color: #6d9cff !important;
    box-shadow: 0 0 0 4px rgba(79, 134, 255, .2) !important;
}

/* O script de tema injeta o botão quando a página não possui o menu lateral. */
body.auth-page .portal-theme-toggle,
body.login-page .portal-theme-toggle {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 2000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #d6e1ee;
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    color: #526987;
    box-shadow: 0 10px 25px rgba(15, 23, 42, .14);
    cursor: pointer;
    backdrop-filter: blur(8px);
}

body.auth-page .portal-theme-toggle:hover,
body.login-page .portal-theme-toggle:hover { transform: translateY(-1px); }
body.auth-page .portal-theme-toggle i,
body.login-page .portal-theme-toggle i { color: #2563eb; }

html[data-theme="dark"] body.auth-page .portal-theme-toggle,
html[data-theme="dark"] body.login-page .portal-theme-toggle {
    background: #172033 !important;
    border-color: #34445c !important;
    color: #d7e3f3 !important;
}

html[data-theme="dark"] body.auth-page .portal-theme-toggle i,
html[data-theme="dark"] body.login-page .portal-theme-toggle i { color: #f7c948 !important; }

@media (max-width: 575px) {
    body.auth-page .portal-theme-toggle,
    body.login-page .portal-theme-toggle {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }
}
