/* Temas: claro (base), escuro, sépia e automático (segue o sistema). O tema fica em <html data-tema="…">. */
:root, :root[data-tema="claro"] {
  --fundo: #f4f5f7; --painel: #ffffff; --texto: #1c2430; --suave: #647082; --linha: #e1e5eb; --linha-forte: #c9d0da;
  --acento: #1f5fbf; --acento-fundo: #e8f0fc; --sobre-acento: #ffffff;
  --bom: #1d8a57; --ruim: #c2412d; --alerta-fundo: #fdf1ec;
  --calor-0: #e7eaef; --calor-1: #b9d3f5; --calor-2: #7fb0ec; --calor-3: #3f85d9; --calor-4: #174f9f;
  --sombra: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .05);
  --veu: rgba(10, 15, 25, .5);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema]), :root[data-tema="auto"] {
    --fundo: #12161c; --painel: #1b212a; --texto: #e7ebf1; --suave: #9aa6b6; --linha: #2b3440; --linha-forte: #3b4655;
    --acento: #6ea8f7; --acento-fundo: #1f2f47; --sobre-acento: #0d1522;
    --bom: #4cc38a; --ruim: #f0836f; --alerta-fundo: #3a2520;
    --calor-0: #252d38; --calor-1: #1f3c63; --calor-2: #295a99; --calor-3: #3f85d9; --calor-4: #8fc0ff;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3);
    --veu: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-tema="escuro"] {
  --fundo: #12161c; --painel: #1b212a; --texto: #e7ebf1; --suave: #9aa6b6; --linha: #2b3440; --linha-forte: #3b4655;
  --acento: #6ea8f7; --acento-fundo: #1f2f47; --sobre-acento: #0d1522;
  --bom: #4cc38a; --ruim: #f0836f; --alerta-fundo: #3a2520;
  --calor-0: #252d38; --calor-1: #1f3c63; --calor-2: #295a99; --calor-3: #3f85d9; --calor-4: #8fc0ff;
  --sombra: 0 1px 2px rgba(0, 0, 0, .3);
  --veu: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
:root[data-tema="sepia"] {
  --fundo: #f3ead6; --painel: #fbf6ea; --texto: #3a2e1f; --suave: #76664f; --linha: #e6dabf; --linha-forte: #d3c2a0;
  --acento: #8a4a12; --acento-fundo: #f1e1c4; --sobre-acento: #fffaf0;
  --bom: #3d7a35; --ruim: #b23e1c; --alerta-fundo: #f6dfcd;
  --calor-0: #e9dec5; --calor-1: #e3cb9c; --calor-2: #d2a964; --calor-3: #ad7a30; --calor-4: #6f4a12;
  --sombra: 0 1px 2px rgba(70, 50, 20, .08), 0 4px 14px rgba(70, 50, 20, .06);
  --veu: rgba(40, 28, 10, .45);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--fundo); color: var(--texto); display: flex; min-height: 100vh; line-height: 1.45; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; margin-bottom: .8rem; }
small { color: var(--suave); font-size: .82rem; }
a { color: var(--acento); }
[hidden] { display: none !important; }
.suave { color: var(--suave); } .centro { text-align: center; } .nowrap { white-space: nowrap; }
.ruim { color: var(--ruim); font-weight: 600; }
.n { text-align: right; font-variant-numeric: tabular-nums; }

/* navegação */
#nav { width: 210px; flex: none; background: var(--painel); border-right: 1px solid var(--linha); padding: 1.1rem .9rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; }
.marca { display: flex; gap: .6rem; align-items: center; padding: 0 .3rem; }
.marca small { display: block; line-height: 1; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--acento); color: var(--sobre-acento); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
#nav-links { display: flex; flex-direction: column; gap: 2px; }
#nav-links a { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; border-radius: 8px; color: var(--texto); text-decoration: none; }
#nav-links a:hover { background: var(--fundo); }
#nav-links a.ativo { background: var(--acento-fundo); color: var(--acento); font-weight: 600; }
#status-salvar { margin-top: auto; padding: 0 .3rem; min-height: 1.2em; }
main { flex: 1; min-width: 0; }
.pagina { max-width: 1120px; margin: 0 auto; padding: 1.6rem 1.6rem 4rem; display: flex; flex-direction: column; gap: 1rem; }
.pagina.estreita { max-width: 780px; }
.topo { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .3rem; }
.carregando { padding: 3rem; color: var(--suave); }

