:root {
    --bg-body: #ffffff;
    --bg-sidebar: #111827;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --danger: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background: var(--bg-body); color: var(--text-dark); height: 100vh; overflow: hidden; }

.hidden { display: none !important; }
.restricted { display: none !important; }

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Fica acima da TOPBAR translúcida (z-index: 9999) */
    z-index: 120000;
    backdrop-filter: blur(4px);
}
.modal-card {
    background: white; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); animation: modalPop 0.3s ease-out;
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* LOADING */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.9);
    z-index: 120001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.spinner {
    width: 40px; height: 40px; border: 4px solid #e5e7eb; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* LOGIN & INPUTS */
#view-login { display: flex; align-items: center; justify-content: center; height: 100vh; background: #e5e7eb; }
.login-card { background: white; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.05); text-align: center; }

/* CLASSE NOVA DA LOGO DE LOGIN */
.login-brand-logo {
    max-width: 220px; 
    height: auto;
    margin: 0 auto 20px auto;
    display: block;
}

.input-wrapper { text-align: left; margin-bottom: 15px; }
.input-wrapper label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.input-wrapper input, .input-wrapper select { 
    width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; transition: 0.2s; background-color: #fff; font-size: 14px;
}
.input-wrapper input:focus, .input-wrapper select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.btn-primary { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* FILTRO DE ANO */
.select-ano {
    padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 6px; background-color: white; color: var(--text-dark);
    font-size: 14px; font-weight: 600; cursor: pointer; outline: none; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: all 0.2s;
}
.select-ano:hover { border-color: var(--primary); }

/* =============================
   RÓTULOS DOS FILTROS (TOP BAR)
   ============================= */
.filter-field{
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-field label{
    font-size: 10px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

/* melhora quebra em telas menores */
.top-bar .actions{ flex-wrap: wrap; }

/* --- LAYOUT PADRÃO (DESKTOP) --- */
#view-app { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

.sidebar { 
    width: 80px; 
    background: var(--bg-sidebar); 
    display: flex; flex-direction: column; align-items: center; padding: 20px 0; 
    flex-shrink: 0; 
    height: 100vh;
}
.brand { color: white; font-size: 24px; margin-bottom: 40px; }
.nav-btn { 
    background: none; border: none; color: #9ca3af; padding: 12px; border-radius: 8px; cursor: pointer; font-size: 20px; 
    margin-bottom: 10px; transition: 0.2s; width: 80%; display: flex; justify-content: center; align-items: center; position: relative;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,0.1); color: white; }
.tooltip { 
    position: absolute; left: 70px; background: #374151; color: white; padding: 4px 8px; border-radius: 3px; font-size: 12px; 
    opacity: 0; pointer-events: none; transition: 0.2s; white-space: nowrap; z-index: 999999;
}
.nav-btn:hover .tooltip { opacity: 1; left: 70px; }
.user-profile { margin-top: auto; margin-bottom: 20px; }
.avatar { width: 36px; height: 36px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.logout-btn { background: none; border: none; color: var(--danger); font-size: 18px; cursor: pointer; margin-bottom: 10px; }

.main-content { 
    flex: 1; 
    padding: 24px 32px; 
    overflow-y: auto; 
    background-color: #ffffff; 
    height: 100vh;
}

.page-section { display: none; animation: fadeIn 0.4s; padding-bottom: 50px; }
.page-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }

/* ================================
   FILTROS (rótulos acima / lado a lado)
   ================================ */
.top-bar .actions{
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.filter-label{
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  line-height: 1;
}

.top-bar h1 { font-size: 24px; font-weight: 700; color: #111827; }
.header-logo { height: 60px; width: auto; object-fit: contain; display: block; }

/* CONFIGURAÇÃO GERAL DOS CARDS */
.kpi-grid { 
    display: grid; 
    gap: 15px; 
    margin-bottom: 24px; 
}
.card { background: white; padding: 15px; border-radius: 10px; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.card-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-value { font-size: 18px; font-weight: 700; }

.text-green { color: var(--success) !important; }
.text-red { color: var(--danger) !important; }

/* --- ESPECÍFICO: DASHBOARD (5 COLUNAS) --- */
#kpi-container {
    grid-template-columns: repeat(5, 1fr);
}

/* --- ESPECÍFICO: ORÇAMENTO (8 COLUNAS - LINHA ÚNICA) --- */
#kpi-orcamento-container {
    grid-template-columns: repeat(8, 1fr);
}
#kpi-orcamento-container .card { padding: 12px; }
#kpi-orcamento-container .card-title { font-size: 10px; margin-bottom: 5px; }
#kpi-orcamento-container .card-value { font-size: 15px; }


/* CONFIGURAÇÃO RÍGIDA PARA DESKTOP (TABELA LARGA, GRÁFICO ESTREITO) */
.dashboard-split { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 30px; 
}

.panel { 
    background: white; border-radius: 10px; border: 1px solid var(--border); 
    display: flex !important; 
    flex-direction: column !important;
    margin-bottom: 0; 
}
.panel-head { padding: 15px 20px; border-bottom: 1px solid var(--border); background: #f9fafb; font-weight: 600; font-size: 14px; }

/* TABELAS (DASHBOARD) - MODIFICADO */
.table-wrapper { 
    display: block !important;
    width: 100% !important;
    height: 500px !important; 
    overflow: auto !important;
    position: relative !important;
    border: 1px solid #e5e7eb; 
    background: #012d5a; 
    border-radius: 8px; 
    scrollbar-width: thin;
    flex: 1 !important; /* Garante que ocupe o espaço dentro do painel flex */
}

/* Garante que o painel pai não cresça além da conta */
.table-panel {
    height: 600px !important; /* Altura total do painel (cabeçalho + tabela) */
    overflow: hidden !important;
}

/* Estilização da barra de rolagem (Chrome/Edge/Safari) */
.table-wrapper::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrapper::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.table-wrapper::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

table { 
    width: max-content !important; 
    min-width: 100% !important;
    border-collapse: collapse; 
    font-size: 13px; 
    white-space: nowrap !important; 
}

#finance-table {
    min-width: 1800px !important;
}

#finance-table thead th { 
    background: #012d5a !important; 
    color: #ffffff !important; 
    padding: 10px 8px; 
    text-align: center; 
    border: 1px solid #e5e7eb; 
    font-weight: 600; 
    position: sticky !important; 
    top: 0 !important; 
    z-index: 100 !important; 
}

#finance-table th:first-child, 
#finance-table td:first-child { 
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 20;
    background-color: inherit;
    border-right: 2px solid #e5e7eb;
    min-width: var(--col-plano-min);
    max-width: var(--col-plano-max);
    padding-left: 15px;
}
#finance-table td:first-child { background-color: #fff; }

#finance-table td { padding: 8px; text-align: center; border: 1px solid #e5e7eb; color: #374151; }
.hover-row:hover { background-color: #f3f4f6 !important; filter: brightness(0.98); }
.toggle-icon { display: inline-block; width: 15px; transition: transform 0.2s ease; margin-right: 5px; color: #6b7280; font-size: 11px; }

.child-row { background-color: #f9fafb; font-size: 12px; color: #4b5563; }
.child-row td:first-child { padding-left: 35px; border-left: 4px solid #e5e7eb; }
.child-row td { border-top: 1px dashed #e5e7eb; }

/* GRÁFICO - Altura Ajustada */
.chart-wrapper { padding: 20px; height: 450px; position: relative; width: 100%; }

/* --- LAYOUT DO CHART + TERMÔMETRO NA ABA ORÇAMENTO --- */
.chart-row {
    display: flex;
    flex-direction: row;
    height: 480px; /* Altura fixa para alinhar */
}
.chart-main {
    flex: 1; /* Ocupa o espaço restante */
    border-right: 1px solid var(--border);
}

/* =========================================================================
   NOVO TERMÔMETRO FLAT (SUBSTITUI O 3D)
   ========================================================================= */
.thermometer-section {
    width: 320px; /* Um pouco mais largo para acomodar labels */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: #fff;
    border-left: 1px solid var(--border);
}

.flat-thermometer-container {
    position: relative;
    width: 240px; 
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Alinha o termômetro na base */
    margin-bottom: 20px;
}

/* Corpo Central */
.thermometer-body {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
    width: 60px;
}

/* O Tubo */
.thermometer-tube-border {
    width: 40px;
    height: 220px;
    background-color: #f1f5f9; /* Fundo cinza claro */
    border: 5px solid #2c3e50; /* Borda grossa escura */
    border-bottom: none; /* Conecta com o bulbo */
    border-radius: 20px 20px 0 0;
    position: relative;
    overflow: hidden; /* Corta o líquido que passar */
    z-index: 2;
}

/* Marcações (Régua) */
.ticks {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 80%;
    z-index: 3;
}
.ticks span {
    width: 12px;
    height: 2px;
    background-color: #cbd5e1;
    display: block;
}

/* O Líquido (Barra que sobe) */
.thermometer-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #2563eb; 
    transition: height 1.0s ease-in-out, background-color 0.5s;
    z-index: 1; /* Fica atrás das réguas */
}

/* O Bulbo (Bola embaixo) */
.thermometer-bulb-border {
    width: 64px;
    height: 64px;
    background-color: transparent; /* A cor vem do fill interno */
    border: 5px solid #2c3e50;
    border-radius: 50%;
    margin-top: -10px; /* Sobe para fundir com o tubo */
    position: relative;
    z-index: 1; /* Fica acima do tubo visualmente nas bordas */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preenchimento do Bulbo */
.thermometer-bulb-fill {
    width: 100%;
    height: 100%;
    background-color: #2563eb;
    border-radius: 50%;
    transition: background-color 0.5s;
}

/* Brilho no Bulbo */
.thermometer-bulb-border::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 15px;
    height: 25px;
    border-left: 4px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    transform: rotate(20deg);
}

/* --- ETIQUETAS LATERAIS (TOOLTIPS) --- */
.thermometer-tooltip {
    position: absolute;
    background-color: #2c3e50; /* Fundo escuro */
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    transition: bottom 1.0s ease-in-out; 
    bottom: 0%; 
    z-index: 999999;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tooltip-left {
    right: 55%; 
    margin-right: 35px;
}

.tooltip-right {
    left: 55%; 
    margin-left: 35px;
}

/* Setas dos Tooltips */
.arrow-right {
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    width: 0; 
    height: 0; 
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid #2c3e50;
}

.arrow-left {
    position: absolute;
    top: 50%;
    left: -6px;
    transform: translateY(-50%);
    width: 0; 
    height: 0; 
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid #2c3e50;
}

/* Legenda Flat */
.flat-legend {
    width: 100%;
    margin-top: 10px;
    border-top: 1px solid #e5e7eb;
    padding-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.legend-item { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 11px;
    font-weight: 500;
    color: #4b5563;
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.2s;
}
.legend-item:hover { background-color: #f9fafb; }

.dot { 
    width: 10px; height: 10px; 
    border-radius: 50%; 
    display: inline-block; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    border: 1px solid rgba(0,0,0,0.05);
}
.dot-blue { background-color: #3b82f6; }
.dot-green { background-color: #10b981; }
.dot-yellow { background-color: #f59e0b; }
.dot-red { background-color: #ef4444; }


/* ORÇAMENTO TABLE */
.table-wrapper-orcamento { 
    background: #fff; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); max-height: 80vh; overflow: auto; 
}

#orcamento-table { border-collapse: separate; border-spacing: 0; width: auto; font-size: 11px; margin: 0; }
#orcamento-table th, #orcamento-table td { 
    padding: 8px 10px; border-bottom: 1px solid #e5e7eb; border-right: 1px solid #f3f4f6; text-align: right; height: 35px;
}

.sticky-col {
    position: sticky; left: 0; z-index: 20; background-color: #fff !important; 
    border-right: 2px solid #e5e7eb !important; text-align: left !important; 
    width: auto; min-width: 320px; max-width: none; white-space: nowrap; 
    font-weight: 600; color: #1f2937; box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

#orcamento-table thead tr th.sticky-col { 
    z-index: 30; top: 0; left: 0; background-color: #012d5a !important; color: white; text-align: center !important;
}
#orcamento-table thead tr th { position: sticky; top: 0; z-index: 10; }

.header-months th { 
    background-color: #012d5a; color: white; text-align: center !important; 
    border: 1px solid #374151; text-transform: uppercase; font-size: 12px; height: 30px;
}
.header-sub th { 
    top: 30px !important; background-color: #f3f4f6; color: #111827; 
    font-weight: 700; font-size: 10px; border-bottom: 2px solid #d1d5db !important; min-width: 100px; box-sizing: border-box;
}
#orcamento-table td:nth-child(4n+5), .header-sub th:nth-child(4n) { border-right: 2px solid #9ca3af !important; }

.col-orc { color: #6b7280; }
.col-real { color: #111827; } 
.col-dif { font-weight: 700; background-color: #f9fafb; }
.col-perc { font-size: 10px; font-weight: 600; } 
#orcamento-table tbody tr:hover td { background-color: #eff6ff !important; transition: background-color 0.1s; }

/* ==========================================================================
   RESPONSIVIDADE 
   ========================================================================== */

/* Notebooks comuns (Abaixo de 1366px) */
@media (max-width: 1366px) {
    #kpi-orcamento-container { grid-template-columns: repeat(4, 1fr); }
    #kpi-container { grid-template-columns: repeat(3, 1fr); }
}

/* Tablets (Abaixo de 1024px) */
@media (max-width: 1024px) {
    #kpi-orcamento-container { grid-template-columns: repeat(2, 1fr); }
    #kpi-container { grid-template-columns: repeat(2, 1fr); }
    .chart-wrapper { height: 350px; }
    
    .chart-row { flex-direction: column; height: auto; }
    .chart-main { border-right: none; border-bottom: 1px solid var(--border); }
    .thermometer-section { 
        width: 100%; 
        border-left: none; 
        border-top: 1px solid var(--border);
        padding: 30px;
    }
}

/* Celulares (Abaixo de 768px) */
@media (max-width: 768px) {
    #view-app { flex-direction: column; height: 100vh; overflow: hidden; }
    
    .sidebar { 
        width: 100%; height: 60px; flex-direction: row; position: fixed; bottom: 0; left: 0; z-index: 1000; 
        padding: 0; justify-content: space-between; border-top: 1px solid #e5e7eb; background: var(--bg-sidebar); 
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1); 
    }
    .sidebar .brand, .sidebar .user-profile, .sidebar .tooltip { display: none !important; }
    .sidebar nav { display: flex; flex-direction: row; justify-content: space-around; align-items: center; width: 100%; height: 100%; }
    .nav-btn { width: auto; margin: 0; padding: 10px; background: transparent; font-size: 20px; flex-grow: 1; border-radius: 0; }
    #btn-logout { display: flex; align-items: center; justify-content: center; width: 60px; height: 100%; margin: 0; border-left: 1px solid rgba(255,255,255,0.1); }
    
    .main-content { width: 100%; padding: 15px; padding-bottom: 80px; overflow-y: auto; height: calc(100vh - 60px); }
    
    .top-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .top-bar .actions { width: 100%; display: flex; justify-content: space-between; align-items: center; }
    .header-logo { height: 40px; }
    
    .table-wrapper { margin: 0 -15px; width: calc(100% + 30px); border-radius: 0; }
    
    th:first-child, td:first-child { min-width: 130px; max-width: 130px; padding-left: 8px !important; font-size: 10px; white-space: normal; line-height: 1.2; }
    .child-row td:first-child { padding-left: 15px !important; }
    
    .kpi-grid, #kpi-container, #kpi-orcamento-container { grid-template-columns: 1fr; gap: 10px; }
    
    .login-card, .modal-card { margin: 20px; padding: 25px; width: 90%; }
}

/* --- BUSCA INTELIGENTE DASHBOARD --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper input {
    padding: 8px 30px 8px 35px; /* Mais espaço na direita para o botão X */
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background-color: white;
    font-size: 14px;
    width: 250px;
    outline: none;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.search-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    width: 280px; 
}

.search-icon {
    position: absolute;
    left: 12px;
    color: #9ca3af;
    font-size: 14px;
    pointer-events: none;
}

/* Ícone de limpar (X) */
.clear-icon {
    position: absolute;
    right: 12px;
    color: #9ca3af;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.clear-icon:hover {
    color: var(--danger);
}

/* Efeito de destaque na linha encontrada */
.highlight-row td {
    background-color: #fef08a !important; /* Amarelo suave */
    color: #bb9d06 !important;
    font-weight: 700;
    border-top: 1px solid #fde047;
    border-bottom: 1px solid #fde047;
}

/* Ajuste mobile para a busca */
@media (max-width: 768px) {
    .search-wrapper input {
        width: 100%;
    }
}


/* =======================================================================
   OVERRIDES (GERADO v2) — Fix: Plano Financeiro visível + Saldo Inicial/Final
   - Header "Plano Financeiro" fixo (topo + esquerda)
   - Scroll horizontal/vertical no wrapper
   - Saldo Inicial (sticky abaixo do thead) e Saldo Final (sticky no rodapé)
     aplicados NAS CÉLULAS (td), mais compatível que sticky em <tr>.
   - Depende do JS que adiciona as classes: sticky-saldo-top / sticky-saldo-bottom
     e define --finance-thead-h (opcional; há fallback).
   ======================================================================= */

/* fallback para altura do thead (JS pode sobrescrever) */
:root{ --finance-thead-h: 44px; }

/* TOPBAR TRANSLÚCIDA (DASHBOARD + ORÇAMENTO) */
.top-bar{
  position: sticky !important;
  top: 0 !important;
  z-index: 600 !important;

  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 20px !important;

  padding: 14px 24px !important;
  margin: 0 0 18px 0 !important;

  background: rgba(255,255,255,0.78) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;

  border-bottom: 1px solid rgba(229,231,235,0.7) !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.04) !important;
}

@media (max-width: 768px){
  .top-bar{
    margin: 0 0 14px 0 !important;
    padding: 12px 16px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
  }
}

/* WRAPPER: scroll X/Y + altura interna */
.table-panel{
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
  overflow: hidden !important;
}

.table-wrapper{
  width: 100% !important;
  position: relative !important;

  overflow-x: auto !important;
  overflow-y: auto !important;

  max-height: calc(100vh - 340px) !important;

  border: 1px solid #e5e7eb !important;
  background: #ffffff !important;
  border-radius: 10px !important;

  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.table-wrapper::-webkit-scrollbar{ height: 10px; width: 10px; }
.table-wrapper::-webkit-scrollbar-track{ background: #f1f5f9; border-radius: 6px; }
.table-wrapper::-webkit-scrollbar-thumb{ background: #cbd5e1; border-radius: 6px; }
.table-wrapper::-webkit-scrollbar-thumb:hover{ background: #94a3b8; }

/* TABELA: força scroll horizontal quando precisar */
#finance-table{
  border-collapse: collapse !important;
  width: max-content !important;
  min-width: 100% !important;
  table-layout: auto !important;
}

/* Células padrão (não corta valores) */
#finance-table th,
#finance-table td{
  font-size: clamp(11px, 0.85vw, 13px) !important;
  padding: clamp(8px, 0.7vw, 12px) clamp(8px, 0.7vw, 12px) !important;
  border: 1px solid #e5e7eb !important;
  text-align: center !important;
  vertical-align: middle !important;
  white-space: nowrap !important;
}

/* HEADER sticky */
#finance-table thead th{
  background: #012d5a !important;
  color: #ffffff !important;
  font-weight: 700 !important;

  position: sticky !important;
  top: 0 !important;
  z-index: 400 !important;
}

/* Colunas de mês com largura mínima */
#finance-table thead th:not(:first-child),
#finance-table td:not(:first-child){
  min-width: 140px !important;
}

/* Primeira coluna sticky (esquerda) + quebra de texto */
#finance-table th:first-child,
#finance-table td:first-child{
  position: sticky !important;
  left: 0 !important;

  text-align: left !important;

  width: auto !important;
  min-width: 260px !important;
  max-width: 520px !important;

  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.25 !important;

  padding-left: 14px !important;
  border-right: 2px solid #e5e7eb !important;

  background: #ffffff !important;
  z-index: 450 !important;
}

/* ✅ GARANTE a célula "Plano Financeiro" (topo+esquerda) visível SEMPRE */
#finance-table thead th:first-child{
  top: 0 !important;
  left: 0 !important;
  background: #012d5a !important;
  color: #ffffff !important;
  z-index: 900 !important;
}

/* Hover */
#finance-table tbody tr:hover td{ background-color: #f8fafc !important; }

/* =====================================================
   SUPERÁVIT / DÉFICIT — LINHA ESPECIAL (antes do 04 - Ativo Imobilizado)
   - Fundo leve verde/vermelho dinâmico
   - Ícones ▲ ▼
   ===================================================== */

#finance-table tbody tr.sd-row td{
  font-weight: 800 !important;
  border-top: 2px solid #e5e7eb !important;
}

#finance-table tbody tr.sd-row td.sd-title{
  background: #f8fafc !important;
  color: #111827 !important;
}

/* Mantém sticky correto na 1ª coluna */
#finance-table tbody tr.sd-row td:first-child{
  background: #f8fafc !important;
}

#finance-table td.sd-cell{
  white-space: nowrap !important;
}

#finance-table td.sd-cell.sd-pos{
  background: rgba(16, 185, 129, 0.12) !important;
  color: #065f46 !important;
}

#finance-table td.sd-cell.sd-neg{
  background: rgba(239, 68, 68, 0.12) !important;
  color: #7f1d1d !important;
}

#finance-table .sd-icon{
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  font-size: 11px;
  line-height: 1;
  opacity: 0.95;
}

#finance-table .sd-val{
  font-weight: 800;
}

/* Hierarquia */
.child-row{
  background-color: #f9fafb !important;
  color: #4b5563 !important;
  font-size: 12px !important;
}
.child-row td:first-child{
  padding-left: 32px !important;
  border-left: 4px solid #e5e7eb !important;
}

/* ===========================
   ✅ SALDO INICIAL / FINAL FIXOS (NAS CÉLULAS)
   =========================== */

/* Fundo e destaque */
#finance-table tbody tr.sticky-saldo-top td,
#finance-table tbody tr.sticky-saldo-bottom td{
  background: #eff6ff !important;
  font-weight: 700 !important;
}

