/* LoginV3 refinements: quiet surfaces, clear controls, and restrained brand accents. */
:root { --login-v3-focus: #2596be; }

body.login-v3-page {
    --preview-focus: #2596be;
    --bg-body: linear-gradient(135deg, #ffeecd 0%, #ffe4b3 100%);
    --bg-card: radial-gradient(circle at 0% 0%, rgba(250, 174, 66, .06), transparent 55%), #ffffff;
    --border-card: 1px solid #f5e6d3;
    --shadow-card: 0 18px 40px rgba(30, 41, 59, .16);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bg-input: #fffbf5;
    --border-input: #e8d5bb;
    --border-input-hover: #d4b896;
    --input-text: #334155;
    --input-placeholder: #64748b;
    --icon-color: #64748b;
    --icon-focus: #faae42;
    --bg-autofill: #fffbf5;
    --text-autofill: #334155;
    --bg-option: #ffffff;
    --concave-color: #ffffff;
    --bg-form-accent: none;
    --link-color: #1e293b;
    --link-hover: #9a5200;
    --bg-bubble: #1e293b;
    --text-bubble: #ffffff;
    --arrow-bubble: #1e293b;
    --bg-error: #fef2f2;
    --border-error: #fecaca;
    --text-error: #991b1b;
    --version-bg: rgba(0, 0, 0, .05);
    --toggle-bg: #e8d5bb;
    --toggle-handle: #ffffff;
    --button-bg: #faae42;
    --button-hover: #e69a2e;
    --button-text: #1e293b;
    --accent-soft: #ffeecd;
    --accent-border: #faae42;
    --footer-border: #f5e6d3;
    background: var(--bg-body);
    color: var(--text-primary);
    color-scheme: light;
    padding: 40px 24px;
    overflow: auto;
}

html[data-theme="dark"] body.login-v3-page {
    --bg-body: radial-gradient(circle at 90% 10%, rgba(234, 88, 12, .1), transparent 40%), linear-gradient(135deg, #0f172a 0%, #334155 100%);
    --bg-card: radial-gradient(circle at 0% 0%, rgba(234, 88, 12, .06), transparent 35%), #1e293b;
    --border-card: 1px solid rgba(255, 255, 255, .08);
    --shadow-card: 0 18px 40px rgba(0, 0, 0, .3);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --bg-input: #0f172a;
    --border-input: #334155;
    --border-input-hover: #475569;
    --input-text: #ffffff;
    --input-placeholder: #94a3b8;
    --icon-color: #94a3b8;
    --icon-focus: #f59e0b;
    --bg-autofill: #0f172a;
    --text-autofill: #ffffff;
    --bg-option: #0f172a;
    --concave-color: #1e293b;
    --link-color: #f59e0b;
    --link-hover: #fbd093;
    --bg-bubble: #ffffff;
    --text-bubble: #0f172a;
    --arrow-bubble: #ffffff;
    --bg-error: #3b222b;
    --border-error: #b56570;
    --text-error: #fecaca;
    --version-bg: rgba(255, 255, 255, .1);
    --toggle-bg: #334155;
    --toggle-handle: #ffffff;
    --button-bg: #faae42;
    --button-hover: #ffc26d;
    --button-text: #1e293b;
    --accent-soft: rgba(245, 158, 11, .1);
    --accent-border: #f59e0b;
    --footer-border: #334155;
    color-scheme: dark;
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

body.login-v3-page .login-v3-card {
    width: min(1000px, 100%);
    height: auto;
    min-height: 620px;
    flex-shrink: 0;
    background: var(--bg-card);
    border: var(--border-card);
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

body.login-v3-page .login-v3-card .form-section {
    width: 50%;
    min-width: 400px;
    padding: 48px 56px 34px 48px;
    background: transparent;
    color: var(--text-primary);
}

body.login-v3-page .login-v3-card .form-section::before { background: none; }
body.login-v3-page .login-v3-card .form-section::after {
    box-shadow: 0 0 0 5000px var(--concave-color);
}

body.login-v3-page .login-v3-card .logo,
body.login-v3-page .login-v3-card .title,
body.login-v3-page .login-v3-card .input-group,
body.login-v3-page .login-v3-card .login-btn,
body.login-v3-page .login-v3-card .footer {
    opacity: 1;
    animation: none;
}

body.login-v3-page .login-v3-card .logo {
    margin-bottom: 22px;
}

body.login-v3-page .login-v3-card .logo .client-logo {
    width: 250px;
    height: 70px;
    max-width: calc(100% - 28px);
    padding: 10px 14px;
    box-sizing: content-box;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(38, 38, 38, .12));
}

body.login-v3-page .login-v3-card .title {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 2rem;
    letter-spacing: -.02em;
}

body.login-v3-page .login-v3-card .portal-badge {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 7px;
    margin: 0 0 24px;
    padding: 5px 9px;
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    color: var(--text-primary);
    background: var(--accent-soft);
    font-size: 13px;
    font-weight: 600;
}

body.login-v3-page .login-v3-card .portal-badge svg { width: 16px; height: 16px; }
body.login-v3-page .login-v3-card .form-main { width: 100%; }
body.login-v3-page .login-v3-card .login-form { position: relative; z-index: 10; }

body.login-v3-page .login-v3-card .input-group {
    margin-bottom: 16px;
}

body.login-v3-page .login-v3-card .field-label {
    display: block;
    margin: 0 0 6px;
    color: var(--text-primary);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.4;
}

body.login-v3-page .login-v3-card .input-wrapper {
    height: 52px;
    padding: 0 14px;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    background: var(--bg-input);
    transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

body.login-v3-page .login-v3-card .input-wrapper:hover {
    border-color: var(--border-input-hover);
}

body.login-v3-page .login-v3-card .input-wrapper:focus-within {
    border-color: var(--login-v3-focus);
    outline: 2px solid var(--login-v3-focus);
    outline-offset: 2px;
    box-shadow: none;
}

body.login-v3-page .login-v3-card .input-wrapper input {
    color: var(--input-text);
    font-size: 1rem;
}

body.login-v3-page .login-v3-card .input-wrapper input::placeholder {
    color: var(--input-placeholder);
    opacity: 1;
}

body.login-v3-page .login-v3-card .input-wrapper input:-webkit-autofill,
body.login-v3-page .login-v3-card .input-wrapper input:-webkit-autofill:hover,
body.login-v3-page .login-v3-card .input-wrapper input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-autofill) inset;
    -webkit-text-fill-color: var(--text-autofill);
    caret-color: var(--text-autofill);
}

body.login-v3-page .login-v3-card .input-icon {
    color: var(--icon-color);
}

body.login-v3-page .login-v3-card .input-wrapper:focus-within .input-icon {
    color: var(--icon-focus);
}

body.login-v3-page .login-v3-card .password-toggle {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    margin-right: -8px;
    padding: 0;
    color: var(--icon-color);
}

body.login-v3-page .login-v3-card .password-toggle:hover .input-icon,
body.login-v3-page .login-v3-card .password-toggle:focus-visible .input-icon {
    color: var(--icon-focus);
}

body.login-v3-page .login-v3-card .company-wrapper {
    height: auto;
    min-height: 62px;
    padding: 9px 14px;
    cursor: pointer;
}

body.login-v3-page .login-v3-card .company-content { width: 100%; min-width: 0; gap: 4px; }
body.login-v3-page .login-v3-card .company-label {
    display: block;
    color: var(--text-primary);
    font-size: .8125rem;
    font-weight: 600;
}
body.login-v3-page .login-v3-card .company-select { display: block; width: 100%; cursor: pointer; }

body.login-v3-page .login-v3-card .field-error {
    display: block;
    margin-top: 5px;
    color: var(--text-error);
    font-size: 13px;
    line-height: 1.4;
}

body.login-v3-page .login-v3-card .error-box {
    position: relative;
    z-index: 3;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border-error);
    border-radius: 8px;
    background: var(--bg-error);
    color: var(--text-error);
    animation: none;
}

body.login-v3-page .login-v3-card .error-content { align-items: flex-start; min-width: 0; }
body.login-v3-page .login-v3-card .error-icon { flex-shrink: 0; margin-top: 1px; }
body.login-v3-page .login-v3-card .error-title { display: block; margin-bottom: 3px; font-size: 14px; line-height: 1.5; }
body.login-v3-page .login-v3-card .error-message { display: block; font-size: 13px; line-height: 1.5; font-weight: 400; overflow-wrap: anywhere; }
body.login-v3-page .login-v3-card .error-box .close-error {
    align-self: flex-start;
    min-width: 44px;
    min-height: 44px;
    margin: -6px -6px 0 0;
    color: inherit;
    opacity: 1;
}

body.login-v3-page .login-v3-card .input-validation-error { box-shadow: inset 0 -2px var(--text-error); }

body.login-v3-page .login-v3-card .login-status {
    margin: 0 0 16px;
    padding: 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    z-index: 3;
}

body.login-v3-page .login-v3-card .login-status:empty { display: none; }
body.login-v3-page .login-v3-card .login-status:not(:empty) {
    padding: 11px 13px;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    background: var(--bg-input);
}
body.login-v3-page .login-v3-card .login-status[data-status="processing"] {
    display: flex;
    align-items: center;
    gap: 10px;
}
body.login-v3-page .login-v3-card .login-status[data-status="processing"]::before {
    content: "";
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: login-status-spin .8s linear infinite;
}
@keyframes login-status-spin { to { transform: rotate(360deg); } }

body.login-v3-page .login-v3-card .login-btn {
    width: 100%;
    min-height: 52px;
    margin-top: 8px;
    padding: 13px 20px;
    border: 1px solid var(--button-bg);
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--button-text);
    box-shadow: none;
    font-size: 1rem;
    font-weight: 700;
    opacity: 1;
    animation: none;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

body.login-v3-page .login-v3-card .login-btn::before { display: none; }
body.login-v3-page .login-v3-card .login-btn:hover {
    background: var(--button-hover);
    border-color: var(--button-hover);
    box-shadow: 0 4px 10px rgba(38, 38, 38, .14);
    transform: none;
}
body.login-v3-page .login-v3-card .login-btn:active { transform: translateY(1px); }
body.login-v3-page .login-v3-card .login-btn:disabled { cursor: wait; opacity: .65; transform: none; }

body.login-v3-page .login-v3-card .btn-spinner {
    border: 2px solid currentColor;
    border-right-color: transparent;
    margin-right: 8px;
}

body.login-v3-page .login-v3-card .otp-resend {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}
body.login-v3-page .login-v3-card .resend-link {
    min-height: 44px;
    padding: 8px 0;
    color: var(--link-color);
    font-size: .85rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}
body.login-v3-page .login-v3-card .resend-link:hover { color: var(--link-hover); }
body.login-v3-page .login-v3-card .resend-link:disabled { cursor: wait; opacity: .6; }

body.login-v3-page .login-v3-card .footer {
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--footer-border);
}
body.login-v3-page .login-v3-card .footer p { color: var(--text-secondary); }
body.login-v3-page .login-v3-card .footer a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 3px;
}
body.login-v3-page .login-v3-card .version { background: var(--version-bg); }

