/* Despesas Pessoais Online - mesmas cores do app Android/Windows (lib/tema.dart) */
:root {
  --principal: #660099;
  --escura: #4A0072;
  --destaque: #EB3C7D;
  --fundo: #F6F2FA;
  --cartao: #FFFFFF;
  --texto: #2A1A35;
  --suave: #76668A;
  --linha: #E6DDF0;
  --receita: #2F9E44;
  --despesa: #D23C3C;
  --raio: 14px;
  --topo: env(safe-area-inset-top, 0px);
  --baixo: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #17101D;
    --cartao: #241A2C;
    --texto: #F1E9F7;
    --suave: #B3A3C4;
    --linha: #3A2C46;
    --receita: #51CF66;
    --despesa: #FF6B6B;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 1.15rem; }
a { color: var(--principal); }
.oculto { display: none !important; }

/* ---------- topo e abas ---------- */
.topo {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(135deg, var(--escura), #8E24AA);
  color: #fff;
  padding: calc(var(--topo) + 10px) 16px 10px;
}
.topo .linha1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topo .titulo { font-weight: 700; font-size: 1.1rem; }
.mes { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
.mes button { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 10px; min-width: 44px; height: 36px; font-size: 1.1rem; }
.mes .nome { min-width: 150px; text-align: center; font-weight: 600; }
.aviso-licenca { background: rgba(255,255,255,.18); border-radius: 10px; padding: 6px 10px; font-size: .85rem; margin-top: 8px; }

.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--cartao); border-top: 1px solid var(--linha);
  padding-bottom: var(--baixo);
}
.abas button { background: none; border: 0; padding: 8px 0 6px; color: var(--suave); font-size: .75rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.abas button svg { width: 24px; height: 24px; }
.abas button.ativa { color: var(--principal); font-weight: 600; }

main#app { padding-bottom: calc(80px + var(--baixo)); }
.conteudo { padding: 12px 16px; max-width: 720px; margin: 0 auto; }

/* ---------- cartoes, listas ---------- */
.cartao { background: var(--cartao); border-radius: var(--raio); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(40, 0, 60, .08); }
.totais { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.totais div { background: var(--cartao); border-radius: var(--raio); padding: 10px; text-align: center; box-shadow: 0 1px 3px rgba(40,0,60,.08); }
.totais small { display: block; color: var(--suave); font-size: .75rem; }
.totais b { font-size: .98rem; }
.verde { color: var(--receita); }
.vermelho { color: var(--despesa); }
.suave { color: var(--suave); }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--linha); cursor: pointer; }
.lista li:last-child { border-bottom: 0; }
.lista .info { flex: 1; min-width: 0; }
.lista .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lista .info small { color: var(--suave); font-size: .8rem; }
.lista .valor { font-weight: 700; white-space: nowrap; }
.dia { font-size: .8rem; color: var(--suave); margin: 12px 2px 2px; font-weight: 600; }
.vazio { text-align: center; color: var(--suave); padding: 30px 10px; }
.icone-foto { font-size: .75rem; color: var(--suave); }

/* ---------- botoes ---------- */
.botao { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--principal); color: #fff; font-weight: 600; min-height: 46px; cursor: pointer; text-decoration: none; }
.botao.claro { background: var(--cartao); color: var(--principal); border: 1px solid var(--linha); }
.botao.perigo { background: var(--despesa); }
.botao.largo { width: 100%; }
.botao:disabled { opacity: .55; }
.botoes { display: flex; gap: 8px; flex-wrap: wrap; }
.botoes .botao { flex: 1 1 140px; }
.acoes-rapidas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.acoes-rapidas button { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio); padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--principal); font-weight: 600; font-size: .85rem; }
.acoes-rapidas svg { width: 28px; height: 28px; }
.fab { position: fixed; right: 18px; bottom: calc(78px + var(--baixo)); z-index: 7; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--destaque); color: #fff; font-size: 2rem; line-height: 1; box-shadow: 0 4px 14px rgba(235, 60, 125, .45); }

