:root {
    --brand: #1d4ed8;
    --brand-light: #dbeafe;
    --bg: #f5f8fc;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;

    /* Legacy aliases */
    --lt-navy: #0f172a;
    --lt-navy-2: #1e293b;
    --lt-teal: var(--brand);
    --lt-teal-dark: #1e40af;
    --lt-emerald: var(--success);
    --lt-gold: #ea580c;
    --lt-gold-soft: #fed7aa;
    --lt-cream: var(--bg);
    --lt-ink: var(--text);
    --lt-muted: var(--muted);
    --lt-border: #e2e8f0;
    --lt-danger: var(--danger);
    --lt-radius: 12px;
    --font-sans: "DM Sans", system-ui, sans-serif;
    --font-display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: #1e40af; }

/* Auth layout — natural document scroll, no clipping */
html.auth-html {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden;
    overflow-y: auto !important;
}

.auth-body {
    min-height: 100vh;
    height: auto !important;
    max-height: none !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: visible !important;
    background: var(--bg);
    padding: 2.5rem 1rem 3rem;
}

.auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 20% 20%, rgba(59, 130, 246, 0.12), transparent 55%),
        radial-gradient(ellipse 70% 50% at 85% 75%, rgba(29, 78, 216, 0.08), transparent 50%),
        linear-gradient(160deg, #f0f5fb 0%, #f5f8fc 45%, #eff6ff 100%);
}

.auth-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(29, 78, 216, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.6;
}

.auth-shell {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    max-width: 700px;
    margin: 0 auto;
    padding: 0;
    flex: 0 0 auto;
}

/* Installer needs a wider card for the full form */
.auth-shell--wide,
.auth-shell:has(.installer-page) {
    width: min(700px, 100%);
}

.auth-mark {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.75rem;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: 2rem;
    color: #ffffff;
    background: var(--brand);
    box-shadow: 0 8px 24px rgba(29, 78, 216, 0.25);
}

.auth-logo {
    display: block;
    max-height: 72px;
    max-width: min(220px, 70vw);
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto 0.75rem;
}

.auth-title {
    font-family: var(--font-display);
    font-size: 2.6rem;
    color: var(--text);
    margin: 0;
    letter-spacing: 0.02em;
}

.auth-tagline {
    color: var(--muted);
    font-size: 0.95rem;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--lt-border);
}

.auth-card h2 {
    font-family: "Outfit", var(--font-sans);
    font-weight: 700;
    font-size: 1.35rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.auth-footer-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
    position: relative;
}

.auth-lang { margin: 0; padding: 0; }

.auth-lang a {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.4rem;
}
.auth-lang a.active,
.auth-lang a:hover { color: var(--brand); }

.auth-theme-toggle {
    position: absolute;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--lt-border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.auth-shell--wide .auth-brand { margin-bottom: 0.85rem !important; }
.auth-shell--wide .auth-mark {
    width: 52px;
    height: 52px;
    font-size: 1.65rem;
    margin-bottom: 0.5rem;
}
.auth-shell--wide .auth-title { font-size: 2.15rem; }
.auth-card--wizard { padding: 1.35rem 1.5rem; }

/* —— Installation wizard —— */
.wiz-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    margin-bottom: 1rem;
}
.wiz-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    opacity: 0.55;
}
.wiz-step.active,
.wiz-step.done { opacity: 1; }
.wiz-step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.85rem;
    background: #e8eef2;
    color: var(--lt-navy);
}
.wiz-step.active .wiz-step-num {
    background: linear-gradient(135deg, var(--lt-teal), var(--lt-emerald));
    color: #fff;
}
.wiz-step.done .wiz-step-num {
    background: var(--lt-teal-dark);
    color: #fff;
}
.wiz-step-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--lt-muted);
    text-align: center;
}
.wiz-step.active .wiz-step-label { color: var(--lt-navy); }
.wiz-step-line {
    flex: 1;
    height: 2px;
    background: #e0e7ec;
    margin-bottom: 1.1rem;
}
.wiz-step.done + .wiz-step-line,
.wiz-step.active + .wiz-step-line { background: var(--lt-teal); }