/* botões e campos */
button, .botao { font: inherit; border-radius: 8px; border: 1px solid transparent; padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
button:disabled { opacity: .45; cursor: default; }
.pri { background: var(--acento); color: var(--sobre-acento); font-weight: 600; }
.pri:hover { filter: brightness(1.08); }
.sec { background: var(--painel); color: var(--texto); border-color: var(--linha-forte); }
.sec:hover:not(:disabled) { background: var(--fundo); }
.grande { padding: .75rem 1.3rem; font-size: 1.05rem; }
.mini { padding: .15rem .5rem; background: transparent; border-color: var(--linha-forte); color: var(--texto); font-size: .9rem; min-width: 30px; }
.mini:hover { background: var(--acento-fundo); border-color: var(--acento); }
.icone { background: transparent; color: var(--suave); padding: .3rem .5rem; }
.icone:hover { color: var(--texto); background: var(--fundo); }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--texto); background: var(--painel); border: 1px solid var(--linha-forte); border-radius: 7px; padding: .45rem .6rem; max-width: 100%; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--acento); }
input.curto { width: 5.2rem; text-align: right; }
select.inline { padding: .15rem .4rem; }
.acoes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.acoes-linha { display: flex; gap: .25rem; justify-content: flex-end; white-space: nowrap; }

/* cartões */
.cartao { background: var(--painel); border: 1px solid var(--linha); border-radius: 12px; padding: 1.1rem 1.2rem; box-shadow: var(--sombra); }
.duas { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; align-items: start; }
.duas > div { display: flex; flex-direction: column; gap: 1rem; }
.destaque { border-left: 5px solid var(--acento); display: flex; flex-direction: column; gap: .5rem; }
.etiqueta { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--acento); font-weight: 700; }
.acao-topico { font-size: 1.05rem; }
.destaque .acoes { margin-top: .5rem; }
.contagem { text-align: right; } .contagem strong { font-size: 2rem; display: block; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi { background: var(--painel); border: 1px solid var(--linha); border-radius: 12px; padding: .9rem 1.1rem; display: flex; flex-direction: column; box-shadow: var(--sombra); }
.kpi strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.kpi-rot, .kpi-sub { color: var(--suave); font-size: .82rem; }
.kpi.alerta { background: var(--alerta-fundo); } .kpi.alerta strong { color: var(--ruim); }
.contador { background: var(--acento); color: var(--sobre-acento); border-radius: 99px; font-size: .75rem; padding: .05rem .5rem; font-weight: 700; vertical-align: middle; }
.vazio { color: var(--suave); padding: .4rem 0; }
.aneis { display: flex; justify-content: space-around; gap: 1rem; margin-bottom: .6rem; }
.anel { position: relative; width: 132px; height: 132px; }
.anel svg { width: 100%; height: 100%; }
.anel circle { fill: none; stroke-width: 8; }
.anel-fundo { stroke: var(--calor-0); } .anel-valor { stroke: var(--acento); stroke-linecap: round; } .anel-valor.cheio { stroke: var(--bom); }
.anel-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.anel-txt strong { font-size: 1.25rem; } .anel-txt span { font-size: .72rem; color: var(--suave); max-width: 80px; }

/* listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista.numerada { counter-reset: n; }
.lista.numerada li::before { counter-increment: n; content: counter(n); color: var(--suave); width: 1.4rem; flex: none; }
.lista li { display: flex; justify-content: space-between; gap: .8rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--linha); }
.lista li:first-child { border-top: 0; }
.lista li > div:first-child { min-width: 0; flex: 1; }
.erro-item p { margin-top: .25rem; white-space: pre-wrap; }
.resposta { background: var(--acento-fundo); border-radius: 8px; padding: .5rem .7rem; }
.insights { margin: 0; display: grid; grid-template-columns: 11rem 1fr; gap: .55rem 1rem; }
.insights dt { color: var(--suave); } .insights dd { margin: 0; }
.fila, .chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip { border: 1px solid var(--linha-forte); border-left-width: 4px; border-radius: 6px; padding: .15rem .5rem; font-size: .85rem; }
.chip.atual { background: var(--acento-fundo); font-weight: 600; }
.chip-btn { background: var(--painel); border: 1px solid var(--linha-forte); color: var(--texto); padding: .25rem .7rem; border-radius: 99px; font-size: .88rem; }
.chip-btn.ativo { background: var(--acento); color: var(--sobre-acento); border-color: var(--acento); }
.filtros { display: flex; flex-direction: column; gap: .7rem; } .filtros .chips { margin: 0; }
.linha-config { display: flex; gap: .7rem 1rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.linha-config input[type=text], .linha-config input[type=search] { flex: 1; min-width: 200px; }
.filtros .linha-config { margin: 0; }

/* barras */
.barra { position: relative; height: 8px; background: var(--calor-0); border-radius: 99px; min-width: 70px; }
.barra i { display: block; height: 100%; border-radius: 99px; background: var(--acento); }
.barra b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--texto); }
.col-barra { width: 22%; }
.bolinha { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .5rem; flex: none; }

