/* Módulo contábil: estilos próprios (o Tailwind do projeto é pré-compilado). */

:root {
    --ct-bg: #f5f6f8;
    --ct-surface: #ffffff;
    --ct-muted: #f1f3f6;
    --ct-border: #e1e5eb;
    --ct-text: #1b2230;
    --ct-text-2: #5a6475;
    --ct-accent: #0f766e;
    --ct-accent-strong: #0b5a54;
    --ct-accent-soft: #e5f3f1;
    --ct-pos: #11743b;
    --ct-neg: #b42318;
    --ct-warn-bg: #fff6e5;
    --ct-warn-border: #f3d193;
    --ct-warn: #7a4a00;
    --ct-info-bg: #eef4fb;
    --ct-bar-a: #0f766e;
    --ct-bar-b: #c2410c;
    --ct-radius: 12px;
    --ct-sombra: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

html.dark {
    --ct-bg: #0f141b;
    --ct-surface: #161c25;
    --ct-muted: #1d2531;
    --ct-border: #2a3442;
    --ct-text: #e6e9ee;
    --ct-text-2: #9aa4b2;
    --ct-accent: #2bb3a6;
    --ct-accent-strong: #5fd0c5;
    --ct-accent-soft: #143331;
    --ct-pos: #4ccf83;
    --ct-neg: #f47066;
    --ct-warn-bg: #2d2412;
    --ct-warn-border: #5c4718;
    --ct-warn: #f3c56b;
    --ct-info-bg: #16263a;
    --ct-bar-a: #2bb3a6;
    --ct-bar-b: #f08a4b;
    --ct-sombra: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.ct-page {
    color: var(--ct-text);
    padding: 28px 28px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-variant-numeric: tabular-nums;
}

.ct-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}
.ct-eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ct-accent);
    margin: 0;
}
.ct-title { font-size: 24px; font-weight: 700; margin: 2px 0 0; color: var(--ct-text); }
.ct-subtitle { font-size: 13px; color: var(--ct-text-2); margin: 4px 0 0; max-width: 760px; }

.ct-card {
    background: var(--ct-surface);
    border: 1px solid var(--ct-border);
    border-radius: var(--ct-radius);
    padding: 18px 20px;
    min-width: 0;
    box-shadow: var(--ct-sombra);
}
.ct-card--flush { padding: 0; overflow: hidden; }
.ct-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ct-border);
}
.ct-card h2, .ct-card-head h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--ct-text); }
.ct-note { font-size: 12px; color: var(--ct-text-2); margin: 0; }

.ct-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.ct-grid--2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
@media (max-width: 520px) {
    .ct-grid--2 { grid-template-columns: 1fr; }
}

.ct-kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ct-kpi { background: var(--ct-surface); border: 1px solid var(--ct-border); border-radius: var(--ct-radius); padding: 16px 18px; box-shadow: var(--ct-sombra); }
.ct-kpi-label { font-size: 12px; color: var(--ct-text-2); margin: 0; }
.ct-kpi-value { font-size: 22px; font-weight: 700; margin: 4px 0 2px; white-space: nowrap; }
.ct-kpi-sub { font-size: 12px; color: var(--ct-text-2); margin: 0; }

.ct-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--ct-border); }
.ct-tab {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ct-text-2);
    border-bottom: 2px solid transparent;
    text-decoration: none;
}
.ct-tab:hover { color: var(--ct-text); }
.ct-tab--ativa { color: var(--ct-accent); border-bottom-color: var(--ct-accent); }

.ct-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.ct-field { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.ct-field label, .ct-label { font-size: 12px; font-weight: 500; color: var(--ct-text-2); }
.ct-field--check { flex-direction: row; align-items: center; gap: 6px; min-width: 0; padding-bottom: 8px; }
.ct-input, .ct-page select, .ct-page input[type="date"], .ct-page input[type="text"],
.ct-page input[type="number"], .ct-page input[type="search"], .ct-page input[type="month"] {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--ct-border);
    border-radius: 8px;
    background: var(--ct-surface);
    color: var(--ct-text);
    font-size: 13px;
}
.ct-page input[type="file"] { font-size: 13px; color: var(--ct-text-2); }

