/*
 * Pulso Eleitoral — tokens de marca sobre o Bootstrap 5.3.
 * Cores extraídas da logo: menta #5bf4d7, turquesa #05c4c2, azul #056fd6.
 */

:root,
[data-bs-theme="light"] {
    --pe-mint: #5bf4d7;
    --pe-teal: #05c4c2;
    --pe-blue: #056fd6;
    --pe-blue-strong: #0458ab;
    --pe-gradient: linear-gradient(135deg, var(--pe-mint) 0%, var(--pe-teal) 38%, var(--pe-blue) 100%);

    --pe-bg: #f4f7fb;
    --pe-surface: #ffffff;
    --pe-surface-2: #f8fafd;
    --pe-border: #e3e9f1;
    --pe-text: #12223a;
    --pe-muted: #5b6b82;
    --pe-sidebar-bg: #0c1b30;
    --pe-sidebar-text: #b9c6d8;
    --pe-sidebar-active: rgba(91, 244, 215, .12);

    --pe-radius: .75rem;
    --pe-radius-sm: .5rem;
    --pe-shadow: 0 1px 2px rgba(16, 34, 58, .06), 0 4px 16px rgba(16, 34, 58, .06);
    --pe-shadow-lg: 0 12px 40px rgba(16, 34, 58, .16);

    --bs-primary: var(--pe-blue);
    --bs-primary-rgb: 5, 111, 214;
    --bs-link-color: var(--pe-blue);
    --bs-link-color-rgb: 5, 111, 214;
    --bs-link-hover-color: var(--pe-blue-strong);
    --bs-body-bg: var(--pe-bg);
    --bs-body-color: var(--pe-text);
    --bs-border-color: var(--pe-border);
    --bs-secondary-color: var(--pe-muted);
    --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-border-radius: var(--pe-radius-sm);
    --bs-focus-ring-color: rgba(5, 111, 214, .3);
}

[data-bs-theme="dark"] {
    --pe-bg: #0a1424;
    --pe-surface: #101e33;
    --pe-surface-2: #13243d;
    --pe-border: #1f324e;
    --pe-text: #e6edf6;
    --pe-muted: #93a4bb;
    --pe-sidebar-bg: #07101d;
    --pe-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);

    --bs-primary: #3b95ee;
    --bs-primary-rgb: 59, 149, 238;
    --bs-link-color: #6db2f5;
    --bs-link-color-rgb: 109, 178, 245;
    --bs-link-hover-color: #9ccbf8;
    --bs-body-bg: var(--pe-bg);
    --bs-body-color: var(--pe-text);
    --bs-border-color: var(--pe-border);
    --bs-secondary-color: var(--pe-muted);
}

body { background: var(--pe-bg); -webkit-font-smoothing: antialiased; }

/* ---------- Botões ---------- */
.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--pe-blue-strong);
    --bs-btn-hover-border-color: var(--pe-blue-strong);
    --bs-btn-active-bg: var(--pe-blue-strong);
    --bs-btn-active-border-color: var(--pe-blue-strong);
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    font-weight: 600;
}
.btn { border-radius: var(--pe-radius-sm); }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color);
}
.btn-icon { display: inline-flex; align-items: center; gap: .4rem; }

