/* ===== Tokens ===== */
:root {
  --chart-brand: #d4a017;   /* paleta de charts.js: marca, informativo/antecipado e pago/ok (mudam com o tema) */
  --chart-info: #1b4fd8;
  --chart-success: #198754;
  --chart-danger: #dc3545;
  --chart-warning: #ffc107;
  --sb-width: 256px;
  --sb-bg: #1b2434;
  --sb-fg: #c7d0dc;
  --accent: #d4a017;
  --accent-soft: rgba(212,160,23,.16);
  --surface: #ffffff;
  --bg: #f4f6f9;
  --border: #e6e9ee;
  --text-muted: #6b7280;
  --text: #1f2937;
  --positive: #198754;
  --negative: #dc3545;
  --radius: .75rem;
  --focus: 0 0 0 .2rem rgba(13,110,253,.35);
  --bs-body-font-size: .95rem;
}
html { scroll-behavior: smooth; }
/* Contraste AA no tema claro fora dos cartões brancos (fundo #f4f6f9 e cabeçalhos #f8f9fa): links e textos coloridos nas
   variantes "emphasis" do Bootstrap; as cores vivas ficam para badges, barras e botões cheios. */
html:not([data-bs-theme="dark"]) { --bs-link-color: #0a58ca; --bs-link-color-rgb: 10,88,202; --bs-link-hover-color: #084298; --bs-link-hover-color-rgb: 8,66,152; --bs-secondary-color: #5b6470; --bs-secondary-color-rgb: 91,100,112; }
html:not([data-bs-theme="dark"]) .text-success { color: #146c43 !important; }
html:not([data-bs-theme="dark"]) .text-danger { color: #b02a37 !important; }
html:not([data-bs-theme="dark"]) .text-primary { color: #0a58ca !important; }
html:not([data-bs-theme="dark"]) .text-info { color: #0a7c91 !important; }
html:not([data-bs-theme="dark"]) .text-warning { color: #997404 !important; }
html:not([data-bs-theme="dark"]) .link-secondary { color: #5b6470 !important; }
html:not([data-bs-theme="dark"]) .btn-outline-secondary { --bs-btn-color: #5b6470; --bs-btn-border-color: #8a93a0; --bs-btn-hover-bg: #5b6470; --bs-btn-hover-border-color: #5b6470; }
html:not([data-bs-theme="dark"]) .btn-outline-info { --bs-btn-color: #0a7c91; --bs-btn-border-color: #0dcaf0; --bs-btn-hover-bg: #0dcaf0; --bs-btn-hover-color: #000; }
html:not([data-bs-theme="dark"]) .btn-outline-success { --bs-btn-color: #146c43; }
html:not([data-bs-theme="dark"]) .btn-outline-danger { --bs-btn-color: #b02a37; }
html:not([data-bs-theme="dark"]) .btn-outline-primary { --bs-btn-color: #0a58ca; }
body { background: var(--bg); color: var(--text); }
a { text-underline-offset: 2px; }

/* ===== Acessibilidade ===== */
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 2000; background: #fff; color: #000; padding: .5rem .75rem; border-radius: .4rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 3px solid #0d6efd; outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow: var(--focus); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ===== Layout ===== */
body.has-sidebar .main-content { margin-left: var(--sb-width); min-height: 100vh; display: flex; flex-direction: column; }
@media (max-width: 991.98px) { body.has-sidebar .main-content { margin-left: 0; } }
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sb-width); background: var(--sb-bg); color: var(--sb-fg); padding: 1rem .75rem; overflow-y: auto; }
.sidebar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem .75rem; }
.sidebar .brand-icon { font-size: 1.4rem; }
.event-chip { display: block; text-decoration: none; background: rgba(255,255,255,.06); border-left: 3px solid var(--accent); border-radius: .5rem; padding: .6rem .75rem; margin: .25rem 0 1rem; color: var(--sb-fg); }
a.event-chip:hover { background: rgba(255,255,255,.1); color: #fff; }
.event-chip .ev-name { color: #fff; font-weight: 600; font-size: .95rem; line-height: 1.25; }
.event-chip .ev-date, .event-chip .ev-countdown { font-size: .8rem; }
.event-chip .ev-countdown { color: var(--accent); font-weight: 600; margin-top: .15rem; }
.nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8ba0; padding: .9rem .75rem .3rem; }
.sidebar .nav-link, .sidebar-offcanvas .nav-link { color: var(--sb-fg); border-radius: .5rem; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; font-size: .93rem; border-left: 3px solid transparent; }
.sidebar .nav-link:hover, .sidebar-offcanvas .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active, .sidebar-offcanvas .nav-link.active { background: var(--accent-soft); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.sidebar .nav-link i, .sidebar-offcanvas .nav-link i { width: 1.2rem; text-align: center; color: var(--accent); }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding-top: .5rem; margin-top: 1rem; }
.sidebar-offcanvas { background: var(--sb-bg); color: var(--sb-fg); width: 300px; }
.sidebar-offcanvas .offcanvas-title { color: #fff; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: .7rem 1.25rem; position: sticky; top: 0; z-index: 1020; }
.page-body { padding: 1.25rem; flex: 1; }
.page-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); }
@media (max-width: 575.98px) {
  .page-body { padding: .9rem; } .topbar { padding: .6rem .9rem; }
  /* Campo de link (somente leitura) com vários botões: o campo ocupa a linha toda e os botões vêm embaixo. */
  .portal-link .input-group, .input-group:has(> .form-control[readonly] ~ .btn ~ .btn) { flex-wrap: wrap; row-gap: .5rem; }
  .portal-link .input-group > .form-control, .input-group:has(> .form-control[readonly] ~ .btn ~ .btn) > .form-control[readonly] { flex: 1 1 100%; width: 100%; border-radius: var(--bs-border-radius) !important; }
  .portal-link .input-group > .form-control + .btn, .input-group:has(> .form-control[readonly] ~ .btn ~ .btn) > .form-control[readonly] + .btn { border-top-left-radius: var(--bs-border-radius) !important; border-bottom-left-radius: var(--bs-border-radius) !important; margin-left: 0 !important; }
}

/* ===== Componentes ===== */
.card { border: 0; box-shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04); border-radius: var(--radius); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; }
.kpi { position: relative; display: flex; flex-direction: column; border-radius: var(--radius); padding: 1rem 1.25rem; background: var(--surface); height: 100%; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.kpi .kpi-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.kpi .kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }
.kpi.kpi-accent { border-top: 3px solid var(--accent); }
.kpi.kpi-success { border-top: 3px solid #198754; }
.kpi.kpi-danger { border-top: 3px solid #dc3545; }
.kpi.kpi-info { border-top: 3px solid #0dcaf0; }
.kpi.kpi-warning { border-top: 3px solid #ffc107; }
.kpi.kpi-primary { border-top: 3px solid #0d6efd; }
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table-sm > :not(caption) > * > * { padding: .35rem .5rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 2px solid #cfd4da; }
.table-responsive { -webkit-overflow-scrolling: touch; }
/* Pista de rolagem horizontal (app.js marca .is-scrollable quando a tabela é mais larga que a caixa): sombras nas bordas que
   somem ao chegar ao fim, pelo truque de fundos com background-attachment local/scroll. As células transparentes deixam ver. */
.table-responsive.is-scrollable {
  background:
    linear-gradient(to right, var(--surface) 40%, rgba(255,255,255,0)) left / 48px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, rgba(255,255,255,0)) right / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.22), rgba(0,0,0,0)) left / 16px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.22), rgba(0,0,0,0)) right / 16px 100% no-repeat scroll;
}
/* Coluna de ações fixa à direita em telas estreitas (app.js aplica quando a coluna é estreita o bastante). */
@media (max-width: 575.98px) {
  /* Só cabeçalho e corpo: no rodapé a última célula costuma ter colspan e cobriria os totais. */
  .table-sticky-actions > thead > tr > th:last-child,
  .table-sticky-actions > tbody > tr > td:last-child { position: sticky; right: 0; z-index: 2; background-color: var(--surface); box-shadow: -6px 0 8px -6px rgba(0,0,0,.3); }
  .table-sticky-actions > thead.table-light > tr > th:last-child,
  .table-sticky-actions > tbody > tr[class*="table-"] > td:last-child { background-color: var(--bs-table-bg); }
  .table-sticky-actions > tbody > tr > td:last-child .btn + .btn, .table-sticky-actions > tbody > tr > td:last-child form + .btn { margin-left: .15rem; }
}
.row-title { font-weight: 600; }
.row-sub { font-size: .8rem; color: var(--text-muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; background: #e9ecef; color: #495057; flex-shrink: 0; }
.text-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge-soft { background: #f1f3f5; color: #495057; border: 1px solid #e3e6ea; }
.badge-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.progress { height: .6rem; border-radius: 1rem; background: #e9ecef; }
/* Mesmas cores das roscas de pagamento: verde = pago, azul = antecipado (não use bg-info, que é o ciano de "crianças"). */
.progress-bar.bar-paid, .badge-dot.bar-paid { background-color: var(--chart-success); }
.progress-bar.bar-advanced, .badge-dot.bar-advanced { background-color: var(--chart-info); }
.progress-bar.bar-open, .badge-dot.bar-open { background-color: var(--chart-danger); }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 220px; }
.chart-caption { font-size: .82rem; color: var(--text-muted); }
.task-done { text-decoration: line-through; color: #8a93a0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: #adb5bd; }
.form-label.required::after { content: " *"; color: #dc3545; }
.form-text { font-size: .8rem; }
.invite-card img { width: 100%; border-radius: .5rem; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.invite-card.selected { outline: 3px solid var(--accent); border-radius: .6rem; }
.login-wrap { min-height: 100vh; display: flex; background: linear-gradient(135deg, #1b2434 0%, #2b3a55 100%); }
.login-card { width: 100%; max-width: 420px; margin: auto; }
.portal-wrap { max-width: 860px; margin: 0 auto; padding: 1rem; }
.portal-hero { background: linear-gradient(135deg, #1b2434, #3a4a6b); color: #fff; border-radius: 1rem; padding: 2rem; }
.portal-hero .display-amount { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
/* Links de texto da faixa em branco; botões (.btn) mantêm as cores deles (ex.: "Editar evento" claro no painel). */
.portal-hero a:not(.btn) { color: #fff; }
.portal-hero .hero-status { background: rgba(255,255,255,.1); border-radius: .75rem; padding: .6rem .85rem; }
.portal-hero .hero-status a { text-decoration: underline; font-weight: 600; }
/* Lista "Quem vai?": a linha inteira é tocável (label envolve a caixa) e tem pelo menos 44 px. */
.portal-people .form-check { min-height: 2.75rem; display: flex; align-items: center; gap: .6rem; padding: .3rem .25rem; margin: 0; border-bottom: 1px solid var(--border); }
.portal-people .form-check:last-child { border-bottom: 0; }
.portal-people .form-check-input { width: 1.4rem; height: 1.4rem; margin: 0; flex-shrink: 0; float: none; }
.portal-people .form-check-label { flex: 1; cursor: pointer; }
.portal-wrap .table td.text-money, .portal-wrap .table th.text-money { white-space: nowrap; }
.portal-wrap .table-sm > :not(caption) > * > * { padding: .4rem .45rem; }
.portal-wrap .card-header { font-size: 1rem; }
.portal-answer { font-size: 1.05rem; }
@media (max-width: 575.98px) {
  .portal-wrap { padding: .75rem; }
  .portal-hero { padding: 1.35rem 1.1rem; border-radius: .85rem; }
  .portal-hero h1 { font-size: 1.5rem; }
}
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .75rem 0; border-top: 1px solid var(--border); z-index: 5; }
.alert { border-radius: var(--radius); }
.btn { border-radius: .55rem; }
.btn-primary { --bs-btn-bg: #1b4fd8; --bs-btn-border-color: #1b4fd8; --bs-btn-hover-bg: #163fb0; --bs-btn-hover-border-color: #163fb0; }
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
/* Toque (celular e tablet): alvos de pelo menos 44 px sem mudar o desenho dos botões pequenos em linhas de tabela. */
@media (pointer: coarse) {
  .btn-sm { padding: .42rem .65rem; min-height: 2.75rem; min-width: 2.75rem; }
  .btn-icon, .theme-toggle, .btn-close { min-width: 2.75rem; min-height: 2.75rem; }
  .btn-icon { width: 2.75rem; height: 2.75rem; }
  .form-control, .form-select { min-height: 2.75rem; }
  .form-check-input { width: 1.4rem; height: 1.4rem; margin-top: .1em; }
  .form-check:not(.form-check-inline):not(.form-switch) { min-height: 2.75rem; display: flex; align-items: center; gap: .5rem; padding-left: 0; }
  .form-check:not(.form-check-inline):not(.form-switch) > .form-check-input { float: none; margin-left: 0; flex-shrink: 0; }
  .form-check-inline { min-height: 2.75rem; display: inline-flex; align-items: center; gap: .5rem; padding-left: 0; }
  .form-check-inline > .form-check-input { float: none; margin-left: 0; flex-shrink: 0; }
  .chart-action, .insight-action, .page-link { display: inline-flex; align-items: center; min-height: 2.75rem; }
  .page-link { min-width: 2.75rem; justify-content: center; }
  /* Botão só de ícone colado (ex.: círculo de concluir tarefa): área de toque maior sem deslocar o layout. */
  .table .btn-link.p-0 { padding: .5rem !important; margin: -.5rem; line-height: 1; }
  .btn-group-sm > .btn { min-height: 2.75rem; }
  .portal-wrap .btn, .login-card .btn { min-height: 2.75rem; }
  /* Botões de tamanho normal também com 44 px, texto centralizado na altura (o ícone e o texto ficam lado a lado). */
  .btn:not(.btn-sm):not(.btn-link):not(.btn-icon) { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
}
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.num-hero { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
/* WhatsApp: prévia da mensagem no estilo da conversa (Configurações > WhatsApp, filas de convite e de cobrança). */
.wa-queue { max-width: 640px; }
.wa-chat { background: #efeae2; border: 1px solid var(--border, #dee2e6); border-radius: .75rem; padding: .9rem; }
.wa-bubble { position: relative; margin-left: auto; width: fit-content; max-width: 100%; background: #d9fdd3; color: #111b21; border-radius: .6rem .6rem .15rem .6rem; padding: .45rem .6rem .3rem; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); font-size: .95rem; line-height: 1.4; overflow-wrap: anywhere; }
.wa-bubble .wa-link { color: #0b5f8a; text-decoration: underline; }
.wa-bubble .wa-time { float: right; margin: .4rem 0 -.15rem .9rem; font-size: .7rem; color: #54656f; white-space: nowrap; }
.wa-bubble .wa-unknown { background: #fff3cd; color: #842029; border-radius: .2rem; padding: 0 .15rem; }
.wa-bubble code { color: inherit; background: rgba(0, 0, 0, .06); padding: 0 .2rem; border-radius: .2rem; }
.wa-empty { color: #54656f; font-style: italic; }
[data-bs-theme="dark"] .wa-chat { background: #0b141a; }
[data-bs-theme="dark"] .wa-bubble { background: #005c4b; color: #e9edef; box-shadow: none; }
[data-bs-theme="dark"] .wa-bubble .wa-link { color: #a5dcf5; }
[data-bs-theme="dark"] .wa-bubble .wa-time, [data-bs-theme="dark"] .wa-empty { color: #c7d3d9; }
[data-bs-theme="dark"] .wa-bubble code { background: rgba(255, 255, 255, .1); }
@media print {
  .sidebar, .topbar, .page-footer, .btn, .no-print, .alert, .offcanvas { display: none !important; }
  .wa-chat, [data-bs-theme="dark"] .wa-chat { background: #fff; }
  body { background: #fff; }
  body.has-sidebar .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  .page-body { padding: 0; }
  /* Impressão sempre clara, também no tema escuro: tokens de volta aos valores claros e fundos brancos. */
  [data-bs-theme="dark"] {
    --bg: #fff; --surface: #fff; --border: #ddd; --text: #000; --text-muted: #555; --positive: #146c43; --negative: #b02a37; --accent: #b8860b;
    --bs-body-bg: #fff; --bs-body-color: #000; --bs-secondary-color: #555; --bs-secondary-bg: #f1f3f5; --bs-tertiary-bg: #f8f9fa;
    --bs-border-color: #ddd; --bs-emphasis-color: #000; --bs-heading-color: #000; --bs-link-color: #0a58ca; color-scheme: light;
  }
  [data-bs-theme="dark"] body, [data-bs-theme="dark"] .card, [data-bs-theme="dark"] .kpi, [data-bs-theme="dark"] .insight, [data-bs-theme="dark"] .modal-content,
  [data-bs-theme="dark"] .list-group-item, [data-bs-theme="dark"] .bg-light, [data-bs-theme="dark"] .text-bg-light, [data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background: #fff !important; color: #000 !important; border-color: #ddd !important; box-shadow: none !important; }
  [data-bs-theme="dark"] .table { --bs-table-color: #000; --bs-table-bg: #fff; --bs-table-border-color: #ddd; --bs-table-striped-bg: #f8f9fa; color: #000; }
  [data-bs-theme="dark"] .table > :not(caption) > * > * { background-color: #fff !important; color: #000 !important; box-shadow: none !important; }
  [data-bs-theme="dark"] .table-light, [data-bs-theme="dark"] .table > thead.table-light > tr > th { background-color: #f1f3f5 !important; color: #000 !important; }
  [data-bs-theme="dark"] .text-muted, [data-bs-theme="dark"] .text-secondary { color: #555 !important; }
  [data-bs-theme="dark"] .text-success { color: #146c43 !important; }
  [data-bs-theme="dark"] .text-danger { color: #b02a37 !important; }
  [data-bs-theme="dark"] .text-primary { color: #0a58ca !important; }
  [data-bs-theme="dark"] .text-warning { color: #997404 !important; }
  [data-bs-theme="dark"] .text-info { color: #087990 !important; }
  [data-bs-theme="dark"] .progress { background: #e9ecef !important; }
  [data-bs-theme="dark"] .chart-legend-table td { border-color: #ddd !important; }
  .progress, .progress-bar, .badge, .badge-dot, .kpi, .insight-icon { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}


/* ===== Cartões KPI: variação e minigráfico ===== */
.kpi .kpi-value .delta { vertical-align: middle; margin-left: .35rem; }
.kpi .kpi-value > .text-money { white-space: nowrap; }
.kpi:has(.kpi-spark) { overflow: hidden; }
.kpi-spark { position: relative; height: 44px; margin: .6rem -1.25rem -1rem; margin-top: auto; padding-top: .35rem; }
.kpi-spark canvas { display: block; }
/* Medidor compacto dentro do cartão (meia rosca ao lado do valor) e rótulo menor para cartões estreitos. */
.kpi-gauge { position: relative; width: 150px; height: 84px; flex-shrink: 0; }
.kpi-gauge canvas { display: block; }
.kpi .kpi-label-sm, .kpi-label-sm { font-size: .68rem; letter-spacing: .02em; white-space: nowrap; }
/* Seis cartões por linha (painel): valor e espaçamento menores, sem perder a hierarquia. */
.kpi.kpi-compact { padding: .85rem 1rem; }
.kpi.kpi-compact .kpi-value { font-size: 1.25rem; }
.kpi.kpi-compact .kpi-label { font-size: .7rem; }
.kpi.kpi-compact .kpi-spark { margin-left: -1rem; margin-right: -1rem; }
.delta { display: inline-flex; align-items: center; gap: .2rem; font-size: .8rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.delta::before { font-weight: 700; }
.delta.up { color: var(--positive); }
.delta.up::before { content: "\2191"; }
.delta.down { color: var(--negative); }
.delta.down::before { content: "\2193"; }
.delta.flat { color: var(--text-muted); }
.delta.flat::before { content: "\2192"; }
/* Semântica independente da direção: "a receber" caindo é bom (.down.good); custo subindo é neutro (.up.neutral). */
.delta.good { color: var(--positive); }
.delta.bad { color: var(--negative); }
.delta.neutral { color: var(--text-muted); }
.delta .delta-ref, .delta-ref { font-weight: 400; color: var(--text-muted); font-size: .76rem; margin-left: .15rem; }
@media (max-width: 575.98px) {
  /* Duas colunas de ~173 px: "R$ 17.300,00" em 1,45rem não cabe; o delta desce para a linha de baixo. */
  .kpi { padding: .85rem 1rem; }
  .kpi .kpi-value { font-size: 1.25rem; }
  .kpi .kpi-value .delta { display: block; margin-left: 0; margin-top: .1rem; }
  .kpi .kpi-value .delta .delta-ref { display: block; margin-left: 0; }
  .kpi-spark { margin-left: -1rem; margin-right: -1rem; }
}

/* ===== Cartão de insight ===== */
.insight { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem .9rem; border-radius: .7rem; background: var(--surface); border: 1px solid var(--border); height: 100%; }
.insight-icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.insight-success .insight-icon { background: rgba(25,135,84,.14); color: #198754; }
.insight-warning .insight-icon { background: rgba(255,193,7,.2); color: #b7791f; }
.insight-danger .insight-icon { background: rgba(220,53,69,.13); color: #dc3545; }
.insight-info .insight-icon { background: rgba(27,79,216,.12); color: #1b4fd8; }
.insight-body { min-width: 0; flex: 1; }
.insight-title { font-weight: 600; font-size: .92rem; line-height: 1.25; margin-bottom: .15rem; }
.insight-text { font-size: .82rem; color: var(--text-muted); line-height: 1.35; margin: 0; }
.insight-action { display: inline-block; font-size: .8rem; margin-top: .3rem; }

/* ===== Cartão de gráfico ===== */
.chart-card { --chart-h: 280px; }
.chart-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: .9rem 1.1rem .4rem; }
.chart-card-head .chart-title { font-weight: 600; font-size: .95rem; margin: 0; line-height: 1.3; }
.chart-card-head .chart-subtitle { font-size: .8rem; color: var(--text-muted); margin: .1rem 0 0; }
.chart-card-head .chart-action { font-size: .82rem; white-space: nowrap; flex-shrink: 0; }
.chart-card-body { position: relative; height: var(--chart-h); padding: 0 .75rem .5rem; }
.chart-card-foot { padding: .25rem 1.1rem .9rem; font-size: .82rem; color: var(--text-muted); }
.chart-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(190px, 42%); gap: 1rem; align-items: center; }
.chart-legend-table { width: 100%; font-size: .85rem; border-collapse: collapse; margin: 0; }
.chart-legend-table td { padding: .32rem .35rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.chart-legend-table tr:last-child td { border-bottom: 0; }
.chart-legend-table .lg-color { width: 1.2rem; padding-right: 0; }
.chart-legend-table .lg-color .badge-dot { margin: 0; }
/* O rótulo fica com a sobra da linha (width 100% + max-width 0 mantém a abreviação com reticências); valor e percentual
   ocupam só o necessário (width 1%). Largura mínima útil da tabela: cerca de 180 px. O nome completo fica no title. */
.chart-legend-table { table-layout: auto; }
.chart-legend-table .lg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; max-width: 0; min-width: 0; }
.chart-legend-table .lg-value { text-align: right; white-space: nowrap; font-weight: 600; width: 1%; }
.chart-legend-table .lg-pct { text-align: right; color: var(--text-muted); width: 1%; min-width: 3.2rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-legend-table tr[role="button"] { cursor: pointer; }
.chart-legend-table tr[role="button"]:hover td { background: rgba(127,139,160,.08); }
.chart-legend-table tr.is-hidden { opacity: .45; }
.chart-legend-table tr.is-hidden .lg-label { text-decoration: line-through; }
@media (max-width: 575.98px) {
  .chart-card-body { height: max(220px, min(var(--chart-h), 300px)); }
  .chart-box, .chart-box-sm { min-height: 220px; }
  .chart-split { grid-template-columns: 1fr; gap: .5rem; }
  .chart-card-head { flex-wrap: wrap; padding: .8rem .9rem .3rem; }
  .chart-card-foot { padding: .25rem .9rem .8rem; }
}

/* ===== Alternância de tema ===== */
.theme-toggle i { font-size: 1rem; line-height: 1; }
.theme-toggle-sidebar { color: var(--sb-fg); border: 1px solid rgba(255,255,255,.12); width: 2.1rem; height: 2.1rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: .5rem; flex-shrink: 0; }
.theme-toggle-sidebar:hover, .theme-toggle-sidebar:focus-visible { background: rgba(255,255,255,.1); color: #fff; }

/* ===== Tema escuro (Bootstrap data-bs-theme="dark") ===== */
[data-bs-theme="dark"] {
  --chart-brand: #f5c242;
  --chart-info: #5b8cff;
  --chart-success: #34d399;
  --chart-danger: #ff6b81;
  --chart-warning: #fbbf24;
  --bg: #0b1220;
  --surface: #131b2e;
  --border: #1f2a44;
  --text: #e6e9f2;
  --text-muted: #9aa4bf;
  --positive: #34d399;
  --negative: #ff6b81;
  --accent: #f5c242;
  --accent-soft: rgba(245,194,66,.16);
  --sb-bg: #0a1020;
  --sb-fg: #b9c2d8;
  --focus: 0 0 0 .2rem rgba(122,162,255,.4);
  --bs-body-bg: #0b1220; --bs-body-bg-rgb: 11,18,32;
  --bs-body-color: #e6e9f2; --bs-body-color-rgb: 230,233,242;
  --bs-emphasis-color: #ffffff; --bs-emphasis-color-rgb: 255,255,255;
  --bs-secondary-color: #9aa4bf; --bs-secondary-color-rgb: 154,164,191;
  --bs-secondary-bg: #182238; --bs-secondary-bg-rgb: 24,34,56;
  --bs-tertiary-color: rgba(230,233,242,.55); --bs-tertiary-color-rgb: 230,233,242;
  --bs-tertiary-bg: #101828; --bs-tertiary-bg-rgb: 16,24,40;
  --bs-border-color: #1f2a44; --bs-border-color-translucent: rgba(230,233,242,.1);
  --bs-link-color: #7aa2ff; --bs-link-color-rgb: 122,162,255; --bs-link-hover-color: #9ab8ff; --bs-link-hover-color-rgb: 154,184,255;
  --bs-heading-color: inherit;
  --bs-code-color: #f472b6;
  color-scheme: dark;
}
[data-bs-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-bs-theme="dark"] .skip-link { background: #182238; color: #fff; }
[data-bs-theme="dark"] :focus-visible { outline-color: #7aa2ff; }
[data-bs-theme="dark"] .sidebar { border-right: 1px solid var(--border); }
[data-bs-theme="dark"] .card { --bs-card-bg: var(--surface); --bs-card-border-color: var(--border); --bs-card-cap-bg: transparent; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.35); }
[data-bs-theme="dark"] .kpi { border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.35); }
[data-bs-theme="dark"] .kpi.kpi-accent { border-top-color: #f5c242; }
[data-bs-theme="dark"] .kpi.kpi-success { border-top-color: #34d399; }
[data-bs-theme="dark"] .kpi.kpi-danger { border-top-color: #ff6b81; }
[data-bs-theme="dark"] .kpi.kpi-info { border-top-color: #38bdf8; }
[data-bs-theme="dark"] .kpi.kpi-warning { border-top-color: #fbbf24; }
[data-bs-theme="dark"] .kpi.kpi-primary { border-top-color: #5b8cff; }
[data-bs-theme="dark"] .topbar { box-shadow: 0 1px 0 var(--border); }
[data-bs-theme="dark"] .table { --bs-table-color: var(--text); --bs-table-bg: transparent; --bs-table-border-color: var(--border); --bs-table-striped-bg: rgba(230,233,242,.03); --bs-table-hover-bg: rgba(230,233,242,.05); --bs-table-hover-color: var(--text); }
[data-bs-theme="dark"] .table-light, [data-bs-theme="dark"] .table > thead.table-light > tr > th { --bs-table-bg: #182238; --bs-table-color: #c7d0e4; --bs-table-border-color: var(--border); background-color: #182238; color: #c7d0e4; }
[data-bs-theme="dark"] .table-warning { --bs-table-bg: rgba(251,191,36,.12); --bs-table-color: var(--text); --bs-table-border-color: rgba(251,191,36,.25); --bs-table-hover-bg: rgba(251,191,36,.18); --bs-table-hover-color: var(--text); }
[data-bs-theme="dark"] .table-danger { --bs-table-bg: rgba(255,107,129,.12); --bs-table-color: var(--text); --bs-table-border-color: rgba(255,107,129,.25); --bs-table-hover-bg: rgba(255,107,129,.18); --bs-table-hover-color: var(--text); }
[data-bs-theme="dark"] .table-active { --bs-table-bg: rgba(230,233,242,.06); --bs-table-color: var(--text); }
[data-bs-theme="dark"] .table tfoot th, [data-bs-theme="dark"] .table tfoot td { border-top-color: #34405f; }
[data-bs-theme="dark"] .bg-white { background-color: var(--surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: #182238 !important; }
[data-bs-theme="dark"] .text-bg-light { background-color: #182238 !important; color: var(--text) !important; }
[data-bs-theme="dark"] .text-bg-light.border { border-color: var(--border) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--text) !important; }
[data-bs-theme="dark"] .text-secondary, [data-bs-theme="dark"] .link-secondary { color: #9aa4bf !important; }
[data-bs-theme="dark"] .text-success { color: #34d399 !important; }
[data-bs-theme="dark"] .text-danger { color: #ff6b81 !important; }
[data-bs-theme="dark"] .text-primary { color: #7aa2ff !important; }
[data-bs-theme="dark"] .text-warning { color: #fbbf24 !important; }
[data-bs-theme="dark"] .text-info { color: #38bdf8 !important; }
[data-bs-theme="dark"] .badge-soft { background: #182238; color: #c7d0e4; border-color: #2a3755; }
[data-bs-theme="dark"] .avatar { background: #243050; color: #d6ddee; }
[data-bs-theme="dark"] .progress { background: #1f2a44; }
[data-bs-theme="dark"] .task-done { color: #74809a; }
[data-bs-theme="dark"] .empty-state i { color: #4f5b7a; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] .input-group-text { background-color: #0f1729; border-color: #2a3755; color: var(--text); }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { border-color: #5b8cff; background-color: #0f1729; }
[data-bs-theme="dark"] .form-control::placeholder { color: #6f7a97; }
[data-bs-theme="dark"] .form-control:disabled, [data-bs-theme="dark"] .form-select:disabled, [data-bs-theme="dark"] .form-control[readonly] { background-color: #182238; }
[data-bs-theme="dark"] .form-check-input { background-color: #0f1729; border-color: #3a4766; }
[data-bs-theme="dark"] .form-check-input:checked { background-color: #1b4fd8; border-color: #1b4fd8; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #b9c2d8; --bs-btn-border-color: #3a4766; --bs-btn-hover-bg: #1f2a44; --bs-btn-hover-border-color: #4a5878; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #243050; --bs-btn-active-border-color: #4a5878; --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-outline-dark { --bs-btn-color: #e6e9f2; --bs-btn-border-color: #6f7a97; --bs-btn-hover-bg: #e6e9f2; --bs-btn-hover-border-color: #e6e9f2; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #c7d0e4; --bs-btn-active-border-color: #c7d0e4; --bs-btn-active-color: #0b1220; }
[data-bs-theme="dark"] .btn-dark { --bs-btn-bg: #e6e9f2; --bs-btn-border-color: #e6e9f2; --bs-btn-color: #0b1220; --bs-btn-hover-bg: #ffffff; --bs-btn-hover-border-color: #ffffff; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #c7d0e4; --bs-btn-active-color: #0b1220; }
[data-bs-theme="dark"] .btn-light { --bs-btn-bg: #182238; --bs-btn-border-color: #2a3755; --bs-btn-color: var(--text); --bs-btn-hover-bg: #1f2a44; --bs-btn-hover-border-color: #3a4766; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #243050; --bs-btn-active-color: #fff; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #2f62ea; --bs-btn-border-color: #2f62ea; --bs-btn-hover-bg: #1b4fd8; --bs-btn-hover-border-color: #1b4fd8; }
[data-bs-theme="dark"] .list-group { --bs-list-group-bg: transparent; --bs-list-group-color: var(--text); --bs-list-group-border-color: var(--border); --bs-list-group-action-hover-bg: rgba(230,233,242,.04); --bs-list-group-action-hover-color: var(--text); --bs-list-group-action-active-bg: rgba(230,233,242,.08); }
[data-bs-theme="dark"] .dropdown-menu { --bs-dropdown-bg: #182238; --bs-dropdown-border-color: var(--border); --bs-dropdown-link-color: var(--text); --bs-dropdown-link-hover-bg: #243050; --bs-dropdown-link-hover-color: #fff; }
[data-bs-theme="dark"] .modal-content { background-color: var(--surface); border-color: var(--border); }
[data-bs-theme="dark"] .nav-tabs { --bs-nav-tabs-border-color: var(--border); --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-color: var(--text); --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--surface); --bs-nav-tabs-link-hover-border-color: var(--border) var(--border) var(--border); }
[data-bs-theme="dark"] .nav-pills { --bs-nav-pills-link-active-bg: #2f62ea; }
[data-bs-theme="dark"] .accordion { --bs-accordion-bg: var(--surface); --bs-accordion-border-color: var(--border); --bs-accordion-btn-bg: var(--surface); --bs-accordion-active-bg: #182238; --bs-accordion-btn-color: var(--text); --bs-accordion-active-color: var(--text); }
[data-bs-theme="dark"] .insight-success .insight-icon { background: rgba(52,211,153,.16); color: #34d399; }
[data-bs-theme="dark"] .insight-warning .insight-icon { background: rgba(251,191,36,.18); color: #fbbf24; }
[data-bs-theme="dark"] .insight-danger .insight-icon { background: rgba(255,107,129,.16); color: #ff6b81; }
[data-bs-theme="dark"] .insight-info .insight-icon { background: rgba(91,140,255,.18); color: #7aa2ff; }
[data-bs-theme="dark"] .chart-legend-table tr[role="button"]:hover td { background: rgba(230,233,242,.05); }
[data-bs-theme="dark"] .invite-card img { box-shadow: 0 2px 12px rgba(0,0,0,.5); }
[data-bs-theme="dark"] .invite-card.selected { outline-color: #f5c242; }
[data-bs-theme="dark"] .login-wrap { background: linear-gradient(135deg, #0b1220 0%, #182238 100%); }
[data-bs-theme="dark"] .portal-hero { background: linear-gradient(135deg, #182238, #26345a); box-shadow: 0 0 0 1px var(--border); }
[data-bs-theme="dark"] .sticky-actions { box-shadow: 0 -4px 12px rgba(0,0,0,.35); }
[data-bs-theme="dark"] .page-footer { border-top-color: var(--border); }
[data-bs-theme="dark"] .alert-secondary { --bs-alert-bg: #182238; --bs-alert-border-color: #2a3755; --bs-alert-color: #c7d0e4; }
[data-bs-theme="dark"] .border, [data-bs-theme="dark"] .border-bottom, [data-bs-theme="dark"] .border-top { border-color: var(--border) !important; }
[data-bs-theme="dark"] .table-responsive { scrollbar-color: #34405f #0f1729; }
[data-bs-theme="dark"] .table-responsive.is-scrollable {
  background:
    linear-gradient(to right, var(--surface) 40%, rgba(19,27,46,0)) left / 48px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, rgba(19,27,46,0)) right / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.65), rgba(0,0,0,0)) left / 16px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.65), rgba(0,0,0,0)) right / 16px 100% no-repeat scroll;
}
/* Botões outline com texto >= 4,5:1 sobre os cartões (#131b2e) e o fundo (#0b1220); no hover ficam cheios com texto escuro. */
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-color: #8db0ff; --bs-btn-border-color: #5b8cff; --bs-btn-hover-bg: #5b8cff; --bs-btn-hover-border-color: #5b8cff; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #7aa2ff; --bs-btn-active-border-color: #7aa2ff; --bs-btn-active-color: #0b1220; --bs-btn-focus-shadow-rgb: 91,140,255; }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: #34d399; --bs-btn-border-color: #2bb985; --bs-btn-hover-bg: #34d399; --bs-btn-hover-border-color: #34d399; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #5fe0b0; --bs-btn-active-border-color: #5fe0b0; --bs-btn-active-color: #0b1220; --bs-btn-focus-shadow-rgb: 52,211,153; }
[data-bs-theme="dark"] .btn-outline-danger { --bs-btn-color: #ff8a9b; --bs-btn-border-color: #ff6b81; --bs-btn-hover-bg: #ff6b81; --bs-btn-hover-border-color: #ff6b81; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #ff8a9b; --bs-btn-active-border-color: #ff8a9b; --bs-btn-active-color: #0b1220; --bs-btn-focus-shadow-rgb: 255,107,129; }
[data-bs-theme="dark"] .btn-outline-warning { --bs-btn-color: #fbbf24; --bs-btn-border-color: #e0a816; --bs-btn-hover-bg: #fbbf24; --bs-btn-hover-border-color: #fbbf24; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #fcd04f; --bs-btn-active-border-color: #fcd04f; --bs-btn-active-color: #0b1220; --bs-btn-focus-shadow-rgb: 251,191,36; }
[data-bs-theme="dark"] .btn-outline-info { --bs-btn-color: #38bdf8; --bs-btn-border-color: #1ea7e4; --bs-btn-hover-bg: #38bdf8; --bs-btn-hover-border-color: #38bdf8; --bs-btn-hover-color: #0b1220; --bs-btn-active-bg: #6ccdf9; --bs-btn-active-border-color: #6ccdf9; --bs-btn-active-color: #0b1220; --bs-btn-focus-shadow-rgb: 56,189,248; }
[data-bs-theme="dark"] .btn-success { --bs-btn-bg: #1f9d6a; --bs-btn-border-color: #1f9d6a; --bs-btn-hover-bg: #178a5c; --bs-btn-hover-border-color: #178a5c; }
/* Caixas "claras" dentro dos cartões: um único tom (#182238), o mesmo de .bg-light. */
[data-bs-theme="dark"] .alert-light { --bs-alert-bg: #182238; --bs-alert-color: var(--text); --bs-alert-border-color: var(--border); --bs-alert-link-color: #9ab8ff; }
[data-bs-theme="dark"] .alert-light.border { border-color: var(--border) !important; }
[data-bs-theme="dark"] .alert-info { --bs-alert-bg: rgba(91,140,255,.14); --bs-alert-color: #cfe0ff; --bs-alert-border-color: rgba(91,140,255,.35); --bs-alert-link-color: #9ab8ff; }
[data-bs-theme="dark"] .alert-warning { --bs-alert-bg: rgba(251,191,36,.14); --bs-alert-color: #fde9b0; --bs-alert-border-color: rgba(251,191,36,.35); --bs-alert-link-color: #fcd04f; }
[data-bs-theme="dark"] .alert-success { --bs-alert-bg: rgba(52,211,153,.14); --bs-alert-color: #c9f5e3; --bs-alert-border-color: rgba(52,211,153,.35); --bs-alert-link-color: #5fe0b0; }
[data-bs-theme="dark"] .alert-danger { --bs-alert-bg: rgba(255,107,129,.14); --bs-alert-color: #ffd3da; --bs-alert-border-color: rgba(255,107,129,.35); --bs-alert-link-color: #ff8a9b; }
[data-bs-theme="dark"] .portal-hero .hero-status { background: rgba(255,255,255,.07); }
[data-bs-theme="dark"] .portal-people .form-check { border-bottom-color: var(--border); }
[data-bs-theme="dark"] .table-sticky-actions > tbody > tr > td:last-child, [data-bs-theme="dark"] .table-sticky-actions > thead > tr > th:last-child { box-shadow: -6px 0 8px -6px rgba(0,0,0,.7); }
@media print { [data-bs-theme="dark"] body { background: #fff; color: #000; } }
