/* Palette taken from the Samply admin template (primary #0576b9). Light is the
   default; the dark override kicks in on [data-theme="dark"] (set before paint
   by an inline script, so there's no flash). */
:root {
  color-scheme: light;
  --brand: #0576b9;
  --brand-hover: #046aa6;
  --bg: #f3f3f9;
  --card: #ffffff;
  --border: #e7e9f1;
  --track: #e7e9f1;
  --text: #495057;
  --muted: #9599ad;
  --heading: #343a40;
  --prog-line: #0576b9;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f1420;
  --card: #161c2b;
  --border: #232c40;
  --track: #232c40;
  --text: #e6e9ef;
  --muted: #9aa4b8;
  --heading: #eef1f7;
  --prog-line: #4aa8e0;
}

/* Bootstrap form controls follow the theme in dark mode. */
:root[data-theme='dark'] .form-select,
:root[data-theme='dark'] .form-control {
  background-color: #0f1420;
  color: var(--text);
  border-color: var(--border);
}
:root[data-theme='dark'] .form-control::placeholder {
  color: var(--muted);
}
:root[data-theme='dark'] .alert-secondary {
  background-color: var(--card);
  color: var(--text);
  border-color: var(--border);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  /* Breathing room so the last row never sits flush against the viewport edge,
     and clearance for the floating back-to-top button. Applies to every page. */
  padding-bottom: 3rem;
}

