/* ==========================================================================
   Sign-in screen (also used by the offline page).
   Phone first: a centred glass card on a soft animated background.
   Tablet: the same card, centred with more room.
   Desktop (960px and up): brand panel on the left, sign-in card on the right.
   Motion is CSS only and respects prefers-reduced-motion (see app.css).
   ========================================================================== */

body.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background-color: var(--brand-100);
    background-image: linear-gradient(160deg, var(--brand-50) 0%, var(--brand-50) 46%, #fdf8ea 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

.login-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    max-width: none;
    background: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

/* Decorative drifting light, behind everything */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(42px);
    opacity: 0.6;
    will-change: transform;
    animation: orb-float 16s ease-in-out infinite alternate;
}

.orb-1 {
    width: min(72vw, 360px);
    height: min(72vw, 360px);
    top: -12%;
    left: -14%;
    background: radial-gradient(circle at 30% 30%, var(--brand-300), var(--brand-500) 58%, transparent 72%);
}

.orb-2 {
    width: min(62vw, 300px);
    height: min(62vw, 300px);
    bottom: -10%;
    right: -12%;
    opacity: 0.45;
    background: radial-gradient(circle at 60% 40%, #fde68a, #f59e0b 22%, transparent 70%);
    animation-duration: 19s;
    animation-delay: -6s;
}

.orb-3 {
    width: min(42vw, 200px);
    height: min(42vw, 200px);
    top: 44%;
    left: 56%;
    opacity: 0.5;
    background: radial-gradient(circle, var(--brand-200), transparent 70%);
    animation-duration: 13s;
    animation-delay: -3s;
}

@keyframes orb-float {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(28px, -22px, 0) scale(1.06); }
    100% { transform: translate3d(-18px, 20px, 0) scale(0.97); }
}

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

@keyframes mark-in {
    from { opacity: 0; transform: scale(0.6) rotate(-14deg); }
    to { opacity: 1; transform: none; }
}

@keyframes mark-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes shine {
    0%, 60% { left: -60%; }
    100% { left: 130%; }
}

@keyframes sheen {
    0% { left: -70%; }
    55%, 100% { left: 130%; }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(2px); }
}

/* ---------- Phone and tablet: centred card ---------- */
.login-wrap {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: calc(28px + env(safe-area-inset-top, 0px)) 18px calc(24px + env(safe-area-inset-bottom, 0px));
}

.login-brand {
    margin-bottom: 22px;
    text-align: center;
    animation: rise 640ms var(--ease-out) both;
}

.brand-mark {
    position: relative;
    overflow: hidden;
    width: 76px;
    height: 76px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: linear-gradient(140deg, var(--brand-400) 0%, var(--brand-700) 55%, var(--brand-800) 100%);
    color: #fff;
    font-size: 34px;
    box-shadow: 0 18px 34px -14px rgba(var(--brand-rgb-700), 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    animation: mark-in 800ms cubic-bezier(0.34, 1.4, 0.64, 1) both, mark-float 5s ease-in-out 1s infinite;
}

.brand-shine {
    position: absolute;
    top: -40%;
    left: -60%;
    width: 40%;
    height: 180%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: rotate(18deg);
    animation: shine 4.5s ease-in-out infinite;
    pointer-events: none;
}

.login-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #0f172a;
}

.login-sub {
    margin: 4px 0 0;
    font-size: 14.5px;
    color: #64748b;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    box-sizing: border-box;
    padding: 30px 24px 24px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.84);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 40px 70px -30px rgba(15, 23, 42, 0.35), 0 8px 20px -10px rgba(15, 23, 42, 0.12);
    animation: rise 720ms var(--ease-out) 120ms both;
}

/* A thin gold and teal line across the top of the card */
.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 28px;
    right: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, transparent, var(--brand-500), #d69e2e, transparent);
    opacity: 0.85;
}

