:root {
  color-scheme: dark;
  --bg: #0f1014;
  --paper: #15161d;
  --panel: #181920;
  --panel-2: #1d1e27;
  --line: #2b2d37;
  --line-soft: rgba(255, 255, 255, .07);
  --ink: #e9eaf0;
  --muted: #8a8d99;
  --faint: #60636e;
  --yellow: #ffc72d;
  --magenta: #e42fe6;
  --purple: #7772ff;
  --mint: #65dec7;
  --green: #48c987;
  --red: #ff6d78;
  --orange: #ff8e48;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: #ece9e3;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 16, 20, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 16, 20, .05) 1px, transparent 1px);
  background-size: 58px 58px;
  pointer-events: none;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.report {
  position: relative;
  min-height: 100vh;
  padding: 34px 24px;
  display: grid;
  place-items: start center;
}

.shell {
  width: min(1180px, calc(100vw - 48px));
  min-height: 820px;
  background: var(--bg);
  border: 1px solid #05060a;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .42);
}

.report-head {
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #121319;
}

.client {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 250px;
}

.logo {
  width: 58px;
  height: auto;
  display: block;
}

.divider {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.client strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.client small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill-button,
.ghost {
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 13px;
  color: var(--ink);
  background: #1a1b24;
  font-size: 11px;
  font-weight: 760;
}

.pill-button {
  background: var(--yellow);
  color: #151515;
  border-color: transparent;
}

.selectlike {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.selectlike select {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  outline: 0;
  max-width: 118px;
}

.tabs {
  height: 44px;
  display: flex;
  align-items: stretch;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #101117;
}

.tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  min-width: 86px;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--magenta);
}

#updatedAt {
  margin-left: auto;
  align-self: center;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}

#updatedAt::after {
  content: " ● en vivo";
  color: var(--green);
}

.date-panel {
  position: absolute;
  z-index: 3;
  right: calc((100vw - min(1180px, calc(100vw - 48px))) / 2 + 20px);
  top: 90px;
  display: flex;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  background: #171821;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
  border-radius: 8px;
}

.date-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.date-panel input,
.date-panel button {
  height: 34px;
  border: 1px solid var(--line);
  background: #101117;
  color: var(--ink);
  border-radius: 6px;
  padding: 0 9px;
  font-size: 12px;
}

.page {
  display: none;
  padding: 14px;
}

