:root {
  --fundo: #f3f5f8; --cartao: #ffffff; --texto: #1c2430; --suave: #5b6675; --borda: #d8dee7;
  --primaria: #1d5fd1; --primaria-esc: #1749a3; --perigo: #b3261e; --ok: #1e7a46;
  --raio: 10px; --sombra: 0 1px 2px rgba(20, 30, 50, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto); line-height: 1.5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 16px;
}
a { color: var(--primaria); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--borda); margin: 1rem 0; }
code { background: #eef1f6; padding: .1em .35em; border-radius: 4px; word-break: break-all; }

.topo { background: #14233b; color: #fff; position: sticky; top: 0; z-index: 10; }
.topo-int { max-width: 1100px; margin: 0 auto; padding: .4rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.marca { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; padding: .4rem 0; }
.menu { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; flex: 1; }
.menu a, .menu-sair {
  color: #dbe5f5; text-decoration: none; padding: .6rem .8rem; border-radius: 8px; min-height: 44px;
  display: inline-flex; align-items: center; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu a:hover, .menu-sair:hover { background: rgba(255,255,255,.12); color: #fff; }
.menu a[aria-current="page"] { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.form-sair { margin: 0 0 0 auto; }

.faixa-demo { background: #fff3c4; color: #5a4300; border-bottom: 1px solid #e6cf7a; padding: .6rem 1rem;
  display: flex; gap: .75rem; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; }
.faixa-demo form { margin: 0; }

.conteudo { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
.conteudo.medio { max-width: 760px; }
.conteudo.estreito { max-width: 440px; padding-top: 2.5rem; }
.rodape { text-align: center; color: var(--suave); font-size: .85rem; padding: 1rem; }

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem; margin-bottom: 1rem; box-shadow: var(--sombra); }
.cartao-suave { background: #fafbfd; }
.cabeca { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cabeca h1 { margin: 0; }
.acoes { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.acoes form { margin: 0; }
.discreto { color: var(--suave); font-size: .92rem; }
.vazio { color: var(--suave); text-align: center; padding: 1.2rem 0; margin: 0; }
.texto-livre { white-space: pre-wrap; margin: 0 0 1rem; }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; padding: .55rem 1.1rem;
  border-radius: 9px; border: 1px solid var(--borda); background: #fff; color: var(--texto); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: #eef2f8; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, .menu-sair:focus-visible {
  outline: 3px solid #8db4f5; outline-offset: 2px;
}
.btn-primario { background: var(--primaria); border-color: var(--primaria); color: #fff; }
.btn-primario:hover { background: var(--primaria-esc); }
.btn-perigo { background: var(--perigo); border-color: var(--perigo); color: #fff; }
.btn-perigo:hover { background: #8f1d17; }
.btn-claro { background: transparent; }
.btn-largo { width: 100%; }
.btn-peq { min-height: 38px; padding: .3rem .8rem; }

.campo { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.campo label, .marcar { font-weight: 600; }
.marcar { display: flex; gap: .6rem; align-items: flex-start; margin: 1rem 0; font-weight: 500; }
.marcar input { width: 22px; height: 22px; margin-top: .1rem; flex: none; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=password], input[type=date], input[type=file], select, textarea {
  width: 100%; min-height: 46px; padding: .6rem .75rem; border: 1px solid #aeb8c6; border-radius: 9px; background: #fff;
  color: var(--texto); font: inherit; font-size: 16px; /* 16px evita zoom automático no iPhone */
}
textarea { resize: vertical; }
.obrig { color: var(--perigo); }
.ajuda { color: var(--suave); }
.msg-erro { color: var(--perigo); font-weight: 600; }
.campo-erro input, .campo-erro select, .campo-erro textarea { border-color: var(--perigo); }
.linha-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.aviso { padding: .8rem 1rem; border-radius: 9px; margin-bottom: 1rem; border: 1px solid; }
.aviso-ok { background: #e6f5ec; border-color: #9ed3b3; color: #134d2b; }
.aviso-erro { background: #fdeceb; border-color: #f0aaa5; color: #7d1710; }

.grade-status { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: .6rem; }
.cartao-status { background: #fff; border: 1px solid var(--borda); border-left-width: 6px; border-radius: var(--raio);
  padding: 1rem; text-decoration: none; color: var(--texto); box-shadow: var(--sombra); display: flex; flex-direction: column; min-height: 96px; }
.cartao-status:hover { background: #f7f9fc; }
.cartao-status .numero { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.cartao-status .rotulo { color: var(--suave); font-weight: 600; }
.cs-aberta { border-left-color: #1d5fd1; }
.cs-em_andamento { border-left-color: #c47a00; }
.cs-aguardando { border-left-color: #7a4bb3; }
.cs-concluida { border-left-color: #1e7a46; }

.selo { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 700; vertical-align: middle; }
.selo-aberta { background: #dce8fb; color: #123f8f; }
.selo-em_andamento { background: #fdebc8; color: #7a4a00; }
.selo-aguardando { background: #ebdff7; color: #50297f; }
.selo-concluida { background: #d6f0e0; color: #135a31; }

.tabela { width: 100%; border-collapse: collapse; }
.tabela th, .tabela td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--borda); vertical-align: top; }
.tabela thead th { color: var(--suave); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.busca { display: flex; gap: .6rem; margin-bottom: 1rem; }
.busca input { flex: 1; }
.filtros { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr auto; gap: 0 .8rem; align-items: end; }
.filtros .campo { margin-bottom: .4rem; }
.filtros .acoes { margin-bottom: .4rem; }
.paginacao { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; flex-wrap: wrap; }

.dados { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1.5rem; margin: 0 0 1rem; }
.dados dt { color: var(--suave); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.dados dd { margin: 0; font-weight: 600; word-break: break-word; }

.menu a.menu-celular { background: #2d7be5; color: #fff; font-weight: 600; }
.menu a.menu-celular:hover { background: #1f66c6; }
.btn-celular { width: 100%; font-size: 1.1rem; min-height: 56px; margin-bottom: 1rem; }
.conectar { text-align: center; }
.passo-texto { font-size: 1.15rem; margin-top: 0; }
.qr-caixa { display: flex; justify-content: center; margin: 1rem 0; }
.qr { background: #fff; padding: .5rem; border: 1px solid var(--borda); border-radius: var(--raio); width: min(100%, 320px); }
.qr svg { display: block; width: 100%; height: auto; }
.endereco-rotulo { margin-bottom: .2rem; color: var(--suave); }
.endereco { font-size: 1.35rem; font-weight: 700; word-break: break-all; margin: 0 0 1rem; }
.acoes-centro { justify-content: center; }
.lista { padding-left: 1.2rem; margin: .4rem 0 1rem; }
.lista li { margin-bottom: .35rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }

@media (max-width: 860px) {
  .grade-status { grid-template-columns: repeat(2, 1fr); }
  .filtros { grid-template-columns: 1fr 1fr; }
  .filtros .acoes { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .conteudo { padding: 1rem .8rem 2rem; }
  .marca { width: 100%; padding-bottom: 0; }
  .topo-int { gap: 0; }
  .menu { gap: .1rem; flex: none; width: 100%; }
  .form-sair { margin-left: auto; }
  .menu a, .menu-sair { padding: .55rem .65rem; font-size: .95rem; }
  .cabeca .acoes, .cabeca .btn { width: 100%; }
  .acoes .btn, .acoes form, .acoes form .btn { width: 100%; }
  .linha-campos, .dados, .filtros { grid-template-columns: 1fr; }
  .busca { flex-wrap: wrap; }
  .busca .btn { flex: 1; }
  .tabela-resp thead { position: absolute; left: -9999px; }
  .tabela-resp, .tabela-resp tbody, .tabela-resp tr, .tabela-resp td { display: block; width: 100%; }
  .tabela-resp tr { border: 1px solid var(--borda); border-radius: 9px; margin-bottom: .7rem; padding: .35rem .6rem; background: #fcfdff; }
  .tabela-resp td { border: 0; display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; text-align: right; word-break: break-word; }
  .tabela-resp td::before { content: attr(data-label); font-weight: 600; color: var(--suave); text-align: left; flex: none; }
}

code { word-break: normal; white-space: nowrap; }
.backup code, .discreto code { white-space: normal; word-break: break-all; }

/* PWA / modos */
.rotulo-modo { display: inline-block; font-weight: 700; padding: .25rem .8rem; border-radius: 999px; margin: 0 0 .8rem; }
.rotulo-local { background: #fdebc8; color: #7a4a00; }
.rotulo-online { background: #d6f0e0; color: #135a31; }
.aviso-versao { position: fixed; left: 50%; bottom: .8rem; transform: translateX(-50%); z-index: 50; width: min(94vw, 520px); background: #14233b; color: #fff; padding: .7rem .9rem; border-radius: 10px; display: flex; gap: .8rem; align-items: center; justify-content: space-between; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.aviso-versao .btn:disabled { opacity: .5; cursor: not-allowed; }
@media (display-mode: standalone) { .rodape { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); } .topo { padding-top: env(safe-area-inset-top); } }
