/* MEI em Dia — mesmo visual da página de validação (Space Grotesk + Manrope, azul-marinho + amarelo) */
:root {
  --bg: #F3F5FA; --surface: #FFFFFF; --surface-2: #F3F5FA; --ink: #0B1B3F; --ink-2: #3A4664; --muted: #55607A;
  --line: #DDE3EF; --track: #E4E9F4; --navy: #0B1B3F; --navy-ink: #FFFFFF; --navy-muted: #C8D1E6;
  --accent: #FFC93C; --accent-ink: #0B1B3F; --blue: #1D4ED8; --blue-soft: #E8EEFF;
  --warn-bg: #FFF6D9; --warn-ink: #7A5500; --warn-bar: #E0A100;
  --danger-bg: #FDECEA; --danger-ink: #9A1C12; --danger-bar: #C8321F;
  --ok-bg: #E3F5EC; --ok-ink: #0B6B40; --info-bg: #E8EEFF; --info-ink: #1D3FA8;
  --shadow: 0 10px 30px rgba(11, 27, 63, .08);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #081022; --surface: #111B33; --surface-2: #0C152B; --ink: #E9EEF8; --ink-2: #C3CCE0; --muted: #9AA6C2;
    --line: #25335A; --track: #22304F; --navy: #0E214D; --navy-ink: #FFFFFF; --navy-muted: #C8D1E6;
    --accent: #FFC93C; --accent-ink: #0B1B3F; --blue: #8CAEFF; --blue-soft: #1A2A55;
    --warn-bg: #3A2E0A; --warn-ink: #FFD873; --warn-bar: #F2B92B;
    --danger-bg: #3D1512; --danger-ink: #FFB4AB; --danger-bar: #FF6B5A;
    --ok-bg: #0E3324; --ok-ink: #8CE5B9; --info-bg: #1A2A55; --info-ink: #B9CCFF;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
h1, h2, h3, .num { font-family: 'Space Grotesk', 'Manrope', sans-serif; letter-spacing: -0.01em; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* faixa demo */
.demo-faixa { background: var(--accent); color: var(--accent-ink); text-align: center; font-weight: 800; font-size: 14px; padding: 8px 16px; }

/* topo */
.topo { background: var(--navy); color: var(--navy-ink); position: sticky; top: 0; z-index: 10; }
.topo-in { max-width: 680px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.marca { display: flex; align-items: center; gap: 10px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 20px; }
.marca-ico { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.topo-nome { font-size: 13px; color: var(--navy-muted); text-align: right; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 680px; margin: 0 auto; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.card-tit { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: 14px; }
.texto { color: var(--ink-2); }
.pequeno { font-size: 13px; color: var(--muted); }

/* painel principal */
.hero { background: var(--navy); color: var(--navy-ink); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.hero .sub { color: var(--navy-muted); }
.hero-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hero-valor { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: clamp(34px, 10vw, 44px); line-height: 1; }
.barra { height: 14px; background: rgba(255, 255, 255, .16); border-radius: 99px; overflow: hidden; position: relative; }
.barra > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
.barra.perto > span { background: #FFB020; }
.barra.estourou > span { background: #FF6B5A; }
.barra-leg { display: flex; justify-content: space-between; font-size: 13px; color: var(--navy-muted); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: rgba(255, 255, 255, .08); border-radius: 14px; padding: 12px; min-width: 0; }
.tile-l { font-size: 13px; color: var(--navy-muted); }
.tile-v { font-weight: 800; font-size: clamp(17px, 5vw, 21px); overflow-wrap: anywhere; }
.tile-v small { font-weight: 600; font-size: 13px; }
.tile.alerta-t { background: rgba(255, 107, 90, .22); }

select.ano-sel { background: rgba(255, 255, 255, .12); color: var(--navy-ink); border: 1px solid rgba(255, 255, 255, .25); border-radius: 12px; padding: 8px 10px; min-height: 44px; font-weight: 700; }
select.ano-sel option { color: #0B1B3F; background: #fff; }
.card select.ano-sel { background: var(--surface-2); color: var(--ink); border-color: var(--line); }

/* alertas */
.alertas { display: flex; flex-direction: column; gap: 10px; }
.alerta { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; background: var(--info-bg); color: var(--ink); }
.alerta svg { flex-shrink: 0; margin-top: 2px; }
.alerta b { display: block; }
.alerta p { font-size: 15px; color: var(--ink-2); }
.alerta .lnk { margin-top: 6px; }
.alerta.perigo { background: var(--danger-bg); } .alerta.perigo svg { color: var(--danger-ink); } .alerta.perigo b { color: var(--danger-ink); }
.alerta.atencao { background: var(--warn-bg); } .alerta.atencao svg { color: var(--warn-ink); } .alerta.atencao b { color: var(--warn-ink); }
.alerta.lembrete { background: var(--warn-bg); } .alerta.lembrete svg { color: var(--warn-ink); }
.alerta.info svg { color: var(--info-ink); }
.alerta.ok { background: var(--ok-bg); } .alerta.ok svg, .alerta.ok b { color: var(--ok-ink); }

/* botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 800; cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover { border-color: var(--blue); }
.btn-pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-pri:hover { filter: brightness(.97); border-color: var(--accent); }
.btn-navy { background: var(--navy); color: var(--navy-ink); border-color: var(--navy); }
.btn-perigo { color: var(--danger-ink); }
.btn-grande { min-height: 58px; font-size: 18px; width: 100%; }
.btn-bloco { width: 100%; }
.btn-peq { min-height: 44px; padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.lnk { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 700; cursor: pointer; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }
.acoes { display: flex; gap: 10px; flex-wrap: wrap; }
.acoes > .btn { flex: 1 1 160px; }

/* gráfico mensal */
.graf { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; position: relative; padding-top: 8px; }
.graf-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; min-width: 0; min-height: 44px; }
.graf-area { height: 120px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.graf-bar { display: block; width: 100%; max-width: 30px; background: var(--blue); border-radius: 6px 6px 3px 3px; }
.graf-col.acima .graf-bar { background: var(--warn-bar); }
.graf-col.inativo { opacity: .35; cursor: default; }
.graf-col.atual .graf-m { color: var(--ink); font-weight: 800; }
.graf-m { font-size: 11px; line-height: 18px; height: 18px; color: var(--muted); }
.graf-ref { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); opacity: .6; pointer-events: none; }
.graf-wrap { position: relative; }

/* formulário */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > label, .rot { font-weight: 700; font-size: 15px; }
.inp { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 16px; }
.inp:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
textarea.inp { min-height: 80px; resize: vertical; }
.valor-wrap { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 16px; padding: 4px 14px; background: var(--surface); }
.valor-wrap:focus-within { border-color: var(--blue); }
.valor-wrap span { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 24px; color: var(--muted); }
.valor-inp { border: 0; background: transparent; width: 100%; font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 36px; min-height: 60px; padding: 0; color: var(--ink); outline: none; }
.linha2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; cursor: pointer; color: var(--ink-2); padding: 6px 8px; }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--navy-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--ink); }
.opcoes { display: grid; gap: 10px; }
.opcao { display: flex; gap: 12px; align-items: flex-start; border: 2px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; background: var(--surface); }
.opcao input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--blue); flex-shrink: 0; }
.opcao:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.opcao b { display: block; }
.erro { color: var(--danger-ink); font-weight: 700; font-size: 14px; }

/* listas */
.lista { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item-t { font-weight: 700; overflow-wrap: anywhere; }
.item-s { font-size: 13px; color: var(--muted); }
.item-v { font-weight: 800; white-space: nowrap; font-family: 'Space Grotesk', sans-serif; }
.ico-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-2); flex-shrink: 0; }
.ico-btn:hover { border-color: var(--blue); color: var(--blue); }
.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mes-nav strong { font-family: 'Space Grotesk', sans-serif; font-size: 18px; text-transform: capitalize; text-align: center; }
.selo { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.selo.pago { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.selo.atrasado { background: var(--danger-bg); color: var(--danger-ink); border-color: transparent; }
.selo.aberto { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.selo.nota { background: var(--blue-soft); color: var(--ink); border-color: transparent; }
.vazio { text-align: center; color: var(--muted); padding: 18px 8px; }
.total-linha { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; padding-top: 10px; border-top: 2px solid var(--line); }

/* checklist */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.check:first-child { border-top: 0; }
.check input { width: 24px; height: 24px; accent-color: var(--blue); flex-shrink: 0; margin: 0; }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }

/* abas internas */
.abas { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.abas .chip { white-space: nowrap; flex-shrink: 0; }

/* tabela de prévia */
.tab { width: 100%; border-collapse: collapse; font-size: 14px; }
.tab th, .tab td { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.tab td.v, .tab th.v { text-align: right; white-space: nowrap; }
.tab tr.tot td { font-weight: 800; background: var(--surface-2); }
.tab-wrap { overflow-x: auto; }

/* guias */
details.guia { border: 1px solid var(--line); border-radius: 14px; padding: 0 16px; background: var(--surface); }
details.guia summary { font-weight: 800; min-height: 52px; display: flex; align-items: center; cursor: pointer; }
details.guia[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
details.guia .conteudo { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; color: var(--ink-2); }
details.guia ol, details.guia ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
details.guia h4 { margin: 6px 0 0; color: var(--ink); font-size: 16px; }

/* navegação inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-in { max-width: 680px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav button { background: none; border: 0; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; padding: 6px 2px; }
.nav button[aria-current="page"] { color: var(--ink); }
.nav button[aria-current="page"] .nav-ico { background: var(--accent); color: var(--accent-ink); }
.nav-ico { width: 44px; height: 28px; border-radius: 99px; display: flex; align-items: center; justify-content: center; }
.nav .nav-lancar .nav-ico { background: var(--navy); color: var(--navy-ink); }

/* toast e modal */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 40; background: var(--navy); color: var(--navy-ink); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); width: max-content; box-shadow: var(--shadow); font-weight: 600; }
.toast button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; font-weight: 800; min-height: 40px; padding: 6px 12px; cursor: pointer; }
.modal-fundo { position: fixed; inset: 0; background: rgba(5, 12, 30, .55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.modal { background: var(--surface); color: var(--ink); border-radius: 20px; padding: 20px; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; margin-bottom: env(safe-area-inset-bottom); }
@media (min-width: 600px) { .modal-fundo { align-items: center; } }

.rodape { text-align: center; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; padding: 4px 8px; }
.boas { display: flex; flex-direction: column; gap: 16px; }
.boas-hero { background: var(--navy); color: var(--navy-ink); border-radius: 24px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.boas-hero h1 { font-size: clamp(26px, 7vw, 34px); }
.boas-hero p { color: var(--navy-muted); }

/* prévia de documento (tela) */
.doc-previa { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fff; color: #111; overflow-x: auto; }
.doc-previa .doc { font-size: 13px; }

/* ---------- documento impresso ---------- */
#print-area { display: none; }
.doc { font-family: 'Manrope', Arial, sans-serif; color: #111; line-height: 1.4; }
.doc h1 { font-family: 'Space Grotesk', Arial, sans-serif; font-size: 18px; text-align: center; margin: 0 0 10px; text-transform: uppercase; }
.doc .doc-cab { border: 1px solid #333; padding: 8px 10px; margin-bottom: 10px; display: grid; gap: 4px; }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.doc th, .doc td { border: 1px solid #333; padding: 6px 8px; text-align: left; vertical-align: top; }
.doc td.v, .doc th.v { text-align: right; white-space: nowrap; width: 28%; }
.doc .sec td { background: #eee; font-weight: 800; }
.doc .tot td { font-weight: 800; }
.doc .ass { margin-top: 36px; display: grid; gap: 24px; }
.doc .ass-linha { border-top: 1px solid #333; padding-top: 4px; text-align: center; max-width: 320px; }
.doc .nota { font-size: 11px; color: #333; margin-top: 8px; }
.doc .grande { font-size: 22px; font-weight: 800; font-family: 'Space Grotesk', Arial, sans-serif; }
.doc .caixa { border: 1px solid #333; padding: 12px; margin-bottom: 10px; }
.doc .marca-doc { display: flex; justify-content: space-between; gap: 10px; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 12px; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff !important; padding: 0 !important; color: #111; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  .doc { font-size: 12px; }
}
