/* =====================================================================
   Nidus — Finanças do casal
   Paleta: verde-pinho #123D2E + verde-folha #1E7A4F + dourado #C9A227
   ===================================================================== */
:root {
  --ink:        #14261F;   /* texto principal */
  --pine:       #123D2E;   /* sidebar / marca */
  --pine-deep:  #0B2A1F;
  --paper:      #F5F4EF;   /* fundo do conteúdo */
  --card:       #FFFFFF;
  --line:       #E3E1D8;
  --muted:      #6C7A72;
  --gold:       #C9A227;   /* progresso / assinatura visual */
  --green:      #1E7A4F;   /* receitas / ok */
  --red:        #B23A3A;   /* despesas / alerta */
  --amber:      #B07A17;   /* atenção */
  --radius:     12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, .brand { font-family: 'Sora', system-ui, sans-serif; }
h1 { font-size: 1.5rem; margin: 0 0 .2rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
a { color: var(--pine); }
small { font-size: .8em; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Shell ---------- */
/* Mobile-first: começa sem sidebar */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--pine), var(--pine-deep));
  color: #EAF2ED;
  padding: 1.4rem 1rem;
  display: none;          /* oculto por padrão (mobile) */
  flex-direction: column; gap: 1.6rem;
}
/* Desktop: ativa a sidebar e o grid de 2 colunas */
@media (min-width: 901px) {
  .shell { grid-template-columns: 220px 1fr; }
  .side  { display: flex; }
}
/* Logo na sidebar */
.side-logo { display: block; text-decoration: none; padding: .2rem 0 .4rem; }
.side-logo img { width: 110px; height: auto; display: block; }

/* Logo nas telas de auth */
.auth-logo { display: flex; justify-content: center; margin-bottom: .6rem; }
.auth-logo img { width: 140px; height: auto; }
.side nav { display: flex; flex-direction: column; gap: .2rem; }
.side nav a {
  color: #C9D8CF; text-decoration: none; padding: .5rem .7rem;
  border-radius: 8px; font-weight: 500;
}
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.side-foot { margin-top: auto; font-size: .85rem; }
.who { margin-bottom: .3rem; color: #C9D8CF; }

.content { padding: 2rem 2.2rem 3rem; max-width: 1060px; }
.page-head { margin-bottom: 1.4rem; display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: baseline; justify-content: space-between; }
.page-head p { margin: 0; flex-basis: 100%; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1.2rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.2rem; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grid-2 .card { margin-bottom: 1.2rem; }

.kpi { display: flex; flex-direction: column; gap: .15rem; }
.kpi-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi-value { font-family: 'Sora', sans-serif; font-size: 1.45rem; }
.kpi-note { font-size: .8rem; color: var(--muted); }
.income  { color: var(--green); }
.expense { color: var(--red); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; font-size: .9rem; }
input, select {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 1px;
}
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
.align-end { align-items: end; }
.form-actions { display: flex; gap: .6rem; }
.tx-form { display: flex; flex-direction: column; gap: .9rem; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .55rem 1rem; border-radius: 8px; text-decoration: none;
}
.btn:hover { border-color: var(--pine); }
.btn-primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-deep); }
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.link-btn {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--pine); text-decoration: underline;
}
.link-btn.danger { color: var(--red); }
.side .link-btn { color: #C9D8CF; }
.inline { display: inline; }

/* Segmented control (receita/despesa) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; width: fit-content; }
.seg-opt input { position: absolute; opacity: 0; }
.seg-opt span { display: block; padding: .45rem 1.1rem; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg-opt input:checked + span { background: var(--pine); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: -2px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table td, .table th { padding: .5rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table small { display: block; }
.th-right, .td-amount { text-align: right; white-space: nowrap; }
.td-date { white-space: nowrap; color: var(--muted); }
.td-actions { text-align: right; white-space: nowrap; }
.td-actions .link-btn { margin-left: .6rem; }
.totals { display: flex; gap: 1rem; font-weight: 600; font-size: .9rem; }

/* ---------- Barras de progresso ---------- */
.bar {
  position: relative; height: 10px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 99px; overflow: hidden;
}
.bar-fill { height: 100%; background: var(--gold); border-radius: 99px; }
.bar-fill.neutral { background: #9AA9A0; }
.bar-fill.s-ok   { background: var(--green); }
.bar-fill.s-warn { background: var(--amber); }
.bar-fill.s-bad  { background: var(--red); }
.bar-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .5; }
.goal-row { margin-bottom: .9rem; }
.goal-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; margin-bottom: .3rem; flex-wrap: wrap; }
.rule-row { margin-bottom: 1rem; }
.status-ok { color: var(--green); font-weight: 600; }
.status-warn { color: var(--amber); font-weight: 600; }
.status-bad { color: var(--red); font-weight: 600; }
.pill {
  font-size: .7rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: .1rem .55rem;
  vertical-align: middle; margin-left: .4rem;
}

