:root {
  --fundo: #141210; --superficie: #1E1B18; --superficie-2: #252119; --linha: #2E2A26;
  --texto: #EDE7E1; --sutil: #A8A09A; --apagado: #5E5750;
  --saida: #3B82F6; --entrada: #F97316; --servico: #A855F7; --pos: #22C55E; --neg: #EF4444;
  --raio: 16px;
  --topo-seguro: env(safe-area-inset-top, 0px); --base-segura: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 650; }
h2 { font-size: 15px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--entrada); outline-offset: 2px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 28px;
  padding: calc(24px + var(--topo-seguro)) 24px calc(24px + var(--base-segura)); max-width: 420px; margin: 0 auto; }
.login-marca { text-align: center; }
.login-marca img { border-radius: 16px; }
.login-marca h1 { font-size: 24px; margin-top: 12px; }
.login-marca p { color: var(--sutil); margin: 4px 0 0; }
.login-form, .form { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sutil); }
input { background: var(--superficie); border: 1px solid var(--linha); border-radius: 12px; padding: 14px; font-size: 16px; }
input:focus { border-color: var(--entrada); outline: none; }
.login-rodape { text-align: center; color: var(--apagado); font-size: 13px; margin: 0; }
.erro { color: var(--neg); min-height: 1em; margin: 0; font-size: 14px; }
.btn-primario { background: var(--entrada); color: #fff; border: 0; border-radius: 12px; padding: 14px; font-weight: 650;
  cursor: pointer; }
.btn-primario:disabled { opacity: .6; }
.btn-secundario { border: 1px solid var(--linha); border-radius: 999px; padding: 8px 14px; text-decoration: none;
  color: var(--texto); font-size: 14px; white-space: nowrap; }
.btn-sair { width: 100%; background: none; border: 1px solid var(--linha); border-radius: 12px; padding: 14px;
  color: var(--neg); cursor: pointer; }

/* ---------- topo ---------- */
.topo { position: sticky; top: 0; z-index: 5; background: rgba(20, 18, 16, .94); backdrop-filter: blur(10px);
  padding: calc(12px + var(--topo-seguro)) 16px 0; border-bottom: 1px solid var(--linha); }
.topo-linha { display: flex; align-items: center; gap: 12px; }
.empresa { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.empresa strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empresa span { color: var(--sutil); font-size: 12px; }
.empresa select { margin-bottom: 4px; }
select { background: var(--superficie); border: 1px solid var(--linha); border-radius: 10px; padding: 8px 10px; }
.meses { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0; scrollbar-width: none; scroll-snap-type: x proximity; }
.meses::-webkit-scrollbar { display: none; }
.meses button { flex: 0 0 auto; scroll-snap-align: center; border: 1px solid var(--linha); background: none;
  border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--sutil); cursor: pointer; }
.meses button.lancado { color: var(--texto); }
.meses button.vazio { color: var(--apagado); border-style: dashed; }
.meses button[aria-pressed="true"] { background: var(--texto); color: var(--fundo); border-color: var(--texto); font-weight: 650; }

/* ---------- conteúdo ---------- */
.conteudo { padding: 16px 16px calc(96px + var(--base-segura)); max-width: 720px; margin: 0 auto; }
.aba { display: flex; flex-direction: column; gap: 14px; }
.cartao { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; }
.cartao h2 { margin-bottom: 10px; }
.sutil { color: var(--sutil); margin: 0; font-size: 14px; }
.aviso { background: rgba(250, 204, 21, .08); border: 1px solid rgba(250, 204, 21, .3); color: #F5DE8A;
  border-radius: 12px; padding: 12px 14px; font-size: 14px; }

.destaque { padding: 8px 2px 4px; }
.rotulo { color: var(--sutil); font-size: 14px; }
.valor-grande { font-size: clamp(32px, 10vw, 44px); font-weight: 750; letter-spacing: -1px; line-height: 1.1; margin: 4px 0; }
.variacao { font-size: 14px; color: var(--sutil); }
.sobe { color: var(--pos); } .desce { color: var(--neg); }