.page.is-active {
  display: block;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.card,
.module {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.card {
  min-height: 76px;
  padding: 12px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.value {
  display: block;
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

.delta-row {
  display: block;
  margin-top: 5px;
  line-height: 1.4;
}

.delta {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
}

.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

.delta-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .05em;
  margin-left: 2px;
  margin-right: 4px;
  text-transform: uppercase;
}

.hero-delta-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.hero-delta-row .delta { font-size: 13px; }
.hero-delta-row .delta-label { font-size: 10px; margin-right: 8px; }

.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(110px, auto);
  gap: 8px;
}

.module {
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}

.module.mod-fill {
  display: flex;
  flex-direction: column;
}
.module.mod-fill > div:not(.module-head) {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.module.mod-fill .src-scroll {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.module h2 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

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

.module-head small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }

.chart {
  width: 100%;
  height: 156px;
}

.chart.tall { height: 190px; }
.chart svg { width: 100%; height: 100%; display: block; }

.axis { stroke: rgba(255, 255, 255, .08); stroke-width: 1; }
.line-income { fill: none; stroke: var(--magenta); stroke-width: 2.5; }
.line-spend { fill: none; stroke: var(--yellow); stroke-width: 2.2; }
.line-muted { fill: none; stroke: #777986; stroke-width: 2; }
.area { fill: rgba(228, 47, 230, .14); }
.chart-label { fill: var(--muted); font-size: 10px; font-weight: 700; }

.donut {
  min-height: 150px;
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 12px;
}

.donut svg { width: 150px; height: 150px; }
.donut-center { fill: var(--ink); font-size: 18px; font-weight: 900; }
.donut-sub { fill: var(--muted); font-size: 9px; font-weight: 800; }

.legend-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.legend-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: start;
  gap: 7px;
}
.legend-row span {
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th {
  color: var(--muted);
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
  padding: 0 8px 8px 0;
  border-bottom: 1px solid var(--line);
}

td {
  color: #c7c9d2;
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

td strong { color: var(--ink); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border-radius: 999px;
  padding: 0 8px;
  color: #ddf8ee;
  background: rgba(72, 201, 135, .2);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.yellow { color: #ffe695; background: rgba(255, 199, 45, .18); }
.chip.orange { color: #ffc09e; background: rgba(255, 142, 72, .18); }
.chip.purple { color: #e2dbff; background: rgba(119, 114, 255, .22); }

.bar-list { display: grid; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 1.6fr 54px;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 760;
}
.bar-row span:first-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.bar-label { display: flex; align-items: center; gap: 5px; }
.bar-plat { font-size: 9px; font-weight: 900; min-width: 18px; }
.bar-val { text-align: right; }
.demo-empty { color: var(--muted); }
.track {
  height: 7px;
  border-radius: 999px;
  background: #30313a;
  overflow: hidden;
}
.fill {
  display: block;
  height: 100%;
  background: var(--magenta);
}
.fill.yellow { background: var(--yellow); }
.fill.mint { background: var(--mint); }
.fill.gray { background: #8c8f99; }

.funnel {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}
.funnel-row {
  display: grid;
  grid-template-columns: 112px 1fr 58px;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 780;
}
.funnel-row .track { height: 20px; border-radius: 3px; }
.funnel-row .fill { background: var(--yellow); }
.funnel-row:last-child .fill { background: var(--magenta); }

.notes {
  display: grid;
  gap: 14px;
  color: #c9cbd4;
  font-size: 12px;
  line-height: 1.45;
}
.missing {
  min-height: 120px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px dashed #3b3d48;
  border-radius: 6px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, .02);
}
.missing strong {
  color: var(--ink);
  font-size: 13px;
}
.missing p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}
.note::before {
  content: "➜";
  color: var(--magenta);
  margin-right: 8px;
  font-weight: 900;
}
.footline {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  font-size: 10px;
  font-weight: 760;
}

.heatmap {
  display: grid;
  grid-template-columns: 34px repeat(6, 1fr);
  gap: 4px;
  align-items: stretch;
  font-size: 10px;
  font-weight: 850;
  text-align: center;
}
.heatmap div {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: #f6d8f7;
}
.heatmap .head { color: var(--muted); background: transparent; }

.creative {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.thumb {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(228,47,230,.5), rgba(255,199,45,.45));
  color: #fff;
  font-weight: 900;
}

.lock {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.lock[hidden] { display: none; }
.lock__panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 28px;
}
.lock__panel img { width: 190px; display: block; margin-bottom: 24px; }
.lock__panel h1 { margin: 0 0 22px; font-size: 28px; }
.lock__panel label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.password-row input,
.password-row button {
  height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
}
.password-row input { background: #101117; color: var(--ink); }
.password-row button {
  background: var(--yellow);
  color: #111;
  border: 0;
  font-weight: 900;
}
.lock__error {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 12px;
}

.tip-hit { fill: transparent; cursor: crosshair; }

.chart-tip {
  position: fixed;
  background: #1c1d26;
  border: 1px solid rgba(119,114,255,.35);
  border-radius: 8px;
  padding: 9px 14px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transition: opacity .1s;
  white-space: nowrap;
  line-height: 1;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
}
.ct-date {
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 5px;
}
.ct-main {
  font-size: 18px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
}
.ct-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}
.ct-muted { color: var(--faint); font-weight: 600; }

/* ── Overview: Hero KPI row ── */
.kpis-hero {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.kpis-hero-6 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.kpis-hero-2 {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.kpis-hero-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.kpis-row2 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 2fr;
  gap: 8px;
  margin-bottom: 8px;
}

.kpis-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.hero-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.hero-label {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--yellow);
}

.hero-date {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.hero-value {
  display: block;
  font-size: 38px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.02em;
  margin-bottom: 12px;
}

.hero-deltas {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hero-deltas .delta {
  font-size: 13px;
}

.hero-abs {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

/* ── Split bar (Meta vs Google) ── */
.split-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.split-values {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 5px;
}

.split-val {
  font-size: 22px;
  font-weight: 850;
  line-height: 1;
}

.split-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--line);
  margin: 4px 0 5px;
}

.split-fill {
  height: 100%;
  transition: width .3s;
}

.split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Source table: total row + sortable ── */
.total-row td {
  border-top: 1px solid var(--line);
  font-weight: 800;
}

.src-scroll {
  overflow-y: auto;
  max-height: 300px;
  border-radius: 4px;
}

.src-scroll table { width: 100%; }

.src-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}

.sort-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sort-th:hover { color: var(--ink); }

.sort-active { color: var(--yellow) !important; }

/* Ads split layout */
.ads-split {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}
.ads-table-col {
  min-width: 0;
}
.ads-table-col .src-scroll {
  max-height: 488px;
}
.ad-preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 80px;
}
.ad-preview-img {
  width: 100%;
  height: 320px;
  border-radius: 8px;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-preview-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.ad-preview-ph {
  width: 100%; height: 100%;
  background: var(--line);
  display: flex; align-items: center; justify-content: center;
}
.ad-preview-name {
  font-weight: 800;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ad-preview-camp {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ad-preview-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.ad-stat { display: flex; flex-direction: column; gap: 2px; }
.ad-stat-val { font-size: 13px; font-weight: 800; }
.ad-stat-lbl { font-size: 9px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.ad-preview-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 40px 0; }
#ads-tbl tr.ad-selected td { background: rgba(228,47,230,.08); }
#ads-tbl tr:hover td { background: rgba(255,255,255,.03); }

.tienda-brand-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 6px;
  margin-bottom: 4px;
}

.export-btn {
  border-color: var(--purple);
  color: var(--purple);
  letter-spacing: .04em;
}

@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  body { background: #0f1014 !important; margin: 0; }

  .lock, .report-head, .tabs, .date-panel,
  .export-btn, .tienda-brand-filter { display: none !important; }

  .report { padding: 0; }
  .shell {
    width: 100% !important;
    min-height: unset;
    border: none;
    box-shadow: none;
  }

  .page { display: none !important; padding: 16px; }
  .page.is-active { display: block !important; }

  .layout { break-inside: avoid-page; }
  .module { break-inside: avoid; }

  .src-scroll { overflow: visible !important; max-height: unset !important; }
}

@media (max-width: 1080px) {
  .report { padding: 16px 12px; }
  .shell { width: calc(100vw - 24px); }
  .report-head { height: auto; padding: 14px; align-items: start; flex-direction: column; }
  .filters { justify-content: flex-start; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis-hero, .kpis-hero-6, .kpis-hero-2, .kpis-hero-3, .kpis-row2, .kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-12 { grid-column: span 12; }
  .donut { grid-template-columns: 1fr; justify-items: center; height: auto; }
}

@media (max-width: 680px) {
  .tabs { gap: 10px; overflow-x: auto; padding: 0 12px; }
  #updatedAt { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .value { font-size: 20px; }
  .page { padding: 10px; }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .funnel-row { grid-template-columns: 1fr; gap: 5px; }
  .date-panel { left: 12px; right: 12px; top: 118px; flex-wrap: wrap; }
}
