/* Marketing Dashboard page — styled as the SHEET.
 *
 * The first version of this page was a grid of KPI cards and it was rejected for exactly that:
 * the value is reading the same document he reads every Monday, in the same shape. So this is a
 * spreadsheet — group header over measure header, an indented row tree with the workbook's own
 * gray banding, right-aligned monospace figures, negatives in parentheses.
 *
 * Tokens are the --bb-* layer with legacy fallbacks; colours are never defined only inside a
 * media query, so an explicit theme toggle wins in both directions.
 */

.md-page { padding-bottom: 64px; }

/* --------------------------------------------------------------------------- scope bar */

.md-scope {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-direction: column; gap: 7px;
  padding: 12px 0 10px;
  background: var(--bb-page, var(--warm-white, #F5F3EE));
  border-bottom: 1px solid var(--bb-line, var(--border, #E3DED4));
}
.md-scope-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.md-scope-ctl { gap: 8px; }

.md-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font: 500 13px/1.2 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-2, var(--text-muted, #6A6459));
  background: var(--bb-surface, #fff);
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-chip, 6px);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.md-chip:hover { background: var(--bb-hover, #F0ECE4); }
.md-chip.on {
  color: #fff;
  background: var(--bb-accent, var(--navy, #0D2A5E));
  border-color: var(--bb-accent, var(--navy, #0D2A5E));
}
.md-div { font-weight: 600; }
.md-chip-n {
  font: 600 11px/1 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums; opacity: .65;
}

/* UGD | GRD | Ambos — one control, so it reads as three states of one thing rather than three
   separate reports. It only renders where the division actually ships both books. */
.md-seg {
  display: inline-flex; margin-left: 4px;
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-chip, 6px);
  overflow: hidden;
  background: var(--bb-surface, #fff);
}
.md-seg-b {
  padding: 6px 12px;
  font: 500 12px/1.2 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-2, var(--text-muted, #6A6459));
  background: none; border: 0;
  border-right: 1px solid var(--bb-line, var(--border, #E3DED4));
  cursor: pointer;
}
.md-seg-b:last-child { border-right: 0; }
.md-seg-b:hover { background: var(--bb-hover, #F0ECE4); }
.md-seg-b.on { color: #fff; background: var(--bb-accent, var(--navy, #0D2A5E)); }

.md-sel {
  padding: 6px 10px;
  font: 500 13px/1.2 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink, var(--text, #1E1B16));
  background: var(--bb-surface, #fff);
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-control, 6px);
  cursor: pointer; max-width: 260px;
}
.md-lbl, .md-meta {
  font: 400 12px/1.3 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
/* A compact chip, not a paragraph callout — scope notes read as data, not as prose. */
.md-flag {
  display: inline-block; padding: 4px 9px;
  font: 500 11.5px/1.35 'Outfit', system-ui, sans-serif;
  color: var(--bb-gold-ink, #7A5A12);
  background: var(--bb-gold-tint, #FBF3E2);
  border: 1px solid var(--bb-gold, #B0700F);
  border-radius: var(--bb-r-chip, 6px);
}

/* ------------------------------------------------------------------------- sections */

.md-sheet { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.md-sec {
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-card, 10px);
  background: var(--bb-surface, #fff);
  overflow: hidden;
}
.md-sec-h {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 14px; text-align: left;
  background: none; border: 0; cursor: pointer;
  border-bottom: 1px solid transparent;
}
.md-sec.is-open .md-sec-h { border-bottom-color: var(--bb-line, var(--border, #E3DED4)); }
.md-sec-h:hover { background: var(--bb-hover, #F0ECE4); }
.md-sec-caret { width: 12px; color: var(--bb-ink-3, #8A8478); font-size: 11px; }
.md-sec-t {
  font: 600 14px/1.2 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink, var(--text, #1E1B16));
}
.md-sec-sub {
  font: 400 11.5px/1.2 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
.md-sec-kpi {
  margin-left: auto;
  font: 600 16px/1 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--bb-ink, var(--text, #1E1B16));
}
.md-sec-dev {
  font: 500 12px/1 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--bb-ink-2, var(--text-muted, #6A6459));
  display: inline-flex; align-items: baseline; gap: 3px;
}
.md-sec-dev em { font: 400 10px/1 'Outfit', sans-serif; font-style: normal; opacity: .7; }
.md-sec-empty {
  margin-left: auto;
  font: 500 11.5px/1 'Outfit', sans-serif;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
.md-sec.is-empty .md-sec-h { opacity: .62; }

/* ---------------------------------------------------------------------------- table */

/* The table itself is reporttable.css now — same look and same gestures as By Program, with
 * `.is-frozen` opted in because this one is up to 26 week blocks wide. What stays here is page
 * chrome: the scope bar, the section accordions, the daily strip. */

/* --------------------------------------------------------------------------- misc */

.md-skel, .md-drop {
  margin-top: 24px; padding: 34px 22px; text-align: center;
  border: 1px dashed var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-card, 10px);
  font: 400 13px/1.5 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
.md-drop-h { font: 600 16px/1.3 'Outfit', sans-serif; color: var(--bb-ink, var(--text, #1E1B16)); }
.md-drop-s { margin-top: 6px; }
.md-note {
  display: none; margin-top: 14px; padding: 8px 12px;
  font: 500 12px/1.45 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink-2, var(--text-muted, #6A6459));
  background: var(--bb-inset, #F7F4EE);
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: var(--bb-r-chip, 6px);
}
.md-note.on { display: block; }

/* ----------------------------------------------------------------------- dark mode */

:root[data-theme="dark"] .md-t tbody tr.md-headrow,
:root[data-theme="dark"] .md-t tbody tr.md-headrow .md-lab { background: var(--bb-hover-2, #24222C); }
:root[data-theme="dark"] .md-c-actual { background: var(--bb-inset, #201E19); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .md-t tbody tr.md-headrow,
  :root:not([data-theme="light"]) .md-t tbody tr.md-headrow .md-lab { background: var(--bb-hover-2, #24222C); }
  :root:not([data-theme="light"]) .md-c-actual { background: var(--bb-inset, #201E19); }
}

/* -------------------------------------------------------------------------- narrow */

html[data-cw="s"] .md-th-lab, html[data-cw="s"] .md-lab { min-width: 170px; max-width: 170px; }
html[data-cw="xs"] .md-th-lab, html[data-cw="xs"] .md-lab { min-width: 140px; max-width: 140px; }
html[data-cw="xs"] .md-scope { position: static; }
html[data-cw="xs"] .md-sec-sub { display: none; }

.md-sec-note {
  font: 600 9.5px/1 'Outfit', system-ui, sans-serif;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: 4px; padding: 2px 5px;
}

/* ============================================== the weekly trend card === */

/* Same machinery as By Program's, on THIS sheet's metrics — which include Inversión, CPL and CPE,
 * the paid-media numbers By Program does not carry. Canvas, so Capturar hands over the exact chart
 * rather than an approximation of the DOM; the brush sits in the DOM below it so a scrubber never
 * lands inside the PNG he pastes into an e-mail. */
.md-trend { padding: 0; overflow: hidden; margin-bottom: 16px; }
.md-trend-h {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.md-trend-t { font-size: 16px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }
.md-trend-s { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.md-trend-act { display: flex; align-items: center; gap: 8px; }
.md-select {
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--navy);
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 10px; cursor: pointer; max-width: 250px;
}
.md-select:hover { background: var(--off-white); }
.md-btn {
  background: var(--navy); color: #fff; border: none; border-radius: 9px;
  padding: 8px 14px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.md-btn:hover { background: var(--navy-light); }

.md-trend-chips {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--warm-white); border-bottom: 1px solid var(--border);
}
.md-chip {
  border: 1px solid var(--border); background: #fff; color: var(--navy);
  border-radius: 9px; padding: 6px 11px; font-family: inherit;
  font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.md-chip:hover { background: var(--off-white); }
.md-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.md-chip-py { font-family: 'JetBrains Mono', monospace; letter-spacing: -0.04em; }
.md-trend-div { width: 1px; align-self: stretch; background: var(--border); margin: 0 5px; }

.md-trend-wrap { padding: 6px 10px 10px; }
.md-trend-wrap canvas { display: block; width: 100%; }

.md-brush { padding: 2px 14px 14px; }
.md-brush-track {
  position: relative; height: 26px; margin: 0 10px;
  background: var(--off-white); border-radius: 7px;
}
.md-brush-tick {
  position: absolute; top: 9px; width: 2px; height: 8px; margin-left: -1px;
  background: rgba(13, 42, 94, 0.18); border-radius: 1px;
}
.md-brush-tick.on { background: rgba(13, 42, 94, 0.5); }
.md-brush-span {
  position: absolute; top: 0; bottom: 0;
  background: rgba(13, 42, 94, 0.12); border-radius: 7px;
  border-left: 1px solid rgba(13, 42, 94, 0.3); border-right: 1px solid rgba(13, 42, 94, 0.3);
}
.md-brush-h {
  position: absolute; top: -3px; transform: translateX(-50%);
  min-width: 34px; height: 32px; padding: 0 6px;
  background: var(--navy); color: #fff; border: 2px solid #fff; border-radius: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
  cursor: grab; box-shadow: 0 2px 6px var(--shadow); touch-action: none;
}
.md-brush-h:active { cursor: grabbing; }
.md-brush-h:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.md-brush-foot {
  display: flex; align-items: center; gap: 10px; margin: 10px 10px 0;
  font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace;
}
.md-brush-all {
  margin-left: auto; border: 1px solid var(--border); background: #fff; color: var(--navy);
  border-radius: 7px; padding: 4px 10px; font-family: inherit; font-size: 10.5px;
  font-weight: 700; cursor: pointer;
}
.md-brush-all:hover { background: var(--off-white); }

/* ------------------------------------------------------------------ chart tooltip ----- */

/* The weekly chart is a canvas, so this is the only way it can answer "what am I looking at".
 * Positioned by the handler from the same x scale the draw used. pointer-events:none matters:
 * without it the tooltip sits under the cursor, steals the mousemove, and the chart flickers
 * between hovered and not. */
.md-trend-wrap { position: relative; }
.md-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 170px; max-width: 250px;
  padding: 8px 10px;
  background: var(--bb-surface, #fff);
  border: 1px solid var(--bb-line, var(--border, #E3DED4));
  border-radius: 9px;
  box-shadow: 0 6px 20px rgba(30, 27, 22, .16);
  font: 500 11.5px/1.45 'Outfit', system-ui, sans-serif;
  color: var(--bb-ink, var(--text, #1E1B16));
}
.md-tip[hidden] { display: none; }
.md-tip > b { display: block; font: 700 12px/1.2 'Outfit', system-ui, sans-serif; }
.md-tip > i {
  display: block; font-style: normal; margin-bottom: 5px;
  font-size: 10.5px; color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
.md-tip span { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; }
.md-tip span i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.md-tip span b {
  margin-left: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.md-tip span u {
  text-decoration: none; flex-basis: 100%; text-align: right;
  font: 500 10px/1.3 'JetBrains Mono', ui-monospace, monospace;
  color: var(--bb-ink-3, var(--text-muted, #8A8478));
}
