:root {
  --fundo: #f4f5f7;
  --cartao: #ffffff;
  --texto: #1d2330;
  --suave: #5d6677;
  --borda: #d9dde4;
  --borda-forte: #b8bfcb;
  --primaria: #1f5fbf;
  --primaria-texto: #ffffff;
  --primaria-hover: #194f9f;
  --foco: #8fb4ee;
  --ok: #1d7a46;
  --ok-fundo: #e3f4ea;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --aviso: #8a5a00;
  --aviso-fundo: #fff4d6;
  --neutro-fundo: #eceff3;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #12151b;
    --cartao: #1b2029;
    --texto: #e6e9ef;
    --suave: #9aa3b2;
    --borda: #2d3441;
    --borda-forte: #3e4757;
    --primaria: #4d8ef0;
    --primaria-texto: #0b1220;
    --primaria-hover: #6fa3f3;
    --foco: #2f5ea8;
    --ok: #5fd08f;
    --ok-fundo: #173526;
    --erro: #ff8a7f;
    --erro-fundo: #3a1c1a;
    --aviso: #f3c35b;
    --aviso-fundo: #3a2f12;
    --neutro-fundo: #262c37;
    --sombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primaria); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.1rem; }
small { font-size: .8em; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95em; }
.sub { color: var(--suave); margin: .25rem 0 1rem; }
.nota { color: var(--suave); font-size: .875rem; margin: .5rem 0; }
.apagado { color: var(--suave); }

/* ---------- topo */
.topo { background: var(--cartao); border-bottom: 1px solid var(--borda); position: sticky; top: 0; z-index: 5; }
.topo-in { max-width: 1280px; margin: 0 auto; padding: .6rem 16px; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.marca { font-weight: 700; text-decoration: none; color: var(--texto); font-size: .88rem; letter-spacing: .03em; white-space: nowrap; }
.menu { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .8rem; font-size: .9rem; }
.menu a { text-decoration: none; color: var(--suave); padding: .2rem 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.menu button.link { font-size: inherit; white-space: nowrap; }
@media (max-width: 720px) {
  .topo-in { padding: .45rem 12px; gap: .3rem .9rem; }
  .marca { font-size: .78rem; }
  .menu { font-size: .83rem; gap: .15rem .6rem; }
  .so-largo { display: none; }
}
.menu a:hover { color: var(--texto); }
.menu a.atual { color: var(--texto); border-bottom-color: var(--primaria); }
.em-linha { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }

/* ---------- layout */
main { margin: 0 auto; padding: 1.25rem 16px 3rem; }
main.estreito { max-width: 720px; }
main.medio { max-width: 980px; }
main.largo { max-width: 1280px; }
main.login { max-width: 400px; padding-top: 12vh; }
.cabeca { margin-bottom: 1rem; }
.cabeca.linha { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.botoes { display: flex; gap: .5rem; flex-wrap: wrap; }
.voltar { margin: 0 0 .5rem; font-size: .9rem; }

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem; box-shadow: var(--sombra); margin-bottom: 1rem; }
.cartao-login { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.5rem; box-shadow: var(--sombra); }
.secao { margin: 0 0 .75rem; font-size: 1rem; }
.secao:not(:first-of-type) { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--borda); }
.grade-2, .grade-3 { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grade-2 { grid-template-columns: 1fr 1fr; }
  .grade-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- formulários */
.campo { display: block; margin: 0 0 .9rem; border: 0; padding: 0; min-width: 0; }
.campo > span, .campo > legend { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .3rem; padding: 0; }
.campo > span small { font-weight: 400; color: var(--suave); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=search], input[type=tel], input[type=email], input:not([type]), select, textarea {
  width: 100%;
  background: var(--cartao);
  border: 1px solid var(--borda-forte);
  border-radius: 8px;
  padding: .55rem .7rem;
  min-height: 44px;
}
input[type=file] { width: 100%; padding: .4rem 0; }
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--foco); outline-offset: 1px;
}
.curto { width: 9.5rem !important; min-height: 36px !important; padding: .35rem .5rem !important; }

