@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 100 700;
    font-display: swap;
    src: url("../fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-latin.woff2") format("woff2");
}

html.system-auth {
    --navy: #0f1b4c;
    --blue: #2445d6;
    --blue-hover: #1c38b8;
    --red: #da3448;
    --ink: #121933;
    --ink-2: #2a3249;
    --muted: #4a5370;
    --border: #d5dbe6;
    --surface-soft: #f7f9fc;
    --danger: #b3202f;
    --danger-bg: #fdebed;
    --ctl: 52px;
}

html.system-auth,
html.system-auth body {
    margin: 0;
    min-height: 100vh;
    background: #ffffff;
    color: var(--ink);
    font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

html.system-auth *,
html.system-auth *::before,
html.system-auth *::after {
    box-sizing: border-box;
}

html.system-auth ::selection {
    background: #cdd6ff;
    color: var(--navy);
}

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: clamp(24px, 4vh, 48px) 20px;
    background: #ffffff;
}

.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    max-width: 440px;
    min-height: 610px;
    padding: 48px 40px 32px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    padding-bottom: 26px;
    margin-bottom: 28px;
    border-bottom: 1px dashed var(--border);
}

.auth-logo {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
}

.auth-logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--surface-soft);
    border: 1px solid #e1e6f0;
    border-radius: 14px;
}

.auth-logo svg {
    width: 34px;
    height: 34px;
    flex: none;
}

.auth-logo-text {
    font-size: 23px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.auth-logo strong {
    color: var(--red);
    font-weight: 600;
}

.auth-header h1 {
    margin: 0;
    color: var(--ink);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.auth-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex: none;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
}

.auth-field {
    margin-bottom: 22px;
}

.auth-field label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-2);
    font-size: 14.5px;
    font-weight: 500;
}

.auth-input {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--ctl);
    padding: 0 10px 0 15px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    transition: background-color 160ms cubic-bezier(0.23, 1, 0.32, 1), border-color 160ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.auth-input:hover {
    border-color: #aeb7c8;
}

.auth-input:focus-within {
    background: #ffffff;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 69, 214, 0.15);
    color: var(--blue);
}

.auth-input.is-invalid {
    border-color: var(--red);
    color: var(--danger);
}

.auth-field-icon {
    color: var(--muted);
}

.auth-input:focus-within .auth-field-icon {
    color: var(--blue);
}

.auth-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 15.5px;
    caret-color: var(--blue);
}

.auth-input input::placeholder {
    color: #5e6885;
    opacity: 1;
}

.auth-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease, transform 150ms cubic-bezier(0.23, 1, 0.32, 1);
}

.auth-toggle:hover {
    background: #eef1f7;
    color: var(--ink);
}

.auth-toggle:active {
    transform: scale(0.96);
}

.auth-error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 26px;
    color: var(--ink-2);
    font-size: 14.5px;
    cursor: pointer;
    user-select: none;
}

.auth-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--blue);
    cursor: pointer;
}

.auth-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: var(--ctl);
    border: 1px solid var(--blue);
    border-radius: 10px;
    background: var(--blue);
    color: #ffffff;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 160ms cubic-bezier(0.23, 1, 0.32, 1), border-color 160ms cubic-bezier(0.23, 1, 0.32, 1), transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

.auth-submit:hover {
    background: var(--blue-hover);
    border-color: var(--blue-hover);
}

.auth-submit:active {
    transform: scale(0.985);
}

.auth-submit-arrow {
    width: 18px;
    height: 18px;
    transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

@media (hover: hover) and (pointer: fine) {
    .auth-submit:hover .auth-submit-arrow {
        transform: translateX(3px);
    }
}

.auth-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    color: var(--muted);
    font-size: 13px;
}

.auth-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.auth-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    background: var(--surface-soft);
    border: 1px solid #e1e6f0;
    border-radius: 6px;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 12px;
    color: var(--ink-2);
}

.auth-badge .auth-icon {
    width: 14px;
    height: 14px;
    color: var(--blue);
}

html.system-auth :focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 2px;
}

html.system-auth .auth-input input:focus-visible {
    outline: 0;
}

@media (max-width: 520px) {
    .auth-shell {
        padding: 16px;
    }

    .auth-card {
        min-height: 540px;
        padding: 36px 22px 24px;
    }

    html.system-auth {
        --ctl: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.system-auth * {
        transition-duration: 0.01ms !important;
    }
}
