/* Paid media dashboard. Colours are roles, set once per theme, drawn from
   the Compare My Move brand: deep teal ink, green accent, mint, peach and
   sand tints on a warm page. The style guide page (#/style-guide) shows
   every role, icon and component as they are right now. */
:root {
  color-scheme: light;
  --page: #faf7f3;
  --panel: #ffffff;
  --panel-2: #fcfaf7;
  --ink: #183d3e;
  --ink-2: #3d5b5c;
  --ink-3: #5e7778;
  --line: #ebe6df;
  --line-strong: #d1d8d8;
  --wash: #f3f8f5;
  --shadow: 0 1px 2px rgba(24, 61, 62, 0.04), 0 1px 3px rgba(24, 61, 62, 0.06);

  --accent: #347a69;
  --accent-ink: #1f5446;
  --accent-wash: #e7fbf1;

  /* the top bar: between the side menu and the page */
  --bar-bg: #fdfbf8;
  --bar-line: #ebe6df;

  /* the side menu: its own surface, so it can differ from the cards */
  --nav-bg: #ffffff;
  --nav-line: #ebe6df;
  --scroll-thumb: #d3ccc1;
  --nav-scroll-thumb: #d3ccc1;
  --nav-wash: #f3f8f5;
  --nav-active: #e7fbf1;

  /* chart series: brighter steps of the brand's own hues, checked for colour-blind safety */
  --chart-main: #118264;
  --google: #118264;
  --microsoft: #d9703a;
  --facebook: #2b6f9e;
  --de-emphasis: #9aa9a9;

  --good: #2a7462;
  --bad: #c2414c;
  --note-bg: #fff5ef;
  --note-line: #ffe5b9;
  --note-ink: #183d3e;

  /* the tinted squares behind the icons on the headline cards */
  --tint-teal-bg: #e3eeee;   --tint-teal-fg: #183d3e;
  --tint-green-bg: #e7fbf1;  --tint-green-fg: #347a69;
  --tint-peach-bg: #ffeee5;  --tint-peach-fg: #c4622d;
  --tint-sand-bg: #fff1d6;   --tint-sand-fg: #9a6a12;

  /* table shading: red through amber to green */
  --heat-saturation: 68%;
  --heat-lightness: 91%;
  --heat-good: 22, 148, 110;
  --heat-bad: 194, 65, 76;

  font-family: "Rethink Sans", Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

/* Dark is the same roles re-stepped for a dark surface. It applies when the
   device asks for it, unless the toggle has been set to light, and whenever
   the toggle has been set to dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0a1415;
    --panel: #101c1d;
    --panel-2: #152526;
    --ink: #f4f7f5;
    --ink-2: #c9d6d3;
    --ink-3: #93a9a6;
    --line: #1f3233;
    --line-strong: #2e4748;
    --wash: #172a2b;
    --shadow: none;

    --accent: #8aecba;
    --accent-ink: #8aecba;
    --accent-wash: #16332f;

  --bar-bg: #0f2526;
  --bar-line: #1f3a3b;

  /* the side menu keeps the brand's deep teal while the page goes near-black */
  --nav-bg: #133132;
  --nav-line: #24494a;
  --scroll-thumb: #2e4748;
  --nav-scroll-thumb: #2f5c5d;
  --nav-wash: #1a4243;
  --nav-active: #1d4a43;

    --chart-main: #1f9e7a;
    --google: #1f9e7a;
    --microsoft: #d0703b;
    --facebook: #4a8abd;
    --de-emphasis: #6c8080;

    --good: #8aecba;
    --bad: #ff9e9e;
    --note-bg: #23261a;
    --note-line: #44432a;
    --note-ink: #ffeee5;

    --tint-teal-bg: #1a3334;   --tint-teal-fg: #bfe3e0;
    --tint-green-bg: #163530;  --tint-green-fg: #8aecba;
    --tint-peach-bg: #382820;  --tint-peach-fg: #ffc7a8;
    --tint-sand-bg: #352d18;   --tint-sand-fg: #ffd98f;

    --heat-saturation: 45%;
    --heat-lightness: 21%;
    --heat-good: 138, 236, 186;
    --heat-bad: 255, 158, 158;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0a1415;
  --panel: #101c1d;
  --panel-2: #152526;
  --ink: #f4f7f5;
  --ink-2: #c9d6d3;
  --ink-3: #93a9a6;
  --line: #1f3233;
  --line-strong: #2e4748;
  --wash: #172a2b;
  --shadow: none;

  --accent: #8aecba;
  --accent-ink: #8aecba;
  --accent-wash: #16332f;

  --bar-bg: #0f2526;
  --bar-line: #1f3a3b;

  /* the side menu keeps the brand's deep teal while the page goes near-black */
  --nav-bg: #133132;
  --nav-line: #24494a;
  --scroll-thumb: #2e4748;
  --nav-scroll-thumb: #2f5c5d;
  --nav-wash: #1a4243;
  --nav-active: #1d4a43;

  --chart-main: #1f9e7a;
  --google: #1f9e7a;
  --microsoft: #d0703b;
  --facebook: #4a8abd;
  --de-emphasis: #6c8080;

  --good: #8aecba;
  --bad: #ff9e9e;
  --note-bg: #23261a;
  --note-line: #44432a;
  --note-ink: #ffeee5;

  --tint-teal-bg: #1a3334;   --tint-teal-fg: #bfe3e0;
  --tint-green-bg: #163530;  --tint-green-fg: #8aecba;
  --tint-peach-bg: #382820;  --tint-peach-fg: #ffc7a8;
  --tint-sand-bg: #352d18;   --tint-sand-fg: #ffd98f;

  --heat-saturation: 45%;
  --heat-lightness: 21%;
  --heat-good: 138, 236, 186;
  --heat-bad: 255, 158, 158;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}

