.auth-body {
    background: linear-gradient(135deg, #0b1a4a, #142f7a);
    min-height: 100vh;
    min-height: 100dvh;
    height: auto !important;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: max(1.5rem, env(safe-area-inset-top)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.auth-main {
    width: min(1200px, 100%);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: center;
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: #f5f7fa;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: clamp(1.35rem, 2vw + 1rem, 2.1rem);
    color: #0f172a;
    width: min(100%, 460px);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.auth-logo img {
    width: 56px;
    height: 56px;
}

.auth-logo h1 {
    margin: 0;
    font-size: 1.35rem;
    letter-spacing: 0.5px;
}

.auth-logo p {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-form label {
    font-weight: 600;
    color: #0f172a;
}

.auth-form input {
    padding: 0.85rem 0.95rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.auth-form input[readonly] {
    background: #f8fafc;
    color: #475569;
}

.password-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
}

.password-toggle-row input {
    width: auto;
    margin: 0;
}

.password-requirements {
    background: #f8fafc;
    border: 1px solid #dbeafe;
    color: #334155;
    border-radius: 10px;
    padding: 0.8rem 0.95rem;
    font-size: 0.95rem;
    line-height: 1.45;
}

.reset-link-textarea {
    width: 100%;
    min-height: 220px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    padding: 1rem;
    box-sizing: border-box;
    font: inherit;
    line-height: 1.5;
    background: #f8fafc;
    color: #0f172a;
}

.reset-link-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1200;
}

.reset-link-modal-card {
    width: min(720px, 100%);
    max-height: min(90vh, 820px);
    overflow: auto;
    background: #f5f7fa;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    padding: 1.2rem;
}

.reset-link-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

.reset-invite-hint {
    background: #f8fafc;
    border: 1px dashed #93c5fd;
    color: #334155;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    line-height: 1.45;
    min-height: 54px;
    box-sizing: border-box;
}

body.dark-mode .reset-link-modal-backdrop {
    background: rgba(2, 6, 23, 0.78);
}

body.dark-mode .reset-link-modal-card {
    background: #0f172a;
    color: #f8fafc;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    border: 1px solid #334155;
}

body.dark-mode .reset-link-modal-card h3 {
    color: #f8fafc;
}

body.dark-mode .reset-link-modal-card .muted {
    color: #cbd5e1;
}

body.dark-mode .reset-link-textarea {
    background: #1b1b1b;
    color: #e5e7eb;
    border-color: #334155;
}

body.dark-mode .reset-invite-hint {
    background: #1b1b1b;
    border-color: #3b82f6;
    color: #dbeafe;
}

.auth-form button {
    margin-top: 0.5rem;
    padding: 0.9rem;
    border: none;
    border-radius: 12px;
    background: #1a237e;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 8px 20px rgba(26, 35, 126, 0.25);
    width: 100%;
    touch-action: manipulation;
    scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom));
}

.auth-form button:hover {
    transform: translateY(-2px);
}

.auth-alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin: 0.5rem 0 0.75rem;
    font-weight: 600;
}

.auth-alert.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.auth-alert.info {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.auth-alert.info strong {
    margin-left: 0.25em;
}

.auth-altcha {
    margin: 0.5rem 0 0.25rem;
}

.auth-footer {
    text-align: center;
    color: #475569;
    margin: 1rem 0 0;
    font-size: 0.9rem;
}

.auth-login-button {
    justify-content: center;
    min-width: 180px;
}

.auth-redirect-countdown {
    margin: 0.75rem 0 0;
    color: #475569;
    line-height: 1.45;
}

.auth-redirect-countdown strong {
    color: #1a237e;
}

/* Rodapé do login alinhado ao painel */
.painel-footer.login-footer {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.5rem 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    align-items: center;
    margin-top: 1.5rem;
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.35);
}

.painel-footer.login-footer .footer-main-logo,
.painel-footer.login-footer .footer-logos img {
    transition: transform 0.2s ease;
}

.painel-footer.login-footer .footer-main-logo:hover,
.painel-footer.login-footer .footer-logos img:hover {
    transform: translateY(-2px);
}

.painel-footer .footer-brand { display: flex; align-items: center; gap: 0.75rem; }
.painel-footer .footer-main-logo { width: 64px; height: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35)); }
.painel-footer .footer-brand-text { display: flex; flex-direction: column; gap: 0.1rem; }
.painel-footer .footer-brand-title { margin: 0; font-size: 1rem; font-weight: 800; letter-spacing: 0.3px; }
.painel-footer .footer-brand-subtitle { margin: 0; color: #cbd5e1; }
.painel-footer .footer-meta { margin: 0; font-size: 0.95rem; line-height: 1.35; }
.painel-footer .footer-meta strong { color: #fff; }
.painel-footer .footer-meta a { color: #93c5fd; text-decoration: underline; }
.painel-footer .footer-support { display: flex; flex-direction: column; gap: 0.35rem; }
.painel-footer .footer-support-label { font-weight: 800; letter-spacing: 0.3px; }
.painel-footer .footer-logos { display: inline-flex; gap: 0.6rem; }
.painel-footer .footer-logos img { height: 42px; width: auto; filter: grayscale(0.1); background: rgba(255,255,255,0.08); padding: 0.4rem; border-radius: 10px; }

.login-access-request {
    width: fit-content;
    max-width: min(100%, 640px);
    box-sizing: border-box;
    border-radius: 999px;
    background: rgba(239, 246, 255, 0.96);
    color: #0f172a;
    border: 1px solid #bfdbfe;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}

.login-access-request[open] {
    width: min(100%, 640px);
    border-radius: 16px;
}

.login-access-request summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.6rem 0.45rem 0.55rem;
    list-style: none;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 800;
    color: #0f172a;
    user-select: none;
}

.login-access-request summary::-webkit-details-marker {
    display: none;
}

.login-access-request-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #dbeafe;
    color: #1d4ed8;
    flex-shrink: 0;
}

.login-access-request-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.login-access-request-chevron {
    width: 20px;
    height: 20px;
    fill: currentColor;
    color: #475569;
    transition: transform 0.18s ease;
}

.login-access-request[open] .login-access-request-chevron {
    transform: rotate(180deg);
}

.login-access-request-content {
    padding: 0 1rem 1rem 3.1rem;
}

.login-access-request p {
    margin: 0 0 0.55rem;
    color: #334155;
    line-height: 1.45;
}

.login-access-request a {
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 0.16em;
}

.login-access-request ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
    color: #334155;
    line-height: 1.45;
}

.login-access-request li + li {
    margin-top: 0.35rem;
}

.auth-body .nimbus-language-floating {
    top: max(12px, env(safe-area-inset-top)) !important;
    right: 12px !important;
    bottom: auto !important;
}

@media (max-width: 640px) {
    .auth-body {
        align-items: stretch;
        justify-content: flex-start;
        padding: calc(4.5rem + env(safe-area-inset-top)) 1rem calc(4rem + env(safe-area-inset-bottom));
        min-height: 100svh;
        min-height: 100dvh;
    }
    .auth-main {
        width: 100%;
        gap: 1rem;
        align-items: stretch;
    }
    .auth-container {
        order: 1;
        justify-content: flex-start;
        align-items: flex-start;
        max-width: none;
        padding: 0;
    }
    .auth-card {
        width: 100%;
        padding: 1.35rem;
        border-radius: 14px;
        box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
    }
    .auth-logo h1 { font-size: 1.2rem; }
    .auth-logo p { font-size: 0.9rem; }
    .auth-form label { font-size: 0.95rem; }
    .auth-form input { padding: 0.8rem 0.9rem; }
    .auth-form button { padding: 0.85rem; }
    .painel-footer.login-footer {
        order: 3;
        grid-template-columns: 1fr;
        text-align: center;
        padding: 1.1rem 1rem;
        gap: 0.9rem;
        border-radius: 14px;
        margin-top: 0;
    }
    .painel-footer .footer-brand { justify-content: center; }
    .painel-footer .footer-support { align-items: center; }
    .painel-footer .footer-meta { font-size: 0.9rem; }
    .painel-footer .footer-logos { justify-content: center; flex-wrap: wrap; }
    .painel-footer .footer-logos img { height: 36px; }
    .login-access-request {
        order: 2;
        width: 100%;
        max-width: none;
        border-radius: 14px;
        align-self: stretch;
    }
    .login-access-request[open] { width: 100%; }
    .login-access-request summary {
        min-height: 52px;
        padding: 0.55rem 0.8rem;
        gap: 0.55rem;
    }
    .login-access-request-content {
        width: auto;
        padding: 0 1rem 1rem;
    }
    .auth-body .nimbus-language-floating {
        top: max(12px, env(safe-area-inset-top)) !important;
        right: 12px !important;
        bottom: auto !important;
    }
}

@media (max-width: 480px) {
    .auth-body { padding: calc(4.25rem + env(safe-area-inset-top)) 0.85rem calc(4.25rem + env(safe-area-inset-bottom)); }
    .auth-main { gap: 0.85rem; }
    .auth-container { padding: 0; }
    .auth-card { padding: 1.1rem; border-radius: 12px; }
    .auth-logo img { width: 48px; height: 48px; }
    .auth-form { gap: 0.65rem; }
    .auth-form label { font-size: 0.9rem; }
    .auth-form input { font-size: 1rem; padding: 0.78rem 0.9rem; }
    .auth-form button { font-size: 1rem; box-shadow: 0 6px 16px rgba(26, 35, 126, 0.22); }
    .painel-footer.login-footer { padding: 1rem 0.85rem; gap: 0.75rem; }
    .painel-footer .footer-main-logo { width: 54px; }
    .painel-footer .footer-logos img { height: 32px; padding: 0.35rem; }
    .login-access-request summary { font-size: 0.9rem; }
    .login-access-request-icon { width: 30px; height: 30px; }
}

@media (orientation: landscape) and (min-width: 768px) {
    .auth-body { justify-content: center; }
    .auth-main { align-items: center; }
}

@media (min-width: 840px) {
    .auth-body { justify-content: center; }
    .auth-main {
        display: grid;
        grid-template-columns: minmax(360px, 520px) minmax(360px, 1fr);
        align-items: center;
        gap: 1.5rem;
    }
    .auth-container {
        max-width: none;
        padding: 1.25rem;
    }
    .auth-card { display: flex; flex-direction: column; }
    .auth-form { margin-top: auto; }
    .painel-footer.login-footer {
        margin-top: 0;
        align-self: center;
        border-radius: 16px;
        box-shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1rem;
    }
    .painel-footer.login-footer .footer-support { align-items: flex-start; }
    .painel-footer.login-footer .footer-logos { flex-wrap: wrap; }
    .login-access-request {
        grid-column: 2;
        align-self: center;
        margin-top: -17rem;
        width: fit-content;
    }
    .login-access-request[open] {
        align-self: center;
        margin-top: -10rem;
        width: min(100%, 640px);
    }
}

/* Intranet */
.intranet-wrapper {
    max-width: 1100px;
    margin: calc(var(--header-height) + 1rem) auto 2rem;
    padding: 0 1.25rem 2.5rem;
}

/* Força as páginas da intranet a usarem scroll padrão, ignorando o overflow do layout geral */
html,
body.intranet-body {
    min-height: 100vh;
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden;
}

.intranet-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.intranet-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.intranet-brand .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0b1a4a, #1a237e);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 10px 24px rgba(26, 35, 126, 0.25);
}

