:root {
    color-scheme: light;
    --theme-bg: #f6f8fb;
    --theme-surface: #ffffff;
    --theme-surface-muted: #f8fafc;
    --theme-surface-raised: #ffffff;
    --theme-text: #0f172a;
    --theme-text-muted: #475569;
    --theme-text-subtle: #64748b;
    --theme-border: #dbe3ed;
    --theme-border-strong: #cbd5e1;
    --theme-input-bg: #ffffff;
    --theme-link: var(--tenant-primary-readable-light, #1b293c);
    --theme-focus: rgba(var(--tenant-primary-rgb, 27, 41, 60), 0.24);
    --theme-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --theme-success-bg: #ecfdf5;
    --theme-success-text: #047857;
    --theme-warning-bg: #fffbeb;
    --theme-warning-text: #b45309;
    --theme-danger-bg: #fef2f2;
    --theme-danger-text: #be123c;
    --theme-info-bg: #eff6ff;
    --theme-info-text: #1d4ed8;
    --tenant-primary-readable: var(--tenant-primary-readable-light, var(--tenant-primary, #1b293c));
    --auth-page-bg: linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
    --auth-panel-bg: rgba(255, 255, 255, 0.94);
    --auth-panel-border: #d9e2ec;
    --auth-panel-shadow: 0 32px 80px rgba(15, 23, 42, 0.12);
    --auth-muted: #64748b;
    --auth-heading: #0f172a;
}

html.dark {
    color-scheme: dark;
    --theme-bg: #0b1120;
    --theme-surface: #111827;
    --theme-surface-muted: #1e293b;
    --theme-surface-raised: #172033;
    --theme-text: #f8fafc;
    --theme-text-muted: #cbd5e1;
    --theme-text-subtle: #94a3b8;
    --theme-border: #334155;
    --theme-border-strong: #475569;
    --theme-input-bg: #0f172a;
    --theme-link: var(--tenant-primary-readable-dark, #93c5fd);
    --theme-focus: rgba(147, 197, 253, 0.28);
    --theme-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
    --theme-success-bg: rgba(6, 95, 70, 0.34);
    --theme-success-text: #bbf7d0;
    --theme-warning-bg: rgba(146, 64, 14, 0.34);
    --theme-warning-text: #fde68a;
    --theme-danger-bg: rgba(159, 18, 57, 0.32);
    --theme-danger-text: #fecdd3;
    --theme-info-bg: rgba(30, 64, 175, 0.34);
    --theme-info-text: #bfdbfe;
    --tenant-primary-readable: var(--tenant-primary-readable-dark, #93c5fd);
    --auth-page-bg: linear-gradient(180deg, #0b1120 0%, #111827 100%);
    --auth-panel-bg: rgba(17, 24, 39, 0.94);
    --auth-panel-border: #334155;
    --auth-panel-shadow: 0 32px 80px rgba(0, 0, 0, 0.42);
    --auth-muted: #cbd5e1;
    --auth-heading: #f8fafc;
}

html,
body {
    background: var(--theme-bg);
}

body {
    color: var(--theme-text);
}

.auth-page {
    min-height: 100vh;
    background: var(--auth-page-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-container {
    width: 100%;
    max-width: 31rem;
}

.auth-container-wide {
    max-width: 54rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-panel-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 0.35rem;
}

.auth-brand-logo {
    display: inline-flex;
    justify-content: center;
    width: min(26rem, 100%);
    height: 5.5rem;
    overflow: hidden;
}

.auth-brand-logo-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.auth-brand-logo-dark {
    display: none;
}

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

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

.auth-brand-badge {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    border-radius: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #1b293c 0%, #223752 100%);
    color: #fff;
    box-shadow: 0 18px 32px rgba(27, 41, 60, 0.18);
}

.auth-brand-title {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--auth-heading);
}

.auth-brand-title:focus,
.auth-panel-title:focus {
    outline: none;
}

.auth-brand-subtitle {
    margin-top: 0.35rem;
    font-size: 0.95rem;
    color: var(--auth-muted);
    font-weight: 500;
}

.sidebar-brand-logo {
    display: inline-flex;
    align-items: center;
    width: min(10.7rem, 100%);
    height: 3.25rem;
    min-width: 0;
    overflow: hidden;
}

.sidebar-brand-logo-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: left center;
}

.sidebar-brand-logo-dark {
    display: none;
}

.sidebar-brand-logo-light {
    transform: translateY(-0.38rem);
}

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

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

.auth-panel {
    background: var(--auth-panel-bg);
    border: 1px solid var(--auth-panel-border);
    border-radius: 1.5rem;
    box-shadow: var(--auth-panel-shadow);
    backdrop-filter: blur(10px);
}

.auth-panel-body {
    padding: 1.55rem 2rem 1.35rem;
}

.auth-panel-title {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--auth-heading);
}

.auth-panel-intro {
    text-align: center;
}

.auth-panel-subtitle {
    margin-top: 0;
    color: var(--auth-muted);
    font-size: 0.98rem;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.auth-field-label {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: #334155;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    color: #64748b;
    font-size: 1.1rem;
    line-height: 1;
    pointer-events: none;
}

.auth-input {
    width: 100%;
    min-height: 3.5rem;
    border-radius: 0.95rem;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    padding: 0.95rem 1rem 0.95rem 3.2rem;
    font-size: 0.95rem;
    box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.auth-input-has-toggle {
    padding-right: 3.4rem;
}

.auth-input:focus {
    border-color: rgba(27, 41, 60, 0.45);
    box-shadow: 0 0 0 4px rgba(27, 41, 60, 0.08);
    outline: none;
}

.auth-input-toggle {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #64748b;
    transition: background 0.2s ease, color 0.2s ease;
}

.auth-input-toggle:hover:not(:disabled) {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
}

.auth-input-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(27, 41, 60, 0.08);
}

.auth-input-toggle:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-otp-card {
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 1.5rem;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.auth-otp-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #94a3b8;
}

.auth-otp-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.6rem;
    width: 100%;
}

.auth-otp-input {
    width: 100% !important;
    min-width: 0;
    min-height: 3.6rem;
    padding: 0;
    border-radius: 1rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.auth-otp-input:focus {
    background: #fff;
    border-color: rgba(27, 41, 60, 0.5);
    box-shadow: 0 0 0 4px rgba(27, 41, 60, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.auth-otp-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.auth-form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.05rem;
}

.auth-turnstile-shell,
.auth-turnstile-frame {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}

.auth-turnstile-frame {
    line-height: 0;
}

.auth-turnstile-frame > div {
    width: 100% !important;
    max-width: 100% !important;
}

.auth-turnstile-frame iframe {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    clip-path: inset(2px);
}

.auth-actions-row {
    margin-top: 0.15rem;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: #475569;
    font-size: 0.92rem;
}

.auth-check input {
    width: 1rem;
    height: 1rem;
    border-radius: 0.3rem;
}

.auth-check span {
    line-height: 1;
}

.auth-link {
    color: #1b293c;
    font-weight: 700;
    font-size: 0.92rem;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-submit {
    width: 100%;
    min-height: 3.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border: 0;
    border-radius: 1rem;
    background: linear-gradient(180deg, #1b293c 0%, #223752 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.96rem;
    letter-spacing: 0.01em;
    box-shadow: 0 18px 34px rgba(27, 41, 60, 0.18);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.auth-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 22px 36px rgba(27, 41, 60, 0.22);
}

.auth-submit:disabled {
    opacity: 0.65;
    box-shadow: none;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--theme-text-subtle);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--theme-border);
}

.auth-footer-copy {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--auth-muted);
    font-size: 0.8rem;
}

.auth-status {
    min-height: 100vh;
    background: var(--auth-page-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-status-card {
    text-align: center;
    padding: 2rem;
    background: var(--auth-panel-bg);
    border: 1px solid var(--auth-panel-border);
    border-radius: 1.5rem;
    box-shadow: var(--auth-panel-shadow);
}

.auth-status-card h1 {
    color: var(--auth-heading);
    font-size: 1.35rem;
    font-weight: 800;
}

.auth-status-card p {
    margin-top: 0.5rem;
    color: var(--auth-muted);
}

.icon-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.icon-input-icon {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    color: #94a3b8;
    font-size: 1.05rem;
    line-height: 1;
    pointer-events: none;
}

.icon-input-icon.is-textarea {
    top: 1rem;
    transform: none;
}

.icon-input {
    padding-left: 2.85rem !important;
}

.icon-input.icon-input-textarea {
    padding-top: 0.85rem;
}

.toolbar-search {
    position: relative;
}

.toolbar-search-input {
    min-height: 2.75rem;
    padding-left: 2.9rem !important;
}

.auth-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auth-stepper-line {
    width: 3rem;
    height: 2px;
    background: #dbe4ee;
}

.auth-stepper-line.is-complete {
    background: #10b981;
}

.tenant-branding-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
}

.tenant-branding-preview {
    display: flex;
    min-height: 24rem;
    flex-direction: column;
    height: 100%;
}

.tenant-branding-preview-stage {
    min-height: 18rem;
}

.tenant-branding-preview-caption {
    margin-top: 1rem;
    line-height: 1.4;
}

.tenant-branding-controls {
    min-width: 0;
}

.tenant-branding-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

@media (min-width: 768px) {
    .tenant-branding-grid {
        grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
        align-items: start;
    }

    .tenant-branding-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (max-width: 640px) {
    .auth-panel-body {
        padding: 1.5rem;
    }

    .auth-brand-title {
        font-size: 1.7rem;
    }

    .auth-panel-title {
        font-size: 1.55rem;
    }

    .auth-otp-card {
        padding: 0.85rem;
    }

    .auth-otp-grid {
        gap: clamp(0.3rem, 1.8vw, 0.45rem);
    }

    .auth-otp-input {
        min-height: clamp(2.75rem, 12vw, 3.15rem);
        font-size: clamp(1.05rem, 5vw, 1.2rem);
        border-radius: 0.9rem;
    }
}

html.dark .bg-white,
html.dark .bg-slate-50\/80,
html.dark .bg-white\/95 {
    background-color: var(--theme-surface) !important;
}

html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .bg-slate-50\/70,
html.dark .bg-slate-100\/80 {
    background-color: var(--theme-surface-muted) !important;
}

html.dark .text-slate-950,
html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700 {
    color: var(--theme-text) !important;
}

html.dark .text-slate-600,
html.dark .text-slate-500,
html.dark .text-slate-400 {
    color: var(--theme-text-muted) !important;
}

html.dark .border-slate-100,
html.dark .border-slate-200,
html.dark .border-slate-300 {
    border-color: var(--theme-border) !important;
}

html.dark .shadow-sm,
html.dark .shadow-lg,
html.dark .shadow-2xl {
    box-shadow: var(--theme-shadow) !important;
}

html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-white:hover {
    background-color: var(--theme-surface-muted) !important;
}

html.dark input,
html.dark select,
html.dark textarea,
html.dark .form-input,
html.dark .form-select,
html.dark .auth-input,
html.dark .auth-otp-input {
    background-color: var(--theme-input-bg) !important;
    border-color: var(--theme-border-strong) !important;
    color: var(--theme-text) !important;
}

html.dark input::placeholder,
html.dark textarea::placeholder,
html.dark .auth-input::placeholder {
    color: var(--theme-text-subtle) !important;
}

html.dark a,
html.dark .auth-link,
html.dark .text-primary {
    color: var(--theme-link) !important;
}

html.dark .auth-brand-title,
html.dark .auth-panel-title,
html.dark .auth-status-card h1,
html.dark .auth-field-label {
    color: var(--theme-text) !important;
}

html.dark .auth-brand-subtitle,
html.dark .auth-panel-subtitle,
html.dark .auth-status-card p,
html.dark .auth-check,
html.dark .auth-footer-copy,
html.dark .auth-input-icon,
html.dark .auth-input-toggle,
html.dark .icon-input-icon {
    color: var(--theme-text-muted) !important;
}

html.dark .auth-panel,
html.dark .auth-status-card,
html.dark .auth-otp-card,
html.dark .tenant-branding-preview {
    background-color: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
}

html.dark .auth-submit,
html.dark .btn-primary {
    color: var(--tenant-primary-foreground, #ffffff) !important;
}

html.dark .auth-divider::before,
html.dark .auth-divider::after,
html.dark .auth-stepper-line {
    background: var(--theme-border) !important;
}

html.dark .badge-success,
html.dark .bg-emerald-50 {
    background-color: var(--theme-success-bg) !important;
    color: var(--theme-success-text) !important;
}

html.dark .badge-warning,
html.dark .bg-amber-50,
html.dark .bg-orange-50 {
    background-color: var(--theme-warning-bg) !important;
    color: var(--theme-warning-text) !important;
}

html.dark .badge-danger,
html.dark .bg-rose-50,
html.dark .bg-red-50 {
    background-color: var(--theme-danger-bg) !important;
    color: var(--theme-danger-text) !important;
}

html.dark .badge-info,
html.dark .bg-blue-50,
html.dark .bg-sky-50 {
    background-color: var(--theme-info-bg) !important;
    color: var(--theme-info-text) !important;
}