h1, h2, h3, p, figure { margin: 0; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* One icon set (static/icons.mjs): same grid, same stroke, sized by its place. */
.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- shell: side menu and page ----------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 16px;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-line);
}
.sidebar-brand { padding: 0 10px; }
/* The real logo, in its own colours: the normal one on light, the reversed one on dark. */
.brand-logo { display: block; width: 176px; max-width: 100%; height: auto; }
.brand-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }

.nav { display: grid; gap: 2px; }
.nav-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tab, .side-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.tab .icon, .side-button .icon { width: 18px; height: 18px; }
.tab:hover, .side-button:hover { background: var(--nav-wash); color: var(--ink); }
.tab[aria-current="page"] { background: var(--nav-active); color: var(--ink); font-weight: 650; }
.tab[aria-current="page"] .icon { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 24px; display: grid; gap: 2px; }
.side-user {
  margin-top: 10px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--nav-line);
  font-size: 12px;
  line-height: 18px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.page {
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 32px 56px;
  min-width: 0;
}

/* ---- page head ------------------------------------------------------------------ */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
h1 { font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { margin-top: 2px; font-size: 13px; line-height: 20px; color: var(--ink-3); }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; line-height: 24px; font-weight: 650; }
h3 { font-size: 14px; line-height: 20px; font-weight: 650; }
.card-sub { font-size: 12px; line-height: 18px; color: var(--ink-3); }

section { margin-top: 28px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 4px 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-sub { font-size: 13px; line-height: 20px; color: var(--ink-3); }

.note, .notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 1px solid var(--note-line);
  border-radius: 10px;
  background: var(--note-bg);
  color: var(--note-ink);
  font-size: 13px;
  line-height: 20px;
}
.note .icon { margin-top: 2px; }
.notice { margin: 0 0 16px; background: var(--panel); border-color: var(--bad); color: var(--ink); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.button, .chip, .field input, .stamp {
  height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  font-size: 13px;
  line-height: 20px;
  font-weight: 550;
}
.button, .stamp, .chip { display: inline-flex; align-items: center; gap: 8px; }
.stamp { margin: 0; color: var(--ink-2); border-color: var(--line); box-shadow: var(--shadow); }
.stamp span { display: inline-flex; }
.button, .chip { cursor: pointer; }
.button { box-shadow: var(--shadow); }
.button:hover, .chip:hover { background: var(--wash); }
select.chip.is-set,
.chip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent); color: var(--ink); font-weight: 650; }
/* a dropdown: as wide as its longest choice, with our own arrow set in from the edge */
.select-wrap { position: relative; display: inline-flex; }
.select-wrap select.chip { appearance: none; -webkit-appearance: none; padding-right: 36px; }
.select-wrap .icon { position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
                     color: var(--ink-3); pointer-events: none; }
