/* =========================================================================
   Design system — Prefeitura Municipal de Feira Nova
   Cores extraídas da logo oficial (assets/LogoFeiraNova.png).
   ========================================================================= */
:root {
    /* Marca */
    --fn-verde-900: #0b3a23;
    --fn-verde-800: #105031;   /* "FEIRA" */
    --fn-verde-600: #068d45;   /* "NOVA" */
    --fn-verde-100: #e3f2e9;
    --fn-verde-50:  #f1f8f4;
    --fn-vermelho-600: #cd1a21;
    --fn-vermelho-100: #fbe5e6;
    --fn-azul-800: #082f62;
    --fn-azul-600: #08568a;
    --fn-azul-100: #e2edf6;

    /* Neutros */
    --cinza-900: #18211c;
    --cinza-700: #3f4a44;
    --cinza-500: #67736c;
    --cinza-300: #d5dcd8;
    --cinza-200: #e6ebe8;
    --cinza-100: #f3f5f4;
    --branco: #ffffff;

    /* Semânticos */
    --bg: var(--cinza-100);
    --surface: var(--branco);
    --text: var(--cinza-900);
    --muted: var(--cinza-500);
    --border: var(--cinza-200);
    --primary: var(--fn-verde-800);
    --focus: var(--fn-azul-600);
    --alerta-bg: #fff7e0;
    --alerta-borda: #e9c46a;
    --alerta-texto: #6b4e00;

    /* Forma e ritmo */
    --raio-sm: 6px;
    --raio: 12px;
    --raio-lg: 16px;
    --sombra-1: 0 1px 2px rgba(16, 40, 28, .06), 0 1px 3px rgba(16, 40, 28, .08);
    --sombra-2: 0 4px 12px rgba(16, 40, 28, .08), 0 2px 4px rgba(16, 40, 28, .05);
    --fonte: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --fonte-titulo: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--fonte);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }

.ico { width: 1.25em; height: 1.25em; flex: none; }

.pular {
    position: absolute; left: 16px; top: -48px; z-index: 10;
    background: var(--primary); color: var(--branco); padding: 8px 14px; border-radius: var(--raio-sm);
    text-decoration: none; font-weight: 600;
}
.pular:focus { top: 8px; }

/* ---------- Barra institucional ---------- */
.barra-gov { background: var(--fn-verde-900); color: rgba(255,255,255,.85); font-size: .8rem; letter-spacing: .02em; }
.barra-gov .wrap { display: flex; gap: 8px; align-items: center; min-height: 32px; }
.barra-gov .sep { opacity: .5; }
.barra-gov a, .trilha a { color: inherit; text-decoration: none; }
.barra-gov a:hover, .trilha a:hover { color: var(--branco); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Cabeçalho ---------- */
.cabecalho { background: var(--branco); }
.cabecalho-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding-top: 16px; padding-bottom: 16px;
}
.marca img { height: 64px; width: auto; }
.orgao-responsavel {
    margin: 0; max-width: 360px; text-align: left;
    color: var(--cinza-700); font-size: .85rem; line-height: 1.35;
    padding-left: 20px; border-left: 3px solid var(--fn-verde-600);
}
@media (max-width: 720px) {
    .cabecalho-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
    .marca img { height: 52px; }
    .orgao-responsavel { text-align: left; max-width: none; }
}

/* Faixa tricolor da marca */
.faixa { display: grid; grid-template-columns: 3fr 1fr 1.2fr; height: 4px; }
.faixa span:nth-child(1) { background: var(--fn-verde-600); }
.faixa span:nth-child(2) { background: var(--fn-vermelho-600); }
.faixa span:nth-child(3) { background: var(--fn-azul-600); }

