/* Estilos Modernos e Compactos para Tabelas Dinâmicas de Dados (Crédito Agrícola) */

:root {
    /* AG - 2026-10-13 22:10 - Altura do menu (50px) + barra superior (10px) = 60px */
    --ca-top-menu-height: 60px;
    --ca-sticky-gap: 3px;
}

.ca-datatable-wrapper {
    width: 98%;
    margin: 6px auto 18px auto;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    overflow: visible;
    border: 1px solid #cbd5e1;
    font-family: var(--ca-font-family, 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif);
}

.ca-datatable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    color: #334155;
    text-align: left;
}

/* Cabeçalho Fixo ao Fazer Scroll */
.ca-datatable thead {
    position: sticky;
    top: calc(var(--ca-top-menu-height, 50px) + var(--ca-sticky-gap, 3px));
    z-index: 20;
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
    color: #ffffff;
}

.ca-datatable thead tr {
    border-bottom: 2px solid #14592f;
}

th.ca-th,
.ca-datatable th.ca-th,
.ca-datatable thead th {
    position: sticky;
    top: calc(var(--ca-top-menu-height, 50px) + var(--ca-sticky-gap, 3px));
    z-index: 20;
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
    padding: 6px 7px;
    /* Espaço interno reduzido */
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #ffffff;
    border-top: none;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid #14592f;
    white-space: nowrap;
    user-select: none;
    transition: background-color 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

/* Máscara opaca de 3px acima do cabeçalho para ocultar texto durante o scroll */
.ca-datatable th.ca-th::before,
.ca-datatable thead th::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -3px;
    height: 3px;
    background-color: #ffffff;
    pointer-events: none;
    z-index: 25;
}

.ca-datatable th:first-child,
.ca-datatable th.ca-th:first-child {
    border-left: none !important;
    border-top-left-radius: 5px;
}

.ca-datatable th:last-child,
.ca-datatable th.ca-th:last-child,
.ca-datatable thead tr th:last-child {
    border-right: none !important;
    border-top-right-radius: 5px;
}

/* Colunas Ordenáveis */
.ca-datatable th.ca-th-sortable {
    cursor: pointer;
}

.ca-datatable th.ca-th-sortable:hover:not(.ca-th-sorted) {
    background-color: #339c5e;
}

/* Coluna Ordenada Ativa (Verde Escuro) */
.ca-datatable th.ca-th-sorted {
    background: #0d4a27 !important;
}

