/* ====================================================
   FINANÇAS — Design System
   Inspirado em Actual Budget + Monarch Money
   ==================================================== */

:root {
  --sidebar-bg: #111827;
  --sidebar-text: rgba(255,255,255,0.55);
  --sidebar-text-strong: rgba(255,255,255,0.9);
  --sidebar-active-bg: rgba(34,197,94,0.15);
  --sidebar-active-text: #4ade80;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-border: rgba(255,255,255,0.07);
  --sidebar-w: 240px;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);

  --green: #16a34a;
  --green-bg: #dcfce7;
  --green-text: #15803d;
  --yellow: #d97706;
  --yellow-bg: #fef3c7;
  --yellow-text: #92400e;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --red-text: #991b1b;
  --vermelho: #dc2626; /* alias para compatibilidade com renderer.js */

  --accent: #22c55e;
  --accent-dark: #15803d;
  --accent-bg: rgba(34,197,94,0.1);

  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.08);

  --font-display: 'Poppins', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
  --suave: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: 28px;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@keyframes entrar {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes escala {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---- Tela de abertura ---- */

.tela-abertura {
  position: fixed; inset: 0;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s var(--suave);
}

.tela-abertura.saindo { opacity: 0; pointer-events: none; }

.abertura-conteudo {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: entrar 0.5s var(--suave);
}

.abertura-orbe {
  position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34,197,94,0.15) 0%, transparent 70%);
  filter: blur(40px); pointer-events: none;
}

.abertura-icones {
  display: flex; align-items: center; gap: 18px; margin-bottom: 8px;
}

.abertura-icone {
  font-size: 22px; opacity: 0;
  animation: entrar 0.4s var(--suave) forwards;
}

.abertura-logo-wrap {
  position: relative; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
}

.abertura-anel {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(34,197,94,0.5);
  animation: spin 3s linear infinite;
}

.abertura-anel-atraso { animation-delay: -1.5s; opacity: 0.4; }

@keyframes spin { to { transform: rotate(360deg); } }

.abertura-logo {
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  color: #4ade80; z-index: 1; opacity: 0;
  animation: entrar 0.4s var(--suave) 0.3s forwards;
}

.abertura-titulo {
  font-family: var(--font-display); font-size: 32px; font-weight: 800;
  color: white; margin: 0; letter-spacing: -0.5px;
}

.abertura-titulo span {
  display: inline-block; opacity: 0;
  animation: entrar 0.35s var(--suave) forwards;
}

.abertura-logo-principal {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--font-display); font-size: 42px; font-weight: 800;
  color: white; letter-spacing: -1px;
  animation: entrar 0.5s var(--suave) 0.2s both;
}

.abertura-logo-principal svg {
  width: 46px; height: 46px; margin: 0 2px;
}

.abertura-subtitulo {
  font-size: 13px; color: var(--sidebar-text); margin: 0;
  animation: entrar 0.4s var(--suave) 0.6s both;
}

.abertura-barra {
  width: 180px; height: 3px; background: rgba(255,255,255,0.1);
  border-radius: 99px; overflow: hidden; margin-top: 4px;
  animation: entrar 0.4s var(--suave) 1.2s both;
}

.abertura-barra-preenchimento {
  height: 100%; width: 0%; background: var(--accent);
  border-radius: 99px;
  animation: preencher 3.2s var(--suave) 1.3s forwards;
}

@keyframes preencher {
  0%   { width: 0%; }
  60%  { width: 80%; }
  100% { width: 100%; }
}

/* ---- Layout ---- */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  text-align: center;
}

.sidebar-brand-word {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
  color: white; letter-spacing: -0.3px;
}

.sidebar-brand-word svg {
  width: 22px; height: 22px; margin: 0 1px;
}

.sidebar-brand-word svg rect { fill: rgba(255,255,255,0.5); }
.sidebar-brand-word svg rect:last-child { fill: var(--accent); }

.sidebar-brand-sub {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--sidebar-text); margin-top: 3px;
}

.sidebar-nav {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}

.aba-btn {
  all: unset;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; color: var(--sidebar-text);
  cursor: pointer; transition: background 0.15s, color 0.15s;
  width: 100%;
}

.aba-btn svg {
  width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7;
  stroke: currentColor;
}

.aba-btn:hover {
  background: var(--sidebar-hover); color: var(--sidebar-text-strong);
}

.aba-btn.ativa {
  background: var(--sidebar-active-bg); color: var(--sidebar-active-text);
  font-weight: 600;
}

.aba-btn.ativa svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  font-size: 11px; color: var(--sidebar-text);
  border-top: 1px solid var(--sidebar-border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}

