:root {
    --brand: #dc7100;
    --brand-dark: #c76300;
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #171717;
    --muted: #70747d;
    --line: #e4e6eb;

    --danger: #b42318;
    --danger-bg: #fef3f2;
    --success: #067647;
    --success-bg: #ecfdf3;
    --warning: #b54708;
    --warning-bg: #fffaeb;

    --shadow: 0 24px 80px rgba(15, 23, 42, .16);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Lato", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(220, 113, 0, .16), transparent 32%),
        linear-gradient(135deg, #ffffff 0%, #f4f5f7 48%, #eef0f4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-x: hidden;
}

.portal-shell {
    width: min(960px, 100%);
    min-height: 560px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(255,255,255,.82);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 32px;
    overflow: hidden;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.portal-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px;
    color: #fff;
    background:
        linear-gradient(135deg, rgba(0,0,0,.78), rgba(0,0,0,.34)),
        url('/img/bg/bg_1.jpg') center / cover no-repeat;
    overflow: hidden;
}

.portal-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 22%, rgba(220,113,0,.42), transparent 30%),
        linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,.30));
    pointer-events: none;
}

.portal-hero > * {
    position: relative;
    z-index: 1;
}

.hero-logo {
    width: 205px;
    max-width: 82%;
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,.35));
}

.hero-center {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hero-title {
    font-size: clamp(2.4rem, 5vw, 4rem);
    font-weight: 900;
    line-height: .95;
    letter-spacing: -.055em;
    margin: 0;
}

.hero-subtitle {
    font-size: 1.05rem;
    font-weight: 800;
    color: rgba(255,255,255,.82);
    margin: 0;
    letter-spacing: .02em;
    line-height: 1.45;
}

.hero-footer {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.14);
    color: rgba(255,255,255,.82);
    font-size: .84rem;
    font-weight: 900;
    letter-spacing: .02em;
}

.hero-footer.is-secure {
    background: rgba(6, 118, 71, .24);
    border-color: rgba(209, 250, 223, .24);
    color: #d1fadf;
}

.hero-footer.is-not-secure {
    background: rgba(180, 35, 24, .28);
    border-color: rgba(254, 205, 202, .28);
    color: #ffdad6;
}

.portal-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
    background: rgba(255,255,255,.94);
}

.login-card {
    width: 100%;
    max-width: 370px;
}

.mobile-logo {
    display: none;
    width: 180px;
    max-width: 78%;
    height: auto;
    margin: 0 auto 22px;
}

.panel-title {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -.04em;
    margin: 0 0 6px;
    color: #171717;
}

.panel-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-weight: 700;
}

.ens-alert {
    border-radius: 15px;
    padding: 11px 13px;
    font-size: .9rem;
    font-weight: 800;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.ens-alert-danger {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(180, 35, 24, .18);
}

.ens-alert-success {
    color: var(--success);
    background: var(--success-bg);
    border-color: rgba(6, 118, 71, .18);
}

.ens-alert-warning {
    color: var(--warning);
    background: var(--warning-bg);
    border-color: rgba(181, 71, 8, .18);
}

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: .84rem;
    font-weight: 900;
    margin-bottom: 7px;
    color: #30323a;
}

.input-wrap {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1.03rem;
    pointer-events: none;
}

.form-control {
    width: 100%;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: #fff;
    color: var(--text);
    padding: 0 14px 0 44px;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.form-control:focus {
    border-color: rgba(220, 113, 0, .78);
    box-shadow: 0 0 0 4px rgba(220, 113, 0, .17);
}

.form-control:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
}

.password-input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: 0;
    background: transparent;
    color: #858b96;
    border-radius: 10px;
    cursor: pointer;
}

.password-toggle:hover {
    background: #f4f5f7;
    color: #111827;
}

.login-button {
    width: 100%;
    height: 50px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    font-size: 1rem;
    font-weight: 900;
    font-family: inherit;
    cursor: pointer;
    margin-top: 6px;
    box-shadow: 0 14px 30px rgba(220, 113, 0, .28);
    transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.login-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(220, 113, 0, .36);
}

.login-button:disabled {
    cursor: not-allowed;
    opacity: .65;
    transform: none;
    box-shadow: none;
}

.login-footer {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(17,24,39,.08);
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .04em;
}

/* ============================================================
   LOADING
============================================================ */

#loadingOverlay[hidden] {
    display: none;
}

#loadingOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, .84);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading-box {
    width: min(310px, calc(100vw - 40px));
    background: rgba(255,255,255,.96);
    border-radius: 24px;
    padding: 28px;
    text-align: center;
    box-shadow: 0 24px 70px rgba(0,0,0,.22);
}

.loading-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(220,113,0,.18);
    border-top-color: var(--brand);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin .8s linear infinite;
}

.loading-text {
    font-weight: 900;
    color: var(--text);
}

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

/* ============================================================
   FORGOT PASSWORD
============================================================ */

.forgot-password-link {
    width: 100%;
    margin-top: 14px;
    border: 0;
    background: transparent;
    color: var(--brand-dark);
    font-family: inherit;
    font-weight: 900;
    font-size: .88rem;
    cursor: pointer;
    text-align: center;
}