/* ---------- Estrutura ---------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    --bs-offcanvas-width: 264px;
    --bs-offcanvas-bg: var(--pe-sidebar-bg);
    --bs-offcanvas-color: var(--pe-sidebar-text);
    background: var(--pe-sidebar-bg);
    color: var(--pe-sidebar-text);
}
@media (min-width: 992px) {
    .app-sidebar {
        position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 1030;
        display: flex; flex-direction: column;
    }
    .app-main { margin-left: 264px; }
}
.app-sidebar .brand {
    display: flex; align-items: center; gap: .65rem; padding: 1.25rem 1.25rem 1rem;
    color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -.01em; font-size: 1rem;
}
.app-sidebar .brand img { width: 34px; height: 34px; }
.app-sidebar .brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--pe-sidebar-text); letter-spacing: .02em; }
.sidebar-section { padding: .75rem 1.25rem .35rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6f819b; font-weight: 600; }
.sidebar-nav { list-style: none; margin: 0; padding: 0 .75rem; }
.sidebar-nav a {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; margin-bottom: 2px;
    border-radius: var(--pe-radius-sm); color: var(--pe-sidebar-text); text-decoration: none; font-weight: 500; font-size: .84rem;
    min-height: 44px;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sidebar-nav a.active { background: var(--pe-sidebar-active); color: var(--pe-mint); }
.sidebar-nav a.active i { color: var(--pe-mint); }
.sidebar-nav i { font-size: .95rem; width: 1.25rem; text-align: center; }
.sidebar-nav .soon { margin-left: auto; white-space: nowrap; flex: none; font-size: .65rem; padding: .1rem .4rem; border-radius: 999px; background: rgba(255, 255, 255, .07); color: #8193ab; }
.sidebar-nav a.disabled { pointer-events: none; opacity: .55; }
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; font-size: .75rem; color: #6f819b; border-top: 1px solid rgba(255, 255, 255, .06); }

.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    background: color-mix(in srgb, var(--pe-surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--pe-border);
    min-height: 64px;
}
.app-content { padding: 1.5rem; max-width: 1400px; }
@media (max-width: 575.98px) { .app-content { padding: 1rem; } }

.org-switch {
    display: inline-flex; align-items: center; gap: .55rem; padding: .4rem .75rem; border-radius: 999px;
    border: 1px solid var(--pe-border); background: var(--pe-surface); color: var(--pe-text); font-weight: 600; font-size: .8rem;
    max-width: 280px;
}
.org-switch .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pe-gradient); flex: none; }
.org-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
    width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--pe-gradient); color: #fff; font-weight: 700; font-size: .85rem; flex: none;
}

/* ---------- Cabeçalho de página ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-header p { margin: .25rem 0 0; color: var(--pe-muted); }

/* ---------- Superfícies ---------- */
.card { background: var(--pe-surface); border: 1px solid var(--pe-border); border-radius: var(--pe-radius); box-shadow: var(--pe-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--pe-border); padding: 1rem 1.25rem; font-weight: 600; }

.stat-card { padding: 1.25rem; position: relative; overflow: hidden; }
.stat-card .label { color: var(--pe-muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: .35rem; }
.stat-card .icon {
    position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; background: rgba(5, 196, 194, .12); color: var(--pe-teal); font-size: 1.15rem;
}

/* ---------- Tabelas ---------- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > :not(caption) > * > * { padding: .8rem 1rem; border-bottom-color: var(--pe-border); }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--pe-muted); font-weight: 600; background: var(--pe-surface-2); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--pe-surface-2); }
.cell-title { font-weight: 600; color: var(--pe-text); }
.cell-sub { font-size: .76rem; color: var(--pe-muted); }

/* Em telas pequenas, linhas viram cartões (sem rolagem horizontal). */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack tr { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--pe-border); }
    .table-stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0 !important; border: 0 !important; text-align: right; }
    .table-stack td::before { content: attr(data-label); font-size: .78rem; color: var(--pe-muted); font-weight: 600; text-align: left; }
    .table-stack td.cell-main { display: block; text-align: left; }
    .table-stack td.cell-main::before { display: none; }
}

