:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --line: #e6e5e0;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0f7b3f;
  --good-bg: #e6f4ec;
  --bad: #c0302f;
  --bad-bg: #fbeaea;
  --warn: #9a6400;
  --warn-bg: #fdf3dc;
  --radius: 10px;
  --fn-a: #0a5fe0;
  --fn-b: #c2417a;
  --fn-line: #b9b5f0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --line: #2d2d2b;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #4cc47f;
    --good-bg: #16301f;
    --bad: #ef7c7b;
    --bad-bg: #3a1a1a;
    --warn: #e8b64a;
    --warn-bg: #352a10;
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --line: #2d2d2b;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #4cc47f;
    --good-bg: #16301f;
    --bad: #ef7c7b;
    --bad-bg: #3a1a1a;
    --warn: #e8b64a;
    --warn-bg: #352a10;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }
.muted { color: var(--muted) !important; }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* topo */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
nav { display: flex; gap: 4px; overflow-x: auto; }
nav a { color: var(--text-2); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
nav a.on { background: var(--bg); color: var(--text); font-weight: 600; }
nav a:hover { text-decoration: none; background: var(--bg); }

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.sub { color: var(--text-2); margin: 0 0 16px; }

/* cartões */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 820px) { .kpis { grid-template-columns: repeat(2, 1fr); } .kpi .v { font-size: 18px; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { color: var(--text-2); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* filtros */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.seg a { padding: 5px 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; }
.seg a.on { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.seg a:hover { text-decoration: none; }
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
textarea { width: 100%; min-height: 90px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input[type=text], input[type=password], input[type=email], input[type=number] { width: 100%; }
.filters input[type=date] { width: auto; }
button, .btn { cursor: pointer; background: var(--accent); color: #fff; border: 0; font-weight: 600; padding: 8px 14px; border-radius: 8px; display: inline-block; }
.btn:hover, button:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost, button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
.help { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .row2 { grid-template-columns: 1fr; } }

/* tabelas */
.tbl-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; white-space: nowrap; }
th a { color: inherit; }
tbody tr:hover { background: var(--bg); }
tfoot td { font-weight: 700; border-bottom: 0; }
td .nm { font-weight: 600; max-width: 380px; overflow: hidden; text-overflow: ellipsis; display: block; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag.aprovada { background: var(--good-bg); color: var(--good); }
.tag.reembolsada, .tag.chargeback { background: var(--bad-bg); color: var(--bad); }
.tag.pendente { background: var(--warn-bg); color: var(--warn); }
.tag.cancelada, .tag.outro { background: var(--bg); color: var(--muted); }
.tag.bump { background: var(--bg); color: var(--text-2); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.erro { background: var(--bad-bg); color: var(--bad); }
.flash.aviso { background: var(--warn-bg); color: var(--warn); }

code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.copy { position: relative; }

/* gráfico */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .b1 { fill: var(--series-1); }
.chart .b2 { fill: var(--series-2); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--line); fill-opacity: .5; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* login */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }

/* funil */
.vis-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.vis-tool select { max-width: 320px; }
.funnel { --cols: 5; }
.fn-cols { display: grid; grid-template-columns: repeat(var(--cols), 1fr); }
.fn-h { text-align: center; font-weight: 700; font-size: 13px; color: var(--text-2); padding: 0 4px 10px; }
.fn-plot { position: relative; height: 300px; }
.fn-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fn-over { position: absolute; inset: 0; }
.fn-c { display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--fn-line); }
.fn-c:first-child { border-left: 0; }
.fn-p { color: #fff; font-weight: 800; font-size: 17px; text-shadow: 0 1px 3px rgba(0,0,0,.45); font-variant-numeric: tabular-nums; }
/* etapa fina: número acima da faixa, na cor do texto */
.fn-p.thin { color: var(--text); text-shadow: none; transform: translateY(-26px); }
.fn-f { text-align: center; padding-top: 10px; font-variant-numeric: tabular-nums; }
.fn-f b { display: block; font-size: 15px; }
.fn-f span { display: block; font-size: 11px; color: var(--muted); }
@media (max-width: 720px) {
  .fn-plot { height: 200px; }
  .fn-h { font-size: 11px; }
  .fn-p { font-size: 13px; }
  .fn-f span { display: none; }
}
/* países */
.flag { font-size: 16px; }
.bar { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
.brand .brand-b { color: var(--accent); margin-left: -8px; }

/* comparação */
.dl { font-weight: 700; font-size: 12px; margin-right: 2px; }

/* tabela de métricas */
table.mt th, table.mt td { white-space: nowrap; }
table.mt th.num a { color: inherit; }
table.mt .stick { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; max-width: 320px; white-space: normal; box-shadow: 1px 0 0 var(--line); }
table.mt tbody tr:hover .stick { background: var(--bg); }
table.mt td .nm { max-width: 300px; }
@media (max-width: 720px) { table.mt .stick { min-width: 150px; max-width: 170px; } }

/* seletor de colunas */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dlg-head button { padding: 4px 10px; }
.dlg-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chip { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 12px; font-weight: 600; }
.dlg-body { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; flex: 1; }
.dlg-col { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.dlg-col:last-child { border-right: 0; }
.dlg-t { display: flex; align-items: center; gap: 6px; padding: 10px 16px; font-weight: 700; font-size: 13px; }
.dlg-scroll { overflow-y: auto; padding: 0 16px 12px; height: 52vh; margin: 0; }
.grp-t { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; }
.ck { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.ck:hover { background: var(--bg); }
.ck i { font-style: normal; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 50%; width: 15px; height: 15px; display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
ol.sel { list-style: none; }
ol.sel li { display: flex; align-items: center; gap: 6px; padding: 6px 6px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--bg); }
ol.sel .n { width: 22px; text-align: center; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
ol.sel .t { flex: 1; font-size: 13px; }
.ic { background: var(--surface); color: var(--text); border: 1px solid var(--line); padding: 2px 8px; font-size: 11px; border-radius: 6px; }
.ic:disabled { opacity: .3; cursor: default; }
.ic.x { color: var(--bad); }
.dlg-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 720px) {
  .dlg-body { grid-template-columns: 1fr; }
  .dlg-col { border-right: 0; border-bottom: 1px solid var(--line); }
  .dlg-scroll { height: 30vh; }
}
.dl.neu { color: var(--text-2); }