/* Saldo Inicial: fixa logo abaixo do thead */
#finance-table tbody tr.sticky-saldo-top td{
  position: sticky !important;
  top: var(--finance-thead-h) !important;
  z-index: 300 !important; /* abaixo do header (400/900) */
  box-shadow: 0 2px 0 rgba(0,0,0,0.06);
}

/* Saldo Final: fixa no rodapé */
#finance-table tbody tr.sticky-saldo-bottom td{
  position: sticky !important;
  bottom: 0 !important;
  z-index: 300 !important;
  box-shadow: 0 -2px 0 rgba(0,0,0,0.06);
}

/* ✅ fixa também a 1ª célula ("Saldo Inicial"/"Saldo Final") na esquerda */
#finance-table tbody tr.sticky-saldo-top td:first-child,
#finance-table tbody tr.sticky-saldo-bottom td:first-child{
  left: 0 !important;
  z-index: 950 !important; /* acima da própria linha e acima das células */
  border-right: 2px solid #e5e7eb !important;
}

/* MOBILE */
@media (max-width: 768px){
  .table-wrapper{
    max-height: calc(100vh - 290px) !important;
    border-radius: 0 !important;
    margin: 0 -15px !important;
    width: calc(100% + 30px) !important;
  }
  #finance-table thead th:not(:first-child),
  #finance-table td:not(:first-child){
    min-width: 150px !important;
  }
  #finance-table th:first-child,
  #finance-table td:first-child{
    min-width: 200px !important;
    max-width: 360px !important;
    padding-left: 10px !important;
  }
}


