/* ===========================================================================
   Trading Wallboard
   Dark-first by deliberate choice: this lives on a TV in a venue, so dark is
   the design, not a preference. A light theme is available via the toggle for
   anyone opening it on a laptop in daylight — it is a *selected* set of steps
   from the same ramps, not an inverted dark theme.
   =========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces & ink */
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #212120;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --gridline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Categorical slots — fixed order, never cycled, never rank-assigned */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  /* Lighter step of slot 1's own ramp — meter tracks & de-emphasised bars */
  --series-1-muted: #1c5cab;
  --meter-track: #22314a;
  --compare: #898781;

  /* Status — reserved, never reused as a series colour */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  /* Ordinal ramp for order stages (slot 1 hue, light→dark) */
  --stage-1: #86b6ef;
  --stage-2: #5598e7;
  --stage-3: #3987e5;
  --stage-4: #2a78d6;
  --stage-5: #256abf;
  --stage-6: #1c5cab;

  --radius: 12px;
  --gap: 0.75rem;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ed;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --gridline: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --border-strong: rgba(11, 11, 11, 0.16);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --series-1-muted: #9ec5f4;
  --meter-track: #e2ecfa;
  --compare: #898781;

  --stage-1: #b7d3f6;
  --stage-2: #86b6ef;
  --stage-3: #5598e7;
  --stage-4: #3987e5;
  --stage-5: #2a78d6;
  --stage-6: #1c5cab;
}

/* --- base ---------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Scales the whole board with the screen — 16px at 1080p, ~22px at 1440p. */
  font-size: clamp(12px, 0.84vw, 24px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.board {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--gap);
  height: 100dvh;
  padding: var(--gap);
  /* Refetch holds the previous render rather than flashing a skeleton. */
  transition: opacity 0.25s ease;
}

.board.is-stale {
  opacity: 0.55;
}

/* --- top bar ------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.topbar__mark {
  width: 2rem;
  height: 2rem;
  flex: none;
}

.topbar__title {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar__subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.topbar__progress {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.dayprog {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(38rem, 100%);
}

.dayprog__track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--meter-track);
  overflow: hidden;
}

.dayprog__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--series-1);
  width: 0%;
  transition: width 1s linear;
}

.dayprog__label {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: none;
}

.badge {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--status-warning);
  color: var(--status-warning);
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.conn__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.conn.is-live .conn__dot {
  background: var(--status-good);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--status-good) 22%, transparent);
}

.conn.is-down .conn__dot {
  background: var(--status-critical);
}

.clock {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Seconds are de-emphasised: the ticking proves the board is live without
   pulling the eye away from the trading figures. */
.clock__secs {
  font-size: 0.72em;
  color: var(--text-secondary);
  margin-left: 0.05em;
}

.topbar__actions {
  display: flex;
  gap: 0.3rem;
}

.iconbtn {
  font: inherit;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  line-height: 1.2;
}

.iconbtn:hover,
.iconbtn:focus-visible {
  color: var(--text-primary);
  border-color: var(--border-strong);
  outline: none;
}

/* --- hero ---------------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr);
  gap: var(--gap);
}

.hero__lead,
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}

.hero__label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* The single hero figure. Proportional figures — tabular-nums reads loose at
   display sizes. Same sans as everything else. */
.hero__figure {
  font-size: 3.2rem;
  font-weight: 660;
  letter-spacing: -0.025em;
  line-height: 1.02;
  margin: 0.1rem 0 0.35rem;
}

.hero__meterrow {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.hero__meterinfo {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.statuschip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 620;
  font-size: 0.78rem;
  white-space: nowrap;
}

.statuschip__glyph {
  font-size: 0.7rem;
  line-height: 1;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--gap);
}

.tile__label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__value {
  font-size: 1.85rem;
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-top: 0.1rem;
}