/* Indicador de Ordenação (do Lado Esquerdo da Label) */
.ca-sort-icon {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    opacity: 0.55;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.ca-th-title {
    vertical-align: middle;
}

.ca-th-sortable:hover .ca-sort-icon {
    opacity: 0.9;
}

.ca-th-sorted .ca-sort-icon {
    opacity: 1;
}

/* Setas CSS Maiores */
.ca-sort-arrow-up,
.ca-sort-arrow-down {
    width: 0;
    height: 0;
    display: block;
}

.ca-sort-arrow-up {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 6px solid rgba(255, 255, 255, 0.5);
    margin-bottom: 2px;
}

.ca-sort-arrow-down {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid rgba(255, 255, 255, 0.5);
}

.ca-th-sortable:hover:not(.ca-th-sorted) .ca-sort-arrow-up {
    border-bottom-color: rgba(255, 153, 51, 0.85);
}

.ca-th-sortable:hover:not(.ca-th-sorted) .ca-sort-arrow-down {
    border-top-color: rgba(255, 153, 51, 0.85);
}

/* Seta Ascendente Ativa (Maior e Destacada na Cor Laranja do Sistema) */
.ca-sort-asc .ca-sort-arrow-up {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid var(--ca-laranja, #FF9933);
    /* Cor laranja do sistema */
    margin-bottom: 0;
}

.ca-sort-asc .ca-sort-arrow-down {
    display: none;
}

/* Seta Descendente Ativa (Maior e Destacada na Cor Laranja do Sistema) */
.ca-sort-desc .ca-sort-arrow-down {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--ca-laranja, #FF9933);
    /* Cor laranja do sistema */
}

.ca-sort-desc .ca-sort-arrow-up {
    display: none;
}

/* Corpo da Tabela */
.ca-datatable tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background-color 0.12s ease;
}

/* Zebra suave */
.ca-datatable tbody tr:nth-child(even) {
    background-color: #ffffff;
}

.ca-datatable tbody tr:nth-child(odd) {
    background-color: #f8fafc;
}

/* Hover na linha */
.ca-datatable tbody tr:hover {
    background-color: #e8f5ec !important;
}

/* Células Compactas */
.ca-datatable td.ca-td,
.ca-datatable td {
    padding: 5px 7px;
    /* Reduzido para caber mais texto */
    font-size: 12px;
    line-height: 1.35;
    color: #334155;
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    text-transform: capitalize;
}

.ca-datatable td input,
.ca-datatable td button,
.ca-datatable td select {
    text-transform: none;
}

.ca-datatable td:first-child,
.ca-datatable td.ca-td:first-child {
    border-left: none !important;
}

.ca-datatable td:last-child,
.ca-datatable td.ca-td:last-child,
.ca-datatable tbody tr td:last-child {
    border-right: none !important;
}

.ca-datatable tbody tr:last-child td {
    border-bottom: none;
}

.ca-datatable tbody tr:last-child td:first-child {
    border-bottom-left-radius: 5px;
}

.ca-datatable tbody tr:last-child td:last-child {
    border-bottom-right-radius: 5px;
}

/* Alinhamentos */
.ca-align-left {
    text-align: left !important;
}

.ca-align-center {
    text-align: center !important;
}

.ca-align-right {
    text-align: right !important;
}

/* Links na Tabela */
.ca-datatable a,
.ca-datatable a:link,
.ca-datatable a:visited {
    color: #0b6635;
    text-decoration: underline;
    font-weight: normal !important;
    font-size: inherit !important;
    transition: color 0.15s ease;
}

.ca-datatable a:hover,
.ca-datatable a:link:hover,
.ca-datatable a:visited:hover {
    color: #054020;
    text-decoration: underline !important;
    font-weight: normal !important;
    font-size: inherit !important;
}

/* Link específico do produto (Ficha do Produto) */
.ca-product-link,
.ca-datatable a.ca-product-link,
.ca-datatable td a.ca-product-link {
    color: #0b6635 !important;
    text-decoration: underline !important;
    font-weight: normal !important;
    font-size: inherit !important;
}

.ca-product-link:hover,
.ca-datatable a.ca-product-link:hover,
.ca-datatable td a.ca-product-link:hover {
    color: #054020 !important;
    text-decoration: underline !important;
    font-weight: normal !important;
    font-size: inherit !important;
}

/* Mensagem quando não existem registos */
.ca-no-records {
    padding: 20px;
    text-align: center;
    color: #64748b;
    font-style: italic;
    font-size: 13px;
}

/* Painel de Navegação de Estatísticas (Crédito Agrícola) */
.ca-stats-panel {
    width: 98%;
    margin: 15px auto 25px auto;
    background-color: #1b7440;
    border: 1px solid #14592f;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    font-family: var(--ca-font-family, 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif);
}

.ca-stats-header {
    background-color: #14562c;
    color: #ffffff;
    text-align: center;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.ca-stats-grid {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    width: 100%;
}

.ca-stats-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 10px 20px 10px;
    text-decoration: none !important;
    border-right: 1px solid rgba(255, 255, 255, 0.45);
    background-color: #1b7440;
    transition: background-color 0.15s ease, filter 0.15s ease;
    cursor: pointer;
}

.ca-stats-btn:last-child {
    border-right: none;
}

.ca-stats-btn:hover {
    background-color: #248b4e;
}

.ca-stats-icon-box {
    background-color: #ffffff;
    padding: 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.ca-stats-icon-box img {
    display: block;
    width: 58px;
    height: 58px;
    object-fit: contain;
}

.ca-stats-label {
    color: #ffffff !important;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1.35;
}

/* Botões Padrão Harmonizados com Cabeçalhos (Crédito Agrícola) */
.btn-normal,
input[type="submit"].btn-normal,
input[type="button"].btn-normal,
button.btn-normal {
    line-height: normal;
    text-transform: uppercase;
    display: inline-block;
    padding: 6px 14px;
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%) !important;
    background-color: #207742 !important;
    color: #ffffff !important;
    text-decoration: none;
    border-radius: 4px;
    font-weight: unset;
    font-size: 12px;
    letter-spacing: 0.4px;
    border: 1px solid #14592f !important;
    cursor: pointer;
    font-family: var(--ca-font-family, 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif);
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: background 0.15s ease, border-color 0.15s ease;
    text-align: center;
    box-sizing: border-box;
}

.btn-equal-dim {
    width: 140px;
    padding-left: 6px !important;
    padding-right: 6px !important;
    white-space: nowrap;
    vertical-align: middle;
}

.btn-equal-dim+.btn-equal-dim {
    margin-left: 6px;
}

.btn-normal:hover,
input[type="submit"].btn-normal:hover,
input[type="button"].btn-normal:hover,
button.btn-normal:hover {
    background: #339c5e !important;
    background-color: #339c5e !important;
    border-color: #1e7a44 !important;
    color: #ffffff !important;
    text-decoration: none;
}

.btn-normal:active,
input[type="submit"].btn-normal:active,
input[type="button"].btn-normal:active,
button.btn-normal:active {
    background: #14592f !important;
    background-color: #14592f !important;
    border-color: #0d4a27 !important;
}

/* Botões da Modal (ca-modal) */
.ca-btn {
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--ca-font-family, 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    user-select: none;
}

.btn-ok-alert,
.btn-ok-confirm,
#ca-btn-ok {
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%) !important;
    background-color: #207742 !important;
    color: #ffffff !important;
    border: 1px solid #14592f !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-ok-alert:hover,
