:root {
  --cor: #F2662A;           /* trocada pela cor da conta */
  --cor-texto: #fff;
  --cinza: #3A3E42;
  --fundo: #F5F5F3;
  --cartao: #fff;
  --texto: #23262A;
  --suave: #6B7075;
  --linha: #E3E3DF;
  --ok: #1F8A4C;
  --alerta: #C0392B;
  --aviso: #B7791F;
  --raio: 14px;
  --sombra: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #17191B; --cartao: #22252A; --texto: #EDEDEA; --suave: #A3A8AD; --linha: #33373C;
    --sombra: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--fundo); color: var(--texto);
  font: 16px/1.45 Figtree, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: Outfit, Figtree, sans-serif; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cor); }

/* Topo */
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .6rem;
  padding: .7rem 16px; padding-top: max(.7rem, env(safe-area-inset-top));
  background: var(--topo, var(--cor)); color: var(--topo-texto, var(--cor-texto));
  border-bottom: 2px solid var(--cor);
}
.topo img { height: 30px; width: 30px; object-fit: contain; border-radius: 6px; background: #fff; }
.topo-nome { font: 600 1.05rem Outfit, sans-serif; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-conta { background: rgba(255,255,255,.18); border: 0; color: inherit; border-radius: 10px; padding: .35rem .7rem; cursor: pointer; }

/* Conteúdo */
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px 150px; }
.carregando { padding: 3rem 0; text-align: center; color: var(--suave); }
.cartao { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 14px 16px; margin-bottom: 12px; }
.cartao.borda { border-left: 4px solid var(--cor); }
.linha-titulo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.suave { color: var(--suave); font-size: .9rem; }
.vazio { text-align: center; color: var(--suave); padding: 2rem 1rem; }
.secao { margin: 1.25rem 0 .5rem; font: 600 .8rem Figtree, sans-serif; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); }