.ct-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--ct-border);
    background: var(--ct-surface);
    color: var(--ct-text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.ct-btn:hover { background: var(--ct-muted); }
.ct-btn--primario { background: var(--ct-accent); border-color: var(--ct-accent); color: #fff; }
.ct-btn--primario:hover { background: var(--ct-accent-strong); }
.ct-btn--pequeno { height: 28px; padding: 0 10px; font-size: 12px; }
.ct-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.ct-table-wrap { overflow-x: auto; }
.ct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ct-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ct-text-2);
    background: var(--ct-muted);
    padding: 8px 12px;
    white-space: nowrap;
}
.ct-table td { padding: 7px 12px; border-top: 1px solid var(--ct-border); vertical-align: top; }
.ct-table .ct-num, .ct-table th.ct-num { text-align: right; white-space: nowrap; }
.ct-table tfoot td { font-weight: 700; background: var(--ct-muted); }
.ct-row-sintetica td { font-weight: 600; }
.ct-row-subtotal td { font-weight: 600; background: var(--ct-muted); }
.ct-row-total td { font-weight: 700; background: var(--ct-accent-soft); color: var(--ct-text); }
.ct-row-alerta td { background: var(--ct-warn-bg); color: var(--ct-warn); }
.ct-row-detalhe td { color: var(--ct-text-2); font-size: 12px; }
.ct-nivel-2 { padding-left: 24px !important; }
.ct-nivel-3 { padding-left: 40px !important; }
.ct-nivel-4 { padding-left: 56px !important; }
.ct-nivel-5 { padding-left: 72px !important; }
.ct-codigo { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ct-text-2); margin-right: 6px; }

.ct-pos { color: var(--ct-pos); }
.ct-neg { color: var(--ct-neg); }
.ct-muted { color: var(--ct-text-2); }

.ct-alert {
    border: 1px solid var(--ct-warn-border);
    background: var(--ct-warn-bg);
    color: var(--ct-warn);
    border-radius: var(--ct-radius);
    padding: 12px 16px;
    font-size: 13px;
}
.ct-alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.ct-info { background: var(--ct-info-bg); border: 1px solid var(--ct-border); border-radius: var(--ct-radius); padding: 12px 16px; font-size: 13px; }

.ct-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--ct-muted);
    color: var(--ct-text-2);
}
.ct-badge--ok { background: var(--ct-accent-soft); color: var(--ct-accent); }
.ct-badge--alerta { background: var(--ct-warn-bg); color: var(--ct-warn); }

.ct-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.ct-rank-linha { display: flex; justify-content: space-between; gap: 8px; }
.ct-rank-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-rank-barra { height: 6px; border-radius: 3px; background: var(--ct-muted); margin-top: 4px; }
.ct-rank-barra span { display: block; height: 6px; border-radius: 3px; background: var(--ct-bar-b); }

.ct-chart { width: 100%; height: auto; display: block; }
.ct-chart text { fill: var(--ct-text-2); font-size: 11px; }
.ct-chart .ct-eixo { stroke: var(--ct-border); stroke-width: 1; }
.ct-chart .ct-barra-a { fill: var(--ct-bar-a); }
.ct-chart .ct-barra-b { fill: var(--ct-bar-b); }
.ct-chart .ct-linha { fill: none; stroke: var(--ct-text); stroke-width: 2; }
.ct-chart .ct-ponto { fill: var(--ct-surface); stroke: var(--ct-text); stroke-width: 2; }
.ct-legenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--ct-text-2); margin-bottom: 8px; }
.ct-legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.ct-pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-top: 1px solid var(--ct-border); font-size: 13px; }
.ct-empty { padding: 36px 20px; text-align: center; color: var(--ct-text-2); font-size: 13px; }

.ct-page details > summary { cursor: pointer; list-style: none; }
.ct-page details > summary::-webkit-details-marker { display: none; }
.ct-page details > summary::before { content: "▸ "; color: var(--ct-text-2); }
.ct-page details[open] > summary::before { content: "▾ "; }

a.ct-card { text-decoration: none; transition: border-color 0.15s ease, transform 0.15s ease; }
a.ct-card:hover { border-color: var(--ct-accent); transform: translateY(-1px); }

/* ------------------------------------------------ gráficos de gastos
   Paleta categórica validada (scripts/validate_palette.js do guia de dataviz):
   5 cores em ordem fixa, passos próprios para o tema escuro. "Outros" é cinza. */
:root {
    --ct-serie-1: #2a78d6;
    --ct-serie-2: #eb6834;
    --ct-serie-3: #1baf7a;
    --ct-serie-4: #eda100;
    --ct-serie-5: #e87ba4;
    --ct-serie-outros: #a3abb6;
    --ct-grade: #e8ebef;
    --ct-eixo: #c9ced6;
}
html.dark {
    --ct-serie-1: #3987e5;
    --ct-serie-2: #d95926;
    --ct-serie-3: #199e70;
    --ct-serie-4: #c98500;
    --ct-serie-5: #d55181;
    --ct-serie-outros: #56606e;
    --ct-grade: #232c38;
    --ct-eixo: #36414f;
}
.ct-serie-1 { fill: var(--ct-serie-1); background: var(--ct-serie-1); }
.ct-serie-2 { fill: var(--ct-serie-2); background: var(--ct-serie-2); }
.ct-serie-3 { fill: var(--ct-serie-3); background: var(--ct-serie-3); }
.ct-serie-4 { fill: var(--ct-serie-4); background: var(--ct-serie-4); }
.ct-serie-5 { fill: var(--ct-serie-5); background: var(--ct-serie-5); }
.ct-serie-0 { fill: var(--ct-serie-outros); background: var(--ct-serie-outros); }