.intranet-brand h1 {
    margin: 0;
    font-size: 1.35rem;
}

.intranet-brand p {
    margin: 0.15rem 0 0;
    color: #475569;
}

.intranet-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.intranet-card {
    background: #f5f7fa;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.intranet-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.intranet-tabs a {
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    color: #0f172a;
    text-decoration: none;
    font-weight: 600;
}

.intranet-tabs a.active {
    background: #1a237e;
    color: #fff;
    border-color: #1a237e;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: 8px;
}

.intranet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 720px;
}

.intranet-table th,
.intranet-table td {
    padding: 0.7rem 0.65rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.intranet-table th {
    background: #f8fafc;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 1;
}

.intranet-table .table-sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
}

.intranet-table .table-sort-link:hover,
.intranet-table .table-sort-link:focus-visible {
    color: #1a237e;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.intranet-table .table-sort-link:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.32);
    outline-offset: 2px;
}

.intranet-table .table-sort-link.active {
    color: #1a237e;
}

.intranet-table .table-sort-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    min-width: 1em;
    font-size: 0.9em;
    font-weight: 800;
}

.intranet-table td {
    overflow-wrap: anywhere;
}

.intranet-table details {
    max-width: min(92vw, 980px);
}

.intranet-table summary.btn {
    list-style: none;
}

