:root {
    --verde: #2f6b3a;
    --verde-escuro: #1f4d28;
    --verde-claro: #e8f2ea;
    --texto: #1f2421;
    --sutil: #5f6b63;
    --borda: #d5ddd7;
    --fundo: #f5f7f5;
    --branco: #fff;
    --erro: #b3261e;
    --erro-fundo: #fdecea;
    --aviso: #8a5a00;
    --aviso-fundo: #fff4d6;
    --sucesso-fundo: #e6f4ea;
    --raio: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--fundo); }
a { color: var(--verde); }
h1 { font-size: 1.5rem; margin: 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.topo { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--verde-escuro); color: #fff; flex-wrap: wrap; }
.topo a { color: #fff; text-decoration: none; }
.marca { font-weight: 700; font-size: 1.05rem; }
.topo nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topo nav a { padding: .35rem .65rem; border-radius: 6px; }
.topo nav a.ativo, .topo nav a:hover { background: rgba(255,255,255,.15); }
.usuario { margin-left: auto; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.usuario form { margin: 0; }
.usuario select { padding: .25rem; border-radius: 6px; }
.link { background: none; border: 0; color: #fff; cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

.conteudo { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.faixa-homologacao { background: var(--aviso-fundo); color: var(--aviso); border: 1px dashed #d6a84a; padding: .4rem .75rem; border-radius: var(--raio); margin-bottom: 1rem; font-size: .9rem; }
.cabecalho { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cabecalho h2 { margin: 0; }
.sutil { color: var(--sutil); font-size: .92rem; }

.cartao { background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.cartao-estreito { max-width: 420px; margin: 3rem auto; }
.duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .duas-colunas { grid-template-columns: 1fr; } }

fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend { font-weight: 600; margin-bottom: .5rem; }
.linha { display: flex; gap: .75rem; flex-wrap: wrap; }
.campo { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .75rem; flex: 1 1 140px; min-width: 0; }
.campo.largo { flex: 3 1 260px; }
.campo label { font-size: .85rem; font-weight: 600; color: #36403a; }
.obrigatorio { color: var(--erro); }
input, select, textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--borda); border-radius: 6px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde); outline-offset: 0; border-color: var(--verde); }
input[readonly] { background: var(--fundo); }
.com-erro input, .com-erro select, .com-erro textarea { border-color: var(--erro); }
.erro { color: var(--erro); font-size: .82rem; }
.ajuda { color: var(--sutil); font-size: .8rem; }
.marcar { display: flex; gap: .4rem; align-items: center; margin-bottom: 1rem; font-size: .9rem; }
.marcar input { width: auto; }

.botao { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .9rem; border: 1px solid var(--borda); border-radius: 6px; background: #fff; color: var(--texto); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.botao:hover { background: var(--verde-claro); }
.botao-primario { background: var(--verde); border-color: var(--verde); color: #fff; }
.botao-primario:hover { background: var(--verde-escuro); }
.botao-perigo { color: var(--erro); border-color: #e6b5b0; }
.botao-perigo:hover { background: var(--erro-fundo); }
.botao-pequeno { padding: .25rem .55rem; font-size: .85rem; }
.botao.largo { width: 100%; }
.botao[disabled] { opacity: .6; cursor: progress; }
.barra-acoes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.barra-acoes form, .acoes form { margin: 0; }
.acoes { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }

.alerta { padding: .7rem .9rem; border-radius: var(--raio); margin-bottom: 1rem; border: 1px solid transparent; }
.alerta ul { margin: 0; padding-left: 1.2rem; }
.alerta-sucesso { background: var(--sucesso-fundo); border-color: #b7dfc2; }
.alerta-aviso { background: var(--aviso-fundo); border-color: #f0d58c; color: #5c3d00; }
.alerta-erro { background: var(--erro-fundo); border-color: #f2b8b5; color: #7a1a14; }

.tabela { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; margin-bottom: 1rem; }
.tabela th, .tabela td { padding: .55rem .65rem; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: middle; }
.tabela th { background: var(--fundo); font-size: .85rem; color: #36403a; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabela tfoot td { font-weight: 600; }
.tabela tfoot .total td { font-size: 1.05rem; }
.vazio { text-align: center; color: var(--sutil); padding: 1.5rem; }
@media (max-width: 800px) { .tabela { display: block; overflow-x: auto; } }

.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.filtros input[type=search] { flex: 1 1 260px; width: auto; }
.filtros select, .filtros input[type=date] { width: auto; }
.filtros label { display: flex; gap: .3rem; align-items: center; font-size: .9rem; }

.status { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eceeed; color: #3d4540; }
.status-autorizada, .status-autorizado { background: #d7efdd; color: #1d5a2b; }
.status-rejeitada, .status-denegada, .status-rejeitado, .status-denegado { background: var(--erro-fundo); color: var(--erro); }
.status-cancelada, .status-cancelado { background: #ececec; color: #555; text-decoration: line-through; }
.status-pendente { background: var(--aviso-fundo); color: var(--aviso); }
.selo { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 4px; text-transform: uppercase; letter-spacing: .03em; }
.selo-homologacao { background: #ffe29a; color: #5c3d00; }
.selo-producao { background: #c9f0d3; color: #1d5a2b; }

.item { border: 1px solid var(--borda); border-radius: var(--raio); padding: .75rem .9rem; margin-bottom: .75rem; background: #fbfcfb; }
.item-cabecalho { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
details summary { cursor: pointer; color: var(--verde); font-size: .9rem; margin-bottom: .5rem; }
.total-nota { text-align: right; font-size: 1.1rem; margin: .5rem 0 0; }

.dados { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dados dt { font-weight: 600; color: #36403a; }
.dados dd { margin: 0; }
.chave { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }
@media (max-width: 600px) { .dados { grid-template-columns: 1fr; } .dados dd { margin-bottom: .4rem; } }

.paginacao { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; color: var(--sutil); }
.rodape { text-align: center; color: var(--sutil, #6b7280); font-size: .85rem; padding: 1.5rem 1rem 2rem; }
.rodape a { color: inherit; }
.legal { max-width: 820px; margin: 0 auto; line-height: 1.55; }
.legal h2 { margin-top: 1.6rem; font-size: 1.1rem; }
.legal .pendente { background: #fff4d6; padding: 0 .25rem; border-radius: 3px; }
