/* ===== KPIs – mini-cards no estilo do mockup ===== */
.kpis{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.kpi-card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
  display:flex;
  flex-direction:column;
  gap: 6px;
}


.kpi__label{
  font: 600 12px/1.1 system-ui, Segoe UI, Inter, Arial;
  color: var(--muted);
}

.kpi__value{
  font: 800 20px/1.15 system-ui, Segoe UI, Inter, Arial;
  color: var(--text);
  letter-spacing: .2px;
}

/* Destaques */
.kpi--primary{
  /* bloco roxo do primeiro KPI */
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 18%, transparent) 0%,
                                       transparent 85%);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border) 65%);
}
.kpi--primary .kpi__value{ color:#ffffff; }
.kpi--primary .kpi__label{ color: color-mix(in srgb, #ffffff 80%, transparent); }

/* “Total em juros” em tom positivo (mantém mock visual) */
.kpi--success .kpi__value{ color: #1aa774; }

/* Responsivo: empilha no mobile */
@media (max-width: 720px){
  .kpis{ grid-template-columns: 1fr; }
}

/* Dark mode: contraste sutil melhorado */
.dark .kpi-card{
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
}
.dark .kpi--primary{
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--primary) 28%, transparent) 0%,
    transparent 85%);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border) 55%);
}



/* ===== Table simples ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
.table th {
  font-weight: 600;
  color: var(--text);
}
.table tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.02);
}
.dark .table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.04);
}

/* ===== KPIs – mini-cards ===== */
.kpis{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.kpi-card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
  display:flex;
  flex-direction:column;
  gap: 6px;
}

.kpi__label{
  font: 600 12px/1.1 system-ui, Segoe UI, Inter, Arial;
  color: var(--muted);
}

.kpi__value{
  font: 800 20px/1.15 system-ui, Segoe UI, Inter, Arial;
  color: var(--text);
  letter-spacing: .2px;
}