/* =====================================================
   ORÇAMENTO – BORDA NA TABELA
   ===================================================== */
.table-wrapper-orcamento{
    border: 1px solid #e5e7eb !important;
    border-radius: 10px !important;
    overflow: auto !important;
    background: #ffffff !important;
}


/* =====================================================
   TOPBAR – SEMPRE À FRENTE DE TUDO (DURANTE SCROLL)
   ===================================================== */
.top-bar{
    z-index: 9999 !important;        /* acima de tabelas, KPI, sticky cells */
}

/* Garante que elementos abaixo nunca passem por cima */
#finance-table thead th,
#finance-table th:first-child,
#finance-table td:first-child,
#finance-table tbody tr.sticky-saldo-top td,
#finance-table tbody tr.sticky-saldo-bottom td{
    z-index: auto !important;
}


:root{
  /* Largura padrão da 1ª coluna (Plano Financeiro) nas duas tabelas */
  --col-plano-min: 260px;
  --col-plano-max: 360px;
}



/* ===== Financeiro (nova tabela) — mesma largura da 1ª coluna da DFC ===== */
#financeiro-table{
    width: 100% !important;
    border-collapse: collapse;
    table-layout: fixed;
}

#financeiro-table th,
#financeiro-table td{
    font-size: clamp(11px, 0.85vw, 13px);
    padding: clamp(8px, 0.7vw, 12px) clamp(6px, 0.6vw, 10px);
    border: 1px solid #e5e7eb;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#financeiro-table thead th{
    background: #012d5a !important;
    color: #ffffff !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    font-weight: 700;
}

