/* =====================================================================
   Odisseia (produto FinSystem) — tema "Razão Financeira"
   Paleta: grafite/azul-noite profundo + dourado de razão contábil +
   verde esmeralda (positivo) / laranja-queimado (alerta).
   Tipografia: Fraunces (display, serifado, peso editorial) + Inter (UI)
   + JetBrains Mono (números — alinhamento tabular de verdade).
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: #0B1220;
  --bg-alt: #0E1626;
  --surface: #121B2E;
  --surface-2: #17233A;
  --surface-border: #223154;
  --text: #EAF0FA;
  --text-muted: #8DA0BF;
  --text-faint: #5C6E8C;

  --gold: #D4AF37;
  --gold-soft: rgba(212, 175, 55, .14);
  --emerald: #34C29A;
  --emerald-soft: rgba(52, 194, 154, .14);
  --burnt: #E4572E;
  --burnt-soft: rgba(228, 87, 46, .14);
  --amber: #E8B33D;
  --amber-soft: rgba(232, 179, 61, .16);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 30px -12px rgba(0,0,0,.55);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(212,175,55,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(52,194,154,.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-soft); color: var(--text); }

/* ---------- Cabeçalho ledger + menu hambúrguer ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, var(--bg-alt) 0%, rgba(14,22,38,.88) 100%);
  border-bottom: 1px solid var(--surface-border);
  backdrop-filter: blur(10px);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.hamburger {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--surface-border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; transition: border-color .15s ease, transform .15s ease;
}
.hamburger:hover { border-color: var(--gold); }
.hamburger span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

.brand { display: flex; flex-direction: column; line-height: 1; }
.brand-mark { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: .2px; }
.brand-mark em { font-style: normal; color: var(--gold); }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }

.period-picker { display: flex; align-items: center; gap: 8px; }
.period-picker select {
  background: var(--surface); color: var(--text); border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm); padding: 9px 12px; font-family: var(--font-mono); font-size: 13px;
  cursor: pointer;
}

/* ---------- Menu lateral (drawer) ---------- */

.drawer-overlay {
  position: fixed; inset: 0; background: rgba(4,8,16,.6);
  opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 45;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: var(--bg-alt); border-right: 1px solid var(--surface-border);
  transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 46; padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
}
.drawer.open { transform: translateX(0); }

.drawer-title { font-family: var(--font-display); font-size: 19px; padding: 6px 10px 18px; color: var(--gold); }

.drawer-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; cursor: pointer; font-size: 14.5px; font-weight: 500;
  border: 1px solid transparent;
}
.drawer-link:hover { background: var(--surface); color: var(--text); }
.drawer-link.active { background: var(--surface-2); color: var(--text); border-color: var(--surface-border); }
.drawer-link .ico { width: 18px; text-align: center; opacity: .85; }
.drawer-separador { height: 1px; background: var(--surface-border); margin: 12px 4px; }
.drawer-sair { color: var(--burnt); }
.drawer-sair:hover { background: rgba(228,87,46,.10); color: var(--burnt); }

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

.page { max-width: 1240px; margin: 0 auto; padding: 26px 22px 80px; }
.view { display: none; }
.view.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.view-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.view-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; }
.view-desc { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

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

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 980px) { .grid-4, .grid-3, .grid-5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2, .grid-5 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--surface-border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 8px; }
.card-value { font-family: var(--font-mono); font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.card-value.positive { color: var(--emerald); }
.card-value.negative { color: var(--burnt); }
.card-value.gold { color: var(--gold); }
.card-foot { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.card-lg { padding: 22px 24px; }

/* ---------- Formulário do mês (entrada salarial) ---------- */

.month-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .month-form { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .month-form { grid-template-columns: 1fr; } }

.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; letter-spacing: .02em; }
.field input, .field select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--surface-border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 12px; font-family: var(--font-mono); font-size: 14px;
  transition: border-color .15s ease;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.field.extra-mes { display: none; }
.field.extra-mes.show { display: block; }

/* ---------- Emergência / Investimento toggles ---------- */

.toggle-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.toggle-label { font-size: 12.5px; color: var(--text-muted); margin-right: 4px; }
.pct-btn {
  background: var(--surface-2); border: 1px solid var(--surface-border); color: var(--text-muted);
  border-radius: 20px; padding: 7px 14px; font-family: var(--font-mono); font-size: 13px; cursor: pointer;
  transition: all .15s ease;
}
.pct-btn:hover { border-color: var(--gold); color: var(--text); }
.pct-btn.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); font-weight: 700; }