.pares { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.par { background: var(--superficie); border: 1px solid var(--linha); border-radius: 14px; padding: 12px 14px;
  border-left: 3px solid var(--cor, var(--linha)); }
.par .r { font-size: 13px; color: var(--sutil); }
.par .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.par .n { font-size: 12px; color: var(--sutil); }
.par.largo { grid-column: 1 / -1; }

.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--sutil); margin-bottom: 8px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legenda i.linha { height: 3px; border-radius: 2px; vertical-align: 2px; }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico text { fill: var(--sutil); font-size: 10px; }
.grafico .sel text.mes { fill: var(--texto); font-weight: 700; }
.dica-grafico { font-size: 13px; color: var(--sutil); margin-top: 8px; min-height: 1.4em; }

.resumo { margin: 0; display: grid; grid-template-columns: 1fr auto; row-gap: 10px; }
.resumo dt { color: var(--sutil); }
.resumo dd { margin: 0; text-align: right; font-weight: 650; }

/* ---------- relatório ---------- */
.cabecalho-aba { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cabecalho-aba h2 { font-size: 18px; }
.lista-meses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lista-meses li { background: var(--superficie); border: 1px solid var(--linha); border-radius: 14px; }
.lista-meses li.vazio { opacity: .5; }
.lista-meses li.sel { border-color: var(--texto); }
.lista-meses details summary { list-style: none; display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  align-items: center; padding: 12px 14px; cursor: pointer; }
.lista-meses details summary::-webkit-details-marker { display: none; }
.lista-meses .m { font-weight: 650; }
.lista-meses .f { font-weight: 650; }
.lista-meses .mg { font-size: 13px; min-width: 56px; text-align: right; }
.lista-meses dl { margin: 0; padding: 0 14px 12px; display: grid; grid-template-columns: 1fr auto; row-gap: 6px; font-size: 14px; }
.lista-meses dt { color: var(--sutil); } .lista-meses dd { margin: 0; text-align: right; }
.lista-meses li.cab { background: none; border: 0; display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 0 14px; font-size: 12px; color: var(--sutil); }
.lista-meses li.cab span:last-child { min-width: 56px; text-align: right; }
.lista-meses li.total { background: var(--superficie-2); }

/* ---------- abas inferiores ---------- */
.abas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: rgba(20, 18, 16, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--linha);
  padding: 6px 8px calc(6px + var(--base-segura)); }
.abas button { flex: 1; max-width: 180px; background: none; border: 0; color: var(--apagado); display: flex;
  flex-direction: column; align-items: center; gap: 2px; font-size: 12px; padding: 6px; cursor: pointer; }
.abas svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.abas button.ativa { color: var(--texto); }
.abas button.ativa svg { stroke: var(--entrada); }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--base-segura)); transform: translateX(-50%);
  background: var(--texto); color: var(--fundo); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 9; }

