:root {
    --builder-bg: #eef1f6;
    --panel-bg: #ffffff;
    --panel-border: #d9dee8;
    --text-main: #172033;
    --text-muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --topbar-bg: #0f172a;
    --topbar-text: #ffffff;
    --input-bg: #ffffff;
    --input-border: #cfd6e4;
    --focus-ring: rgba(37, 99, 235, 0.16);
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
    --topbar-height: 64px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    --builder-bg: #0f172a;
    --panel-bg: #111827;
    --panel-border: #263244;
    --text-main: #e5e7eb;
    --text-muted: #94a3b8;
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --topbar-bg: #020617;
    --topbar-text: #ffffff;
    --input-bg: #0f172a;
    --input-border: #334155;
    --focus-ring: rgba(96, 165, 250, 0.2);
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    background: var(--builder-bg);
    color: var(--text-main);
}

button,
input {
    font: inherit;
}

.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: var(--topbar-height) minmax(0, 1fr);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.13), transparent 34%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent 45%),
        var(--builder-bg);
}

:root[data-theme="dark"] .auth-shell {
    background:
        radial-gradient(circle at top left, rgba(96, 165, 250, 0.18), transparent 34%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.55), transparent 45%),
        var(--builder-bg);
}

.auth-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: var(--topbar-bg);
    color: var(--topbar-text);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.auth-brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 4px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.34);
}

.auth-brand-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.auth-brand-text strong {
    font-size: 0.98rem;
    line-height: 1.2;
    white-space: nowrap;
}

.auth-brand-text small {
    color: rgba(226, 232, 240, 0.72);
    font-size: 0.78rem;
}

.auth-main {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 36px 18px;
}

.auth-card {
    width: min(100%, 440px);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    box-shadow: var(--shadow-soft);
    padding: 30px;
}

.auth-card-header {
    margin-bottom: 26px;
}

.auth-card-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

:root[data-theme="dark"] .auth-card-kicker {
    background: rgba(96, 165, 250, 0.12);
    color: var(--primary);
}

.auth-card h1 {
    margin: 16px 0 8px;
    color: var(--text-main);
    font-size: clamp(1.8rem, 4vw, 2.2rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.auth-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.5;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.auth-field {
    display: grid;
    gap: 8px;
}

.auth-field label,
.auth-recovery-box strong {
    color: var(--text-main);
    font-size: 0.86rem;
    font-weight: 750;
}

.auth-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.auth-link {
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 700;
    text-decoration: none;
}

.auth-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-field input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-main);
    padding: 11px 13px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-field input::placeholder {
    color: var(--text-muted);
    opacity: 0.78;
}

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

.auth-recovery-box {
    display: grid;
    gap: 4px;
    padding: 13px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.06);
}

:root[data-theme="dark"] .auth-recovery-box {
    background: rgba(96, 165, 250, 0.08);
}

.auth-recovery-box span {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.auth-submit {
    width: 100%;
    min-height: 48px;
    border: 0;
    border-radius: 4px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
    cursor: default;
    box-shadow: 0 14px 26px rgba(37, 99, 235, 0.22);
    transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.auth-submit:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.26);
}


.login-main {
    place-items: center;
}

.login-access-grid {
    width: min(100%, 820px);
    display: grid;
    grid-template-columns: minmax(0, 440px) minmax(0, 320px);
    align-items: stretch;
    justify-content: center;
    gap: 18px;
}

.login-admin-card,
.login-public-card {
    width: 100%;
}

.login-public-card {
    display: grid;
    align-content: center;
    gap: 0;
    padding: 24px;
}

.login-public-card-header {
    margin-bottom: 20px;
    text-align: center;
}

.login-public-card .auth-card-kicker {
    margin-inline: auto;
}

.login-public-card h2 {
    margin: 14px 0 8px;
    color: var(--text-main);
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.login-public-form {
    gap: 16px;
}

.login-public-form .auth-field {
    text-align: center;
}

.login-public-form .auth-field input {
    text-align: center;
}

.login-public-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    text-align: center;
    text-decoration: none;
}

@media (max-width: 760px) {
    .login-access-grid {
        grid-template-columns: 1fr;
        width: 100%;
        gap: 14px;
    }

    .login-public-card {
        width: 100%;
    }
}

@media (max-width: 560px) {

    .auth-topbar {
        padding: 0 16px;
    }

    .auth-brand-text strong {
        font-size: 0.9rem;
    }

    .auth-brand-text small {
        display: none;
    }

    .auth-main {
        padding: 24px 14px;
        align-items: start;
    }

    .auth-card {
        padding: 22px;
        border-radius: 6px;
    }
}

.auth-actions-row {
    display: flex;
    justify-content: center;
    margin-top: 2px;
}

.auth-helper-text {
    margin: -2px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.auth-security-box {
    display: grid;
    gap: 4px;
    padding: 13px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.06);
}

:root[data-theme="dark"] .auth-security-box {
    background: rgba(96, 165, 250, 0.08);
}