/* ---------- Status ---------- */
.badge-status { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .76rem; padding: .3rem .6rem; border-radius: 999px; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active, .status-success { background: rgba(16, 163, 127, .12); color: #0b8a6b; }
.status-suspended, .status-denied { background: rgba(224, 142, 0, .14); color: #a86400; }
.status-revoked, .status-blocked, .status-failure { background: rgba(214, 51, 72, .12); color: #c22b3f; }
[data-bs-theme="dark"] .status-active, [data-bs-theme="dark"] .status-success { color: #4fd4ae; }
[data-bs-theme="dark"] .status-suspended, [data-bs-theme="dark"] .status-denied { color: #f2b350; }
[data-bs-theme="dark"] .status-revoked, [data-bs-theme="dark"] .status-blocked, [data-bs-theme="dark"] .status-failure { color: #f27585; }

/* ---------- Filtros em fichas ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--pe-border); }
.filter-bar .search { flex: 1 1 240px; max-width: 360px; position: relative; }
.filter-bar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--pe-muted); }
.filter-bar .search input { padding-left: 2.25rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .8rem; border-radius: 999px;
    border: 1px solid var(--pe-border); background: var(--pe-surface); color: var(--pe-text); font-size: .78rem; font-weight: 500;
    text-decoration: none; min-height: 36px;
}
.chip:hover { border-color: var(--bs-primary); color: var(--bs-primary); }
.chip.active { background: rgba(var(--bs-primary-rgb), .1); border-color: var(--bs-primary); color: var(--bs-primary); font-weight: 600; }
.chip .count { font-size: .72rem; background: var(--bs-primary); color: #fff; border-radius: 999px; padding: 0 .4rem; }

/* ---------- Estado vazio ---------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state .icon { width: 56px; height: 56px; border-radius: 16px; display: inline-grid; place-items: center; background: rgba(5, 196, 194, .12); color: var(--pe-teal); font-size: 1.5rem; margin-bottom: 1rem; }
.empty-state h2 { font-size: .95rem; font-weight: 700; }
.empty-state p { color: var(--pe-muted); max-width: 420px; margin: .25rem auto 1rem; }

/* ---------- Painel lateral ---------- */
.offcanvas.side-panel { --bs-offcanvas-width: min(560px, 100vw); background: var(--pe-surface); }
.side-panel .offcanvas-header { border-bottom: 1px solid var(--pe-border); padding: 1.1rem 1.5rem; }
.side-panel .offcanvas-title { font-weight: 700; letter-spacing: -.01em; }
.side-panel .offcanvas-body { padding: 1.5rem; }
.form-section-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--pe-muted); font-weight: 700; margin: 1.5rem 0 .75rem; }
.form-section-title:first-child { margin-top: 0; }
.form-label { font-weight: 600; font-size: .8rem; }
.form-text { color: var(--pe-muted); }

.option-card { display: block; border: 1px solid var(--pe-border); border-radius: var(--pe-radius-sm); padding: .75rem .9rem .75rem 2.5rem; position: relative; cursor: pointer; margin-bottom: .5rem; }
.option-card .form-check-input { position: absolute; left: .9rem; top: .95rem; margin: 0; }
.option-card:has(.form-check-input:checked) { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .05); }
.option-card:has(.form-check-input:disabled) { opacity: .55; cursor: not-allowed; }
.option-card .title { font-weight: 600; font-size: .82rem; }
.option-card .desc { font-size: .74rem; color: var(--pe-muted); }
.option-card code { font-size: .74rem; }

/* ---------- Autenticação ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 992px) { .auth-wrap { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.auth-hero {
    display: none; position: relative; overflow: hidden; color: #fff; padding: 3rem;
    /* Imagem em public/assets/img/auth.jpg; o degradê escurece as bordas para o texto ficar legível. */
    background:
        linear-gradient(to top, rgba(7, 16, 29, .92) 0%, rgba(7, 16, 29, .55) 30%, rgba(7, 16, 29, 0) 60%),
        linear-gradient(to bottom, rgba(7, 16, 29, .7) 0%, rgba(7, 16, 29, 0) 22%),
        url("../img/auth.jpg") center / cover no-repeat,
        #0b1a2e;
}
@media (min-width: 992px) { .auth-hero { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-hero h2 { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; max-width: 460px; }
.auth-hero p { color: #b9c6d8; max-width: 440px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { width: 52px; height: 52px; }
.auth-card h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; }

/* ---------- Diversos ---------- */
.text-gradient { background: var(--pe-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kbd-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.audit-changes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; white-space: pre-wrap; word-break: break-word; background: var(--pe-surface-2); border-radius: var(--pe-radius-sm); padding: .5rem .75rem; margin-top: .4rem; }
.alert { border-radius: var(--pe-radius-sm); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; user-select: all; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
.text-xs { font-size: .75rem; }
.error-card { max-width: 560px; }

/* ---------- Escala tipográfica: base 10% menor que o padrão do Bootstrap ---------- */
:root {
    --bs-body-font-size: .9rem;
}
body { font-size: var(--bs-body-font-size); }
.btn { --bs-btn-font-size: .9rem; }
.btn-sm { --bs-btn-font-size: .79rem; }
.btn-lg { --bs-btn-font-size: 1.125rem; }
.form-control, .form-select, .input-group-text { font-size: .9rem; }
.form-control-lg, .input-group-lg > .form-control, .input-group-lg > .btn { font-size: 1.125rem; }
.dropdown-menu { --bs-dropdown-font-size: .9rem; }
.list-group-item, .alert, .modal-body, .page-link { font-size: .9rem; }
.pagination-sm { --bs-pagination-font-size: .79rem; }
.small, small { font-size: .875em; }
.h4 { font-size: 1.35rem; }
.fs-5 { font-size: 1.125rem !important; }
.display-5 { font-size: 2.7rem; }

/* ---------- Dropdowns ---------- */
.dropdown-menu {
    --bs-dropdown-bg: var(--pe-surface);
    --bs-dropdown-border-color: var(--pe-border);
    --bs-dropdown-border-radius: var(--pe-radius);
    --bs-dropdown-padding-x: .375rem;
    --bs-dropdown-padding-y: .375rem;
    --bs-dropdown-item-padding-x: .75rem;
    --bs-dropdown-item-padding-y: .5rem;
    --bs-dropdown-item-border-radius: var(--pe-radius-sm);
    --bs-dropdown-link-color: var(--pe-text);
    --bs-dropdown-link-hover-color: var(--pe-text);
    --bs-dropdown-link-hover-bg: var(--pe-surface-2);
    --bs-dropdown-link-active-color: var(--bs-primary);
    --bs-dropdown-link-active-bg: rgba(var(--bs-primary-rgb), .1);
    --bs-dropdown-header-color: var(--pe-muted);
    --bs-dropdown-divider-bg: var(--pe-border);
    --bs-dropdown-divider-margin-y: .375rem;
    min-width: 15rem;
    box-shadow: var(--pe-shadow-lg) !important;
    margin-top: .5rem !important;
}
.dropdown-item { display: flex; align-items: center; gap: .65rem; border-radius: var(--pe-radius-sm); font-weight: 500; }
.dropdown-item i { font-size: 1rem; width: 1.1rem; text-align: center; color: var(--pe-muted); }
.dropdown-item:hover i, .dropdown-item:focus i { color: var(--pe-text); }
.dropdown-item.text-danger i { color: inherit; }
.dropdown-item.text-danger:hover { background: rgba(214, 51, 72, .1); color: #c22b3f; }
.dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; padding: .5rem .75rem .35rem; }
.dropdown-user { display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem .75rem; }
.dropdown-user .name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.dropdown-user .email { font-size: .75rem; color: var(--pe-muted); }
.dropdown-toggle.org-switch::after, .btn-account::after { display: none; }
.org-switch .chev, .btn-account .chev { font-size: .7rem; color: var(--pe-muted); transition: transform .15s; }
.org-switch[aria-expanded="true"] .chev, .btn-account[aria-expanded="true"] .chev { transform: rotate(180deg); }
.org-switch:hover, .btn-account:hover { border-color: color-mix(in srgb, var(--bs-primary) 45%, var(--pe-border)); }
.btn-account { display: flex; align-items: center; gap: .55rem; padding: .25rem .6rem .25rem .25rem; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--pe-text); }
.btn-account:hover { background: var(--pe-surface-2); }
.btn-account .avatar { width: 32px; height: 32px; font-size: .78rem; }
.btn-icon-round { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--pe-muted); border: 1px solid transparent; background: transparent; }
.btn-icon-round:hover { background: var(--pe-surface-2); color: var(--pe-text); }

/* ---------- Painel lateral: área do formulário rola; barra de botões fica fixa embaixo ---------- */
.side-panel .offcanvas-body { display: flex; flex-direction: column; padding: 0; overflow: hidden; min-height: 0; }
.side-panel .panel-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1.5rem; overscroll-behavior: contain; }
.side-panel .panel-footer {
    position: static; margin: 0; flex: none; display: flex; gap: .5rem; justify-content: flex-end;
    padding: .9rem 1.5rem; border-top: 1px solid var(--pe-border); background: var(--pe-surface);
    box-shadow: 0 -6px 16px -12px rgba(16, 34, 58, .35);
}
.side-panel .offcanvas-header .btn-close { opacity: .6; }

/* ---------- Campos ---------- */
.form-control, .form-select { border-color: var(--pe-border); background-color: var(--pe-surface); padding: .375rem .7rem; font-size: .9rem; line-height: 1.45; }
.form-select { padding-right: 2.25rem; }
.input-group > .btn { padding-top: .375rem; padding-bottom: .375rem; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background-color: var(--pe-surface-2); }
.form-control::placeholder { color: color-mix(in srgb, var(--pe-muted) 70%, transparent); }
.form-control:hover, .form-select:hover { border-color: color-mix(in srgb, var(--pe-muted) 45%, var(--pe-border)); }
.min-w-0 { min-width: 0; }

/* O Bootstrap força fundo transparente em .offcanvas-lg no desktop; o menu lateral é sempre escuro. */
.app-sidebar { background-color: var(--pe-sidebar-bg) !important; }

/* ---------- Linha do tempo da auditoria ---------- */
.audit-timeline { list-style: none; margin: 0; padding: .5rem 0; }
.audit-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: .9rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--pe-border); }
.audit-item:last-child { border-bottom: 0; }
.audit-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 1rem; background: var(--pe-surface-2); color: var(--pe-muted); }
.tone-success .audit-icon { background: rgba(16, 163, 127, .12); color: #0b8a6b; }
.tone-warning .audit-icon { background: rgba(224, 142, 0, .14); color: #a86400; }
.tone-danger .audit-icon { background: rgba(214, 51, 72, .12); color: #c22b3f; }
[data-bs-theme="dark"] .tone-success .audit-icon { color: #4fd4ae; }
[data-bs-theme="dark"] .tone-warning .audit-icon { color: #f2b350; }
[data-bs-theme="dark"] .tone-danger .audit-icon { color: #f27585; }
.audit-text { line-height: 1.5; padding-top: .45rem; }
.audit-text strong { font-weight: 600; }
.audit-details { margin: .35rem 0 0; padding-left: 1.1rem; color: var(--pe-muted); font-size: .84rem; }
.audit-details li { margin-bottom: .1rem; }
.audit-details strong, .audit-details em { color: var(--pe-text); }
.audit-tech { margin-top: .35rem; font-size: .78rem; }
.audit-tech summary { color: var(--pe-muted); cursor: pointer; width: max-content; }
.audit-tech summary:hover { color: var(--bs-primary); }
.audit-tech dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .15rem .75rem; margin: .5rem 0 0; padding: .6rem .75rem; background: var(--pe-surface-2); border-radius: var(--pe-radius-sm); }
.audit-tech dt { font-weight: 600; color: var(--pe-muted); }
.audit-tech dd { margin: 0; word-break: break-all; }
.audit-when { font-size: .78rem; color: var(--pe-muted); text-align: right; white-space: nowrap; padding-top: .45rem; }
.audit-when span { display: block; font-size: .72rem; }
.audit-timeline.compact { padding: 0; }
.audit-timeline.compact .audit-item { padding: .7rem 1.1rem; grid-template-columns: 32px minmax(0, 1fr) auto; }
.audit-timeline.compact .audit-icon { width: 32px; height: 32px; font-size: .9rem; }
.audit-timeline.compact .audit-text { font-size: .84rem; padding-top: .3rem; }
.audit-timeline.compact .audit-when { padding-top: .35rem; }
@media (max-width: 575.98px) {
    .audit-item { grid-template-columns: 32px minmax(0, 1fr); }
    .audit-when { grid-column: 2; text-align: left; padding-top: 0; }
    .audit-when span { display: inline; margin-left: .35rem; }
}

/* ---------- Avisos (flash) ---------- */
.alert-flash {
    display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem;
    border: 1px solid var(--bs-alert-border-color); border-left-width: 3px;
    box-shadow: var(--pe-shadow); line-height: 1.5;
}
.alert-flash .alert-icon { display: inline-flex; align-items: center; height: 1.5em; flex: none; font-size: 1.05rem; }
.alert-flash .alert-icon i { line-height: 1; }
.alert-flash .alert-text { flex: 1 1 auto; min-width: 0; }
.alert-flash .btn-close { flex: none; width: .6em; height: .6em; padding: .45em; margin: .1rem -.25rem 0 0; opacity: .45; }
.alert-flash .btn-close:hover { opacity: .8; }
.alert-success.alert-flash { border-left-color: #10a37f; }
.alert-danger.alert-flash { border-left-color: #d63348; }
.alert-warning.alert-flash { border-left-color: #e08e00; }
.alert-info.alert-flash { border-left-color: var(--bs-primary); }
[data-bs-theme="dark"] .alert-flash .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---------- Menu: rótulo em uma linha e itens das próximas etapas ---------- */
.sidebar-nav .nav-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav a.upcoming { opacity: .55; }
.sidebar-nav a.upcoming:hover { opacity: .85; }

/* ---------- Página "Como usar" ---------- */
.help-steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .6rem; }
.help-steps li { padding-left: .25rem; }
.help-steps li::marker { color: var(--bs-primary); font-weight: 700; }
.help-faq { --bs-accordion-bg: transparent; --bs-accordion-border-color: var(--pe-border); --bs-accordion-btn-padding-y: .85rem; --bs-accordion-active-bg: var(--pe-surface-2); --bs-accordion-active-color: var(--pe-text); --bs-accordion-btn-focus-box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.help-faq .accordion-button { font-weight: 600; font-size: .9rem; }
.help-faq .accordion-body { color: var(--pe-muted); font-size: .88rem; }
.help-icon { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: rgba(5, 196, 194, .12); color: var(--pe-teal); flex: none; }
.help-upcoming:target { border-color: var(--bs-primary); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }

/* ---------- Rodapé do menu centralizado ---------- */
.sidebar-footer { text-align: center; }
.sidebar-footer .footer-short { display: none; }

/* ---------- Menu lateral recolhível (desktop) ---------- */
.sidebar-nav a .nav-label { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text { white-space: nowrap; }
@media (min-width: 992px) {
    .app-sidebar, .app-main { transition: width .2s ease, margin-left .2s ease; }

    .sidebar-collapsed .app-sidebar { width: 76px; }
    .sidebar-collapsed .app-main { margin-left: 76px; }
    .sidebar-collapsed .app-sidebar .brand { justify-content: center; padding-left: 0; padding-right: 0; }
    .sidebar-collapsed .app-sidebar .brand-text,
    .sidebar-collapsed .sidebar-nav .nav-label,
    .sidebar-collapsed .sidebar-nav .soon,
    .sidebar-collapsed .sidebar-footer .footer-full { display: none; }
    .sidebar-collapsed .sidebar-footer .footer-short { display: inline; }
    .sidebar-collapsed .sidebar-footer { padding-left: 0; padding-right: 0; }
    /* Títulos das seções viram uma linha divisória. */
    .sidebar-collapsed .sidebar-section { font-size: 0; padding: 0; margin: .75rem 1.1rem; height: 1px; background: rgba(255, 255, 255, .08); }
    .sidebar-collapsed .sidebar-nav { padding: 0 .9rem; }
    .sidebar-collapsed .sidebar-nav a { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
    .sidebar-collapsed .sidebar-nav i { font-size: 1.1rem; width: auto; }
}
@media (min-width: 992px) and (prefers-reduced-motion: reduce) {
    .app-sidebar, .app-main { transition: none; }
}

/* Dica (tooltip) com o nome do item quando o menu está recolhido. */
.tooltip { --bs-tooltip-bg: #0c1b30; --bs-tooltip-font-size: .8rem; --bs-tooltip-padding-x: .65rem; --bs-tooltip-padding-y: .4rem; --bs-tooltip-border-radius: 8px; }
.tooltip .tooltip-inner { box-shadow: var(--pe-shadow-lg); border: 1px solid rgba(255, 255, 255, .08); }
@media (min-width: 992px) {
    .sidebar-collapsed .app-sidebar > div:first-child { justify-content: center !important; }
    .sidebar-collapsed .app-sidebar .brand { width: 100%; }
}
.stat-card .label { padding-right: 48px; }

/* ---------- Cadastros genéricos: abas, busca com autocompletar, seleção múltipla ---------- */
.resource-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--pe-border); scrollbar-width: thin; }
.resource-tab {
    display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .9rem; white-space: nowrap;
    color: var(--pe-muted); text-decoration: none; font-weight: 600; font-size: .85rem;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.resource-tab:hover { color: var(--pe-text); }
.resource-tab.active { color: var(--bs-primary); border-bottom-color: var(--bs-primary); }
.resource-description { max-width: 760px; }

.lookup { position: relative; }
.lookup-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--pe-muted); font-size: .85rem; pointer-events: none; }
.lookup .lookup-input { padding-left: 2.1rem; padding-right: 2.1rem; }
.lookup-clear { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--pe-muted); padding: .25rem .4rem; border-radius: 6px; }
.lookup-clear:hover { color: var(--pe-text); background: var(--pe-surface-2); }
.lookup-list {
    position: absolute; z-index: 1060; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: .3rem; list-style: none;
    max-height: 260px; overflow-y: auto; background: var(--pe-surface); border: 1px solid var(--pe-border);
    border-radius: var(--pe-radius-sm); box-shadow: var(--pe-shadow-lg);
}
.lookup-list li { padding: .45rem .6rem; border-radius: 6px; cursor: pointer; font-size: .86rem; }
.lookup-list li:hover, .lookup-list li.active { background: rgba(var(--bs-primary-rgb), .1); color: var(--bs-primary); }
.lookup-list .lookup-empty { color: var(--pe-muted); cursor: default; }
.lookup-list .lookup-empty:hover { background: transparent; color: var(--pe-muted); }
.lookup-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .4rem; }
.lookup-chips:empty { display: none; }
.lookup-chip { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .25rem .2rem .6rem; border-radius: 999px; background: rgba(var(--bs-primary-rgb), .1); color: var(--bs-primary); font-size: .8rem; font-weight: 600; }
.lookup-chip button { border: 0; background: transparent; color: inherit; padding: 0 .2rem; line-height: 1; border-radius: 50%; }
.lookup-chip button:hover { background: rgba(var(--bs-primary-rgb), .15); }

.multi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .4rem; max-height: 240px; overflow-y: auto; padding: .1rem; }
.multi-grid.is-invalid { outline: 1px solid var(--bs-form-invalid-border-color); border-radius: var(--pe-radius-sm); }
.multi-option { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border: 1px solid var(--pe-border); border-radius: var(--pe-radius-sm); font-size: .82rem; cursor: pointer; }
.multi-option .form-check-input { margin: 0; flex: none; }
.multi-option:has(:checked) { border-color: var(--bs-primary); background: rgba(var(--bs-primary-rgb), .05); }
