:root {
    color-scheme: light;

    --background: #f3f7f4;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-muted: #f8faf8;
    --text: #17221b;
    --muted: #657168;
    --border: #dce5de;
    --primary: #1f6f4a;
    --primary-hover: #185c3d;
    --primary-soft: #e6f2eb;
    --focus: rgba(31, 111, 74, 0.15);
    --danger: #a83232;
    --danger-background: #fff0f0;
    --danger-border: #f0caca;
    --success: #27613e;
    --success-background: #edf8f1;
    --success-border: #c8e5d2;
    --shadow: 0 28px 80px rgba(23, 50, 34, 0.14);
}

html.dark {
    color-scheme: dark;

    --background: #101713;
    --surface: rgba(24, 24, 27, 0.97);
    --surface-muted: #202521;
    --text: #f4f4f5;
    --muted: #a1aaa4;
    --border: rgba(255, 255, 255, 0.11);
    --primary: #3b9b67;
    --primary-hover: #45ac74;
    --primary-soft: rgba(59, 155, 103, 0.14);
    --focus: rgba(69, 172, 116, 0.18);
    --danger: #f4a7a7;
    --danger-background: rgba(127, 29, 29, 0.2);
    --danger-border: rgba(248, 113, 113, 0.28);
    --success: #8ed4aa;
    --success-background: rgba(20, 83, 45, 0.22);
    --success-border: rgba(74, 222, 128, 0.22);
    --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 12%, rgba(31, 111, 74, 0.15), transparent 32rem),
        radial-gradient(circle at 88% 86%, rgba(76, 175, 80, 0.09), transparent 28rem),
        var(--background);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(31, 111, 74, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 111, 74, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    content: "";
    mask-image: radial-gradient(circle at center, #000 0, transparent 72%);
    pointer-events: none;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
}

.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding:
        max(72px, env(safe-area-inset-top))
        max(18px, env(safe-area-inset-right))
        max(30px, env(safe-area-inset-bottom))
        max(18px, env(safe-area-inset-left));
}

.theme-toggle {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(23, 50, 34, 0.08);
    cursor: pointer;
    transition:
        color 150ms ease,
        border-color 150ms ease,
        transform 150ms ease;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.theme-icon-moon,
html.dark .theme-icon-sun {
    display: none;
}

html.dark .theme-icon-moon {
    display: block;
}

.login-card {
    width: min(100%, 460px);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.login-header {
    padding: 31px 32px 23px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.brand-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.brand-logo {
    width: min(100%, 308px);
    height: auto;
    display: block;
}

.brand-logo-dark,
html.dark .brand-logo-light {
    display: none;
}

html.dark .brand-logo-dark {
    display: block;
}

.brand-description {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 550;
    line-height: 1.45;
}

.login-content {
    padding: 28px 32px 30px;
}

.login-heading {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 24px;
}

.login-heading-icon {
    width: 43px;
    height: 43px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    border-radius: 12px;
}

.login-heading-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.login-content h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.intro {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.field {
    margin-bottom: 17px;
}

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 650;
}

.field input {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    color: var(--text);
    caret-color: var(--primary);
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition:
        background 150ms ease,
        border-color 150ms ease,
        box-shadow 150ms ease;
}

.field input::placeholder {
    color: var(--muted);
    opacity: 0.68;
}

.field input:hover {
    border-color: color-mix(in srgb, var(--primary) 48%, var(--border));
}

.field input:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus);
}

.remember-row {
    display: flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    margin: 2px 0 21px;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
}

.remember-row input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--primary);
}

.form-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 2px 0 21px;
}

.form-meta-row .remember-row {
    margin: 0;
}

.form-link,
.auth-back-link {
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    text-underline-offset: 3px;
}

.form-link {
    flex: 0 0 auto;
}

.auth-back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: fit-content;
    margin: 18px auto 0;
}

.auth-back-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.password-hint {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.login-button {
    width: 100%;
    min-height: 49px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    color: #ffffff;
    background: var(--primary);
    border: 0;
    border-radius: 12px;
    box-shadow: 0 9px 22px rgba(31, 111, 74, 0.2);
    cursor: pointer;
    font-weight: 750;
    transition:
        background 150ms ease,
        box-shadow 150ms ease,
        transform 100ms ease;
}

.login-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.login-button:hover {
    background: var(--primary-hover);
    box-shadow: 0 11px 25px rgba(31, 111, 74, 0.25);
}

.login-button:active {
    transform: translateY(1px);
}

.theme-toggle:focus-visible,
.brand-link:focus-visible,
.login-button:focus-visible,
.form-link:focus-visible,
.auth-back-link:focus-visible,
.login-support a:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.error-box,
.status-box {
    margin-bottom: 19px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
}

.error-box {
    color: var(--danger);
    background: var(--danger-background);
    border: 1px solid var(--danger-border);
}

.status-box {
    color: var(--success);
    background: var(--success-background);
    border: 1px solid var(--success-border);
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 14px 20px;
    color: var(--muted);
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
    font-size: 12px;
    font-weight: 550;
}

.login-footer svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--primary);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.login-support {
    margin: 20px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.login-support a {
    color: var(--primary);
    font-weight: 700;
    text-underline-offset: 3px;
}

@media (max-width: 480px) {
    .login-page {
        justify-content: flex-start;
        padding-top: max(78px, env(safe-area-inset-top));
    }

    .theme-toggle {
        top: max(16px, env(safe-area-inset-top));
        right: max(16px, env(safe-area-inset-right));
    }

    .login-card {
        border-radius: 18px;
    }

    .login-header {
        padding: 27px 23px 21px;
    }

    .brand-logo {
        width: min(100%, 276px);
    }

    .login-content {
        padding: 25px 23px 27px;
    }

    .form-meta-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