.topbar {
  background: var(--brand);
  color: #fff;
  /* Slim: a low bar leaves more room on phones. */
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.brand-mark {
  flex: 0 0 auto;
}
.brand-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.tb-tools {
  gap: 0.4rem;
}
/* Connection + audience in one compact chip: the dot carries live/offline (it
   pulses when connected), the number is how many are watching. */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.5rem 0.14rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* Green = live (universal), a faint dot = offline. Overrides the white topbar dot
   inside the pill so the state reads at a glance without the old "EN VIVO" text. */
.live-pill .live-dot {
  width: 0.5rem;
  height: 0.5rem;
}
.live-pill .live-dot.on {
  background: #2ee6a6;
  transform-origin: center;
  animation: live-breathe 1.3s ease-in-out infinite;
}
/* Breathe (the dot grows/shrinks — visible on any screen) plus an expanding ring.
   Its own name: pulse-live already exists for the on-stage badge. */
@keyframes live-breathe {
  0% {
    transform: scale(0.85);
    box-shadow: 0 0 0 0 rgba(46, 230, 166, 0.9);
  }
  45% {
    transform: scale(1.35);
    box-shadow: 0 0 0 0.5rem rgba(46, 230, 166, 0);
  }
  100% {
    transform: scale(0.85);
    box-shadow: 0 0 0 0 rgba(46, 230, 166, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .live-pill .live-dot.on {
    animation: none;
  }
}

/* ---------------------------------------------------------------------------
   Navigation polish: a load/nav progress bar, cross-fade page transitions, and
   skeleton placeholders while the first socket snapshot is in flight.
   --------------------------------------------------------------------------- */

/* 1 · thin progress bar pinned to the top of the viewport. chrome.js drives it. */
#app-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  /* Light cyan→white so it reads over the blue top bar it sits on (a brand-blue
     bar would vanish against it). */
  background: linear-gradient(90deg, #6fd9ff, #ffffff);
  box-shadow:
    0 0 8px rgba(255, 255, 255, 0.8),
    0 0 4px #6fd9ff;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition:
    width 0.3s ease,
    opacity 0.3s ease;
}

/* 2 · cross-document view transitions. The chrome (top bar + nav) is identical
   across pages, so a full-page cross-fade shows change only where it differs —
   the content. Chromium honours this; other browsers navigate normally. */
@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.24s;
}

/* 3 · skeleton shimmer for list rows before data arrives. */
.sk {
  border-radius: 5px;
  background: linear-gradient(100deg, var(--track) 30%, var(--card) 50%, var(--track) 70%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.3s linear infinite;
}
.sk-circle {
  border-radius: 50%;
}
@keyframes sk-shimmer {
  0% {
    background-position: 150% 0;
  }
  100% {
    background-position: -50% 0;
  }
}
.sk-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.sk-row .sk-info {
  flex: 1 1 auto;
}
/* Event-name placeholder in the page title. Display lives here, not inline, so
   x-show (which toggles inline display) doesn't clobber inline-block. */
.sk-title {
  display: inline-block;
  width: 12rem;
  max-width: 60vw;
  height: 1.15rem;
  border-radius: 5px;
  vertical-align: -2px;
}

@media (prefers-reduced-motion: reduce) {
  #app-progress {
    transition: opacity 0.3s ease;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
  .sk {
    animation: none;
  }
}

/* Empty state — a section icon, clear copy, and a live/offline indicator, so an
   empty board reads as ready-and-waiting rather than broken. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.6rem 1.5rem;
  gap: 0.35rem;
}
.empty-badge {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.25rem;
  display: grid;
  place-items: center;
  margin-bottom: 0.9rem;
  color: var(--brand);
  background: rgba(5, 118, 185, 0.08);
}
:root[data-theme='dark'] .empty-badge {
  color: #6cc0f0;
  background: rgba(74, 168, 224, 0.14);
}
.empty-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid currentColor;
  opacity: 0.2;
}
.empty-badge svg {
  width: 2.1rem;
  height: 2.1rem;
}
.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--heading);
}
.empty-sub {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 34ch;
}
.empty-live {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #12905f;
  background: rgba(23, 185, 128, 0.12);
}
:root[data-theme='dark'] .empty-live {
  color: #2ee6a6;
  background: rgba(46, 230, 166, 0.14);
}
.empty-live.off {
  color: var(--muted);
  background: rgba(120, 132, 158, 0.14);
}
.empty-live .live-dot {
  width: 8px;
  height: 8px;
}
.empty-live .live-dot.on {
  background: #2ee6a6;
  animation: live-breathe 1.3s ease-in-out infinite;
}
.empty-live.off .live-dot {
  background: var(--muted);
}

.card-cat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 0.1rem 0.35rem rgba(18, 38, 63, 0.06);
}

.card-cat .cat-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
}

/* Connection indicator, sitting on the blue topbar. */
.live-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
  background: rgba(255, 255, 255, 0.45);
}
.live-dot.on {
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  }
  70% {
    box-shadow: 0 0 0 0.5rem rgba(255, 255, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

/* Three readable states at a glance:
   activo      = on stage now (highlighted)
   finalizado  = already judged (recedes)
   everything else = still to come (normal) */
/* Layout lives here rather than in Bootstrap utilities on the element, so the
   phone breakpoint below can switch it to grid without fighting !important. */
.turno-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
}
.turno-info {
  flex: 1 1 auto;
}
/* Roomier rows (programa), where each row is a whole competition. */
.turno-row-lg {
  padding: 0.5rem;
}
/* Competidores "Todos": a third, quieter line under the name/origin carrying the
   category, since the flat list has no per-category card header to sit under. */
.turno-cat {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Competidores "Directorio": a competitor card that expands to list every
   category (routine) they compete in — status, date, time and turn each. */
.ncat-chip {
  flex: 0 0 auto;
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--brand);
  background: rgba(5, 118, 185, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
}
:root[data-theme='dark'] .ncat-chip {
  color: #6cc0f0;
  background: rgba(74, 168, 224, 0.12);
}
/* One connected panel; each competitor is an accordion item with a full-width,
   clickable header and a collapsible body. Everyone has at least one routine, so
   every item is meaningfully expandable. */
.acc {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  overflow: hidden;
  background: var(--card);
}
.acc-item + .acc-item {
  border-top: 1px solid var(--border);
}
.acc-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: transparent;
  border: 0;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.acc-head:hover {
  background: rgba(5, 118, 185, 0.05);
}
:root[data-theme='dark'] .acc-head:hover {
  background: rgba(74, 168, 224, 0.07);
}
.acc-item.open > .acc-head {
  background: rgba(5, 118, 185, 0.06);
}
:root[data-theme='dark'] .acc-item.open > .acc-head {
  background: rgba(74, 168, 224, 0.09);
}
.acc-head > .avatar {
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
}
.acc-titulo {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.acc-caret {
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.acc-item.open > .acc-head .acc-caret {
  transform: rotate(180deg);
}
/* Body uses the full width of the item (no avatar-width indent — that read as an
   empty column) with breathing room top and bottom so it isn't cramped. */
.acc-body {
  padding: 0.6rem 0.85rem 0.75rem;
}
/* Expanded list of this competitor's routines (each a shared competitor row),
   hung off a left accent rule. */
.dir-entradas {
  padding-left: 0.85rem;
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Phones: one routine per row is still too much for a single line — the name
   and academy end up as ellipses. Stack it instead: order, time and status on
   top, then the photo with the full name and academy, nothing truncated. */
@media (max-width: 575.98px) {
  .turno-stack {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
      'num hora hora badge'
      'img info info info';
    column-gap: 0.5rem;
    row-gap: 0.35rem;
    align-items: center;
  }
  /* The leading chip is the order number in minuto and the position in
     resultados; the trailing one is the status badge or the score. */
  .turno-stack > .turno-num,
  .turno-stack > .pos-chip {
    grid-area: num;
  }
  .turno-stack > .hora-chip {
    grid-area: hora;
    justify-self: start;
    width: auto;
  }
  .turno-stack > .avatar {
    grid-area: img;
    align-self: start;
  }
  /* Rows without a photo (programa) give that column back to the text. */
  .turno-stack.sin-foto {
    grid-template-areas:
      'num hora hora badge'
      'info info info info';
  }
  .turno-stack > .turno-info {
    grid-area: info;
  }
  .turno-stack > .badge-estatus,
  .turno-stack > .score-chip {
    grid-area: badge;
    justify-self: end;
  }
  /* The whole point of stacking: let the lines wrap. */
  .turno-stack .turno-nombre,
  .turno-stack .turno-sub,
  .turno-stack .turno-cat {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  /* Tables become cards: the header row disappears and every cell turns into a
     "label: value" line, so a seven-column table reads without the horizontal
     scrolling that made it useless on a phone. Labels come from data-label. */
  .tabla-apilable thead {
    display: none;
  }
  .tabla-apilable > tbody > tr {
    display: block;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border);
  }
  /* Label column + value column. Pushing the value to the right edge instead
     (space-between) reads fine for "2" but tears a long category name in half,
     so both columns start at a fixed left edge and the value wraps normally. */
  .tabla-apilable > tbody > tr > td {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    justify-items: start;
    align-items: baseline;
    gap: 0 0.75rem;
    width: 100%;
    padding: 0.1rem 0;
    border: 0;
    box-shadow: none;
    text-align: left !important;
  }
  .tabla-apilable > tbody > tr > td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  /* A cell whose label would be its only content is noise. */
  .tabla-apilable > tbody > tr > td:empty {
    display: none;
  }

  /* Competidores has too many columns for the label/value stack — seven labelled
     lines per competitor. It becomes a compact card instead, laid out like a
     minuto row: turno, time and status on top, then who, what and where. Order
     comes from data-rol, not column position, so the three tabs (whose column
     orders differ) all get the same card, and flex-wrap fills in only the
     fields a given tab actually has. */
  .tabla-tarjeta thead {
    display: none;
  }
  .tabla-tarjeta > tbody > tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem 0.5rem;
    padding: 0.6rem 0.4rem;
    border-bottom: 1px solid var(--border);
  }
  .tabla-tarjeta > tbody > tr > td {
    width: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    text-align: left !important;
  }
  /* The card speaks for itself; the labels would only add noise. */
  .tabla-tarjeta > tbody > tr > td::before {
    content: none;
  }
  .tabla-tarjeta > tbody > tr > td:empty {
    display: none;
  }
  /* Line 1 */
  .tabla-tarjeta td[data-rol='turno'] {
    order: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .tabla-tarjeta td[data-rol='hora'] {
    order: 2;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
  }
  .tabla-tarjeta td[data-rol='estado'],
  .tabla-tarjeta td[data-rol='ncat'] {
    order: 3;
    margin-left: auto;
  }
  /* The one field that means nothing on its own: a bare "3" next to a name
     could be anything, so this count keeps its label. */
  .tabla-tarjeta td[data-rol='ncat'] {
    color: var(--muted);
    font-size: 0.85rem;
  }
  .tabla-tarjeta td[data-rol='ncat']::before {
    content: attr(data-label);
    margin-right: 0.35rem;
    font-size: 0.72rem;
    text-transform: uppercase;
  }
  /* Line 2: who. Line 3: what. Both take the full width so they wrap freely. */
  .tabla-tarjeta td[data-rol='competidor'] {
    order: 4;
    flex: 1 1 100%;
  }
  .tabla-tarjeta td[data-rol='categoria'] {
    order: 5;
    flex: 1 1 100%;
    color: var(--muted);
    font-size: 0.85rem;
  }
  /* Line 4: academy and date share it. */
  .tabla-tarjeta td[data-rol='academia'] {
    order: 6;
    color: var(--muted);
    font-size: 0.85rem;
  }
  .tabla-tarjeta td[data-rol='fecha'] {
    order: 7;
    color: var(--muted);
    font-size: 0.85rem;
  }
  .tabla-tarjeta td[data-rol='academia'] + td[data-rol='fecha']::before {
    content: '·';
    margin-right: 0.35rem;
  }
  /* No academy, no dangling separator. */
  .tabla-tarjeta td[data-rol='academia']:empty + td[data-rol='fecha']::before {
    content: none;
  }
  .tabla-tarjeta > tbody > tr.fila-activa {
    background: rgba(5, 118, 185, 0.08);
    border-radius: 0.5rem;
  }

  /* The medal table would be six near-empty lines under the generic rule. It
     reads better as two: position and academy, then the four counts inline. */
  .medal-table thead {
    display: none;
  }
  .medal-table > tbody > tr {
    display: grid;
    grid-template-columns: auto repeat(3, 1fr);
    align-items: baseline;
    gap: 0.2rem 0.6rem;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid var(--border);
  }
  /* Line 1: position + academy. Line 2: the four counts, evenly placed. */
  .medal-table > tbody > tr > td:nth-child(1) {
    grid-area: 1 / 1;
  }
  .medal-table > tbody > tr > td:nth-child(2) {
    grid-area: 1 / 2 / 2 / -1;
  }
  .medal-table > tbody > tr > td:nth-child(n + 3) {
    grid-row: 2;
  }
  .medal-table > tbody > tr > td {
    width: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
    text-align: left !important;
  }
  .medal-table > tbody > tr > td:nth-child(n + 3)::before {
    content: attr(data-label);
    margin-right: 0.3rem;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
  }
}

.turno-row.activo {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: rgba(5, 118, 185, 0.06);
  border-radius: 0.5rem;
}

.turno-row.finalizado {
  background: rgba(120, 132, 158, 0.1);
  border-radius: 0.5rem;
}
/* Dim the identity, not the status badge — the badge must stay legible. */
.turno-row.finalizado .avatar {
  filter: grayscale(1);
  opacity: 0.6;
}
.turno-row.finalizado .min-w-0 {
  opacity: 0.7;
}
/* A finished routine that is somehow also active keeps the highlight. */
.turno-row.activo.finalizado {
  background: rgba(5, 118, 185, 0.06);
}

.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}
/* Initials fallback used in place of the competitor photo. Inherits the .avatar
   size (and any context override) and just fills it with the initials. */
.avatar-ini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: rgba(5, 118, 185, 0.1);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
:root[data-theme='dark'] .avatar-ini {
  background: rgba(74, 168, 224, 0.16);
  color: #6cc0f0;
}

/* Order number as a filled circle, following the template's avatar-title
   pattern (solid primary, white text) instead of a bare "#3". */
.turno-num {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
/* On stage / judged follow the row's state so the circle never contradicts it. */
.turno-row.activo .turno-num {
  background: #12905f;
}
.turno-row.finalizado .turno-num {
  background: rgba(120, 132, 158, 0.45);
}

.hora-chip {
  width: 3rem;
  flex: 0 0 auto;
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Start–end range (programa): one line, or the rows end up different heights. */
.hora-chip.rango {
  width: 5rem;
  white-space: nowrap;
  font-size: 0.75rem;
}
/* Phones keep only the start time — the category name needs that width more. */
@media (max-width: 575.98px) {
  .hora-chip.rango {
    width: 2.75rem;
  }
  .hora-fin {
    display: none;
  }
}

/* Resultados: position + score chips. */
.pos-chip {
  width: 2rem;
  flex: 0 0 auto;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}
.score-chip {
  flex: 0 0 auto;
  min-width: 3.5rem;
  text-align: right;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
:root[data-theme='dark'] .score-chip {
  color: #4aa8e0;
}

/* "Ver detalle" badge (soft-info style from the template) — links to the
   external score summary. */
.badge-detalle {
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(5, 118, 185, 0.12);
  border: 1px solid rgba(5, 118, 185, 0.25);
}
.badge-detalle:hover {
  background: rgba(5, 118, 185, 0.2);
}
/* «Se decide por posiciones». Va en ámbar y no en el azul de la marca porque no es
   una acción como «Ver detalle» que está a su lado: es la razón por la que esta
   categoría no trae ninguna cifra. Sin cursor ni hover, que no invite a hacerle
   clic. */
.badge-posiciones {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: #8a5a00;
  background: rgba(214, 158, 46, 0.16);
  border: 1px solid rgba(214, 158, 46, 0.35);
}
/* En oscuro el ámbar quemado no se lee: sube a la variante clara del mismo tono. */
:root[data-theme='dark'] .badge-posiciones {
  color: #ffca6b;
  background: rgba(214, 158, 46, 0.18);
  border-color: rgba(255, 202, 107, 0.35);
}

/* Programa schedule table — theme-aware (Bootstrap table vars). */
.prog-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  color: var(--text);
}
.prog-table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}
.prog-table td,
.prog-table th {
  border-color: var(--border);
}
.prog-table .hora-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.prog-table .no-cell {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}
/* Per-competition advance inside a programa row: a short track that reads at a
   glance without costing a column. Hidden on narrow screens, where the row has
   to give its width to the category name. */
.prog-mini {
  flex: 0 0 auto;
  width: 3.5rem;
  height: 4px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.prog-mini-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--prog-line);
}
@media (max-width: 575.98px) {
  .prog-mini {
    display: none;
  }
}

/* Currently-performing row in flat tables (minuto v3). */
.prog-table tr.fila-activa td {
  background: rgba(5, 118, 185, 0.08);
  font-weight: 600;
}
:root[data-theme='dark'] .prog-table tr.fila-activa td {
  background: rgba(74, 168, 224, 0.12);
}
/* Already judged: recedes so pending rows read as pending. */
.prog-table tr.fila-finalizada td {
  background: rgba(120, 132, 158, 0.09);
  color: var(--muted);
}
.prog-table tr.fila-finalizada .badge-estatus {
  opacity: 1;
}

/* Landing page: event cards. */
.group-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
}
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}
.event-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 0.1rem 0.35rem rgba(18, 38, 63, 0.06);
  transition:
    transform 0.12s ease,
    border-color 0.12s ease;
}
.event-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
}
.event-poster {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--track);
}
/* `cover` so artwork fills the tile edge to edge. Wide logos get cropped at the
   sides — accepted trade-off for a solid grid with no letterboxing. */
