/* ===========================================================================
   Nexus — identidade laranja / branco / preto, com tema light e dark.
   As variáveis mantêm os nomes históricos (--blue*) por compatibilidade com
   todo o CSS existente, mas apontam para a LARANJA da marca. Assim o rebrand
   é feito num ponto só. Cor accent do logo: #F7791A (laranja Nexus).
   =========================================================================== */
:root, :root[data-theme="light"] {
  --page: #f5f5f6;
  --surface: #ffffff;
  --border: #e6e6e8;
  --text-primary: #1c1c1e;
  --text-secondary: #55555b;
  --text-muted: #82828a;

  /* accent = laranja Nexus (nomes --blue* mantidos p/ compat) */
  --blue: #f7791a;
  --blue-dark: #c85a06;
  --blue-tint: #fdeede;
  --blue-tint-2: #fbdcbc;
  --accent-solid: #b8540a; /* laranja escura p/ FUNDOS com texto branco (≥4,5:1) */

  --aqua: #1baf7a;
  --yellow: #eda100;
  --violet: #7a5cff;

  --good: #0a8f0a;
  --good-tint: #e7f6e7;
  --bad: #c9302c;
  --bad-tint: #fdeceb;
  --warn: #c96a00;
  --warn-tint: #fdf3e6;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 22, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- Tema escuro ---------- */
:root[data-theme="dark"] {
  --page: #0f0f11;
  --surface: #1a1a1d;
  --border: #2c2c31;
  --text-primary: #f4f4f6;
  --text-secondary: #b6b6bd;
  --text-muted: #7d7d86;

  --blue: #ff8c33;         /* laranja mais clara p/ contraste no escuro */
  --blue-dark: #ffab5e;
  --blue-tint: #2a1e12;    /* "tint" no dark = fundo alaranjado escuro */
  --blue-tint-2: #402c17;
  --accent-solid: #c25a08; /* fundo de botão com texto branco no dark (≥4,5:1) */

  --aqua: #2ecb93;
  --yellow: #f0b53d;
  --violet: #9b83ff;

  --good: #35c759;
  --good-tint: #14301c;
  --bad: #ff5a52;
  --bad-tint: #331715;
  --warn: #ff9f2e;
  --warn-tint: #33240f;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 20px;
  font-weight: 700;
  font-size: 14.5px;
}

.sidebar-brand .brand-icon,
.sidebar-brand .brand-fallback {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-solid);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.sidebar-brand .brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}

.sidebar nav a:hover { background: var(--page); color: var(--text-primary); }

.sidebar nav a.active {
  background: var(--blue-tint);
  color: var(--blue);
  font-weight: 600;
}

/* ---------- Main ---------- */
.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 16px;
}

.topbar .title-wrap { display: flex; align-items: center; gap: 12px; }

.topbar .title-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}
.topbar .title-icon img { width: 40px; height: 40px; object-fit: contain; }
.topbar .title-icon > span {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-solid); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.topbar h1 { font-size: 16px; margin: 0; }
.topbar .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.topbar .actions { display: flex; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.kpi-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.kpi-card .icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--blue-tint);
  color: var(--blue);
}

.kpi-card .label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }

.kpi-card .value-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-card .value { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-card .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.delta {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.delta.up { background: var(--good-tint); color: var(--good); }
.delta.down { background: var(--bad-tint); color: var(--bad); }
.delta.neutral { background: var(--page); color: var(--text-muted); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
  min-width: 0;
}

.panel h3 { margin: 0 0 2px; font-size: 15px; }
.panel .panel-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2, .grid-2-even { grid-template-columns: 1fr; } }

/* ---------- Insight footnote ---------- */
.insight {
  margin-top: 14px;
  background: var(--blue-tint);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--blue-dark);
}
.insight strong { color: var(--blue-dark); }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: none;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--text-primary) 4%, var(--surface)); }

.cell-main { font-weight: 600; }
.cell-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; }
.status.ativa .dot { background: var(--good); }
.status.pausada .dot { background: var(--text-muted); }

.metric-good { color: var(--good); font-weight: 600; }
.metric-bad { color: var(--warn); font-weight: 600; }