/* Destaque roxo */
.kpi--primary{
  background: var(--primary);
  color: var(--primary-contrast);
}
.kpi--primary .kpi__label{ color: rgba(255,255,255,.85); }
.kpi--primary .kpi__value{ color:#fff; }

/* Destaque positivo */
.kpi--success .kpi__value{ color: #1aa774; }

/* Responsivo */
@media (max-width: 720px){
  .kpis{ grid-template-columns: 1fr; }
}

.field select {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #333;
  background-color: #2a2a2a; /* mesma cor dos inputs */
  color: #fff;
  font-size: 14px;
  appearance: none; /* remove seta padrão */
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

/* ===== Controle composto: input + select no mesmo bloco ===== */
.input-split{
  display:flex;
  align-items:center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;                 /* une as bordas */
}

.input-split input,
.input-split select{
  height: 33px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 14px/1 Inter, system-ui;
}

.input-split input{
  flex: 1 1 auto;
  padding:  12px;
  /* remove setinhas dos number */
}
.input-split input[type=number]::-webkit-inner-spin-button,
.input-split input[type=number]::-webkit-outer-spin-button{ -webkit-appearance:none; margin:0; }
.input-split input[type=number]{ -moz-appearance:textfield; }

.input-split select{
  flex: 0 0 auto;
  padding: 0 36px 0 120px;           /* espaço pra seta */
  border-left: 1px solid var(--border);
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer;
  min-width: 110px;                 /* garante leitura do rótulo */
}

/* setinha custom do select */
.input-split{ position: relative; }
.input-split::after{
  content: "▾";
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--muted);
  font-size: 12px;
}

/* foco consistente */
.input-split:focus-within{
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* dark refinado */
.dark .input-split{
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}

/* ===== Controle composto: input + select colados (taxa e período) ===== */
.input-split{
  display:flex;
  align-items:center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;                 /* une as bordas */
  position: relative;
}

/* altura e tipografia uniformes */
.input-split input,
.input-split select{
  height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 14px/1 Inter, system-ui;
}

/* campo longo à esquerda */
.input-split input{
  flex: 1 1 auto;
  padding: 0 12px;
  border-top-right-radius: 0;       /* tira canto interno */
  border-bottom-right-radius: 0;
  /* remove setinhas do number */
}
.input-split input[type=number]::-webkit-inner-spin-button,
.input-split input[type=number]::-webkit-outer-spin-button{ -webkit-appearance:none; margin:0; }
.input-split input[type=number]{ -moz-appearance:textfield; }

/* select curtinho à direita, colado na divisória */
.input-split select{
  flex: 0 0 auto;
  min-width: 96px;                  /* ajuste se quiser menor/maior */
  padding: 0 32px 0 12px;           /* esquerda 12 para colar no traço */
  border-left: 1px solid var(--border);
  margin-left: -1px;                /* remove a borda dupla */
  border-top-left-radius: 0;        /* tira canto interno */
  border-bottom-left-radius: 0;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer;
}

/* setinha custom do select */
.input-split::after{
  content: "▾";
  position: absolute;
  right: 12px;
  pointer-events: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

/* foco bonito e consistente */
.input-split:focus-within{
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* escopo do select padrão (não interferir nos que estão dentro do .input-split) */
.field > select{
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #333;
  background-color: #2a2a2a;
  color: #fff;
  font-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

/* Split da taxa: input + select com bom respiro */
.input-split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

/* Seletor compacto, sem caret (setinha) */
#rateUnit.no-caret {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  padding-inline: 12px;
  min-width: 90px;   /* cabe “ao mês / ao ano” sem estourar */
}

/* (Opcional) remover setas de number do Chrome/Firefox, se quiser um look mais “limpo” global */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.input-split{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center;}
.no-caret{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:none;padding-inline:12px;min-width:90px;}

#growth-chart{ min-height:320px; }

/* Caixa do gráfico com altura controlada */
.chart-box{
  position: relative;
  width: 100%;
  height: 360px;        /* altura padrão */
  max-height: 60vh;     /* nunca passa de 60% da viewport */
  overflow: hidden;     /* evita “vazar” conteúdo */
  border-radius: 14px;  /* inline com seus cards */
}

/* Em telas maiores, dá um pouco mais de respiro */
@media (min-width: 1024px){
  .chart-box{ height: 420px; }
}

/* Canvas preenche o wrapper */
#growth-chart{
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* (Se ainda existir) remova qualquer min-height antigo do canvas */
#growth-chart{ min-height: 0; }

/* Wrapper da tabela */
.table-scroll{
  overflow: hidden;            /* padrão: sem scroll */
  border-radius: 12px;
}

/* Quando houver muitos meses, o JS adiciona .scrollable */
.table-scroll.scrollable{
  overflow: auto;              /* ativa scroll */
  max-height: clamp(360px, 56vh, 680px); /* responsivo, sem estourar a página */
}

/* (Opcional) scrollbar elegante no dark */
.table-scroll.scrollable::-webkit-scrollbar{ width: 8px; }
.table-scroll.scrollable::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

/* (Opcional) cabeçalho “grudado” no topo do wrapper */
.table-scroll thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface, #14151a);
}

.actions{
  display: flex; gap: 12px; align-items: center; justify-content: flex-start;
  flex-wrap: wrap;
}

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  height:44px; padding:0 16px; border-radius:12px; border:1px solid transparent;
  font-weight:600; line-height:1; cursor:pointer; transition:all .18s ease;
}

:root{
  --brand: #48139c;          /* primária */
  --brand-600: #a695ca;      /* um tom mais escuro p/ borda */
  --brand-300: #e1dde9;      /* textos sutis/ghost */
  --text-on-brand: #fff;     /* contraste no CTA */
}

/* CTA principal (Calcular) – sólido elevado */
.btn-primary{
  color: var(--text-on-brand);
  border: 1px solid var(--brand-600);
  background:
    linear-gradient(180deg,
      color-mix(in oklab, var(--brand), white 6%) 0%,
      color-mix(in oklab, var(--brand), black 6%) 100%);
  box-shadow:
    0 6px 16px color-mix(in oklab, var(--brand), transparent 75%),
    inset 0 1px 0 color-mix(in oklab, white, transparent 85%);
  transform: translateY(0);
  transition: transform .15s ease, filter .15s ease, box-shadow .2s ease;
}

.btn-primary:hover{
  filter: brightness(1.05);
  box-shadow:
    0 8px 22px color-mix(in oklab, var(--brand), transparent 70%),
    inset 0 1px 0 color-mix(in oklab, white, transparent 82%);
  transform: translateY(-1px);
}

.btn-primary:active{
  filter: brightness(0.98);
  box-shadow:
    0 2px 8px color-mix(in oklab, var(--brand), transparent 82%);
  transform: translateY(0);
}

.btn-primary:focus-visible{
  outline: 2px solid color-mix(in oklab, var(--brand), white 35%);
  outline-offset: 2px;
}

.btn-primary:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Secundário (Limpar) – ghost consistente */
.btn-ghost{
  color: var(--brand);
  border: 1px solid var(--brand);
  background: transparent;
}
.btn-ghost:hover{
  background: color-mix(in oklab, var(--brand), transparent 90%);
}
.btn-ghost:active{
  background: color-mix(in oklab, var(--brand), transparent 82%);
}


.btn-ghost{
  background:transparent; color:#f1eff3; border-color:#874ee4;
}
.btn-ghost:hover{ background:rgba(122,95,167,.08); }

.select, .input-split select{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  height:44px; padding:0 40px 0 12px; border-radius:12px; border:1px solid #020202;
  background:transparent; color:#E7E9EE;
}
.select:focus{ outline:2px solid rgba(255, 255, 255, 0.45); outline-offset:2px; }

/* Ações: linha por padrão, alinhadas à direita */
.form-actions{
  display:flex;
  gap:12px;
  justify-content:flex-end;   /* posiciona no canto do card */
  align-items:center;
  flex-wrap:wrap;
}

/* Ordem/hierarquia (garante primário antes do secundário) */
.form-actions .btn-primary{ order:1; }
.form-actions .btn-ghost{   order:2; }

/* Botões: altura consistente e mínimo de largura para não “pular” */
.btn{ height:44px; padding:0 16px; border-radius:12px; min-width:112px; }

/* Mobile: empilha e ocupa 100% (tocabilidade) */
@media (max-width: 640px){
  .form-actions{ justify-content:stretch; flex-direction:column; }
  .form-actions .btn{ width:100%; }
}

/* ===== Moeda: compacto e harmônico ===== */
.field-moeda { width: fit-content; }              /* não ocupar a coluna toda */
@media (min-width: 992px){
  .field-moeda { max-width: 260px; }              /* largura máxima elegante no desktop */
}

/* variação compacta do componente select */
.select--sm{
  height: 38px;                                   /* menor que os 44px padrão */
  padding: 0 28px 0 12px;
  font-size: .95rem;
  border-radius: 10px;
}

/* styling específico do select de Moeda para combinar com o tema */
.field-moeda .select{
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
}
.field-moeda .select:focus{
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent);
  outline-offset: 2px;
}

/* ===== Período e Taxa: tamanho e estilo coerentes ===== */
#periodUnit,
#rateUnit,
.select--unit{
  min-width: 112px;          /* largura confortável p/ rótulos longos */
  width: 112px;
  height: 44px;              /* igual aos inputs */
  padding: 0 32px 0 12px;
  border-radius: 12px;
  border: 1px solid #2B2F3B;
  background: #101217;       /* superfície dark do form */
  color: #E7E9EE;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

#periodUnit:focus,
#rateUnit:focus{
  outline: 2px solid rgba(122,95,167,.45);  /* roxo da marca */
  outline-offset: 2px;
}

/* Dropdown (lista aberta) — cores legíveis no dark (Chrome/Firefox) */
#periodUnit option,
#rateUnit option{
  background: #111318;       /* fundo do menu */
  color: #E7E9EE;
}

/* opção selecionada dentro do menu */
#periodUnit option:checked,
#rateUnit option:checked{
  background: #b9a3dd00;       /* roxo da marca */
  color: #fff;
}