.event-poster img {
  position: relative; /* paints over .poster-fallback */
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--track);
  display: block;
}
/* No poster (or a broken one): a neutral tile with the event initial. */
.event-poster.sin-poster img {
  display: none;
}
.poster-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.75rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #0a4d78);
}
.event-live {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.event-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.event-name {
  font-weight: 600;
  line-height: 1.25;
}
.event-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-variant-numeric: tabular-nums;
}

/* Stats strip (competidores). */
.stats-row {
  display: flex;
  flex-wrap: wrap;
}
.stats-row .stat {
  flex: 1 1 33%;
  min-width: 120px;
  text-align: center;
  padding: 0.25rem 0.5rem;
  border-right: 1px solid var(--border);
}
.stats-row .stat:last-child {
  border-right: none;
}
.stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
:root[data-theme='dark'] .stat-num {
  color: #6cc0f0;
}
.stat-lbl {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Pager. */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}
.pg {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 0.35rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
}
.pg:disabled {
  opacity: 0.45;
  cursor: default;
}
.pg.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

@media print {
  .topbar,
  .nav-bar,
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card-cat {
    border: none;
    box-shadow: none;
  }
}

/* Rhythm tabs (medallero). */
.ritmo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.ritmo-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
}
.ritmo-tab:hover {
  border-color: var(--brand);
}
.ritmo-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* Medal table. */
.medal-table .medal-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
/* Column-header medal coins, doubled from the base .medal-ico so the gold/silver/
   bronze columns read clearly at a glance. Scoped to the header, not the podium. */
