:root {
  --verde: #2e7d6b;
  --verde-escuro: #1f5c4e;
  --fundo: #f4f1ec;
  --cartao: #ffffff;
  --texto: #222;
  --suave: #6b6b6b;
  --linha: #e4dfd6;
  --perigo: #c0392b;
  --ju: #2f6fd6;
  --dani: #c2417a;
  --carol: #d9822b;
  --sombra: 0 1px 3px rgba(0, 0, 0, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #15181c; --cartao: #1f242a; --texto: #eee; --suave: #a2a7ad; --linha: #333a42;
    --verde: #3fa58d; --verde-escuro: #2e7d6b; --sombra: none;
    --ju: #6c9bf0; --dani: #e27aa7; --carol: #f0a45a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo); color: var(--texto);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }

/* ---------- telas cheias (senha / quem é você) ---------- */
.tela-cheia {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; text-align: center; gap: 8px;
}
.tela-cheia form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.logo-grande { width: 96px; height: 96px; border-radius: 22px; }
.botoes-pessoas { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.botoes-pessoas button { width: 96px; height: 96px; border-radius: 50%; border: none; color: #fff; font-size: 20px; font-weight: 700; }

/* ---------- topo e abas ---------- */
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; background: var(--verde); color: #fff;
}
.topo .seta, .topo .menu { background: none; border: none; color: #fff; font-size: 28px; width: 44px; height: 44px; border-radius: 50%; }
.topo .seta:active, .topo .menu:active { background: rgba(255, 255, 255, .15); }
.mes-atual { flex: 1; text-align: center; font-size: 19px; font-weight: 600; display: flex; flex-direction: column; align-items: center; }
.mes-atual .link { color: #fff; font-size: 13px; font-weight: 400; }

main { padding: 12px 12px calc(env(safe-area-inset-bottom) + 150px); max-width: 720px; margin: 0 auto; }

.abas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: var(--cartao); border-top: 1px solid var(--linha); padding-bottom: env(safe-area-inset-bottom);
}
.abas button { flex: 1; border: none; background: none; padding: 8px 4px 10px; font-size: 13px; color: var(--suave); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.abas button span { font-size: 22px; filter: grayscale(1); opacity: .6; }
.abas button.ativa { color: var(--verde); font-weight: 700; }
.abas button.ativa span { filter: none; opacity: 1; }

.mais {
  position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 6;
  width: 60px; height: 60px; border-radius: 50%; border: none; background: var(--verde); color: #fff;
  font-size: 34px; line-height: 1; box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
}

/* ---------- cartões ---------- */
.cartao { background: var(--cartao); border-radius: 14px; box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.cartao h2, .cartao h3 { margin: 0 0 8px; font-size: 16px; }
.titulo-secao { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 18px 4px 8px; }
.vazio { text-align: center; color: var(--suave); padding: 28px 12px; }

.totais { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.totais .grande { font-size: 22px; font-weight: 700; }
.totais .legenda { font-size: 13px; color: var(--suave); }
.pagou-cada { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pagou-cada div { flex: 1; min-width: 90px; background: var(--fundo); border-radius: 10px; padding: 6px 8px; font-size: 14px; }

/* lista de despesas */
.despesa { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: none; background: var(--cartao); border-radius: 12px; padding: 12px; margin-bottom: 8px; box-shadow: var(--sombra); }
.despesa .dia { width: 42px; text-align: center; flex-shrink: 0; }
.despesa .dia b { display: block; font-size: 20px; line-height: 1; }
.despesa .dia small { color: var(--suave); font-size: 12px; }
.despesa .meio { flex: 1; min-width: 0; }
.despesa .meio .desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.despesa .meio .det { font-size: 13px; color: var(--suave); }
.despesa .valor { text-align: right; font-weight: 700; white-space: nowrap; }
.despesa .valor small { display: block; font-weight: 400; font-size: 12px; color: var(--suave); }

.pessoa { display: inline-block; padding: 1px 8px; border-radius: 99px; color: #fff; font-size: 12px; font-weight: 700; }
.p-Ju { background: var(--ju); } .p-Dani { background: var(--dani); } .p-Carol { background: var(--carol); }

/* acerto */
.transf { background: var(--cartao); border-radius: 14px; box-shadow: var(--sombra); padding: 14px; margin-bottom: 10px; }
.transf.eu { outline: 2px solid var(--verde); }
.transf.pulou { opacity: .75; }
.transf .linha1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.transf .seta-t { color: var(--suave); }
.transf .quanto { margin-left: auto; font-size: 22px; font-weight: 700; }
.transf.pulou .quanto { text-decoration: line-through; }
.transf .frase { font-size: 14px; color: var(--suave); margin: 6px 0 0; }
.transf .controles { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 8px; }
.pulou-caixa { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 6px 4px; }
.pulou-caixa input { width: 22px; height: 22px; accent-color: var(--perigo); }
.selo-pulou { background: #fdecea; color: var(--perigo); border-radius: 8px; font-size: 13px; padding: 4px 8px; margin-top: 8px; display: inline-block; }
@media (prefers-color-scheme: dark) { .selo-pulou { background: #4a2420; color: #ffb4a8; } }
details.contas { margin-top: 8px; font-size: 14px; }
details.contas summary { color: var(--verde); cursor: pointer; padding: 4px 0; }
details.contas ul { margin: 6px 0 0; padding-left: 18px; }
details.contas li { margin-bottom: 4px; }
details.contas .menos { color: var(--verde); }
.nota { font-size: 13px; color: var(--suave); text-align: center; margin: 14px 8px; }

/* ---------- formulários e diálogos ---------- */
dialog {
  border: none; border-radius: 18px; padding: 18px; width: min(94vw, 460px); max-height: 92dvh;
  background: var(--cartao); color: var(--texto); box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
label, .rotulo { display: block; font-size: 14px; font-weight: 600; color: var(--suave); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=date], select {
  width: 100%; padding: 12px; border: 1px solid var(--linha); border-radius: 10px; background: var(--fundo); font-size: 17px;
  min-height: 48px;
}
input:focus, select:focus { outline: 2px solid var(--verde); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { border: 1px solid var(--linha); background: var(--fundo); border-radius: 99px; padding: 6px 12px; font-size: 14px; }
.segmentos { display: flex; gap: 6px; }
.segmentos button { flex: 1; min-height: 46px; border: 2px solid var(--linha); background: var(--fundo); border-radius: 10px; font-weight: 600; }
.segmentos button.sel { border-color: var(--verde); background: var(--verde); color: #fff; }
.segmentos button.sel.p-Ju { border-color: var(--ju); background: var(--ju); }
.segmentos button.sel.p-Dani { border-color: var(--dani); background: var(--dani); }
.segmentos button.sel.p-Carol { border-color: var(--carol); background: var(--carol); }
.segmentos button.p-Ju:not(.sel), .segmentos button.p-Dani:not(.sel), .segmentos button.p-Carol:not(.sel) { background: var(--fundo); color: var(--texto); }
.acoes { display: flex; gap: 8px; margin-top: 18px; }
.acoes .botao-principal { flex: 1; }
.botao-principal, .botao-secundario, .botao-perigo { min-height: 48px; padding: 10px 16px; border-radius: 10px; font-weight: 700; border: none; }
.botao-principal { background: var(--verde); color: #fff; }
.botao-secundario { background: var(--fundo); border: 1px solid var(--linha); }
.botao-perigo { background: none; color: var(--perigo); border: 1px solid var(--perigo); }
.botao-perigo.confirmar { background: var(--perigo); color: #fff; }
.largo { width: 100%; margin-top: 10px; }
.link { background: none; border: none; color: var(--verde); text-decoration: underline; padding: 0 2px; }
.erro { color: var(--perigo); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; }
.dica { font-size: 14px; color: var(--suave); }

.aviso {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 150px); z-index: 20;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 90vw; text-align: center; font-size: 15px;
}
.aviso.ruim { background: var(--perigo); }