/* estados desabilitados (ex.: "ano(s)") */
#periodUnit option:disabled,
#rateUnit option:disabled{
  color: rgba(231,233,238,.45);
}

/* Hover em navegadores que suportam (Chromium) */
#periodUnit option:hover,
#rateUnit option:hover{
  background: rgba(122,95,167,.18);
}

/* Variante compacta opcional: se quiser menos destaque */
.select--unit.select--sm{
  height: 38px;
  border-radius: 10px;
  padding-right: 28px;
  font-size: .95rem;
}

/* === NORMALIZAÇÃO GLOBAL DE CONTROLES (altura/raio) === */
:root{
  --control-h: 44px;           /* altura padrão única */
  --control-radius: 12px;      /* raio padrão único   */
}

/* Inputs/Selects “soltos” */
.field input[type="text"],
.field input[type="number"],
.select,
#moeda,
#periodUnit,
#rateUnit{
  height: var(--control-h);
  line-height: calc(var(--control-h) - 2px);
  border-radius: var(--control-radius);
}

/* Wrapper do combo (input + select colados) */
.input-split{
  /* havia grid/flex em regras anteriores; mantém o último (flex) */
  display: flex;
  align-items: center;
  border-radius: var(--control-radius);
  overflow: hidden;
  min-height: var(--control-h);
}