.btn-ok-confirm:hover,
#ca-btn-ok:hover {
    background: #339c5e !important;
    background-color: #339c5e !important;
    border-color: #1e7a44 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.ca-btn-cancel,
#ca-btn-cancel {
    background: transparent;
    color: #777777;
    border: 1px solid transparent;
}

.ca-btn-cancel:hover,
#ca-btn-cancel:hover {
    background: #339c5e !important;
    background-color: #339c5e !important;
    color: #ffffff !important;
    border-color: #1e7a44 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Estatísticas TOP 10+1 por Entidade e Ano (Crédito Agrícola)
   ========================================================================== */


/* Linha Selecionada nas Tabelas Padrão (Sem alterar tamanho nem peso de fonte) */
.ca-datatable tr.ca-row-selected {
    background-color: #e8f5ec !important;
}

.ca-datatable tr.ca-row-selected td {
    color: #065f46 !important;
    font-weight: normal !important;
    font-size: 12px !important;
}

/* Tabela de Seleção de Relatórios com Altura Homogénea Estrita de 32px */
.ca-report-selector-table tbody tr,
.ca-report-row {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
}

.ca-report-td {
    height: 32px !important;
    padding: 0 10px !important;
    vertical-align: middle !important;
}

/* Links da Tabela de Seleção de Relatórios TOP 10+1 (Sem sublinhado e altura uniforme) */
.ca-datatable a.ca-report-link,
.ca-datatable a.ca-report-link:link,
.ca-datatable a.ca-report-link:visited,
.ca-datatable a.ca-report-link:hover,
.ca-datatable a.ca-report-link:active,
.ca-datatable tr.ca-row-selected a.ca-report-link,
.ca-datatable tr.ca-row-selected a.ca-report-link:hover,
.ca-datatable tr:hover a.ca-report-link {
    display: flex;
    align-items: center;
    height: 32px;
    line-height: 32px;
    text-decoration: none !important;
    font-size: 12px !important;
    font-weight: normal !important;
    color: #0b6635 !important;
    box-sizing: border-box;
    transition: color 0.15s ease;
}

.ca-datatable tr.ca-row-selected a.ca-report-link {
    color: #065f46 !important;
}

.ca-datatable a.ca-report-link:hover,
.ca-datatable tr:hover a.ca-report-link {
    color: #054020 !important;
    text-decoration: none !important;
}

/* Espaço reservado e fixo para o marcador / seta (impede que o texto seja empurrado) */
.ca-report-bullet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    min-width: 20px;
    height: 32px;
    line-height: 32px;
    margin-right: 6px;
    font-size: 10px;
    color: #0b6635;
    flex-shrink: 0;
    user-select: none;
    box-sizing: border-box;
}

.ca-datatable tr.ca-row-selected .ca-report-bullet {
    color: #065f46;
}

.ca-report-text {
    flex: 1;
    height: 32px;
    line-height: 32px;
    white-space: nowrap;
    text-decoration: none !important;
}

/* Garantia estrita de tamanho e peso de letra inalterados em links de tabelas */
.ca-datatable a,
.ca-datatable a:hover,
.ca-datatable a:visited,
.ca-datatable a:active {
    font-size: inherit !important;
    font-weight: normal !important;
}


/* AG- Faixa de Título do Relatório Ativo: 1176px (98% de 1200px do container principal) */
.ca-top-banner {
    width: 1176px;
    max-width: 1176px;
    margin: 0 auto 12px auto;
    box-sizing: border-box;
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
    color: #ffffff;
    text-align: center;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* AG- Contentor de Scroll Horizontal dos Anos: 1176px para alinhar com a tabela anterior sem estender tabela_principal */
.ca-top-scroll-wrapper {
    width: 1176px;
    max-width: 1176px;
    margin: 0 auto 24px auto;
    overflow-x: auto;
    overflow-y: hidden;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #2a8b51 #f1f5f9;
}

.ca-top-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.ca-top-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.ca-top-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #2a8b51;
    border-radius: 4px;
}