.sidebar-footer a {
  color: var(--sidebar-text); opacity: 0.75; text-decoration: none;
}
.sidebar-footer a:hover { opacity: 1; text-decoration: underline; }

.badge-nav {
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; margin-left: 6px;
}

.status-cenario {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}
.status-pendente { background: rgba(234,179,8,0.15); color: #a16207; }
.status-aprovado { background: rgba(34,197,94,0.15); color: #15803d; }
.status-rejeitado { background: rgba(239,68,68,0.15); color: #b91c1c; }

#cenPreview .erro {
  background: var(--red-bg); color: var(--red-text);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px;
}
#cenPreview table { font-size: 13px; width: 100%; }
#cenPreview .linha-alerta-negativo td { background: var(--red-bg); color: var(--red-text); }
#cenPreview .cor-vermelho { color: var(--red); font-weight: 600; }

.cenarios-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}
.cenarios-form { margin-bottom: 0; }
.cenarios-preview { margin-bottom: 0; min-height: 260px; }

.cenarios-historico {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.cenarios-historico .custo-card { max-width: none; margin-bottom: 0; }

@media (max-width: 900px) {
  .cenarios-grid { grid-template-columns: 1fr; }
}

/* ---- Mobile nav ---- */

.sidebar-mobile {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--sidebar-bg); border-top: 1px solid var(--sidebar-border);
  padding: 6px 8px; gap: 4px;
  z-index: 100;
}

.sidebar-mobile .aba-btn {
  flex: 1; flex-direction: column; gap: 3px;
  padding: 8px 4px; font-size: 10px; text-align: center;
  border-radius: var(--radius-xs);
}

.sidebar-mobile .aba-btn svg { width: 18px; height: 18px; }

/* ---- Main content ---- */

main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg);
}

/* ---- Seção / aba ---- */

.aba-conteudo {
  padding: 0;
  animation: entrar 0.3s var(--suave);
}

.aba-conteudo[hidden] { display: none; }

/* ---- Page header ---- */

.page-header {
  display: flex; align-items: center; gap: 16px;
  padding: 24px var(--pad) 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.page-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
  color: var(--text); margin: 0; flex: 1;
  display: flex; align-items: center; gap: 8px;
}

.page-title-sub {
  font-size: 14px; font-weight: 500; color: var(--text-muted);
}

.page-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ---- Content area ---- */

.content-area {
  padding: 20px var(--pad) var(--pad);
}

.content-row {
  display: grid;
  gap: 16px;
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  margin: 0 0 12px;
}

/* ---- Compatibility: cartao → card alias ---- */

.cartao {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin: 0;
  max-width: none;
  break-inside: avoid;
}

.cartao h2 {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  margin: 0 0 12px; color: var(--text);
}

.cartao-larga { max-width: none; }

/* ---- Dashboard: grade de resumo ---- */

.grade-resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.item-resumo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  animation: entrar 0.3s var(--suave) backwards;
}

.item-resumo .rotulo {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px;
}

.item-resumo .valor {
  font-size: 24px; font-weight: 700; color: var(--text);
  font-family: var(--font-display); letter-spacing: -0.5px;
}

.item-resumo .valor.destaque {
  color: var(--green);
}

/* ---- Chips (seletores de ano/mês) ---- */

.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 16px;
}

.chip {
  all: unset; cursor: pointer;
  padding: 5px 14px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); transition: all 0.15s;
}

.chip:hover { border-color: var(--border-strong); color: var(--text); }

.chip.ativo {
  background: var(--accent); border-color: var(--accent);
  color: white; font-weight: 600;
}

/* ---- Sub-navegação ---- */

.sub-nav {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 20px var(--pad) 0;
}

.sub-btn {
  all: unset; cursor: pointer;
  padding: 6px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  transition: all 0.15s;
}

.sub-btn:hover { color: var(--text); border-color: var(--border-strong); }

.sub-btn.ativa {
  background: var(--accent); color: white;
  border-color: var(--accent); font-weight: 600;
}

.sub-secao { padding: 16px var(--pad) var(--pad); }
.sub-secao[hidden] { display: none; }
.sub-secao:not([hidden]) { animation: entrar 0.25s var(--suave); }

/* ---- Botões globais ---- */

button, input, select, textarea { font-family: var(--font-body); }

button {
  all: unset; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  background: var(--accent); color: white;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

button:hover { background: var(--accent-dark); }
button:active { transform: scale(0.98); }

button.secundario {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}

button.secundario:hover { border-color: var(--border-strong); background: var(--surface-2); }

button.perigo {
  background: var(--red); color: white;
}

button.perigo:hover { background: #b91c1c; }

button:disabled { opacity: 0.4; pointer-events: none; }

.botoes {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 14px;
}

/* ---- Inputs ---- */

input[type="text"], input[type="number"], input[type="date"],
select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13.5px; color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.12);
}