.wiz-progress { height: 6px; border-radius: 99px; background: #e8eef2; }
.wiz-progress .progress-bar {
    background: linear-gradient(90deg, var(--lt-teal), var(--lt-emerald));
    border-radius: 99px;
}

.wiz-title {
    font-size: 1.25rem !important;
    margin-bottom: 0.25rem !important;
}
.wiz-sub {
    color: var(--lt-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.wiz-status {
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.wiz-status.ok { background: #d1fae5; color: #065f46; }
.wiz-status.fail { background: #fee2e2; color: #991b1b; }

.wiz-req-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}
.wiz-req-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    border: 1px solid var(--lt-border);
    background: #f8fafb;
}
.wiz-req-detail { font-size: 0.78rem; color: var(--lt-muted); margin-top: 0.15rem; }
.wiz-optional { font-size: 0.65rem; vertical-align: middle; margin-left: 0.35rem; }
.wiz-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}
.wiz-badge.pass { background: #d1fae5; color: #065f46; }
.wiz-badge.fail { background: #fee2e2; color: #991b1b; }

.wiz-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}
.btn-outline-lottery {
    border: 1.5px solid var(--lt-teal);
    color: var(--lt-teal-dark);
    font-weight: 600;
    border-radius: 12px;
}
.btn-outline-lottery:hover {
    background: rgba(13, 148, 136, 0.08);
    color: var(--lt-teal-dark);
    border-color: var(--lt-teal-dark);
}

.wiz-alert {
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.wiz-alert.ok { background: #d1fae5; color: #065f46; }
.wiz-alert.fail { background: #fee2e2; color: #991b1b; }

.wiz-env-box {
    border: 1px solid var(--lt-border);
    background: #f8fafb;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}
.wiz-env-notes {
    margin: 0;
    padding-left: 1.1rem;
}
.wiz-env-notes li { margin-bottom: 0.25rem; }

.wiz-db-result {
    border-radius: 12px;
    padding: 0.9rem 1rem;
    font-size: 0.9rem;
}
.wiz-db-result.ok { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.wiz-db-result.fail { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }
.wiz-db-title { font-weight: 700; margin-bottom: 0.35rem; }
.wiz-db-result ul { padding-left: 1.2rem; }
.wiz-db-result details { margin-top: 0.5rem; }
.wiz-db-result code {
    display: block;
    margin-top: 0.35rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
}
.wiz-sql-box {
    margin-top: 0.75rem;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.65);
    padding: 0.65rem 0.75rem;
}
.wiz-sql-box pre {
    margin: 0.4rem 0 0.65rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
    max-height: 220px;
    overflow: auto;
}
.wiz-db-result.ok .wiz-sql-box,
.wiz-db-result.fail .wiz-sql-box {
    background: rgba(255, 255, 255, 0.55);
}
.wiz-pass-once {
    margin-top: 1.25rem;
    border: 1px solid #f59e0b;
    background: #fffbeb;
    color: #78350f;
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.wiz-pass-once-title {
    font-weight: 700;
    margin-bottom: 0.35rem;
}
html.theme-dark .wiz-pass-once {
    background: #3b2f14;
    border-color: #b45309;
    color: #fde68a;
}
html.theme-dark .wiz-sql-box {
    background: #0d1826;
    border-color: #2a3d55;
}
.wiz-preset-results {
    border: 1px solid var(--lt-border);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    background: #fff;
}

html.theme-dark .wiz-env-box,
html.theme-dark .wiz-preset-results {
    background: #0d1826;
    border-color: #2a3d55;
    color: #e8eef5;
}

.wiz-divider { border-color: var(--lt-border); opacity: 1; margin: 0.25rem 0; }

.wiz-logo-preview img {
    max-height: 72px;
    max-width: 180px;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid var(--lt-border);
    padding: 0.35rem;
    background: #fff;
}

.password-meter {
    height: 6px;
    background: #e8eef2;
    border-radius: 99px;
    overflow: hidden;
}
.password-meter-bar {
    height: 100%;
    width: 0;
    border-radius: 99px;
    transition: width 0.2s ease, background 0.2s ease;
}

.wiz-install-current {
    font-weight: 600;
    color: var(--lt-navy);
    margin-bottom: 0.75rem;
}
.wiz-install-log {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
    max-height: 280px;
    overflow-y: auto;
}
.wiz-install-log li {
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    font-size: 0.9rem;
    background: #f8fafb;
    border: 1px solid var(--lt-border);
}
.wiz-install-log li.ok { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.wiz-install-log li.fail { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.wiz-install-log li.skip { color: var(--lt-muted); }
.wiz-install-log li.running { border-color: #99f6e4; background: #f0fdfa; }

/* Dark mode (auth / installer) */
html.theme-dark .auth-card {
    background: #132033;
    border-color: rgba(255,255,255,0.08);
    color: #e8eef5;
}
html.theme-dark .auth-card h2,
html.theme-dark .wiz-title,
html.theme-dark .wiz-step.active .wiz-step-label,
html.theme-dark .wiz-install-current,
html.theme-dark .form-label { color: #f3f7fb !important; }
html.theme-dark .wiz-sub,
html.theme-dark .form-text,
html.theme-dark .text-muted { color: #9aadc0 !important; }
html.theme-dark .form-control,
html.theme-dark .form-select {
    background: #0d1826;
    border-color: #2a3d55;
    color: #e8eef5;
}
html.theme-dark .form-control:focus,
html.theme-dark .form-select:focus {
    background: #0d1826;
    color: #e8eef5;
    border-color: var(--lt-teal);
    box-shadow: 0 0 0 0.2rem rgba(13,148,136,0.2);
}
html.theme-dark .wiz-req-list li,
html.theme-dark .wiz-install-log li {
    background: #0d1826;
    border-color: #2a3d55;
}
html.theme-dark .wiz-step-num { background: #24374f; color: #d7e4f0; }
html.theme-dark .wiz-step-line { background: #2a3d55; }
html.theme-dark .wiz-progress { background: #24374f; }
html.theme-dark .password-meter { background: #24374f; }
html.theme-dark .wiz-divider { border-color: #2a3d55; }
html.theme-dark .btn-outline-secondary {
    border-color: #3d5570;
    color: #d7e4f0;
}
html.theme-dark .wiz-logo-preview img { background: #0d1826; border-color: #2a3d55; }

@media (max-width: 768px) {
    .auth-body {
        padding: 1.75rem 1rem 2.5rem;
    }

    .auth-card {
        padding: 1.35rem;
        border-radius: 16px;
    }

    .auth-title {
        font-size: 2.2rem;
    }

    .auth-mark {
        width: 56px;
        height: 56px;
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .auth-body {
        padding: 1.25rem 0.75rem 2rem;
    }

    .auth-card {
        padding: 1.1rem;
    }

    .auth-title {
        font-size: 1.9rem;
    }

    .auth-tagline {
        font-size: 0.85rem;
    }

    .wiz-step-label { font-size: 0.65rem; }
    .auth-card--wizard { padding: 1.1rem; }
    .wiz-actions { flex-direction: column-reverse; align-items: stretch; }
    .wiz-actions .btn { width: 100%; }
}

.btn-lottery {
    background: var(--brand);
    border: none;
    color: #fff;
    font-weight: 600;
    padding: 0.7rem 1.25rem;
    border-radius: 10px;
}
.btn-lottery:hover {
    background: #1e40af;
    color: #fff;
}

.btn-gold {
    background: linear-gradient(135deg, #e8c547, var(--lt-gold));
    border: none;
    color: var(--lt-navy);
    font-weight: 700;
}

.form-label { font-weight: 600; font-size: 0.9rem; color: var(--lt-navy-2); }
.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--lt-border);
    padding: 0.65rem 0.85rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(29, 78, 216, 0.15);
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--lt-muted);
    font-weight: 700;
    white-space: nowrap;
}

.badge-status {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--lt-muted);
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(13,148,136,0.12), transparent 50%),
        var(--lt-cream);
    text-align: center;
    padding: 2rem;
}
.error-page .code {
    font-family: var(--font-display);
    font-size: clamp(5rem, 16vw, 8rem);
    line-height: 1;
    color: var(--lt-navy);
    margin: 0;
}
.error-page h1 { font-family: "Outfit", sans-serif; margin: 0.5rem 0 1rem; }
