:root {
  --page: #f4f3ef;
  --surface: #ffffff;
  --surface-muted: #f7f7f4;
  --surface-hover: #fbfbf9;
  --ink: #17201d;
  --muted: #66706c;
  --faint: #8a938e;
  --line: #dfe3df;
  --line-strong: #cbd1cc;
  --accent: #b9552e;
  --accent-soft: #f7e8e0;
  --good: #226b55;
  --good-soft: #e4f1ec;
  --warning: #8b5b19;
  --warning-soft: #f6eddc;
  --danger: #a43e2a;
  --danger-soft: #f7e5e0;
  --badge: #ecefec;
  --badge-ink: #4f5c57;
  --track-capacity: #eceee9;
  --track-area: rgba(34, 107, 85, 0.2);
  --track-full: #a43e2a;
  --track-full-area: rgba(164, 62, 42, 0.2);
  --topbar: rgba(244, 243, 239, 0.9);
  --topbar-line: rgba(203, 209, 204, 0.84);
  --skeleton-a: #f3f4f1;
  --skeleton-b: #fafaf8;
  --tip-bg: #17201d;
  --tip-ink: #ffffff;
  --focus: rgba(185, 85, 46, 0.24);
  --radius-panel: 12px;
  --radius-control: 8px;
  --event-card-date-size: 1.5rem;
  --event-card-primary-size: 1rem;
  --event-card-meta-size: 0.8rem;
  --event-card-supporting-size: 0.875rem;
  --event-card-badge-size: 0.75rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #111614;
    --surface: #171d1a;
    --surface-muted: #1c2320;
    --surface-hover: #1b221f;
    --ink: #e6ebe8;
    --muted: #9ba49f;
    --faint: #7c8781;
    --line: #26302b;
    --line-strong: #34403a;
    --accent: #e38a64;
    --accent-soft: #3a241a;
    --good: #74c8a7;
    --good-soft: #17302a;
    --warning: #e0b265;
    --warning-soft: #33291a;
    --danger: #ec8a74;
    --danger-soft: #3a211b;
    --badge: #222b27;
    --badge-ink: #b4bdb8;
    --track-capacity: #222b27;
    --track-area: rgba(116, 200, 167, 0.18);
    --track-full: #ec8a74;
    --track-full-area: rgba(236, 138, 116, 0.18);
    --topbar: rgba(17, 22, 20, 0.9);
    --topbar-line: rgba(52, 64, 58, 0.9);
    --skeleton-a: #171d1a;
    --skeleton-b: #1c2320;
    --tip-bg: #e6ebe8;
    --tip-ink: #111614;
    --focus: rgba(227, 138, 100, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page: #111614;
  --surface: #171d1a;
  --surface-muted: #1c2320;
  --surface-hover: #1b221f;
  --ink: #e6ebe8;
  --muted: #9ba49f;
  --faint: #7c8781;
  --line: #26302b;
  --line-strong: #34403a;
  --accent: #e38a64;
  --accent-soft: #3a241a;
  --good: #74c8a7;
  --good-soft: #17302a;
  --warning: #e0b265;
  --warning-soft: #33291a;
  --danger: #ec8a74;
  --danger-soft: #3a211b;
  --badge: #222b27;
  --badge-ink: #b4bdb8;
  --track-capacity: #222b27;
  --track-area: rgba(116, 200, 167, 0.18);
  --track-full: #ec8a74;
  --track-full-area: rgba(236, 138, 116, 0.18);
  --topbar: rgba(17, 22, 20, 0.9);
  --topbar-line: rgba(52, 64, 58, 0.9);
  --skeleton-a: #171d1a;
  --skeleton-b: #1c2320;
  --tip-bg: #e6ebe8;
  --tip-ink: #111614;
  --focus: rgba(227, 138, 100, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.info-tip:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px max(24px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid var(--topbar-line);
  background: var(--topbar);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand span {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
}

.brand strong {
  font-size: 1.05rem;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.theme-toggle,
.mark-seen,
.retry-load {
  flex: 0 0 auto;
  padding: 6px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle {
  min-width: 34px;
  font-size: 1rem;
  line-height: 1.2;
}

.theme-toggle:hover,
.mark-seen:hover {
  border-color: var(--accent);
}

.refresh-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.refresh-state.status-good {
  color: var(--good);
}

.refresh-state.status-warning {
  color: var(--warning);
}

.refresh-state.status-alert {
  color: var(--danger);
}

.refresh-state.status-neutral {
  color: var(--muted);
}

.dashboard-shell {
  width: min(1320px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(700px, 1.15fr);
  gap: 40px;
  align-items: end;
  margin-bottom: 18px;
}

.overview h1,
.section-heading h2,
.event-copy h3,
.empty-state h3,
.month-heading h3,
.production-card h4 {
  margin: 0;
  font-weight: 600;
}

.overview h1 {
  max-width: 18ch;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.overview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.overview-heading h1 {
  min-width: 0;
}

.overview-copy > p {
  max-width: 64ch;
  margin: 8px 0 0;
  color: var(--muted);
}

.overview-summary {
  min-width: 0;
}

.programme-count {
  flex-shrink: 0;
  margin: 0;
  padding: 6px 10px;
  border-radius: var(--radius-control);
  background: var(--good-soft);
  color: var(--good);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.summary-grid div {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 16px;
  border-left: 1px solid var(--line);
}

.summary-grid div:first-child {
  border-left: 0;
}

.summary-grid dt {
  flex: 1;
  color: var(--muted);
  font-size: 0.875rem;
}

.summary-grid dd {
  margin: 4px 0 0;
  font-size: 1.875rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.since-visit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 11px 14px;
  color: var(--good);
  border: 1px solid var(--good);
  border-radius: var(--radius-panel);
  background: var(--good-soft);
  font-size: 0.9rem;
}

.since-visit p {
  margin: 0;
}

.since-visit b {
  font-weight: 700;
}

.since-visit:not(.since-visit-quiet) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.since-visit:not(.since-visit-quiet) #since-visit-text {
  display: contents;
}

.since-visit-heading {
  grid-column: 1;
  grid-row: 1;
}

.since-visit:not(.since-visit-quiet) .mark-seen {
  grid-column: 2;
  grid-row: 1;
}

.since-visit-details {
  display: grid;
  grid-column: 1 / -1;
  justify-self: start;
  max-width: 100%;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
}

.visit-change {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4rem minmax(3ch, max-content);
  align-items: baseline;
  column-gap: 12px;
}

.visit-change-title {
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.visit-change-date {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.visit-change-delta {
  color: var(--good);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.visit-change-delta.is-negative {
  color: var(--danger);
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.68fr) minmax(0, 0.6fr) auto;
  gap: 14px;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.controls .status-select-field,
[hidden] {
  display: none !important;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  text-overflow: ellipsis;
}

.field input::placeholder {
  color: var(--faint);
}

.field input:hover,
.field select:hover {
  border-color: var(--faint);
}

.status-filter {
  align-self: end;
  display: inline-flex;
  justify-self: end;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-muted);
}

.status-filter button {
  min-height: 34px;
  padding: 6px 11px;
  color: var(--muted);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.status-filter button:hover {
  color: var(--ink);
}

.status-filter button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
}

.status-filter button span {
  margin-left: 4px;
  font-size: 0.78rem;
  opacity: 0.76;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-heading h2 {
  font-size: 1.12rem;
}

.section-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.generated-at {
  flex: 0 0 auto;
  text-align: right;
}

.generated-at strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Performance list ---------- */
.event-list {
  display: grid;
  gap: 18px;
}

.month-group {
  display: grid;
  gap: 8px;
}

.month-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.month-heading h3 {
  color: var(--ink);
  font-size: 1rem;
}

.month-rows {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.event-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 32px;
  align-items: start;
  padding: 18px 22px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: background-color 140ms ease;
}

.event-row:last-child {
  border-bottom: 0;
}

.event-row:hover {
  background: var(--surface-hover);
}

.event-row:hover .event-copy h3 {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.event-row:focus-visible {
  position: relative;
  z-index: 1;
}

.event-date {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  column-gap: 6px;
  font-variant-numeric: tabular-nums;
}

.date-day {
  font-size: var(--event-card-date-size);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}

.date-month {
  color: var(--muted);
  font-size: var(--event-card-meta-size);
}

.date-meta {
  grid-column: 1 / -1;
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--event-card-meta-size);
  white-space: nowrap;
}

.date-countdown {
  grid-column: 1 / -1;
  margin-top: 2px;
  color: var(--faint);
  font-size: var(--event-card-meta-size);
  white-space: nowrap;
}

.date-soon {
  color: var(--accent);
  font-weight: 600;
}

.event-identity {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.event-poster {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 80px;
  overflow: hidden;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-muted);
}

.event-poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-fallback {
  max-width: 42px;
  font-size: 0.66rem;
  line-height: 1.2;
  text-align: center;
}

.event-poster:not(.poster-missing) .poster-fallback {
  visibility: hidden;
}

.event-copy {
  min-width: 0;
}

.event-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.event-copy h3 {
  min-width: 0;
  font-size: var(--event-card-primary-size);
  line-height: 1.25;
}

.event-context,
.event-site,
.tracking-checked,
.inventory-note,
.inventory-progress-empty {
  margin: 3px 0 0;
  color: var(--muted);
}

.event-context,
.event-site {
  font-size: var(--event-card-supporting-size);
}

.tracking-checked {
  color: var(--faint);
  font-size: var(--event-card-meta-size);
}

.inventory-note,
.inventory-progress-empty {
  font-size: var(--event-card-meta-size);
}

.event-context {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 8px;
  color: var(--badge-ink);
  border-radius: 999px;
  background: var(--badge);
  font-size: var(--event-card-badge-size);
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.status-sold-out,
.status-badge.status-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-badge.status-muted {
  color: var(--warning);
  background: var(--warning-soft);
}

/* Tickets sold since the previous check: a solid chip so it stands out next to the name. */
.status-badge.sales-flash-positive {
  color: var(--surface);
  background: var(--good);
  font-weight: 800;
}

.status-badge.sales-flash-returned {
  color: var(--surface);
  background: var(--accent);
  font-weight: 800;
}

/* ---------- Sold line ---------- */
.inventory-block {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.fill-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.fill-pct {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.fill-pct small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
}

.fill-counts {
  margin: 0;
  color: var(--muted);
  font-size: var(--event-card-meta-size);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* The seats still to sell are the number acted on: the size of the counts beside them, but bold and dark. */
.free-count {
  color: var(--ink);
  font-weight: 600;
}

.sales-track {
  display: grid;
  gap: 2px;
}

.sales-track svg {
  display: block;
  width: 100%;
  height: auto;
}

.track-capacity {
  fill: var(--track-capacity);
}

.track-area {
  fill: var(--track-area);
}

.track-line,
.track-forecast {
  fill: none;
  stroke: var(--good);
  stroke-width: 1.6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.track-forecast {
  stroke-dasharray: 4 3;
}

.track-today {
  stroke: var(--ink);
  stroke-opacity: 0.22;
  vector-effect: non-scaling-stroke;
}

.track-now {
  fill: var(--good);
}

.sales-track-full .track-area {
  fill: var(--track-full-area);
}

.sales-track-full .track-line {
  stroke: var(--track-full);
}

.sales-track-full .track-now {
  fill: var(--track-full);
}

.track-caption {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  color: var(--faint);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.track-caption span:last-child {
  text-align: right;
}

.site-split {
  display: grid;
  gap: 4px;
  margin-top: 3px;
}

.site-split-bar {
  display: flex;
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--track-capacity);
}

.site-split-bar span {
  display: block;
  height: 100%;
}

.site-split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.site-split-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
}

/* ---------- Movement ---------- */
.tracking-block {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tracking-block > .status-badge,
.tracking-block > .stalled-tag {
  align-self: flex-start;
}

.move-cells {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

.move-cell {
  display: grid;
  gap: 1px;
  padding: 4px 10px;
  border-left: 1px solid var(--line);
}

.move-cell:first-child {
  border-left: 0;
}

.move-cell small {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.move-cell b {
  font-size: 0.95rem;
  font-weight: 800;
}

.move-positive {
  color: var(--good);
}

.move-returned,
.move-negative {
  color: var(--accent);
}

.move-quiet,
.move-unavailable {
  color: var(--faint);
}

.latest-change,
.forecast-line {
  color: var(--muted);
  font-size: var(--event-card-meta-size);
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.latest-change b {
  font-weight: 800;
}

.forecast-sellout {
  color: var(--good);
  font-weight: 600;
}

.stalled-tag {
  padding: 2px 8px;
  color: var(--warning);
  border-radius: 999px;
  background: var(--warning-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ---------- Explanations ---------- */
.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  color: var(--muted);
  border: 1px solid var(--faint);
  border-radius: 50%;
  font: italic 700 10px/1 Georgia, serif;
  letter-spacing: 0;
  vertical-align: 1px;
  cursor: help;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 20;
  width: min(260px, 70vw);
  padding: 9px 11px;
  color: var(--tip-ink);
  border-radius: var(--radius-control);
  background: var(--tip-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font: 400 12px/1.45 "Manrope", sans-serif;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.info-tip:hover::after,
.info-tip:focus::after {
  opacity: 1;
}

/* ---------- Production totals and legend ---------- */
/* ---------- Overview: daily sales and production totals ---------- */
.insights {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 22px;
  align-items: start;
  margin-top: 26px;
}

.insights > [hidden] {
  display: none;
}

.daily-sales {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.daily-sales-readout {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.daily-sales-readout b {
  color: var(--ink);
  font-weight: 600;
}

.daily-sales-chart {
  padding: 10px 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.day-cols {
  display: flex;
  gap: 2px;
}

.day-col {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  justify-items: center;
  border-radius: 4px;
  cursor: default;
}

.day-col:hover {
  background: var(--surface-muted);
}

.day-value {
  min-height: 1.1rem;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1rem;
}

.day-zone {
  display: flex;
  width: 100%;
  justify-content: center;
}

.day-up {
  align-items: flex-end;
  border-bottom: 1px solid var(--line-strong);
}

.day-zone i {
  display: block;
  width: min(22px, 72%);
}

.day-up i {
  border-radius: 4px 4px 0 0;
  background: var(--good);
}

.day-down i {
  border-radius: 0 0 4px 4px;
  background: var(--danger);
}

.day-label {
  margin-top: 4px;
  color: var(--faint);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.is-weekend .day-label {
  color: var(--muted);
  font-weight: 600;
}

.is-today .day-label {
  color: var(--ink);
  font-weight: 600;
}

.production-totals {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.pace-needed {
  display: block;
  color: var(--faint);
  font-size: var(--event-card-meta-size);
}

.site-sales {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.site-sales-rows {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.site-sales-row {
  display: grid;
  grid-template-columns: minmax(96px, 0.9fr) minmax(60px, 1fr) 44px;
  align-items: center;
  gap: 2px 10px;
  padding: 5px 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.site-sales-row + .site-sales-row {
  border-top: 1px solid var(--line);
}

.site-sales-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-sales-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--track-capacity);
}

.site-sales-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--good);
}

.site-sales-value {
  font-weight: 600;
  text-align: right;
}

.site-sales-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.74rem;
}

.finished-shows {
  display: grid;
  gap: 8px;
  margin-top: 26px;
}

.finished-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

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

.finished-table th,
.finished-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.finished-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.finished-table tbody tr:last-child td {
  border-bottom: 0;
}

.finished-table b {
  font-weight: 600;
}

.finished-linked-row {
  position: relative;
  cursor: pointer;
}

.finished-linked-row:hover,
.finished-linked-row:focus-within {
  background: var(--surface-hover);
}

.finished-detail-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.finished-detail-link:focus-visible {
  outline: none;
}

.finished-detail-link:focus-visible::after {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.finished-date {
  color: var(--muted);
  white-space: nowrap;
}

.finished-place {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.finished-table .finished-count {
  text-align: right;
  white-space: nowrap;
}

.finished-fill {
  min-width: 150px;
  white-space: nowrap;
}

.finished-fill .production-bar {
  display: inline-block;
  width: 84px;
  margin-right: 8px;
  vertical-align: middle;
}

.finished-fill .status-badge {
  margin-left: 8px;
}

.finished-shows .mark-seen {
  justify-self: start;
}

.production-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.production-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.production-card h4 {
  font-size: 0.92rem;
}

/* The total of every show, set apart from the shows it adds up. */
.production-card-total {
  background: var(--surface-muted);
}

.production-percent {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

.production-percent small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.production-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--track-capacity);
}

.production-bar span {
  display: block;
  height: 100%;
  background: var(--good);
}

.production-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 18px 0 0;
  padding: 12px 2px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  list-style: none;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 16px;
}

.legend-capacity {
  height: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--track-capacity);
}

.legend-line {
  border-top: 2px solid var(--good);
}

.legend-dash {
  border-top: 2px dashed var(--good);
}

.legend .status-badge {
  min-height: 0;
  padding: 1px 6px;
  font-size: 0.68rem;
}

/* ---------- States ---------- */
.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 40px 24px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
}

.empty-state h3 {
  font-size: 1.05rem;
}

.empty-state p {
  margin: 5px 0 0;
  color: var(--muted);
}

.error-state h3 {
  color: var(--danger);
}

.skeleton-row {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  animation: skeleton-shift 1.2s ease-in-out infinite;
}

@keyframes skeleton-shift {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

@media (max-width: 1200px) {
  .overview {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (max-width: 1120px) {
  .insights {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .event-row {
    grid-template-columns: 72px minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 0.95fr);
    gap: 20px;
    padding: 16px 18px;
  }

  .controls {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr) minmax(0, 0.7fr);
  }

  .status-filter {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 820px) {
  .dashboard-shell {
    width: min(100% - 28px, 720px);
    padding-top: 22px;
  }

  .month-rows {
    display: grid;
    gap: 12px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .event-row {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: var(--surface);
  }

  .event-row:last-child {
    border-bottom: 1px solid var(--line);
  }

  .inventory-block,
  .tracking-block {
    grid-column: 1 / -1;
  }

}

/* Phones: search on top, then status, site and sort as three dropdowns on one line. */
@media (max-width: 560px) {
  :root {
    --event-card-supporting-size: 0.9375rem;
  }

  .topbar {
    min-height: 56px;
    padding: 9px 14px;
  }

  .brand {
    display: grid;
    gap: 0;
    line-height: 1.1;
  }

  .brand span {
    font-size: 0.7rem;
  }

  .brand strong {
    font-size: 0.9rem;
  }

  .topbar-actions {
    gap: 8px;
  }

  .refresh-state {
    max-width: 44vw;
    font-size: 0.72rem;
    line-height: 1.25;
    text-align: right;
  }

  .theme-toggle {
    padding: 4px 8px;
  }

  .dashboard-shell {
    width: calc(100% - 20px);
    padding: 18px 0 30px;
  }

  .overview h1 {
    font-size: 1.65rem;
  }

  .overview-copy > p {
    font-size: 0.85rem;
  }

  .programme-count {
    max-width: 96px;
  }

  .summary-grid div {
    padding: 10px 8px;
  }

  .summary-grid dt {
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .summary-grid dd {
    font-size: 1.5rem;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .controls .field > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .controls .status-select-field {
    display: grid !important;
    order: 1;
  }

  .controls .field:has(#site-filter) {
    order: 2;
  }

  .controls .field:has(#sort-filter) {
    order: 3;
  }

  .field select {
    min-height: 40px;
    padding: 8px;
    font-size: 0.82rem;
    font-weight: 600;
  }

  .status-filter {
    display: none;
  }

  .section-heading {
    align-items: start;
  }

  .generated-at {
    display: none;
  }

  .event-row {
    grid-template-columns: 1fr;
    gap: 11px;
    min-height: 0;
    padding: 13px;
  }

  .event-date {
    grid-template-columns: auto auto 1fr;
    column-gap: 6px;
  }

  .date-day {
    font-size: 1.25rem;
  }

  .date-meta {
    grid-column: 3;
    justify-self: end;
    margin-top: 0;
  }

  .event-identity,
  .inventory-block,
  .tracking-block {
    grid-column: 1;
  }

  .event-identity {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .event-poster {
    width: 54px;
    height: 74px;
  }

  .event-context {
    white-space: normal;
  }

  .inventory-block {
    padding-top: 9px;
    border-top: 1px solid var(--line);
  }

  .tracking-block {
    align-items: stretch;
  }

  .tracking-block > .status-badge,
  .stalled-tag {
    align-self: flex-start;
  }

  .production-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finished-table thead {
    display: none;
  }

  .finished-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
  }

  .finished-table tbody tr:last-child {
    border-bottom: 0;
  }

  .finished-table td {
    padding: 0;
    border-bottom: 0;
  }

  .finished-table td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .finished-fill {
    min-width: 0;
    text-align: right;
  }

  .info-tip::after {
    left: auto;
    right: -8px;
    transform: none;
  }
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  border: 0 !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
}

@media (prefers-reduced-motion: reduce) {
  .event-row {
    transition: none;
  }

  .skeleton-row {
    animation: none;
  }
}

.retry-load {
  color: inherit;
  border-color: currentColor;
  background: transparent;
}

/* Keep search and filters available without a permanent toolbar. */
.event-section > .section-heading {
  align-items: center;
  gap: 10px;
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.filters-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 0.8125rem;
  white-space: nowrap;
  cursor: pointer;
}

.filters-toggle:hover,
.filters-toggle[aria-expanded="true"] {
  background: var(--surface-hover);
}

.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  color: var(--good);
  background: var(--good-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.filter-actions {
  grid-column: 1 / -1;
  order: 4;
}

@media (max-width: 820px) {
  .list-tools .generated-at {
    display: none;
  }
}

/* Keep the no-change recap to one short row; movement details keep their space. */
.since-visit.since-visit-quiet {
  flex-wrap: nowrap;
  gap: 8px;
  padding: 6px 10px;
  line-height: 1.35;
}

.since-visit-quiet p {
  white-space: nowrap;
}

.since-visit-quiet b {
  font-weight: 600;
}

.since-visit-quiet .mark-seen {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 8px;
}