.medal-table thead th .medal-ico {
  width: 2.7rem;
  height: 2.7rem;
}
.medal-table tr.top-medal td {
  background: rgba(5, 118, 185, 0.05);
}
.medal-table tr.top-medal .no-cell {
  color: var(--brand);
}
:root[data-theme='dark'] .medal-table tr.top-medal td {
  background: rgba(74, 168, 224, 0.08);
}
:root[data-theme='dark'] .medal-table tr.top-medal .no-cell {
  color: #6cc0f0;
}
:root[data-theme='dark'] .badge-detalle {
  color: #6cc0f0;
  background: rgba(74, 168, 224, 0.16);
  border-color: rgba(74, 168, 224, 0.3);
}

/* Podium (top 3) — gold / silver / bronze, arranged 2-1-3 on wide screens. */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
}
.podium-card {
  flex: 1 1 30%;
  min-width: 150px;
  max-width: 230px;
  text-align: center;
  padding: 1rem 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-top-width: 4px;
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: 0 0.2rem 0.7rem rgba(18, 38, 63, 0.1);
}
.medal-ico {
  width: 1.35rem;
  height: 1.35rem;
  vertical-align: middle;
}
.medal-ico-lg {
  display: block;
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
}
.podium-card.p1 .medal-ico-lg {
  width: 2.4rem;
  height: 2.4rem;
}
.podium-avatar {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  object-fit: cover;
  margin: 0.4rem auto 0.3rem;
  border: 3px solid var(--border);
  background: var(--border);
}
.podium-pos {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.podium-name {
  font-weight: 700;
  margin-top: 0.15rem;
}
.podium-acad {
  font-size: 0.78rem;
  color: var(--muted);
}
.podium-score {
  margin-top: 0.4rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--brand);
}
:root[data-theme='dark'] .podium-score {
  color: #4aa8e0;
}