.ca-top-scroll-wrapper::-webkit-scrollbar-thumb:hover {
    background: #14592f;
}

.ca-top-years-flex {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 10px;
    align-items: stretch;
    width: max-content;
}

/* Coluna de cada Ano */
.ca-top-year-col {
    flex: 0 0 280px;
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ca-top-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    color: #334155;
    text-align: left;
}

.ca-top-th-year {
    background: #14562c !important;
    color: #ffffff !important;
    text-align: center !important;
    padding: 6px 8px !important;
    font-size: 12px !important;
    font-weight: bold !important;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25) !important;
}

.ca-top-th-sub {
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%) !important;
    color: #ffffff !important;
    padding: 5px 6px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border-bottom: 2px solid #14592f !important;
    border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.ca-top-th-sub:last-child {
    border-right: none !important;
}

.ca-top-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.12s ease;
}

.ca-top-table tbody tr:nth-child(even) {
    background-color: #ffffff;
}

.ca-top-table tbody tr:nth-child(odd) {
    background-color: #f8fafc;
}

.ca-top-table tbody tr:hover {
    background-color: #e8f5ec !important;
}

.ca-top-td-pedidos {
    width: 58px;
    min-width: 58px;
    text-align: center;
    padding: 4px 6px;
    font-size: 11px;
    font-weight: bold;
    color: #1e293b;
    border-right: 1px solid #e2e8f0;
    background-color: rgba(0, 150, 94, 0.03);
}

.ca-top-td-entidade {
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.3;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.ca-top-td-entidade:hover {
    color: #0b6635;
}

/* Indicador de Top 1 */
.ca-top-rank-1 {
    font-weight: 600;
}

.ca-top-rank-1 .ca-top-td-pedidos {
    color: #0b6635;
    background-color: rgba(0, 150, 94, 0.09);
}

/* AG- Aviso de seleção inicial: 1176px */
.ca-top-empty-state {
    width: 1176px;
    max-width: 1176px;
    margin: 20px auto;
    padding: 30px 20px;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    color: #64748b;
    font-size: 13px;
}

/* ==========================================================================
   AG- Tabela Matriz de Distribuição Anual por Entidade (1176px = 98% de 1200px)
   ========================================================================== */
.ca-matrix-section {
    width: 1176px;
    max-width: 1176px;
    margin: 18px auto 30px auto;
    box-sizing: border-box;
}

.ca-matrix-header {
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
    color: #ffffff;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 4px 4px 0 0;
    box-sizing: border-box;
}

.ca-matrix-table-wrapper {
    width: 100%;
    max-width: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-top: none;
    border-radius: 0 0 6px 6px;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 540px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #2a8b51 #f1f5f9;
}

.ca-matrix-table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.ca-matrix-table-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.ca-matrix-table-wrapper::-webkit-scrollbar-thumb {
    background: #2a8b51;
    border-radius: 4px;
}

.ca-matrix-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #14592f;
}

.ca-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    color: #334155;
    text-align: left;
    white-space: nowrap;
}

.ca-matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #14562c;
    color: #ffffff;
    padding: 7px 8px;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 2px solid #0d4a27;
}

.ca-matrix-table thead th:last-child {
    border-right: none;
}

.ca-matrix-table thead th.ca-th-sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.ca-matrix-table thead th.ca-th-sortable:hover:not(.ca-th-sorted) {
    background-color: #207742 !important;
}

.ca-matrix-table thead th.ca-th-sorted {
    background: #0d4a27 !important;
}


.ca-matrix-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.12s ease;
}

.ca-matrix-table tbody tr:nth-child(even) {
    background-color: #ffffff;
}

.ca-matrix-table tbody tr:nth-child(odd) {
    background-color: #f8fafc;
}

.ca-matrix-table tbody tr:hover {
    background-color: #e8f5ec !important;
}

.ca-matrix-th-entidade {
    width: 22%;
    min-width: 170px;
    max-width: 220px;
}

.ca-matrix-td-entidade {
    width: 22%;
    min-width: 170px;
    max-width: 220px;
    padding: 5px 8px;
    font-size: 11px;
    color: #334155;
    font-weight: 500;
    border-right: 1px solid #e2e8f0;
    vertical-align: middle;
}