.forgot-password-link:hover {
    color: var(--brand);
    text-decoration: underline;
}

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

.forgot-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.forgot-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.forgot-modal-box {
    position: relative;
    z-index: 1;
    width: min(390px, 100%);
    background: #fff;
    border-radius: 26px;
    padding: 30px 24px 24px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .30);
}

.forgot-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: #f4f5f7;
    color: #171717;
    cursor: pointer;
}

.forgot-modal-close:hover {
    background: #eceef2;
}

.forgot-modal-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    margin-bottom: 18px;
}

.forgot-modal-box h3 {
    margin: 0 0 10px;
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -.03em;
}

.forgot-modal-box p {
    margin: 0 0 20px;
    color: var(--muted);
    font-weight: 700;
    line-height: 1.55;
}

/* ============================================================
   TELEFON — JASNY FULLSCREEN Z PROSTYM PASKIEM
============================================================ */

@media (max-width: 820px) {
    :root {
        color-scheme: light;
    }

    html,
    body {
        width: 100%;
        min-height: 100%;
        height: 100%;
        background-color: #ffffff;
    }

    body {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
        color: var(--text);
        background:
            linear-gradient(135deg, rgba(0,0,0,.52), rgba(0,0,0,.24)),
            url('/img/bg/bg_1.jpg') center / cover no-repeat;
    }

    .portal-shell {
        width: 100%;
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        display: grid;
        grid-template-columns: 1fr;
        border-radius: 0;
        border: 0;
        box-shadow: none;
        overflow: hidden;
        background:
            radial-gradient(circle at top right, rgba(220,113,0,.16), transparent 34%),
            linear-gradient(180deg, rgba(255,255,255,.98), rgba(250,250,250,.96));
    }

    .portal-hero {
        display: none;
    }

    .portal-panel {
        position: relative;
        min-height: 100vh;
        min-height: 100dvh;
        width: 100%;
        padding:
            max(34px, env(safe-area-inset-top))
            22px
            max(24px, env(safe-area-inset-bottom));
        background:
            linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.92));
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

  .portal-panel::before,
.portal-panel::after {
    display: none;
    content: none;
}

    .login-card {
        position: relative;
        z-index: 1;
        max-width: 390px;
        width: 100%;
        padding: 24px 0 0;
    }

    .mobile-logo {
        display: block;
        width: 188px;
        max-width: 78%;
        height: auto;
        margin: 0 auto 34px;
        filter: drop-shadow(0 10px 22px rgba(0,0,0,.18));
    }

    .panel-title,
    .panel-subtitle {
        text-align: center;
    }

    .panel-title {
        font-size: 1.82rem;
        margin-top: 8px;
        color: #171717;
    }

    .panel-subtitle {
        margin-bottom: 22px;
        color: #5f636b;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-label {
        color: #30323a;
    }

    .form-control {
        height: 52px;
        border-radius: 17px;
        border-color: rgba(17,24,39,.10);
        background: #ffffff;
        color: var(--text);
        box-shadow: 0 8px 24px rgba(15,23,42,.05);
    }

    .form-control:focus {
        border-color: rgba(220,113,0,.82);
        background: #ffffff;
        box-shadow: 0 0 0 4px rgba(220,113,0,.17);
    }

    .login-button {
        height: 52px;
        border-radius: 17px;
        box-shadow: 0 16px 34px rgba(220,113,0,.30);
    }

    .login-footer {
        margin-top: 22px;
        color: #7b8089;
    }

    .ens-alert {
        box-shadow: 0 10px 24px rgba(15,23,42,.06);
    }
}

/* ============================================================
   TELEFON POZIOMO
============================================================ */

@media screen and (max-width: 820px) and (orientation: landscape) {
    .portal-panel {
        padding: 14px 20px;
        align-items: center;
    }

    .portal-panel::before {
        height: 72px;
        clip-path: none;
    }

    .login-card {
        max-width: 430px;
        padding-top: 0;
    }

    .mobile-logo {
        width: 132px;
        margin-bottom: 8px;
    }

    .panel-title {
        font-size: 1.35rem;
        margin-top: 0;
    }

    .panel-subtitle {
        margin-bottom: 10px;
    }

    .form-group {
        margin-bottom: 8px;
    }

    .form-control,
    .login-button {
        height: 42px;
    }

    .login-footer {
        display: none;
    }
}

/* ============================================================
   MODAL RESETU — MOBILE LIGHT
============================================================ */

@media (max-width: 820px) {
    .forgot-modal {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .forgot-modal-box {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        padding:
            max(34px, env(safe-area-inset-top))
            22px
            max(24px, env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        justify-content: center;
        background:
            radial-gradient(circle at top right, rgba(220,113,0,.14), transparent 34%),
            #ffffff;
        color: #171717;
        box-shadow: none;
    }

    .forgot-modal-icon {
        margin-left: auto;
        margin-right: auto;
    }

    .forgot-modal-box h3,
    .forgot-modal-box p {
        text-align: center;
    }

    .forgot-modal-box h3 {
        color: #171717;
    }

    .forgot-modal-box p {
        color: var(--muted);
    }
}

@media all and (display-mode: standalone) {
    body {
        background-color: #ffffff;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}