.tile__sub {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delta {
  font-weight: 620;
}
.delta--up {
  color: var(--status-good);
}
.delta--down {
  color: var(--status-critical);
}
.delta--flat {
  color: var(--muted);
}

/* --- main grid ----------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1.02fr) minmax(0, 1fr);
  grid-template-areas:
    "sites sites sites sites sites leaders leaders leaders leaders orders orders orders"
    "hourly hourly hourly hourly hourly trend trend mix mix orders orders orders";
  min-height: 0;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.panel--sites {
  grid-area: sites;
}
.panel--leaders {
  grid-area: leaders;
}
.panel--orders {
  grid-area: orders;
}
.panel--hourly {
  grid-area: hourly;
}
.panel--trend {
  grid-area: trend;
}
.panel--mix {
  grid-area: mix;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  flex: none;
}

.panel__title {
  font-size: 0.92rem;
  font-weight: 640;
  letter-spacing: -0.005em;
}

.panel__hint {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

/* Small key glyphs so the site cards' encoding is stated, not guessed. */
.key {
  display: inline-block;
  flex: none;
}
.key--fill {
  width: 0.7rem;
  height: 0.55rem;
  border-radius: 2px;
  background: color-mix(in srgb, var(--series-1) 35%, transparent);
  border-bottom: 2px solid var(--series-1);
}
.key--line {
  width: 0.7rem;
  height: 2px;
  background: var(--compare);
  border-radius: 1px;
}
.key--tick {
  width: 2px;
  height: 0.7rem;
  background: var(--text-secondary);
  border-radius: 1px;
}

.legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.legend__swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  flex: none;
}

.legend__swatch--rule {
  height: 2px;
  border-radius: 1px;
}

.chartwrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.chartwrap svg {
  display: block;
}

/* --- site cards ---------------------------------------------------------- */

.sitegrid {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
  align-content: start;
  overflow: hidden;
}

.sitecard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* Severity re-stated as a left rule so status is never colour in one place only. */
.sitecard::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--card-accent, var(--muted));
}

.sitecard__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}

.sitecard__name {
  font-size: 0.82rem;
  font-weight: 620;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sitecard__flag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--status-serious);
  color: var(--status-serious);
  white-space: nowrap;
  flex: none;
}