/* 1ª coluna (Plano Financeiro) — igual DFC */
#financeiro-table th:first-child,
#financeiro-table td:first-child{
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 110;
    min-width: var(--col-plano-min);
    max-width: var(--col-plano-max);
    white-space: nowrap;
    border-right: 2px solid #e5e7eb;
    padding-left: 14px;
}

#financeiro-table thead th:first-child{
    background: #012d5a !important;
    color: #ffffff !important;
}

#financeiro-table tbody td:first-child{
    background: #ffffff !important;
}

/* Financeiro: ícone expand/recolhe */
#financeiro-table .toggle-icon{
  display:inline-block;
  width: 16px;
  margin-right: 6px;
  transition: transform .15s ease;
}
#financeiro-table .toggle-icon.rotated{
  transform: rotate(90deg);
}

/* =====================================================
   FINANCEIRO (nova tabela do Dashboard)
   - Visibilidade é controlada via JS (classe .is-hidden)
   - Mantém o mesmo "design" e comportamento da tabela DFC
   ===================================================== */

#financeiro-panel{ display:flex; flex-direction:column; }
#financeiro-panel.is-hidden{ display:none !important; }
#financeiro-panel.is-hidden{ display:none !important; }

/* Wrapper e tabela seguem o mesmo padrão do DFC */
.financeiro-wrapper{ max-height: 420px; }