/* progress bar (ROAS etc.) */
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.bar-track { flex: 1; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--blue); }

/* mini bars (vendas sparkline) */
.minibars { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; }
.minibars span { width: 4px; border-radius: 2px 2px 0 0; background: var(--blue-tint-2); }
.minibars span.on { background: var(--blue); }

/* ---------- Highlight / resumo ---------- */
.highlight-card {
  background: var(--blue-tint);
  border: 1px solid var(--blue-tint-2);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.highlight-card .trophy {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-solid);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.highlight-card .hl-label { font-size: 11.5px; color: var(--blue-dark); }
.highlight-card .hl-value { font-size: 15px; font-weight: 700; color: var(--blue-dark); }
.highlight-card .hl-sub { font-size: 12px; color: var(--blue-dark); }

.summary-strip {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 22px 6px 0;
  margin-right: 22px;
  border-right: 1px solid var(--border);
}
.summary-item:last-of-type { border-right: none; }

.summary-item .icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-tint);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.summary-item .s-value { font-size: 16px; font-weight: 700; }
.summary-item .s-label { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Funnel ---------- */
.funnel-list { display: flex; flex-direction: column; gap: 8px; }

.funnel-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 8px;
  align-items: stretch;
}

.funnel-metric {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.funnel-metric .fm-label { font-size: 12px; color: var(--text-secondary); }
.funnel-metric .fm-value { font-size: 17px; font-weight: 700; }

.funnel-rate {
  background: var(--blue-tint);
  border: 1px solid var(--blue-tint-2);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.funnel-rate .fr-label { font-size: 10.5px; color: var(--blue-dark); }
.funnel-rate .fr-value { font-size: 15px; font-weight: 700; color: var(--blue-dark); }

/* ---------- Charts ---------- */
.chart-wrap { width: 100%; overflow-x: auto; }

.chart-legend {
  display: flex; gap: 16px;
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 10px;
}
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

.empty-state { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

.footnote { font-size: 11px; color: var(--text-muted); margin-top: 10px; }

/* ---------- Criativos em cards ---------- */
.cc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.cc-tabs { display: flex; gap: 4px; }

.cc-tab {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.cc-tab:hover { background: var(--page); }
.cc-tab.active { background: var(--blue-tint); color: var(--blue); font-weight: 600; }

.cc-search {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  min-width: 220px;
}
.cc-search:focus { outline: 2px solid var(--blue-tint-2); border-color: var(--blue); }

.cc-sort {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
}

.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.creative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.creative-card .thumb {
  position: relative;
  height: 150px;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
}

.creative-card .thumb .name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 12px 8px;
  background: linear-gradient(transparent, rgba(9, 20, 38, 0.85));
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creative-card .cc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.cc-stat-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--page);
}

.cc-stat-box.accent {
  background: var(--blue-tint);
  border-color: var(--blue-tint-2);
}

.cc-stat-box .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-stat-box .lbl { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.cc-stat-box.accent .lbl { color: var(--blue-dark); }
.cc-stat-box .val { font-size: 15px; font-weight: 700; }
.cc-stat-box .val-sm { font-size: 13px; font-weight: 600; }
.cc-stat-box .divider { border-top: 1px solid var(--border); margin: 8px 0; }
.cc-stat-box.accent .divider { border-color: var(--blue-tint-2); }

.roas-pill {
  display: inline-block;
  background: var(--good-tint);
  color: var(--good);
  font-weight: 700;
  font-size: 13px;
  border-radius: 6px;
  padding: 2px 8px;
}
.roas-pill.bad { background: var(--bad-tint); color: var(--bad); }
.roas-pill.warn { background: var(--warn-tint); color: var(--warn); }

.cc-meters { padding: 0 12px 10px; display: flex; flex-direction: column; gap: 7px; }

.meter { display: grid; grid-template-columns: 70px 1fr 64px; align-items: center; gap: 10px; font-size: 12px; }
.meter .m-label { color: var(--text-secondary); }
.meter .m-track { height: 5px; border-radius: 999px; background: var(--border); overflow: hidden; }
.meter .m-fill { height: 100%; border-radius: 999px; }
.meter .m-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.meter.good .m-fill { background: var(--good); }
.meter.good .m-value { color: var(--good); }
.meter.warn .m-fill { background: var(--yellow); }
.meter.warn .m-value { color: var(--warn); }
.meter.bad .m-fill { background: var(--bad); }
.meter.bad .m-value { color: var(--bad); }

.cc-footer {
  padding: 8px 12px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ---------- Sidebar em seções ---------- */
.sidebar .nav-section {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 12px 6px;
}

/* ---------- HBarList (rankings) ---------- */
.hbar-list { display: flex; flex-direction: column; gap: 9px; }

.hbar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) 1fr minmax(110px, auto);
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.hbar-label {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hbar-track { height: 8px; border-radius: 999px; background: var(--page); border: 1px solid var(--border); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--blue); }
.hbar-value { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Heatmap ---------- */
.hm-wrap { display: flex; flex-direction: column; gap: 3px; }
.hm-hours { position: relative; height: 14px; margin-left: 38px; font-size: 9.5px; color: var(--text-muted); }
.hm-hours span { position: absolute; }
.hm-row { display: flex; align-items: center; gap: 6px; }
.hm-dow { width: 32px; font-size: 10px; color: var(--text-muted); text-align: right; }
.hm-cells { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; flex: 1; }
.hm-cell { aspect-ratio: 1.6; border-radius: 3px; min-width: 0; }
.hm-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.hm-leg { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- Progress goal (hero atribuição) ---------- */
.pgoal { margin-top: 12px; }
.pgoal-track { position: relative; height: 10px; border-radius: 999px; background: var(--page); border: 1px solid var(--border); }
.pgoal-fill { height: 100%; border-radius: 999px; background: var(--good); }
.pgoal-fill.under { background: var(--warn); }
.pgoal-marker { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-secondary); }
.pgoal-marker span { position: absolute; top: -18px; left: -20px; font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.pgoal-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-top: 6px; }

.hero-value { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }
.hero-sub { font-size: 12.5px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- Toggle switch ---------- */
.tswitch {
  width: 36px; height: 20px;
  border-radius: 999px;
  border: none;
  background: var(--border);
  position: relative;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s;
}
.tswitch .knob {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: left 0.15s;
}
.tswitch.on { background: var(--good); }
.tswitch.on .knob { left: 18px; }

/* ---------- Tabela hierárquica de campanhas ---------- */
.camp-table td, .camp-table th { padding: 9px 10px; }
.camp-table .group-row td {
  background: var(--page);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}
.camp-table .group-row .caret { display: inline-block; width: 14px; color: var(--text-muted); }
.camp-table .total-row td {
  background: var(--blue-tint);
  font-weight: 700;
  border-top: 2px solid var(--blue-tint-2);
}
.camp-table .name-cell { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camp-table .fy-col { background: color-mix(in srgb, var(--blue) 7%, var(--surface)); }
.camp-table th.fy-col { color: var(--blue-dark); }

.camp-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.camp-table th.sortable:hover { color: var(--blue-dark); }
.camp-table th.sortable .sort-arrow { font-size: 10px; color: var(--text-muted); margin-left: 2px; }
.camp-table th.sortable:hover .sort-arrow { color: var(--blue); }
.camp-table th.sortable.sorted { color: var(--blue-dark); }
.camp-table th.sortable.sorted .sort-arrow { color: var(--blue); font-weight: 700; }

.budget-input {
  width: 86px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-variant-numeric: tabular-nums;
  padding: 3px 6px;
  text-align: right;
  color: var(--text-primary);
}
.budget-input:hover { border-color: var(--border); background: var(--surface); }
.budget-input:focus { border-color: var(--blue); background: var(--surface); outline: none; }

/* ---------- Percentil chips / distribuição ---------- */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip-sm {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--text-secondary);
  background: var(--page);
}

.page-tabs { display: flex; gap: 4px; margin-bottom: 14px; }

/* ---------- Barra de filtros (chips + popovers) ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  position: relative;
}

.fchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 13px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.fchip:hover { border-color: var(--blue-tint-2); background: var(--blue-tint); color: var(--blue-dark); }
.fchip.active { background: var(--blue-tint); border-color: var(--blue-tint-2); color: var(--blue-dark); font-weight: 600; }
.fchip .count {
  background: var(--accent-solid);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
}
.fchip .x { font-weight: 700; opacity: 0.6; }
.fchip .x:hover { opacity: 1; }

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.14);
  padding: 14px;
  min-width: 240px;
}
.popover.right { left: auto; right: 0; }

.pop-section { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin: 12px 0 6px; }
.pop-section:first-child { margin-top: 0; }
.pop-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-primary); padding: 5px 0; cursor: pointer; }
.pop-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- Date picker ---------- */
.datepicker { display: flex; min-width: 560px; }
.dp-presets { border-right: 1px solid var(--border); padding-right: 10px; margin-right: 14px; min-width: 140px; max-height: 300px; overflow-y: auto; }
.dp-preset { display: block; width: 100%; text-align: left; border: none; background: none; font: inherit; font-size: 13px; color: var(--text-primary); padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.dp-preset:hover { background: var(--page); }
.dp-preset.active { background: var(--blue-tint); color: var(--blue-dark); font-weight: 600; }

.dp-cal { flex: 1; }
.dp-months { display: flex; gap: 20px; }
.dp-month { flex: 1; }
.dp-month h4 { text-align: center; font-size: 13px; margin: 0 0 8px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { font-size: 10px; color: var(--text-muted); text-align: center; padding: 3px 0; }
.dp-day {
  border: none; background: none; font: inherit; font-size: 12px;
  padding: 5px 0; border-radius: 7px; cursor: pointer; text-align: center;
  color: var(--text-primary);
}
.dp-day:hover { background: var(--blue-tint); }
.dp-day.out { color: var(--text-muted); opacity: 0.35; cursor: default; }
.dp-day.inrange { background: var(--blue-tint); border-radius: 0; }
.dp-day.edge { background: var(--accent-solid); color: #fff; font-weight: 700; }
.dp-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; font-size: 12.5px; color: var(--text-secondary); }

/* ---------- Seletor de colunas ---------- */
.col-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.col-item .col-move { display: flex; gap: 2px; margin-left: auto; }
.col-item .col-move button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  width: 22px; height: 22px; font-size: 11px; cursor: pointer; color: var(--text-secondary);
  line-height: 1;
}
.col-item .col-move button:hover { background: var(--blue-tint); color: var(--blue-dark); }
.col-item.fy-tag::after { content: "FY"; font-size: 9px; font-weight: 700; color: var(--blue-dark); background: var(--blue-tint); border-radius: 4px; padding: 1px 5px; }

/* ---------- Drill-down (níveis indentados) ---------- */
.camp-table .lvl-caret {
  border: none; background: none; cursor: pointer; font-size: 11px;
  color: var(--text-muted); width: 18px; padding: 0; flex-shrink: 0;
}
.camp-table .lvl-1 td:first-child { padding-left: 26px; }
.camp-table .lvl-1 { background: color-mix(in srgb, var(--text-primary) 3%, var(--surface)); }
.camp-table .lvl-2 td:first-child { padding-left: 52px; }
.camp-table .lvl-2 { background: color-mix(in srgb, var(--text-primary) 6%, var(--surface)); }
.camp-table .rowcheck { flex-shrink: 0; }

/* ---------- Tela Ativos ---------- */
.ativos-layout { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .ativos-layout { grid-template-columns: 1fr; } }

.mini-nav { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.mini-nav button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; border: none; background: none; font: inherit;
  font-size: 13px; color: var(--text-secondary); padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.mini-nav button:hover { background: var(--page); }
.mini-nav button.active { background: var(--blue-tint); color: var(--blue-dark); font-weight: 600; }
.mini-nav .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.mini-nav button.ok .dot { background: var(--good); }

.bm-header td { background: var(--page); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }

/* cards de ativo (site / checkout / pixel) */
.asset-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface);
}
.asset-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.asset-head .asset-name { font-weight: 700; font-size: 14px; }
.asset-head .spacer { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.asset-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.asset-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.badge-green {
  font-size: 11px; font-weight: 600;
  color: var(--good); background: var(--good-tint);
  border-radius: 999px; padding: 3px 10px;
}
.badge-warn {
  font-size: 11px; font-weight: 600;
  color: var(--warn); background: var(--warn-tint);
  border-radius: 999px; padding: 3px 10px;
}
.badge-blue {
  font-size: 11px; font-weight: 600;
  color: var(--blue-dark); background: var(--blue-tint);
  border-radius: 999px; padding: 3px 10px;
}
.badge-muted {
  font-size: 11px; color: var(--text-muted); background: var(--page);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}

.mono-box {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  line-height: 1.5;
}

.btn-ghost {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  font: inherit; font-size: 12px; border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.btn-ghost:hover { background: var(--blue-tint); color: var(--blue-dark); border-color: var(--blue-tint-2); }

.danger-zone {
  border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--border));
  background: var(--bad-tint);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.danger-zone h4 { margin: 0 0 6px; font-size: 14px; color: var(--bad); }
.danger-zone p { margin: 0; font-size: 12.5px; color: var(--text-secondary); max-width: 640px; }
.btn-danger {
  border: 1px solid var(--bad); background: var(--surface); color: var(--bad);
  font: inherit; font-size: 13px; font-weight: 600; border-radius: 9px; padding: 9px 16px; cursor: pointer;
}
.btn-danger:hover { background: var(--bad); color: #fff; }

.inline-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px;
}
.inline-form label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); width: 100%; }

#btn-refresh { padding: 7px 10px; }
#btn-refresh.spinning svg { animation: kspin 0.9s linear infinite; }
@keyframes kspin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-screen {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
  padding: 32px 28px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-logo { width: 72px; height: 72px; object-fit: contain; display: block; margin: 0 auto 6px; }
.login-brand { font-size: 22px; font-weight: 800; text-align: center; color: var(--text-primary); letter-spacing: 0.02em; }
.login-sub { font-size: 12.5px; color: var(--text-muted); text-align: center; margin-bottom: 8px; }
.login-error { min-height: 16px; font-size: 12px; color: var(--bad); text-align: center; }
.login-card input { width: 100%; }

.sidebar-footer { margin-top: 18px; padding: 0 4px; }

/* ---------- Low Ticket: canvas de nós ---------- */
.flow-canvas {
  position: relative;
  background:
    radial-gradient(circle, var(--border) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 20px;
  overflow-x: auto;
}

.flow-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 8fr minmax(230px, 1.2fr);
  grid-template-columns: minmax(210px, 3fr) minmax(280px, 4fr) minmax(230px, 3fr);
  gap: 34px;
  align-items: center;
  position: relative;
}
@media (max-width: 1050px) { .flow-row { grid-template-columns: 1fr; gap: 20px; } }

/* conector pontilhado entre os nós da linha principal */
.flow-node { position: relative; }
@media (min-width: 1051px) {
  .flow-node.has-next::after {
    content: "";
    position: absolute;
    top: 50%; right: -34px;
    width: 34px; border-top: 2px dashed var(--blue-tint-2);
  }
}

.node-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.node-card.destaque { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
.node-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 13.5px;
}
.node-head .n-icon {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--blue-tint); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
}
.node-head .spacer { margin-left: auto; display: flex; gap: 6px; }
.node-body { padding: 8px 14px 12px; }

.node-metric {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.node-metric:last-child { border-bottom: none; }
.node-metric .m-label { font-size: 12px; color: var(--text-secondary); border-left: 3px solid var(--blue-tint-2); padding-left: 8px; }
.node-metric .m-value { font-size: 15.5px; font-weight: 700; white-space: nowrap; }
.node-metric .m-value .m-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* pipeline do nó central (etapa + taxa em pill) */
.pipe-step { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 0 2px; }
.pipe-step .p-label { font-size: 10.5px; letter-spacing: 0.05em; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.pipe-step .p-value { font-size: 17px; font-weight: 800; }
.pipe-step .p-right { text-align: right; }
.pipe-step .p-right .p-label { color: var(--blue-dark); }
.pipe-rate {
  display: flex; justify-content: center; margin: 2px 0 4px;
}
.pipe-rate span {
  border: 1px dashed var(--blue-tint-2);
  background: var(--blue-tint);
  color: var(--blue-dark);
  border-radius: 8px;
  font-size: 11px; font-weight: 700;
  padding: 3px 12px;
}

/* chips CPA/ROAS acima do nó de venda */
.node-chips { display: flex; gap: 8px; margin-bottom: 8px; justify-content: flex-end; }
.node-chip {
  border: 1px solid var(--blue-tint-2);
  background: var(--surface);
  border-radius: 999px;
  font-size: 11.5px; padding: 4px 12px;
}
.node-chip b { color: var(--blue-dark); margin-left: 4px; }

/* bumps pendurados */
.bump-tree { position: relative; margin-top: 4px; padding-top: 18px; }
.bump-tree::before {
  content: ""; position: absolute; top: 0; left: 50%;
  height: 18px; border-left: 2px solid var(--blue-tint-2);
}
.bump-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.bump-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  position: relative;
}
.bump-card .attach {
  position: absolute; top: -9px; left: 10px;
  background: var(--blue-tint); color: var(--blue-dark);
  border: 1px solid var(--blue-tint-2);
  border-radius: 6px; font-size: 10px; font-weight: 800; padding: 1px 7px;
}
.bump-card .b-nome { font-size: 11.5px; font-weight: 700; margin: 4px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bump-card .b-tag { font-size: 9px; letter-spacing: 0.06em; color: var(--text-muted); text-transform: uppercase; }
.bump-card .b-meta { font-size: 11.5px; color: var(--text-secondary); }
.bump-card .b-meta b { color: var(--text-primary); }

/* variantes */
.variant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.variant-url {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px; color: var(--text-muted);
  background: var(--page); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.variant-check { position: absolute; top: 10px; right: 10px; }

/* comparação */
.compare-panel table td.better { color: var(--good); font-weight: 700; }
.compare-panel table td.worse { color: var(--bad); }

/* régua de produtos */
.ladder { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 6px 2px; }
.ladder-card {
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  flex-shrink: 0;
}
.ladder-card .l-tipo { font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.ladder-card .l-nome { font-size: 12px; font-weight: 700; margin: 3px 0 6px; }
.ladder-card .l-num { font-size: 20px; font-weight: 800; }
.ladder-card .l-sub { font-size: 11px; color: var(--text-muted); }
.ladder-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 8px; flex-shrink: 0;
}
.ladder-arrow .pct {
  background: var(--blue-tint); color: var(--blue-dark);
  border: 1px solid var(--blue-tint-2);
  border-radius: 999px; font-size: 11px; font-weight: 800; padding: 2px 10px;
  margin-bottom: 2px;
}
.ladder-arrow .arr { color: var(--blue); font-size: 18px; }

/* conversões do funil */
.conv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.conv-card {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  border-left: 3px solid var(--blue);
}
.conv-card .conv-value { font-size: 24px; font-weight: 800; color: var(--blue-dark); letter-spacing: -0.02em; }
.conv-card .conv-label { font-size: 12.5px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.conv-card .conv-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Visão Geral (mix FY) ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0;
}
.stat-strip > div {
  padding: 4px 18px;
  border-right: 1px solid var(--border);
}
.stat-strip > div:last-child { border-right: none; }
.stat-strip .ss-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.stat-strip .ss-value { font-size: 19px; font-weight: 700; }
.stat-strip .ss-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.badge-bad {
  font-size: 11px; font-weight: 600;
  color: var(--bad); background: var(--bad-tint);
  border-radius: 999px; padding: 3px 10px;
}

.anomalias-list { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.link-arrow { font-size: 12.5px; color: var(--blue); text-decoration: none; font-weight: 600; }
.link-arrow:hover { text-decoration: underline; }
.btn-danger-ghost {
  border: 1px solid var(--bad-tint); background: var(--surface); color: var(--bad);
  font: inherit; font-size: 12px; border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
.btn-danger-ghost:hover { background: var(--bad-tint); }
.btn-primary {
  border: none; background: var(--accent-solid); color: #fff; font: inherit; font-size: 13px;
  font-weight: 600; border-radius: 9px; padding: 10px 16px; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

