:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --good: #006300;
  --bad: #b42d2d;
  --s-lastlink: #2a78d6;
  --s-kiwify: #eb6834;
  --s-stripe: #1baf7a;
  --s-liquido: #6250d6;
  --s-taxas: #eda100;
  --s-afiliados: #e87ba4;
  --s-neutral: #52514e;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --good: #0ca30c;
    --bad: #e66767;
    --s-lastlink: #3987e5;
    --s-kiwify: #d95926;
    --s-stripe: #199e70;
    --s-liquido: #9085e9;
    --s-taxas: #c98500;
    --s-afiliados: #d55181;
    --s-neutral: #c3c2b7;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- topo */
.top {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 8px; }
.top nav a.on, .top nav a:hover { color: var(--ink); background: var(--page); text-decoration: none; }
.top form { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: 13px; }
button, .btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); padding: 7px 14px;
}
button:hover, .btn:hover { border-color: var(--axis); text-decoration: none; }
button.primary, .btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
button.link { border: 0; background: none; color: var(--ink-2); padding: 4px 6px; }
button.danger { color: var(--bad); }

/* ---------- títulos e filtros */
.head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 2px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--page); color: var(--ink); font-weight: 600; }

/* ---------- cartões */
.tiles { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.tile, .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.tile.hero .value { font-size: 40px; }
.tile .meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.delta-up { color: var(--good); }
.delta-down { color: var(--bad); }
.split { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.card .chart { position: relative; margin-top: 10px; height: 240px; }
.card .chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--ink-2); }
.legend .line-key { display: inline-block; width: 14px; height: 2px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }

.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); padding: 8px 10px; font-size: 12.5px; display: none;
}
.tip .t { color: var(--muted); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .r span { color: var(--ink-2); display: flex; align-items: center; }
.tip .line-key { display: inline-block; width: 12px; height: 2px; margin-right: 6px; border-radius: 2px; }

/* ---------- tabelas */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.l, th.l { text-align: left; }
tr.partial td { color: var(--muted); }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.ok { color: var(--good); }
.err { color: var(--bad); }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--page); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.stack > * + * { margin-top: 12px; }
.flash { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 13.5px; }

/* ---------- login */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login h1 { margin-bottom: 6px; }
.login .btn { display: block; margin-top: 18px; padding: 11px; }
.loading { opacity: 0.5; transition: opacity 0.2s; }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile.hero { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile .value { font-size: 20px; }
  .tile.hero .value { font-size: 32px; }
  .top { gap: 10px; }
  .who { display: none; }
}
.mt { margin-top: 12px; }
