: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: 26px; 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: #ffffff;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);

    /* Sombra externa azul (institucional) */
    box-shadow:
        0 4px 10px rgba(37, 99, 235, 0.15),
        0 0 0 1px rgba(37, 99, 235, 0.08);

    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover{
    box-shadow:
        0 6px 16px rgba(37, 99, 235, 0.25),
        0 0 0 1px rgba(37, 99, 235, 0.15);
}

.card-title{
    font-size: 16px;
    font-weight: 800;
    color: #000000;
    text-transform: uppercase;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.card-value{
    font-size: 24px;
    font-weight: 900;
    color: #000000;
    font-variant-numeric: tabular-nums;
}

/* KPI (Dashboard) — layout com velocímetro + linhas à direita */
.kpi-expanded{
  padding: 12px 14px 14px;
}
.kpi-expanded .card-title{
  text-align: center;
  margin-bottom: 10px;
}
.kpi-card-gauge{
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fbfbfc 0%, #f2f3f5 100%);
  box-shadow:
    inset 0 2px 10px rgba(255,255,255,0.85),
    inset 0 -6px 18px rgba(15, 23, 42, 0.08),
    inset 0 0 28px rgba(15, 23, 42, 0.05),
    0 4px 10px rgba(37, 99, 235, 0.15),
    0 0 0 1px rgba(37, 99, 235, 0.08);
}
.kpi-card-gauge::before{
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 22% 18%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.45) 24%, rgba(255,255,255,0) 52%),
              radial-gradient(circle at 75% 85%, rgba(15,23,42,0.08) 0%, rgba(15,23,42,0) 48%);
}
.kpi-card-gauge > *{
  position: relative;
  z-index: 1;
}
.kpi-card-body{
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}
.kpi-gauge-wrap{
  position: relative;
  width: 250px;
  min-width: 250px;
  height: 122px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.kpi-gauge{
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.14));
}
.kpi-gauge-track,
.kpi-gauge-base,
.kpi-gauge-fill{
  fill: none;
  stroke-linecap: round;
}
.kpi-gauge-track{
  stroke-width: 24;
}
.kpi-gauge-base{
  stroke: rgba(75, 85, 99, 0.14);
  stroke-width: 24;
}
.kpi-gauge-fill{
  stroke: var(--gauge-color, #10b981);
  stroke-width: 18;
  transition: stroke-dashoffset 1.2s ease;
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.16));
}
.kpi-exec-label{
  position: absolute;
  left: 50%;
  top: 60px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #1f2937;
}
.kpi-exec-value{
  position: absolute;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: 900;
}
.kpi-lines{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-lines-right{
  min-width: 0;
}
.kpi-line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #f3f4f6;
}
.kpi-label{
  font-size: 16px;
  font-weight: 800;
  color: #000000;
}
.kpi-num{
  font-size: 16px;
  font-weight: 900;
  color: #111827;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.kpi-green .kpi-num{ color: var(--success); }
.kpi-red .kpi-num{ color: var(--danger); }
.kpi-pos .kpi-num{ color: var(--success); }
.kpi-neg .kpi-num{ color: var(--danger); }

@media (max-width: 1400px){
  .kpi-card-body{
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .kpi-lines-right{
    width: 100%;
  }
}

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

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

/* --- ESPECÍFICO: ORÇAMENTO (8 COLUNAS - LINHA ÚNICA) --- */
#kpi-orcamento-container {
    grid-template-columns: repeat(8, 1fr);
}
#kpi-orcamento-container .card { padding: 18px 16px; display:flex; flex-direction:column; text-align:center; min-height: 118px; }
#kpi-orcamento-container .card-title { font-size: 12px; margin-bottom: 8px; text-align:center; line-height: 1.25; white-space: normal; }
#kpi-orcamento-container .card-value { font-size: 20px; font-weight: 900; text-align: center; line-height: 1.1; }

/* 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: 3600px !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; }

/* ================================
   DFC (Dashboard) — colunas numéricas auto-dimensionadas
   - A largura é calculada via JS e aplicada em --dfc-num-col-width
   - Mantém TODAS as colunas numéricas com o mesmo tamanho
   - Mantém números CENTRALIZADOS e sem corte
   ================================ */

/* valor default (JS sobrescreve no próprio #finance-table) */
#finance-table{ --dfc-num-col-width: 128px; }

/* Mantemos fixed para garantir colunas uniformes e sticky consistente */
#finance-table{ table-layout: fixed !important; }

/* Todas as colunas numéricas (exceto a 1ª coluna de descrição) */
#finance-table th:not(:first-child),
#finance-table td:not(:first-child){
  width: var(--dfc-num-col-width) !important;
  min-width: var(--dfc-num-col-width) !important;
  max-width: var(--dfc-num-col-width) !important;
  white-space: nowrap !important;
  overflow: visible !important; /* evita corte */
  text-overflow: clip !important;
  font-variant-numeric: tabular-nums;
}

