﻿*, *::before, *::after {
    box-sizing: border-box;
}

.auth-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    padding: clamp(16px, 5vw, 56px);
    display: grid;
    place-items: center;
    font: 400 1rem/1.7 var(--font-family);
    color: var(--color-text);
    background: #edf3fb;
}

.auth-shell {
    width: min(100%, 960px);
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    overflow: hidden;
    border: 1px solid #dce6f3;
    border-radius: 30px;
    background: var(--color-surface);
    box-shadow: 0 24px 70px rgb(16 38 83 / 12%);
}

.auth-brand {
    display: grid;
    align-content: center;
    justify-items: start;
    gap: 24px;
    min-height: 530px;
    padding: clamp(24px, 5vw, 64px);
    color: #fff;
    background: radial-gradient(ellipse at 25% 90%, rgb(25 111 245 / 30%), transparent 58%), repeating-linear-gradient(90deg, rgb(255 255 255 / 5%) 0 1px, transparent 1px 34px), repeating-linear-gradient(0deg, rgb(255 255 255 / 5%) 0 1px, transparent 1px 34px), linear-gradient(155deg, #102653, #17427e);
}

    .auth-brand p {
        margin: 0;
        font-size: clamp(1.55rem, 3.5vw, 2.45rem);
        font-weight: 700;
        line-height: 1.55;
    }

.auth-mark {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border: 1px solid rgb(183 216 255 / 38%);
    border-radius: 18px;
    background: rgb(208 229 255 / 12%);
}

    .auth-mark::before {
        content: "";
        width: 25px;
        height: 34px;
        background: #a8d6ff;
        clip-path: polygon(61% 0, 9% 57%, 43% 57%, 34% 100%, 92% 40%, 56% 40%);
    }

.auth-panel {
    min-width: 0;
    display: grid;
    align-items: center;
    padding: clamp(24px, 5vw, 64px);
}

.auth-panel-inner {
    width: min(100%, 420px);
    margin-inline: auto;
}

.auth-panel h1 {
    margin: 0;
    font-size: clamp(1.45rem, 3vw, 2rem);
    line-height: 1.5;
}

.auth-description {
    margin: 8px 0 28px;
    color: #53657e;
}

.auth-form, .auth-field {
    display: grid;
    gap: 18px;
}

.auth-field {
    gap: 7px;
}

    .auth-field label {
        font-weight: 700;
    }

    .auth-field input, .auth-form button, .auth-cancel {
        font: inherit;
    }

    .auth-field input {
        width: 100%;
        min-height: 52px;
        padding: 10px 14px;
        border: 1px solid #a9b9d0;
        border-radius: 12px;
        background: #f8faff;
        color: var(--color-text);
        font-size: 1rem;
    }

        .auth-field input:focus {
            border-color: var(--color-primary);
            outline: 2px solid #8db5ff;
            outline-offset: 2px;
            background: #fff;
        }

.auth-password {
    position: relative;
}

    .auth-password.has-reveal input {
        padding-left: 88px;
    }

.auth-reveal {
    position: absolute;
    inset-block: 4px;
    left: 5px;
    min-inline-size: 76px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #164c9d;
    cursor: pointer;
}

    .auth-reveal:hover, .auth-cancel:hover {
        background: var(--color-primary-light);
    }

.auth-form .auth-submit {
    min-height: 52px;
    margin-top: 3px;
    padding: 10px 16px;
    border: 0;
    border-radius: 12px;
    background: #145bdf;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.auth-submit:hover {
    background: var(--color-primary-dark);
}

.auth-form :is(button, a):focus-visible {
    outline: 3px solid #387be5;
    outline-offset: 3px;
}

.auth-error {
    margin: -6px 0 20px;
    padding: 10px 13px;
    border-inline-start: 3px solid #c43232;
    border-radius: 8px;
    color: #8b2020;
    background: #fff2f2;
}

.auth-cancel {
    display: block;
    padding: 8px;
    border-radius: 8px;
    color: #164c9d;
    text-align: center;
}

@media (max-width: 700px) {
    .auth-shell {
        max-width: 465px;
        grid-template-columns: minmax(0, 1fr);
        border-radius: 22px;
    }

    .auth-brand {
        min-height: 0;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 12px;
        padding: 20px;
    }

        .auth-brand p {
            font-size: 1.05rem;
        }

    .auth-brand-break {
        display: none;
    }

    .auth-mark {
        width: 43px;
        height: 43px;
        border-radius: 12px;
    }

        .auth-mark::before {
            width: 17px;
            height: 24px;
        }

    .auth-panel {
        padding: 24px 20px;
    }

    .auth-description {
        margin-bottom: 22px;
    }
}

@media (max-height: 540px) {
    .auth-brand {
        min-height: 0;
    }
}

/* Login redesign; existing logout layout remains unchanged. */
.auth-page:has(.login-emblem) {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(24px, 5vw, 76px);
    background: linear-gradient(145deg,#83b2e6,#dceaff 65%,#f4f8ff);
}

    .auth-page:has(.login-emblem)::before {
        content: "";
        position: absolute;
        z-index: -1;
        inset: 0 auto 0 0;
        width: 54%;
        background: linear-gradient(135deg,transparent 50%,#124e9022),url('../images/backgrounds/login-substation.jpg') center / cover no-repeat;
        clip-path: polygon(0 0,100% 0,75% 100%,0 100%);
    }

    .auth-page:has(.login-emblem)::after {
        content: "";
        position: absolute;
        z-index: -1;
        bottom: -16%;
        left: -10%;
        width: 120%;
        height: 32%;
        border-radius: 50% 55% 0 0;
        background: linear-gradient(110deg,#083d80,#1767bc);
        transform: rotate(-4deg);
        box-shadow: 0 -22px 0 #70a8e68c;
    }

.auth-shell:has(.login-emblem) {
    width: min(100%,1400px);
    display: flex;
    justify-content: flex-start;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

    .auth-shell:has(.login-emblem) .auth-brand {
        display: none;
    }

    .auth-shell:has(.login-emblem) .auth-panel {
        width: min(56%,760px);
        padding: clamp(28px,4vw,62px);
        border-radius: 34px;
        background: linear-gradient(145deg,#fffF,#f2f7ffed);
        border: 1px solid #ffffffb0;
        box-shadow: 0 22px 65px #163b7133;
    }

    .auth-shell:has(.login-emblem) .auth-panel-inner {
        width: 100%;
        max-width: 620px;
    }

.login-emblem {
    display: grid;
    place-items: center;
    margin-bottom: 12px;
}

.auth-shell:has(.login-emblem) h1 {
    text-align: center;
    color: #0d3472;
    font-size: clamp(1.4rem,2.6vw,2.3rem);
    font-weight: 700;
}

.auth-shell:has(.login-emblem) .auth-description {
    text-align: center;
    color: #34445a;
    margin: 8px 0 38px;
    font-size: clamp(.85rem,1.4vw,1.1rem);
}

.auth-shell:has(.login-emblem) .auth-field label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.auth-shell:has(.login-emblem) .auth-field input {
    min-height: 60px;
    border: 1px solid #bdc9d9;
    border-radius: 14px;
    padding-inline: 48px 16px;
    background-color: #ffffffb8;
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 22px;
}

.auth-shell:has(.login-emblem) #auth-username {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233e5065' stroke-width='1.8'%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3Cpath d='M4 22v-3a8 8 0 0 1 16 0v3z'/%3E%3C/svg%3E");
}

.auth-shell:has(.login-emblem) #auth-password {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233e5065' stroke-width='1.8'%3E%3Crect x='5' y='10' width='14' height='12' rx='2'/%3E%3Cpath d='M8 10V6a4 4 0 0 1 8 0v4M12 14v4'/%3E%3C/svg%3E");
}

.auth-shell:has(.login-emblem) .auth-password.has-reveal input {
    padding-left: 88px;
}

.auth-shell:has(.login-emblem) .auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 60px;
    border-radius: 14px;
    background: linear-gradient(180deg,#1768c4,#0b478e);
    font-size: 1.08rem;
}

    .auth-shell:has(.login-emblem) .auth-submit:hover {
        background: #0c4389;
    }

.login-features {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    border-top: 1px solid #d9e3f0;
    margin-top: 38px;
    padding-top: 25px;
}

    .login-features > div {
        display: grid;
        justify-items: center;
        gap: 8px;
        text-align: center;
        padding: 0 5px;
        font-weight: 700;
        font-size: clamp(.72rem,1.15vw,.95rem);
    }

        .login-features > div + div {
            border-inline-start: 1px solid #d9e3f0;
        }

    .login-features svg {
        width: 34px;
        height: 34px;
        color: #1456a7;
    }

@media(max-width:800px) {
    .auth-page:has(.login-emblem) {
        padding: 24px 16px;
    }

        .auth-page:has(.login-emblem)::before {
            width: 100%;
            height: 43%;
            clip-path: none;
            opacity: .55;
            background-position: center 40%;
        }

    .auth-shell:has(.login-emblem) {
        max-width: 480px;
        justify-content: center;
    }

        .auth-shell:has(.login-emblem) .auth-panel {
            width: 100%;
            padding: 30px 22px;
            border-radius: 26px;
        }

        .auth-shell:has(.login-emblem) .auth-description {
            margin-bottom: 26px;
        }

    .login-features {
        margin-top: 28px;
        padding-top: 20px;
    }

    .login-emblem svg {
        width: 65px;
        height: 65px;
    }
}

/* Corrected login composition */
.auth-page:has(.login-emblem) {
    direction: rtl;
    padding: clamp(20px,4vh,48px) 6vw;
    background: linear-gradient(145deg,#86b1e6,#dbe9fc 65%,#f4f8ff);
}

    .auth-page:has(.login-emblem)::before {
        width: 48%;
        background-size: 100% 100%;
        background-position: left center;
        clip-path: polygon(0 0,100% 0,100% 65%,72% 100%,0 100%);
    }

    .auth-page:has(.login-emblem)::after {
        bottom: -12%;
        height: 24%;
        transform: rotate(-5deg);
        box-shadow: 0 -16px 0 #83b7ed99;
    }

.auth-shell:has(.login-emblem) {
    width: 100%;
    max-width: none;
}

    .auth-shell:has(.login-emblem) .auth-panel {
        width: 54%;
        max-width: 900px;
        padding: clamp(24px,4.2vh,48px) clamp(24px,4vw,70px);
        background: linear-gradient(145deg,#f9fbff,#f0f5fd);
    }

    .auth-shell:has(.login-emblem) .auth-panel-inner {
        max-width: none;
    }

.login-emblem svg {
    width: clamp(72px,11vh,112px);
    height: clamp(72px,11vh,112px);
}

.auth-shell:has(.login-emblem) h1 {
    font-size: clamp(1.5rem,2.7vw,2.8rem);
}

.auth-shell:has(.login-emblem) .auth-description {
    margin: 8px 0 clamp(24px,5vh,52px);
}

.auth-shell:has(.login-emblem) .auth-field input {
    direction: rtl;
    text-align: right;
    padding-right: 52px;
    padding-left: 16px;
    min-height: clamp(54px,7.5vh,78px);
    font-size: clamp(1rem,1.35vw,1.3rem);
}

.auth-shell:has(.login-emblem) .auth-password.has-reveal input {
    padding-left: 56px;
}

.auth-shell:has(.login-emblem) .auth-reveal {
    min-inline-size: 44px;
    width: 44px;
    color: #3e5065;
}

.auth-reveal:not([hidden]) {
    display: grid;
    place-items: center;
}

.auth-reveal .eye-slash {
    display: none;
}

.auth-reveal[aria-pressed="true"] .eye-slash {
    display: block;
}

.auth-shell:has(.login-emblem) .auth-submit {
    min-height: clamp(54px,7.5vh,78px);
    font-size: clamp(1rem,1.45vw,1.4rem);
}

.login-features {
    margin-top: clamp(26px,5vh,55px);
    padding-top: clamp(18px,3vh,32px);
}

    .login-features svg {
        width: clamp(32px,4vh,46px);
        height: clamp(32px,4vh,46px);
    }

@media(max-width:800px) {
    .auth-page:has(.login-emblem) {
        padding: 24px 16px;
    }

        .auth-page:has(.login-emblem)::before {
            width: 100%;
            height: 45%;
            background-size: cover;
            background-position: center 55%;
            clip-path: none;
            opacity: .5;
        }

    .auth-shell:has(.login-emblem) {
        max-width: 480px;
    }

        .auth-shell:has(.login-emblem) .auth-panel {
            width: 100%;
            padding: 28px 20px;
        }

    .login-emblem svg {
        width: 72px;
        height: 72px;
    }

    .auth-shell:has(.login-emblem) h1 {
        font-size: clamp(1.25rem,5vw,1.65rem);
    }
}
.login-emblem {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    margin: 0 auto 22px;
    background: transparent;
    box-shadow: none;
}

.login-company-logo {
    display: block;
    width: 115px;
    height: 115px;
    object-fit: contain;
    mix-blend-mode: multiply;
}

@media (max-width: 600px) {
    .login-company-logo {
        width: 85px;
        height: 85px;
    }

    .login-emblem {
        margin-bottom: 16px;
    }
}
@media (min-width: 801px) {
    .auth-page:has(.login-emblem)::before {
        content: none;
        background: none;
    }

    .auth-shell:has(.login-emblem) {
        max-width: 480px;
        margin-inline: auto;
    }

    .auth-shell:has(.login-emblem) .auth-panel {
        width: 100%;
        padding: 28px 20px;
        border: 1px solid #dce6f4;
        box-shadow: 0 24px 80px #1128452b;
    }

    .auth-shell:has(.login-emblem) h1 {
        font-size: 1.65rem;
    }

    .login-company-logo {
        width: 85px;
        height: 85px;
    }

    .login-emblem {
        margin-bottom: 16px;
    }

    .auth-shell:has(.login-emblem) .auth-field input {
        min-height: 54px;
        font-size: 1rem;
        border-color: #b9cbe5;
        background-color: #f8faff;
    }

    .auth-shell:has(.login-emblem) .auth-submit {
        min-height: 54px;
        font-size: 1rem;
        background: linear-gradient(110deg, #11498f, #1769e4);
        box-shadow: 0 7px 18px #1769e42c;
    }
}