/* ---------- Recomendações ---------- */
.rec { border-left: 4px solid var(--muted); padding: .5rem .9rem; margin-bottom: .8rem; background: var(--paper); border-radius: 0 8px 8px 0; }
.rec p { margin: .2rem 0 0; }
.rec-ok   { border-color: var(--green); }
.rec-warn { border-color: var(--amber); }
.rec-bad  { border-color: var(--red); }
.rec-info { border-color: var(--pine); }

/* ---------- Consultor ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--pine); stroke-width: 2.5; }
.chart-target { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 6 5; }
.chart-label { font-size: 11px; fill: var(--muted); }
.sim-result { font-weight: 600; margin: .8rem 0 0; min-height: 1.4em; }
.cta-advisor { display: flex; justify-content: space-between; align-items: center; gap: 1.2rem; }
.cta-advisor h2 { margin-bottom: .2rem; }
.cta-advisor p { margin: 0; }

.deposit-form { display: flex; gap: .6rem; margin-top: .8rem; }
.deposit-form input { flex: 1; max-width: 240px; }
.goal-card .bar { margin-bottom: .2rem; }

/* ---------- Flash & vazios ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-ok   { background: #E4F2E9; color: var(--green); }
.flash-bad  { background: #F6E4E4; color: var(--red); }
.empty { color: var(--muted); }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(900px 600px at 10% 110%, rgba(30,122,79,.13), transparent),
    radial-gradient(700px 400px at 90% -5%,  rgba(201,162,39,.12), transparent),
    var(--paper);
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 2.2rem 2rem;
  text-align: center;
}
.auth-card .stack { text-align: left; }
.auth-card label { text-align: left; }
.auth-sub { color: var(--muted); margin: .2rem 0 1.4rem; font-size: .95rem; }
.auth-alt { margin-top: 1.2rem; font-size: .9rem; }

/* ---------- Filtro de mês ---------- */
.month-filter input { padding: .4rem .6rem; }

