:root {
    --crimson: #9B1C1C;
    --crimson-dark: #7b1111;
    --crimson-lite: #c0392b;
    --crimson-glow: rgba(155, 28, 28, 0.15);
    --ca-gray: #6B7280;
    --border: #e2e5ea;
    --text: #1a1a2a;
    --ease-out: cubic-bezier(.2, .8, .2, 1);
}

* {
    box-sizing: border-box;
}

body {
    background-color: #f6f3f4;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Calibri, sans-serif;
    color: var(--text);
    padding: 1.5rem;
    position: relative;
    overflow-x: hidden;
}

/* ── Animated background ─────────────────────────────────── */
/* faint dotted grid that fades toward the edges */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(rgba(155, 28, 28, .16) 1px, transparent 1.4px);
    background-size: 26px 26px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, transparent 72%);
    mask-image: radial-gradient(ellipse at center, #000 0%, transparent 72%);
    animation: grid-drift 30s linear infinite;
}

.login-scene {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* soft blurred crimson orbs (aurora) */
.login-scene span,
.login-scene::before,
.login-scene::after {
    content: '';
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .55;
    will-change: transform;
}

.login-scene span:nth-child(1) {
    width: 28rem;
    height: 28rem;
    top: -11rem;
    left: -9rem;
    background: radial-gradient(circle, rgba(155, 28, 28, .55), transparent 68%);
    animation: orb-a 16s ease-in-out infinite;
}

.login-scene span:nth-child(2) {
    width: 24rem;
    height: 24rem;
    right: -8rem;
    bottom: -10rem;
    background: radial-gradient(circle, rgba(192, 57, 43, .5), transparent 68%);
    animation: orb-b 19s ease-in-out infinite;
}

.login-scene span:nth-child(3) {
    width: 14rem;
    height: 14rem;
    right: 18%;
    top: 8%;
    background: radial-gradient(circle, rgba(123, 17, 17, .35), transparent 68%);
    animation: orb-c 13s ease-in-out infinite;
}

.login-scene::before {
    width: 18rem;
    height: 18rem;
    left: 12%;
    bottom: -6rem;
    background: radial-gradient(circle, rgba(192, 57, 43, .32), transparent 68%);
    animation: orb-c 22s ease-in-out -6s infinite reverse;
}

.login-scene::after {
    width: 10rem;
    height: 10rem;
    left: 40%;
    top: 4%;
    background: radial-gradient(circle, rgba(155, 28, 28, .28), transparent 68%);
    animation: orb-a 18s ease-in-out -9s infinite;
}

@keyframes orb-a {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(60px, 40px) scale(1.12);
    }
}

@keyframes orb-b {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-70px, -35px) scale(1.15);
    }
}

@keyframes orb-c {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-30px, 50px) scale(.9);
    }
}

@keyframes grid-drift {
    to {
        background-position: 26px 26px;
    }
}

/* ── Card (frosted glass + rotating glow border) ─────────── */
.login-box {
    background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 1.5rem;
    box-shadow:
        0 20px 60px -12px rgba(123, 17, 17, .22),
        0 2px 6px rgba(0, 0, 0, .05);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    animation: card-in .8s var(--ease-out) both;
    transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}


/* animated gradient ring around the card */
.login-box::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(from var(--angle),
            transparent 0deg, rgba(155, 28, 28, .0) 120deg,
            rgba(192, 57, 43, .9) 200deg, rgba(155, 28, 28, 0) 280deg, transparent 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    pointer-events: none;
    animation: spin-ring 6s linear infinite;
    z-index: 2;
}

.login-box:hover {
    transform: translateY(-4px);
    box-shadow:
        0 28px 70px -12px rgba(123, 17, 17, .3),
        0 2px 6px rgba(0, 0, 0, .06);
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(28px) scale(.97);
        filter: blur(6px);
    }

    to {
        opacity: 1;
        transform: none;
        filter: blur(0);
    }
}

@keyframes spin-ring {
    to {
        --angle: 360deg;
    }
}

/* Top accent stripe with moving shimmer */
.login-stripe {
    height: 5px;
    background: linear-gradient(90deg, #7b1111, #c0392b, #9B1C1C, #c0392b, #7b1111);
    background-size: 200% 100%;
    animation: stripe-flow 5s linear infinite;
}

@keyframes stripe-flow {
    to {
        background-position: -200% 0;
    }
}

/* ── Staggered entrance of the card content ──────────────── */
.login-brand>*,
.nav-pills,
.tab-content,
#office-location-message,
.footer-note {
    opacity: 0;
    animation: rise .65s var(--ease-out) forwards;
}

.login-brand> :nth-child(1) {
    animation-delay: .20s;
}

.login-brand> :nth-child(2) {
    animation-delay: .30s;
}

.login-brand> :nth-child(3) {
    animation-delay: .40s;
}

.login-brand> :nth-child(4) {
    animation-delay: .48s;
}

.nav-pills {
    animation-delay: .58s;
}

.tab-content {
    animation-delay: .68s;
}

#office-location-message {
    animation-delay: .78s;
}

