:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6;
  --warn-bg: #fff6e0;
  --warn-ink: #6b4a00;
  --s-gcp: #2a78d6;
  --s-r2: #eb6834;
  --s-magalu: #1baf7a;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --accent: #3987e5;
    --warn-bg: #2e2510;
    --warn-ink: #f3d08a;
    --s-gcp: #3987e5;
    --s-r2: #d95926;
    --s-magalu: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.05);
  --accent: #3987e5;
  --warn-bg: #2e2510;
  --warn-ink: #f3d08a;
  --s-gcp: #3987e5;
  --s-r2: #d95926;
  --s-magalu: #199e70;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
}
a { color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

.top h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--ink-2); }

.warnings {
  margin: 16px 0 0; padding: 10px 12px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 13px;
}
.warnings p { margin: 0; }
.warnings p + p { margin-top: 4px; }

/* ── filtros ─────────────────────────────────────────────────────────── */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  margin: 20px 0 16px;
}
.seg {
  display: inline-flex; background: var(--surface); border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--ring); padding: 2px; flex-wrap: wrap;
}
.seg button {
  font: inherit; font-size: 13px; color: var(--ink-2); background: none; border: 0;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.seg button:hover { background: var(--wash); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--surface); font-weight: 600; }
.seg button:focus-visible, .sel select:focus-visible, .more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sel { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.sel select {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 0; box-shadow: inset 0 0 0 1px var(--ring); border-radius: 8px; padding: 6px 8px;
  max-width: 220px;
}

/* ── KPIs ────────────────────────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 12px; margin-bottom: 16px;
}
.kpi { background: var(--surface); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--ring); padding: 14px 16px; min-width: 0; }
.kpi .label { color: var(--ink-2); font-size: 13px; }
.kpi .value { font-size: 26px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .value { font-size: 48px; line-height: 1.1; letter-spacing: -0.02em; }
.kpi .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi .bar { display: flex; gap: 2px; height: 6px; margin-top: 10px; }
.kpi .bar span { display: block; height: 100%; min-width: 0; }
.kpi .bar span:first-child { border-radius: 3px 0 0 3px; }
.kpi .bar span:last-child { border-radius: 0 3px 3px 0; }
.kpi .bar span:only-child { border-radius: 3px; }
@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi.hero { grid-column: 1 / -1; }
  .kpi.hero .value { font-size: 40px; }
  .kpi .value { font-size: 20px; }
}

/* ── cartões ─────────────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--ring); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 12px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } .grid2 .card { margin-bottom: 16px; } }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend b { color: var(--ink); font-weight: 600; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart path { pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--wash); }
.chart .partial { opacity: 0.45; }
.chart .empty { fill: var(--muted); font-size: 13px; }

/* barras horizontais por uso */
.hbars { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 8px 12px; align-items: center; }
.hbars .row { display: contents; }
.hbars .name { min-width: 0; cursor: pointer; }
.hbars .name b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbars .name small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbars .name a { color: inherit; text-decoration: none; }
.hbars .name a:hover, .hbars .name a:focus-visible { text-decoration: underline; }
.hbars .track { display: flex; gap: 2px; height: 16px; min-width: 0; cursor: pointer; }
.hbars .track span { height: 100%; min-width: 0; }
.hbars .track span:last-child { border-radius: 0 4px 4px 0; }
.hbars .track span:hover { filter: brightness(1.12); }
.hbars .val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbars .val small { color: var(--muted); margin-left: 6px; font-size: 12px; }
.hbars .row.sel .name b { font-weight: 700; }
.hbars .row:focus-within .name b { text-decoration: underline; }
.hbars .empty { grid-column: 1 / -1; color: var(--muted); }
@media (max-width: 560px) {
  .hbars { display: block; }
  .hbars .row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name val" "track track"; gap: 4px 12px; margin-bottom: 12px; }
  .hbars .name { grid-area: name; }
  .hbars .val { grid-area: val; align-self: start; }
  .hbars .track { grid-area: track; }
}

/* tabelas */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td.res { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .hide-sm { display: none; } }
tr.tot td { font-weight: 600; border-bottom: 0; }
td .key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.tableview { margin-top: 12px; }
.tableview summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.tableview .scroll { max-height: 360px; overflow-y: auto; margin-top: 8px; }
.more { font: inherit; font-size: 13px; margin-top: 10px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }

.notes { color: var(--ink-2); font-size: 12px; margin-top: 24px; max-width: 80ch; }
.notes p { margin: 0 0 8px; }

/* tooltip */
.tip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 1px var(--ring), 0 6px 20px rgba(0, 0, 0, 0.12); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; min-width: 150px; max-width: 280px;
}
.tip .t { color: var(--ink-2); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .r span { color: var(--ink-2); }
.tip .k { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip .tot { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }

@media (forced-colors: active) {
  .hbars .track span, .kpi .bar span, .legend .sw { forced-color-adjust: none; }
}