.chip-title { font-size: 14px; font-weight: 650; }
.button:focus-visible, .chip:focus-visible, .field input:focus-visible, .table-scroll:focus-visible,
a:focus-visible, .row-toggle:focus-visible, .plot svg:focus-visible, .side-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- headline cards -------------------------------------------------------------------
   Every card is the same grid at fixed line heights: icon beside label and
   value, then one line for what it is compared with and the change. Labels,
   values and changes therefore sit on shared lines across a row whatever the
   numbers are. */
.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  transition: opacity 120ms;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: 18px 30px 18px;
  column-gap: 12px;
  row-gap: 0;
  min-width: 0;
}
.tile-icon {
  grid-row: 1 / 3;
  align-self: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
}
.tile-icon .icon { width: 20px; height: 20px; }
.tint-teal { background: var(--tint-teal-bg); color: var(--tint-teal-fg); }
.tint-green { background: var(--tint-green-bg); color: var(--tint-green-fg); }
.tint-peach { background: var(--tint-peach-bg); color: var(--tint-peach-fg); }
.tint-sand { background: var(--tint-sand-bg); color: var(--tint-sand-fg); }
.figure-label {
  font-size: 12px;
  line-height: 18px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-value {
  font-size: 22px;
  line-height: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.tile-foot {
  grid-column: 1 / -1;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.versus { font-size: 12px; line-height: 18px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 650;
  color: var(--ink-3);
  white-space: nowrap;
}
.delta .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.delta-good { color: var(--good); }
.delta-bad { color: var(--bad); }
.tile { grid-template-rows: 18px 30px auto; }

/* ---- channel cards ------------------------------------------------------------------ */
.channel-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.channel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.channel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.channel-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch-google { background: var(--google); }
.swatch-microsoft { background: var(--microsoft); }
.swatch-facebook { background: var(--facebook); }
.swatch-revenue { background: var(--chart-main); }
.swatch-spend { background: var(--de-emphasis); }
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 650;
  color: var(--accent-ink);
  text-decoration: none;
  white-space: nowrap;
}
.card-link:hover { text-decoration: underline; }
.card-link .icon { width: 14px; height: 14px; }
.figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 16px;
  margin-top: 14px;
}
.figure { display: grid; grid-template-rows: 18px 28px; row-gap: 2px; min-width: 0; }
.figure-value { font-size: 18px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }

/* ---- forecast blocks -------------------------------------------------------------------- */
.blocks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; min-height: 24px; }
.block-title { display: flex; align-items: center; }
.pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 18px;
  font-weight: 550;
  white-space: nowrap;
}
.block .figure { grid-template-rows: 18px 28px 18px 18px; }
.block .figure-value { font-size: 20px; }
.prior { font-size: 12px; line-height: 18px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--note-bg);
  border: 1px solid var(--note-line);
  color: var(--note-ink);
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: help;
}
.tag .icon { width: 11px; height: 11px; }

/* ---- filters ---------------------------------------------------------------------------- */
.filters {
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  margin: 16px 0;
}
section > .filters { margin-top: 0; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label, .field { font-size: 13px; line-height: 20px; color: var(--ink-3); }
.field { display: inline-flex; align-items: center; gap: 7px; }

.selection {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-wash);
  font-size: 13px;
  line-height: 20px;
}
.selection-lead { color: var(--ink-2); }
.selection strong { color: var(--accent-ink); font-weight: 650; margin-right: auto; }
.selection .chip { height: 30px; padding: 4px 10px; gap: 6px; }
.selection .icon { width: 14px; height: 14px; }

/* ---- charts -------------------------------------------------------------------------------- */
.charts {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  transition: opacity 120ms;
}
.is-loading { opacity: 0.55; }
.chart-card { padding: 16px 18px 12px; min-width: 0; }
.chart-second-title { margin-top: 18px; }
/* the picker stands where the other card has its title and subtitle */
.chart-pick { display: flex; align-items: center; min-height: 38px; }
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 18px;
  margin-top: 10px;
  font-size: 12px;
  line-height: 18px;
  color: var(--ink-2);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.plot { height: 230px; margin-top: 8px; }