.footer-note {
    animation-delay: .86s;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Brand ───────────────────────────────────────────────── */
.login-brand-subtitle {
    font-size: .8rem;
    color: var(--ca-gray);
    letter-spacing: .01em;
}

.ca-logo-img {
    height: 72px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
    transition: transform .4s var(--ease-out);
    opacity: 0;
    animation:
        rise .65s var(--ease-out) .2s forwards,
        logo-breathe 5s ease-in-out 1.2s infinite;
}

.login-box:hover .ca-logo-img {
    transform: scale(1.04);
}

@keyframes logo-breathe {

    0%,
    100% {
        filter: drop-shadow(0 0 0 rgba(155, 28, 28, 0));
    }

    50% {
        filter: drop-shadow(0 6px 14px rgba(155, 28, 28, .25));
    }
}

.portal-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .9rem;
    background: rgba(155, 28, 28, .07);
    border: 1px solid rgba(155, 28, 28, .22);
    border-radius: 100px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--crimson);
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(155, 28, 28, .08);
}

.portal-badge::after {
    /* light sweep */
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .8), transparent);
    transform: skewX(-20deg);
    animation: sweep 4.5s ease-in-out 1.5s infinite;
}

.portal-badge .bi {
    animation: pulse-icon 2.4s ease-in-out infinite;
}

@keyframes sweep {
    0% {
        left: -60%;
    }

    40%,
    100% {
        left: 140%;
    }
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.18);
    }
}

/* ── Tabs ────────────────────────────────────────────────── */
.nav-pills {
    background: rgba(244, 246, 250, .9);
    border: 1px solid var(--border);
    border-radius: .9rem;
    padding: .3rem;
}

