/* Tokens de cor. Claro por padrão; escuro pelo sistema ou pela escolha salva (data-theme).
   As cores de série dos gráficos seguem a paleta validada da skill de dataviz (contraste e daltonismo). */
:root {
  color-scheme: light;
  --page: #f5f5f2;
  --surface: #fcfcfb;
  --surface-2: #f3f3f0;
  --hover: rgb(11 11 11 / 0.04);
  --hover-strong: rgb(11 11 11 / 0.07);
  --border: rgb(11 11 11 / 0.09);
  --border-strong: rgb(11 11 11 / 0.15);
  --grid: #ecebe6;
  --chart-grid: #e1e0d9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --accent: #2a78d6;
  --focus: rgb(42 120 214 / 0.28);
  --ink: #161615;
  --ink-text: #fcfcfb;
  --good: #006300;
  --bad: #c43232;
  --warn: #9a6400;
  --dot-good: #0ca30c;
  --dot-warn: #fab219;
  --dot-bad: #d03b3b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-1-track: #e3eefc;
  --bar-muted: #d6d5cf;
  --notice-bg: #fbf6e8;
  --notice-border: #efe1b8;
  --shadow-pop: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  /* Curvas fortes (ease-out para resposta, curva de gaveta estilo iOS para o menu no celular). */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  /* Contorno em sombra semitransparente no lugar de borda sólida: não ocupa espaço e se mistura ao fundo. */
  --ring: 0 0 0 1px var(--border);
  --elev: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #212120;
    --hover: rgb(255 255 255 / 0.045);
    --hover-strong: rgb(255 255 255 / 0.08);
    --border: rgb(255 255 255 / 0.08);
    --border-strong: rgb(255 255 255 / 0.14);
    --grid: #252523;
    --chart-grid: #2c2c2a;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8d87;
    --accent: #3987e5;
    --focus: rgb(57 135 229 / 0.35);
    --ink: #f0efec;
    --ink-text: #111110;
    --good: #2bb82b;
    --bad: #e66767;
    --warn: #e5a514;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-1-track: #1f2f45;
  --bar-muted: #3a3a37;
    --notice-bg: #221d12;
    --notice-border: #3a311b;
    --shadow-pop: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0f0f0e;
  --surface: #1a1a19;
  --surface-2: #212120;
  --hover: rgb(255 255 255 / 0.045);
  --hover-strong: rgb(255 255 255 / 0.08);
  --border: rgb(255 255 255 / 0.08);
  --border-strong: rgb(255 255 255 / 0.14);
  --grid: #252523;
  --chart-grid: #2c2c2a;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8d87;
  --accent: #3987e5;
  --focus: rgb(57 135 229 / 0.35);
  --ink: #f0efec;
  --ink-text: #111110;
  --good: #2bb82b;
  --bad: #e66767;
  --warn: #e5a514;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-1-track: #1f2f45;
  --bar-muted: #3a3a37;
  --notice-bg: #221d12;
  --notice-border: #3a311b;
  --shadow-pop: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.45);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

::selection {
  background: var(--focus);
}

/* ---------- estrutura */
:root {
  --topbar-h: 52px;
  --sidebar-w: 248px;
}

/* Menu lateral opcional: aberto, ocupa uma coluna e empurra a página; fechado, a página usa a largura toda.
   A escolha fica salva. No celular ele abre em tela cheia (regras no fim do arquivo). */
.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

body.menu-open .layout {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  display: none;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  overscroll-behavior: contain;
  background: var(--page);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  scrollbar-width: none;
}

body.menu-open .sidebar {
  display: flex;
}

