:root {
  color-scheme: light;
  --bg: #f8f5ee;
  --surface: #ffffff;
  --surface-2: #f4f0e8;
  --text: #24272c;
  --muted: #6f6c64;
  --line: #ebe5da;
  --primary: #274a6d;
  --primary-2: #2f73b5;
  --primary-text: #ffffff;
  --accent-soft: #e9f0f7;
  --gold: #94722f;
  --ok: #2f6b4f;
  --ok-soft: #e7f3ec;
  --warn: #85622a;
  --warn-soft: #faf1df;
  --danger: #a23e3e;
  --s0: #f1ede4;
  --s1: #d9e7f4;
  --s2: #a9cae8;
  --s3: #6fa5d6;
  --s4: #2f73b5;
  --s5: #1b4674;
  --sombra: 0 1px 2px rgb(45 40 30 / .05), 0 4px 16px rgb(45 40 30 / .05);
  --serifa: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
table { border-collapse: collapse; width: 100%; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .92em; }

.casca { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.lateral { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 22px 14px; background: linear-gradient(180deg, #1f3c59 0%, #274a6d 100%); color: #dbe6f1; display: flex; flex-direction: column; gap: 22px; }
.marca { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.marca-icone { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: rgb(255 255 255 / .13); color: #f0d9a4; font-size: 20px; }
.marca b { display: block; color: #fff; font-family: var(--serifa); font-size: 18px; font-weight: 600; line-height: 1.15; }
.marca div span { color: #aebfd1; font-size: 12.5px; }
.menu { display: grid; gap: 3px; }
.menu button { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 41px; padding: 8px 12px; border: 0; border-radius: 9px; background: transparent; color: #c6d4e2; font-weight: 500; text-align: left; transition: background .15s, color .15s; }
.menu button:hover { background: rgb(255 255 255 / .08); color: #fff; }
.menu button[aria-current="page"] { background: rgb(255 255 255 / .15); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #e2bd6d; }
.selo { min-width: 20px; padding: 0 6px; border-radius: 10px; background: #e2bd6d; color: #2c2410; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.rodape-menu { margin-top: auto; padding: 0 10px; color: #a3b6c9; font-size: 12px; }

.conteudo { padding: 28px 32px 56px; max-width: 1320px; width: 100%; }
.cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.cabecalho h1 { font-family: var(--serifa); font-size: 30px; font-weight: 600; line-height: 1.12; letter-spacing: -.005em; }
.cabecalho p { color: var(--muted); font-size: 14px; margin-top: 3px; }

.filtros { padding: 12px 14px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sombra); }
.filtros-campos { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filtros .pilulas { margin-top: 10px; }
.campo { display: grid; gap: 3px; min-width: 0; }
.campo > span { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.campo select, .campo input, .entrada { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.entrada.compacta { min-height: 32px; width: 100%; }
.campo-curto input { width: 80px; }
.pilulas { display: flex; flex-wrap: wrap; gap: 6px; }
.pilula { min-height: 31px; padding: 3px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; transition: background .15s, color .15s; }
.pilula:hover { background: var(--surface-2); }
.pilula[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.btn { min-height: 38px; padding: 7px 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-weight: 600; white-space: nowrap; transition: background .15s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.primario { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primario:hover:not(:disabled) { background: #1f3c59; }
.btn.grande { width: 100%; min-height: 46px; margin-top: 12px; }
.btn.perigo { color: var(--danger); }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.acoes.centro { justify-content: center; }
.acoes.fim { justify-content: flex-end; margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; min-height: 112px; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sombra); overflow: hidden; }
.kpi-r { display: block; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi b { display: block; margin-top: 4px; font-family: var(--serifa); font-size: 32px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.kpi-barra { display: block; height: 5px; margin-top: 9px; background: var(--s0); border-radius: 3px; overflow: hidden; }
.kpi-barra i { display: block; height: 100%; background: var(--primary-2); border-radius: 3px; }
.g-faisca { position: absolute; right: 12px; top: 14px; width: 92px; height: 30px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tile b { display: block; font-family: var(--serifa); font-size: 29px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.tiles { display: grid; gap: 12px; }

.grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.grade.doisum { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grade.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cartao { min-width: 0; padding: 18px 20px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sombra); }
.grade > .cartao { margin-bottom: 0; }
.cartao-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cartao-topo h2 { font-family: var(--serifa); font-size: 18.5px; font-weight: 600; line-height: 1.2; }
.cartao-topo p { margin-top: 2px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.ferramentas { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.vazio { padding: 24px; color: var(--muted); text-align: center; }
.fraco { color: var(--muted); }
.sem-quebra { white-space: nowrap; }
.quebra { overflow-wrap: anywhere; }
.linha-info { margin-bottom: 12px; }

/* Gráficos */
.g-svg { display: block; width: 100%; height: auto; }
.g-grade { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.g-grade.base { stroke: #cfc7b8; stroke-dasharray: none; }
.g-eixo { fill: var(--muted); font-size: 12px; }
.g-fim { fill: var(--text); font-size: 12px; font-weight: 600; }
.g-hit line { stroke: #8c98a6; stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.g-hit circle { opacity: 0; }
.g-hit rect { fill: transparent; pointer-events: all; }
.g-hit:hover line, .g-hit:hover circle { opacity: 1; }
.g-col rect { fill: transparent; pointer-events: all; }
.g-col:hover rect { fill: rgb(39 74 109 / .06); }
.g-legenda { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; color: var(--muted); font-size: 12.5px; }
.g-legenda i { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.ver-tabela summary { color: var(--muted); font-size: 12.5px; cursor: pointer; padding-top: 8px; }

.g-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.g-linha-rank { display: grid; grid-template-columns: auto minmax(58px, 150px) minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 3px 6px; border: 0; border-radius: 7px; background: transparent; text-align: left; }
button.g-linha-rank:hover { background: var(--surface-2); }
.g-pos { width: 20px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.g-nome { min-width: 0; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.g-nome small { display: block; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.g-trilho { display: block; height: 9px; background: var(--s0); border-radius: 5px; overflow: hidden; }
.g-trilho i { display: block; height: 100%; background: linear-gradient(90deg, #4f92d0, var(--primary-2)); border-radius: 5px; transform-origin: left; animation: crescer .55s cubic-bezier(.2, .7, .2, 1) both; }
.g-val { min-width: 34px; color: var(--text); font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grade.doisum > .cartao:last-child .g-linha-rank { grid-template-columns: minmax(0, 1fr) auto; row-gap: 4px; padding-block: 5px; }
.grade.doisum > .cartao:last-child .g-nome { grid-column: 1; grid-row: 1; font-weight: 500; }
.grade.doisum > .cartao:last-child .g-val { grid-column: 2; grid-row: 1; }
.grade.doisum > .cartao:last-child .g-trilho { grid-column: 1 / -1; grid-row: 2; }
@keyframes crescer { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.g-rosca { display: grid; gap: 12px; justify-items: center; }
.g-rosca svg { width: min(190px, 100%); height: auto; }
.g-rosca-v { fill: var(--text); font-family: var(--serifa); font-size: 32px; font-weight: 600; }
.g-rosca-s { fill: var(--muted); font-size: 12px; }
.g-rosca ul { list-style: none; width: 100%; margin: 0; padding: 0; display: grid; gap: 5px; }
.g-rosca li { display: grid; grid-template-columns: 11px minmax(0, 1fr) auto 50px; align-items: center; gap: 8px; font-size: 13px; }
.g-rosca li i { width: 11px; height: 11px; border-radius: 3px; }
.g-rosca li small { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.g-matriz-rolo { overflow-x: auto; }
.g-matriz { min-width: 700px; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.g-matriz th { padding: 3px 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: center; }
.g-matriz thead th:first-child, .g-matriz tbody th { width: 58px; }
.g-matriz tbody th button { width: 100%; min-height: 30px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 13px; }
.g-matriz td { height: 32px; border-radius: 5px; text-align: center; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-matriz td.g-total { background: transparent; color: var(--text); }
.n0 { background: var(--s0); color: transparent; }
.n1 { background: var(--s1); color: #1d3c5c; }
.n2 { background: var(--s2); color: #16324f; }
.n3 { background: var(--s3); color: #10263d; }
.n4 { background: var(--s4); color: #fff; }
.n5 { background: var(--s5); color: #fff; }
.g-mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 3px; max-height: 430px; overflow-y: auto; padding-right: 3px; }
.g-mapa button { height: 28px; padding: 0; border: 0; border-radius: 5px; font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; transition: transform .1s; }
.g-mapa button.n0 { color: #8c867a; }
.g-mapa button:hover { transform: scale(1.14); box-shadow: 0 2px 6px rgb(0 0 0 / .22); position: relative; z-index: 1; }
.g-escala { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.g-escala i { width: 20px; height: 12px; border-radius: 3px; }

.tabela-rolo { overflow-x: auto; }
.tabela th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 700; text-align: left; white-space: nowrap; }
.tabela th button { border: 0; padding: 0; background: none; color: inherit; font-weight: 700; }
.tabela td { padding: 7px 10px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.tabela td small { color: var(--muted); }
.tabela .n { text-align: right; font-variant-numeric: tabular-nums; }
.tabela tbody tr.clicavel { cursor: pointer; }
.tabela tbody tr.clicavel:hover { background: var(--surface-2); }
.tabela.espaco { margin-bottom: 12px; }
.linha-grupo td { padding-top: 12px; color: var(--gold); font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.rolo { max-height: 560px; overflow: auto; }
.rolo th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.hino-tag { display: inline-block; min-width: 40px; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--primary); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.celula-barra { display: flex; align-items: center; gap: 8px; min-width: 110px; }
td.celula-barra { border-bottom: 1px solid var(--surface-2); }
.celula-barra > span:first-child:not(.mini) { width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.mini { display: block; flex: 1; min-width: 60px; height: 6px; background: var(--s0); border-radius: 3px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--primary-2); border-radius: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { min-width: 42px; padding: 4px 7px; border: 0; border-radius: 6px; background: var(--accent-soft); color: var(--primary); font-size: 12.5px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
button.chip:hover { background: var(--s1); }

.aviso { padding: 11px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.sucesso { padding: 11px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-size: 14px; }
.erro { padding: 11px 14px; margin-bottom: 14px; border-radius: 10px; background: #f9e9e7; color: var(--danger); font-size: 14px; }
.soltar { padding: 20px; border: 1.5px dashed #d8d0c1; border-radius: 12px; color: var(--muted); text-align: center; }
.soltar.ativo { border-color: var(--primary-2); background: var(--accent-soft); }
.conflito { padding: 14px; margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; }
.conflito h3 { font-size: 15px; }
.conflito small { color: var(--muted); }
.conflito .tabela { margin: 8px 0 10px; }
.conflito .antes { background: #fbf4ee; }
.conflito .depois { background: #eef6f1; }
.linha-acao { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.pilha { display: grid; gap: 12px; }
.pilha > .btn { justify-self: start; }
.escolhas { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; padding: 0; border: 0; }
.escolhas legend { padding: 0; margin-bottom: 5px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.linha-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 260px)); gap: 12px; }
.nota { color: var(--muted); font-size: 12.5px; }

.entrada-fundo { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1f3c59 0%, #2d5379 62%, #3f6588 100%); }
.entrada-tela { width: min(440px, 100%); padding: 32px; background: var(--surface); border-radius: 18px; box-shadow: 0 18px 50px rgb(10 20 35 / .32); }
.entrada-tela .marca-icone { width: 46px; height: 46px; margin-bottom: 14px; background: var(--accent-soft); color: var(--gold); font-size: 24px; }
.entrada-tela h1 { font-family: var(--serifa); font-size: 29px; font-weight: 600; margin-bottom: 6px; }
.entrada-tela p { color: var(--muted); margin-bottom: 18px; }
.entrada-tela .entrada { width: 100%; font-size: 16px; }

#dica { position: fixed; z-index: 60; max-width: 280px; padding: 8px 11px; border-radius: 8px; background: #1f2a36; color: #fff; font-size: 12.5px; line-height: 1.4; pointer-events: none; white-space: pre-line; box-shadow: 0 6px 18px rgb(0 0 0 / .24); }
#toast { position: fixed; right: 22px; bottom: 22px; z-index: 70; max-width: min(420px, calc(100vw - 32px)); padding: 11px 15px; border-radius: 10px; background: #1f2a36; color: #fff; font-size: 14px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.visivel { opacity: 1; transform: none; }
dialog { width: min(620px, calc(100vw - 24px)); max-height: 88vh; padding: 22px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(10 20 35 / .3); }
dialog::backdrop { background: rgb(25 35 48 / .42); }
dialog h2 { font-family: var(--serifa); font-size: 22px; font-weight: 600; margin-bottom: 2px; }
dialog p { color: var(--muted); margin-bottom: 14px; }
dialog h3 { margin: 16px 0 6px; font-size: 12px; color: var(--gold); letter-spacing: .05em; text-transform: uppercase; }
dialog > .acoes { justify-content: flex-end; margin-top: 16px; }
.dlg-topo { display: flex; align-items: center; gap: 14px; }
.dlg-topo p { margin-bottom: 0; }
.hino-grande { flex: none; display: grid; place-items: center; min-width: 58px; height: 58px; padding: 0 8px; border-radius: 13px; background: linear-gradient(145deg, #2f73b5, #1b4674); color: #fff; font-family: var(--serifa); font-size: 23px; font-weight: 600; }
#relatorio { display: none; }

@media (max-width: 1120px) {
  .grade.doisum { grid-template-columns: minmax(0, 1fr); }
  .grade.tres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .casca { display: block; }
  .lateral { position: sticky; z-index: 20; height: auto; padding: 10px 12px 8px; gap: 8px; }
  .marca-icone { width: 30px; height: 30px; font-size: 16px; }
  .marca b { font-size: 16px; }
  .menu { display: flex; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .menu button { flex: none; min-height: 36px; padding: 6px 11px; font-size: 13.5px; }
  .menu button[aria-current="page"] { box-shadow: inset 0 -2px 0 #e2bd6d; }
  .rodape-menu { display: none; }
  .conteudo { padding: 16px 16px 40px; }
  .cabecalho h1 { font-size: 25px; }
  .grade, .grade.tres { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; }
  .kpi { min-height: 104px; padding: 12px 13px; }
  .kpi b { font-size: 26px; }
  .g-faisca { display: none; }
  .cartao { padding: 15px 14px; }
  .filtros-campos .campo { flex: 1 1 120px; }
  .filtros-campos select { width: 100%; }
  .filtros .pilulas { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding-inline: 14px; }
  .pilula { flex: none; }
  .g-linha-rank { grid-template-columns: auto minmax(52px, 96px) minmax(0, 1fr) auto; gap: 7px; }
  .linha-campos { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #toast, .menu button, .pilula, .g-mapa button { transition: none; }
  .g-trilho i { animation: none; }
}

@page { size: A4; margin: 14mm; }
@media print {
  html, body { background: #fff; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #app, #dica, #toast, #dlg { display: none !important; }
  #relatorio { display: block; color: #222; }
  #relatorio h1 { font-family: var(--serifa); font-size: 22pt; font-weight: 600; }
  #relatorio h2 { margin: 16pt 0 5pt; padding-bottom: 3pt; border-bottom: 1px solid #c9bda6; font-family: var(--serifa); font-size: 13.5pt; font-weight: 600; break-after: avoid; }
  #relatorio .meta { color: #555; font-size: 10pt; margin-bottom: 10pt; }
  #relatorio .tiles { grid-template-columns: repeat(5, 1fr); gap: 6pt; }
  #relatorio .tile { padding: 6pt 8pt; border-color: #d8cfbf; }
  #relatorio .tile b { font-size: 17pt; }
  #relatorio .tile span { font-size: 8.5pt; }
  #relatorio table { font-size: 9.5pt; }
  #relatorio th, #relatorio td { padding: 3pt 5pt; border-bottom: 1px solid #e5dfd3; text-align: left; }
  #relatorio .n { text-align: right; }
  #relatorio tr, #relatorio .bloco { break-inside: avoid; }
  #relatorio .duas { display: grid; grid-template-columns: 1fr 1fr; gap: 14pt; }
  #relatorio .chips { gap: 2pt; }
  #relatorio .chip { min-width: 26pt; padding: 1pt 3pt; font-size: 8.5pt; background: #eef1f4; }
  #relatorio .fim { margin-top: 14pt; color: #777; font-size: 8.5pt; }
}