.podium-card.p1 {
  border-top-color: #f5c518;
}
.podium-card.p2 {
  border-top-color: #b7c0cd;
}
.podium-card.p3 {
  border-top-color: #cd8b45;
}
.podium-card.p1 .podium-avatar {
  border-color: #f5c518;
  width: 5.5rem;
  height: 5.5rem;
}
.podium-card.p2 .podium-avatar {
  border-color: #b7c0cd;
}
.podium-card.p3 .podium-avatar {
  border-color: #cd8b45;
}

@media (min-width: 576px) {
  .podium-card.p1 {
    order: 2;
    transform: translateY(-0.7rem);
  }
  .podium-card.p2 {
    order: 1;
  }
  .podium-card.p3 {
    order: 3;
  }
}
@media (max-width: 575.98px) {
  .podium-card {
    flex-basis: 100%;
    max-width: none;
  }
}

/* National flag standing in for the competitor photo on the medal podium. The
   circle crop matches the podium-avatar so academies read like contenders, and
   the per-rank gold/silver/bronze ring is inherited from .podium-card.pN. */
.bandera-avatar {
  object-fit: cover;
}
.podium-avatar.sin-bandera {
  background: var(--track);
}
/* Gold / silver / bronze tally under the academy name. */
.podium-medallas {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 0.5rem;
}
.podium-medallas .pm {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--text);
}
.podium-medallas .medal-ico {
  width: 1rem;
  height: 1rem;
}
.podium-score {
  margin-top: 0.55rem;
  line-height: 1;
}
.podium-score-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* Small round flag in the ranked table (rows 4+), same circle language as the
   podium so the two halves of the page feel like one board. */