/* Barra do topo: acompanha a rolagem, então o ☰ e o ↻ estão sempre à mão. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 28px 0 22px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
}

.topbar .refresh-btn {
  margin-left: auto;
}

.menu-toggle {
  color: var(--text);
}

.btn.menu-close {
  display: none;
}

.current-page {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.workspace {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.workspace select {
  flex: 1;
  width: 100%;
  padding-right: 22px;
  font-weight: 600;
  font-size: 14px;
  border-color: transparent;
  background-color: transparent;
  padding-left: 8px;
}

@media (hover: hover) and (pointer: fine) {
  .workspace select:hover {
    background-color: var(--hover);
  }
}

nav {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-title {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 10px 4px;
}

nav a {
  color: var(--text-2);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13.5px;
}

@media (hover: hover) and (pointer: fine) {
  nav a:hover {
    background: var(--hover);
    color: var(--text);
    text-decoration: none;
  }
}

nav a.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.04);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.sidebar-foot button {
  text-align: left;
  background: none;
  border: 0;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .sidebar-foot button:hover {
    background: var(--hover);
    color: var(--text);
  }
}

main {
  min-width: 0;
}

/* ---------- filtros: uma linha de "chips" com o rótulo dentro */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
}

.filters .field {
  flex-direction: row;
  align-items: center;
  gap: 0;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding-left: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

@media (hover: hover) and (pointer: fine) {
  .filters .field:hover {
    border-color: color-mix(in srgb, var(--text) 25%, transparent);
  }
}

.filters .field > span {
  white-space: nowrap;
}

.filters .field select,
.filters .field input,
.filters .field summary.btn {
  border: 0;
  background-color: transparent;
  height: 30px;
  box-shadow: none;
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
}

.filters .field input {
  padding: 0 8px;
}

.filters .field summary.btn {
  padding: 0 10px 0 6px;
  display: flex;
  align-items: center;
}

@media (hover: hover) and (pointer: fine) {
  .filters .field summary.btn:hover {
    background: none;
  }
}

.filters .toggle {
  border: 0;
  margin: 0 3px 0 6px;
  gap: 2px;
}

.filters .toggle button {
  height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  background: none;
}

.filters .toggle button.active {
  background: var(--hover-strong);
  color: var(--text);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 15px;
}

/* ---------- página */
.page {
  padding: 28px 32px 56px;
  max-width: 1480px;
}

h2 {
  margin: 0 0 20px;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
}

h3 {
  margin: 0 0 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.page > h3,
.page-view > h3 {
  margin: 28px 0 10px;
  color: var(--text-2);
  font-weight: 500;
}

.page > h2 + h3,
.page-view > h2 + h3 {
  margin-top: 0;
}

/* ---------- controles */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}

input,
select,
textarea {
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 32px;
  font: inherit;
  font-size: 13.5px;
  min-width: 0;
}

textarea {
  height: auto;
  padding: 8px 10px;
}

select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 11px) 52%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[type='checkbox'],
input[type='radio'] {
  height: auto;
  accent-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--surface-2);
  }
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-text);
}

@media (hover: hover) and (pointer: fine) {
  .btn.primary:hover {
    opacity: 0.88;
  }
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}

@media (hover: hover) and (pointer: fine) {
  .btn.ghost:hover {
    background: var(--hover);
    color: var(--text);
  }
}

.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn.danger {
  color: var(--bad);
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.toggle {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--hover);
  border: 0;
}

.toggle button {
  background: none;
  color: var(--text-2);
  border: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.06);
}

/* ---------- números (cards): uma grade com linhas finas em vez de uma caixa por número */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  background: var(--surface);
  box-shadow: var(--elev);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.card {
  padding: 16px 18px 18px;
  box-shadow: 1px 0 0 var(--grid), 0 1px 0 var(--grid);
  min-width: 0;
  container-type: inline-size;
}