.nav-pills .nav-link {
    color: var(--ca-gray);
    font-weight: 600;
    font-size: .85rem;
    border-radius: .65rem;
    transition: background .3s, color .3s, box-shadow .3s, transform .2s;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-pills .nav-link.active {
    background: linear-gradient(135deg, var(--crimson), var(--crimson-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(155, 28, 28, .35);
}

.nav-pills .nav-link:not(.active):hover {
    background: rgba(155, 28, 28, .08);
    color: var(--crimson);
    transform: translateY(-1px);
}

/* Tab pane switch animation */
.tab-pane.show.active {
    animation: pane-in .45s var(--ease-out);
}

@keyframes pane-in {
    from {
        opacity: 0;
        transform: translateX(14px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Form fields ─────────────────────────────────────────── */
.form-label {
    color: #374151;
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: .4rem;
}

.form-control {
    background: #fafbfd;
    border: 1.5px solid var(--border);
    color: var(--text);
    border-radius: .65rem;
    padding: .72rem 1rem;
    font-size: 1rem;
    /* >= 16px to prevent iOS auto-zoom */
    min-height: 46px;
    transition: border-color .25s, box-shadow .25s, background .25s, transform .25s var(--ease-out);
}

.form-control::placeholder {
    color: #b0b7c3;
}

.form-control:hover {
    border-color: rgba(155, 28, 28, .4);
}

.form-control:focus {
    background: #fff;
    border-color: var(--crimson);
    color: var(--text);
    box-shadow: 0 0 0 .25rem var(--crimson-glow), 0 8px 18px -8px rgba(155, 28, 28, .35);
    transform: translateY(-1px);
}

/* ── Split auth-code input ───────────────────────────────── */
.code-segments {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    max-width: 100%;
}

.code-cell {
    width: 52px;
    height: 62px;
    border: 2px solid var(--border);
    border-radius: .75rem;
    background: #fafbfd;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--crimson);
    text-align: center;
    text-transform: uppercase;
    caret-color: var(--crimson);
    outline: none;
    transition: border-color .2s, box-shadow .25s, background .2s, transform .25s var(--ease-out);
    -moz-appearance: textfield;
}

.code-cell::-webkit-outer-spin-button,
.code-cell::-webkit-inner-spin-button {
    display: none;
}

.code-cell:hover {
    border-color: rgba(155, 28, 28, .45);
}

.code-cell:focus {
    border-color: var(--crimson);
    background: #fff;
    box-shadow: 0 0 0 .25rem var(--crimson-glow), 0 10px 20px -10px rgba(155, 28, 28, .5);
    transform: translateY(-3px);
}

.code-cell.filled {
    border-color: var(--crimson);
    background: linear-gradient(180deg, rgba(155, 28, 28, .08), rgba(155, 28, 28, .02));
    animation: cell-pop .3s var(--ease-out);
}

@keyframes cell-pop {
    0% {
        transform: scale(.88);
    }

    60% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

.code-dash {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--crimson);
    opacity: .45;
    line-height: 1;
    user-select: none;
    padding: 0 .1rem;
    flex-shrink: 0;
}

/* ── Button (with light sweep) ───────────────────────────── */
.btn-ca {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--crimson) 0%, var(--crimson-dark) 100%);
    border: none;
    color: #fff;
    font-weight: 700;
    border-radius: .75rem;
    padding: .78rem 1rem;
    min-height: 48px;
    letter-spacing: .01em;
    font-size: .95rem;
    transition: transform .25s var(--ease-out), box-shadow .25s, background .25s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px -6px rgba(155, 28, 28, .5);
}

.btn-ca::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -75%;
    width: 50%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
    transform: skewX(-20deg);
    transition: left .7s var(--ease-out);
}

.btn-ca:hover {
    background: linear-gradient(135deg, var(--crimson-lite) 0%, var(--crimson) 100%);
    box-shadow: 0 14px 28px -8px rgba(155, 28, 28, .6);
    transform: translateY(-2px);
    color: #fff;
}

.btn-ca:hover::after {
    left: 130%;
}

.btn-ca:active {
    transform: translateY(0) scale(.99);
}

.btn-ca:focus-visible {
    outline: 3px solid var(--crimson-glow);
    outline-offset: 2px;
}

.btn-ca .bi {
    transition: transform .25s var(--ease-out);
}

.btn-ca:hover .bi {
    transform: translateX(3px);
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    border-radius: .75rem;
    animation: alert-in .45s var(--ease-out);
}

.alert-danger {
    background: #fff5f5;
    border-color: #fecaca;
    color: #991b1b;
    animation-name: alert-in, shake;
    animation-duration: .45s, .5s;
    animation-delay: 0s, .1s;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

@keyframes alert-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(5px);
    }

    60% {
        transform: translateX(-3px);
    }

    80% {
        transform: translateX(2px);
    }
}

/* ── Footer note ─────────────────────────────────────────── */
.footer-note {
    font-size: .78rem;
    color: #9ca3af;
}

.footer-note .cred {
    color: #374151;
    font-weight: 600;
}

.inner-divider {
    border-color: var(--border) !important;
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }

    .login-brand>*,
    .nav-pills,
    .tab-content,
    #office-location-message,
    .footer-note {
        opacity: 1;
    }
}

/* ════════════════════════════════════════════════════════════
   Mobile Responsive Breakpoints
   ════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    body {
        padding: .75rem;
    }

    .login-box {
        border-radius: 1.15rem;
    }

    .login-box .p-4 {
        padding: 1.5rem 1.15rem !important;
    }

    .ca-logo-img {
        height: 56px;
    }

    .login-box h5 {
        font-size: 1.1rem;
    }

    .nav-pills {
        gap: .25rem;
    }

    .nav-pills .nav-link {
        font-size: .8rem;
        padding: .45rem .6rem;
    }

    .login-scene span,
    .login-scene::before,
    .login-scene::after {
        filter: blur(44px);
    }

    .code-segments {
        gap: .35rem;
    }

    .code-cell {
        width: 44px;
        height: 54px;
        font-size: 1.35rem;
        border-radius: .55rem;
    }

    .code-dash {
        font-size: 1.4rem;
        padding: 0 .05rem;
    }

    .btn-ca {
        font-size: .9rem;
        padding: .7rem 1rem;
    }

    .footer-note {
        font-size: .72rem;
    }
}

@media (max-width: 390px) {
    body {
        padding: .5rem;
    }

    .login-box .p-4 {
        padding: 1.25rem .9rem !important;
    }

    .ca-logo-img {
        height: 48px;
    }

    .login-box h5 {
        font-size: 1rem;
    }

    .code-segments {
        gap: .25rem;
    }

    .code-cell {
        width: 38px;
        height: 48px;
        font-size: 1.25rem;
        border-radius: .45rem;
    }

    .code-dash {
        font-size: 1.25rem;
        padding: 0;
    }

    .nav-pills .nav-link {
        font-size: .75rem;
        padding: .4rem .45rem;
    }
}

@media (max-width: 340px) {
    .login-box .p-4 {
        padding: 1rem .7rem !important;
    }

    .code-segments {
        gap: .18rem;
    }

    .code-cell {
        width: 33px;
        height: 44px;
        font-size: 1.1rem;
        border-width: 1.5px;
        border-radius: .35rem;
    }

    .code-dash {
        font-size: 1.1rem;
    }
}