.ca-matrix-td-num {
    padding: 6px 8px;
    text-align: right;
    font-size: 11px;
    color: #334155;
    border-right: 1px solid #f1f5f9;
}

.ca-matrix-td-total {
    padding: 6px 10px;
    text-align: right;
    font-size: 11px;
    font-weight: bold;
    color: #14562c;
    background-color: rgba(0, 150, 94, 0.05);
    border-right: 1px solid #e2e8f0;
}

.ca-matrix-td-media {
    padding: 6px 10px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
}

/* ==========================================================================
   Ícone de Minigráfico e Tooltip Flutuante com Canvas (Crédito Agrícola)
   ========================================================================== */
.ca-matrix-entity-cell {
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
}

.ca-chart-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 20px;
    min-width: 22px;
    flex-shrink: 0;
    margin-right: 6px;
    background: #eef7f1;
    color: #1b7440;
    border: 1px solid #c2e2d0;
    border-radius: 3px;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.15s ease;
    user-select: none;
}

.ca-chart-btn:hover,
.ca-matrix-td-entidade:hover .ca-chart-btn {
    background: #207742;
    color: #ffffff;
    border-color: #14592f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ca-matrix-entity-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #334155;
    font-weight: 500;
}

/* Tooltip Flutuante com Gráfico Canvas (A 10px da margem superior, centrado horizontalmente) */
.ca-chart-tooltip {
    position: fixed;
    top: 10px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 999999;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.06);
    padding: 14px 18px 12px 18px;
    width: 500px;
    box-sizing: border-box;
    font-family: var(--ca-font-family, 'Roboto', sans-serif);
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.ca-chart-tooltip-header {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.ca-chart-tooltip-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin-bottom: 6px;
    white-space: normal;
    word-break: break-word;
}

.ca-chart-tooltip-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.ca-chart-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}

.ca-badge-total {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.ca-badge-years {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.ca-badge-avg {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.ca-chart-canvas-container {
    width: 100%;
    height: 200px;
    position: relative;
    background: #fafcfb;
    border-radius: 4px;
    border: 1px solid #edf2f7;
}

.ca-chart-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.ca-chart-tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 6px;
    margin-top: 6px;
    font-size: 10px;
    color: #64748b;
}

.ca-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ca-legend-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.ca-legend-bar {
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
}

.ca-legend-avg {
    background: #ea580c;
    height: 3px;
    width: 14px;
    border-radius: 1px;
}

/* ==========================================================================
   AG- Painel de Seleção Segmented Controls para TOP 10+1
   ========================================================================== */
.ca-top-selector-panel {
    width: 1176px;
    max-width: 1176px;
    margin: 6px auto 18px auto;
    box-sizing: border-box;
}

.ca-top-selector-header {
    background: linear-gradient(180deg, #2a8b51 0%, #207742 100%);
    color: #ffffff;
    padding: 7px 12px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 4px 4px 0 0;
    box-sizing: border-box;
}

.ca-top-selector-body {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 12px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ca-top-selector-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ca-top-selector-label {
    width: 130px;
    min-width: 130px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ca-top-selector-group {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ca-seg-btn {
    appearance: none;
    -webkit-appearance: none;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    outline: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ca-seg-btn:hover:not(.ca-seg-active) {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #0f172a;
}

.ca-seg-btn.ca-seg-active {
    background: #1e3a8a !important;
    /* AG- Azul escuro de destaque */
    border-color: #1e3a8a !important;
    color: #ffffff !important;
    box-shadow: 0 2px 4px rgba(30, 58, 138, 0.25);
    font-weight: bold;
}

/* AG - 2026-10-13 - Estilo para Item de Menu Ativo no Menu Superior */
.menu_top td.menu_active,
.menu_top td.active {
    background-color: rgb(192, 215, 192);
}

.menu_top td.menu_active .link_top,
.menu_top td.menu_active a,
.menu_top td.active .link_top,
.menu_top td.active a,
.link_top.menu_active,
.link_top.active {
    color: #000000;
    text-decoration: underline;
    text-decoration-color: #000000;
}

.menu_top td.menu_active .link_top:hover,
.menu_top td.menu_active a:hover,
.menu_top td.active .link_top:hover,
.menu_top td.active a:hover,
.link_top.menu_active:hover,
.link_top.active:hover {
    color: #000000;
    text-decoration: none;
}

.menu_top td.menu_active .username,
.menu_top td.active .username {
    color: #000000;
}

.menu_top td.menu_active img,
.menu_top td.active img,
.link_top.menu_active img,
.link_top.active img {
    filter: invert(100%);
}