#financeiro-table{ width: max-content !important; min-width: 100% !important; border-collapse: collapse; }

#financeiro-table thead th{
  background: #012d5a !important;
  color: #ffffff !important;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 100;
}

#financeiro-table th,
#financeiro-table td{
  border: 1px solid #e5e7eb;
  padding: 8px;
  text-align: center;
  white-space: nowrap;
}

/* 1ª coluna fixa e mesma largura do DFC */
#financeiro-table th:first-child,
#financeiro-table td:first-child{
  position: sticky;
  left: 0;
  z-index: 110;
  text-align: left;
  min-width: var(--plano-col-min, 260px);
  max-width: var(--plano-col-max, 380px);
  border-right: 2px solid #e5e7eb;
  padding-left: 14px;
  background: #ffffff;
}
#financeiro-table thead th:first-child{ background:#012d5a !important; color:#fff !important; z-index: 130; }

/* Hover / pré-seleção (mesmo do DFC) */
#financeiro-table tbody tr:hover td{ background-color: #f3f4f6 !important; }

/* Nível 1 em negrito */
#financeiro-table tbody tr.grupo td{ font-weight: 700; }

/* =====================================================
   SINCRONIZAR LARGURA DAS COLUNAS (DFC + FINANCEIRO)
   ===================================================== */

:root {
    --plano-col-min: 280px;
    --plano-col-max: 380px;
    --mes-col-width: 110px;
}

/* Ambas tabelas usam o MESMO modelo */
#finance-table,
#financeiro-table {
    width: 100% !important;
    min-width: calc(var(--plano-col-min) + (12 * var(--mes-col-width)));
    table-layout: fixed !important;
    border-collapse: collapse;
}

/* Primeira coluna igual nas duas */
#finance-table th:first-child,
#finance-table td:first-child,
#financeiro-table th:first-child,
#financeiro-table td:first-child {
    min-width: var(--plano-col-min) !important;
    max-width: var(--plano-col-max) !important;
    text-align: left;
    font-weight: 600;
}

/* Meses com largura fixa e igual */
#finance-table th:not(:first-child),
#finance-table td:not(:first-child),
#financeiro-table th:not(:first-child),
#financeiro-table td:not(:first-child) {
    width: var(--mes-col-width) !important;
    min-width: var(--mes-col-width) !important;
    max-width: var(--mes-col-width) !important;
    text-align: center;
}

/* Wrapper garante scroll sincronizado */
.table-wrapper {
    overflow-x: auto;
    max-width: 100%;
}


/* =========================================================
   FIX FINAL (DFC + FINANCEIRO)
   - Restaura o layout do Demonstrativo (id #finance-table)
   - Mantém Financeiro independente (id #financeiro-table)
   - Hover/Pré-seleção igual nas duas
   ========================================================= */

.table-wrapper { background: #ffffff !important; }

#finance-table,
#financeiro-table{
  width: max-content !important;
  min-width: 100% !important;
  table-layout: auto !important;
  border-collapse: collapse !important;
}

#finance-table th,
#finance-table td,
#financeiro-table th,
#financeiro-table td{
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

#finance-table thead th,
#financeiro-table thead th{
  background: #012d5a !important;
  color: #fff !important;
  font-weight: 700 !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
}

:root{
  --plano-col-width: 240px;     /* menor para não “comer” os meses */
  --month-col-min: 140px;
}

#finance-table th:first-child,
#finance-table td:first-child,
#financeiro-table th:first-child,
#financeiro-table td:first-child{
  min-width: var(--plano-col-width) !important;
  max-width: 320px !important;
  position: sticky !important;
  left: 0 !important;
  z-index: 120 !important;
  text-align: left !important;
  white-space: normal !important;
  word-break: break-word !important;
  background: #ffffff !important;
  border-right: 2px solid #e5e7eb !important;
}

#finance-table thead th:first-child,
#financeiro-table thead th:first-child{
  background: #012d5a !important;
  color: #fff !important;
  z-index: 200 !important;
}