.card .label {
  color: var(--text-2);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.card .value {
  font-size: 22px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  /* Número não se corta nem se parte: diminui com a largura do card e, no limite, quebra só depois do "R$". */
  font-size: clamp(15px, 9.5cqi, 22px);
}

.card .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* Rótulo com explicação: sublinhado pontilhado, o texto aparece ao passar o mouse. */
.hint {
  text-decoration: underline dotted color-mix(in srgb, var(--muted) 70%, transparent);
  text-underline-offset: 3px;
  cursor: help;
}

th[title] {
  cursor: help;
}

/* Linha de destaque do Resumo: um número principal e três de apoio. */
.kpi-hero {
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.kpi-hero .card {
  padding: 20px 22px 22px;
}

.kpi-hero .card .value {
  font-size: clamp(16px, 9.5cqi, 26px);
  margin-top: 10px;
}

.kpi-hero .card.hero .value {
  font-size: clamp(30px, 11cqi, 48px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.kpi-hero .card.hero .sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 10px;
}

/* ---------- bom / no limite / ruim */
.card.tone-good .value,
td.tone-good,
.tone-text-good {
  color: var(--good);
}

.card.tone-warn .value,
td.tone-warn,
.tone-text-warn {
  color: var(--warn);
}

.card.tone-bad .value,
td.tone-bad,
.tone-text-bad {
  color: var(--bad);
}

td.tone-good,
td.tone-warn,
td.tone-bad {
  font-weight: 600;
}

/* Selo ao lado do rótulo: bolinha + palavra ("Lucrativo", "No limite", "Prejuízo"). */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  vertical-align: 1px;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Variação contra o período anterior: seta + porcentagem num fundo bem leve da mesma cor. */
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  margin-right: 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  cursor: help;
  white-space: nowrap;
}

/* Card estreito: a etiqueta de variação mostra só a porcentagem (o valor em R$ fica no título). */
@container (max-width: 230px) {
  .delta .delta-abs {
    display: none;
  }
}

.status.tone-good,
.delta.tone-good {
  color: var(--good);
  background: color-mix(in srgb, var(--dot-good) 14%, transparent);
}

.status.tone-warn,
.delta.tone-warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--dot-warn) 18%, transparent);
}

.status.tone-bad,
.delta.tone-bad {
  color: var(--bad);
  background: color-mix(in srgb, var(--dot-bad) 14%, transparent);
}

.delta.tone-neutral {
  color: var(--text-2);
  background: var(--hover-strong);
}

.kpi-hero .card .sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.kpi-hero .card .sub .delta {
  margin-right: 0;
}

.compare-note {
  margin: -12px 0 16px;
}

.good {
  color: var(--good) !important;
}

.bad {
  color: var(--bad) !important;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--surface);
  box-shadow: var(--elev);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel .cards {
  box-shadow: 0 0 0 1px var(--grid);
}

.scroll-x {
  overflow-x: auto;
}

.chart-box {
  position: relative;
  height: 260px;
}

.chart-box.tall {
  height: 320px;
}

.chart-box.short {
  height: 180px;
}

/* ---------- tabelas */
.table-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  box-shadow: var(--elev);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Dentro de um painel, a tabela encosta nas bordas do painel em vez de virar outra caixa. */
.panel > .table-wrap,
.panel > .scroll-x {
  box-shadow: none;
  border-radius: 0;
  margin: 0 -20px;
  background: transparent;
}

.panel > .table-wrap :is(th, td):first-child,
.panel > .scroll-x :is(th, td):first-child {
  padding-left: 20px;
}

.panel > .table-wrap :is(th, td):last-child,
.panel > .scroll-x :is(th, td):last-child {
  padding-right: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th:first-child,
td:first-child,
th.left,
td.left {
  text-align: left;
}

th {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  cursor: pointer;
  user-select: none;
}

th.sorted {
  color: var(--text);
}

th.sorted::after {
  content: ' ↓';
  color: var(--muted);
}

@media (hover: hover) and (pointer: fine) {
  tbody tr:hover td {
    background: var(--hover);
  }
}

tfoot td {
  font-weight: 600;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

td.name {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td .drill {
  background: none;
  border: 0;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  padding: 0;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  td .drill:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

td .id {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

/* Status: bolinha colorida + texto neutro (a cor nunca é o único sinal). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  --dot: var(--muted);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot);
}

.badge.paid {
  --dot: var(--dot-good);
}

.badge.waiting_payment {
  --dot: var(--dot-warn);
}

.badge.refunded,
.badge.chargedback,
.badge.refused {
  --dot: var(--dot-bad);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.tabs {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  gap: 2px;
  background: var(--hover);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tabs button {
  white-space: nowrap;
  background: none;
  border: 0;
  color: var(--text-2);
  height: 26px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
}

.tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.06);
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb button {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

details.columns {
  position: relative;
}

details.columns summary {
  list-style: none;
}

details.columns summary::-webkit-details-marker {
  display: none;
}

details.columns .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 6px 14px;
  z-index: 10;
  max-height: 60vh;
  overflow: auto;
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: 13px;
}

details.columns label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

p {
  margin: 0;
}

.stack > p + p {
  margin-top: -6px;
}

code,
.copy {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  word-break: break-all;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}

.copy-row code {
  flex: 1;
  padding: 7px 10px;
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 13px;
}

.error {
  color: var(--bad);
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}

/* ---------- login e aviso flutuante */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-pop);
}

.login-card h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-2);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--ink);
  color: var(--ink-text);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow-pop);
  z-index: 50;
  max-width: 420px;
  font-size: 13px;
}