/* Lista */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); margin-bottom: 8px; }
.item { display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; background: none; border: 0; padding: 12px 14px; cursor: pointer; min-height: 56px; }
.item-corpo { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--suave); font-size: .88rem; }
.item-titulo, .item-sub { display: block; }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--cor) 15%, transparent); color: var(--cor); font-weight: 700; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 0; border-radius: 12px; padding: .7rem 1rem; min-height: 44px; font-weight: 600; cursor: pointer; background: var(--cor); color: var(--cor-texto); text-decoration: none; }
.btn.sec { background: transparent; color: var(--texto); border: 1px solid var(--linha); }
.btn.perigo { background: transparent; color: var(--alerta); border: 1px solid currentColor; }
.btn.zap { background: #25D366; color: #fff; }
.btn.peq { min-height: 36px; padding: .4rem .75rem; font-size: .9rem; }
.btn.bloco { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.botoes { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.flutuante { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 6; border-radius: 999px; width: 56px; height: 56px; font-size: 1.6rem; box-shadow: 0 6px 18px rgba(0,0,0,.2); }

/* Formulários */
.campo { display: block; margin-bottom: .8rem; }
.campo > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.campo input, .campo select, .campo textarea, .busca {
  width: 100%; border: 1px solid var(--linha); border-radius: 10px; padding: .65rem .75rem; background: var(--cartao); min-height: 44px;
}
.campo textarea { min-height: 80px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .busca:focus { outline: 2px solid var(--cor); outline-offset: 0; border-color: transparent; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.busca { margin-bottom: .75rem; }

/* Menu inferior */
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--cartao); border-top: 1px solid var(--linha); padding-bottom: env(safe-area-inset-bottom);
}
.menu a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px; text-decoration: none; color: var(--suave); font-size: .72rem; font-weight: 600; min-height: 56px; }
.menu a .ico { font-size: 1.3rem; line-height: 1; }
.menu a.ativo { color: var(--cor); }

/* Janela (folha que sobe no celular) */
.janela { border: 0; padding: 0; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; background: var(--cartao); color: var(--texto); }
.janela::backdrop { background: rgba(0,0,0,.45); }
.janela-corpo { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); overflow: auto; max-height: 92vh; }
@media (min-width: 700px) { .janela { margin: auto; border-radius: 18px; } }

/* Aviso */
.aviso { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: var(--cinza); color: #fff; padding: .6rem 1rem; border-radius: 10px; z-index: 20; max-width: calc(100% - 32px); pointer-events: none; }
.aviso.mostra { opacity: 1; transform: translateX(-50%); }
.aviso.erro { background: var(--alerta); }

/* Selos */
.selo { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--linha); color: var(--texto); }

/* Agenda */
.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: .75rem; }
.semana a { display: flex; flex-direction: column; align-items: center; padding: 6px 0; border-radius: 10px; text-decoration: none; color: var(--texto); background: var(--cartao); font-size: .75rem; min-height: 56px; }
.semana a strong { font-size: 1.05rem; }
.semana a small { color: var(--cor); font-weight: 700; min-height: 1em; }
.semana a.hoje { outline: 1px solid var(--cor); }
.semana a.ativo { background: var(--cor); color: var(--cor-texto); }
.semana a.ativo small { color: inherit; }
.dia-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.dia-nav strong { text-align: center; flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; border: 1px solid var(--linha); background: var(--cartao); border-radius: 999px; padding: .35rem .8rem; min-height: 36px; cursor: pointer; font-size: .9rem; }
a.chip { text-decoration: none; color: var(--texto); }
.chip.ativo, a.chip.ativo { background: var(--cor); color: var(--cor-texto); border-color: transparent; }
.linha-titulo { flex-wrap: wrap; }
details summary { cursor: pointer; min-height: 32px; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 0 0 .2rem; }
.item.ag { border-left: 4px solid var(--cor); border-radius: var(--raio); }
.ag-hora { display: flex; flex-direction: column; font-weight: 700; min-width: 3.2rem; }
.ag-hora small { font-weight: 400; color: var(--suave); }
.item.apagado { opacity: .55; }
.item.apagado .item-titulo { text-decoration: line-through; }
.item.livre { border: 1.5px dashed color-mix(in srgb, var(--cor) 55%, transparent); border-radius: var(--raio); color: var(--cor); }
.item.livre .item-titulo { color: var(--cor); }
.sugestoes { list-style: none; margin: .25rem 0 0; padding: 0; }
.sugestoes button { width: 100%; text-align: left; background: var(--fundo); border: 0; border-radius: 8px; padding: .6rem .75rem; margin-bottom: 4px; cursor: pointer; min-height: 44px; }

/* Hoje */
.tarefa-botoes { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: 0 14px 12px 64px; }

/* Financeiro */
.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.numero { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 12px 14px; }
.numero span { display: block; font-size: .8rem; color: var(--suave); }
.numero strong { display: block; font: 700 1.25rem Outfit, sans-serif; margin-top: 2px; }
.numero.destaque { grid-column: 1 / -1; border-left: 4px solid var(--cor); }
.numero.destaque strong { font-size: 1.6rem; }
.barra-linha { display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: .6rem; padding: .35rem 0; color: inherit; text-decoration: none; }
.barra-nome { font-weight: 600; font-size: .9rem; }
.barra-trilho { height: 10px; background: var(--linha); border-radius: 999px; overflow: hidden; }
.barra-cheia { display: block; height: 100%; background: var(--cor); border-radius: 999px; min-width: 2px; }
.barra-valor { text-align: right; font-weight: 600; font-size: .9rem; display: flex; flex-direction: column; }
.barra-valor small { font-weight: 400; font-size: .75rem; }
.positivo { color: var(--ok); } .negativo { color: var(--alerta); }

/* Login */
.login { max-width: 380px; margin: 10vh auto 0; }
.login .marca { text-align: center; margin-bottom: 1.25rem; }

/* Tema forçado pela marca da conta (config.visual.tema) */
:root[data-tema="escuro"] { --fundo: #0F0F0F; --cartao: #1B1B1B; --texto: #F2EFE8; --suave: #A9A39A; --linha: #2E2E2E; --sombra: none; color-scheme: dark; }
:root[data-tema="claro"] { --fundo: #F5F5F3; --cartao: #fff; --texto: #23262A; --suave: #6B7075; --linha: #E3E3DF; color-scheme: light; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