.auth-security-box strong {
    color: var(--text-main);
    font-size: 0.86rem;
    font-weight: 750;
}

.auth-security-box span {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.auth-code-field input {
    text-align: center;
    letter-spacing: 0.32em;
    font-size: 1.3rem;
    font-weight: 800;
    padding-left: 22px;
}

.auth-code-field input::placeholder {
    letter-spacing: 0.22em;
}


.auth-alert {
    margin: 0 0 18px;
    border-radius: 4px;
    padding: 12px 14px;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.45;
}

.auth-alert ul {
    margin: 0;
    padding-left: 18px;
}

.auth-alert-success {
    border: 1px solid rgba(22, 163, 74, 0.24);
    background: rgba(22, 163, 74, 0.08);
    color: #15803d;
}

.auth-alert-error {
    border: 1px solid rgba(220, 38, 38, 0.24);
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
}

:root[data-theme="dark"] .auth-alert-success {
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.22);
}

:root[data-theme="dark"] .auth-alert-error {
    color: #fecaca;
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.22);
}


.auth-secondary-button {
    min-height: 42px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text-main);
    padding: 10px 14px;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.auth-secondary-button:hover,
.auth-secondary-button:focus-visible {
    border-color: rgba(37, 99, 235, 0.42);
    color: var(--primary-dark);
    box-shadow: 0 0 0 4px var(--focus-ring);
    outline: none;
}

.auth-secondary-button:disabled {
    cursor: wait;
    opacity: 0.68;
    transform: none;
}

.auth-field select,
.auth-field textarea,
.auth-select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-main);
    padding: 11px 13px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-field textarea {
    min-height: 92px;
    resize: vertical;
    line-height: 1.45;
}

.auth-field select:focus,
.auth-field textarea:focus,
.auth-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.install-main {
    align-items: start;
}

.install-card {
    width: min(100%, 920px);
}

.install-form {
    gap: 22px;
}

.install-section {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.56);
}

:root[data-theme="dark"] .install-section {
    background: rgba(15, 23, 42, 0.34);
}

.install-section-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.install-section-number {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 850;
}

:root[data-theme="dark"] .install-section-number {
    background: rgba(96, 165, 250, 0.13);
    color: var(--primary);
}

.install-section h2,
.install-two-factor-result h2 {
    margin: 0 0 4px;
    color: var(--text-main);
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.install-section p,
.install-two-factor-result p,
.install-recovery-codes p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.45;
}

.install-section code {
    color: var(--primary-dark);
    font-weight: 800;
}

.install-grid {
    display: grid;
    gap: 16px;
}

.install-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.install-grid-compact {
    gap: 12px;
}

.install-field-full {
    grid-column: 1 / -1;
}

.install-database-options-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.install-inline-status {
    flex: 1 1 280px;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.install-inline-status-success {
    color: #15803d;
}

.install-inline-status-error {
    color: #b91c1c;
}

:root[data-theme="dark"] .install-inline-status-success {
    color: #bbf7d0;
}

:root[data-theme="dark"] .install-inline-status-error {
    color: #fecaca;
}


.install-complete-card {
    width: min(100%, 760px);
}

.install-two-factor-result {
    display: grid;
    gap: 18px;
}

.install-two-factor-qr {
    width: 260px;
    min-height: 260px;
    justify-self: center;
    display: grid;
    place-items: center;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: #ffffff;
    color: #172033;
    text-align: center;
    font-size: 0.86rem;
    line-height: 1.45;
}

.install-two-factor-qr svg {
    width: 220px;
    height: 220px;
    display: block;
}

.install-copy-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.8rem;
}

.install-recovery-codes {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    background: rgba(37, 99, 235, 0.06);
}

:root[data-theme="dark"] .install-recovery-codes {
    background: rgba(96, 165, 250, 0.08);
}

.install-recovery-codes strong {
    color: var(--text-main);
    font-size: 0.9rem;
}

.install-recovery-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.install-recovery-grid code {
    display: block;
    padding: 8px 10px;
    border-radius: 4px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    font-size: 0.78rem;
    text-align: center;
}

.install-complete-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.install-secondary-submit {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--panel-border);
    box-shadow: none;
}

.install-secondary-submit:hover {
    color: #ffffff;
}

.install-link-submit {
    display: grid;
    place-items: center;
    text-decoration: none;
    cursor: pointer;
}

@media (max-width: 760px) {
    .install-grid-two,
    .install-complete-actions,
    .install-recovery-grid {
        grid-template-columns: 1fr;
    }

    .install-card {
        padding: 22px;
    }

    .install-section {
        padding: 15px;
    }

    .install-two-factor-qr {
        width: 100%;
        max-width: 260px;
    }
}
.theme-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.theme-toggle-button:hover,
.theme-toggle-button:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.32);
    transform: translateY(-1px);
    outline: none;
}

.theme-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

.theme-toggle-label {
    line-height: 1;
}