.login-heading {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.login-lead {
    margin: 6px 0 0;
    font-size: 14.5px;
    color: #64748b;
}

.login-alert {
    margin: 18px 0 0;
    border-radius: 14px;
}

/* Fields: label above, icon on the left, show/hide on the right, one clear error line */
.field {
    margin-top: 20px;
    animation: rise 560ms var(--ease-out) both;
    animation-delay: calc(240ms + var(--i, 0) * 70ms);
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: #334155;
    letter-spacing: 0.005em;
}

.field-control {
    position: relative;
    display: flex;
    align-items: center;
}

.field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    z-index: 1;
    transform: translateY(-50%);
    font-size: 18px;
    color: #94a3b8;
    pointer-events: none;
    transition: color 200ms, transform 300ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

.field-input {
    width: 100%;
    height: 56px;
    box-sizing: border-box;
    padding: 0 16px 0 48px;
    border: 1.5px solid #dfe6ee;
    border-radius: 16px;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    font: inherit;
    font-size: 16px;
    color: #0f172a;
    transition: border-color 200ms, box-shadow 250ms, background-color 200ms;
}

.field-input.has-toggle {
    padding-right: 52px;
}

.field-input::placeholder {
    color: #a8b4c4;
}

.field-input:hover {
    border-color: #c5d2de;
}

.field-input:focus {
    outline: none;
    border-color: var(--brand-500);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(var(--brand-rgb-500), 0.18), 0 8px 18px -12px rgba(var(--brand-rgb-700), 0.5);
}

.field-control:focus-within .field-icon {
    color: var(--brand-600);
    transform: translateY(-50%) scale(1.12);
}

.field-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #64748b;
    font-size: 19px;
    transition: background-color 150ms, color 150ms, transform 150ms;
}

.field-toggle:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.field-toggle:active {
    transform: translateY(-50%) scale(0.92);
}

.field-control.is-invalid .field-input {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.14);
}

.field-control.is-invalid .field-icon {
    color: #ef4444;
}

.field-error:not(:empty) {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #b91c1c;
    animation: rise 240ms var(--ease-out) both;
}

.field-error:empty {
    display: none;
}

.caps-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12.5px;
    font-weight: 650;
    color: #b45309;
    animation: rise 240ms var(--ease-out) both;
}

/* Sign-in button: gradient, sheen, press and loading states */
.login-submit {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 56px;
    margin-top: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-700) 55%, var(--brand-800) 100%);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 750;
    letter-spacing: 0.01em;
    box-shadow: 0 18px 30px -14px rgba(var(--brand-rgb-700), 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: rise 560ms var(--ease-out) 380ms backwards;
    transition: transform 180ms var(--ease-out), box-shadow 250ms, filter 200ms, background 400ms;
    cursor: pointer;
}

.login-submit::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -70%;
    width: 60%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: sheen 3.6s ease-in-out 1s infinite;
    pointer-events: none;
}

