/* ==========================================================
   WRAPPER
========================================================== */

.data-table-wrap {

    background: var(--card-bg);

    border: 1px solid var(--border-color);

    border-radius: 0;

    overflow: auto;

    max-height: 840px;
}

/* ==========================================================
   TABELA
========================================================== */

.data-table {

    width: 100%;

    border-collapse: collapse;

    font-size: var(--font-size-scale-base);
}

/* ==========================================================
   CABEÇALHO
========================================================== */

.data-table thead th {

    position: sticky;

    top: 0;

    background: var(--thead-bg);

    color: var(--text-faint);

    text-transform: uppercase;

    font-size: 11px;

    letter-spacing: .5px;

    padding: var(--table-row-small) var(--table-padding);

    text-align: right;

    border-bottom: 2px solid var(--border-color);

    z-index: 1;

    font-weight: var(--font-weight-semi-bold);
}

.data-table thead th:first-child {

    text-align: left;
}

/* Cabeçalho unificado: colunas de valores (últimas 3) alinhadas à direita */
#tabelaHead th:nth-last-child(-n+3) {

    text-align: left;
}

/* Área das colunas configuráveis nas linhas da ÁRVORE/thead (span vazio) */
.config-span {

    background: transparent;

}

/* Linha-cabeçalho CONGELADA do nó expandido.
   Fica logo abaixo do thead (que já é sticky em top:0) e acima dos registros,
   permanecendo visível enquanto se rola pela faixa de registros do nó. */
.frozen-construtor-header {

    position: sticky;

    z-index: 2;

    background: var(--thead-bg);

    color: var(--text-faint);

    text-transform: uppercase;

    font-size: 11px;

    letter-spacing: .5px;

    border-bottom: 2px solid var(--border);

}

.frozen-construtor-header th {

    text-align: right;

    padding: 8px 12px;

    white-space: nowrap;

}

.frozen-construtor-header th[data-ci] {

    text-align: left;

    cursor: grab;

    user-select: none;

}

.frozen-construtor-header th[data-ci]:active {

    cursor: grabbing;

}

.frozen-construtor-header th[data-ci]:hover {

    color: var(--primary);

}

.frozen-construtor-header td.detalhe-label-cell {

    padding-left: 52px;

}

/* ==========================================================
   LINHAS
========================================================== */

.data-table td {

    padding: var(--table-row-small) var(--table-padding);

    border-bottom: 1px solid var(--border-color);

    color: var(--text);
}

.data-table tbody tr:hover {

    background-image: linear-gradient(
        rgba(var(--color-rgb), var(--hover)),
        rgba(var(--color-rgb), var(--hover))
    );
}

/* ==========================================================
   NÚMEROS
========================================================== */

.numeric {

    text-align: right;

    font-family: var(--mono);
}

/* ==========================================================
   TOTAIS
========================================================== */

.total-row {

    font-weight: 700;

    background: rgba(var(--primary-rgb), 0.10);
}

.total-row td {

    border-top: 2px solid var(--primary);
}

/* ==========================================================
   SEM DADOS
========================================================== */

.empty-table {

    padding: 40px;

    text-align: center;

    color: var(--text-faint);
}

/* ==========================================================
   ROWS EXPANSÍVEIS / DETALHES

.row-mes.expandivel {

    cursor: pointer;
}

.row-mes.expandivel:hover {

    background: rgba(255,255,255,0.03);
}

.toggle-icon {

    display: inline-block;

    width: 16px;

    text-align: center;

    font-weight: 700;

    color: var(--primary);

    font-size: 14px;

    margin-right: 4px;
}

.row-mes.aberto .toggle-icon {

    color: var(--danger);
}

.row-detalhe {

    background: rgba(var(--primary-rgb), 0.04);
}

.detalhe-cell {

    padding-left: 36px !important;

    font-size: 12px;

    color: var(--text-dim);

    border-bottom: 1px solid var(--border-soft);
}

.dou-link {

    color: var(--primary);

    text-decoration: none;

    transition: color .15s;
}

.dou-link:hover {

    color: #6ea8fe;

    text-decoration: underline;
}

/* ==========================================================
   ROW DE INSTRUMENTO (2º nível da árvore)
========================================================== */