textarea { min-height: 72px; resize: vertical; }

input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---- Texto auxiliar ---- */

.texto-fraco { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.rotulo-inline { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox-inline input { width: auto; }

/* ---- Status global ---- */

#status-global {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white;
  padding: 10px 20px; border-radius: 99px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  transform: translateX(-50%) translateY(8px);
  z-index: 200;
}

#status-global.visivel {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

#status-global.erro { background: var(--red); }

/* (Compat: status inside resumo — hide it) */
#status { font-size: 12px; color: var(--text-muted); margin-top: 8px; min-height: 16px; }

/* ---- Linha editável ---- */

.linha-editavel {
  display: flex; gap: 8px; align-items: flex-start;
  flex-wrap: wrap;
}

.linha-editavel input[type="text"] { flex: 2; min-width: 120px; }
.linha-editavel input[type="number"] { flex: 1; min-width: 90px; }
.linha-editavel select { flex: 1; min-width: 110px; }
.linha-editavel input[type="date"] { flex: 1; min-width: 130px; }

.linha-parcelamento, .linha-calculadora, .linha-inicio-vigencia {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding: 8px 10px;
  background: var(--surface-2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.linha-parcelamento input, .linha-parcelamento select { width: auto; flex: 0 0 auto; }
.linha-parcelamento input[type="number"] { width: 70px; }

.texto-fim { font-size: 12px; color: var(--text-muted); }

/* ---- Item genérico (receitas, etc.) ---- */

.item-despesa-fixa {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.btn-remover {
  background: none; color: var(--red);
  border: 1px solid rgba(220,38,38,0.25);
  border-radius: var(--radius-xs);
  padding: 5px 10px; font-size: 12px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-remover:hover { background: var(--red-bg); }

/* ---- Receitas grid ---- */

#listaReceitas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px; align-items: start;
}

/* ---- Custo de vida — grid de cards ---- */

#listaCustoVida {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px; align-items: start;
}

.custo-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.custo-card:hover { border-color: var(--border-strong); }

.custo-card-del {
  position: absolute; top: 8px; right: 10px;
  all: unset; cursor: pointer;
  font-size: 18px; line-height: 1; color: var(--text-muted);
  opacity: 0; transition: opacity 0.15s, color 0.15s; padding: 0 2px;
}

.custo-card:hover .custo-card-del { opacity: 1; }
.custo-card-del:hover { color: var(--red); }

.custo-card-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px;
}

.custo-input-cat {
  width: 100%; font-size: 14px; font-weight: 600; color: var(--text);
  background: none; border: none; border-bottom: 1px solid var(--border);
  border-radius: 0; padding: 2px 0 4px; outline: none;
}

.custo-input-cat:focus { border-bottom-color: var(--accent); }

.custo-valor-wrap {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 10px; margin-top: 8px;
}

.custo-cifrao { font-size: 11px; color: var(--text-muted); font-weight: 500; flex-shrink: 0; }

.custo-input-meta {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  font-size: 15px; font-weight: 700; color: var(--green-text);
  text-align: right;
}

/* ---- Despesas fixas ---- */

#gruposDespesas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px; align-items: start;
}

.grupo-despesa {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}

/* compat: renderer.js usa desp-grupo-* */
.grupo-header, .desp-grupo-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}

.grupo-nome, .desp-grupo-nome {
  flex: 1; font-size: 12px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
}

.grupo-acoes, .desp-grupo-acoes { display: flex; gap: 4px; }

.grupo-btn, .btn-item-pequeno {
  all: unset; cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted);
  transition: all 0.15s;
}

.grupo-btn:hover, .btn-item-pequeno:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-bg); }
.grupo-btn.perigo:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.btn-rem-grupo:hover { border-color: var(--red) !important; color: var(--red) !important; background: var(--red-bg) !important; }

.desp-bloco { border-bottom: 1px solid var(--border); }
.desp-bloco:last-child { border-bottom: none; }

.desp-linha {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; transition: background 0.12s;
}

.desp-linha:hover { background: var(--surface-2); }
.desp-linha.desp-linha-aberta { background: var(--surface-2); }