.login-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.03);
    box-shadow: 0 24px 36px -14px rgba(var(--brand-rgb-700), 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.login-submit:active:not(:disabled) {
    transform: scale(0.98);
}

.login-submit:disabled {
    opacity: 1;
    cursor: progress;
}

.login-submit-icon {
    transition: transform 300ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

.login-submit:hover:not(:disabled) .login-submit-icon {
    transform: translateX(4px);
}

.login-submit.is-done {
    background: linear-gradient(135deg, #34d399, #059669 60%, #047857);
    box-shadow: 0 18px 30px -14px rgba(5, 150, 105, 0.8);
}

.login-submit.is-done::after {
    display: none;
}

.login-submit .spinner-border {
    width: 1.1rem;
    height: 1.1rem;
    border-width: 0.18em;
}

/* Shake the card on a failed sign-in (set by the page script) */
.login-card.is-shaking {
    animation: shake 360ms var(--ease-out);
}

/* Install option */
.login-install {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.login-install:empty {
    display: none;
}

.install-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1.5px dashed var(--brand-300);
    border-radius: 999px;
    background: rgba(240, 253, 250, 0.9);
    color: var(--brand-800);
    font: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 150ms, transform 150ms, border-color 150ms;
}

.install-btn:hover {
    background: var(--brand-100);
    border-color: var(--brand-400);
}

.install-btn:active {
    transform: scale(0.96);
}

.install-btn i {
    font-size: 17px;
    animation: bob 2.4s ease-in-out infinite;
}

.login-foot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 20px 0 0;
    max-width: 360px;
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
    color: #64748b;
    animation: rise 500ms both;
    animation-delay: 560ms;
}

.login-foot i {
    flex: 0 0 auto;
    color: var(--brand-600);
    font-size: 13px;
}

/* ---------- Tablet (768px and up): a little more room around the card ---------- */
@media (min-width: 768px) {
    .login-wrap {
        padding: 56px 32px;
    }

    .login-card {
        max-width: 460px;
        padding: 36px 34px 30px;
    }

    .login-title {
        font-size: 32px;
    }
}

/* ---------- Desktop (960px and up): brand panel on the left, card on the right ---------- */
.login-hero {
    display: none;
}

@media (min-width: 960px) {
    body.login-page .login-shell {
        display: grid;
        grid-template-columns: minmax(0, 1.1fr) minmax(440px, 540px);
        min-height: 100vh;
    }

    body.login-page .login-hero {
        position: relative;
        overflow: hidden;
        display: flex;
        align-items: center;
        padding: 64px 72px;
        color: #fff;
        background: linear-gradient(160deg, var(--brand-500) 0%, var(--brand-700) 52%, var(--brand-900) 100%);
    }

    body.login-page .login-hero::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image: radial-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1.3px);
        background-size: 18px 18px;
        -webkit-mask-image: linear-gradient(120deg, transparent 20%, #000 95%);
        mask-image: linear-gradient(120deg, transparent 20%, #000 95%);
        pointer-events: none;
    }

    body.login-page .login-hero::after {
        content: "";
        position: absolute;
        left: -120px;
        bottom: -140px;
        width: 380px;
        height: 380px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(214, 158, 46, 0.45), transparent 66%);
        animation: orb-float 14s ease-in-out infinite alternate;
        pointer-events: none;
    }

    .hero-inner {
        position: relative;
        z-index: 1;
        max-width: 540px;
        animation: rise 800ms var(--ease-out) both;
    }

    .hero-inner .brand-mark {
        width: 68px;
        height: 68px;
        margin: 0 0 26px;
        background: rgba(255, 255, 255, 0.18);
        box-shadow: none;
        font-size: 32px;
    }

    .hero-title {
        margin: 0 0 14px;
        font-size: 40px;
        font-weight: 800;
        line-height: 1.15;
        letter-spacing: -0.025em;
    }

    .hero-sub {
        margin: 0 0 34px;
        font-size: 17px;
        line-height: 1.55;
        color: rgba(255, 255, 255, 0.92);
    }

    .hero-points {
        display: grid;
        gap: 18px;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .hero-points li {
        display: flex;
        align-items: flex-start;
        gap: 14px;
        font-size: 15px;
        line-height: 1.5;
        animation: rise 600ms var(--ease-out) both;
        animation-delay: calc(300ms + var(--i, 0) * 110ms);
    }

    .hero-points i {
        flex: 0 0 auto;
        display: grid;
        place-items: center;
        width: 40px;
        height: 40px;
        border-radius: 13px;
        background: rgba(255, 255, 255, 0.16);
        font-size: 19px;
    }

    body.login-page .login-wrap {
        justify-content: center;
        padding: 56px 64px;
    }

    body.login-page .login-brand {
        display: none;
    }

    body.login-page .login-bg {
        display: none;
    }

    body.login-page .login-card {
        padding: 42px 38px 34px;
        border-radius: 30px;
        box-shadow: 0 40px 80px -30px rgba(15, 23, 42, 0.32), 0 8px 20px -10px rgba(15, 23, 42, 0.1);
    }

    body.login-page .login-heading {
        font-size: 30px;
    }

    body.login-page .login-foot {
        margin-top: 28px;
    }
}

@media (min-width: 1200px) {
    body.login-page .login-hero {
        padding: 80px 88px;
    }
}

/* ---------- Semexsoft logo on the sign-in page ---------- */
.login-logo {
    display: block;
    width: min(240px, 66vw);
    height: auto;
    margin: 0 auto 18px;
    animation: rise 640ms var(--ease-out) both;
}

.hero-logo {
    display: block;
    width: min(300px, 80%);
    height: auto;
    margin: 0 0 34px;
    animation: rise 700ms var(--ease-out) both;
}

/* ---------- Theme switch (sign-in page) ---------- */
.theme-switch {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    animation: rise 500ms both;
    animation-delay: 500ms;
}

.theme-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1.5px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    transition: border-color 150ms, color 150ms, background-color 150ms, transform 150ms, box-shadow 200ms;
}

.theme-chip:hover {
    color: var(--text);
    border-color: var(--brand-300);
}

.theme-chip:active {
    transform: scale(0.96);
}

.theme-chip:focus-visible {
    outline: 3px solid rgba(var(--brand-rgb-500), 0.45);
    outline-offset: 2px;
}

.theme-chip.active {
    color: var(--brand-800);
    border-color: var(--brand-600);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(var(--brand-rgb-500), 0.16);
}

.theme-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.1);
}

.dot-teal {
    background: linear-gradient(135deg, #14b8a6, #0f766e);
}

.dot-semexsoft {
    background: linear-gradient(135deg, #2a72a0, #002840);
}

/* ---------- Offline page (Offline.html) ---------- */
.offline-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    box-sizing: border-box;
}

.offline-card {
    width: 100%;
    max-width: 420px;
    padding: 36px 28px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 40px 70px -30px rgba(15, 23, 42, 0.3);
    text-align: center;
    animation: rise 640ms var(--ease-out) both;
}

.offline-card .brand-mark {
    margin-bottom: 20px;
}

.offline-title {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.offline-text {
    margin: 0 0 22px;
    font-size: 15px;
    line-height: 1.55;
    color: #64748b;
}