.row-instr {

    cursor: pointer;

    background: rgba(var(--primary-rgb), 0.04);
}

.row-instr:hover {

    background: rgba(var(--primary-rgb), 0.08);
}

.row-instr.aberto {

    background: rgba(var(--primary-rgb), 0.10);
}
.row-instr.aberto .toggle-icon {

    color: var(--danger);

}

/* ==========================================================
   CÉLULA DE RÓTULO (1ª coluna fixa do cabeçalho unificado)
========================================================== */

.detalhe-label-cell {

    text-align: left;

}

.row-instr .detalhe-label-cell {

    padding-left: 36px !important;

    font-size: 12px;

    color: var(--text-dim);

}

/* ==========================================================
   ROW DE REGISTROS (nível 3 da árvore, mesmo tbody)
========================================================= */

.row-registro {

    background: var(--bg-soft);

}

.row-registro .detalhe-label-cell {

    padding-left: 52px !important;

}

.row-registro td {

    font-size: 12px;

    color: var(--text-dim);

}

/* ==========================================================
   TREE-TOTAL ROW (total dos registros do nó expandido)
========================================================== */

.tree-total-row .detalhe-label-cell {

    padding-left: 36px !important;

}

/* ==========================================================
   ROW DE TOTAIS DO CONSTRUTOR
========================================================== */

.row-total {

    font-weight: 700;

    background: var(--bg-soft);
}

.row-total td {

    border-top: 2px solid var(--border);

}

/* ==========================================================
   HOST DO CONSTRUTOR DENTRO DA ÁRVORE
   (sub-tabela construtora embutida sob o instrumento/mês)
========================================================== */

.tree-construtor-row {

    background: var(--bg-soft);

}

.tree-construtor-cell {

    padding: 0 !important;

    border-bottom: none !important;

}

.tree-construtor-host {

    padding: 10px 12px 14px 36px;

    border-left: 3px solid var(--primary);

    background: rgba(var(--primary-rgb), 0.05);

}

.tree-construtor-host .construtor-section {

    border: 1px solid var(--border);

    border-radius: var(--radius-lg);

    overflow: hidden;

    background: var(--card-bg);

}

.tree-construtor-host .construtor-table-wrap {

    max-height: 380px;

}

/* ==========================================================
   SUB-TABELA DO NÓ EXPANDIDO
   (cabeçalho fixo | faixa rolável de registros | totais fixos)
   Host = 1 linha do tbody com 3 mini-tabelas alinhadas via colgroup.
   A faixa central mostra no máximo MAX_REGISTROS_VISIVEIS (6) linhas; o
   restante sai pela barra de rolagem. Cabeçalho e totais ficam fixos.
========================================================== */

.construtor-host-row > td {

    padding: 0 !important;

    border-bottom: none !important;

}

.construtor-inner {

    padding: 0;

}

.construtor-head {

    background: var(--thead-bg);

}

.construtor-scroll {

    overflow-y: auto;

    overflow-x: hidden;

    border-top: 1px solid var(--border-soft);

    border-bottom: 1px solid var(--border-soft);

    background: var(--bg-soft);

}

table.construtor-mini {

    width: 100%;

    border-collapse: collapse;

    table-layout: fixed;

}

table.construtor-mini td {

    padding: var(--table-row-small) var(--table-padding);

    border-bottom: 1px solid var(--border-color);

}

table.construtor-mini .row-total td {

    border-bottom: none;

}

/* Grade de colunas fixa (medida da sub-tabela) aplicada à tabela principal */
table.data-table.layout-fixed {

    table-layout: fixed;

}


