/* Finanças do Casal — estilos (visual limpo) */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #a1a1aa;
  --line: #ececee;
  --line-2: #f4f4f5;
  --brand: #18181b;
  --acc: #0f766e;
  --pos: #0f766e;
  --neg: #c2410c;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 10px;
  --side: 220px;
  font-size: 14.5px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
svg { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.3rem; font-weight: 600; letter-spacing: -.015em; }
h2 { font-size: .95rem; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-2); }
.fraco { color: var(--ink-3); }
.small { font-size: .87rem; }
.tiny { font-size: .78rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Estrutura ---------- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side);
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px; z-index: 20;
}
.marca { display: flex; align-items: center; gap: 9px; padding: 0 10px 24px; font-weight: 600; font-size: .98rem; color: var(--ink); }
.marca-ico { width: 26px; height: 26px; border-radius: 7px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: .72rem; font-weight: 700; }
.nav-sec { font-size: .72rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: var(--ink-2); font-weight: 500; margin-bottom: 1px;
}
.nav a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.nav a.ativo { background: var(--line-2); color: var(--ink); font-weight: 600; }
.nav svg { width: 17px; height: 17px; opacity: .75; }
.side-rodape { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.side-rodape .quem { display: flex; align-items: center; gap: 8px; color: var(--ink); margin-bottom: 6px; font-weight: 500; }
.side-rodape a { color: var(--ink-2); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: var(--ink-2); }
.linkbtn:hover { text-decoration: underline; }

.main { margin-left: var(--side); padding: 28px 40px 60px; max-width: calc(1180px + var(--side)); }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; min-height: 36px; }
.topo-acoes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.bottom-nav, .fab { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-c { padding: 18px 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 0; min-height: 22px; }
.card-h + .card-c { padding-top: 12px; }

.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mb { margin-bottom: 20px; }

/* Faixa de números */
.stats { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.stat { padding: 16px 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .rot { font-size: .82rem; color: var(--ink-2); }
.stat .val { font-size: 1.35rem; font-weight: 600; letter-spacing: -.015em; margin-top: 2px; }
.stat .sub { font-size: .78rem; color: var(--ink-3); margin-top: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 500; font-size: .9rem;
  cursor: pointer; white-space: nowrap; line-height: 1.25;
}
.btn:hover { text-decoration: none; background: var(--line-2); }
.btn-p { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-p:hover { background: #3f3f46; }
.btn-perigo { color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: .84rem; border-radius: 7px; }
.btn-ico { padding: 6px 7px; border-color: transparent; color: var(--ink-3); }
.btn-ico:hover { color: var(--ink); }
.btn svg { width: 15px; height: 15px; vertical-align: 0; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.badge { display: inline-block; font-size: .72rem; font-weight: 500; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink-2); vertical-align: 1px; }
.b-ok { color: var(--pos); border-color: #cde7e3; }
.b-pend { color: var(--warn); border-color: #f3e1c1; }
.b-atr { color: var(--danger); border-color: #f5cccc; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: .68rem; font-weight: 600; flex: none; }

.alerta { padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: .92rem; border: 1px solid; }
.alerta-ok { background: #f0faf8; border-color: #cde7e3; color: #134e4a; }
.alerta-erro { background: #fef5f5; border-color: #f5cccc; color: #7f1d1d; }
.alerta ul { margin: 4px 0 0; padding-left: 18px; }

/* Seletor de mês */
.mes-sel { display: inline-flex; align-items: center; gap: 2px; }
.mes-sel a { padding: 6px; color: var(--ink-2); display: grid; place-items: center; border-radius: 7px; }
.mes-sel a:hover { background: var(--line-2); text-decoration: none; }
.mes-sel span { padding: 0 6px; font-weight: 600; min-width: 124px; text-align: center; }

/* Menu suspenso (novo lançamento) */
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-itens { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.08); padding: 4px; min-width: 180px; z-index: 40; }
.menu-itens a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px; }
.menu-itens a:hover { background: var(--line-2); text-decoration: none; }

/* ---------- Tabelas ---------- */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: .78rem; font-weight: 500; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tabela th.right { text-align: right; }
.tabela td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover td { background: #fcfcfc; }
.tabela .acoes { text-align: right; white-space: nowrap; width: 1px; }
.tabela tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.tab-wrap { overflow-x: auto; }
.desc-l { font-weight: 500; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.lista li:last-child { border-bottom: 0; }
.lista .grow { flex: 1; min-width: 0; }
.lista .grow > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.vazio { text-align: center; color: var(--ink-3); padding: 30px 10px; }

.barra { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 99px; background: #a1a1aa; }
.barra.ok > i { background: var(--acc); }
.barra.alerta-b > i { background: #f59e0b; }
.barra.estouro > i { background: var(--danger); }

.check-pago { background: none; border: 0; padding: 2px; cursor: pointer; display: inline-grid; place-items: center; }
.check-pago span { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #d4d4d8; display: grid; place-items: center; color: transparent; }
.check-pago.on span { background: var(--acc); border-color: var(--acc); color: #fff; }
.check-pago svg { width: 11px; height: 11px; vertical-align: 0; }
.check-pago:hover span { border-color: var(--acc); }

/* ---------- Formulários ---------- */
.form { max-width: 640px; }
.campo { margin-bottom: 16px; }
.campo label, .rotulo { display: block; font-weight: 500; font-size: .87rem; margin-bottom: 5px; color: var(--ink-2); }
.campo .ajuda { font-size: .79rem; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #e4e4e7; border-radius: 8px; font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(24, 24, 27, .08); border-color: #a1a1aa; }
input[type=color] { width: 44px; height: 36px; border: 1px solid #e4e4e7; border-radius: 8px; padding: 3px; background: #fff; cursor: pointer; }
.input-valor { font-size: 1.25rem !important; font-weight: 600; }
.linha { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.linha-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.form-acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 20px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap; background: #fff; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 5px 13px; border-radius: 6px; font-weight: 500; font-size: .88rem; color: var(--ink-2); cursor: pointer; }
.seg input:checked + span { background: var(--line-2); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--ink-3); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros select, .filtros input { width: auto; min-width: 150px; padding: 6px 9px; font-size: .88rem; }
.painel-filtros { padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fcfcfc; }

.grafico { position: relative; height: 280px; }
.grafico-sm { position: relative; height: 220px; }

.rank { list-style: none; margin: 0; padding: 0; }
.rank li { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.rank li:last-child { border-bottom: 0; }
.rank .topo-r { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rank .topo-r .num { margin-left: auto; }
.leg { display: flex; gap: 14px; font-size: .8rem; color: var(--ink-2); }
.leg span { display: inline-flex; align-items: center; gap: 6px; }
.leg i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(420px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.15); }
dialog::backdrop { background: rgba(24, 24, 27, .3); }
dialog .card-c { padding: 20px 22px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(360px, 100%); }
.login .marca { justify-content: center; padding-bottom: 20px; font-size: 1.1rem; }

.matriz td, .matriz th { padding: 8px 12px; font-size: .86rem; }
.matriz td.num, .matriz th.num { text-align: right; }
.matriz .cat { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 170px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .g-21, .g3 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 24px 24px 60px; }
}
@media (max-width: 820px) {
  .side { display: none; }
  .main { margin-left: 0; padding: 16px 14px 96px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--line); padding: 13px 16px; }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat .val { font-size: 1.12rem; }
  .linha, .linha-3 { grid-template-columns: minmax(0, 1fr); }
  .topo { margin-bottom: 16px; }
  .topo h1 { font-size: 1.15rem; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--ink-3); padding: 4px 6px; min-width: 56px; }
  .bottom-nav a.ativo { color: var(--ink); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav svg { width: 21px; height: 21px; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: calc(74px + env(safe-area-inset-bottom)); z-index: 31;
    width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.2);
  }
  .fab svg { width: 24px; height: 24px; vertical-align: 0; }
  .so-desk { display: none !important; }

  .tabela.resp thead { display: none; }
  .tabela.resp, .tabela.resp tbody, .tabela.resp tr, .tabela.resp td { display: block; }
  .tabela.resp tr { display: grid; grid-template-columns: auto 1fr auto; gap: 1px 10px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); align-items: center; }
  .tabela.resp td { padding: 0; border: 0; }
  .tabela.resp td.c-pago { grid-row: span 2; }
  .tabela.resp td.c-desc { grid-column: 2; }
  .tabela.resp td.c-valor { grid-column: 3; text-align: right; }
  .tabela.resp td.c-meta { grid-column: 2 / 4; font-size: .78rem; color: var(--ink-3); }
  .tabela.resp td.c-data, .tabela.resp td.c-cat, .tabela.resp td.c-orig, .tabela.resp td.c-resp, .tabela.resp td.acoes { display: none; }
  .tabela.resp tbody tr:hover td { background: transparent; }
}
@media (min-width: 821px) {
  .so-mob { display: none !important; }
  .tabela.resp td.c-meta { display: none; }
}
.card-h .topo-acoes { flex-wrap: nowrap; }
@media (max-width: 820px) { .stats > .stat:last-child:nth-child(odd) { grid-column: span 2; } }

/* Tetos de gasto */
.alerta-aviso { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.alerta-aviso a { color: #78350f; text-decoration: underline; margin-left: 4px; }
.teto-linha { padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.teto-linha:last-child { border-bottom: 0; }
.teto-topo { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.teto-topo .valores { margin-left: auto; }
.teto-rodape { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; }
.teto-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; padding: 12px; background: #fcfcfc; border: 1px solid var(--line); border-radius: 8px; }
.teto-form .campo { margin: 0; }
.teto-form input { width: 130px; }
.teto-form input[name=alerta_pct] { width: 80px; }
.barra { position: relative; }
.barra .marca-alerta { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #d4d4d8; }
.aviso-teto { margin-top: 6px; font-size: .82rem; padding: 7px 10px; border-radius: 7px; background: #fafafa; border: 1px solid var(--line); color: var(--ink-2); }
.aviso-teto.alerta { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.aviso-teto.estourou { background: #fef5f5; border-color: #f5cccc; color: #7f1d1d; }
.b-alerta { color: var(--warn); border-color: #f3e1c1; }
