/* =====================================================================
   Poupa+ — design system
   Paleta: verde-cédula profundo + papel claro + dourado de progresso
   ===================================================================== */
: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 ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, var(--pine), var(--pine-deep));
  color: #EAF2ED;
  padding: 1.4rem 1rem;
  display: flex; flex-direction: column; gap: 1.6rem;
}
.brand { font-weight: 700; font-size: 1.35rem; letter-spacing: -.02em; }
.brand span { color: var(--gold); }
.brand.big { font-size: 2rem; color: var(--pine); }
.brand.big span { color: var(--gold); }
.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(1100px 500px at 80% -10%, rgba(201,162,39,.14), transparent),
    var(--paper);
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 2rem;
}
.auth-sub { color: var(--muted); margin: .3rem 0 1.4rem; }
.auth-alt { margin-top: 1.2rem; font-size: .9rem; }

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

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .8rem; padding: .9rem 1rem; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; display: flex; gap: .8rem; align-items: center; }
  .who { margin: 0; }
  .content { padding: 1.2rem; }
  .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; }
}