.plot-short { height: 130px; }
.plot-tall { height: 426px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot text { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-line, .reference-line, .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-area { stroke: none; opacity: 0.1; }
.stroke-revenue { stroke: var(--chart-main); }
.stroke-spend { stroke: var(--de-emphasis); }
.fill-revenue { fill: var(--chart-main); }
.fill-spend { fill: var(--de-emphasis); }
.fill-google { fill: var(--google); }
.fill-microsoft { fill: var(--microsoft); }
.fill-facebook { fill: var(--facebook); }
.dot { stroke: var(--panel); stroke-width: 2; }
.hover-band { fill: var(--wash); }
.empty { fill: var(--ink-3); font-size: 13px; }

.tooltip {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  pointer-events: none;
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  font-size: 12px;
  line-height: 18px;
}
.tooltip-title { font-weight: 650; margin-bottom: 4px; }
.tooltip-row { display: flex; align-items: center; gap: 6px; }
.tooltip-row .key-line { width: 10px; }
.tooltip-name { color: var(--ink-2); }
.tooltip-value { margin-left: auto; padding-left: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip-total { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }

/* ---- tables ------------------------------------------------------------------------------------ */
.table-card { margin-top: 14px; overflow: hidden; }
.table-head { padding: 16px 18px 12px; }
.table-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
/* a long table scrolls inside its card so its headings and total stay in view */
.table-scroll-capped { overflow: auto; max-height: min(720px, 80vh); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td {
  padding: 0 10px;
  height: 42px;
  font-size: 13px;
  line-height: 20px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
thead th {
  position: sticky;
  z-index: 2;
  height: 36px;
  background: var(--panel-2);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 550;
}
thead tr:first-child th { top: 0; text-align: left; color: var(--ink); font-weight: 650; border-bottom: 0; }
thead tr:last-child th { top: 36px; }
/* a table with one heading row: column labels only, pinned at the very top */
thead tr:only-child th {
  top: 0; text-align: right; color: var(--ink-3); font-weight: 550; border-bottom: 1px solid var(--line);
}
thead tr:only-child th:first-child { text-align: left; }
th:first-child, td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  padding-left: 18px;
  text-align: left;
  background: var(--panel);
  border-right: 1px solid var(--line);
  font-weight: 550;
}
thead th:first-child { z-index: 3; background: var(--panel-2); }
.group-start { border-left: 1px solid var(--line-strong); }
.group-name { display: inline-flex; align-items: center; gap: 8px; }
tbody tr:hover > td { background-image: linear-gradient(var(--wash), var(--wash)); }
td.heat { background-color: hsl(var(--hue) var(--heat-saturation) var(--heat-lightness)); }
td.heat-profit { background-color: rgba(var(--heat-good), var(--strength)); }
td.heat-loss { background-color: rgba(var(--heat-bad), var(--strength)); color: var(--bad); font-weight: 650; }
td.none { color: var(--ink-3); font-weight: 400; }
.date-day { display: inline-block; width: 34px; color: var(--ink-3); font-weight: 400; }

/* rows that open */
tr.opens { cursor: pointer; }
/* an opened row is marked, but its shaded cells keep their shading */
tr.is-open > td { font-weight: 650; }
tr.is-open > td:not(.heat):not(.heat-profit):not(.heat-loss) {
  background-image: linear-gradient(var(--accent-wash), var(--accent-wash));
}
tr.is-open > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.row-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: -6px;
  padding: 4px 6px 4px 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-weight: inherit;
  cursor: pointer;
}
.row-toggle .icon { width: 14px; height: 14px; color: var(--ink-3); transition: transform 120ms; }
.row-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
tr.child > td { color: var(--ink-2); background-color: var(--panel-2); }
/* the rows inside an opened row are shaded too, against each other */
tr.child > td.heat { background-color: hsl(var(--hue) var(--heat-saturation) var(--heat-lightness)); }
tr.child > td.heat-profit { background-color: rgba(var(--heat-good), var(--strength)); }
tr.child > td.heat-loss { background-color: rgba(var(--heat-bad), var(--strength)); color: var(--bad); }
tr.child > td:first-child { background-color: var(--panel-2); font-weight: 400; }
.child-label { display: inline-flex; align-items: center; gap: 6px; padding-left: 14px; }
.child-label .icon { width: 13px; height: 13px; color: var(--ink-3); }
td.change { color: var(--ink-3); }
tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--panel-2);
  font-weight: 700;
  border-top: 1px solid var(--line-strong);
  border-bottom: 0;
}
tfoot td:first-child { z-index: 2; background: var(--panel-2); font-weight: 700; }
.table-foot { padding: 12px 18px 14px; border-top: 1px solid var(--line); font-size: 12px; line-height: 18px; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) { .row-toggle .icon, .charts, .tiles { transition: none; } }

/* ---- narrower screens ------------------------------------------------------------------------------ */
@media (max-width: 1599px) {
  /* six across only where a seven-figure sum still fits beside its icon */
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  /* three figures need more room than a third of this width gives them */
  .channel-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1180px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
  .plot-tall { height: 260px; }
  .blocks { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  /* the side menu becomes a bar across the top */
  .app { display: block; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--nav-line);
  }
  .nav { display: flex; gap: 4px; margin-top: 0; overflow-x: auto; margin-right: auto; }
  .nav-label { display: none; }
  .tab { width: auto; white-space: nowrap; }
  .sidebar-foot { display: flex; align-items: center; gap: 4px; margin-top: 0; padding-top: 0; }
  .side-button { width: auto; }
  .side-user { display: none; }
  .page { padding: 20px 16px 40px; }
  .channel-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 12px; column-gap: 10px; grid-template-columns: 32px minmax(0, 1fr); }
  .tile-icon { width: 32px; height: 32px; border-radius: 9px; }
  .tile-icon .icon { width: 16px; height: 16px; }
  .tile-value { font-size: 19px; }
  .tile-foot { flex-wrap: wrap; gap: 0 8px; }
  .figure-value, .block .figure-value { font-size: 17px; }
  .figures { column-gap: 10px; }
}

