:root {
  --fundo: #f4f5f7;
  --superficie: #ffffff;
  --texto: #1b1f24;
  --suave: #5d6673;
  --linha: #e1e4e8;
  --marca: #0f5c4d;
  --marca-forte: #0a4237;
  --marca-clara: #e3f1ed;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --info-fundo: #eef4ff;
  --info: #1d4ed8;
  --ok-fundo: #e7f6ec;
  --ok: #157f3c;
  --teste: #9a5b00;
  --teste-fundo: #fff4de;
  --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: #111417;
    --superficie: #1a1e23;
    --texto: #e8eaed;
    --suave: #9aa3ad;
    --linha: #2c3238;
    --marca: #3fb89c;
    --marca-forte: #66cdb4;
    --marca-clara: #16302a;
    --erro: #f87171;
    --erro-fundo: #3a1717;
    --info-fundo: #172338;
    --info: #93b4ff;
    --ok-fundo: #12301d;
    --ok: #6fd49a;
    --teste: #f5b955;
    --teste-fundo: #3a2c12;
    --sombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--marca); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: .25rem 0 .25rem; letter-spacing: -.01em; }
.sub { color: var(--suave); margin: 0 0 1.25rem; }

.topo { background: var(--superficie); border-bottom: 1px solid var(--linha); }
.topo-in { max-width: 860px; margin: 0 auto; padding: .75rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.marca { font-weight: 700; font-size: 1.1rem; color: var(--texto); text-decoration: none; letter-spacing: -.01em; }
.marca span { color: var(--marca); font-weight: 600; }
.topo nav { margin-left: auto; display: flex; gap: 1.1rem; align-items: center; }
.topo nav a, .link { color: var(--suave); text-decoration: none; font: inherit; font-size: .95rem; background: none; border: 0; padding: 0; cursor: pointer; }
.topo nav a:hover, .link:hover { color: var(--texto); }
.topo nav form { margin: 0; }

main { max-width: 860px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

.cartao { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.5rem; }
.entrar { max-width: 380px; margin: 3rem auto; }
.formulario { max-width: 560px; display: grid; gap: 1.1rem; }

label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; color: var(--suave); font-size: .82rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--texto); background: var(--superficie);
  border: 1px solid var(--linha); border-radius: 8px; padding: .65rem .75rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marca); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
.campo-moeda { display: flex; align-items: stretch; }
.campo-moeda span { display: grid; place-items: center; padding: 0 .75rem; border: 1px solid var(--linha); border-right: 0; border-radius: 8px 0 0 8px; color: var(--suave); font-weight: 500; }
.campo-moeda input { border-radius: 0 8px 8px 0; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
fieldset { border: 1px solid var(--linha); border-radius: 8px; padding: .6rem .9rem; margin: 0; }
legend { font-weight: 600; font-size: .92rem; padding: 0 .3rem; }
.op { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.op input { width: auto; }

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--marca); color: #fff; border: 1px solid var(--marca); border-radius: 8px;
  padding: .7rem 1.2rem; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.botao:hover { background: var(--marca-forte); border-color: var(--marca-forte); }
.botao[disabled] { opacity: .45; cursor: not-allowed; }
.botao.secundario { background: transparent; color: var(--texto); border-color: var(--linha); }
.botao.secundario:hover { background: var(--fundo); }
.acoes { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0; align-items: center; }
.acoes form { margin: 0; }
.topo-acoes { margin-top: 0; }

.passos { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.passos span { font-size: .78rem; color: var(--suave); background: var(--superficie); border: 1px solid var(--linha); border-radius: 999px; padding: .15rem .65rem; }
.passos .atual { color: var(--marca); border-color: var(--marca); font-weight: 600; }
.passos .atual.ok { color: var(--ok); border-color: var(--ok); }
.passos .atual.erro { color: var(--erro); border-color: var(--erro); }

.aviso { border-radius: 8px; padding: .8rem 1rem; margin: 0 0 1.25rem; font-size: .95rem; }
.aviso ul { margin: 0; padding-left: 1.1rem; }
.aviso-erro { background: var(--erro-fundo); color: var(--erro); }
.aviso-info { background: var(--info-fundo); color: var(--info); }
.aviso-ok { background: var(--ok-fundo); color: var(--ok); }
.selo { font-size: .75rem; font-weight: 600; border-radius: 999px; padding: .1rem .55rem; }
.selo-teste { background: var(--teste-fundo); color: var(--teste); }

/* Nota (DANFSe) */
.nota { position: relative; background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1.5rem; }
.nota-selo { display: inline-block; margin-bottom: .9rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--marca); background: var(--marca-clara); border-radius: 999px; padding: .2rem .65rem; }
.nota-cab { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--linha); padding-bottom: 1rem; }
.nota-cab h2 { margin: 0; font-size: 1.3rem; }
.nota-cab p { margin: .15rem 0 0; color: var(--suave); font-size: .85rem; }
.mini { display: flex; gap: 1.5rem; margin: 0; }
.chave { margin: 1rem 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; }
.chave span { display: block; font-family: inherit; }
.nota section { padding-top: 1rem; margin-top: 1rem; border-top: 1px solid var(--linha); }
.nota h3 { margin: 0 0 .6rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--suave); }
dl { margin: 0; }
dt, .chave span { font-size: .75rem; color: var(--suave); }
dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
.grade { display: grid; grid-template-columns: 2fr 1fr; gap: .8rem 1.5rem; }
.grade .inteiro { grid-column: 1 / -1; }
.descricao { white-space: pre-wrap; }
.valores { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem 1.5rem; font-variant-numeric: tabular-nums; }
.valores .total dd { font-size: 1.25rem; font-weight: 700; }
.nota-rodape { margin: .9rem 0 0; color: var(--suave); font-size: .8rem; }