.desp-nome {
  flex: 1; font-size: 13px; color: var(--text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.desp-valor {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; flex-shrink: 0;
}

.desp-badge-wrap { display: flex; }

.desp-badge {
  font-size: 10.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; white-space: nowrap;
}

.desp-badge-fixo {
  background: var(--green-bg); color: var(--green-text);
}

.desp-badge-parc {
  background: var(--yellow-bg); color: var(--yellow-text);
}

.desp-acoes { display: flex; gap: 2px; }

.desp-btn-edit, .desp-btn-del {
  all: unset; cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs); color: var(--text-muted);
  transition: all 0.12s;
}

.desp-btn-edit svg, .desp-btn-del svg { width: 14px; height: 14px; }

.desp-btn-edit:hover { background: var(--accent-bg); color: var(--accent-dark); }
.desp-btn-del:hover { background: var(--red-bg); color: var(--red); }

.desp-form {
  padding: 12px 14px; background: var(--surface-2);
  border-top: 1px solid var(--border);
  animation: entrar 0.2s var(--suave);
}

.desp-form[hidden] { display: none; }

.desp-form-grade {
  display: flex; gap: 10px; flex-wrap: wrap;
}

.desp-form-campo {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; min-width: 120px;
}

.desp-form-campo label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
}

.desp-form-sep {
  width: 100%; height: 1px; background: var(--border); margin: 8px 0;
}

.desp-vazio {
  padding: 16px 14px; font-size: 13px; color: var(--text-muted);
  font-style: italic; margin: 0;
}

/* ---- Controle do Mês ---- */

.mes-selector {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 16px var(--pad) 0;
}

.grade-categorias-mes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.categoria-mes-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: default;
  transition: border-color 0.15s;
}

.categoria-mes-card:hover { border-color: var(--border-strong); }

.nome-categoria-mes {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}

.restante-mes {
  font-size: 26px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: -0.5px;
  margin-bottom: 10px; line-height: 1;
}

.restante-mes.cor-verde { color: var(--green); }
.restante-mes.cor-amarelo { color: var(--yellow); }
.restante-mes.cor-vermelho { color: var(--red); }

.barra-progresso {
  height: 6px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden;
  margin-bottom: 10px; border: 1px solid var(--border);
}

.preenchimento {
  height: 100%; border-radius: 99px;
  transition: width 0.4s var(--suave);
}

.preenchimento.cor-verde { background: var(--accent); }
.preenchimento.cor-amarelo { background: var(--yellow); }
.preenchimento.cor-vermelho { background: var(--red); }

.linha-valores-mes {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-muted); padding: 2px 0;
}

.linha-valores-mes strong { color: var(--text); font-weight: 600; }

/* ---- Tabelas ---- */

.tabela-scroll { overflow-x: auto; border-radius: var(--radius-sm); }

table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}

thead th {
  padding: 10px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap; position: sticky; top: 0;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

.linha-secao td {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
  background: var(--bg); padding: 8px 12px;
}

.linha-subgrupo td {
  font-weight: 600; color: var(--text-muted); font-size: 12px;
  padding-left: 20px;
}

.linha-item td:first-child { padding-left: 24px; }

.linha-destaque td {
  font-weight: 700; color: var(--text);
  background: rgba(34,197,94,0.04);
}

.celula-total {
  font-weight: 700; text-align: right;
  border-left: 1px solid var(--border);
}

/* Tabela de gastos */

.tabela-gastos td:last-child { text-align: right; }
.tabela-aportes td:last-child { text-align: right; }

.valor-positivo { color: var(--green); font-weight: 600; }

/* ---- Investimentos / Reserva ---- */

.valor-acumulado {
  font-size: 42px; font-weight: 800;
  font-family: var(--font-display); color: var(--green);
  letter-spacing: -1px; margin: 8px 0 16px; line-height: 1;
}

.linha-meta {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 12px;
}

.linha-meta span { font-size: 13px; color: var(--text-muted); }
.linha-meta input { width: 140px; flex: 0 0 auto; }

.form-aporte {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px; background: var(--surface-2);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  margin-top: 10px;
}

.form-aporte input { flex: 1; min-width: 120px; }

/* ---- FAB — botão flutuante de adicionar ---- */

.fab {
  position: fixed; bottom: 28px; right: 28px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent);
  color: white; font-size: 26px; font-weight: 300; line-height: 1;
  box-shadow: var(--shadow-lg);
  z-index: 150; padding: 0;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  border: none;
}

.fab:hover {
  background: var(--accent-dark);
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(34,197,94,0.35);
}

/* ---- Overlays e modais ---- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  animation: fadeIn 0.15s;
}

.overlay[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-prompt {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: escala 0.2s var(--suave);
}

.modal-prompt p {
  font-size: 15px; line-height: 1.5; margin: 0 0 16px;
}

.modal-prompt input {
  margin-bottom: 16px;
}

/* Modal de gasto rápido */