/* Partes internas do combo */
.input-split input,
.input-split select{
  height: var(--control-h);
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 14px/1 Inter, system-ui;
}

.input-split input{
  flex: 1 1 auto;
  padding: 0 12px;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-split select{
  flex: 0 0 auto;
  min-width: 112px;               /* cabe “mês(es)/ao mês/ao ano” sem quebrar */
  padding: 0 32px 0 12px;         /* espaço para a seta custom */
  margin-left: -1px;              /* remove a borda dupla */
  border-left: 1px solid var(--border);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Variações passam a respeitar a altura padrão também */
.select--unit,
.select--sm{
  height: var(--control-h);
  padding-right: 40px;
  border-radius: var(--control-radius);
  font-size: 1rem;
}

/* Botões com a mesma altura/raio dos campos */
.btn{
  height: var(--control-h);
  border-radius: var(--control-radius);
  min-width: 112px;
}

/* === FIX: Moeda legível e coerente com o tema === */
#moeda{
  /* mantém a altura global (já normalizada) e melhora legibilidade */
  line-height: normal;                 /* evita “apertar” o texto em <select> */
  background: #111318;                 /* mesmo tom dos campos no dark */
  color: #E7E9EE;                      /* contraste alto */
  border: 1px solid #2B2F3B;           /* borda coerente */
  padding: 0 28px 0 12px;              /* espaço para caret */
  width: auto;                         /* não esticar a coluna inteira */
  min-width: 136px;                    /* cabe “Dólar (US$)” e “Euro (€)” */
}

/* foco visível (corrige outline negativo que estava aplicado) */
.field-moeda .select:focus,
#moeda:focus{
  outline: 2px solid rgba(122,95,167,.45);
  outline-offset: 2px;
}

/* menu aberto coerente com o dark */
#moeda option{
  background: #111318;
  color: #E7E9EE;
}
#moeda option:checked{
  background: rgba(122,95,167,.35);
  color: #fff;
}
#moeda option:disabled{
  color: rgba(231,233,238,.45);
}

/* ==== Modal base (genérico) ==== */
.modal.hidden { display: none; }
.modal { position: fixed; inset: 0; z-index: 9999; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.38); }

