:root {
  --verde: #1b7a3a;
  --verde-escuro: #135c2b;
  --verde-claro: #eaf4ee;
  --verde-lima: #bddba0;
  --fundo: #f3f6f4;
  --papel: #ffffff;
  --texto: #1d2b22;
  --suave: #5b6b61;
  --borda: #d3ddd7;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --aviso: #7a5a00;
  --aviso-fundo: #fff6e0;
  --raio: 14px;
  --sombra: 0 1px 2px rgba(16, 40, 24, .05), 0 4px 16px rgba(16, 40, 24, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; }

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--texto);
  background: var(--fundo);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--verde); }
h1 { font-size: clamp(1.45rem, 1.1rem + 1.4vw, 1.9rem); margin: 0 0 .35rem; line-height: 1.2; }
h2 { font-size: 1.12rem; margin: 0; color: var(--verde-escuro); line-height: 1.3; }
.sub { color: var(--suave); margin: 0; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.quebra { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- topo */
.topo { background: var(--papel); box-shadow: 0 1px 0 var(--borda); position: relative; z-index: 5; }
.topo-in {
  max-width: 1400px; margin: 0 auto; padding: .7rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; flex-wrap: wrap;
}
.marca { display: block; line-height: 0; }
.marca img { width: 240px; }
.faixa { background: var(--verde); color: #fff; }
.faixa span {
  display: block; max-width: 1400px; margin: 0 auto; padding: .4rem 1.25rem;
  font-size: .8rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.faixa::after { content: ""; display: block; height: 4px; background: var(--verde-lima); }

.menu { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.menu > a, .usuario summary {
  color: var(--verde-escuro); text-decoration: none; padding: .55rem .95rem; border-radius: 999px;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}
.menu > a:hover, .usuario summary:hover { background: var(--verde-claro); }
.menu > a.ativo { background: var(--verde); color: #fff; }
.usuario { position: relative; }
.usuario summary { list-style: none; border: 1px solid var(--borda); }
.usuario summary::-webkit-details-marker { display: none; }
.usuario summary::after { content: " ▾"; font-size: .8em; }
.usuario-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 220px;
  background: var(--papel); border: 1px solid var(--borda); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,.14);
  padding: .4rem;
}
.usuario-email { display: block; padding: .4rem .7rem .55rem; font-size: .8rem; color: var(--suave); border-bottom: 1px solid var(--borda); margin-bottom: .3rem; overflow-wrap: anywhere; }
.usuario-menu a, .usuario-menu button {
  display: block; width: 100%; text-align: left; padding: .55rem .7rem; border-radius: 7px;
  color: var(--texto); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.usuario-menu a:hover, .usuario-menu button:hover { background: var(--verde-claro); }

/* ---------------------------------------------------------------- layout */
.conteudo { width: 100%; max-width: 900px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; flex: 1; }
.conteudo.largo { max-width: 1400px; }
.conteudo.estreito { max-width: 520px; }
.rodape {
  text-align: center; color: var(--suave); font-size: .82rem; line-height: 1.7;
  padding: 1.25rem 1rem; background: var(--papel); border-top: 1px solid var(--borda);
}

.cabecalho-pagina {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.acoes { display: flex; gap: .5rem; flex-wrap: wrap; }

.apresentacao { margin-bottom: 1.5rem; }
.apresentacao > p { color: var(--suave); margin: 0 0 1rem; max-width: 60ch; }
.info-rapida {
  list-style: none; padding: 0; margin: 0 0 .9rem;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem;
}
.info-rapida li {
  background: var(--papel); border: 1px solid var(--borda); border-left: 4px solid var(--verde);
  border-radius: 10px; padding: .6rem .85rem; display: flex; flex-direction: column; line-height: 1.3;
}
.info-rapida strong { font-size: .95rem; }
.info-rapida span { color: var(--suave); font-size: .85rem; }
.legenda-obrig { font-size: .88rem; color: var(--suave); margin: 0; }

.bloco, .cartao {
  background: var(--papel); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 1.4rem 1.5rem 1.5rem; margin-bottom: 1.1rem; box-shadow: var(--sombra);
}
.cartao { padding: 1.9rem; }
.cartao .sub { margin-bottom: 1.25rem; }
.bloco > h2 { margin-bottom: 1rem; }

.bloco-cab { display: flex; gap: .85rem; align-items: flex-start; margin-bottom: 1.2rem; }
.bloco-cab p { margin: .1rem 0 0; color: var(--suave); font-size: .9rem; }
.passo {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--verde); color: #fff; font-weight: 700; font-size: .95rem;
}

/* ---------------------------------------------------------------- alertas */
.alerta { padding: .85rem 1.1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; }
.alerta-sucesso { background: var(--verde-claro); border-color: #b9dcc5; color: var(--verde-escuro); }
.alerta-erro { background: var(--erro-fundo); border-color: #f5c2bd; color: var(--erro); }
.alerta-aviso, .alerta-message { background: var(--aviso-fundo); border-color: #f0dca8; color: var(--aviso); }
.alerta-destaque { font-size: 1.02rem; border-left-width: 5px; }
.alerta-destaque strong { display: block; font-size: 1.1rem; margin-bottom: .2rem; }

/* ---------------------------------------------------------------- formulário */
.grade { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.revelar { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: inherit; }
.c-2 { grid-column: span 2; } .c-3 { grid-column: span 3; } .c-4 { grid-column: span 4; }
.c-5 { grid-column: span 5; } .c-6 { grid-column: span 6; } .c-7 { grid-column: span 7; }
.c-8 { grid-column: span 8; } .c-9 { grid-column: span 9; } .c-12 { grid-column: span 12; }

.campo { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.campo > label, .campo legend { font-weight: 600; font-size: .92rem; line-height: 1.3; }
.obrig { color: var(--erro); margin-left: .2rem; font-weight: 700; }
input[type=text], input[type=email], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 2.9rem; padding: .65rem .8rem; border: 1.5px solid var(--borda); border-radius: 9px;
  font: inherit; color: inherit; background: #fff; transition: border-color .15s, box-shadow .15s;
}
select { appearance: auto; }
textarea { resize: vertical; min-height: 5.5rem; }
input::placeholder, textarea::placeholder { color: #98a59d; }
input:hover, select:hover, textarea:hover { border-color: #b3c2b9; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--verde); box-shadow: 0 0 0 4px rgba(27, 122, 58, .15);
}
button:focus-visible, a:focus-visible, .opcao:focus-within { outline: 3px solid rgba(27, 122, 58, .35); outline-offset: 2px; }
.com-erro input, .com-erro select, .com-erro textarea { border-color: var(--erro); background: #fffafa; }
.com-erro .opcao { border-color: #f0b4ae; }
.msg-erro { color: var(--erro); font-size: .85rem; font-weight: 500; }
.dica-campo { color: var(--suave); font-size: .82rem; }

fieldset.opcoes { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.opcoes legend { padding: 0; margin-bottom: .45rem; }
.opcoes-lista { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .55rem; }
.opcao {
  display: flex; align-items: center; gap: .65rem; cursor: pointer; min-height: 2.9rem;
  padding: .6rem .85rem; border: 1.5px solid var(--borda); border-radius: 10px; background: #fff; font-weight: 500;
  transition: border-color .15s, background .15s;
}
.opcao:hover { border-color: #9fc1ab; }
.opcoes-lista .opcao:has(input:checked) { border-color: var(--verde); background: var(--verde-claro); color: var(--verde-escuro); }
.opcao input { margin: 0; accent-color: var(--verde); width: 1.15rem; height: 1.15rem; flex: none; }

.cep-status { align-self: end; font-size: .88rem; color: var(--suave); min-height: 1.4rem; padding-bottom: .7rem; }
.cep-status.ok { color: var(--verde); }
.cep-status.aviso { color: var(--aviso); }

.declaracoes {
  max-height: 240px; overflow-y: auto; font-size: .9rem; color: #33443a;
  background: #fafbfa; border: 1px solid var(--borda); border-radius: 10px; padding: .35rem 1.1rem; margin-bottom: 1rem;
}
.declaracoes p { text-align: justify; hyphens: auto; }
.aceite .opcao { border-color: var(--verde); background: var(--verde-claro); align-items: flex-start; }
.aceite .opcao input { margin-top: .2rem; }

.acoes-form { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; }
.barra-acoes {
  position: sticky; bottom: 0; z-index: 4; display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap;
  background: rgba(255, 255, 255, .95); backdrop-filter: blur(6px); border: 1px solid var(--borda);
  border-radius: var(--raio); padding: .8rem 1rem; box-shadow: 0 -4px 18px rgba(16, 40, 24, .08);
  margin-bottom: max(.5rem, env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- botões */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem;
  padding: .6rem 1.2rem; border-radius: 10px; border: 1.5px solid var(--verde);
  background: var(--verde); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.botao:hover { background: var(--verde-escuro); border-color: var(--verde-escuro); }
.botao-sec { background: #fff; color: var(--verde); }
.botao-sec:hover { background: var(--verde-claro); color: var(--verde-escuro); }
.botao-grande { padding: .9rem 2rem; font-size: 1.08rem; }
.botao-largo { width: 100%; }
.botao-mini { min-height: 2rem; padding: .25rem .7rem; font-size: .82rem; border-radius: 8px; }

/* ---------------------------------------------------------------- confirmação */
.confirmacao { text-align: center; }
.selo {
  width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%; background: var(--verde-claro);
  color: var(--verde); font-size: 2.2rem; display: grid; place-items: center; font-weight: 700;
}
.resumo { display: grid; gap: .55rem; margin: 1.5rem 0; text-align: left; }
.resumo div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--borda); padding-bottom: .45rem; }
.resumo dt { color: var(--suave); }
.resumo dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.protocolo { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; color: var(--verde-escuro); }
.dica { background: var(--aviso-fundo); border-radius: 10px; padding: .75rem .95rem; margin: 1rem 0 0; font-size: .9rem; text-align: left; }

/* ---------------------------------------------------------------- relatório */
.filtros {
  display: grid; grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)) auto; gap: .7rem; align-items: end;
  background: var(--papel); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1rem; margin-bottom: 1rem;
  box-shadow: var(--sombra);
}
.filtros label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 600; color: var(--suave); }
.filtros input, .filtros select { min-height: 2.6rem; padding: .45rem .6rem; font-size: .92rem; }
.f-botoes { display: flex; gap: .4rem; }

.tabela-wrap { overflow-x: auto; background: var(--papel); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); }
.tabela { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabela th {
  background: var(--verde); color: #fff; text-align: left; padding: .7rem .65rem; font-weight: 600; white-space: nowrap;
}
.tabela td { padding: .6rem .65rem; border-top: 1px solid #e6ece8; vertical-align: top; }
.tabela tbody tr:nth-child(even) { background: #f8fbf9; }
.tabela tbody tr:hover { background: var(--verde-claro); }
.tabela small { color: var(--suave); }
.tabela .vazio { text-align: center; color: var(--suave); padding: 2.5rem; }
.col-nome a { font-weight: 600; }
.protocolo-linha { display: block; }
.acoes-linha { display: flex; gap: .35rem; flex-wrap: wrap; }
.etiqueta {
  display: inline-block; margin-left: .35rem; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; vertical-align: middle;
  background: var(--aviso-fundo); color: var(--aviso); border: 1px solid #f0dca8;
}
.paginacao { display: flex; gap: .3rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.paginacao a, .paginacao strong, .paginacao span { padding: .45rem .8rem; border-radius: 8px; }
.paginacao a { border: 1px solid var(--borda); background: #fff; text-decoration: none; }
.paginacao strong { background: var(--verde); color: #fff; }

/* ---------------------------------------------------------------- detalhe do filiado */
.dados { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .9rem 1.25rem; margin: 0; }
.dados div.largo { grid-column: 1 / -1; }
.dados dt { font-size: .76rem; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; }
.dados dd { margin: .1rem 0 0; font-weight: 500; overflow-wrap: anywhere; }
.dados .pre { white-space: pre-line; }
.dados.compacto { font-size: .88rem; margin-top: .75rem; }
.historico { border: 1px solid var(--borda); border-radius: 10px; padding: .65rem .85rem; margin-top: .6rem; }
.historico summary { cursor: pointer; font-weight: 500; }

/* ---------------------------------------------------------------- tablet */
@media (max-width: 1100px) {
  .filtros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f-busca, .f-botoes { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .grade, .revelar { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .c-2, .c-3, .c-4, .c-5 { grid-column: span 3; }
  .c-6, .c-7, .c-8, .c-9, .c-12 { grid-column: span 6; }
  .cep-status { padding-bottom: 0; }
  .cep-status:empty { display: none; }

  /* Relatório vira lista de cartões */
  .tabela-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tabela-responsiva thead { display: none; }
  .tabela-responsiva, .tabela-responsiva tbody, .tabela-responsiva tr, .tabela-responsiva td { display: block; width: 100%; }
  .tabela-responsiva tr {
    background: var(--papel) !important; border: 1px solid var(--borda); border-radius: var(--raio);
    margin-bottom: .75rem; padding: .6rem .9rem; box-shadow: var(--sombra);
  }
  .tabela-responsiva td { border: 0; padding: .3rem 0; display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; }
  .tabela-responsiva td::before { content: attr(data-label); color: var(--suave); font-size: .78rem; font-weight: 600; padding-top: .1rem; }
  .tabela-responsiva td.col-nome { display: block; font-size: 1.02rem; padding-bottom: .5rem; border-bottom: 1px solid var(--borda); margin-bottom: .3rem; }
  .tabela-responsiva td.col-nome::before, .tabela-responsiva td.col-acoes::before { content: none; }
  .tabela-responsiva td.col-acoes { display: block; padding-top: .6rem; }
  .tabela-responsiva .vazio { display: block; background: var(--papel); border-radius: var(--raio); }
}

/* ---------------------------------------------------------------- celular */
@media (max-width: 560px) {
  body { font-size: 16px; }  /* evita zoom automático do iPhone ao focar nos campos */
  .topo-in { justify-content: center; padding: .6rem .9rem; }
  .marca img { width: 200px; }
  .menu { width: 100%; justify-content: center; }
  .menu > a, .usuario summary { padding: .5rem .8rem; font-size: .92rem; }
  .faixa span { font-size: .68rem; text-align: center; padding: .35rem .75rem; }
  .conteudo { padding: 1.1rem .75rem 2.5rem; }
  .info-rapida { grid-template-columns: 1fr; }
  .bloco, .cartao { padding: 1.1rem 1rem 1.2rem; border-radius: 12px; }
  .grade, .revelar { grid-template-columns: 1fr; gap: .9rem; }
  .grade > *, .revelar > * { grid-column: 1 / -1 !important; }
  .opcoes-lista { grid-template-columns: 1fr; }
  .acoes-form .botao, .barra-acoes .botao { flex: 1 1 100%; }
  .acoes { width: 100%; }
  .acoes .botao { flex: 1; }
  .filtros { grid-template-columns: 1fr; }
  .resumo div { flex-direction: column; gap: 0; }
  .resumo dd { text-align: left; }
  .usuario-menu { right: 50%; transform: translateX(50%); }
}
