:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #020617;
    color: #e2e8f0;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

* {
    box-sizing: border-box;
}

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow-y: auto;
    background:
        radial-gradient(ellipse at 15% 15%, rgba(250, 204, 21, .15), transparent 42%),
        radial-gradient(ellipse at 90% 85%, rgba(202, 138, 4, .12), transparent 40%),
        #020617;
}

.login-card {
    width: min(100%, 440px);
    padding: clamp(24px, 6vw, 40px);
    border: 1px solid #1e293b;
    border-radius: 24px;
    background: rgba(15, 23, 42, .96);
    box-shadow: 0 28px 80px rgba(0, 0, 0, .46);
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #f8fafc;
    font-size: 18px;
    font-weight: 750;
    text-decoration: none;
}

.login-brand span {
    text-align: center;
}

.login-brand img {
    width: 92px;
    height: 44px;
    padding: 5px;
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
}

.login-heading {
    margin: 34px 0 26px;
    text-align: center;
}

.login-icon {
    display: inline-grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border: 1px solid #854d0e;
    border-radius: 15px;
    background: #422006;
    color: #facc15;
    font-size: 30px;
}

.login-heading h1 {
    margin: 16px 0 7px;
    color: #f8fafc;
    font-size: 23px;
}

.login-heading p,
.login-hint {
    margin: 0;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.55;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    margin-top: 8px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 650;
}

.login-form input {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid #334155;
    border-radius: 10px;
    outline: none;
    background: #020617;
    color: #f8fafc;
    font: inherit;
    font-size: 16px;
}

.login-form input:focus {
    border-color: #facc15;
    box-shadow: 0 0 0 3px rgba(250, 204, 21, .18);
}

.password-field {
    position: relative;
    display: block;
}

.login-form .password-field input {
    padding-right: 52px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    touch-action: manipulation;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    color: #facc15;
    outline: 2px solid #854d0e;
    outline-offset: -2px;
}

.password-toggle svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.server-temperature-chart {
    width: 90px;
    height: 24px;
    margin-top: 2px;
    overflow: visible;
}

.temperature-chart-axis {
    stroke: #475569;
    stroke-width: 1;
}

.temperature-chart-line {
    fill: none;
    stroke: #34d399;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.server-temperature-range {
    max-width: 120px;
    color: #94a3b8;
    font-size: 8px;
    font-variant-numeric: tabular-nums;
}

.password-toggle .hidden {
    display: none;
}

.login-error[hidden] {
    display: none;
}

.login-hint {
    font-size: 12px;
}

.login-contact {
    margin-top: 18px;
    text-align: center;
}

.login-submit,
.login-toggle,
.login-back {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-top: 12px;
    border-radius: 10px;
    text-align: center;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
}

.login-submit {
    border: 1px solid #facc15;
    background: #facc15;
    color: #0f172a;
    cursor: pointer;
}

.login-submit:hover {
    border-color: #eab308;
    background: #eab308;
}

.login-submit:disabled {
    cursor: wait;
    opacity: .65;
}

.login-toggle,
.login-back {
    display: grid;
    place-items: center;
    border: 1px solid #334155;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    text-decoration: none;
}

.login-toggle:hover,
.login-back:hover {
    background: #1e293b;
    color: #fff;
}

.login-back {
    min-height: 42px;
    border: 0;
    color: #94a3b8;
    font-size: 13px;
}

.login-error {
    margin: 4px 0 0;
    padding: 12px;
    border: 1px solid #881337;
    border-radius: 10px;
    background: rgba(76, 5, 25, .55);
    color: #fda4af;
    font-size: 13px;
    line-height: 1.5;
}

.klic-drag-active {
    border-color: #facc15 !important;
    background-color: rgba(250, 204, 21, .1) !important;
}

.kml-drag-active {
    border-color: #34d399 !important;
    background-color: rgba(16, 185, 129, .1) !important;
}

#sidebar,
#sidebar-backdrop,
#gps-center-btn,
#layer-switch-btn,
#user-profile-btn,
#toggle-sidebar-btn {
    touch-action: manipulation;
}

#toggle-sidebar-btn,
#user-profile-btn,
#gps-center-btn,
#layer-switch-btn {
    min-height: 44px;
}

#sidebar-backdrop {
    padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 767px) {
    .app-header {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    #sidebar {
        width: min(94vw, 400px);
    }

    #sidebar {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top));
        bottom: 0;
        left: 0;
        width: min(90vw, 400px);
        height: auto;
        max-height: calc(100dvh - 56px - env(safe-area-inset-top));
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 1100;
    }

    #sidebar-backdrop {
        position: fixed;
        top: calc(56px + env(safe-area-inset-top));
        right: 0;
        bottom: 0;
        left: 0;
    }

    #gps-status-badge {
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: 12px;
    }

    .leaflet-control-zoom a {
        width: 42px !important;
        height: 42px !important;
        line-height: 42px !important;
        font-size: 22px !important;
    }

    #notification-toast {
        right: max(8px, env(safe-area-inset-right));
        left: max(8px, env(safe-area-inset-left));
        width: auto;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .login-page {
        padding: 14px;
    }

    .login-card {
        padding: 26px 20px;
        border-radius: 18px;
    }

    .login-heading {
        margin-top: 28px;
    }

    .login-brand {
        flex-direction: column;
        gap: 10px;
        font-size: 17px;
    }

    #toggle-sidebar-btn {
        padding: 8px;
    }

    @media (max-width: 360px) {
        .login-card {
            padding: 22px 16px;
        }

        .login-heading h1 {
            font-size: 21px;
        }

        #sidebar .grid-cols-4 button {
            font-size: 10px;
        }
    }

    #user-profile-btn {
        gap: 6px;
        padding: 6px 8px;
    }

    .app-header {
        gap: 6px;
    }

    .app-header .app-name {
        display: block;
        max-width: 36vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .server-status {
        font-size: 8px;
    }

    #user-name-label {
        max-width: 58px;
    }

    #layer-switch-btn,
    #gps-center-btn {
        width: 46px;
        height: 46px;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .login-page {
        place-items: start center;
    }

    .login-card {
        margin: 12px 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