button, .botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid var(--borda-forte); background: var(--cartao); color: var(--texto);
  border-radius: 8px; padding: .55rem 1rem; min-height: 44px; cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: .95rem; white-space: nowrap;
}
button:hover, .botao:hover { border-color: var(--suave); }
button:disabled { opacity: .6; cursor: progress; }
.primario { background: var(--primaria); border-color: var(--primaria); color: var(--primaria-texto); }
.primario:hover { background: var(--primaria-hover); border-color: var(--primaria-hover); }
.perigo { color: var(--erro); border-color: var(--erro); background: transparent; }
.perigo:hover { background: var(--erro-fundo); border-color: var(--erro); }
.sec { background: var(--cartao); }
.largo { width: 100%; }
.mini { min-height: 32px; padding: .25rem .6rem; font-size: .8rem; font-weight: 600; }
button.link { border: 0; background: none; color: var(--suave); padding: .2rem 0; min-height: 0; font-weight: 400; font-size: .95rem; }
button.link:hover { color: var(--texto); }
.acoes { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .75rem; margin-top: .5rem; }
.acoes .perigo { margin-right: auto; }

.segmentado { display: inline-flex; border: 1px solid var(--borda-forte); border-radius: 8px; overflow: hidden; }
.segmentado label { position: relative; }
.segmentado input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmentado span { display: block; padding: .55rem 1.4rem; min-height: 44px; line-height: 1.6; cursor: pointer; font-weight: 600; }
.segmentado label + label span { border-left: 1px solid var(--borda-forte); }
.segmentado input:checked + span { background: var(--primaria); color: var(--primaria-texto); }
.segmentado input[value="não"]:checked + span { background: var(--suave); color: var(--cartao); }
.segmentado input:focus-visible + span { outline: 3px solid var(--foco); outline-offset: -3px; }

.telefones { display: grid; grid-template-columns: 1fr; gap: .5rem; }
@media (min-width: 560px) { .telefones { grid-template-columns: repeat(3, 1fr); } }

/* ---------- mensagens */
.aviso-msg { border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; border: 1px solid; }
.aviso-msg.ok { background: var(--ok-fundo); color: var(--ok); border-color: transparent; }
.aviso-msg.erro { background: var(--erro-fundo); color: var(--erro); border-color: transparent; }
.vazio { text-align: center; color: var(--suave); padding: 2.5rem 1rem; }