.modal-card {
  position: relative;
  margin: 6vh auto 0;
  width: min(520px, 92vw);
  background: var(--surface, #fff);
  color: var(--text, #111827);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  outline: none;
}
.modal-header { display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--border,#e5e7eb); }
.modal-body   { padding: 16px 18px; }
.modal-actions{ display:flex; gap:12px; justify-content:flex-end; padding: 12px 18px 18px; }

.modal-close {
  appearance: none; border:0; background:transparent; font-size:20px; line-height:1;
  cursor:pointer; color: var(--muted,#6b7280);
}
.modal-close:hover { color: var(--text,#111827); }

/* animação sutil (sem quebrar performance) */
@keyframes fzModalIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }
.modal-card { animation: fzModalIn .16s ease-out; }


/* ===== Validação: realce de campo inválido ===== */
.is-invalid,
.is-invalid .input-split,
.input-split.is-invalid{
  border-color: #e11d48 !important;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, .18) !important;
}



/* === Modal (elegant / glassy) === */
.modal-backdrop{
  background: radial-gradient(1200px 800px at 50% -10%, rgba(122,95,167,.28), transparent 60%),
              rgba(0,0,0,.50);
  backdrop-filter: blur(6px);
}
.dark .modal-backdrop{ backdrop-filter: none !important; background: rgba(0, 0, 0, 0) !important; }

.modal-card{
  border: 3px solid color-mix(in srgb, var(--primary, #6f5992) 16%, var(--border, #2B2F3B));
  background-color: #0B0C12 !important; /* cor lisa do card */
  background-image: none !important; /* remove qualquer gradiente anterior */
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--card, #0f1116) 90%, transparent) 30%,
                           color-mix(in srgb, var(--surface, #14151a) 95%, transparent) 100%);
  border-radius: 16px;
  box-shadow:
    0 20px 44px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.04);
}

.modal-header{
  padding: 18px 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #2B2F3B) 86%, transparent);
}
.modal-header h3{
  font: 700 1.15rem/1.25 Inter, system-ui, -apple-system, Segoe UI, Arial;
  letter-spacing: .2px;
}

.modal-body{ padding: 18px 22px; color: var(--muted, #9aa1b2); }
.modal-actions{ padding: 12px 22px 20px; }

/* Button inside modal inherits primary styling; ensure min-width & softer radius */
#fz-error-ok.btn{ min-width: 108px; border-radius: 12px; }

/* ====== Ajustes para TEMA CLARO ====== */

/* 1) Botão "Limpar" (ghost) com texto escuro no tema claro */
html:not(.dark) .btn-ghost{
  color: var(--text, #111827);                 /* texto escuro */
  border-color: var(--primary, #7A5FA7);
  background: transparent;
}
html:not(.dark) .btn-ghost:hover{
  background: color-mix(in srgb, var(--primary, #7A5FA7) 10%, #ffffff);
}
html:not(.dark) .btn-ghost:disabled{
  color: #9ca3af;
  border-color: #d1d5db;
}

/* 2) Modal no padrão claro (card branco, texto escuro) */
/* ===== Modal – TEMA CLARO (card branco + botão roxo) ===== */
html:not(.dark) .modal-backdrop{
  backdrop-filter: none !important;
  background: rgba(0,0,0,.30) !important; /* dim leve do fundo */
}

html:not(.dark) .modal-card{
  background: #ffffff !important;          /* branco puro */
  background-image: none !important;       /* sem gradiente anterior */
  opacity: 1 !important;                   /* evita qualquer translucidez herdada */
  color: #111827;                          /* texto escuro */
  border: 1px solid #e5e7eb;
  box-shadow: 0 24px 48px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.40);
}

html:not(.dark) .modal-header{
  border-bottom: 1px solid #e5e7eb;        /* divisor visível no claro */
}

html:not(.dark) .modal-body{
  color: #374151;                          /* corpo com contraste confortável */
}

/* Botão OK no mesmo padrão do dark (roxo + leve relevo) */
html:not(.dark) #fz-error-ok.btn{
  color: #fff;
  border-color: var(--primary, #7A5FA7);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--primary, #7A5FA7) 94%, #ffffff) 0%,
    var(--primary, #7A5FA7) 100%
  ) !important;
  box-shadow: 0 10px 26px rgba(122,95,167,.28);
}

html:not(.dark) #fz-error-ok.btn:hover{
  filter: brightness(1.04);
}

html:not(.dark) #fz-error-ok.btn:focus{
  outline: 3px solid color-mix(in srgb, var(--primary,#7A5FA7) 35%, transparent);
  outline-offset: 2px;
}

/* ===== Fix de empilhamento do modal ===== */
.modal-card { position: relative; z-index: 2; }   /* card acima do backdrop */
.modal-backdrop { position: absolute; inset: 0; z-index: 1; }  /* backdrop atrás */

/* ===== Tema claro: card branco e tipografia escura ===== */
html:not(.dark) .modal-card{
  background: #fff !important;           /* branco puro, sem gradiente */
  background-image: none !important;
  color: #111827;
  border: 1px solid #e5e7eb;
  box-shadow: 0 24px 48px rgba(0,0,0,.16), inset 0 1px 0 rgba(255,255,255,.40);
}
html:not(.dark) .modal-header{ border-bottom: 1px solid #e5e7eb; }
html:not(.dark) .modal-body{ color: #374151; }

/* Botão OK com o mesmo padrão roxo do dark */
html:not(.dark) #fz-error-ok.btn{
  color:#fff;
  border-color: var(--primary, #5f0de4);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--primary,#702edb) 94%, #ffffff) 0%,
    var(--primary,#6117d8) 100%) !important;
  box-shadow: 0 10px 26px rgba(123, 95, 167, 0.76);
}
html:not(.dark) #fz-error-ok.btn:hover{ filter: brightness(1.04); }


/* ===== Prosa padrão FlowZenHub (escopado p/ calculadora) ===== */
.card.prose{
  max-width: 1280px;              /* largura de leitura confortável */
  margin-inline: auto;
  line-height: 1.65;
  font-size: clamp(.96rem, .28vw + .9rem, 1.05rem);
  color: var(--text);
}

.card.prose h1,
.card.prose h2,
.card.prose h3{
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0 0 .6rem;
  color: var(--text);
}

.card.prose h1{ font-size: clamp(1.6rem, 1vw + 1.3rem, 2rem); }
.card.prose h2{ font-size: clamp(1.25rem, .8vw + 1.1rem, 1.6rem); margin-top: .5rem; }
.card.prose h3{ font-size: clamp(1.05rem, .45vw + 1rem, 1.25rem); margin-top: 1rem; }

.card.prose p{ margin: 0 0 .75rem; }
.card.prose ul,
.card.prose ol{
  margin: .5rem 0 1rem;
  padding-left: 1.25rem;     /* bullets alinhados */
}
.card.prose li + li{ margin-top: .35rem; }
.card.prose strong{ color: var(--text); }

/* ===== Tabela de comparação – look consistente ===== */
.card.prose .table{
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.card.prose .table th,
.card.prose .table td{
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.card.prose .table thead th{
  text-transform: none;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in oklab, var(--text) 4%, transparent);
}
.card.prose .table tbody tr:nth-child(even){
  background: color-mix(in oklab, var(--text) 3%, transparent);
}

/* ===== Micro-respiros entre cartões textuais ===== */
.card.prose + .card.prose{ margin-top: 18px; }

/* ===== Links em prosa (acessíveis) ===== */
.card.prose a{
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.card.prose a:hover{ filter: brightness(1.06); }

/* ===== Dark/Light já herdam de var(--*) — nada extra necessário */

/* spinner sutil reaproveitando o tema */
.btn[disabled][data-loading]{
  position: relative;
  pointer-events: none;
  opacity: .85;
}
.btn[disabled][data-loading]::after{
  content: '';
  position:absolute; inset-inline-end:10px; top:50%; translate:0 -50%;
  width:14px; height:14px; border-radius:50%;
  border:2px solid color-mix(in srgb, var(--primary) 70%, transparent);
  border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }


/* Fix minimalista para leitura no tema claro */
html[data-theme="light"] .card.prose,
body.light .card.prose {
  color: #1F2133; /* texto principal escuro */
}

html[data-theme="light"] .card.prose h1,
html[data-theme="light"] .card.prose h2,
html[data-theme="light"] .card.prose h3,
body.light .card.prose h1,
body.light .card.prose h2,
body.light .card.prose h3 {
  color: #1F2133; /* títulos idem */
}

html[data-theme="light"] .card.prose strong,
body.light .card.prose strong {
  color: #111827; /* negrito ainda mais forte */
}











/* ============================
   Calculadora — LIGHT OVERRIDES
   (light = html NÃO tem .dark)
   ============================ */

/* Inputs com select acoplado */
html:not(.dark) .input-split{
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
html:not(.dark) .input-split input,
html:not(.dark) .input-split select{
  color: var(--text);
}

/* Selects que estavam “forçando” dark */
html:not(.dark) #periodUnit,
html:not(.dark) #rateUnit,
html:not(.dark) #moeda,
html:not(.dark) .select,
html:not(.dark) .field > select{
  background: var(--card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

/* Botão ghost (secundário) no light */
html:not(.dark) .btn-ghost{
  color: var(--text);
  background: var(--card);
  border: 1px solid color-mix(in oklab, var(--fz-primary) 45%, var(--border));
}
html:not(.dark) .btn-ghost:hover{
  background: color-mix(in oklab, var(--fz-primary) 10%, var(--card));
}

/* KPIs (elevação sutil e blend roxo) */
html:not(.dark) .kpi-card{
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 22px rgba(26,26,54,.06);
}
html:not(.dark) .kpi--primary{
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--fz-primary) 22%, #fff) 0%,
    var(--card) 70%
  );
}
html:not(.dark) .kpi--success .kpi__value{ color:#0f9d6a; }

/* Gráfico e Tabela */
html:not(.dark) .chart-box{
  background: var(--card);
  border: 1px solid var(--border);
}
html:not(.dark) .table thead th{
  background: var(--card);
  color: var(--text);
}
html:not(.dark) .table tbody tr:nth-child(even){
  background: color-mix(in oklab, var(--text) 4%, transparent);
}

/* Ações abaixo da tabela */
html:not(.dark) .actions .btn{ border-color: var(--border); }

/* === Calc: Light-only patch — bloco de valores =================== */
/* Escopado ao form para não vazar para outras páginas */
body.light #calc-form .input-split,
html[data-theme="light"] #calc-form .input-split{
  background: #fff;                 /* contraste no light */
  border: 1px solid #E0E3E8;        /* mesma borda global do light */
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}

/* Texto dentro dos inputs/selects */
body.light #calc-form .input-split input,
body.light #calc-form .input-split select,
html[data-theme="light"] #calc-form .input-split input,
html[data-theme="light"] #calc-form .input-split select{
  color: #3B3F56;                   /* var(--fz-text) no light */
}

/* Neutraliza as regras “força-dark” dos selects no light */
body.light #calc-form #periodUnit,
body.light #calc-form #rateUnit,
body.light #calc-form #moeda,
body.light #calc-form .select,
body.light #calc-form .field > select,
html[data-theme="light"] #calc-form #periodUnit,
html[data-theme="light"] #calc-form #rateUnit,
html[data-theme="light"] #calc-form #moeda,
html[data-theme="light"] #calc-form .select,
html[data-theme="light"] #calc-form .field > select{
  background: #fff !important;
  color: #3B3F56 !important;
  border: 1px solid #E0E3E8 !important;
}

/* Placeholder e foco mais visíveis no light */
body.light #calc-form input::placeholder,
html[data-theme="light"] #calc-form input::placeholder{ color:#6B6F85; } /* var(--fz-text-dim) */

body.light #calc-form .input-split:focus-within,
html[data-theme="light"] #calc-form .input-split:focus-within{
  border-color: rgba(122,95,167,.45);
  box-shadow: 0 0 0 3px rgba(122,95,167,.18);
}

/* === Calc: visibilidade de texto e combo — SOMENTE LIGHT ================== */
body.light #calc-form input,
html[data-theme="light"] #calc-form input{
  color: #3B3F56;               /* texto digitado (tokens do light) */
  -webkit-text-fill-color:#3B3F56; /* WebKit garante preenchimento */
  caret-color:#5b2ea5;          /* cursor visível no light */
}

body.light #calc-form input::placeholder,
html[data-theme="light"] #calc-form input::placeholder{
  color:#6B6F85;                /* placeholder (muted do light) */
  opacity:1;
}

/* Bloco input+select (período e taxa) – fundo/borda claros */
body.light #calc-form .input-split,
html[data-theme="light"] #calc-form .input-split{
  background:#fff;
  border:1px solid #E0E3E8;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}

/* Selects do form (inclui Moeda, Período e Taxa) */
body.light #calc-form select,
html[data-theme="light"] #calc-form select{
  background:#fff !important;
  color:#3B3F56 !important;
  border-color:#E0E3E8 !important;
}

/* Opções do dropdown nativo (lista) — melhora contraste no light */
body.light #calc-form select option,
html[data-theme="light"] #calc-form select option{
  color:#3B3F56;
  background:#fff;
}

/* Foco visível consistente no light */
body.light #calc-form .input-split:focus-within,
html[data-theme="light"] #calc-form .input-split:focus-within{
  border-color: rgba(122,95,167,.45);
  box-shadow: 0 0 0 3px rgba(122,95,167,.18);
}

/* === Resultados (KPIs) — LIGHT ONLY makeover ==================== */
/* Escopo: só a section de resultados, no tema claro */
body.light #results-kpis .kpis{
  gap: 14px;
}

body.light #results-kpis .kpi-card{
  background: #fff;                      /* var(--fz-surface) do light */
  border: 1px solid #E0E3E8;             /* var(--fz-border) do light */
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}

body.light #results-kpis .kpi__label{
  color: #6B6F85;                        /* var(--fz-text-dim) */
  font: 600 12px/1.1 Inter, system-ui;
  letter-spacing: .02em;
}

body.light #results-kpis .kpi__value{
  color: #3B3F56;                        /* var(--fz-text) */
  font: 800 22px/1.2 Inter, system-ui;
  letter-spacing: .2px;
}

/* Destaque do 1º KPI (montante): roxo “glass” suave no light */
body.light #results-kpis .kpi--primary{
  background: linear-gradient(
    180deg,
    rgba(122,95,167,.10) 0%,
    rgba(122,95,167,.02) 100%
  );
  border-color: rgba(122,95,167,.35);    /* mistura com border do light */
}
body.light #results-kpis .kpi--primary .kpi__value{ color:#3B2A8F; }
body.light #results-kpis .kpi--primary .kpi__label{ color: rgba(59,63,86,.75); }

/* “Total em juros” com verde positivo já existente */
body.light #results-kpis .kpi--success .kpi__value{ color:#1aa774; }

/* Micro-interação */
@media (hover:hover){
  body.light #results-kpis .kpi-card:hover{
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0,0,0,.10);
  }
}

/* Tipografia um pouco maior em telas grandes */
@media (min-width: 980px){
  body.light #results-kpis .kpi__value{ font-size: 24px; }
}

/* === CHART (apenas tema claro) === */
html:not(.dark) {
  /* paleta do gráfico */
  --chart-line-total: #7A5FA7;      /* roxo brand (linha “Montante”) */
  --chart-fill-total:  #EAE6F6;     /* fill suave do roxo */
  --chart-line-invest: #7DB7FF;     /* azul leve (linha “Total investido”) */
  --chart-grid:        #E7EAF2;     /* grid/ticks */
  --chart-axis:        #9AA3B2;     /* rótulos dos eixos */
  --chart-tooltip-bg:  #FFFFFF;
  --chart-tooltip-bd:  #E4E7EE;
}

html:not(.dark) .chart-box{
  background: #fff;                 /* harmoniza com os cards */
  border: 1px solid var(--chart-grid);
  box-shadow: 0 6px 24px rgba(26,33,61,.06);
}

/* legenda do Chart.js “no tema” */
html:not(.dark) #growth-chart + .chartjs-size-monitor,
html:not(.dark) .chart-legend { color: var(--fz-text); } /* fallback */

/* Chart – LIGHT: eixos/grades legíveis usando tokens globais */
html:not(.dark){
--chart-axis:  #4A4F68;         /* +contraste */
--chart-grid:  #232527;         /* grid mais escura */
}

/* ===== Ajustes Chart.js para tema claro ===== */
html[data-theme="light"] #growth-chart,
body.light #growth-chart {
  color: #3B3F56 !important;          /* texto principal (eixos, labels) */
}

html[data-theme="light"] #growth-chart .chartjs-render-monitor,
html[data-theme="light"] canvas {
  color: #3B3F56 !important;          /* força herdar texto escuro */
}

/* Ajuste fino para tooltips e legendas */
html[data-theme="light"] .chartjs-tooltip,
html[data-theme="light"] .chart-legend {
  color: #3B3F56 !important;          /* tom do texto */
  background: #fff;                   /* contraste */
  border: 1px solid #E0E3E8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* === Tabela de evolução — LIGHT ONLY =================================== */
html:not(.dark) #results-table .table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid #E0E3E8;
  border-radius: 12px;
  overflow: hidden;                 /* preserva o radius no thead sticky */
  box-shadow: 0 6px 24px rgba(26,33,61,.06);
}

html:not(.dark) #results-table .table thead th {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(#fff, #F7F8FC);
  color: #3B3F56;                   /* texto forte (tokens light) */
  font: 600 12px/1.2 Inter, system-ui;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding: 12px 14px;
  border-bottom: 1px solid #E0E3E8;
}

html:not(.dark) #results-table .table tbody td {
  color: #3B3F56;
  padding: 12px 14px;
  border-bottom: 1px solid #EEF1F6;
}

/* zebra + hover para leitura mais fácil */
html:not(.dark) #results-table .table tbody tr:nth-child(odd) td { background: #FBFCFE; }
html:not(.dark) #results-table .table tbody tr:hover td        { background: #F2F5FF; }

/* alinhar números à direita (Aportes, Juros, Montante) */
html:not(.dark) #results-table .table tbody td:nth-child(n+2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* wrapper com rolagem e “fade” nas bordas para indicar scroll */
html:not(.dark) #results-table .table-scroll {
  position: relative;
  overflow: auto;
  max-height: 420px;
  scrollbar-gutter: stable;
}
html:not(.dark) #results-table .table-scroll::before,
html:not(.dark) #results-table .table-scroll::after {
  content: "";
  position: sticky; top: 0; bottom: 0; width: 16px;
  pointer-events: none;
}
html:not(.dark) #results-table .table-scroll::before {
  left: 0;  background: linear-gradient(90deg, #fff, rgba(255,255,255,0));
}
html:not(.dark) #results-table .table-scroll::after {
  right: 0; background: linear-gradient(-90deg, #fff, rgba(255,255,255,0));
}

/* ações abaixo da tabela */
html:not(.dark) #result-actions{
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px;
}

/* Calculadora – mapeia tokens globais para variáveis locais (SOMENTE LIGHT) */
html:not(.dark) #calc-page{
  --text:   var(--fz-text);       /* cor de texto principal */
  --muted:  var(--fz-text-dim);   /* textos secundários */
  --card:   var(--fz-surface);    /* fundo do card */
  --border: var(--fz-border);     /* bordas */
  --primary:#7A5FA7;              /* roxo do projeto */
}

