/* Layout: ferramenta de escritório. Faixa superior fixa com abas, resumo antes do detalhe,
   números alinhados em colunas. Paleta padrão da marca H9: marinho #0F2D5C para ação e títulos,
   dourado #C9A84C só em filetes e destaques (não em texto), creme #F5F0E8 de fundo e carvão
   #2C2C2A no texto. Vermelho, âmbar e verde ficam reservados para estado. */
:root {
  --paper: #F5F0E8;
  --surface: #ffffff;
  --ink: #2C2C2A;
  --muted: #665f52;
  --line: #e3dccf;
  --accent: #0F2D5C;
  --accent-soft: #e4e9f1;
  --on-accent: #ffffff;
  --gold: #C9A84C;
  --bad: #a8271f;    --bad-soft: #f8e1df;
  --warn: #8f5606;   --warn-soft: #fbecd2;
  --info: #3d4f9a;   --info-soft: #e3e7f7;
  --good: #1c6e46;   --good-soft: #dcefe4;
  --display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a1622; --surface: #122335; --ink: #e5edf6; --muted: #93a4b7; --line: #25394e;
    --accent: #9cc4ee; --accent-soft: #1a3350; --on-accent: #0a1622; --gold: #e2bd5c;
    --bad: #ff9d94; --bad-soft: #3d1b19; --warn: #f1bc6a; --warn-soft: #3a2a10;
    --info: #a9b6f5; --info-soft: #1e2647; --good: #7fd3a6; --good-soft: #153325;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0a1622; --surface: #122335; --ink: #e5edf6; --muted: #93a4b7; --line: #25394e;
  --accent: #9cc4ee; --accent-soft: #1a3350; --on-accent: #0a1622; --gold: #e2bd5c;
  --bad: #ff9d94; --bad-soft: #3d1b19; --warn: #f1bc6a; --warn-soft: #3a2a10;
  --info: #a9b6f5; --info-soft: #1e2647; --good: #7fd3a6; --good-soft: #153325;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* topo */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); border-top: 4px solid var(--accent); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px 0; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: flex-end; justify-content: space-between; }
.brand { display: flex; gap: 12px; align-items: center; padding-bottom: 10px; min-width: 0; }
.brand-logo { height: 44px; width: auto; background: #ffffff; border-radius: 6px; padding: 4px 6px; flex: none; }
.brand-text { border-left: 2px solid var(--gold); padding-left: 12px; min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 700; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--gold); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }
.view { display: flex; flex-direction: column; gap: 16px; }
.view[hidden] { display: none; }
.sec { font-size: 16px; margin-top: 8px; }
.fine { color: var(--muted); font-size: 13px; margin: 0; max-width: 85ch; }
.status { margin: 0; min-height: 0; font-size: 14px; font-weight: 500; color: var(--accent); }
.status:empty { display: none; }
.status.err { color: var(--bad); }

/* resumo */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 6px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font: 700 26px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; }
.tile.hl { border-top-color: var(--bad); }

/* botões */
.toolbar, .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: 500 14px/1.2 var(--body); padding: 9px 14px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-align: center; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.copybox { width: 100%; font: 13px/1.45 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); }

/* tabelas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { font: 600 12px/1.3 var(--body); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .n { text-align: right; white-space: nowrap; }
.grid tr.tot td { font-weight: 600; border-top: 2px solid var(--line); }
.grid tr.adj td { color: var(--muted); }
.grid td small { display: block; color: var(--muted); font-size: 12.5px; max-width: 46ch; }
.grid .acts { white-space: nowrap; text-align: right; }
.cname { font-weight: 600; }
.tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; margin-left: 6px; }
.up { color: var(--bad); font-weight: 600; }

.pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill.atingido { background: var(--bad-soft); color: var(--bad); }
.pill.monitorar { background: var(--warn-soft); color: var(--warn); }
.pill.revisar { background: var(--info-soft); color: var(--info); }
.pill.fora { background: var(--good-soft); color: var(--good); }

/* formulários */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px; }
.card h2 { font-size: 17px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f label, .pick label { font-size: 13px; font-weight: 500; color: var(--muted); }
.f small { color: var(--muted); font-size: 12.5px; }
input[type=text], select { font: 400 15px/1.3 var(--body); padding: 9px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); width: 100%; min-width: 0; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.row2.end { align-items: end; }
.quarters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.chk { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.chk input { margin-top: 3px; accent-color: var(--accent); }
.form-foot { display: flex; justify-content: flex-end; }
.pick { display: flex; flex-direction: column; gap: 4px; max-width: 460px; }
.two { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.prose ol, .prose ul { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; max-width: 75ch; }

/* resultado */
.res { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lead { font: 600 19px/1.35 var(--display); max-width: 40ch; }
.lead em { font-style: normal; color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--paper); border-radius: 5px; padding: 10px 12px; }
.stat b { display: block; font: 700 20px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; font-size: 13.5px; }
.bar-row .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 12px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--muted); border-radius: 3px; }
.bar-row.now .bar-fill { background: var(--accent); }
.notes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.notes li { border-left: 4px solid var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 0 5px 5px 0; font-size: 14px; }
.notes li.info { border-left-color: var(--info); background: var(--info-soft); }
.verdict { font-weight: 600; }

.foot { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); font-size: 13px; padding: 22px 16px 30px; border-top: 1px solid var(--line); }
.foot img { height: 84px; width: auto; background: #ffffff; border-radius: 8px; padding: 8px 10px; }
.rep-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: #e6dfd2; padding: 16px; }

@media (max-width: 860px) {
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .quarters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs a { padding: 10px 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .tabs a { transition: border-color .15s, color .15s; }
}