.toast.error {
  background: var(--bad);
  color: #fff;
}

/* ---------- filtro de vários produtos e ofertas */
details.multi .menu {
  left: -11px;
  right: auto;
  grid-template-columns: minmax(220px, 1fr);
  max-width: min(420px, 90vw);
}

details.multi summary {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 14px;
  color: var(--text);
}

.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
}

td.name .btn {
  margin: 6px 6px 0 0;
}

/* ---------- funil */
.funnel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.funnel-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-2);
}

.funnel-label strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.funnel-bar {
  height: 6px;
  background: var(--series-1-track);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 4px;
}

.funnel-bar span {
  display: block;
  height: 100%;
  background: var(--series-1);
  border-radius: 999px;
}

.funnel-rate {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- primeira coluna fixa nas tabelas largas */
.table-wrap th:first-child,
.table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--grid);
}

.table-wrap th:first-child {
  z-index: 3;
}

@media (hover: hover) and (pointer: fine) {
  .table-wrap tbody tr:hover td:first-child {
    background: color-mix(in srgb, var(--surface) 96%, var(--text));
  }
}

.table-wrap tfoot td:first-child {
  background: var(--surface-2);
}

/* ---------- esconder valores (para gravar tela ou mostrar a alguém) */
body.privacy .card .value,
body.privacy .card .sub,
body.privacy .table-wrap tbody td:not(:first-child),
body.privacy .table-wrap tfoot td:not(:first-child),
body.privacy .panel table td:not(:first-child),
body.privacy .chart-box,
body.privacy .funnel strong {
  filter: blur(7px);
}