.ajustes { margin-top: 1rem; background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); padding: .8rem 1rem; }
.ajustes summary { cursor: pointer; font-weight: 600; }
.ajustes form { display: grid; gap: .9rem; margin-top: .9rem; max-width: 480px; }

.tabela { overflow-x: auto; background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--linha); white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); }
tr:last-child td { border-bottom: 0; }
td:nth-child(3) { white-space: normal; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .nota { padding: 1.1rem; }
  .grade, .valores { grid-template-columns: 1fr; }
  .topo nav { margin-left: 0; width: 100%; }
}

@media print {
  .topo, .acoes, .passos, .aviso, .ajustes { display: none !important; }
  body, .nota { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .nota { border: 0; box-shadow: none; }
}

/* aviso sobre o PDF oficial (DANFSe) na tela da nota */
.nota-pdf { margin: -.35rem 0 1.1rem; font-size: .88rem; max-width: 46rem; }

/* Recorrentes e duplicar (08/11/2026) */
.contador { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; margin-left: .2rem; border-radius: 999px; background: var(--marca); color: #fff; font-size: .72rem; font-weight: 700; vertical-align: 1px; }
.pendentes { background: var(--marca-clara); border: 1px solid var(--marca); border-radius: var(--raio); padding: 1rem 1.1rem; margin: 0 0 1.5rem; }
.pendentes h2 { margin: 0 0 .6rem; font-size: 1rem; color: var(--marca-forte); }
.pendente { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap; padding: .65rem 0; border-top: 1px solid color-mix(in srgb, var(--marca) 25%, transparent); }
.pendente:first-of-type { border-top: 0; padding-top: 0; }
.pendente strong { display: block; }
.pendente span { color: var(--suave); font-size: .9rem; }
.acoes-linha { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.acoes-linha form { margin: 0; }
.tabela .acoes-linha a, .tabela .link { font-size: .9rem; }
.link.forte { color: var(--marca); font-weight: 600; }
.titulo-acao { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.vazio p { margin: 0 0 .4rem; }
.linha2 { display: block; color: var(--suave); font-size: .8rem; white-space: normal; }
.selo-pendente { background: var(--marca-clara); color: var(--marca); }
.selo-ativa { background: var(--ok-fundo); color: var(--ok); }
.selo-pausa { background: var(--fundo); color: var(--suave); border: 1px solid var(--linha); }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.mais { border: 1px solid var(--linha); border-radius: 8px; padding: .7rem .9rem; }
.mais summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.mais-in { display: grid; gap: 1rem; margin-top: .9rem; }
.avisos { margin-top: 1.75rem; }
.avisos h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.linha-form { display: flex; gap: .6rem; flex-wrap: wrap; }
.linha-form input { flex: 1 1 220px; width: auto; }
@media (max-width: 640px) {
  .duas { grid-template-columns: 1fr; }
  .tabela td:last-child { min-width: 9rem; }
}

/* Notas canceladas ou substituídas (sincronização com o sistema nacional) */
.selo-cancelada { background: var(--erro-fundo); color: var(--erro); }
tr.riscada td:nth-child(4) { text-decoration: line-through; color: var(--suave); }

/* Fase C: pessoas, equipe e certificado */
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.troca-empresa { margin: 0; }
.troca-empresa select, .empresa-atual { font-size: .88rem; color: var(--suave); }
.troca-empresa select { width: auto; max-width: 16rem; padding: .3rem .5rem; }
.empresa-atual { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entrar.largo { max-width: 560px; }
.entrar form { display: grid; gap: 1rem; }
.link-baixo { margin: 1rem 0 0; text-align: center; }
.totp { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; align-items: center; border: 1px solid var(--linha); border-radius: 8px; padding: .8rem; }
.totp p { margin: .3rem 0; font-size: .85rem; }
.qr { width: 160px; height: 160px; display: block; border-radius: 6px; }
.segredo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; }
.subtitulo { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
.miudo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.linha-form.compacto { gap: .35rem; align-items: center; flex-wrap: nowrap; }
.linha-form.compacto select { width: auto; padding: .25rem .4rem; font-size: .85rem; }
@media (max-width: 640px) {
  .totp { grid-template-columns: 1fr; justify-items: start; }
}
.quem { color: var(--suave); font-size: .85rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo nav { flex-wrap: wrap; row-gap: .4rem; }
@media (max-width: 640px) {
  .topo nav { gap: .45rem 1rem; }
  .topo nav a, .topo nav .link { font-size: .9rem; }
}

/* Rodapé com a versão do sistema */
.rodape { max-width: 860px; margin: 0 auto; padding: 0 16px 2rem; color: var(--suave); font-size: .78rem; text-align: center; }

/* 1.7.0: login em duas etapas, código por e-mail e Minha conta */
.codigo-email { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.25rem; letter-spacing: .18em; text-transform: uppercase; }
.cartao h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.cartao + .cartao { margin-top: 1.25rem; }
.lista { margin: 0; padding-left: 1.1rem; }