.ct-grid--graficos { grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); align-items: start; }
.ct-card-head--solto { padding: 0 0 14px; border: 0; }
.ct-kpi-value--texto { font-size: 18px; overflow: hidden; text-overflow: ellipsis; }

.ct-barras { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ct-barra-linha {
    display: grid;
    grid-template-columns: minmax(90px, 38%) 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 5px 6px;
    border-radius: 6px;
    font-size: 13px;
}
.ct-barra-linha:hover { background: var(--ct-muted); }
.ct-barra-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-barra-trilho { height: 10px; }
.ct-barra-preenchida { display: block; height: 10px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--ct-accent); }
.ct-barra-preenchida--outros { background: var(--ct-serie-outros); }
.ct-barra-valor { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }

.ct-legenda-series { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ct-text-2); }
.ct-legenda-series i, .ct-marcador { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.ct-colunas { width: 100%; height: auto; display: block; }
.ct-colunas .ct-grade { stroke: var(--ct-grade); stroke-width: 1; }
.ct-colunas .ct-eixo-base { stroke: var(--ct-eixo); stroke-width: 1; }
.ct-colunas .ct-eixo-texto { fill: var(--ct-text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.ct-colunas .ct-total-coluna { fill: var(--ct-text); font-size: 11px; font-weight: 600; }
.ct-colunas .ct-segmento { transition: opacity 0.12s ease; }
.ct-colunas:hover .ct-segmento { opacity: 0.55; }
.ct-colunas .ct-segmento:hover { opacity: 1; }

.ct-dica {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 70;
    max-width: 320px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--ct-text);
    color: var(--ct-surface);
    font-size: 12px;
    line-height: 1.4;
    pointer-events: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
@media (max-width: 640px) {
    .ct-barra-linha { grid-template-columns: 1fr auto; row-gap: 4px; }
    .ct-barra-trilho { grid-column: 1 / -1; grid-row: 2; }
}

/* ------------------------------------------------ contas a pagar */
.ct-situacao--vencido { background: #fde8e7; color: #a4221b; }
.ct-situacao--vence_em_breve { background: var(--ct-warn-bg); color: var(--ct-warn); }
.ct-situacao--a_vencer { background: var(--ct-muted); color: var(--ct-text-2); }
.ct-situacao--parcial { background: var(--ct-info-bg); color: #1d4f91; }
.ct-situacao--pago { background: var(--ct-accent-soft); color: var(--ct-accent); }
html.dark .ct-situacao--vencido { background: #3a1716; color: #f79c95; }
html.dark .ct-situacao--parcial { color: #8cb8f5; }
.ct-tabela-cp td { white-space: nowrap; }
.ct-tabela-cp .ct-badge + .ct-badge { margin-left: 4px; }
.ct-linha-vencida td { background: color-mix(in srgb, var(--ct-neg) 6%, transparent); }
.ct-fornecedor { display: block; font-weight: 500; }
.ct-cnpj, .ct-sub { display: block; font-size: 11.5px; color: var(--ct-text-2); font-variant-numeric: tabular-nums; margin-top: 2px; }
.ct-observacao { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--ct-text-2); }
.ct-nowrap { white-space: nowrap; }

/* ------------------------------------------------ diagnóstico do SharePoint */
.ct-config { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 10px 0 14px; font-size: 13px; }
.ct-config dt { color: var(--ct-text-2); }
.ct-config dd { margin: 0; overflow-wrap: anywhere; }
.ct-etapas { list-style: none; margin: 0; padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.ct-etapas li { display: flex; gap: 10px; align-items: flex-start; }
.ct-etapas i { margin-top: 2px; font-size: 15px; }
.ct-etapas .is-ok i { color: var(--ct-pos); }
.ct-etapas .is-falha i { color: var(--ct-neg); }
.ct-etapas .is-falha strong { color: var(--ct-neg); }
.ct-diag-bloco { padding: 0 20px 14px; }
.ct-diag-bloco .ct-badge { margin: 2px 2px 0 0; }

/* ------------------------------------------------ recebimentos */
.ct-barra-preenchida--entrada { background: var(--ct-pos); }
.ct-barra-nome .ct-marcador { margin-right: 6px; }
.ct-barra-valor .ct-sub { text-align: right; }