.acad-cell {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.medal-flag {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 0.55rem;
  border: 1px solid var(--border);
  background: var(--border);
}
.medal-flag.sin-bandera {
  display: inline-block;
  background: var(--track);
}

/* Status badges. Colour carries the meaning — on stage / done / pending — so the
   routine that is performing is obvious without reading. Green here is a status
   colour ("on air"), not brand: the chrome stays template blue. Soft fills keep
   them legible in both themes. Icons come from CSS so every view inherits them. */
.badge-estatus {
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-estatus::before {
  margin-right: 0.25rem;
}
/* Icon-only variant (programa): the colour and glyph carry the status, and the
   width they save goes to the category name. The label stays in the DOM for
   screen readers and as a tooltip. */
.badge-icono {
  width: 1.6rem;
  padding: 0.25rem 0;
  text-align: center;
}
.badge-icono::before {
  margin-right: 0;
}
/* Same idea, but only where the screen is too narrow to spend ~90px on a word
   (minuto): the label collapses to the icon and stays readable to screen
   readers and as a tooltip, instead of squeezing the routine name. */
@media (max-width: 575.98px) {
  .badge-icono-sm {
    width: 1.6rem;
    padding: 0.25rem 0;
    text-align: center;
  }
  .badge-icono-sm::before {
    margin-right: 0;
  }
  .badge-icono-sm .badge-txt {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* On stage now (ACTIVO / PRESENTANDO). */
.badge-activo {
  background: rgba(25, 160, 100, 0.16);
  border-color: rgba(25, 160, 100, 0.4);
  color: #12905f;
}
/* Same expanding ring as the connection dot, so the routine on stage reads as
   "live" at a glance. Motion is dropped for users who ask for reduced motion. */
.badge-activo::before {
  content: '▶';
  display: inline-block;
  border-radius: 50%;
  animation: pulse-live 1.6s infinite;
}
@keyframes pulse-live {
  0% {
    box-shadow: 0 0 0 0 rgba(25, 160, 100, 0.55);
  }
  70% {
    box-shadow: 0 0 0 0.45rem rgba(25, 160, 100, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(25, 160, 100, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .badge-activo::before,
  .live-dot.on {
    animation: none;
  }
}
:root[data-theme='dark'] .badge-activo {
  color: #35c98a;
}

/* Judged. */
.badge-fin {
  background: rgba(120, 132, 158, 0.16);
  border-color: rgba(120, 132, 158, 0.32);
  color: #5b6a86;
}
.badge-fin::before {
  content: '✓';
}
:root[data-theme='dark'] .badge-fin {
  color: #9aa8c2;
}

/* Still to come (EN ESPERA / PREPARADO / SORTEADO / anything new). */
.badge-espera {
  background: rgba(214, 145, 20, 0.16);
  border-color: rgba(214, 145, 20, 0.36);
  color: #a86c05;
}
.badge-espera::before {
  content: '⏱';
}
:root[data-theme='dark'] .badge-espera {
  color: #e0a53c;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  border-radius: 0.3rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}
.icon-btn svg {
  display: block;
}

/* Navigation bar under the top bar. Scrolls horizontally on small screens so a
   day with many links never wraps into a saturated block. */
/* Scroll-tab nav with an affordance: a fade + chevron on the right edge shown
   only while there is more to scroll to, so the off-screen tabs aren't a
   surprise. chrome.js toggles has-overflow / at-end. */
.nav-scroll {
  position: relative;
}
.nav-scroll::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 1px;
  width: 42px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: linear-gradient(to right, transparent, var(--card));
}
.nav-cue {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-55%);
  color: var(--brand);
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
:root[data-theme='dark'] .nav-cue {
  color: #6cc0f0;
}
.nav-scroll.has-overflow:not(.at-end)::after,
.nav-scroll.has-overflow:not(.at-end) .nav-cue {
  opacity: 1;
}
.nav-bar {
  display: flex;
  gap: 0.1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-bar::-webkit-scrollbar {
  display: none;
}
.nav-link-x {
  padding: 0.6rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.nav-link-x:hover {
  color: var(--text);
}
.nav-link-x.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}
:root[data-theme='dark'] .nav-link-x.active {
  color: #6cc0f0;
  border-bottom-color: #6cc0f0;
}

.lang-switch {
  display: inline-flex;
  gap: 0.15rem;
}
.lang-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
  border-radius: 0.3rem;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
}
.lang-btn.active {
  background: #fff;
  color: var(--brand);
  font-weight: 700;
}

.theme-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  border-radius: 0.3rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Progress bars in template blue. */
.progress {
  background-color: var(--track);
  border-radius: 999px;
}
.progress-bar {
  background-color: var(--brand);
}
.progress-dia {
  height: 0.6rem;
}
.progress-cat {
  height: 0.35rem;
}

.btn-top {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0.4rem 1rem rgba(18, 38, 63, 0.25);
  cursor: pointer;
  z-index: 1030;
}
.btn-top:hover {
  background: var(--brand-hover);
}

@media (max-width: 575.98px) {
  .desktop-only {
    display: none !important;
  }
}
@media (min-width: 576px) {
  .mobile-only {
    display: none !important;
  }
}

/* --- Minuto v3: the running order, competitor by competitor -------------- */
/* "En escena": the one routine dancing right now, given the room it deserves. */
.escena-hero {
  border-color: var(--brand);
}
.escena-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.escena-head .empty-live {
  color: #12905f;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.escena-head .live-dot {
  background: rgba(18, 144, 95, 0.35);
}
.escena-head .live-dot.on {
  background: #12905f;
  animation: live-breathe 1.3s ease-in-out infinite;
}
.escena-fila {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.escena-avatar {
  width: 3.25rem;
  height: 3.25rem;
  font-size: 1rem;
}
.escena-nombre {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.2;
}
.escena-cat {
  font-size: 0.85rem;
  color: var(--text);
}
.escena-sub {
  font-size: 0.78rem;
  color: var(--muted);
}