/* ---------- Destaque (título da página) ---------- */
.destaque {
    background:
        radial-gradient(1200px 300px at 100% 0%, rgba(6,141,69,.35), transparent 60%),
        linear-gradient(135deg, var(--fn-verde-800) 0%, var(--fn-verde-900) 100%);
    color: var(--branco);
    padding: 28px 0 72px;
}
.trilha ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; font-size: .82rem; color: rgba(255,255,255,.75); }
.trilha li + li::before { content: "›"; margin-right: 6px; opacity: .6; }
.trilha [aria-current] { color: var(--branco); font-weight: 600; }
.destaque h1 {
    margin: 0 0 8px; font-family: var(--fonte-titulo); font-weight: 700;
    font-size: clamp(1.6rem, 3.6vw, 2.4rem); line-height: 1.15; letter-spacing: -.01em;
}
.lead { margin: 0 0 20px; max-width: 680px; color: rgba(255,255,255,.85); font-size: 1.02rem; }
.acoes { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.selo {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
    padding: 6px 12px; border-radius: 999px; font-size: .85rem;
}
.pulso { width: 8px; height: 8px; border-radius: 50%; background: #5ee39a; box-shadow: 0 0 0 0 rgba(94,227,154,.6); animation: pulso 2s infinite; }
.selo-alerta .pulso { background: #ffd166; animation: none; }
@keyframes pulso { 70% { box-shadow: 0 0 0 8px rgba(94,227,154,0); } 100% { box-shadow: 0 0 0 0 rgba(94,227,154,0); } }
@media (prefers-reduced-motion: reduce) { .pulso { animation: none; } }

.botao {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--branco); color: var(--fn-verde-800);
    border: 0; border-radius: var(--raio-sm); padding: 8px 14px;
    font: 600 .9rem var(--fonte); cursor: pointer; box-shadow: var(--sombra-1);
}
.botao:hover { background: var(--fn-verde-50); }

/* ---------- Conteúdo ---------- */
.conteudo { margin-top: -48px; padding-bottom: 48px; position: relative; }

.titulo-secao { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi {
    --tom: var(--fn-verde-600); --tom-bg: var(--fn-verde-100);
    position: relative; overflow: hidden;
    background: var(--surface); border-radius: var(--raio-lg); box-shadow: var(--sombra-2);
    padding: 20px 20px 18px;
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--tom); }
.kpi-verde    { --tom: var(--fn-verde-600);    --tom-bg: var(--fn-verde-100); }
.kpi-azul     { --tom: var(--fn-azul-600);     --tom-bg: var(--fn-azul-100); }
.kpi-escuro   { --tom: var(--fn-verde-800);    --tom-bg: var(--fn-verde-100); }

.kpi-ico {
    width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
    background: var(--tom-bg); color: var(--tom); margin-bottom: 14px;
}
.kpi-rotulo { margin: 0; color: var(--muted); font-size: .88rem; font-weight: 500; }
.kpi-valor {
    margin: 2px 0 0; font-family: var(--fonte-titulo); font-weight: 700;
    font-size: 2.1rem; line-height: 1.15; letter-spacing: -.01em; font-variant-numeric: tabular-nums;
    color: var(--cinza-900);
}
.kpi-valor-texto { font-size: 1.35rem; color: var(--cinza-700); padding: 6px 0 2px; }
.kpi-nota { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }

/* Cartões */
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-bottom: 24px; }
.cartao { background: var(--surface); border-radius: var(--raio-lg); box-shadow: var(--sombra-1); padding: 20px; overflow-x: auto; }
.cartao-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cartao-topo h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--fonte-titulo); font-size: 1.05rem; font-weight: 650; color: var(--fn-verde-800); }
.contador { background: var(--fn-verde-100); color: var(--fn-verde-800); font-weight: 700; font-size: .85rem; padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.contador-azul { background: var(--fn-azul-100); color: var(--fn-azul-800); }

/* Tabela */
.tabela { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tabela th, .tabela td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela thead th { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom-color: var(--cinza-300); }
.tabela tbody tr:hover { background: var(--fn-verde-50); }
.tabela tfoot th, .tabela tfoot td { font-weight: 700; border-bottom: 0; padding-top: 12px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-dist { width: 38%; white-space: nowrap; }
.sigla {
    display: inline-block; min-width: 2.6em; text-align: center; margin-right: 6px;
    background: var(--fn-verde-800); color: var(--branco);
    border-radius: 5px; padding: 1px 6px; font-weight: 700; font-size: .75rem; letter-spacing: .03em;
}
.barra { display: inline-block; vertical-align: middle; width: calc(100% - 48px); height: 8px; background: var(--cinza-100); border-radius: 999px; overflow: hidden; }
.barra span { display: block; height: 100%; background: linear-gradient(90deg, var(--fn-verde-600), var(--fn-verde-800)); border-radius: inherit; }
section[aria-labelledby="t-aut"] .barra span { background: linear-gradient(90deg, var(--fn-azul-600), var(--fn-azul-800)); }
section[aria-labelledby="t-aut"] .sigla { background: var(--fn-azul-800); }
.pct { display: inline-block; width: 44px; text-align: right; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.vazio { color: var(--muted); margin: 0; }

@media (max-width: 520px) {
    .col-dist { display: none; }
}

/* Notas */
.notas dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px 28px; }
.notas dt { font-weight: 650; font-size: .9rem; color: var(--cinza-900); margin-bottom: 2px; }
.notas dd { margin: 0; color: var(--cinza-700); font-size: .9rem; }
.notas .ico { color: var(--fn-verde-600); }

/* Avisos */
.aviso { display: flex; gap: 12px; align-items: flex-start; border-radius: var(--raio); padding: 14px 18px; margin-bottom: 20px; border: 1px solid; box-shadow: var(--sombra-1); }
.aviso p, .aviso h2 { margin: 0; }
.aviso h2 { font-size: 1.05rem; margin-bottom: 4px; }
.aviso .ico { margin-top: 2px; }
.aviso-alerta { background: var(--alerta-bg); border-color: var(--alerta-borda); color: var(--alerta-texto); }
.aviso-erro { background: var(--fn-vermelho-100); border-color: #eaa3a6; color: #7a1014; }

/* ---------- Rodapé ---------- */
.rodape { background: var(--fn-verde-900); color: rgba(255,255,255,.8); font-size: .85rem; }
.rodape-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 24px; padding-bottom: 28px; }
.rodape-marca { display: flex; align-items: center; gap: 14px; }
.rodape-marca img { width: 48px; height: 48px; background: var(--branco); border-radius: 50%; padding: 2px; }
.rodape-marca strong { display: block; color: var(--branco); font-size: .95rem; }
.rodape-marca span { display: block; max-width: 420px; line-height: 1.35; }
.rodape-fonte { margin: 0; }

.orgao-responsavel p { margin: 0; }
.so-impressao { display: none; }

/* =========================================================================
   Impressão / PDF — relatório institucional em A4
   ========================================================================= */
@page {
    size: A4 portrait;
    margin: 14mm 14mm 16mm;

    @bottom-left {
        content: "Prefeitura Municipal de Feira Nova · Painel de Consulta - Licenciamento Ambiental";
        font: 7.5pt "Segoe UI", Arial, sans-serif; color: #67736c;
    }
    @bottom-right {
        content: "Página " counter(page) " de " counter(pages);
        font: 7.5pt "Segoe UI", Arial, sans-serif; color: #67736c;
    }
}

@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; box-shadow: none !important; }

    html, body { background: #fff; }
    body { font-size: 9.5pt; line-height: 1.4; color: #18211c; }
    .wrap { max-width: none; padding: 0; }

    /* Oculta elementos de navegação do site */
    .barra-gov, .pular, .acoes, .trilha, .rodape, .kpi-ico, .titulo-secao { display: none !important; }
    .so-impressao { display: block; }

    /* Cabeçalho do documento */
    .cabecalho-inner { flex-direction: row; align-items: center; padding: 0 0 4mm; gap: 8mm; }
    .marca img { height: 17mm; width: auto; }
    .orgao-responsavel { text-align: right; border-left: 0; padding: 0; max-width: 85mm; font-size: 8.5pt; color: #3f4a44; }
    .doc-tipo {
        margin: 0 0 1mm !important; font-size: 10.5pt; font-weight: 700; letter-spacing: .04em;
        text-transform: uppercase; color: var(--fn-verde-800);
    }
    .faixa { height: 1.2mm; }

    /* Título e ficha de identificação */
    .destaque { background: none; color: inherit; padding: 6mm 0 0; }
    .destaque h1 { font-size: 17pt; color: var(--fn-verde-800); margin: 0 0 1.5mm; }
    .lead { color: #3f4a44; font-size: 9.5pt; margin: 0 0 4mm; max-width: none; }
    .ficha {
        display: grid; grid-template-columns: repeat(4, auto); gap: 0;
        margin: 0; border: .6pt solid #cfd8d3; border-radius: 2mm; overflow: hidden;
    }
    .ficha > div { padding: 2mm 3mm; border-right: .6pt solid #cfd8d3; background: var(--fn-verde-50); }
    .ficha > div:nth-child(4) { border-right: 0; }
    .ficha .ficha-url { grid-column: 1 / -1; border-right: 0; border-top: .6pt solid #cfd8d3; background: #fff; }
    .ficha dt { font-size: 6.8pt; text-transform: uppercase; letter-spacing: .06em; color: #67736c; font-weight: 600; }
    .ficha dd { margin: .5mm 0 0; font-weight: 600; font-size: 9pt; word-break: break-all; }

    /* Conteúdo */
    .conteudo { margin-top: 0; padding: 5mm 0 0; }
    .aviso { box-shadow: none; padding: 2.5mm 4mm; margin-bottom: 4mm; font-size: 9pt; }

    /* Indicadores: 4 em linha, compactos */
    .kpis { grid-template-columns: repeat(3, 1fr); gap: 3mm; margin-bottom: 5mm; }
    .kpi { border: .6pt solid #cfd8d3; border-radius: 2mm; padding: 4mm 3.5mm 3mm; break-inside: avoid; }
    .kpi::before { height: 1.2mm; }
    .kpi-rotulo { font-size: 7.5pt; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; min-height: 2.6em; }
    .kpi-valor { font-size: 17pt; margin-top: 1mm; }
    .kpi-valor-texto { font-size: 11.5pt; padding: 1.5mm 0 .5mm; }
    .kpi-nota { font-size: 7.5pt; margin-top: 1mm; }

    /* Tabelas lado a lado */
    .grade { grid-template-columns: 1fr 1fr; gap: 4mm; margin-bottom: 5mm; }
    .cartao { border: .6pt solid #cfd8d3; border-radius: 2mm; padding: 4mm; overflow: visible; break-inside: avoid; }
    .cartao-topo { margin-bottom: 2mm; }
    .cartao-topo h2 { font-size: 10.5pt; }
    .contador { font-size: 8pt; }
    .tabela { font-size: 8.5pt; }
    .tabela th, .tabela td { padding: 1.8mm 1.5mm; }
    .tabela thead th { font-size: 6.8pt; }
    .tabela tbody tr:hover { background: none; }
    .col-dist { display: table-cell !important; width: 32%; }
    .barra { height: 2mm; width: calc(100% - 11mm); }
    .pct { width: 10mm; font-size: 7.5pt; }
    .sigla { font-size: 6.8pt; }

    /* Notas */
    .notas { padding: 4mm; }
    .notas dl { grid-template-columns: repeat(3, 1fr); gap: 2.5mm 6mm; }
    .notas dt { font-size: 8.5pt; }
    .notas dd { font-size: 8pt; }

    .encerramento {
        margin: 5mm 0 0; padding-top: 2.5mm; border-top: .6pt solid #cfd8d3;
        font-size: 7.5pt; color: #67736c; break-inside: avoid;
    }
}