/* ---------- telas médias */
@media (max-width: 1100px) {
  .grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  .kpi-hero {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-hero .card.hero {
    grid-column: 1 / -1;
  }

  .filters,
  .page {
    padding-left: 24px;
    padding-right: 24px;
  }

  /* Em tela estreita os filtros ocupam várias linhas: rolam junto com a página. */
  .filters {
    position: static;
  }
}

/* ---------- celular: menu vira uma barra no topo */
@media (max-width: 720px) {
  .filters {
    position: static;
    padding: 10px 12px;
    gap: 6px;
  }

  .page {
    padding: 18px 12px 40px;
  }

  h2 {
    font-size: 20px;
    margin-bottom: 14px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card {
    padding: 14px;
  }

  .kpi-hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-hero .card:last-child {
    grid-column: 1 / -1;
  }

  .panel {
    padding: 16px;
  }

  .panel > .table-wrap,
  .panel > .scroll-x {
    margin: 0 -16px;
  }

  .panel > .table-wrap :is(th, td):first-child,
  .panel > .scroll-x :is(th, td):first-child {
    padding-left: 16px;
  }

  td.name {
    max-width: 150px;
    white-space: normal;
  }
}

/* Botão só com ícone (☰, ↻, +): quadrado, sem o recuo lateral dos botões de texto. */
.btn.icon-btn {
  width: 32px;
  padding: 0;
  flex-shrink: 0;
}

.btn.icon-btn svg {
  flex-shrink: 0;
}

/* Tabela aninhada num painel (ex.: teste A/B ao lado do funil): sem borda própria, sem encostar nas bordas. */
.panel .table-wrap .table-wrap,
.panel :not(.panel) > .table-wrap {
  box-shadow: none;
  border-radius: 0;
  background: transparent;
}

/* Texto de introdução logo abaixo do título da página. */
.page > p,
.page-view > p {
  margin-bottom: 16px;
  max-width: 76ch;
  color: var(--text-2);
}

.page > p.compare-note,
.page-view > p.compare-note {
  color: var(--muted);
}

/* Telas sem filtro (configuração): a barra mostra só o menu e o nome da tela. */
.filters.no-filters {
  display: none;
}

/* Celular: o menu abre em tela cheia, por cima, com links maiores para o dedo. */
@media (max-width: 720px) {
  body.menu-open .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 40;
    width: 100%;
    height: 100%;
    padding: 12px 16px 20px;
    border-right: 0;
    transform: translateX(-100%);
    visibility: hidden;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    /* Fechar é mais rápido que abrir. */
    transition: transform 200ms var(--ease-out), visibility 0s linear 200ms;
  }

  body.menu-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 280ms var(--ease-drawer);
  }

  body.menu-open {
    overflow: hidden;
  }

  .btn.menu-close {
    display: inline-flex;
  }

  nav {
    gap: 18px;
  }

  nav a,
  .sidebar-foot button {
    padding: 11px 12px;
    font-size: 16px;
  }

  .nav-title {
    font-size: 12.5px;
    padding: 0 12px 4px;
  }

  .topbar {
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .sidebar,
  body.menu-open .sidebar {
    transition: none;
  }
}

/* Comparação ao lado do selo do lucro: "▲ +R$ 5,00 · 50%  vs ontem". */
.compare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.compare .delta {
  margin-right: 0;
}

.compare-label {
  color: var(--muted);
  font-size: 12px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
}

/* Ranking (produtos, formas de pagamento): posição, nome, valor, barra e detalhe. */
.rank {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rank li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.rank-pos {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 20px;
}

.rank li:first-child .rank-pos {
  color: var(--text);
}

.rank-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
}

.rank-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.rank-bar {
  height: 6px;
  margin: 6px 0 5px;
  border-radius: 999px;
  background: var(--series-1-track);
  overflow: hidden;
}

.rank-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--series-1);
}

.rank-sub {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0;
}

/* Picos de venda */
.peaks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.peak {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
}

.peak-label {
  font-size: 12px;
  color: var(--text-2);
}

.peak-value {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 4px;
}

.peak-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.heatmap-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  margin-top: 18px;
}

.heatmap {
  display: grid;
  grid-template-columns: 34px repeat(24, minmax(14px, 1fr));
  gap: 3px;
  min-width: 520px;
  font-size: 11px;
  color: var(--muted);
}

.hm-cell {
  display: block;
  height: 20px;
  border-radius: 4px;
}

.hm-day {
  line-height: 20px;
}

.hm-hour {
  text-align: left;
  white-space: nowrap;
}

.hm-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.hm-legend .hm-cell {
  width: 16px;
  height: 12px;
  border-radius: 3px;
}

.hm-legend span:first-child {
  margin-right: 4px;
}

.hm-legend span:last-child {
  margin-left: 4px;
}

body.privacy .rank-value,
body.privacy .rank-sub,
body.privacy .peak-value,
body.privacy .peak-sub {
  filter: blur(7px);
}