/* Valores centralizados (pedido) */
#finance-table td:not(:first-child){
  text-align: center !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}
.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: 24px; height: 520px; 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: fixed !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: var(--dfc-num-col-width) !important;
  max-width: var(--dfc-num-col-width) !important;
  width: var(--dfc-num-col-width) !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;
}

/*
  Quando exibimos "valor + percentual" dentro da célula,
  precisamos permitir 2 linhas sem corte.
  (mantemos o comportamento antigo de ellipsis para células comuns)
*/
#financeiro-table td.has-perc{
    white-space: normal;
    overflow: visible;
}

/* ================================
   Financeiro (Dashboard) — valor + percentual (Inadimplência)
   ================================ */
#financeiro-table td .dfc-cell{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

#financeiro-table td .dfc-val{
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

#financeiro-table td .dfc-perc{
    margin-top: 3px;
    font-size: 0.90em;
    font-weight: 900;
    opacity: 0.95;
    font-variant-numeric: tabular-nums;
}

#financeiro-table td .dfc-perc.risk-low{ color: var(--success); }
#financeiro-table td .dfc-perc.risk-med{ color: #f59e0b; } /* amber */
#financeiro-table td .dfc-perc.risk-high{ color: var(--danger); }

#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)
   - Mantém o mesmo "design" e comportamento da tabela DFC
   ===================================================== */

#financeiro-panel{ display:flex; flex-direction:column; }

/* 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: fixed !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)
========================================================= */

@media (max-width: 768px){
  #page-orcamento .filter-field{
    width: 100%;
  }
}
/* =========================================================
   PATCH (FINAL v2)
   - Labels acima dos filtros (Dashboard + Orçamento)
   - Filtros lado a lado (layout antigo)
   ======================================================== */
.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){
  .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) */

/* Orçamento: badge de dias úteis na faixa de filtros */

/* Preferência: KPI de dias úteis (badge oculto) */

/* --- Layout dos filtros da Aba Orçamento --- */

/* Orçamento: filtros em linha, mesmo design */

/* 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 */

/* ===========================
   Comentários (Orçamento)
   =========================== */
.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; }

.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 */

/* Garante que a flag nunca "vaze" para fora da célula */
#orcamento-table td
/* 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 */

.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" */

/* --- 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; }

/* =====================================================
   DFC (Dashboard) — 2 linhas de cabeçalho (Todos x Realizado)
   - 1ª linha: meses/trimestres/anos (colspan=2)
   - 2ª linha: subcolunas
   ===================================================== */
:root{ --finance-thead-row1-h: 34px; }

#finance-table thead tr:nth-child(1) th{ z-index: 120 !important; }
#finance-table thead tr:nth-child(2) th{
  top: var(--finance-thead-row1-h) !important;
  background: #f3f4f6 !important;
  color: #111827 !important;
  z-index: 110 !important;
}
#finance-table thead th.subhdr{ font-size: 12px; font-weight: 800; }

/* =======================================
   FIX DEFINITIVO — Colunas Previsto/Realizado
   - Força largura igual
   - Centraliza cabeçalho
   ======================================= */

.table-wrapper table {
    table-layout: fixed !important;
}

.table-wrapper th,
.table-wrapper td {
    text-align: center !important;
}

.table-wrapper thead th {
    text-align: center !important;
    font-weight: 700;
}