body.login-v3-page .login-v3-card .image-section {
    width: 55%;
    min-height: 620px;
    margin-left: -5%;
    background: var(--accent-soft);
}
body.login-v3-page .login-v3-card .illustration-img {
    object-position: 80% 35%;
}
body.login-v3-page .login-v3-card .image-section::before {
    background: linear-gradient(90deg, var(--concave-color) 0%, transparent 100%);
}

body.login-v3-page .theme-switch-wrapper { top: 18px; right: 24px; }
body.login-v3-page .switch { width: 52px; height: 30px; }
body.login-v3-page .switch input { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; cursor: pointer; }
body.login-v3-page .slider { background: var(--toggle-bg); color: var(--text-primary); }
body.login-v3-page .slider:before { width: 22px; height: 22px; left: 4px; bottom: 4px; }
body.login-v3-page input:checked + .slider { background: var(--accent-border); }
body.login-v3-page input:checked + .slider:before { transform: translateX(22px); }
body.login-v3-page .fa-sun { color: #262626; }
body.login-v3-page .fa-moon { color: #ffffff; }

body.login-v3-page .help-bubble { color: var(--text-bubble); }
body.login-v3-page .bubble-text { animation: none; }
body.login-v3-page .mascot-img { filter: drop-shadow(0 3px 6px rgba(38, 38, 38, .16)); }

body.login-v3-page :focus-visible {
    outline: 2px solid var(--login-v3-focus);
    outline-offset: 3px;
}
body.login-v3-page .login-v3-card .input-wrapper input:focus-visible { outline: none; }
body.login-v3-page .switch input:focus-visible + .slider { outline: 2px solid var(--login-v3-focus); outline-offset: 3px; }
body.login-v3-page .input-wrapper input { caret-color: var(--text-primary); }
body.login-v3-page ::selection { background: #fbd093; color: #262626; }

/* The custom company list is appended to body, so it cannot be nested under the card. */
body.login-v3-page .company-trigger {
    min-height: 32px;
    border: 0;
    color: var(--input-text);
    background: transparent;
    text-align: left;
    justify-content: space-between;
    gap: 12px;
}
body.login-v3-page .company-trigger::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-right: 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    flex-shrink: 0;
}
body.login-v3-page .company-trigger:focus-visible { outline: none; }
body.login-v3-page .company-options {
    position: fixed;
    z-index: 10000;
    right: auto;
    border-color: var(--border-input);
    border-radius: 8px;
    background: var(--bg-option);
    box-shadow: 0 8px 18px rgba(38, 38, 38, .18);
    transform: none;
    transition: none;
}
body.login-v3-page .company-options .select-option {
    min-height: 44px;
    color: var(--input-text);
    overflow-wrap: anywhere;
}
body.login-v3-page .company-options .select-option:hover,
body.login-v3-page .company-options .select-option.active {
    color: var(--input-text);
    background: var(--accent-soft);
    box-shadow: inset 3px 0 var(--accent-border);
}

@media (min-width: 901px) {
    body.login-v3-page .login-v3-card .illustration-img { position: absolute; inset: 0; }
}

@media (max-width: 900px) {
    body.login-v3-page {
        align-items: flex-start;
        padding: 72px 16px 32px;
    }
    body.login-v3-page .login-v3-card {
        width: min(520px, 100%);
        min-height: 0;
    }
    body.login-v3-page .login-v3-card .form-section {
        width: 100%;
        min-width: 0;
        padding: 40px 32px 32px;
        order: 1;
    }
    body.login-v3-page .login-v3-card .image-section,
    body.login-v3-page .login-v3-card .form-section::after { display: none; }
    body.login-v3-page .login-v3-card .footer { flex-direction: column; text-align: center; }
    body.login-v3-page .help-bubble { display: none; }
}

@media (max-width: 480px) {
    body.login-v3-page { padding: 60px 12px 24px; }
    body.login-v3-page .login-v3-card .form-section { padding: 32px 20px 24px; }
    body.login-v3-page .login-v3-card .title { font-size: 1.75rem; }
    body.login-v3-page .login-v3-card .logo { margin-bottom: 16px; }
    body.login-v3-page .login-v3-card .logo .client-logo { padding-top: 0; padding-bottom: 0; }
    body.login-v3-page .login-v3-card .portal-badge { margin-bottom: 20px; }
    body.login-v3-page .theme-switch-wrapper { top: 16px; right: 16px; }
}

@media (max-height: 850px) and (min-width: 901px) {
    body.login-v3-page { align-items: flex-start; }
    body.login-v3-page .help-bubble { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    body.login-v3-page *,
    body.login-v3-page *::before,
    body.login-v3-page *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
