:root {
  --bg: #faf8f4;
  --panel: #ffffff;
  --fg: #0f1d3a;
  --muted: #5d6678;
  --line: #e6e2d9;
  --accent: #1e9a87;
  --accent-soft: #e8f5f2;
  --accent-line: #cfe9e3;
  --ok: #17836f;
  --warn: #c9770c;
  --bad: #c2413b;
  --track: #dde2e7;
  --bar-muted: #b7bec9;
  --ref: #7a8396;
  --tip-bg: #ffffff;
  --shadow: 0 12px 32px rgba(15, 29, 58, .14);
  --radius: 14px;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1420;
    --panel: #151d2c;
    --fg: #e8ecf3;
    --muted: #9aa4b5;
    --line: #263043;
    --accent: #34b89f;
    --accent-soft: #11292a;
    --accent-line: #1d4541;
    --ok: #4cc2a9;
    --warn: #e6a04a;
    --bad: #e2726b;
    --track: #263043;
    --bar-muted: #4a5568;
    --ref: #8c95a8;
    --tip-bg: #1b2536;
    --shadow: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.pg { max-width: 72rem; margin: 0 auto; padding: 0 16px 48px; }
@media (min-width: 720px) { .pg { padding: 0 32px 64px; } }

.cor-ok { color: var(--ok); }
.cor-warn { color: var(--warn); }
.cor-bad { color: var(--bad); }

/* Topo */
.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.marca-nome { font-weight: 800; font-size: 20px; letter-spacing: -.01em; line-height: 1.1; }
.marca-sub { font-size: 13px; color: var(--muted); }
.topo-dir { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.estado { font-size: 12px; color: var(--muted); text-align: right; }
.estado.erro { color: var(--bad); }
.ano {
  font-weight: 600; font-size: 14px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel);
}

main { display: flex; flex-direction: column; gap: 24px; }

/* Cabeça */
.cabeca h1 {
  font-size: clamp(26px, 4.2vw, 40px); font-weight: 800; letter-spacing: -.02em;
  line-height: 1.12; margin: 0 0 6px;
}
.sub { margin: 0 0 14px; color: var(--muted); font-size: 16px; }
.lede { margin: 0; max-width: 50rem; font-size: 16px; }
.lede b { font-weight: 700; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
@media (min-width: 880px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 18px 16px;
  border-left: 1px solid var(--line); min-width: 0;
}
.kpis > :nth-child(odd) { border-left: 0; padding-left: 0; }
@media (min-width: 880px) {
  .kpis > :nth-child(odd) { border-left: 1px solid var(--line); padding-left: 18px; }
  .kpis > :first-child { border-left: 0; padding-left: 0; }
}
@media (max-width: 879px) { .kpis > :nth-child(-n+2) { border-bottom: 1px solid var(--line); } }
.kpi-btn {
  appearance: none; background: none; border: 0; border-left: 1px solid var(--line); border-radius: 0;
  margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.kpi-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.kpi-l { font-size: 14px; color: var(--muted); }
.kpi-v {
  font-size: clamp(26px, 3.4vw, 36px); font-weight: 800; letter-spacing: -.02em; line-height: 1.1;
  font-variant-numeric: tabular-nums; min-height: 1.1em;
}
.kpi-n { font-size: 12.5px; color: var(--muted); }
.kpi-mais { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--accent); }
.kpi-btn:hover .kpi-mais { text-decoration: underline; }

/* Cobertura */
.cobertura {
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius);
  padding: 22px 24px;
}
.big { margin: 0; font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.big span { font-weight: 800; }
.nota { margin: 4px 0 14px; color: var(--muted); font-size: 13.5px; }
.nota-fim { margin: 14px 0 0; }
.cobertura .nota { font-size: 16px; }
.barra { position: relative; height: 16px; border-radius: 8px; background: var(--track); overflow: hidden; margin: 16px 0 6px; }
.barra-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 8px; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .barra-fill { transition: width .8s cubic-bezier(.2, .7, .2, 1); } }
.barra-leg { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.split {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 16px 28px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--accent-line);
}
.split-item { display: flex; gap: 12px; align-items: flex-start; }
.ico { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-top: 1px; }
.split-t { font-weight: 700; }
.split-v { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.split-n { color: var(--muted); font-size: 14px; }

/* Cards */
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.card h2, .dlg h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

.card-cab { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.botao {
  appearance: none; display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: 6px 12px;
}
.botao:hover { border-color: var(--accent); }
.botao:focus { outline: none; }
.botao:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rolagem.alta { max-height: 30rem; overflow: auto; }
.rolagem.alta .tab th { position: sticky; top: 0; background: var(--panel); z-index: 1; }

/* Tabelas */
.rolagem { overflow-x: auto; }
.tab { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.tab th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tab td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tab tr:last-child td { border-bottom: 0; }
.tab .n { text-align: right; white-space: nowrap; }
.tab td.m { color: var(--muted); font-size: 13px; }
.tab td.k { font-weight: 600; white-space: nowrap; }
.tab tr.total td { font-weight: 700; border-top: 1px solid var(--line); }
.tab td.vazio { color: var(--muted); text-align: center; padding: 18px 0; }
.pilula {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted);
}
.pilula.receita { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pilula.fixo { background: color-mix(in srgb, #4b6bdc 14%, transparent); color: #4b6bdc; }
.pilula.compra { background: color-mix(in srgb, #8a55d6 14%, transparent); color: #8a55d6; }
.pilula.manutencao { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
@media (prefers-color-scheme: dark) {
  .pilula.fixo { color: #8ea6f2; }
  .pilula.compra { color: #b993ef; }
}

/* Gráfico */
.legenda { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: 6px; vertical-align: -1px; }
.tracejado { display: inline-block; width: 18px; border-top: 2px dashed var(--ref); margin-right: 6px; vertical-align: 3px; }
.grafico { position: relative; min-height: 240px; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .rot-v { font-size: 12.5px; font-weight: 600; fill: var(--fg); font-variant-numeric: tabular-nums; }
.grafico .rot-m { font-size: 12.5px; fill: var(--muted); }
.tip {
  position: absolute; pointer-events: none; opacity: 0; z-index: 2; white-space: nowrap;
  background: var(--tip-bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12.5px; line-height: 1.5;
}
.tip-h { color: var(--muted); }

/* Pop-ups */
.dlg {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--panel); color: var(--fg); font-family: var(--sans);
  width: min(42rem, calc(100vw - 32px)); max-height: min(85vh, 44rem); overflow: auto;
  box-shadow: var(--shadow);
}
.dlg::backdrop { background: rgba(10, 16, 30, .45); }
.dlg-in { padding: 22px 24px; }
.dlg-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dlg-x {
  appearance: none; background: none; border: 0; cursor: pointer; color: var(--muted);
  font: inherit; font-size: 26px; line-height: 1; padding: 0 6px; margin: -6px -6px 0 0; border-radius: 6px;
}
.dlg-x:hover { color: var(--fg); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.dlg-x:focus { outline: none; }
.dlg-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.dlg h2:focus { outline: none; }

.rodape { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; max-width: 58rem; }

.carregando [data-campo] { color: transparent; background: var(--track); border-radius: 6px; }
