:root {
  --azul: #0e4d7a; --azul2: #1d6fa5; --fundo: #f1f5f9; --cartao: #fff; --texto: #0f172a; --suave: #64748b;
  --borda: #e2e8f0; --verde: #15803d; --vermelho: #b91c1c; --amarelo: #a16207;
  --topo: calc(54px + env(safe-area-inset-top)); --baixo: calc(62px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-top: var(--topo); padding-bottom: var(--baixo); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }

#topo { position: fixed; top: 0; left: 0; right: 0; z-index: 10; height: var(--topo); padding: env(safe-area-inset-top) 6px 0;
  display: flex; align-items: center; gap: 4px; background: var(--azul); color: #fff; }
#topo h1 { flex: 1; margin: 0 8px; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icone { background: none; border: 0; color: inherit; font-size: 24px; width: 44px; height: 44px; border-radius: 22px; cursor: pointer; }
#topo .icone:active { background: rgba(255,255,255,.15); }
#voltar { font-size: 34px; line-height: 1; }

#tela { padding: 12px; max-width: 640px; margin: 0 auto; }
#abas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; height: var(--baixo); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: #fff; border-top: 1px solid var(--borda); }
#abas button { flex: 1; border: 0; background: none; color: var(--suave); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
#abas button span { font-size: 21px; line-height: 1; }
#abas button.ativa { color: var(--azul); font-weight: 600; }

.cartao { background: var(--cartao); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.cartao h3 { margin: 0 0 8px; font-size: 16px; }
.cartao.clicavel { cursor: pointer; }
.cartao.clicavel:active { background: #f8fafc; }
.suave { color: var(--suave); font-size: 14px; }
.pequeno { font-size: 13px; }
.linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.linha + .linha { margin-top: 6px; }
.linha > :first-child { min-width: 0; }
.linha > :last-child:not(:first-child) { white-space: nowrap; text-align: right; }
.lista > div { padding: 10px 0; border-top: 1px solid var(--borda); }
.lista > div:first-child { border-top: 0; }
.verde { color: var(--verde); } .vermelho { color: var(--vermelho); } .amarelo { color: var(--amarelo); }
.forte { font-weight: 600; }
.selo { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e0f2fe; color: var(--azul); font-weight: 600; }
.selo.cinza { background: #f1f5f9; color: var(--suave); }
.bola { display: inline-block; width: 12px; height: 12px; border-radius: 6px; vertical-align: middle; margin-right: 6px; flex: none; }
.vazio { text-align: center; color: var(--suave); padding: 24px 8px; }

.botao { display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px 16px; background: var(--azul); color: #fff; font-weight: 600; cursor: pointer; text-align: center; }
.botao:active { background: var(--azul2); }
.botao:disabled { opacity: .5; }
.botao.claro { background: #e0f2fe; color: var(--azul); }
.botao.perigo { background: #fee2e2; color: var(--vermelho); }
.botao + .botao, .botoes { margin-top: 8px; }
.botoes { display: flex; gap: 8px; } .botoes .botao { margin: 0; }
.link { background: none; border: 0; color: var(--azul2); padding: 4px 0; cursor: pointer; font-weight: 600; }

label { display: block; font-size: 14px; color: var(--suave); margin: 12px 0 4px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul2); border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; color: var(--texto); font-size: 16px; margin: 14px 0 4px; }
.check input { width: 22px; height: 22px; }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.erro { color: var(--vermelho); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* entrada */
.entrada { max-width: 380px; margin: 8vh auto 0; }
.entrada .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 12px; }
.entrada h2 { text-align: center; margin: 0 0 4px; }

/* calendário */
.mes-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mes-nav h3 { margin: 0; text-transform: capitalize; }
.mes-nav .icone { color: var(--azul); font-size: 28px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .sem { text-align: center; font-size: 12px; color: var(--suave); padding-bottom: 2px; }
.dia { aspect-ratio: 1 / 1.05; border-radius: 10px; border: 1px solid var(--borda); background: #fff; padding: 3px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; font-size: 14px; cursor: pointer; position: relative; overflow: hidden; }
.dia .n { font-weight: 600; }
.dia .quem { font-size: 10px; font-weight: 700; color: #fff; border-radius: 6px; padding: 1px 4px; margin-top: 2px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dia.fora { visibility: hidden; }
.dia.passado { background: #f8fafc; color: #94a3b8; cursor: default; }
.dia.passado .quem { opacity: .55; }
.dia.hoje { border: 2px solid var(--azul); }
.dia.meu { box-shadow: inset 0 0 0 2px #fbbf24; }
.dia.livre:active { background: #e0f2fe; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; }
.contador { display: flex; gap: 6px; align-items: center; }
.contador i { width: 22px; height: 8px; border-radius: 4px; background: #e2e8f0; display: inline-block; }
.contador i.cheio { background: #fbbf24; }

/* modal (folha de baixo) */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
#modal[hidden] { display: none; }
.folha { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 6px 16px calc(18px + env(safe-area-inset-bottom)); animation: sobe .18s ease-out; }
.folha-topo { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; padding-top: 8px; z-index: 1; }
.folha-topo h2 { font-size: 18px; margin: 0; }
.folha-topo .icone { color: var(--suave); font-size: 20px; }
@keyframes sobe { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }

#aviso { position: fixed; left: 12px; right: 12px; top: calc(var(--topo) + 8px); z-index: 30; background: #0f172a; color: #fff; padding: 12px 14px; border-radius: 12px; text-align: center; max-width: 520px; margin: 0 auto; }
#aviso.erro { background: var(--vermelho); }
.carregando { text-align: center; color: var(--suave); padding: 40px; }
.valor-grande { font-size: 26px; font-weight: 700; }
pre.texto { white-space: pre-wrap; background: #f8fafc; border-radius: 10px; padding: 12px; font: 14px/1.45 inherit; font-family: inherit; max-height: 45vh; overflow: auto; }
.senha-mostrar { font-size: 26px; font-weight: 700; letter-spacing: 2px; text-align: center; background: #fef9c3; border-radius: 12px; padding: 14px; margin: 10px 0; user-select: all; }
[hidden] { display: none !important; }
a { color: var(--azul2); text-decoration: none; font-weight: 600; }
.check input { flex: none; }