@media (min-width: 1200px) {
  .peaks {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---------- toque e resposta ao clique */
button,
a,
summary,
[role='button'] {
  touch-action: manipulation;
}

button,
summary,
.tabs button,
.toggle button,
nav a {
  user-select: none;
  -webkit-user-select: none;
}

/* Botão responde ao apertar (no toque também): leve redução em 140 ms. */
.btn,
.toggle button,
.tabs button,
.sidebar-foot button {
  transition: transform 140ms var(--ease-out);
}

.btn:active:not(:disabled),
.toggle button:active,
.tabs button:active,
.sidebar-foot button:active {
  transform: scale(0.97);
}

/* Ao trocar filtro, a tela anterior fica visível e esmaecida até os dados novos chegarem. */
#page {
  position: relative;
}

.page-view.refreshing {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 150ms ease;
}

/* Celular/tablet: campo com menos de 16px faz o iPhone dar zoom na página. */
@media (pointer: coarse) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .toggle button,
  .tabs button,
  .sidebar-foot button {
    transition: none;
  }

  .btn:active:not(:disabled),
  .toggle button:active,
  .tabs button:active,
  .sidebar-foot button:active {
    transform: none;
  }
}

/* Menus suspensos (colunas, produtos): surgem do botão que os abriu, rápido e com ease-out. */
details.columns .menu {
  transform-origin: top right;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}

details.multi .menu {
  transform-origin: top left;
}

details[open] .menu {
  @starting-style {
    opacity: 0;
    transform: scale(0.97) translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  details[open] .menu {
    @starting-style {
      transform: none;
    }
  }
}

.src-code {
  width: 130px;
  height: 28px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

@media (pointer: coarse) {
  .src-code {
    font-size: 16px;
  }
}

/* Coluna de nome nas tabelas: não espreme a ponto de quebrar "Ativação D1" em duas linhas. */
.table-wrap td.name {
  min-width: 170px;
}

/* ---------- Assinaturas */
.sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sections > .grid-2 {
  margin-bottom: 0;
}

.peaks.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 4px;
}

.chart-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.chart-title {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 8px;
}

@media (max-width: 900px) {
  .chart-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Explicação que abre ao clicar. */
details.explain {
  border-top: 1px solid var(--grid);
  padding-top: 12px;
}

details.explain summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

details.explain summary::-webkit-details-marker {
  display: none;
}

details.explain summary::before {
  content: '›';
  display: inline-block;
  transition: transform 150ms var(--ease-out);
}

details.explain[open] summary::before {
  transform: rotate(90deg);
}

details.explain[open] > :not(summary) {
  margin-top: 12px;
}

/* Mapa de retenção das turmas. */
table.cohort td.cohort-cell {
  text-align: center;
  font-weight: 600;
  min-width: 64px;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--surface);
}

table.cohort td.cohort-cell.strong {
  color: #fff;
}

table.cohort td.cohort-cell.partial {
  opacity: 0.55;
}

table.cohort td.cohort-cell.pending {
  color: var(--muted);
  font-weight: 400;
}

table.cohort tbody tr:hover td.cohort-cell {
  filter: none;
}

/* ---------- caixa de diálogo */
.dialog {
  border: 0;
  border-radius: 14px;
  padding: 22px;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.dialog h3 {
  margin: 0;
  font-size: 15px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dialog[open] {
  animation: dialog-in 180ms var(--ease-out);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialog[open] {
    animation: none;
  }
}

/* Cabeçalho de painel dentro de .stack: o espaço já vem do gap. */
.stack > .panel-head {
  margin-bottom: 0;
}

/* ---------- Notificações */
.style-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 720px) {
  .style-options {
    grid-template-columns: minmax(0, 1fr);
  }
}

.style-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border-strong);
  cursor: pointer;
  transition: box-shadow 150ms ease;
}

.style-option.selected {
  box-shadow: 0 0 0 2px var(--accent);
}

.style-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.style-option:has(input:focus-visible) {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px var(--focus);
}

.style-name {
  font-weight: 600;
  font-size: 14px;
}

.style-desc {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 8px;
}

/* Prévia no formato de notificação do celular. */
.notif-preview {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.35;
}

.notif-preview img {
  border-radius: 8px;
  flex-shrink: 0;
}

.notif-preview > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.notif-preview .notif-app {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.notif-preview strong {
  font-weight: 600;
}

.notif-preview strong + span {
  color: var(--text-2);
}

.push-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

ol.steps {
  margin: 8px 0 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.device-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--grid);
}

.device-list li:last-child {
  border-bottom: 0;
}