.modal-gasto {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: escala 0.2s var(--suave);
  overflow: hidden;
}

.modal-gasto-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-gasto-header h2 {
  margin: 0; font-size: 16px; font-weight: 700;
  font-family: var(--font-display);
}

.modal-fechar {
  all: unset; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--text-muted);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs); transition: background 0.12s;
}

.modal-fechar:hover { background: var(--border); }

.modal-gasto-corpo {
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 14px;
}

.modal-campo {
  display: flex; flex-direction: column; gap: 5px;
}

.modal-campo label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
}

.modal-campo input, .modal-campo select { width: 100%; }

.modal-campo-valor input {
  font-size: 28px; font-weight: 700;
  color: var(--green); padding: 10px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  text-align: right; letter-spacing: -0.5px;
}

.modal-campo-valor input:focus { border-color: var(--accent); }

.modal-gasto-rodape {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ---- Menu de contexto ---- */

.menu-contexto {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden; z-index: 600; min-width: 180px;
  animation: escala 0.15s var(--suave);
}

.menu-contexto[hidden] { display: none; }

.menu-contexto button {
  all: unset; cursor: pointer;
  display: block; width: 100%;
  padding: 10px 14px; font-size: 13px; color: var(--text);
  transition: background 0.1s;
}

.menu-contexto button:hover { background: var(--surface-2); }
.menu-contexto button.item-perigo { color: var(--red); }
.menu-contexto button.item-perigo:hover { background: var(--red-bg); }
.menu-contexto button:disabled { opacity: 0.4; pointer-events: none; }

/* ---- Anos: vigência ---- */

#aba-estrutura .sub-secao > .cartao,
#aba-orcamento .cartao,
#aba-controle .cartao,
#aba-investimentos .cartao {
  max-width: none;
}

/* ---- Controle do Mês: layout interno ---- */

.controle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ---- Orçamento: seção ---- */

#aba-orcamento .tabela-scroll {
  max-height: calc(100vh - 250px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ---- Drag & Drop (SortableJS) ---- */

.drag-handle {
  cursor: grab; color: var(--text-light);
  flex-shrink: 0; display: flex; align-items: center;
  padding: 0 4px; opacity: 0.5; transition: opacity 0.15s;
  user-select: none;
}

.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 14px; height: 14px; }

.grupo-despesa:hover .drag-handle,
.custo-card:hover .drag-handle,
.item-despesa-fixa:hover .drag-handle { opacity: 1; }

.sortable-ghost {
  opacity: 0.35;
  border: 2px dashed var(--accent) !important;
  border-radius: var(--radius) !important;
}

.sortable-chosen {
  box-shadow: var(--shadow-lg) !important;
  transform: scale(1.01);
  z-index: 10;
}

.sortable-drag { opacity: 1; }

/* ---- Print / PDF ---- */

@media print {
  .sidebar, .sidebar-mobile, .fab, .overlay, #telaAbertura,
  .page-actions, .chips, .botoes, .btn-remover, .btn-remover-gasto,
  .desp-acoes, .modal-gasto, #status-global, .drag-handle { display: none !important; }

  body { background: white; font-size: 12px; }
  .app-layout { display: block; margin: 0; }
  main { margin-left: 0 !important; padding: 0 !important; overflow: visible; }
  .aba-conteudo { display: block !important; }
  .aba-conteudo[hidden] { display: none !important; }
  .page-header { padding: 12px 0 8px; border-bottom: 2px solid #000; margin-bottom: 16px; }
  .content-area { padding: 0; }
  .grade-resumo { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .item-resumo { padding: 10px 12px; border: 1px solid #ddd; page-break-inside: avoid; }
  .categoria-mes-card { page-break-inside: avoid; }
  #dashboard-graficos { display: none !important; }
  .tabela-scroll { overflow: visible; max-height: none !important; }
  table { font-size: 10px; }
  thead th, tbody td { padding: 5px 8px; }
}

/* ---- Responsivo ---- */

@media (max-width: 768px) {
  :root { --pad: 16px; --sidebar-w: 0px; }
  .sidebar { display: none; }
  .sidebar-mobile { display: flex; }
  main { margin-left: 0; padding-bottom: 70px; }
  .grade-resumo { grid-template-columns: 1fr 1fr; }
  .item-resumo .valor { font-size: 20px; }
  .grade-categorias-mes { grid-template-columns: 1fr; }
  #gruposDespesas { grid-template-columns: 1fr; }
  #listaCustoVida { grid-template-columns: 1fr 1fr; }
  #listaReceitas { grid-template-columns: 1fr; }
  .fab { bottom: 80px; }
}