/* =========================
   HOTFIX: Subheader widths/alignment (Previsto/Realizado/Orçado)
   - Evita que apenas "Orçado" fique mais largo
   - Centraliza texto vertical/horizontal
   ========================= */
#finance-table{ table-layout: fixed !important; }

#finance-table thead tr:nth-child(2) th,
#finance-table thead th.subhdr,
#finance-table thead th.th-planejado,
#finance-table thead th.th-realizado{
  width: var(--dfc-num-col-width, 128px) !important;
  min-width: var(--dfc-num-col-width, 128px) !important;
  max-width: var(--dfc-num-col-width, 128px) !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding-left: 8px !important;
  padding-right: 8px !important;
  white-space: nowrap !important;
}

#finance-table thead tr:nth-child(2) th{
  display: table-cell !important; /* garante alinhamento padrão */
}

/* Se existir alguma regra posterior puxando width:auto, sobrescreve */
#finance-table th:not(:first-child),
#finance-table td:not(:first-child){
  width: var(--dfc-num-col-width, 128px) !important;
  min-width: var(--dfc-num-col-width, 128px) !important;
  max-width: var(--dfc-num-col-width, 128px) !important;
}

/* =========================================================
   HOTFIX v4: Colunas com auto-regulagem (não cortar números)
   - Reverte table-layout fixed para auto
   - Remove widths travadas das colunas numéricas
   - Mantém padronização via min-width e centralização
   ========================================================= */
.table-wrapper table,
#finance-table,
#financeiro-table{
  table-layout: auto !important;
}

/* Permite que a tabela cresça conforme o conteúdo, com scroll horizontal no wrapper */
#finance-table,
#financeiro-table{
  width: max-content !important;
  min-width: 100% !important;
}

/* Colunas de valores: largura automática + mínimo confortável */
#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: auto !important;
  min-width: var(--dfc-num-col-min, 150px) !important;
  max-width: none !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  font-variant-numeric: tabular-nums;
}

/* Subheaders (Orçado/Previsto/Realizado): mesma regra das colunas numéricas */
#finance-table thead tr:nth-child(2) th,
#financeiro-table thead tr:nth-child(2) th{
  width: auto !important;
  min-width: var(--dfc-num-col-min, 150px) !important;
  max-width: none !important;
  text-align: center !important;
  vertical-align: middle !important;
}

/* DASHBOARD - FINANCE TABLE MONTH ALIGN */
#finance-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* mantém colunas alinhadas mês a mês */
}

#finance-table th, #finance-table td {
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

/* separador no fim de cada mês (após Diferença) */
#finance-table tbody td:nth-child(3n+1) {
  border-right: 2px solid rgba(0,0,0,0.12);
}

/* cabeçalho 2ª linha: Orçado | Realizado | Diferença (%) */
#finance-table thead tr:nth-child(2) th:nth-child(3n) {
  border-right: 2px solid rgba(0,0,0,0.12);
}

/* cabeçalho 1ª linha: o TH do mês (colspan=3) */

/* ============================
   Dashboard (Financeiro) — valor + percentual na célula
   ============================ */
.finance-cell{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    line-height:1.15;
}

.finance-value{
    font-weight:600;
}

.finance-percent{
    color:#6b7280;
    margin-top:2px;
    font-weight:500;
}

/* ============================
   Dashboard (Financeiro) — barra + gradiente por percentual
   ============================ */
.finance-bar{
    width: 78%;
    height: 6px;
    border-radius: 999px;
    background: rgba(17,24,39,0.10);
    overflow: hidden;
    margin-top: 4px;
}

.finance-bar-fill{
    height: 100%;
    border-radius: 999px;
    background: rgba(var(--risk-r, 37), var(--risk-g, 99), var(--risk-b, 235), 0.95);
}

/* ============================
   Dashboard — padronização de fonte (aba completa)
   Ajuste central: todos os textos do dashboard ficam no mesmo tamanho base.
   ============================ */
#page-dashboard{
    font-size: 14px;
}

#page-dashboard h1,
#page-dashboard h2,
#page-dashboard h3,
#page-dashboard p,
#page-dashboard label,
#page-dashboard input,
#page-dashboard select,
#page-dashboard button,
#page-dashboard .filter-label,
#page-dashboard .card-title,
#page-dashboard .card-value,
#page-dashboard .kpi-label,
#page-dashboard .kpi-num{
    font-size: 14px !important;
}