.carregando .conteudo { opacity: .55; transition: opacity .15s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (min-width: 720px) { .pares { grid-template-columns: repeat(4, 1fr); } .par.largo { grid-column: auto; } }

/* ---------- contábil ---------- */
.barra-desp { margin: 10px 0; }
.barra-desp .t { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.barra-desp .t b { white-space: nowrap; }
.barra-desp .b { height: 6px; background: var(--linha); border-radius: 3px; margin-top: 5px; }
.barra-desp .b div { height: 6px; background: var(--entrada); border-radius: 3px; }
#cont-conteudo { display: flex; flex-direction: column; gap: 14px; }

/* ---------- folha / fator r ---------- */
.bloco { display: flex; flex-direction: column; gap: 14px; }
.fr-cartao .valor-grande { margin: 2px 0 6px; }
.pilula { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.fr-explica { margin: 12px 0; font-size: 13px; }
.fr-cartao .resumo { margin-bottom: 12px; }
.abas button { font-size: 11px; }

.func { border-top: 1px solid var(--linha); }
.func:first-child { border-top: 0; }
.func summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; cursor: pointer; }
.func summary::-webkit-details-marker { display: none; }
.func summary b { display: block; font-weight: 600; }
.func summary small { color: var(--sutil); font-size: 12px; }
.func summary .v { font-weight: 650; white-space: nowrap; }
.func .resumo { padding: 0 0 10px; row-gap: 6px; font-size: 14px; }

/* ---------- entradas × saídas ---------- */
.es-explica { font-size: 13px; margin-bottom: 6px; }
.es-res { margin: 14px 0 6px; }
.es-sub { font-size: 14px; font-weight: 650; margin: 18px 0 2px; display: flex; justify-content: space-between; gap: 10px; }
.es-sub span { color: var(--sutil); font-weight: 400; }
.es-tag { font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 999px; margin-left: 4px; white-space: nowrap; }
.es-soma { background: rgba(249, 115, 22, .15); color: #FDBA74; }
.es-abate { background: rgba(250, 204, 21, .15); color: #FACC15; }
.es-fora { background: var(--linha); color: var(--sutil); }

/* ---------- opções da tela Início ---------- */
.opcoes { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 4px; }
.opcoes::-webkit-scrollbar { display: none; }
.opcoes button { flex: 1 0 auto; border: 1px solid var(--linha); background: var(--superficie); color: var(--sutil);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.opcoes button[aria-pressed="true"] { background: var(--entrada); border-color: var(--entrada); color: #fff; }

/* ---------- resumo e diagnóstico (entradas × saídas) ---------- */
.es-status { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: var(--superficie); border: 1px solid var(--linha); border-left: 4px solid var(--c); border-radius: 14px; padding: 12px 14px; }
.es-status .ic, .diag-topo .ic { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c); color: #141210; font-weight: 800; }
.es-status .tx { flex: 1; display: flex; flex-direction: column; }
.es-status .tx small { color: var(--sutil); font-size: 12px; }
.es-status .seta { color: var(--sutil); font-size: 22px; }
.es-cem { display: flex; height: 18px; border-radius: 9px; overflow: hidden; background: var(--linha); margin: 6px 0 10px; }
.es-cem div { height: 100%; }
.es-cem-leg { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.es-cem-leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.diag { border-top: 4px solid var(--c, var(--linha)); }
.diag-topo { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.diag-topo small { color: var(--sutil); font-size: 12px; }
.diag-topo h2 { font-size: 18px; margin: 0; }
.diag-tx { margin: 0 0 10px; line-height: 1.55; }
.diag-ano { margin: 0 0 10px; color: var(--sutil); font-size: 14px; }
.diag h3 { font-size: 14px; margin: 14px 0 6px; }
.diag ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

/* ---------- relatório anual entradas × saídas ---------- */
.rel-tab-wrap { overflow-x: auto; border: 1px solid var(--linha); border-radius: 14px; background: var(--superficie); }
.es-tab { width: 100%; border-collapse: collapse; font-size: 13px; }
.es-tab th, .es-tab td { padding: 10px 8px; border-bottom: 1px solid var(--linha); white-space: nowrap; text-align: right; }
.es-tab thead th { color: var(--sutil); font-weight: 600; font-size: 12px; vertical-align: bottom; background: var(--superficie-2); }
.es-tab thead th small { display: block; font-weight: 400; font-size: 11px; color: var(--apagado); }
.es-tab th:first-child { text-align: left; }
.es-tab tbody th { font-weight: 600; }
.es-tab tr.vazio { color: var(--apagado); }
.es-tab tr.sel { background: rgba(255, 255, 255, .05); }
.es-tab td.neg { color: var(--neg); font-weight: 650; }
.es-tab td.pos { color: var(--pos); }
.es-tab tfoot th, .es-tab tfoot td { font-weight: 700; background: var(--superficie-2); border-bottom: 0; }
.es-nota { font-size: 12px; padding: 10px 12px; margin: 0; }

.es-pares { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .es-pares { grid-template-columns: repeat(4, 1fr); } }
.es-pares .v { font-size: 20px; }
