:root {
  --fundo: #f4f6f8; --cartao: #ffffff; --texto: #1d2733; --suave: #5d6b7a; --linha: #dde3e9;
  --primaria: #1f5f8b; --primaria-texto: #fff; --perigo: #b42318; --ok: #157347; --alerta: #b54708;
  --sombra: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #12171d; --cartao: #1b222b; --texto: #e6ebf0; --suave: #9aa8b6; --linha: #2c3642;
    --primaria: #5aa6dc; --primaria-texto: #0b1620; --perigo: #f97066; --ok: #47cd89; --alerta: #fdb022;
    --sombra: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primaria); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.carregando { padding: 2rem; text-align: center; color: var(--suave); }
header { background: var(--cartao); border-bottom: 1px solid var(--linha); position: sticky; top: 0; z-index: 5; }
.topo { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.marca { font-weight: 700; color: var(--primaria); margin-right: auto; }
.quem { color: var(--suave); font-size: .9rem; }
nav { display: flex; gap: .25rem; overflow-x: auto; padding: 0 1rem; max-width: 1200px; margin: 0 auto; }
nav button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .55rem .8rem; color: var(--suave); font: inherit; cursor: pointer; white-space: nowrap; }
nav button.ativo { color: var(--primaria); border-bottom-color: var(--primaria); font-weight: 600; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.cartao { background: var(--cartao); border: 1px solid var(--linha); border-radius: 10px; padding: 1rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.linha { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.linha > label { flex: 1 1 180px; }
label { display: block; font-size: .85rem; color: var(--suave); }
input, select, textarea { width: 100%; font: inherit; color: var(--texto); background: var(--cartao); border: 1px solid var(--linha); border-radius: 7px; padding: .5rem .6rem; margin-top: .2rem; }
textarea { min-height: 80px; resize: vertical; }
button.btn, a.btn { display: inline-block; font: inherit; border: 1px solid var(--linha); background: var(--cartao); color: var(--texto); border-radius: 7px; padding: .5rem .9rem; cursor: pointer; }
button.btn.primario, a.btn.primario { background: var(--primaria); color: var(--primaria-texto); border-color: var(--primaria); }
button.btn.perigo { color: var(--perigo); }
button.btn.pequeno, a.btn.pequeno { padding: .25rem .55rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }
.tabela { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { color: var(--suave); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; }
.etiqueta { display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .78rem; border: 1px solid currentColor; }
.etiqueta.aberta { color: var(--alerta); } .etiqueta.respondida { color: var(--primaria); } .etiqueta.concluida { color: var(--ok); }
.ok { color: var(--ok); } .erro { color: var(--perigo); } .suave { color: var(--suave); }
.numero-grande { font-size: 1.6rem; font-weight: 700; }
.login { max-width: 380px; margin: 8vh auto; }
.login form > * { margin-bottom: .7rem; }
#aviso { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); background: var(--texto); color: var(--fundo); padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#aviso.visivel { opacity: 1; }
.pendencia { border-left: 4px solid var(--linha); padding-left: .75rem; margin: .75rem 0; }
.pendencia.aberta { border-left-color: var(--alerta); } .pendencia.respondida { border-left-color: var(--primaria); } .pendencia.concluida { border-left-color: var(--ok); }
.acoes { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
@media (max-width: 600px) { main { padding: .75rem 16px; } .topo { padding: .5rem 16px; } }

/* Telas mostradas dentro do app completo (painel/): sem cabeçalho próprio, com as cores e letras dele. */
body.embutido {
  --fundo: #F3F5F4; --cartao: #FFFFFF; --texto: #15222C; --suave: #5A6971; --linha: #D8E0DD; --primaria: #1E5C78;
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
html[data-theme="dark"] body.embutido {
  --fundo: #0E1418; --cartao: #161F25; --texto: #E4ECEF; --suave: #93A3AB; --linha: #2A373E; --primaria: #62B4D4; --primaria-texto: #062430;
}
body.embutido header { position: static; background: transparent; border: 0; }
body.embutido .marca, body.embutido .quem { display: none; }
body.embutido .topo, body.embutido nav, body.embutido main { max-width: none; padding-left: 0; padding-right: 0; }
body.embutido .topo { justify-content: flex-start; padding-top: 0; }

/* Logomarca da Exame (fundo branco também no modo escuro, como no app completo) */
.logo-login { display: block; height: 72px; width: auto; max-width: 100%; margin: 0 auto 1rem; background: #fff; border-radius: 10px; padding: 4px 8px; }
.login h1 { text-align: center; }
.logo-topo { display: block; height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px 6px; }

/* Tela de entrada: fundo em degradê azul-marinho com detalhe dourado (cores da logomarca) */
body:has(.login) {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(80, 140, 200, .25), transparent 60%),
    linear-gradient(135deg, #0b1f3a 0%, #13325a 55%, #1c4677 100%);
  background-attachment: fixed;
}
body:has(.login) #app { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login.cartao {
  --fundo: #f4f6f8; --cartao: #ffffff; --texto: #1d2733; --suave: #5d6b7a; --linha: #dde3e9; --primaria: #13325a; --primaria-texto: #fff;
  background: var(--cartao); color: var(--texto); margin: 0; width: 100%;
  border: 0; border-top: 4px solid #c9a227; border-radius: 14px; padding: 2rem 1.75rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.login .logo-login { padding: 0; margin-bottom: .75rem; }
.login > .suave:first-of-type { text-align: center; margin-top: 0; }

/* Painel da prefeitura (gestor) */
.painel-topo { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.resumo-g { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.destaque .rotulo { font-size: .9rem; color: var(--suave); font-weight: 600; }
.destaque .numero { font-size: 1.7rem; font-weight: 700; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.destaque.st-ok { border-left: 5px solid var(--ok); }
.destaque.st-bad { border-left: 5px solid var(--perigo); }
.t-bad { color: var(--perigo); }
.ind-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.ind { border-top: 5px solid var(--linha); display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.ind.st-ok { border-top-color: var(--ok); } .ind.st-warn { border-top-color: var(--alerta); } .ind.st-bad { border-top-color: var(--perigo); }
.ind-nome { font-weight: 700; }
.ind-valor { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ind-chip { align-self: flex-start; font-size: .85rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--fundo); }
.st-ok .ind-chip { background: #e3f4ea; color: #0f5132; } .st-warn .ind-chip { background: #fdf0d5; color: #7a4a00; } .st-bad .ind-chip { background: #fde4e1; color: #8a1c13; }
.ind-regra { font-size: .9rem; } .ind-falta { font-size: .9rem; font-weight: 600; }
.ind-exp { font-size: .85rem; color: var(--suave); }
.ind-lei summary { font-size: .85rem; color: var(--primaria); cursor: pointer; } .ind-lei p { font-size: .85rem; margin: .4rem 0 0; }
.legenda { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .9rem; margin-bottom: .5rem; }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.graf-caixa { position: relative; }
.graf { width: 100%; height: auto; display: block; }
.graf .eixo { font-size: 11px; fill: var(--suave); }
.graf .grade-l { stroke: var(--linha); stroke-width: 1; }
.graf .base-l { stroke: var(--suave); stroke-width: 1; }
.graf .alvo { cursor: default; }
.dica { position: absolute; pointer-events: none; background: var(--texto); color: var(--cartao); font-size: .8rem; padding: .3rem .55rem; border-radius: 6px; white-space: nowrap; }
.tabela-graf { margin-top: .6rem; } .tabela-graf summary { font-size: .85rem; color: var(--primaria); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .graf-caixa { overflow-x: auto; }
  .graf { min-width: 600px; }
}
.acesso-pronto { border-left: 5px solid var(--ok); }
.acesso-pronto pre { background: var(--fundo); padding: .6rem .8rem; border-radius: 8px; font-size: 1rem; margin: .6rem 0; white-space: pre-wrap; }
details.cartao > summary { cursor: pointer; }