#finance-table th:not(:first-child),
#finance-table td:not(:first-child),
#financeiro-table th:not(:first-child),
#financeiro-table td:not(:first-child){
  min-width: var(--month-col-min) !important;
  width: auto !important;
}

#finance-table tbody tr:hover td,
#financeiro-table tbody tr:hover td{
  background-color: #f3f4f6 !important;
}

#financeiro-panel.hidden{ display:none !important; }

/* Nível 1 no Financeiro em negrito */
#financeiro-table tbody tr.grupo td{ font-weight: 700 !important; }


/* =========================================================
   PATCH — ORÇAMENTO: rótulos acima + filtros lado a lado
   (corrige layout/posicionamento na aba Orçamento)
========================================================= */
#page-orcamento .top-bar{
  align-items: center;
}

#page-orcamento .top-bar .actions{
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

#page-orcamento .filter-field{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

#page-orcamento .filter-field label{
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1;
}

#page-orcamento .filter-field select{
  min-width: 220px;
}

@media (max-width: 768px){
  #page-orcamento .top-bar .actions{
    width: 100%;
    justify-content: flex-start;
  }
  #page-orcamento .filter-field,
  #page-orcamento .filter-field select{
    width: 100%;
  }
}



/* =========================================================
   PATCH (FINAL v2)
   - Labels acima dos filtros (Dashboard + Orçamento)
   - Filtros lado a lado (layout antigo)
   ======================================================== */