.intranet-table summary.btn::-webkit-details-marker {
    display: none;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.form-grid label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form-grid input,
.form-grid select {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 0.95rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

.button.primary {
    background: #1a237e;
    color: #fff;
}

.button.secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.button.danger {
    background: #dc2626;
    color: #fff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    font-weight: 700;
    color: #fff;
    font-size: 0.85rem;
}

.status-pill.admin {
    background: #1d4ed8;
}

.status-pill.user {
    background: #0ea5e9;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    gap: 0.75rem;
}

.metric-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    min-width: 0;
}

.metric-card h4 {
    margin: 0 0 0.25rem;
}

.metric-card p {
    margin: 0;
    color: #0f172a;
    font-weight: 700;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: #e8eaf6;
    color: #1a237e;
    font-weight: 700;
}

.logout-link {
    color: #1a237e;
    font-weight: 700;
    text-decoration: none;
}

body.dark-mode .auth-alert.error {
    background: rgba(127, 29, 29, 0.22);
    color: #fecaca;
    border-color: #7f1d1d;
}

body.dark-mode .auth-alert.info {
    background: rgba(30, 64, 175, 0.2);
    color: #bfdbfe;
    border-color: #1d4ed8;
}

body.dark-mode .auth-redirect-countdown {
    color: #cbd5e1;
}

body.dark-mode .auth-redirect-countdown strong {
    color: #93c5fd;
}

body.dark-mode .intranet-table th,
body.dark-mode .intranet-table td {
    border-bottom-color: var(--gray-300);
    color: var(--text);
}

body.dark-mode .intranet-table th {
    background: #182338;
}

body.dark-mode .intranet-table .table-sort-link:hover,
body.dark-mode .intranet-table .table-sort-link:focus-visible,
body.dark-mode .intranet-table .table-sort-link.active {
    color: #bfdbfe;
}

body.dark-mode .metric-card {
    background: var(--surface-container);
    border-color: var(--outline-variant);
}

body.dark-mode .metric-card p {
    color: var(--text);
}

body.dark-mode .status-pill.admin {
    background: #1e40af;
}

body.dark-mode .status-pill.user {
    background: #0369a1;
}

body.dark-mode .user-badge {
    background: #1e293b;
    color: #bfdbfe;
}

body.dark-mode .logout-link {
    color: #93c5fd;
}

@media (max-width: 760px) {
    .table-responsive {
        overflow-x: visible;
        border-radius: 0;
    }

    .intranet-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 0.75rem;
        font-size: 0.92rem;
    }

    .intranet-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .intranet-table tbody,
    .intranet-table tr,
    .intranet-table td {
        display: block;
        width: 100%;
    }

    .intranet-table tr {
        background: var(--surface);
        border: 1px solid var(--outline-variant);
        border-radius: 8px;
        box-shadow: var(--shadow-1);
        overflow: hidden;
    }

    .intranet-table td {
        display: grid;
        grid-template-columns: minmax(7.2rem, 34%) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        padding: 0.72rem 0.85rem;
        border-bottom: 1px solid var(--outline-variant);
        min-height: 44px;
    }

    .intranet-table td:last-child {
        border-bottom: 0;
    }

    .intranet-table td::before {
        content: attr(data-label);
        color: var(--text-secondary);
        font-size: 0.75rem;
        font-weight: 800;
        line-height: 1.25;
        text-transform: uppercase;
        overflow-wrap: anywhere;
    }

    .intranet-table td[colspan] {
        display: block;
        text-align: center;
    }

    .intranet-table td[colspan]::before {
        content: none;
    }

    .intranet-table td details {
        min-width: 0;
    }

    .intranet-table td details[open] {
        grid-column: 1 / -1;
    }

    .intranet-table td:has(details)::before {
        padding-top: 0.45rem;
    }

    .intranet-table details .form-grid {
        margin-top: 0.75rem !important;
    }

    .intranet-table details form + form {
        margin-top: 0.65rem !important;
    }

    .intranet-table .btn,
    .intranet-table details form .btn {
        width: 100%;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .metric-card {
        padding: 0.85rem;
    }
}

@media (max-width: 460px) {
    .intranet-table td {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }
}