#page-dashboard .card-title,
#page-dashboard .kpi-label{
    font-weight: 800 !important;
}

#page-dashboard .card-value,
#page-dashboard .kpi-num{
    font-weight: 900 !important;
}

/* Tabelas do dashboard: cabeçalho e corpo no mesmo tamanho */
#finance-table thead th,
#finance-table td,
#financeiro-table thead th,
#financeiro-table td{
    font-size: 14px !important;
}

/* ============================
   Financeiro (Dashboard) — percentual + gradiente de risco + cores automáticas
   ============================ */
#financeiro-table td{
    vertical-align: middle;
}

.finance-cell{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    line-height:1.15;
}

.finance-value{
    font-weight:700;
}

.finance-percent{
    margin-top:2px;
    font-weight:700;
}

/* ================================
   Financeiro (tabela inferior) — mostrar valor + percentual (2 linhas)
   ================================ */
#financeiro-table td { white-space: normal !important; }
#financeiro-table td .finance-cell{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
}
#financeiro-table td .finance-value{
  font-weight:600;
}
#financeiro-table td .finance-percent{
  font-size:11px;
  font-weight:800;
  line-height:1;
}

/* AUMENTO APENAS DA FONTE DO TÍTULO DO DASHBOARD (SEM ALTERAR LAYOUT) */
.top-bar .titles h1{
    font-size: 34px;
}

.top-bar .titles p{
    font-size: 18px;
}

/* ===== Dashboard comparison chart ===== */
.dashboard-comparison-panel .panel-head.dashboard-chart-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}
.dashboard-chart-title-wrap{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.dashboard-chart-title-wrap h3{
  margin:0;
}
.dashboard-chart-year{
  font-size:12px;
  font-weight:700;
  color:#64748b;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.dashboard-chart-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}
.chart-tab-btn{
  border:1px solid rgba(148,163,184,.35);
  background:#fff;
  color:#334155;
  font-weight:700;
  font-size:13px;
  line-height:1;
  padding:10px 14px;
  border-radius:999px;
  cursor:pointer;
  transition:all .2s ease;
  box-shadow:0 4px 12px rgba(15,23,42,.05);
}
.chart-tab-btn:hover{
  border-color:rgba(37,99,235,.45);
  color:#1d4ed8;
  transform:translateY(-1px);
}
.chart-tab-btn.active{
  background:linear-gradient(135deg, #1d4ed8, #2563eb);
  border-color:#1d4ed8;
  color:#fff;
  box-shadow:0 10px 24px rgba(37,99,235,.22);
}
.comparison-chart-wrapper{
  min-height:390px;
}

@media (max-width: 900px){
  .dashboard-comparison-panel .panel-head.dashboard-chart-head{
    align-items:flex-start;
  }
  .dashboard-chart-tabs{
    width:100%;
  }
  .chart-tab-btn{
    flex:1 1 calc(50% - 10px);
    text-align:center;
    justify-content:center;
  }
  .comparison-chart-wrapper{
    min-height:340px;
  }
}

/* ==================================================
   KPI RESPONSIVO — AJUSTE FINO SEM DISTORÇÃO
   Mantém 4 cards no desktop, reduz progressivamente
   e preserva rótulos/valores legíveis.
   ================================================== */
#kpi-container{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:16px;
  align-items:stretch;
}

.kpi-expanded{
  padding:12px 14px 14px;
}

.kpi-expanded .card-title{
  font-size:clamp(14px, 0.95vw, 16px);
  line-height:1.2;
  white-space:normal;
  overflow:visible;
  text-overflow:unset;
  word-break:normal;
  overflow-wrap:break-word;
  min-height:34px;
}

.kpi-card-body{
  display:grid;
  grid-template-columns:minmax(150px, 43%) minmax(180px, 1fr);
  align-items:center;
  gap:12px;
}

.kpi-gauge-wrap{
  position:relative;
  width:100%;
  max-width:210px;
  min-width:150px;
  height:auto;
  aspect-ratio:2.05 / 1;
  margin-inline:auto;
}

.kpi-gauge{
  width:100%;
  height:100%;
}

.kpi-exec-label{
  top:56%;
  left:50%;
  transform:translate(-50%, -50%);
  width:100%;
  padding:0 8px;
  text-align:center;
  font-size:clamp(10px, 0.72vw, 12px);
  line-height:1.05;
}

.kpi-exec-value{
  top:71%;
  left:50%;
  transform:translate(-50%, -50%);
  width:100%;
  padding:0 8px;
  text-align:center;
  font-size:clamp(14px, 1.08vw, 18px);
  line-height:1;
}

.kpi-lines,
.kpi-lines-right{
  width:100%;
  min-width:0;
}

.kpi-line{
  display:grid;
  grid-template-columns:minmax(88px, auto) minmax(0, 1fr);
  align-items:center;
  gap:10px;
  padding:8px 10px;
}

.kpi-label{
  font-size:clamp(13px, 0.95vw, 16px);
  line-height:1.15;
  white-space:nowrap;
  word-break:normal;
  overflow-wrap:normal;
}

.kpi-num{
  font-size:clamp(13px, 0.98vw, 16px);
  line-height:1.15;
  text-align:right;
  word-break:normal;
  overflow-wrap:anywhere;
}

@media (max-width: 1600px){
  #kpi-container{
    grid-template-columns:repeat(4, minmax(0, 1fr));
  }

  .kpi-card-body{
    grid-template-columns:minmax(145px, 40%) minmax(168px, 1fr);
  }

  .kpi-gauge-wrap{
    max-width:190px;
  }

  .kpi-line{
    grid-template-columns:minmax(82px, auto) minmax(0, 1fr);
    gap:8px;
  }
}

@media (max-width: 1366px){
  #kpi-container{
    grid-template-columns:repeat(2, minmax(320px, 1fr));
  }

  .kpi-card-body{
    grid-template-columns:minmax(165px, 42%) minmax(210px, 1fr);
  }

  .kpi-gauge-wrap{
    max-width:205px;
  }
}