/* ---------- Responsivo ---------- */
/* ─── Topbar mobile (oculta em desktop) ─── */
.topbar {
  display: none;         /* oculto em desktop; ativado no @media abaixo */
  position: sticky; top: 0; z-index: 200;
  background: var(--pine-deep);
  padding: .7rem 1rem;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-logo { display: flex; align-items: center; gap: .55rem; text-decoration: none; }
.topbar-wordmark {
  font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.15rem;
  color: #EAF2ED; letter-spacing: -.03em;
}
.topbar-right  { display: flex; align-items: center; gap: .7rem; }
.topbar-avatars { display: flex; gap: .35rem; }

/* Hambúrguer */
.burger {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 5px;
  padding: 4px; border-radius: 6px;
}
.burger span {
  display: block; width: 22px; height: 2px;
  background: #EAF2ED; border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.burger:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Overlay */
.menu-overlay {
  display: none; position: fixed; inset: 0; z-index: 290;
  background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .25s ease;
}
.menu-overlay.open { opacity: 1; }

/* Drawer lateral */
.mobile-drawer {
  position: fixed; top: 0; left: 0; z-index: 300;
  width: min(80vw, 280px); height: 100%;
  background: linear-gradient(180deg, var(--pine), var(--pine-deep));
  display: flex; flex-direction: column;
  padding: 1.2rem 1rem 1.4rem;
  gap: 1.2rem; overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 0 24px rgba(0,0,0,.3);
}
.mobile-drawer.open { transform: translateX(0); }

.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-close {
  background: none; border: none; color: #C9D8CF;
  font-size: 1.8rem; line-height: 1; cursor: pointer;
  padding: .1rem .4rem; border-radius: 6px;
}
.drawer-close:hover { color: #fff; }
.drawer-close:focus-visible { outline: 2px solid var(--gold); }

.drawer-couple { align-items: center !important; gap: .6rem !important; }
.drawer-who    { color: #C9D8CF; font-size: .9rem; font-weight: 500; }

.drawer-nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.drawer-nav a {
  color: #C9D8CF; text-decoration: none;
  padding: .7rem .85rem; border-radius: 9px;
  font-weight: 500; font-size: 1rem;
  transition: background .15s, color .15s;
}
.drawer-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.drawer-nav a.on   { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }

.drawer-foot .btn {
  width: 100%;
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15);
  color: #C9D8CF; font-size: .9rem;
}
.drawer-foot .btn:hover { background: rgba(255,255,255,.14); color: #fff; }

/* Avatar menor para topbar */
.side-avatar-sm { width: 26px !important; height: 26px !important; font-size: .75rem !important; }

/* ─── Mobile ≤ 900px ─── */
@media (max-width: 900px) {
  .topbar  { display: flex !important; }   /* garante topbar visível */
  .content { padding: 1.2rem 1rem 2.5rem; }
  .cards-3, .grid-2, .row-3 { grid-template-columns: 1fr; }
  .cta-advisor { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: no-preference) {
  .bar-fill { transition: width .5s ease; }
}

/* =====================================================================
   Nidus v2 — estilos adicionais para casal
   ===================================================================== */

/* Avatares na sidebar */
.side-couple { display:flex; gap:.5rem; padding:.2rem 0; }
.side-avatar {
  width:34px; height:34px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-family:'Sora',sans-serif; font-weight:700; font-size:.95rem; color:#fff;
  border:2px solid rgba(255,255,255,.2);
}

/* Parceiros no perfil do casal */
.partners-row { display:flex; gap:1.2rem; flex-wrap:wrap; margin-bottom:.5rem; }
.partner-card {
  display:flex; flex-direction:column; align-items:center; gap:.4rem;
  padding:.8rem 1.2rem; border:1px solid var(--line); border-radius:var(--radius);
  min-width:120px;
}
.partner-card.is-me { border-color:var(--pine); }
.partner-pending { opacity:.5; }
.avatar {
  width:52px; height:52px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-family:'Sora',sans-serif; font-weight:700; font-size:1.4rem; color:#fff;
}
.avatar-empty { background:var(--line); color:var(--muted); }

/* Carteiras no perfil */
.wallets-row { display:grid; grid-template-columns:repeat(3,1fr); gap:1rem; }
.wallet-card {
  display:flex; flex-direction:column; gap:.25rem;
  padding:.8rem 1rem; background:var(--paper); border-radius:var(--radius);
  border:1px solid var(--line);
}
.wallet-kind {
  font-size:.7rem; text-transform:uppercase; letter-spacing:.07em;
  color:var(--muted); font-weight:600;
}

/* Convite */
.invite-box { display:flex; gap:.5rem; margin-bottom:.6rem; }
.invite-box input { flex:1; font-size:.85rem; color:var(--muted); background:var(--paper); }
.invite-share { display:flex; gap:.5rem; flex-wrap:wrap; }

/* Wallet KPIs no dashboard */
.wallet-summary-row { display:grid; grid-template-columns:repeat(3,1fr); gap:1rem; }
.wallet-kpi { display:flex; flex-direction:column; gap:.15rem; padding:.6rem .8rem; background:var(--paper); border-radius:var(--radius); }
.wallet-kpi .kpi-label { font-size:.75rem; }
.wallet-kpi span { font-size:.85rem; }
.wallet-kpi strong { font-size:1.05rem; }

/* Helpers de layout */
.row-2 { display:grid; grid-template-columns:1fr 1fr; gap:.9rem; }
.divider { border:none; border-top:1px solid var(--line); margin:.4rem 0; }
.form-hint { color:var(--muted); font-size:.88rem; margin:0; }
.flash-info { background:#E6F1FB; color:#185FA5; }

/* Responsivo v2 */
@media (max-width:900px) {
  .wallets-row, .wallet-summary-row { grid-template-columns:1fr; }
  .row-2 { grid-template-columns:1fr; }
  .invite-box { flex-direction:column; }
}

/* =====================================================================
   LGPD checkbox
   ===================================================================== */
.lgpd-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: .55rem;
  font-weight: 400;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.45;
}
.lgpd-check input[type="checkbox"] {
  width: 17px; height: 17px; flex-shrink: 0;
  margin-top: .15rem; cursor: pointer;
  accent-color: var(--pine);
}
.lgpd-check a { color: var(--pine); font-weight: 500; }

/* =====================================================================
   Metas — duas barras + aporte calculado
   ===================================================================== */
.goal-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: .8rem 0 .6rem;
}
.goal-bar-col { display: flex; flex-direction: column; gap: .25rem; }
.bar-title { font-size: .8rem; font-weight: 600; color: var(--ink); }
.bar-pct   { font-size: .78rem; color: var(--muted); text-align: right; }

.bar-fill-time  { background: #5B9BD5; }                  /* azul-sereno para tempo */
.bar-fill-warn  { background: var(--amber) !important; }   /* laranja se tempo > valor */

.goal-deposit-info {
  display: flex; flex-wrap: wrap; gap: .4rem 1rem;
  font-size: .88rem; margin: .4rem 0 .6rem;
  align-items: center;
}
.goal-deposit-info strong { color: var(--pine); }

/* Aporte sugerido (preview ao digitar) */
.suggested-wrap { margin: .2rem 0; }
.suggested-box {
  display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .8rem;
  background: #EAF5EF; border: 1px solid #B4DECA;
  border-radius: 10px; padding: .65rem 1rem;
}
.suggested-label { font-size: .85rem; color: var(--muted); }
.suggested-value { font-family: 'Sora', sans-serif; font-size: 1.15rem; color: var(--green); }
.suggested-hint  { font-size: .8rem; color: var(--muted); }

/* Prazo em aberto (details/summary) */
.manual-deposit {
  border: 1px dashed var(--line); border-radius: 8px; padding: .5rem .8rem;
}
.manual-deposit summary {
  cursor: pointer; font-size: .88rem; color: var(--muted); list-style: none;
}
.manual-deposit summary::-webkit-details-marker { display: none; }
.manual-deposit summary::before { content: '+ '; font-weight: 700; }
details[open] .manual-deposit summary::before { content: '− '; }

/* Pills de status na meta */
.pill-ok   { background: #D1F5E4; color: var(--green); border-color: #B4DECA; }
.pill-warn { background: #FEF3C7; color: var(--amber); border-color: #FCD34D; }

/* Responsivo metas */
@media (max-width: 600px) {
  .goal-bars { grid-template-columns: 1fr; }
}

/* =====================================================================
   PWA — botão instalar e banner de atualização
   ===================================================================== */

/* Botão "Adicionar à tela inicial" — flutuante no canto inferior direito */
.pwa-install-btn {
  position: fixed; bottom: 1.4rem; right: 1.2rem; z-index: 500;
  display: flex; align-items: center; gap: .5rem;
  background: var(--pine); color: #fff;
  border: none; border-radius: 50px;
  padding: .65rem 1.1rem .65rem .85rem;
  font: 600 .88rem/1 'IBM Plex Sans', sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  cursor: pointer;
  animation: slideUp .4s cubic-bezier(.34,1.56,.64,1) both;
}
.pwa-install-btn:hover { background: var(--pine-deep); transform: translateY(-2px); }
.pwa-install-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Banner de nova versão — topo da tela */
.pwa-update-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 600;
  background: var(--pine-deep);
  color: #EAF2ED;
  padding: .6rem 1rem;
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  font-size: .9rem; font-weight: 500;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.pwa-update-banner .btn { background: var(--gold); border-color: var(--gold); color: #0B2A1F; }

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

/* PWA instalado (standalone) — safe areas e topbar garantida */
@media (display-mode: standalone) {
  /* Garante topbar visível em qualquer tamanho de tela quando instalado */
  .topbar  { display: flex !important; }
  .side    { display: none !important; }
  .shell   { grid-template-columns: 1fr !important; }

  /* Safe areas iOS (notch / home indicator) */
  .auth-body { padding-top: env(safe-area-inset-top, 1.5rem); }
  .topbar    { padding-top: max(.7rem, env(safe-area-inset-top)); }
  .content   { padding-bottom: max(2.5rem, env(safe-area-inset-bottom)); }
}