/* ---------- lista do captador */
.abas { display: flex; gap: .4rem; overflow-x: auto; margin: 0 -16px .75rem; padding: 0 16px .25rem; scrollbar-width: none; }
.aba { flex: none; text-decoration: none; color: var(--texto); border: 1px solid var(--borda); background: var(--cartao); padding: .4rem .8rem; border-radius: 999px; font-size: .9rem; }
.aba .n { color: var(--suave); margin-left: .2rem; font-variant-numeric: tabular-nums; }
.aba.ativa { background: var(--texto); border-color: var(--texto); color: var(--cartao); }
.aba.ativa .n { color: inherit; opacity: .75; }
.busca, .filtros { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.busca input[type=search] { flex: 1 1 200px; width: auto; }
.filtros input[type=search] { flex: 2 1 220px; width: auto; }
.filtros select { flex: 1 1 170px; width: auto; }
.limpar { font-size: .9rem; }

.contato { padding: 1rem 1rem .9rem; scroll-margin-top: 70px; }
.contato-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .9rem; }
.quem { min-width: 0; }
.nome { margin: 0 0 .2rem; font-size: 1.1rem; overflow-wrap: anywhere; }
.cpf { color: var(--suave); font-size: .9rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.cpf code { color: var(--texto); font-size: 1rem; }
.estado { font-size: .85rem; color: var(--suave); margin-right: auto; }
.estado.ok { color: var(--ok); }
.estado.aviso { color: var(--aviso); }
.estado.erro { color: var(--erro); }

.selo { display: inline-block; flex: none; font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: var(--neutro-fundo); color: var(--suave); white-space: nowrap; }
.selo.contatado { background: var(--ok-fundo); color: var(--ok); }
.selo.sem_sucesso { background: var(--aviso-fundo); color: var(--aviso); }
.selo.admin { background: var(--neutro-fundo); color: var(--suave); font-weight: 600; }

/* ---------- admin */
.numeros { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.numero { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: .7rem .85rem; text-decoration: none; color: var(--texto); box-shadow: var(--sombra); }
.numero b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.numero span { color: var(--suave); font-size: .85rem; }
.numero.destaque { border-color: var(--aviso); }
.numero.destaque b { color: var(--aviso); }
.numero.bom b { color: var(--ok); }
.resumo summary { cursor: pointer; font-weight: 600; margin-bottom: .25rem; }
.resumo[open] summary { margin-bottom: .75rem; }

.rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabela { width: 100%; border-collapse: collapse; background: var(--cartao); font-size: .9rem; }
.tabela th, .tabela td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
.tabela th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); font-weight: 700; background: var(--cartao); position: sticky; top: 0; }
.tabela tbody tr:hover { background: var(--neutro-fundo); }
.tabela.compacta td, .tabela.compacta th { padding: .4rem .6rem; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela .chk { width: 2rem; }
.tabela input[type=checkbox] { width: 18px; height: 18px; }
.tabela tr.apagado td { color: var(--suave); }
.pequeno { font-size: .82rem; }
.quebra { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.obs { max-width: 260px; color: var(--suave); }
.barra-lote { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem; margin-bottom: .5rem; background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); position: sticky; top: 52px; z-index: 3; }
.barra-lote select { width: auto; flex: 1 1 180px; max-width: 280px; }
.barra-lote .sel { font-size: .9rem; color: var(--suave); margin-right: auto; }

.historico { list-style: none; margin: 0; padding: 0; }
.historico > li { padding: .6rem 0; border-bottom: 1px solid var(--borda); font-size: .9rem; }
.historico > li:last-child { border-bottom: 0; }
.historico ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.historico s { color: var(--suave); }

@media (max-width: 560px) {
  h1 { font-size: 1.3rem; }
  .acoes { justify-content: stretch; }
  .acoes .primario { flex: 1; }
  .barra-lote { top: 0; position: static; }
}

/* ---------- painel de ofícios */
.sinc { display: grid; gap: .2rem; background: var(--cartao); border: 1px solid var(--borda); border-left: 4px solid var(--ok); border-radius: var(--raio); padding: .65rem .9rem; margin-bottom: 1rem; font-size: .9rem; }
.sinc.com-erro { border-left-color: var(--aviso); }
.txt-erro { color: var(--erro); }
.txt-aviso { color: var(--aviso); font-weight: 600; }
.forte { font-weight: 600; }
.vara { max-width: 200px; }
.pdf { font-weight: 700; text-decoration: none; }
.pdf::before { content: "📄 "; }
.selo.saiu { background: var(--erro-fundo); color: var(--erro); font-weight: 600; }
.selo.sem-captador { background: var(--aviso-fundo); color: var(--aviso); }
.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--suave); }
.check input { width: 18px; height: 18px; }
.tabela td a.forte { color: var(--texto); }

/* ---------- página do ofício */
.duas-colunas { display: grid; gap: 0 1rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 860px) { .duas-colunas { grid-template-columns: 1.1fr 1fr; } }
.valor-grande { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ok); }
.dados { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0 0 1rem; font-size: .92rem; }
.dados dt { color: var(--suave); }
.dados dd { margin: 0; overflow-wrap: anywhere; }
.trecho { margin: .5rem 0 1rem; font-size: .9rem; }
.trecho summary { cursor: pointer; color: var(--primaria); }
.trecho blockquote { margin: .5rem 0 0; padding: .6rem .8rem; background: var(--neutro-fundo); border-radius: 8px; color: var(--texto); }
.arquivos { list-style: none; margin: 0 0 .75rem; padding: 0; }
.arquivos li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; padding: .35rem 0; border-bottom: 1px solid var(--borda); }
.arquivos li:last-child { border-bottom: 0; }
.anexar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.anexar input[type=file] { width: auto; flex: 1 1 200px; font-size: .85rem; }

