:root {
    --ew-primary: #4f46e5;
    --ew-primary-rgb: 79, 70, 229;
    --ew-sidebar-width: 280px;
    --ew-topbar-height: 64px;
    --ew-radius: 14px;
    --ew-font: "Plus Jakarta Sans", system-ui, sans-serif;
}

[data-bs-theme="light"] {
    --ew-sidebar-bg: #0f172a;
    --ew-sidebar-text: #cbd5e1;
    --ew-sidebar-active: #ffffff;
    --ew-body-bg: #f1f5f9;
    --ew-card-bg: #ffffff;
}

[data-bs-theme="dark"] {
    --ew-sidebar-bg: #020617;
    --ew-sidebar-text: #94a3b8;
    --ew-sidebar-active: #f8fafc;
    --ew-body-bg: #0b1220;
    --ew-card-bg: #111827;
}

* { box-sizing: border-box; }

body {
    font-family: var(--ew-font);
    background: var(--ew-body-bg);
}

.app-loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, .35);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.app-loader.is-active {
    opacity: 1;
    pointer-events: auto;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--ew-sidebar-width);
    background: var(--ew-sidebar-bg);
    color: var(--ew-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    transform: translateX(0);
    transition: transform .3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand strong {
    display: block;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand small {
    opacity: .65;
    font-size: .72rem;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--ew-primary), #06b6d4);
    color: #fff;
    font-size: 1.25rem;
}

.sidebar-nav {
    flex: 1;
    overflow: auto;
    padding: .75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: 10px;
    color: var(--ew-sidebar-text);
    text-decoration: none;
    margin-bottom: .15rem;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: var(--ew-sidebar-active);
    transform: translateX(2px);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.06);
}

.app-main {
    flex: 1;
    margin-left: var(--ew-sidebar-width);
    min-width: 0;
}

.app-topbar {
    height: var(--ew-topbar-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    background: var(--ew-card-bg);
    border-bottom: 1px solid rgba(15,23,42,.08);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    animation: fadeUp .35s ease;
}

.stat-card, .card {
    border-radius: var(--ew-radius);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.page-header h1 {
    letter-spacing: -.02em;
}

.animate-in {
    animation: fadeUp .4s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-page {
    min-height: 100vh;
    position: relative;
}

.login-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(var(--ew-primary-rgb), .25), transparent 40%),
        radial-gradient(circle at 80% 0%, rgba(6,182,212,.2), transparent 35%),
        linear-gradient(160deg, #0f172a, #1e1b4b 55%, #312e81);
    z-index: -1;
}

.login-card {
    width: min(440px, 100%);
    border-radius: calc(var(--ew-radius) + 4px);
    backdrop-filter: blur(8px);
}

.login-logo {
    width: 64px;
    height: 64px;
    margin-inline: auto;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    color: #fff;
    background: linear-gradient(135deg, var(--ew-primary), #06b6d4);
}

.module-hero {
    background: linear-gradient(135deg, rgba(var(--ew-primary-rgb), .08), rgba(6,182,212,.06));
}

.module-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(var(--ew-primary-rgb), .12);
    color: var(--ew-primary);
    font-size: 1.4rem;
}

.escola-select-card {
    transition: transform .2s ease, box-shadow .2s ease;
}

.escola-select-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(15,23,42,.12) !important;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
    }
}

.doc-type-card { transition: transform .2s ease, box-shadow .2s ease; }
.doc-type-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.1) !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