/* ---------- formularios ---------- */
label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: .82rem; color: var(--suave); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], input[inputmode], select, textarea {
  width: 100%; border: 1px solid var(--linha); border-radius: 10px; padding: 11px 12px; background: var(--cartao); min-height: 46px;
  font-size: 16px; /* evita o zoom do iPhone */
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--principal); outline-offset: -1px; }
.dupla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.erro { color: var(--despesa); font-size: .9rem; margin: 6px 0; }
.dica { font-size: .85rem; color: var(--suave); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips button { border: 1px solid var(--linha); background: var(--cartao); border-radius: 20px; padding: 6px 12px; font-size: .85rem; }
.chips button.sel { background: var(--principal); color: #fff; border-color: var(--principal); }

/* ---------- tela cheia (formulario, camera) ---------- */
.folha { position: fixed; inset: 0; z-index: 20; background: var(--fundo); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.folha .cabeca { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: calc(var(--topo) + 8px) 12px 8px; background: var(--cartao); border-bottom: 1px solid var(--linha); }
.folha .cabeca h2 { flex: 1; margin: 0; font-size: 1.05rem; }
.folha .cabeca button { background: none; border: 0; color: var(--principal); font-weight: 600; min-height: 40px; padding: 0 8px; }
.folha .corpo { padding: 14px 16px calc(24px + var(--baixo)); max-width: 640px; margin: 0 auto; }
.camera { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; flex-direction: column; }
.camera video { flex: 1; width: 100%; object-fit: cover; }
.camera .mira { position: absolute; left: 50%; top: 45%; width: 64vw; height: 64vw; max-width: 320px; max-height: 320px; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.camera .rodape { padding: 14px 16px calc(14px + var(--baixo)); color: #fff; text-align: center; display: grid; gap: 10px; }
.foto-previa { width: 100%; max-height: 260px; object-fit: contain; border-radius: 10px; background: #0001; }

/* ---------- entrada ---------- */
.entrada { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--topo) + 24px) 20px calc(24px + var(--baixo)); max-width: 440px; margin: 0 auto; }
.entrada .logo { text-align: center; margin-bottom: 18px; }
.entrada .logo img { width: 84px; height: 84px; border-radius: 20px; }
.entrada .logo h1 { color: var(--principal); margin-top: 10px; font-size: 1.5rem; }
.trocar { text-align: center; margin-top: 14px; }
.trocar button { background: none; border: 0; color: var(--principal); font-weight: 600; padding: 8px; }

/* ---------- resumo ---------- */
.grafico { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.grafico svg { width: 150px; height: 150px; flex: none; }
.legenda { flex: 1; min-width: 150px; list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.legenda li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.legenda i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legenda span { flex: 1; }
.barra-cat { height: 8px; border-radius: 4px; background: var(--linha); overflow: hidden; margin-top: 3px; }
.barra-cat i { display: block; height: 100%; background: var(--principal); }

/* ---------- avisos ---------- */
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--baixo)); transform: translateX(-50%); z-index: 50; background: #2A1A35; color: #fff; padding: 10px 16px; border-radius: 12px; max-width: 90vw; text-align: center; font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.carregando { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; overflow: hidden; }
.carregando .barra { height: 100%; width: 40%; background: var(--destaque); animation: corre 1s infinite ease-in-out; }
@keyframes corre { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.passos { margin: 6px 0 0; padding-left: 20px; }
.passos li { margin-bottom: 6px; }
.codigo { font-family: ui-monospace, Menlo, monospace; font-size: 1.2rem; letter-spacing: 1px; background: var(--fundo); padding: 8px 10px; border-radius: 8px; display: inline-block; user-select: all; }

/* ---------- impressao do relatorio ---------- */
@media print {
  .topo, .abas, .fab, .nao-imprimir { display: none !important; }
  body, .cartao { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  main#app { padding: 0; }
}
@media print {
  body.imprimindo > *:not(.folha-relatorio) { display: none !important; }
  body.imprimindo .folha-relatorio { position: static; overflow: visible; background: #fff; }
  body.imprimindo .folha-relatorio .cabeca { display: none; }
}
/* telas estreitas: nada passa da largura */
html, body { overflow-x: hidden; }
.dupla > * { min-width: 0; }
input, select, textarea { min-width: 0; max-width: 100%; }
input[type=date] { -webkit-appearance: none; appearance: none; }
.grafico svg { width: 128px; height: 128px; }
.legenda { min-width: 0; }
.legenda span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legenda b { white-space: nowrap; }
.totais div { min-width: 0; padding: 10px 4px; }
.totais b { font-size: clamp(.78rem, 3.7vw, .98rem); white-space: nowrap; }