/* ---------- usuários */
.credenciais { border-color: var(--ok); }
.mensagem { white-space: pre-wrap; background: var(--neutro-fundo); border-radius: 8px; padding: .75rem .9rem; font: .95rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; margin: 0 0 .75rem; overflow-wrap: anywhere; }
.editar summary { cursor: pointer; list-style: none; }
.editar summary::-webkit-details-marker { display: none; }
.editar[open] summary { margin-bottom: .4rem; }
.acoes-linha { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }

/* ---------- segurança */
.qrcode { margin: .6rem 0; }
.qrcode img { display: block; background: #fff; border-radius: 8px; padding: 4px; }
.chave { font-size: .95rem; letter-spacing: .04em; overflow-wrap: anywhere; }
.passos { padding-left: 1.2rem; margin: 0 0 .75rem; }
.passos li { margin-bottom: .6rem; }
input.codigo { font: 1.3rem/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .25em; text-align: center; }
.desativar-2fa { margin-top: .5rem; }

/* ---------- cadastro feito pelo captador */
main.cadastro { max-width: 560px; padding-top: 5vh; }
.escondido { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.check.aceite { align-items: flex-start; gap: .55rem; margin: .25rem 0 1rem; line-height: 1.4; }
.check.aceite input { flex: none; margin-top: .15rem; }
.convite { margin: 1rem 0 0; text-align: center; font-size: .92rem; color: var(--suave); }
.contador { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 999px; background: var(--erro); color: var(--cartao); font-size: .72rem; font-weight: 700; line-height: 1.4; text-align: center; vertical-align: 1px; }
.pedido-cabeca { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .75rem; }
.pedido-cabeca .secao { margin-bottom: .5rem; }
.perfil { margin: .35rem 0 .5rem; font-size: .85rem; }
/* ---------- tabela de ofícios: compacta no computador, cartões no celular */
.tabela.oficios { font-size: .88rem; }
.tabela.oficios td { padding: .45rem .55rem; }
.tabela.oficios .c-credor { min-width: 180px; }
.tabela.oficios .c-credor a.forte { color: var(--texto); }
.tabela.oficios .c-captador { min-width: 150px; }
.tabela.oficios .c-captador > a + span { margin-left: .3rem; }
.situacao-linha { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .4rem; margin-top: .25rem; }
.tabela.oficios .c-vara { max-width: 210px; min-width: 140px; }
.tabela.oficios .c-obs { max-width: 230px; min-width: 120px; color: var(--suave); }
.tabela.oficios .c-oficio .pdf + .pdf { margin-left: .4rem; }
.duas-linhas { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 860px) {
  .tabela.oficios, .tabela.oficios tbody { display: block; }
  .tabela.oficios thead { display: none; }
  .tabela.oficios tr {
    display: grid;
    grid-template-columns: 1.9rem minmax(0, 1fr) auto;
    grid-template-areas: "chk credor valor" "chk captador captador" "chk processo oficio" "chk vara vara" "chk obs obs";
    gap: .2rem .6rem; padding: .7rem .6rem; border-bottom: 1px solid var(--borda);
  }
  .tabela.oficios td { display: block; padding: 0; border: 0; min-width: 0; max-width: none; }
  .tabela.oficios .chk { grid-area: chk; width: auto; }
  .tabela.oficios .c-credor { grid-area: credor; }
  .tabela.oficios .c-valor { grid-area: valor; }
  .tabela.oficios .c-captador { grid-area: captador; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .5rem; }
  .tabela.oficios .c-captador .situacao-linha { margin-top: 0; }
  .tabela.oficios .c-processo { grid-area: processo; }
  .tabela.oficios .c-oficio { grid-area: oficio; text-align: right; }
  .tabela.oficios .c-oficio .sem-pdf { display: none; }
  .tabela.oficios .c-vara { grid-area: vara; }
  .tabela.oficios .c-obs { grid-area: obs; }
  .tabela.oficios .c-obs:empty, .tabela.oficios .c-vara:has(.duas-linhas:empty) { display: none; }
}

/* tabelas comuns (Usuários, Acessos, resumos): no celular, cada linha vira um cartão com rótulos */
@media (max-width: 860px) {
  .tabela.cartoes, .tabela.cartoes tbody, .tabela.cartoes tr { display: block; }
  .tabela.cartoes thead { display: none; }
  .tabela.cartoes tr { padding: .6rem .55rem; border-bottom: 1px solid var(--borda); }
  .tabela.cartoes td { display: flex; align-items: baseline; gap: .6rem; padding: .1rem 0 !important; border: 0;
                       text-align: left !important; white-space: normal; }
  .tabela.cartoes td[data-label]::before { content: attr(data-label); flex: none; width: 7.5rem; color: var(--suave);
                                           font: 400 .78rem/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
  .tabela.cartoes td.titulo { display: block; font-weight: 600; margin-bottom: .2rem; }
  .tabela.cartoes td.acoes-celula { display: block; margin-top: .45rem; }
  .tabela.cartoes td > div { min-width: 0; }
}

/* ---------- pedir mais contatos */
.pedir-contatos { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; }
.pedir-contatos.destaque { border-color: var(--aviso); background: var(--aviso-fundo); }
.pedir-contatos.aguardando { border-left: 4px solid var(--primaria); }
.pedir-campos { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; flex: 1 1 320px; justify-content: flex-end; }
.pedir-campos select { width: auto; }
.pedir-campos input { flex: 1 1 160px; width: auto; }
.pedidos-contatos { border-color: var(--aviso); }
.pedido-linha { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .55rem 0; border-bottom: 1px solid var(--borda); }
.pedido-linha:last-child { border-bottom: 0; padding-bottom: 0; }
.sessoes { list-style: none; margin: 0 0 .75rem; padding: 0; }
.sessoes li { padding: .5rem 0; border-bottom: 1px solid var(--borda); }
.sessoes li:last-child { border-bottom: 0; }

/* página Baixar ofícios */
.baixar-cabeca { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1.5rem; }
.baixar-cabeca > div { flex: 1 1 26rem; }
.baixar-cabeca .sub { margin-bottom: 0; }
.selo.juntado { background: var(--ok-fundo); color: var(--ok); font-weight: 600; }
.selo.atrasado { background: var(--aviso-fundo); color: var(--aviso); }
.tabela.baixar td.titulo .mini, .tabela.baixar td.titulo a.pequeno { margin-left: .35rem; }
.tabela.baixar td .selo + .selo { margin-left: .25rem; }
.quebra { overflow-wrap: anywhere; }
@media (max-width: 860px) { .tabela.cartoes td.situacao:empty { display: none; } }
.abas.tipos .aba { font-size: .82rem; padding: .3rem .7rem; }
.selo.rpv { background: var(--aviso-fundo); color: var(--aviso); }
.tabela.baixar td.valor .selo { margin-top: .2rem; }
.titulo-secao { font-size: 1.05rem; margin: 1.25rem 0 .25rem; }
.form-marcar { display: grid; grid-template-columns: 1fr auto; gap: .3rem; min-width: 230px; }
.form-marcar select { grid-column: 1 / -1; }
.form-marcar select, .form-marcar input { min-height: 32px; padding: .25rem .5rem; font-size: .82rem; }
@media (max-width: 860px) { .form-marcar { min-width: 0; width: 100%; } }
.lido-pdf { border-left: 3px solid var(--ok); padding-left: .75rem; margin: .75rem 0; }