.filters-row{
  display:flex;
  align-items:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.filter-field{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.filter-label{
  font-size:12px;
  font-weight:700;
  color: var(--text-muted);
  line-height: 1;
}
@media (max-width: 768px){
  .filters-row{ width:100%; }
  .filter-field{ width:100%; }
}


/* Toggle de visibilidade de senha */
.password-field{position:relative;display:flex;align-items:center;}
.password-field input{width:100%;padding-right:44px;}
.btn-toggle-password{position:absolute;right:10px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:var(--text-muted);cursor:pointer;
  opacity:0.6;
  transition: opacity .15s ease, transform .15s ease;
padding:6px;border-radius:8px;}
.btn-toggle-password:hover{background:rgba(0,0,0,0.06);color:var(--text-dark);}
.btn-toggle-password:focus{outline:2px solid rgba(37,99,235,0.35);outline-offset:2px;}


/* Garantir tooltips por cima de tudo (charts/KPIs) */
.chartjs-tooltip, .fc-tooltip, .tooltip-popover {
    z-index: 999999 !important;
}


/* Orçamento: badge de dias úteis na faixa de filtros */
.dias-uteis-badge{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:12px;background:rgba(255,255,255,.08);backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.14);color:#e5e7eb;font-size:12px;margin-left:auto;}
.dias-uteis-badge .label{opacity:.85;}
.dias-uteis-badge .value{font-weight:700;}

/* Preferência: KPI de dias úteis (badge oculto) */
.dias-uteis-badge{display:none !important;}

/* --- Layout dos filtros da Aba Orçamento --- */
.orcamento-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.orcamento-filters .filter-group {
  min-width: 180px;
}


/* Orçamento: filtros em linha, mesmo design */
.filters-row-orcamento{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end;justify-content:flex-start;}
.filters-row-orcamento .filter-group{display:flex;flex-direction:column;gap:6px;min-width:180px;flex:1;}
.filters-row-orcamento .filter-group select{width:100%;}


/* Garantia: filtros em linha (inclui Orçamento) */
.actions{flex-wrap:wrap;}
.actions .filter-field{display:flex;flex-direction:column;gap:6px;min-width:180px;}
.actions .filter-field .filter-label{font-size:12px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;opacity:.7;}
.actions .filter-field select{width:100%;}


/* Ocultar colunas do orçamento quando filtro de Mês ativo */
.hide-col{display:none !important;}


/* Sublinhado do título por tipo de visão (Orçamento) */
#orcamento-title.view-receita { border-bottom: 4px solid #16a34a; padding-bottom: 6px; display: inline-block; }
#orcamento-title.view-orcamento { border-bottom: 4px solid #ef4444; padding-bottom: 6px; display: inline-block; }
#orcamento-title.view-todos { border-bottom: 4px solid transparent; padding-bottom: 6px; display: inline-block; }


/* KPI GANHOS - cores */
.kpi-verde { color: #10b981 !important; }
.kpi-vermelho { color: #ef4444 !important; }



/* ===========================
   Comentários (Orçamento)
   =========================== */
.comment-cell { position: relative; }
.comment-flag{
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);

  position:absolute;
  top:2px;
  left:2px;
  width:11px;
  height:11px;
  border:0;
  background: rgba(255,255,255,0.92);
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  padding:0;
  cursor:pointer;
  opacity:0.6;
  transition: opacity .15s ease, transform .15s ease;

  display:flex;
  align-items:center;
  justify-content:center;
  z-index:50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.comment-flag .flag-plus{
  font-size:10px;
  line-height:11px;
  color:#9ca3af;
  font-weight:700;
}
.comment-flag:hover{
  border-color:#cbd5e1;
  transform: translateY(-0.5px);
}
.comment-flag.has-comment .flag-plus{ display:none; }
.comment-flag .flag-dot{
  width:6px;
  height:6px;
  border-radius:999px;
  background:#ef4444;
  display:inline-block;
}

/* Timeline actions (editar) */
.timeline-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.timeline-actions{ display:flex; gap:8px; }
.timeline-btn{
  border:1px solid #e5e7eb;
  background:transparent;
  color:#374151;
  border-radius:10px;
  padding:3px 8px;
  font-size:12px;
  line-height:1.2;
  cursor:pointer;
}
.timeline-btn:hover{ border-color:#cbd5e1; background:rgba(255,255,255,0.6); }
.timeline-btn:active{ transform: translateY(0.5px); }

.comentario-footer-actions{ display:flex; gap:10px; justify-content:flex-end; align-items:center; }
.btn-secondary{
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #111827;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.btn-secondary:hover{ border-color:#cbd5e1; }
.comment-highlight{
  outline:2px solid rgba(59,130,246,0.55);
  outline-offset:-2px;
  box-shadow:0 0 0 4px rgba(59,130,246,0.15);
}

/* Modal comentário */
.comentario-modal{
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  z-index: 120010;
  padding: 14px;
}
.comentario-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}
.comentario-title{ font-weight:800; color:#111827; }
.comentario-meta{ font-size:12px; color:#6b7280; margin-top:2px; }
.comentario-text{
  width:100%;
  min-height:130px;
  border:1px solid #e5e7eb;
  border-radius:12px;
  padding:10px;
  outline:none;
  resize:vertical;
}
.comentario-actions{
  display:flex;
  justify-content:flex-end;
  margin-top:10px;
}
.btn-primary{
  background:#2563eb;
  color:#fff;
  border:0;
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
  opacity:0.6;
  transition: opacity .15s ease, transform .15s ease;

  font-weight:700;
}
.icon-btn{
  width:34px;
  height:34px;
  border-radius:10px;
  border:1px solid #e5e7eb;
  background:#fff;
  cursor:pointer;
  opacity:0.6;
  transition: opacity .15s ease, transform .15s ease;

  display:flex;
  align-items:center;
  justify-content:center;
}

/* Toasts */
.toast-container{
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* acima da top-bar (z-index 9999) */
  z-index: 120020;
}
.toast{
  width: min(360px, calc(100vw - 32px));
  background: #111827;
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.25);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show{ opacity:1; transform: translateY(0); }
.toast-title{ font-weight:800; font-size:13px; }
.toast-meta{ opacity:.85; font-size:12px; margin-top:4px; }

/* Painel notificações */
.notificacoes-panel{
  position: fixed;
  top: 64px;
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: 70vh;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.18);
  /* acima da top-bar (z-index 9999) */
  z-index: 120015;
  overflow: hidden;
  display:flex;
  flex-direction:column;
}
.notificacoes-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 12px;
  border-bottom:1px solid #e5e7eb;
}
.notificacoes-title{ font-weight:800; color:#111827; }
.notificacoes-list{
  padding: 8px;
  overflow:auto;
}
.notif-item{
  border:1px solid #e5e7eb;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor:pointer;
  opacity:0.6;
  transition: opacity .15s ease, transform .15s ease;

}
.notif-item:hover{ background:#f9fafb; }
.notif-title{ font-weight:800; font-size:13px; color:#111827; }
.notif-meta{ font-size:12px; color:#6b7280; margin-top:4px; }

/* Badge no botão */
.nav-badge{
  position:absolute;
  top: 10px;
  right: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color:#fff;
  font-size: 10px;
  line-height: 16px;
  font-weight: 800;
  display:flex;
  align-items:center;
  justify-content:center;
}
.nav-btn{ position: relative; }
.bottom-btn{ margin-top: 10px; }


/* Comentários - timeline (histórico) */
.comentario-timeline{
  max-height: 220px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  background: #fafafa;
  margin-top: 10px;
  margin-bottom: 10px;
}
.timeline-item{
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #f0f0f0;
  margin-bottom: 8px;
}
.timeline-item:last-child{ margin-bottom: 0; }
.timeline-meta{
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}
.timeline-text{
  font-size: 13px;
  color: #111827;
  line-height: 1.35;
}
.timeline-empty{
  font-size: 13px;
  color: #6b7280;
  padding: 6px;
}

/* Filtro de comentários (linhas) */
.comment-filter-hide{
  display: none !important;
}


/* Notificações: não lidas */
#notificacoes-badge.hidden { display:none !important; }
.notif-item.unread{
  border-color:#2563eb;
  box-shadow: 0 8px 22px rgba(37,99,235,0.14);
}
.notif-item.unread .notif-title::before{
  content:'•';
  color:#2563eb;
  margin-right:6px;
  font-weight:900;
}


/* Flag discreta: aparece melhor no hover, sem atrapalhar leitura */
.comment-cell:hover .comment-flag{
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
 opacity:1; transform: translateY(-0.5px); }


/* Garante que a flag nunca "vaze" para fora da célula */
#orcamento-table td.comment-cell{ position:relative; overflow:hidden; }
#orcamento-table td.comment-cell .comment-flag{
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);

  top:2px;
  left:2px;
  z-index:2;
}
/* evita que a flag apareça sobre header sticky */
#orcamento-table thead .comment-flag{
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
 display:none !important; }

/* Botão Editar (timeline) - design profissional */
.btn-edit-comentario{
  border:1px solid #e5e7eb;
  background:rgba(255,255,255,0.85);
  color:#111827;
  border-radius:10px;
  padding:3px 10px;
  font-size:12px;
  line-height:1.2;
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn-edit-comentario:hover{
  background:rgba(255,255,255,1);
  border-color:#cbd5e1;
}
.btn-edit-comentario:active{ transform: translateY(0.5px); }



/* Notificações: histórico e destaque por lida/não lida */
.notif-item{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(229,231,235,0.9);
  background: rgba(255,255,255,0.92);
  cursor:pointer;
  transition: opacity .15s ease, transform .05s ease, background .15s ease, border-color .15s ease;
}
.notif-item:hover{ background: rgba(255,255,255,1); border-color: rgba(203,213,225,1); }
.notif-item:active{ transform: translateY(0.5px); }

.notif-item.is-unread{
  opacity: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.notif-item.is-unread .notif-title{ font-weight: 700; color:#111827; }
.notif-item.is-unread .notif-meta{ opacity: 0.95; }

.notif-item.is-read{
  opacity: 0.55;
  box-shadow: none;
}
.notif-item.is-read .notif-title{ font-weight: 600; color:#374151; }
.notif-item.is-read .notif-meta{ opacity: 0.75; }


/* ===== PrintScreen Guard (blur + overlay) ===== */
.screen-blurred #app,
.screen-blurred .app-container,
.screen-blurred main {
  filter: blur(8px);
}

#screen-blur-overlay{
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.25);
}
#screen-blur-overlay.hidden{ display:none; }

.screen-blur-card{
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(229,231,235,0.9);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.18);
  text-align:center;
  max-width: 320px;
}
.screen-blur-title{ font-weight: 800; font-size: 14px; color:#111827; }
.screen-blur-sub{ margin-top:4px; font-size: 12px; color:#374151; }


/* ===== Marca d’água dinâmica ===== */
#watermark-layer{
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  pointer-events: none;
  opacity: 0.18;
  display: none;
}
#watermark-layer .wm{
  position:absolute;
  transform: rotate(-20deg);
  font-size: 12px;
  font-weight: 700;
  color: rgba(17, 24, 39, 0.55);
  white-space: nowrap;
  user-select: none;
}


/* Histórico de notificações: estado visual */
.notification.read { opacity: 0.45; }
.notification.unread { opacity: 1; font-weight: 600; }


.notif-empty{padding:12px 10px; color: rgba(55,65,81,0.75); font-size:12px;}

/* Comentário: ícone inline após valor (Diferença %) */
.comment-icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin-left:6px;
  width:16px;
  height:16px;
  cursor:pointer;
  vertical-align:middle;
  border-radius: 4px;
}
.comment-icon-btn img{
  width:16px;
  height:16px;
  display:block;
  opacity:0.85;
}
.comment-icon-btn.has-comment img{ opacity:1; }
.comment-icon-btn.unread img{ filter: drop-shadow(0 0 2px rgba(220,38,38,0.65)); }


/* Override: botão inline após número em 'Diferença %' */
#orcamento-table td button.comment-icon-btn{
  position: static !important;
  float: none !important;
  margin-left: 6px !important;
  width: 18px !important;
  height: 18px !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  cursor: pointer;
}
#orcamento-table td button.comment-icon-btn img{
  width: 18px !important;
  height: 18px !important;
}

/* garante que o ícone não seja cortado */
#orcamento-table td{ overflow: visible; }

/* Diferença %: manter valor + ícone na mesma linha */
#orcamento-table td.col-perc { white-space: nowrap; }
/* garante botão visível */
#orcamento-table td.col-perc .comment-icon-btn { display:inline-flex; margin-left:6px; }


/* Mensagem de erro no modal de comentários */
.comentario-error{
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #ef4444;
}


/* Botão Excluir comentário (mantém identidade do Editar, com vermelho) */
.btn-edit-comentario,
.btn-delete-comentario{
  border:1px solid #e5e7eb;
  background:transparent;
  color:#374151;
  border-radius:10px;
  padding:3px 8px;
  font-size:12px;
  line-height:1.2;
  cursor:pointer;
  transition: border-color .15s ease, background .15s ease, transform .08s ease;
}

.btn-edit-comentario:hover,
.btn-delete-comentario:hover{
  border-color:#cbd5e1;
  background:rgba(255,255,255,0.6);
}

.btn-edit-comentario:active,
.btn-delete-comentario:active{
  transform: translateY(0.5px);
}

/* Excluir em vermelho (mantém o mesmo shape do Editar) */
.btn-delete-comentario{
  border-color: rgba(239, 68, 68, 0.55);
  color:#b91c1c;
}

.btn-delete-comentario:hover{
  border-color: rgba(239, 68, 68, 0.75);
  background: rgba(239, 68, 68, 0.06);
}


/* --- Modo offline (alerta + trava) --- */
.system-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120002;
  background: #7f1d1d;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.system-offline-banner .banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.system-offline-banner .banner-left strong {
  font-weight: 700;
  white-space: nowrap;
}
.system-offline-banner .banner-left span {
  opacity: 0.95;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.system-offline-banner .banner-actions {
  display: flex;
  gap: 8px;
}
.system-offline-banner button {
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
}
.system-offline-banner button:hover {
  background: rgba(255,255,255,0.18);
}
.system-offline-overlay {
  position: fixed;
  inset: 0;
  z-index: 120003;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.system-offline-card {
  width: min(520px, 95vw);
  background: #fff;
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  border: 1px solid rgba(0,0,0,0.06);
}
.system-offline-card .head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.system-offline-card .icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #fee2e2;
  color: #991b1b;
  font-size: 18px;
}
.system-offline-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}
.system-offline-card p {
  margin: 10px 0 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.4;
}
.system-offline-card .reason {
  margin-top: 8px;
  font-size: 12px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 12px;
}
.system-offline-card .actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.system-offline-card .btn-primary-offline {
  border: none;
  background: #991b1b;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}
.system-offline-card .btn-secondary-offline {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}
.disabled-offline {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

/* Compatibilidade extra: caso algum trecho use "toggle-password" */
.toggle-password{
  position:absolute;
  right:10px;
  top:50%;
  transform:translateY(-50%);
  border:0;
  background:transparent;
  color:var(--text-muted);
  cursor:pointer;
  opacity:0.7;
  transition: opacity .15s ease, transform .15s ease, background .15s ease;
  padding:6px;
  border-radius:8px;
}
.toggle-password:hover{
  opacity:1;
  background:rgba(0,0,0,0.04);
}
.toggle-password i{ pointer-events:none; }


/* --- ORÇAMENTO: COLUNA TOTAL (após Dezembro) --- */
#orcamento-table thead .th-total{ font-weight:800; }
#orcamento-table thead .th-total-sub{ font-weight:800; }


/* ===============================
   FCL - Texto forte + cor condicional + sticky
   =============================== */

#finance-table tr.fcl-row td {
  font-weight: 800 !important;
}

#finance-table tr.fcl-row td:first-child {
  font-weight: 900 !important;
}

:root {
  --fcl-sticky-top: 40px;
}

#finance-table tr.fcl-row td {
  position: sticky;
  top: var(--fcl-sticky-top);
  z-index: 80;
  background: #fff !important;
  border-bottom: 2px solid #e5e7eb !important;
}


/* ====== FCL highlight for 'financeiro-table' (fallback to finance-table) ====== */
#financeiro-table tr.fcl-row td,
#finance-table tr.fcl-row td {
  font-weight: 800 !important;
}

#financeiro-table tr.fcl-row td:first-child,
#finance-table tr.fcl-row td:first-child {
  font-weight: 900 !important;
}

/* Sticky top offset: adjust if header height differs */
:root {
  --fcl-sticky-top: 48px;
}

/* Apply sticky per cell to avoid layout shifts */
#financeiro-table tr.fcl-row td,
#finance-table tr.fcl-row td {
  position: sticky;
  top: var(--fcl-sticky-top);
  z-index: 80;
  background: #ffffff !important;
  border-bottom: 2px solid #e5e7eb !important;
}

/* Ensure color classes exist */
.text-green { color: var(--success) !important; }
.text-red { color: var(--danger) !important; }