.confirm-toggle {
  background: var(--surface-2); border: 1px solid var(--surface-border); border-radius: 20px;
  padding: 7px 16px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  font-family: var(--font-body); transition: all .15s ease; white-space: nowrap;
}
.confirm-toggle:hover { border-color: var(--gold); color: var(--text); }
.confirm-toggle.on { background: var(--emerald-soft); border-color: var(--emerald); color: var(--emerald); }
.confirm-toggle-inline { display: block; width: 100%; margin-top: 8px; text-align: center; }

.resgate-btn {
  margin-top: 14px; width: 100%; padding: 12px; border-radius: var(--radius-sm);
  background: transparent; border: 1px dashed var(--surface-border); color: var(--text-muted);
  font-size: 13px; cursor: pointer; transition: all .15s ease;
}
.resgate-btn:hover { border-color: var(--gold); color: var(--gold); }
.resgate-btn.on { border-style: solid; border-color: var(--emerald); color: var(--emerald); background: var(--emerald-soft); }

/* ---------- Tabela de despesas ---------- */

.table-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; flex-wrap: wrap; gap: 10px; }
.btn {
  background: var(--gold); color: #1A1405; border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; font-weight: 700; font-size: 13.5px; cursor: pointer; transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--surface-border); }
.btn.small { padding: 8px 12px; font-size: 12.5px; }

/* ---------- Meta de previdência ---------- */
.meta-barra-track { width: 90px; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; }
.meta-barra-fill { height: 100%; background: var(--emerald); border-radius: 4px; }
.tabs-mini { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.tab-mini-btn { background: transparent; border: none; color: var(--text-muted); font-family: var(--font-body); font-size: 11.5px; font-weight: 600; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.tab-mini-btn.active { background: var(--gold); color: #1A1405; }
.meta-pct { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); margin-left: 6px; }
.sim-resultado {
  background: var(--surface-2); border: 1px solid var(--surface-border); border-radius: 10px;
  padding: 14px 18px; margin-top: 8px; font-size: 13px; line-height: 1.6;
}
.sim-resultado b { color: var(--gold); }
.sim-aviso { font-size: 11px; color: var(--text-faint); margin-top: 8px; }

.despesas-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.despesas-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--surface-border);
}
.despesas-table td { padding: 12px; border-bottom: 1px solid rgba(34,49,84,.5); }
.despesas-table tr:hover td { background: rgba(255,255,255,.015); }

.tipo-pill {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
  letter-spacing: .02em;
}
.tipo-Fixa { background: rgba(107,140,255,.15); color: #93AAFF; }
.tipo-SemiFixa { background: rgba(163,120,255,.15); color: #C3A6FF; }
.tipo-Flex { background: var(--amber-soft); color: var(--amber); }
.tipo-Extra { background: rgba(255,255,255,.08); color: var(--text-muted); }

.valor-cell { font-family: var(--font-mono); cursor: pointer; border-radius: 6px; padding: 6px 10px !important; transition: background .12s ease; }
.valor-cell.status-0 { background: var(--amber-soft); color: var(--amber); }
.valor-cell.status-1 { background: var(--emerald-soft); color: var(--emerald); }
.valor-cell.status-2 { background: var(--burnt-soft); color: var(--burnt); }
.valor-cell:hover { filter: brightness(1.15); }

.status-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.status-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.p0 { background: var(--amber); } .dot.p1 { background: var(--emerald); } .dot.p2 { background: var(--burnt); }

.excluir-btn { color: var(--text-faint); cursor: pointer; font-size: 15px; }
.excluir-btn:hover { color: var(--burnt); }

/* ---------- Resumo do mês (rodapé da tabela) ---------- */

.resumo-mes {
  margin-top: 20px; display: flex; justify-content: flex-end; gap: 34px; flex-wrap: wrap;
  border-top: 1px solid var(--surface-border); padding-top: 18px;
}
.resumo-item { text-align: right; }
.resumo-item .label { font-size: 11.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.resumo-item .value { font-family: var(--font-mono); font-size: 19px; font-weight: 700; margin-top: 3px; }

/* ---------- Insights ---------- */

.insight-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.insight-list li {
  background: var(--surface-2); border: 1px solid var(--surface-border); border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 13.5px; color: var(--text-muted); line-height: 1.5;
}
.insight-list li::before { content: "→ "; color: var(--gold); font-weight: 700; }

/* ---------- Cards inteligentes (insights mensais) ---------- */

.insight-card {
  background: var(--surface-2); border: 1px solid var(--surface-border); border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.insight-card.positivo { border-left-color: var(--emerald); }
.insight-card.atencao { border-left-color: var(--amber); }
.insight-card.alerta { border-left-color: var(--burnt); }
.insight-card.info { border-left-color: var(--gold); }
.insight-card .insight-titulo {
  font-size: 13px; font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; gap: 6px;
}
.insight-card.positivo .insight-titulo { color: var(--emerald); }
.insight-card.atencao .insight-titulo { color: var(--amber); }
.insight-card.alerta .insight-titulo { color: var(--burnt); }
.insight-card.info .insight-titulo { color: var(--gold); }
.insight-card .insight-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

/* ---------- Gráficos ---------- */

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }

/* ---------- Mercado / conversor ---------- */

.market-card { display: flex; align-items: center; justify-content: space-between; }
.market-sym { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }
.market-name { font-size: 11.5px; color: var(--text-faint); }
.market-price { font-family: var(--font-mono); font-size: 18px; font-weight: 700; text-align: right; }
.market-change { font-size: 12px; text-align: right; margin-top: 2px; }
.market-change.up { color: var(--emerald); }
.market-change.down { color: var(--burnt); }

.converter-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.converter-row .field { flex: 1; min-width: 140px; }
.swap-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--surface-border); color: var(--gold); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.converter-result { margin-top: 16px; font-family: var(--font-mono); font-size: 30px; font-weight: 700; color: var(--gold); }
.converter-rate { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Indicadores técnicos — deliberadamente neutros, sem verde/vermelho de compra/venda ---------- */

.indicadores-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 900px) { .indicadores-grid { grid-template-columns: repeat(2, 1fr); } }
.indicador-item {
  background: var(--surface-2); border: 1px solid var(--surface-border); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.indicador-item .rotulo { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: 6px; }
.indicador-item .valor { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--text); }
.leitura-tecnica {
  background: rgba(107,140,255,.12); border: 1px solid rgba(107,140,255,.35); color: #93AAFF;
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; margin-bottom: 12px;
}
.aviso-tecnico {
  font-size: 11.5px; color: var(--text-faint); border-top: 1px solid var(--surface-border);
  padding-top: 12px; margin-top: 4px; line-height: 1.5;
}

/* ---------- Alerta visível — pra erro/aviso que precisa ser NOTADO, não passar despercebido ---------- */
.alerta-box {
  background: var(--amber-soft); border: 1px solid var(--amber); border-radius: 10px;
  padding: 12px 16px; margin: 12px 0; font-size: 12.5px; color: var(--text); line-height: 1.55;
}
.alerta-box strong { color: var(--amber); }
.alerta-box.erro { background: var(--burnt-soft); border-color: var(--burnt); }
.alerta-box.erro strong { color: var(--burnt); }

/* ---------- Modal nova despesa ---------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,8,16,.65); display: none;
  align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.modal h3 { font-family: var(--font-display); margin: 0 0 16px; font-size: 20px; }
.modal .field { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

.status-toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--surface-2); border: 1px solid var(--emerald);
  color: var(--emerald); padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 80;
}
.status-toast.show { transform: translateY(0); opacity: 1; }

.text-faint { color: var(--text-faint); font-size: 12.5px; }
