:root {
    --brand-900: #3f0d18;
    --brand-700: #6f1b2d;
    --brand-500: #98283e;
    --accent-500: #d49f1e;
    --ink-900: #101828;
    --ink-700: #344054;
    --ink-500: #667085;
    --line: #d0d5dd;
    --surface-100: #f8fafc;
    --surface-200: #eef2f7;
    --surface-300: #e4eaf2;
    --white: #ffffff;
    --success: #198754;
    --warning: #d89f00;
    --danger: #c93c3c;
    --sidebar-width: 278px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: 'Outfit', 'Segoe UI', Tahoma, sans-serif;
    color: var(--ink-900);
    background: var(--surface-100);
}

.app-bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 15% 15%, rgba(152, 40, 62, 0.08), transparent 35%),
        radial-gradient(circle at 85% 10%, rgba(212, 159, 30, 0.08), transparent 34%),
        linear-gradient(180deg, #f9fbff 0%, #f1f5fb 100%);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--brand-900) 0%, #250912 100%);
    color: var(--white);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.2rem;
    margin-right: -0.2rem;
    scrollbar-gutter: stable;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.32);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.25rem;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--accent-500), #f3cc67);
    color: #3d2a00;
}

.brand-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.brand-subtitle {
    margin: 0;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    margin: 0.95rem 0 0.8rem;
}

.sidebar-subnav {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}

.sidebar-section-title {
    margin: 0.35rem 0 0.2rem;
    padding: 0 0.35rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.56);
    font-weight: 700;
}

.nav-entry {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 0.72rem 0.85rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-entry:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.nav-entry.active {
    color: #2f1c00;
    background: linear-gradient(135deg, var(--accent-500), #f2c755);
    border-color: rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

.nav-entry.nav-entry-sub {
    padding: 0.56rem 0.72rem;
    border-radius: 10px;
    margin-left: 0.12rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.78);
}

.nav-entry.nav-entry-sub:hover {
    color: var(--white);
}

.nav-entry.nav-entry-sub.active {
    color: #2f1c00;
}

.sidebar-footer {
    margin-top: auto;
    color: rgba(255, 255, 255, 0.5);
}

.app-main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
    background: rgba(15, 23, 42, 0.72);
    color: var(--white);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.8rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-title {
    color: #e2e8f0;
    font-weight: 600;
}

.custom-breadcrumb {
    --bs-breadcrumb-divider-color: #cbd5e1;
    --bs-breadcrumb-item-active-color: #ffffff;
    margin-bottom: 0;
}

.custom-breadcrumb .breadcrumb-item,
.custom-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: #cbd5e1;
}

.role-badge {
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 0.2rem 0.65rem;
    font-size: 0.74rem;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.08);
}

.user-name {
    font-weight: 500;
}

.app-content {
    animation: fade-up 0.42s ease;
}

.app-footer {
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    color: var(--ink-500);
    font-size: 0.82rem;
    padding: 0.7rem 1.15rem;
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
}

.card-institucional {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.card-institucional .card-header {
    border-bottom: 1px solid #eceff4;
    background: linear-gradient(90deg, rgba(152, 40, 62, 0.09), rgba(212, 159, 30, 0.12));
    font-weight: 700;
}

.metric-card {
    padding: 1rem;
    border-radius: 14px;
    border: 1px solid #e8edf5;
    background: var(--white);
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}

.metric-label {
    font-size: 0.82rem;
    color: var(--ink-500);
    margin: 0;
}

.metric-value {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 800;
    color: var(--ink-900);
}

.btn-brand {
    --bs-btn-color: #ffffff;
    --bs-btn-bg: var(--brand-700);
    --bs-btn-border-color: var(--brand-700);
    --bs-btn-hover-bg: var(--brand-500);
    --bs-btn-hover-border-color: var(--brand-500);
    --bs-btn-active-bg: var(--brand-900);
    --bs-btn-active-border-color: var(--brand-900);
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-outline-brand {
    --bs-btn-color: var(--brand-700);
    --bs-btn-border-color: #c9929e;
    --bs-btn-hover-color: #ffffff;
    --bs-btn-hover-bg: var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    border-radius: 10px;
    font-weight: 600;
}

.table-institucional thead th {
    border-bottom: 2px solid #dde4ee;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.74rem;
    color: var(--ink-500);
}

.table-institucional tbody tr {
    transition: background 0.2s ease;
}

.table-institucional tbody tr:hover {
    background: #f8fbff;
}

.attendance-note-wrap.is-hidden {
    display: none;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    font-size: 0.76rem;
    padding: 0.2rem 0.62rem;
    border: 1px solid transparent;
}

.status-pill.success {
    color: #0f5132;
    background: #d1f4e0;
    border-color: #9fe1bf;
}

.status-pill.warning {
    color: #7a5200;
    background: #ffecc2;
    border-color: #f3d58a;
}

.status-pill.danger {
    color: #7f1d1d;
    background: #fde1e1;
    border-color: #f6b7b7;
}

.reveal {
    opacity: 0;
    transform: translateY(10px);
    animation: fade-up 0.45s ease forwards;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(430px, 100%);
    border-radius: 16px;
    border: 1px solid #e7ecf4;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
    box-shadow: 0 20px 36px rgba(15, 23, 42, 0.12);
    padding: 1.2rem;
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.auth-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
    border: 1px solid #e5e7eb;
}

.auth-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
}

.auth-subtitle {
    margin: 0;
    color: var(--ink-500);
    font-size: 0.9rem;
}

.auth-form {
    display: grid;
    gap: 0.8rem;
}

.auth-hint {
    margin-top: 0.9rem;
    color: var(--ink-500);
    font-size: 0.85rem;
    margin-bottom: 0;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: -100%;
        width: 82%;
        max-width: 330px;
        height: 100vh;
        z-index: 999;
        transition: left 0.25s ease;
    }

    .app-shell.sidebar-open .app-sidebar {
        left: 0;
    }

    .app-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 767.98px) {
    .attendance-table thead {
        display: none;
    }

    .attendance-table tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #e4eaf2;
        border-radius: 12px;
        background: #fff;
    }

    .attendance-table tbody tr td {
        display: block;
        width: 100%;
        border: 0;
        padding: 0.55rem 0.75rem;
    }

    .attendance-table tbody tr td + td {
        border-top: 1px solid #edf1f6;
    }

    .attendance-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--ink-500);
        margin-bottom: 0.2rem;
        font-weight: 700;
    }

    .attendance-table .attendance-status,
    .attendance-table .attendance-note {
        width: 100%;
    }
}