/* the change line inside a forecast figure */
.delta-line { display: flex; align-items: center; height: 18px; }

/* Company logos (static/icons.mjs): in their own colours, never recoloured. */
.logo { width: 18px; height: 18px; flex: none; }
.channel-name .logo, .group-name .logo { width: 16px; height: 16px; }
h1 .logo { width: 24px; height: 24px; margin-right: 10px; vertical-align: -3px; }

/* ---- style guide page -------------------------------------------------------------------------------- */
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sg-swatch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  min-width: 0;
}
.sg-chip { width: 44px; height: 44px; flex: none; border-radius: 10px; border: 1px solid var(--line-strong); }
.sg-name { font-size: 13px; line-height: 18px; font-weight: 650; }
.sg-value { font-size: 12px; line-height: 18px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sg-logos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.sg-logo-box { padding: 28px 24px 14px; border-radius: 16px; border: 1px solid var(--line); min-width: 0; }
.sg-logo-box img { display: block; width: 240px; max-width: 100%; height: auto; margin-bottom: 18px; }
/* each version of the logo on the background it is made for, whatever the theme */
.sg-on-light { background: #ffffff; }
.sg-on-light .card-sub { color: #5e7778; }
.sg-on-dark { background: #133132; }
.sg-on-dark .card-sub { color: #9bb5b0; }
.sg-card { padding: 16px 18px; }
.sg-type { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sg-type:last-child { border-bottom: 0; }
.sg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.sg-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}
.sg-icon .icon, .sg-icon .logo { width: 24px; height: 24px; }
.sg-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sg-row { display: flex; align-items: center; gap: 12px 14px; flex-wrap: wrap; margin-top: 14px; }
.sg-row .legend { margin-top: 0; }
.sg-row .tag { margin-left: 0; }
.sg-rules { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px 18px; margin: 0; }
.sg-rules dt { font-weight: 650; }
.sg-rules dd { margin: 0; color: var(--ink-2); }
@media (max-width: 760px) {
  .sg-logos, .sg-tiles, .sg-rules { grid-template-columns: minmax(0, 1fr); }
  .sg-rules dd { margin-bottom: 8px; }
}

/* ---- the top bar ------------------------------------------------------------------------------------
   Beside the side menu and edge to edge across the rest of the window: the
   dates, grouping and export. It stays put while the page scrolls on screens
   wide enough to spare the room, so the dates in force are always in view.
   Its surface sits between the side menu's and the page's. */
.app { grid-template-rows: auto 1fr; }
.sidebar { grid-row: 1 / -1; }
.topbar {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px 20px;
  flex-wrap: wrap;
  min-height: 60px;
  padding: 10px 32px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--bar-line);
}
.topbar .filters { margin: 0; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.topbar.is-bare { display: none; }
.sidebar-brand { padding: 6px 10px 20px; }
@media (min-width: 901px) {
  .topbar { position: sticky; top: 0; z-index: 20; }
}
@media (max-width: 900px) {
  .topbar { padding: 12px 16px; }
  .toolbar-actions { margin-left: 0; }
  .sidebar-brand { padding: 0; margin-right: auto; }
  .sidebar-brand .brand-logo { width: 150px; }
}

.date-input {
  height: 36px;
  width: 132px;
  padding: 7px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
  font-size: 13px;
  line-height: 20px;
}
.date-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.topbar .filters { gap: 8px 12px; }
/* the bar holds a lot on one line, so its controls are a little tighter */
.topbar .filter-group { gap: 5px; }
.topbar .chip { padding-left: 10px; padding-right: 10px; }
.topbar .select-wrap select.chip { padding-right: 30px; }
.topbar .select-wrap .icon { right: 10px; }
.topbar .date-input { width: 124px; }

/* ---- the date buttons and the calendar that opens under them ---- */
.date-pick { position: relative; display: inline-flex; }
.date-button {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  color: var(--ink); font-weight: 550; cursor: pointer; white-space: nowrap;
}
.topbar .date-button { width: 128px; padding: 7px 10px; }
.date-button .icon { width: 15px; height: 15px; flex: none; color: var(--ink-3); }
.date-button:hover { background: var(--wash); }
.date-button[aria-expanded="true"] { border-color: var(--accent); }
.calendar {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 284px;
  padding: 12px;
  transform: translateX(var(--shift, 0px));
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(10, 30, 30, 0.18);
}
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-title { font-size: 14px; line-height: 20px; font-weight: 650; color: var(--ink); }
.calendar-step, .calendar-day {
  display: grid; place-items: center; border: 0; background: none; color: var(--ink); cursor: pointer;
}
.calendar-step { width: 32px; height: 32px; border-radius: 9px; color: var(--ink-2); }
.calendar-step .icon { width: 16px; height: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.calendar-weekday {
  height: 28px; display: grid; place-items: center;
  font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.04em; color: var(--ink-3);
}
.calendar-day {
  height: 36px; border-radius: 10px;
  font-size: 13px; line-height: 20px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.calendar-day.in-range { background: var(--accent-wash); border-radius: 0; }
.calendar-step:hover:not(:disabled), .calendar-day:hover:not(:disabled) { background: var(--wash); }
.calendar-day.in-range:hover:not(:disabled) { background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent); }
.calendar-day[aria-pressed="true"],
.calendar-day[aria-pressed="true"]:hover { background: var(--accent); color: var(--page); font-weight: 700; border-radius: 10px; box-shadow: none; }
.calendar-step:disabled, .calendar-day:disabled { color: var(--ink-3); opacity: 0.45; cursor: default; }
.calendar-step:focus-visible, .calendar-day:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.date-pick:last-child .calendar { left: auto; right: 0; }
.side-stamp { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--ink-2); }
.side-stamp .icon { width: 14px; height: 14px; }

/* The filters sit in the middle of the bar, with the export at its right end.
   Equal columns either side keep them centred on the bar itself, not on the
   space the export leaves. */
@media (min-width: 901px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  }
  .topbar .filters { grid-column: 2; justify-content: center; }
  .toolbar-actions { grid-column: 3; justify-self: end; margin-left: 0; }
}

/* room between a page's heading and its first cards */
#platform-tiles { margin-top: 16px; }
.selection { margin: 16px 0 0; }

/* ---- the menu's smart bidding label links ---- */
.nav-group { display: grid; gap: 2px; }

/* ---- small additions: table search, forecast note, campaign type ---- */
.table-head-split { display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.search-input { width: 250px; max-width: 100%; }
.section-note { margin-top: 12px; max-width: 110ch; font-size: 12px; line-height: 18px; color: var(--ink-3); }
.kind-tag {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--ink-2);
  font-size: 11px;
  line-height: 16px;
  font-weight: 550;
}

/* ---- names that may be long ---------------------------------------------------- */
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.name-label, .child-label, .row-toggle { max-width: 340px; }
.name-label { display: inline-flex; align-items: center; gap: 8px; }
.name-label .logo { width: 16px; height: 16px; flex: none; }
.rank {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--wash);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 22px;
  font-weight: 650;
  text-align: center;
}
tr.is-static > td { font-weight: 650; }

/* ---- Facebook Ads and service label pages ------------------------------------------ */
#page-detail .page-head { align-items: center; }
#detail-platforms { margin-top: 4px; }
#detail-tiles { margin-top: 16px; }
#detail-logo:empty { display: none; }

/* ---- Specialist analysis --------------------------------------------------------------- */
.tiles-four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; }
.tile-icon .logo { width: 20px; height: 20px; }
.tile-foot-plain { justify-content: flex-start; }
.charts-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.charts > .table-card { margin-top: 0; }
.table-head h3 { display: flex; align-items: center; gap: 8px; }
.table-head h3 .logo { width: 18px; height: 18px; flex: none; }
.mix-card { padding: 16px 18px 18px; }
.bars { display: grid; gap: 18px; margin-top: 20px; }
.bar-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 4px 12px; }
.bar-name { display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 20px; font-weight: 600; }
.bar-name .logo { width: 16px; height: 16px; flex: none; }
.bar-spend { grid-column: 2; font-size: 12px; line-height: 18px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.share { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.share-track { flex: 1; height: 10px; border-radius: 4px; background: var(--wash); overflow: hidden; }
.share-fill { display: block; width: var(--share); height: 100%; border-radius: 0 4px 4px 0; background: var(--chart-main); }
.share-value { flex: none; width: 52px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
td.share-cell { min-width: 220px; }
@media (max-width: 1280px) {
  .tiles-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .tiles-four { grid-template-columns: minmax(0, 1fr); }
}

/* ---- scrollbars in the theme's colours ----------------------------------------------
   Thin ones inside cards and the menu; the page's own keeps its normal width. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
:root { scrollbar-width: auto; scrollbar-color: var(--scroll-thumb) var(--page); }
.sidebar { scrollbar-color: var(--nav-scroll-thumb) transparent; }

/* ---- a menu that folds away to its icons ---------------------------------------------- */
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-right: 0; }
.sidebar-brand .brand-logo { width: 146px; min-width: 0; }
.brand-mark { display: none; flex: none; width: 40px; height: 40px; border-radius: 11px; }
.nav-toggle {
  /* level with the middle of the logo's letters, which sit above the middle of
     its file because of the tails on the p and the y */
  position: relative;
  top: -3px;
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.nav-toggle .icon { width: 18px; height: 18px; }
.nav-toggle:hover { background: var(--nav-wash); color: var(--ink); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 901px) {
  :root[data-nav="collapsed"] .app { grid-template-columns: 68px minmax(0, 1fr); }
  :root[data-nav="collapsed"] .sidebar { padding-left: 12px; padding-right: 12px; }
  /* the folded menu shows the square brand mark, with the button to open it underneath */
  :root[data-nav="collapsed"] .sidebar-brand { flex-direction: column; justify-content: center; gap: 12px; padding: 0 0 14px; }
  :root[data-nav="collapsed"] .brand-mark { display: block; }
  :root[data-nav="collapsed"] .nav-toggle { top: 0; }
  :root[data-nav="collapsed"] .brand-logo,
  :root[data-nav="collapsed"] .side-user { display: none; }
  /* the words go; the icons stay, centred in the rail */
  :root[data-nav="collapsed"] .tab,
  :root[data-nav="collapsed"] .side-button { justify-content: center; gap: 0; font-size: 0; }
  /* a section heading becomes a rule between the groups of icons */
  :root[data-nav="collapsed"] .nav-label {
    height: 1px; margin: 10px 8px; font-size: 0; line-height: 0; background: var(--nav-line);
  }
}
@media (max-width: 900px) {
  .nav-toggle { display: none; }      /* the menu is already a bar across the top */
}

/* ---- the sign-in page ---------------------------------------------------------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; padding: 36px 32px 28px; text-align: center; }
.login-card .brand-logo { width: 200px; margin: 0 auto 28px; }
.login-card h1 { font-size: 22px; line-height: 30px; }
.login-sub { margin-top: 6px; font-size: 14px; line-height: 22px; color: var(--ink-2); }
.login-card .notice { margin: 20px 0 0; text-align: left; }
.login-button {
  width: 100%; height: 44px; margin-top: 24px; justify-content: center; gap: 10px;
  font-size: 14px; font-weight: 650; color: var(--ink); text-decoration: none;
}
.login-button .logo { width: 18px; height: 18px; }
.login-foot { margin-top: 20px; font-size: 12px; line-height: 18px; color: var(--ink-3); }