/* tabelas */
.rolagem { overflow-x: auto; }
.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th { text-align: left; font-weight: 600; color: var(--suave); font-size: .8rem; padding: .4rem .6rem; border-bottom: 1px solid var(--linha-forte); white-space: nowrap; }
.tabela th.n { text-align: right; }
.tabela td { padding: .45rem .6rem; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: color-mix(in srgb, var(--acento-fundo) 45%, transparent); }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topicos tr.feito td:nth-child(2) { color: var(--suave); }
.paginacao { display: flex; justify-content: space-between; align-items: center; margin-top: .8rem; }

/* edital */
.disc { padding: 0; }
.disc summary { display: grid; grid-template-columns: auto minmax(0, 2.2fr) 1.3fr .8fr .9fr; gap: 1rem; align-items: center; padding: .85rem 1.2rem; cursor: pointer; list-style: none; }
.disc summary::-webkit-details-marker { display: none; }
.disc summary:hover { background: color-mix(in srgb, var(--acento-fundo) 45%, transparent); border-radius: 12px; }
.disc-nome b, .disc-num b { display: block; } .disc-num { text-align: right; }
.disc-nome small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.det-corpo { padding: 0 1.2rem 1rem; }
.det-corpo .linha-config { margin: .8rem 0 0; }

/* ciclo */
.blocos { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.blocos li { border: 1px solid var(--linha); border-left: 5px solid var(--cor); border-radius: 8px; padding: .55rem .7rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.blocos li.feito { opacity: .5; } .blocos li.feito b { text-decoration: line-through; }
.blocos li.atual { background: var(--acento-fundo); border-color: var(--acento); border-left-color: var(--cor); }
.bloco-info { min-width: 0; } .bloco-info b, .bloco-info small { display: block; }
.bloco-info .sug { color: var(--texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* gráficos */
.grafico { width: 100%; height: auto; display: block; }
.grafico .grade { stroke: var(--linha); stroke-width: 1; }
.grafico .eixo { fill: var(--suave); font-size: 11px; }
.grafico .barra-h { fill: var(--calor-2); } .grafico .barra-h:hover { fill: var(--calor-3); }
.grafico .linha-pct { fill: none; stroke: var(--bom); stroke-width: 2; }
.grafico .ponto-pct { fill: var(--painel); stroke: var(--bom); stroke-width: 2; }
.grafico .meta-linha { stroke: var(--ruim); stroke-width: 1; stroke-dasharray: 4 4; }
.legenda { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; color: var(--suave); font-size: .82rem; margin-top: .5rem; }
.legenda span { display: inline-flex; align-items: center; gap: .35rem; }
.lg-barra { width: 12px; height: 10px; background: var(--calor-2); border-radius: 2px; }
.lg-linha { width: 16px; height: 2px; background: var(--bom); } .lg-meta { width: 16px; border-top: 1px dashed var(--ruim); }
.calor-wrap { overflow-x: auto; }
.calor, .calor-meses { display: flex; gap: 3px; }
.calor-meses span { width: 13px; flex: none; font-size: .7rem; color: var(--suave); overflow: visible; white-space: nowrap; }
.calor-col { display: flex; flex-direction: column; gap: 3px; }
.calor i, .calor-lg { width: 13px; height: 13px; border-radius: 3px; display: block; flex: none; }
.calor i.fora { visibility: hidden; }
.n0 { background: var(--calor-0); } .n1 { background: var(--calor-1); } .n2 { background: var(--calor-2); } .n3 { background: var(--calor-3); } .n4 { background: var(--calor-4); }
.calor-wrap .legenda { gap: 3px; }

/* cronômetro */
#timerbar { position: sticky; top: 0; z-index: 5; background: var(--painel); border-bottom: 2px solid var(--acento); padding: .6rem 1.6rem; display: flex; align-items: center; gap: 1.2rem; box-shadow: var(--sombra); }
.timer-info { flex: 1; min-width: 0; } .timer-info b, .timer-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#timer-relogio { font-size: 1.7rem; font-variant-numeric: tabular-nums; } #timer-relogio.pausado { color: var(--suave); }

/* modal, formulários, aviso */
.modal-fundo { position: fixed; inset: 0; background: var(--veu); display: grid; place-items: center; padding: 1rem; z-index: 20; }
.modal { background: var(--painel); border-radius: 14px; width: min(600px, 100%); max-height: 92vh; overflow: auto; padding: 1.2rem 1.4rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.form { display: flex; flex-direction: column; gap: .8rem; }
.form footer { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.campo { display: flex; flex-direction: column; gap: .25rem; }
.campo > span { font-size: .85rem; color: var(--suave); font-weight: 600; }
.grade-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.check { display: flex; gap: .5rem; align-items: center; }
.erro { color: var(--ruim); min-height: 1.2em; }
#toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translate(-50%, 150%); background: var(--texto); color: var(--fundo); padding: .7rem 1.1rem; border-radius: 10px; transition: transform .25s; z-index: 30; max-width: 90vw; }
#toast.visivel { transform: translate(-50%, 0); }

@media (max-width: 900px) {
  body { flex-direction: column; }
  #nav { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: .6rem .8rem; gap: .6rem; }
  #nav-links { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; }
  #nav-links a { white-space: nowrap; gap: .4rem; }
  #status-salvar { margin: 0 0 0 auto; }
  .pagina { padding: 1rem .9rem 3rem; }
  .duas, .kpis { grid-template-columns: 1fr 1fr; } .duas { grid-template-columns: 1fr; }
  .disc summary { grid-template-columns: auto 1fr auto; } .disc-prog, .disc summary .disc-num:last-child { display: none; }
  .grade-3 { grid-template-columns: 1fr 1fr; } .insights { grid-template-columns: 1fr; gap: .1rem; } .insights dd { margin-bottom: .6rem; }
  #timerbar { flex-wrap: wrap; padding: .6rem .9rem; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* login e primeiro acesso (modo nuvem) */
body.sem-nav #nav, body.sem-nav #timerbar { display: none !important; }
.pagina.acesso { max-width: 440px; padding-top: 12vh; }
.marca.grande { justify-content: center; margin-bottom: .5rem; }
.marca.grande .logo { width: 44px; height: 44px; font-size: 1.4rem; }
.acesso .cartao h2 { margin-bottom: .2rem; }
code { background: var(--fundo); border-radius: 4px; padding: .05rem .3rem; font-size: .9em; }
.versoes { margin-top: .6rem; }

/* seletor de tema */
#btn-tema { justify-content: flex-start; gap: .5rem; font-size: .88rem; padding: .35rem .7rem; }
#btn-tema .tema-ico { width: 1.1rem; text-align: center; }
.opcoes-tema { display: flex; flex-wrap: wrap; gap: .6rem; }
.opcao-tema { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .5rem; border: 2px solid var(--linha); border-radius: 10px; background: var(--painel); color: var(--texto); min-width: 96px; }
.opcao-tema.ativo { border-color: var(--acento); }
.opcao-tema i { display: block; width: 72px; height: 40px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .12); }