@media (max-width: 900px){
  #kpi-container{
    grid-template-columns:1fr;
  }

  .kpi-card-body{
    grid-template-columns:minmax(150px, 190px) minmax(0, 1fr);
  }
}

@media (max-width: 640px){
  .kpi-card-body{
    grid-template-columns:1fr;
    justify-items:center;
  }

  .kpi-gauge-wrap{
    max-width:180px;
  }

  .kpi-lines-right{
    width:100%;
  }

  .kpi-line{
    grid-template-columns:1fr;
    justify-items:center;
    text-align:center;
  }

  .kpi-label,
  .kpi-num{
    text-align:center;
    white-space:normal;
  }
}

/* ===== Dashboard comparison chart - composição refinada ===== */
.comparison-chart-wrapper{
  min-height: 430px;
}
.dashboard-comparison-panel{
  overflow: visible;
}
.dashboard-chart-tabs{
  align-items:center;
}
.chart-tab-btn{
  min-height: 40px;
}
@media (max-width: 900px){
  .chart-tab-btn{
    flex: 1 1 calc(50% - 10px);
  }
  .comparison-chart-wrapper{
    min-height: 360px;
  }
}

/* ================================
   AJUSTES FINAIS — Dashboard/Orçamento
   ================================ */
#dashboard-chart-tabs{
  display:none !important;
}

.dashboard-chart-head{
  justify-content: space-between;
  align-items: center;
}

.comparison-chart-wrapper{
  min-height: 520px;
  padding-top: 28px;
}

.chart-panel canvas{
  max-height: 520px !important;
}

@media (max-width: 1024px){
  .chart-wrapper{
    height: 440px;
    padding: 18px;
  }

  .comparison-chart-wrapper{
    min-height: 440px;
  }

  #kpi-orcamento-container .card-value{
    font-size: 18px;
  }
}

@media (max-width: 768px){
  .chart-wrapper{
    height: 360px;
    padding: 14px;
  }

  .comparison-chart-wrapper{
    min-height: 360px;
  }

  #kpi-orcamento-container .card{
    min-height: 102px;
  }

  #kpi-orcamento-container .card-value{
    font-size: 18px;
  }
}