.sitecard__net {
  font-size: 1.5rem;
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.sitecard__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.sitecard__spark {
  margin-top: 0.1rem;
}

.sitecard__spark svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- leaderboard --------------------------------------------------------- */

.leaders {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  overflow: hidden;
}

.leader {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  background: var(--surface-2);
}

.leader--top {
  background: color-mix(in srgb, var(--series-1) 12%, var(--surface-2));
}

.leader__rank {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.leader--top .leader__rank {
  color: var(--text-primary);
}

.leader__name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leader__site {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leader__figures {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leader__net {
  font-size: 0.88rem;
  font-weight: 640;
}

.leader__sub {
  font-size: 0.68rem;
  color: var(--muted);
}

.leader__bar {
  grid-column: 2 / 4;
  margin-top: 0.1rem;
}

.rowbar {
  display: block;
  width: 100%;
  height: 4px;
}

/* --- order flow ---------------------------------------------------------- */

.stagebar {
  display: flex;
  gap: 2px;
  margin-bottom: 0.5rem;
  flex: none;
}

.stagebar__seg {
  flex: 1;
  border-radius: 6px;
  padding: 0.25rem 0.3rem;
  text-align: center;
  background: var(--surface-2);
  min-width: 0;
}

.stagebar__count {
  font-size: 1rem;
  font-weight: 660;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stagebar__label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stagebar__seg[data-stage] .stagebar__dot {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.orders {
  /* Shrink to the orders actually present so Top sellers rises to meet them,
     rather than leaving a hole in the panel during quiet hours. */
  flex: 0 1 auto;
  max-height: 44%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Secondary heading inside a panel that carries two related lists. */
.panel__split {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.6rem 0 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  flex: none;
}

.sellers {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.seller {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.4rem;
  border-radius: 7px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.seller__name {
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seller__group {
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seller__qty {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.seller__value {
  font-size: 0.8rem;
  font-weight: 620;
  white-space: nowrap;
  min-width: 3.2rem;
  text-align: right;
}

.seller__bar {
  grid-column: 1 / 4;
  margin-top: 0.05rem;
}

.order {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 0.5rem;
  border-left: 3px solid var(--order-accent, var(--stage-3));
}

.order--late {
  border-left-color: var(--status-serious);
}

.order__top {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.order__ref {
  font-size: 0.78rem;
  font-weight: 620;
  white-space: nowrap;
}

.order__site {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order__age {
  font-size: 0.78rem;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.order__age--late {
  color: var(--status-serious);
}

.order__lines {
  font-size: 0.68rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order__stage {
  font-size: 0.66rem;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: flex-end;
}

.order__stagedot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex: none;
}

/* --- payment mix --------------------------------------------------------- */

.mix {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.donut {
  display: block;
  flex: none;
}

.donut-value {
  fill: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 660;
}

.donut-caption {
  fill: var(--muted);
  font-size: 0.65rem;
}

.mixlegend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mixlegend li {
  display: grid;
  grid-template-columns: 0.65rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.mixlegend__swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
}

.mixlegend__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.mixlegend__pct {
  color: var(--muted);
  min-width: 2.4rem;
  text-align: right;
}

/* --- chart text ---------------------------------------------------------- */

.axis-label {
  fill: var(--muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.axis-label.is-today {
  fill: var(--text-primary);
  font-weight: 640;
}

.chart-endlabel {
  fill: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 640;
}

/* --- ticker -------------------------------------------------------------- */

.ticker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  min-height: 2.1rem;
}

.ticker__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: none;
}

.ticker__track {
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.ticker__items {
  display: flex;
  gap: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ticker__glyph {
  font-size: 0.7rem;
}

.ticker__item--critical {
  color: var(--status-critical);
}
.ticker__item--warn {
  color: var(--status-warning);
}
.ticker__item--ok {
  color: var(--text-secondary);
}

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

/* A class selector out-specifies the UA's [hidden] rule, so restate it. */
.tableview[hidden] {
  display: none;
}

.tableview {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--page) 92%, transparent);
  backdrop-filter: blur(4px);
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.tableview__inner {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: min(70rem, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tableview__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.tableview__head h2 {
  font-size: 1rem;
  font-weight: 640;
}

.tableview__scroll {
  overflow: auto;
  padding: 0 1rem 1rem;
}

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

th,
td {
  text-align: right;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-weight: 620;
  font-size: 0.74rem;
}

tfoot td {
  font-weight: 660;
  border-top: 2px solid var(--border-strong);
}

.empty {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem 0;
  text-align: center;
}

/* ===========================================================================
   Scrollable lists
   These panels hold more rows than fit. Previously they were clipped, which
   silently truncated the leaderboard and left half-rows at the bottom edge.
   Now they scroll, with a fade to signal there is more below.
   =========================================================================== */

.leaders,
.orders,
.sellers {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  /* Fade the last few pixels so a clipped row reads as "more below" rather
     than as a rendering bug. */
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4rem), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4rem), transparent 100%);
  padding-bottom: 0.3rem;
}

.leaders::-webkit-scrollbar,
.orders::-webkit-scrollbar,
.sellers::-webkit-scrollbar {
  width: 6px;
}

.leaders::-webkit-scrollbar-thumb,
.orders::-webkit-scrollbar-thumb,
.sellers::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

.leaders::-webkit-scrollbar-track,
.orders::-webkit-scrollbar-track,
.sellers::-webkit-scrollbar-track {
  background: transparent;
}

/* Scrolled to the end: drop the fade, otherwise the final row looks cut off. */
.leaders.is-at-end,
.orders.is-at-end,
.sellers.is-at-end {
  mask-image: none;
  -webkit-mask-image: none;
}

/* ===========================================================================
   Chart tooltips
   =========================================================================== */

.tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 30;
  pointer-events: none;
  min-width: 9rem;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface-2) 96%, transparent);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
  font-size: 0.78rem;
  backdrop-filter: blur(6px);
}

.tip[hidden] {
  display: none;
}

.tip__title {
  font-weight: 660;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.tip__row {
  display: grid;
  grid-template-columns: 0.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

/* Rows without a swatch still align with those that have one. */
.tip__row .tip__label:first-child {
  grid-column: 2;
}

.tip__swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
}

.tip__value {
  color: var(--text-primary);
  font-weight: 620;
}

.hit {
  cursor: crosshair;
}

.donut__seg {
  transition: opacity 120ms ease-out;
}

.donut:hover .donut__seg {
  opacity: 0.55;
}

.donut .donut__seg:hover {
  opacity: 1;
}

/* ===========================================================================
   Celebration layer
   Fires when data actually changes, never on a no-op refresh. Everything here
   animates transform/opacity only, removes its own nodes when finished, and is
   switched off entirely by prefers-reduced-motion — this runs on a screen for
   weeks at a time, so it must not leak nodes or pin the compositor.
   =========================================================================== */

:root {
  --coin: #f0c419;
  --coin-edge: #c08f0b;
}

/* --- board-wide sweep on update ------------------------------------------ */

.sweep {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.sweep::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40vw;
  left: -45vw;
  background: linear-gradient(
    100deg,
    transparent 0%,
    color-mix(in srgb, var(--series-1) 9%, transparent) 45%,
    color-mix(in srgb, var(--series-1) 16%, transparent) 50%,
    color-mix(in srgb, var(--series-1) 9%, transparent) 55%,
    transparent 100%
  );
  animation: sweep-across 1100ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes sweep-across {
  to {
    left: 105vw;
  }
}

/* --- money rain ----------------------------------------------------------- */

.rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
  border-radius: inherit;
}

/* Coins fall *behind* the figures. The whole point of the board is the
   numbers, so the celebration must never be the thing you read first. */
.sitecard > *:not(.rain):not(.targethit) {
  position: relative;
  z-index: 2;
}

.coin {
  opacity: 0;
}

.coin {
  position: absolute;
  top: -1.4rem;
  width: 1.15rem;
  height: 1.15rem;
  will-change: transform, opacity;
  animation: coin-fall var(--dur, 1600ms) cubic-bezier(0.35, 0.1, 0.6, 1) var(--delay, 0ms) forwards;
  opacity: 0;
}

@keyframes coin-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.7);
    opacity: 0;
  }
  12% {
    opacity: 1;
    transform: translate3d(0, 12%, 0) rotate(20deg) scale(1);
  }
  85% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift, 0px), var(--dist, 160px), 0) rotate(var(--rot, 220deg)) scale(1);
    opacity: 0;
  }
}

/* --- floating "+£x" chip -------------------------------------------------- */

.deltachip {
  position: absolute;
  right: 0.55rem;
  top: 1.4rem;
  z-index: 4;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--status-good);
  text-shadow: 0 1px 6px color-mix(in srgb, var(--page) 80%, transparent);
  pointer-events: none;
  animation: chip-rise 2000ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
  white-space: nowrap;
}

@keyframes chip-rise {
  0% {
    transform: translateY(0.5rem) scale(0.85);
    opacity: 0;
  }
  18% {
    transform: translateY(0) scale(1.06);
    opacity: 1;
  }
  30% {
    transform: translateY(-0.1rem) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    transform: translateY(-1.9rem) scale(1);
    opacity: 0;
  }
}

/* --- card / tile pulse ---------------------------------------------------- */

.is-bumped {
  animation: bump 900ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes bump {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--status-good) 45%, transparent);
  }
  35% {
    transform: scale(1.018);
    box-shadow: 0 0 0 0.35rem color-mix(in srgb, var(--status-good) 0%, transparent);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 transparent;
  }
}

/* Digits that are mid-count-up get a subtle lift so the eye follows them. */
.is-counting {
  color: var(--status-good);
  transition: color 600ms ease-out;
}

/* --- target hit ----------------------------------------------------------- */

.targethit {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  border-radius: inherit;
}

.targethit__label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--page);
  background: var(--status-good);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  animation: target-pop 2600ms cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes target-pop {
  0% {
    transform: scale(0.5) rotate(-6deg);
    opacity: 0;
  }
  15% {
    transform: scale(1.12) rotate(2deg);
    opacity: 1;
  }
  28% {
    transform: scale(1) rotate(0deg);
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: scale(1.02);
    opacity: 0;
  }
}

/* --- leaderboard rank change --------------------------------------------- */

.leader.is-climbing {
  animation: climb 1200ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes climb {
  0% {
    transform: translateX(-0.5rem);
    background: color-mix(in srgb, var(--status-good) 26%, var(--surface-2));
  }
  100% {
    transform: translateX(0);
  }
}

.leader__climb {
  color: var(--status-good);
  font-size: 0.62rem;
  font-weight: 700;
  margin-left: 0.2rem;
}

/* Motion is decoration here — every value it draws attention to is also
   present as text, so switching it all off loses nothing. */
@media (prefers-reduced-motion: reduce) {
  .sweep,
  .rain,
  .deltachip,
  .targethit {
    display: none !important;
  }
  .is-bumped,
  .leader.is-climbing {
    animation: none !important;
  }
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 1500px) {
  .grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "sites sites sites sites sites orders orders orders"
      "leaders leaders leaders hourly hourly hourly hourly hourly"
      "trend trend trend trend mix mix mix mix";
  }
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1000px) {
  body {
    overflow: auto;
  }
  .board {
    height: auto;
    min-height: 100dvh;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas:
      "sites"
      "leaders"
      "orders"
      "hourly"
      "trend"
      "mix";
  }
  .panel {
    min-height: 16rem;
  }
  .topbar {
    flex-wrap: wrap;
  }
  .topbar__progress {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
