:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dde1e8;
  --text: #1e2330;
  --text-muted: #6b7280;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --danger: #dc2626;
  --radius: 8px;
  --mono: "SF Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  background: #1c1917;
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}

.badge-ts {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  color: white;
}

.badge-ts.conectado { background: #ea580c; }
.badge-ts.desconectado { background: #a32d2d; }
.badge-ts.inactivo { background: rgba(255,255,255,0.1); color: #cfcfc8; }

.topbar-selectores select {
  margin-left: 8px;
}

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.activo {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

main {
  padding: 20px 24px 60px;
  max-width: 1200px;
  margin: 0 auto;
}

/* La pestaña de participantes ocupa todo el ancho de la ventana,
   rompiendo el max-width y el padding del main */
#tab-participantes.activo {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 123px;   /* topbar ~74px + barra de tabs ~49px */
  left: 0;
  right: 0;
  bottom: 40px; /* altura exacta del pie — la tabla NO se mete debajo */
  overflow: hidden;
  z-index: 1;
}

.tab-panel { display: none; }
.tab-panel.activo { display: block; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.panel h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.form-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-wrap { row-gap: 8px; }

input, select, button {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

input { flex: 1; min-width: 110px; }

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
}

button:hover { background: var(--accent-dark); }

button.secundario {
  background: var(--surface);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

button.peligro {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 4px 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover { background: #faf9f6; }

td.mono { font-family: var(--mono); }

.filtros {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.acciones {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  background: #eef0ea;
  color: var(--accent-dark);
}

.badge.inactivo {
  background: #f1ece4;
  color: var(--text-muted);
}

.badge.cronometro {
  background: var(--accent);
  color: white;
  font-family: var(--mono);
  margin-left: 6px;
}

.vacio {
  color: var(--text-muted);
  font-style: italic;
  padding: 12px 0;
}

.ayuda {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.5;
}

.ayuda code {
  background: #f1ece4;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.resultado-import {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.resultado-import.ok { background: #fff7ed; color: var(--accent-dark); }
.resultado-import.con-errores { background: #fbeeee; color: var(--danger); }

.columnas-detalles {
  position: relative;
}

.columnas-detalles summary {
  cursor: pointer;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  list-style: none;
}

.columnas-detalles summary::-webkit-details-marker { display: none; }

.columnas-panel {
  position: absolute;
  top: 36px;
  right: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.columnas-panel label {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}

select

.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}

.stat-card .valor {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-dark);
}

.stat-card .etiqueta {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.subtitulo {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 8px;
}

.paginacion {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ===================== DASHBOARD ===================== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
}

.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.widget-wide { grid-column: 1 / -1; }

.widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.widget-header h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}

.widget-icon { font-size: 16px; }

.cronometros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.crono-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--bg);
}

.crono-card.lanzado { border-color: var(--accent); background: #fff7ed; }
.crono-card.pausado { border-color: var(--border); }

.crono-nombre {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.crono-tiempo {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--accent-dark);
  letter-spacing: 0.04em;
  margin: 6px 0 2px;
}

.crono-hora {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.estado-barra {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.estado-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.estado-nombre {
  font-size: 13px;
  min-width: 100px;
}

.estado-barra-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.estado-barra-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.fill-corriendo  { background: var(--accent); }
.fill-finalizado { background: #ea580c; }

.fill-descalificado { background: var(--danger); }

.estado-num {
  font-size: 13px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
  color: var(--text-primary);
}

.split-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.split-fila:last-child { border-bottom: none; }

.split-info { display: flex; flex-direction: column; }
.split-nombre { font-size: 13px; font-weight: 500; }
.split-ultima { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

.split-conteo {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-dark);
  min-width: 48px;
  text-align: right;
}

.split-tipo-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin-left: 4px;
}

.ts-estado-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.ts-estado-dot.online  { background: #ea580c; box-shadow: 0 0 0 3px #fed7aa; }
.ts-estado-dot.offline { background: var(--danger); }
.ts-estado-dot.inactivo { background: #aaa; }

.ts-info { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.ts-fila { display: flex; justify-content: space-between; }
.ts-label { color: var(--text-muted); }
.ts-val { font-family: var(--mono); font-weight: 500; }

.flujo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.flujo-punto {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}

.flujo-punto.activo { border-color: var(--accent); background: #fff7ed; }

.flujo-num {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-dark);
}

.flujo-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.evento-selector-panel {
  background: #fff7ed;
  border-color: var(--accent);
}

.evento-selector-select {
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px;
  border-color: var(--accent);
}

/* ---- Layout pantalla participantes ---- */
.tab-participantes-full {
  padding: 0 !important;
  height: 100%;
  /* NO poner display aquí — lo maneja .tab-panel { display:none } y #tab-participantes.activo */
}

.participantes-screen {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;  /* clave para que flex no desborde el contenedor padre */
  overflow: hidden;
}

/* Barra vertical de iconos a la izquierda */
.iconbar-vertical {
  width: 64px;
  min-width: 64px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  z-index: 10;
  overflow: hidden;
}

/* Wrapper del panel deslizante (posición absoluta sobre la tabla) */
.aside-wrapper {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}

.aside-icon-btn {
  background: none;
  border: none;
  width: 56px;
  height: 48px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  padding: 4px 2px;
  gap: 2px;
  transition: background 0.15s, color 0.15s;
}

.icon-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1;
}

.aside-icon-btn:hover,
.aside-icon-btn.activo {
  background: var(--bg);
  color: var(--accent-dark);
}

.aside-icon-btn.activo {
  background: #fff7ed;
  color: var(--accent);
}

.form-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.form-vertical input,
.form-vertical select,
.form-vertical textarea {
  flex: none;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.campo-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}
/* Rejilla de 2 columnas para formularios de modal */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid-2 input,
.form-grid-2 select {
  width: 100%;
  box-sizing: border-box;
  flex: none;
  min-width: 0;
}
.check-inline {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 12px 0;
  cursor: pointer;
}
.check-inline input {
  width: auto;
  flex: none;
  min-width: 0;
}
/* Tabla de usuarios */
.tabla-usuarios { width: 100%; border-collapse: collapse; }
.tabla-usuarios th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border, #e7e5e4);
  padding: 7px 8px;
  white-space: nowrap;
}
.tabla-usuarios td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border, #e7e5e4);
  font-size: 13px;
  vertical-align: middle;
}
.tabla-usuarios input.email-edit {
  width: 100%;
  min-width: 0;
  flex: none;
  font-size: 12px;
  padding: 5px 7px;
  box-sizing: border-box;
}
.tabla-usuarios .acciones-cel { white-space: nowrap; text-align: right; }
.tabla-usuarios .acciones-cel button { font-size: 11px; padding: 3px 7px; margin-left: 4px; }
@media (max-width: 620px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

.mapeo-fila {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.mapeo-fila:last-child { border-bottom: none; }
.mapeo-col-original { flex: 1; color: var(--text-muted); font-family: var(--mono); }

/* ---- Panel deslizante ---- */
.aside-flyout {
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 0 solid var(--border);
  border-radius: var(--radius);
  margin-right: 0;
  margin-left: 0;
  transition: width 0.25s ease, border-width 0.25s;
  flex-shrink: 0;
  order: -1;
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
}

.aside-flyout.abierto {
  width: 400px;
  border-width: 1px;
  margin-right: 8px;
}

.aside-flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.aside-flyout-cerrar {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
}

.aside-flyout-cerrar:hover { background: var(--bg); color: var(--text-primary); }

.aside-flyout-body {
  padding: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

.aside-panel { display: none; }
.aside-panel.activo { display: block; }

/* ---- Config niveles ---- */
.config-nivel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-shared-badge {
  font-size: 10px;
  font-weight: 400;
  background: #fff7ed;
  color: var(--accent-dark);
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: 0;
}

.config-evento-select {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* ---- Bloque evento destacado ---- */
.config-evento-bloque {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  margin-top: 4px;
}

.config-evento-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
}

.config-evento-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.config-evento-header strong {
  color: var(--accent-dark);
  font-size: 16px;
}

/* ===================== MODAL FICHA PARTICIPANTE ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}

.modal-contenido {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 1000px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fd;
}

.modal-subtitulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.modal-titulo {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.modal-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.modal-cerrar {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
}

.modal-cerrar:hover { background: var(--bg); color: var(--text); }

.modal-cuerpo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 300px;
}

@media (max-width: 700px) {
  .modal-cuerpo { grid-template-columns: 1fr; }
}

.ficha-col {
  padding: 18px 20px;
}

.ficha-col:first-child {
  border-right: 1px solid var(--border);
}

.ficha-col-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ficha-tabla {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.ficha-tabla th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.ficha-tabla td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.ficha-tabla tbody tr:hover { background: var(--bg); }
.ficha-tabla tbody tr:last-child td { border-bottom: none; }

/* ===================== AUTO-RECÁLCULO ===================== */
.dash-autorecalc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #fff7ed;
  border: 1px solid #93c5fd;
  border-radius: var(--radius);
  font-size: 12px;
  color: #9a3412;
  margin-bottom: 14px;
}

.autorecalc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulso 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulso {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.autorecalc-stop {
  margin-left: auto;
  background: none;
  border: 1px solid #93c5fd;
  color: #9a3412;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.autorecalc-stop:hover { background: #fed7aa; }

/* ===================== SELECCIÓN MÚLTIPLE Y MENÚ CONTEXTUAL ===================== */
.fila-seleccionada { background: #fff7ed !important; }

/* ===================== MENÚ CONTEXTUAL ESTILO COPÉRNICO ===================== */
.menu-contextual {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  min-width: 200px;
  padding: 4px 0;
  font-size: 13px;
  user-select: none;
}

.menu-ctx-cabecera {
  padding: 6px 14px 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.menu-ctx-item {
  padding: 7px 16px;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.menu-ctx-item i { font-size: 14px; color: var(--text-muted); flex-shrink: 0; }
.menu-ctx-item:hover { background: #fff7ed; color: var(--accent-dark); }
.menu-ctx-item:hover i { color: var(--accent); }

/* Item con submenú */
.menu-ctx-has-sub { position: relative; }
.menu-ctx-arrow { margin-left: auto; font-size: 14px; color: var(--text-muted); }

/* Submenú de estado */
.menu-ctx-sub {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  min-width: 160px;
  padding: 4px 0;
  z-index: 10000;
}

/* Ítem peligroso (eliminar) */
.menu-ctx-danger { color: #dc2626 !important; }
.menu-ctx-danger i { color: #dc2626 !important; }
.menu-ctx-danger:hover { background: #fef2f2 !important; }

.menu-ctx-separador {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

/* ---- Lecturas en ficha ---- */
.lectura-usada   { background: #f0fdf4; }
.lectura-anulada { opacity: 0.45; text-decoration: line-through; background: #fef2f2; }

.badge-usada {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: #16a34a;
  color: #fff;
  padding: 1px 5px;
  border-radius: 8px;
  vertical-align: middle;
  margin-left: 4px;
  letter-spacing: 0.02em;
}

/* ===================== TABLA PARTICIPANTES ESTILO COPERNICO ===================== */

/* La tabla ocupa el 100% incluyendo desbordamiento horizontal */
.participantes-main {
  width: 100%;
  overflow-x: auto;
}

#tabla-participantes {
  font-size: 11.5px;
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

#tabla-participantes thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fc;
}

#tabla-participantes th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  padding: 5px 6px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

#tabla-participantes td {
  padding: 3px 6px;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid #f0f1f4;
}

/* Filas alternas */
#tabla-participantes tbody tr:nth-child(even) { background: #fafbfc; }
#tabla-participantes tbody tr:hover { background: #fff7ed; }
#tabla-participantes tbody tr.fila-seleccionada { background: #fff7ed !important; }
#tabla-participantes tbody tr.fila-seleccionada:hover { background: #fed7aa !important; }

/* Fila retirado / sin salida → aparece atenuada */
#tabla-participantes tbody tr.fila-atenuada { opacity: 0.5; }
#tabla-participantes tbody tr.fila-atenuada:hover { opacity: 0.75; }

/* Indicador de selección: punto azul al inicio */
.col-dot {
  width: 10px;
  padding: 3px 2px !important;
}
.col-chk { width: 22px; padding: 3px 2px !important; }
.col-acc  { width: 44px; padding: 3px 2px !important; }
.tc  { text-align: center; }
.fw6 { font-weight: 600; }

.dot-sel {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Icono de género */
.sexo-m { color: #1d4ed8; font-weight: 700; font-size: 13px; }
.sexo-f { color: #ec4899; font-weight: 700; font-size: 13px; }

/* Estado con icono estilo Copérnico */
.est-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.est-badge .est-ico { font-size: 12px; opacity: 0.7; }
.est-finalizado-txt  { color: #15803d; }
.est-corriendo-txt   { color: #0369a1; }
.est-sin-txt         { color: #9ca3af; font-style: italic; }
.est-retirado-txt    { color: #9ca3af; font-style: italic; }
.est-cuarentena-txt  { color: #f97316; }
.est-descalif-txt    { color: #dc2626; font-weight: 700; }

/* Tiempo monoespaciado */
.t-cell {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
}
.t-cell.t-dim { color: var(--text-muted); font-weight: 400; }
.tod-cell {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* Botones de acción mínimos */
.btn-ico {
  background: none;
  border: none;
  padding: 1px 3px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 3px;
  font-size: 13px;
  line-height: 1;
}
.btn-ico:hover { color: var(--accent); background: #fff7ed; }

/* Pills de estado (menú contextual y filtro) */
.estado-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}
.est-sin         { background: #f3f4f6; color: #6b7280; }
.est-corriendo   { background: #e0f2fe; color: #0369a1; }
.est-finalizado  { background: #dcfce7; color: #166534; }
.est-cuarentena  { background: #fff7ed; color: #ea580c; border:1px solid #fed7aa; }
.est-retirado    { background: #f3f4f6; color: #4b5563; border:1px solid #d1d5db; }
.est-descalificado { background: #fee2e2; color: #991b1b; }

/* Dashboard barras */
.fill-cuarentena { background: #f97316; }

/* ===================== BANNER RECALCULAR ===================== */
.banner-recalcular {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 13px;
  color: #92400e;
  font-weight: 500;
}

.banner-recalcular button {
  background: #f97316;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.banner-recalcular button:hover { background: #f97316; }

.btn-cerrar-banner {
  margin-left: auto;
  background: none !important;
  color: #92400e !important;
  font-size: 16px !important;
  padding: 0 4px !important;
  border-radius: 4px !important;
}

/* ===================== EDICIÓN INLINE SPLITS/TRAMOS ===================== */
.edit-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: #f0f6ff;
  border-radius: 6px;
}

.edit-inline-form input,
.edit-inline-form select {
  font-size: 12px;
  padding: 4px 8px;
}

/* ===================== INFORMES ===================== */
.informe-form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.informe-form > label,
.informe-form-row > label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #57534e);
}
.informe-form input[type="text"],
.informe-form select { font-size: 13px; padding: 6px 8px; font-weight: 400; }
.informe-form-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-end; }
.informe-check { flex-direction: row !important; align-items: center; gap: 7px !important; }
.informe-check input { width: auto; }

/* ===================== CENTRAL (supervisión multi-carrera) ===================== */
.central-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.central-card {
  background: var(--surface, #fff); border: 1px solid var(--border, #e7e5e4); border-left: 5px solid #9ca3af;
  border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: box-shadow .15s, transform .05s;
}
.central-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.central-card:active { transform: translateY(1px); }
.central-card.salud-ok { border-left-color: #16a34a; }
.central-card.salud-aviso { border-left-color: #f59e0b; }
.central-card.salud-alerta { border-left-color: #dc2626; }
.central-card.salud-idle { border-left-color: #9ca3af; }
.cc-head { display: flex; align-items: center; gap: 8px; }
.cc-head h3 { margin: 0; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-fecha { font-size: 11px; color: var(--text-muted, #78716c); }
.cc-dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }
.salud-ok .cc-dot { background: #16a34a; animation: pulso 1.6s infinite; }
.salud-aviso .cc-dot { background: #f59e0b; }
.salud-alerta .cc-dot { background: #dc2626; animation: pulso 1s infinite; }
.cc-nums { font-size: 13px; margin: 8px 0 4px; }
.cc-nums b { color: var(--accent-dark, #ea580c); }
.cc-flujo { font-size: 12px; color: var(--text-muted, #78716c); }
.salud-alerta .cc-flujo, .salud-aviso .cc-flujo { color: #b45309; font-weight: 600; }
.cc-puntos { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.cp { font-size: 11px; background: var(--bg, #f5f5f4); border-radius: 5px; padding: 2px 7px; color: var(--text-muted, #57534e); }
.cp.muda { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.cc-eventos { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-muted, #78716c); margin-top: 4px; }
.cc-eventos b { color: var(--text, #1c1917); }
.cc-abrir { text-align: right; font-size: 12px; color: var(--accent, #f97316); font-weight: 600; margin-top: 6px; }

/* ===================== TOKENS / RELÉ ===================== */
.token-val { font-family: var(--mono); font-size: 12px; background: var(--bg, #f5f5f4); padding: 2px 6px; border-radius: 4px; }

/* ===================== VERSIÓN ===================== */
.version-chip { font-size: 11px; color: #d6d3d1; opacity: .8; font-variant-numeric: tabular-nums; }
.login-version { text-align: center; margin-top: 12px; font-size: 12px; color: var(--text-muted, #78716c); }

/* ===================== LOGIN ===================== */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: #1c1917; display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-box {
  background: var(--surface, #fff); border-radius: 14px; padding: 28px 26px; width: 100%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 6px;
}
.login-logo { background: #1c1917; border-radius: 10px; padding: 12px; text-align: center; margin-bottom: 10px; }
.login-box h2 { margin: 0 0 10px; font-size: 17px; text-align: center; }
.login-box label { font-size: 12px; font-weight: 600; color: var(--text-muted, #57534e); margin-top: 6px; }
.login-box input { padding: 10px 12px; border: 1px solid var(--border, #e7e5e4); border-radius: 8px; font-size: 15px; }
.login-box button { margin-top: 14px; background: var(--accent, #f97316); color: #fff; border: 0; padding: 11px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--accent-dark, #ea580c); }
.login-error { color: #dc2626; font-size: 13px; min-height: 18px; text-align: center; }
.usuario-chip { color: #fff; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; opacity: .9; }
.btn-logout { background: rgba(255,255,255,.12); color: #fff; border: 0; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ===================== REASIGNAR LECTURAS ===================== */
.lecturas-reasignar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin: 10px 0;
  background: var(--bg, #f5f5f4); border: 1px solid var(--border, #e7e5e4); border-radius: 8px;
}
.lecturas-reasignar label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.lecturas-reasignar select { font-size: 13px; padding: 5px 7px; }
#lecturas-reasignar-res { font-size: 13px; }
#tabla-lecturas .col-chk { width: 32px; text-align: center; }
#tabla-lecturas tr.lectura-anulada { opacity: .45; text-decoration: line-through; }

/* ===================== DASHBOARD DE WIDGETS ===================== */
.dash-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.dash-add { position: relative; }
.dash-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  background: var(--surface, #fff); border: 1px solid var(--border, #e7e5e4);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; min-width: 240px;
}
.dash-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text, #1c1917);
}
.dash-menu button:hover { background: var(--bg, #f5f5f4); }
.dash-menu button:disabled { opacity: .4; cursor: default; }
.dash-menu .dash-menu-vacio { padding: 8px; font-size: 12px; color: var(--text-muted, #78716c); }

.dash-board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .dash-board { grid-template-columns: 1fr; } }

.dwidget {
  background: var(--surface, #fff); border: 1px solid var(--border, #e7e5e4);
  border-radius: var(--radius, 10px); overflow: hidden; display: flex; flex-direction: column;
}
.dwidget-wide { grid-column: 1 / -1; }
.dwidget-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--dw-color, #1c1917); color: #fff;
}
.dwidget-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.dwidget-icon { font-size: 15px; }
.dwidget-sub { font-size: 11px; opacity: .7; margin-left: 2px; }
.dwidget-acts { margin-left: auto; display: flex; gap: 2px; }
.dwidget-acts button {
  background: rgba(255,255,255,.15); color: #fff; border: 0; width: 24px; height: 24px;
  border-radius: 5px; cursor: pointer; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.dwidget-acts button:hover { background: rgba(255,255,255,.3); }
.dwidget-body { padding: 14px 16px; }

/* Widget Estado de carrera (columnas por punto) */
.ec-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.ec-col { text-align: center; padding: 6px 4px; border-radius: 8px; background: var(--bg, #f5f5f4); }
.ec-col .ec-nom { font-size: 11px; text-transform: uppercase; color: var(--text-muted, #78716c); letter-spacing: .5px; }
.ec-col .ec-num { font-size: 28px; font-weight: 700; color: var(--accent-dark, #ea580c); line-height: 1.1; }
.ec-col .ec-pct { font-size: 12px; color: var(--text-muted, #78716c); }
.ec-col .ec-hora { font-size: 11px; color: var(--text-muted, #78716c); font-family: var(--mono); }

/* Widget Reloj de salida */
.reloj-grande { font-family: var(--mono); font-size: 52px; font-weight: 700; text-align: center; color: var(--text, #1c1917); padding: 8px 0; }
.reloj-sub { text-align: center; font-size: 12px; color: var(--text-muted, #78716c); }

/* Widget Estados (lista con %) */
.estado-lista { display: flex; flex-direction: column; }
.estado-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border, #f0efed); }
.estado-item:last-child { border-bottom: 0; }
.estado-item .ei-ico { width: 20px; text-align: center; }
.estado-item .ei-nom { flex: 1; font-size: 13px; }
.estado-item .ei-num { font-weight: 700; font-size: 15px; min-width: 40px; text-align: right; }
.estado-item .ei-pct { font-size: 12px; color: var(--text-muted, #78716c); min-width: 56px; text-align: right; }

/* Widget Trofeos */
.trofeo-item { display: flex; align-items: center; gap: 10px; padding: 7px 2px; }
.trofeo-item .ti-nom { flex: 1; font-size: 13px; }
.trofeo-item .ti-cnt { font-size: 12px; color: var(--text-muted, #78716c); min-width: 36px; text-align: right; }
.trofeo-track { width: 90px; height: 7px; background: var(--bg, #f5f5f4); border-radius: 4px; overflow: hidden; }
.trofeo-fill { height: 100%; background: #16a34a; border-radius: 4px; }

/* Podio / listas */
.podio-lista, .mini-lista { display: flex; flex-direction: column; }
.podio-fila { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--border, #f0efed); }
.podio-fila:last-child { border-bottom: 0; }
.podio-pos { width: 22px; height: 22px; border-radius: 50%; background: var(--accent, #f97316); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.podio-dorsal { font-weight: 700; min-width: 36px; }
.podio-nom { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podio-t { font-variant-numeric: tabular-nums; }

.mini-fila { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid var(--border, #f0efed); font-size: 13px; }
.mini-fila:last-child { border-bottom: 0; }
.mini-dorsal { font-weight: 700; min-width: 34px; }
.mini-nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-t { font-variant-numeric: tabular-nums; color: var(--text-muted, #78716c); }
.mini-motivo { font-size: 11px; color: var(--text-muted, #78716c); }
.mini-fila.antena-amber { color: #b45309; }
.mini-fila.antena-roja { color: #dc2626; font-weight: 600; }

/* Líder / último (destacado) */
.lider-box { text-align: center; padding: 6px 0; }
.lider-dorsal { font-size: 13px; color: var(--text-muted, #78716c); font-weight: 700; }
.lider-nom { font-size: 20px; font-weight: 700; line-height: 1.15; }
.lider-t { font-size: 30px; font-weight: 700; color: var(--accent-dark, #ea580c); font-variant-numeric: tabular-nums; }
.lider-cat { font-size: 12px; color: var(--text-muted, #78716c); }

/* Buscar dorsal */
.buscar-box { border: 1px solid var(--border, #e7e5e4); border-radius: 8px; padding: 10px; }
.buscar-nom { font-size: 15px; }
.buscar-meta { font-size: 12px; color: var(--text-muted, #78716c); margin: 4px 0 8px; }
.buscar-t { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 0; }

/* Progreso */
.progreso-num { font-size: 40px; font-weight: 700; color: var(--accent-dark, #ea580c); text-align: center; }
.progreso-track { height: 12px; background: var(--bg, #f5f5f4); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progreso-fill { height: 100%; background: #16a34a; border-radius: 6px; transition: width .4s; }
.progreso-sub { text-align: center; font-size: 12px; color: var(--text-muted, #78716c); }

/* Distribuciones (barras) */
.dist-lista { display: flex; flex-direction: column; gap: 6px; }
.dist-fila { display: flex; align-items: center; gap: 8px; }
.dist-nom { font-size: 12px; min-width: 90px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-track { flex: 1; height: 10px; background: var(--bg, #f5f5f4); border-radius: 5px; overflow: hidden; }
.dist-fill { height: 100%; background: var(--accent, #f97316); border-radius: 5px; }
.dist-num { font-size: 12px; font-weight: 600; min-width: 28px; text-align: right; }

/* Sexo */
.sexo-box { display: flex; justify-content: space-around; padding: 6px 0; }
.sexo-item { text-align: center; }
.sexo-ico { font-size: 30px; font-weight: 900; display: block; }
.sexo-num { font-size: 24px; font-weight: 700; }
.sexo-pct { font-size: 12px; color: var(--text-muted, #78716c); }

/* Sparkline llegadas por minuto */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.spark-bar { flex: 1; background: var(--accent, #f97316); border-radius: 3px 3px 0 0; position: relative; min-width: 6px; }
.spark-bar span { position: absolute; top: -14px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--text-muted, #78716c); }
.spark-eje { font-size: 11px; color: var(--text-muted, #78716c); text-align: center; margin-top: 6px; }

/* DNS/DNF */
.dnsdnf-row { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid var(--border, #f0efed); font-size: 13px; }

/* Texto libre */
.texto-libre { font-size: 15px; line-height: 1.5; }

/* Secuenciación de chips */
.tabla-secuencia { width: 100%; border-collapse: collapse; }
.tabla-secuencia th { text-align: left; font-size: 11px; color: var(--text-muted, #57534e); text-transform: uppercase; padding: 4px 6px; border-bottom: 1px solid var(--borde, #e7e5e4); }
.tabla-secuencia td { padding: 4px 6px; }
.tabla-secuencia input, .tabla-secuencia select { font-size: 13px; padding: 5px 7px; width: 100%; box-sizing: border-box; }
.tabla-secuencia input[readonly] { background: #f5f5f4; color: #78716c; cursor: default; }
.tabla-secuencia .col-num { width: 130px; }
.secuencia-preview { max-height: 260px; overflow: auto; border: 1px solid var(--borde, #e7e5e4); border-radius: 6px; }
.secuencia-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.secuencia-preview th { position: sticky; top: 0; background: #f5f5f4; padding: 4px 8px; text-align: left; }
.secuencia-preview td { padding: 3px 8px; border-bottom: 1px solid #f5f5f4; font-variant-numeric: tabular-nums; }
.sec-aviso { color: #b45309; font-size: 12px; margin: 6px 0; }
.sec-error { color: #dc2626; font-size: 12px; margin: 6px 0; }
.sec-ok { color: #16a34a; font-weight: 600; }

/* Editor de nombres de columna del informe */
.etq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 14px; }
.etq-row { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-muted, #57534e); }
.etq-row .etq-def { font-weight: 600; }
.etq-row input { font-size: 12px; padding: 4px 7px; font-weight: 400; }

/* ===================== PRESETS ===================== */
.presets-bar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 6px;
  border-left: 1px solid var(--borde, #e7e5e4);
  margin-left: 2px;
}
.presets-bar select {
  font-size: 12px;
  padding: 4px 6px;
  max-width: 160px;
}
.presets-bar button {
  padding: 4px 9px;
  font-size: 12px;
}

/* ===================== ORDENACIÓN DE TABLA ===================== */
#tabla-participantes thead th.th-sortable {
  cursor: pointer;
  user-select: none;
}
#tabla-participantes thead th.th-sortable:hover {
  color: var(--accent);
}
#tabla-participantes thead th.orden-asc::after { content: " ↑"; color: var(--accent); }
#tabla-participantes thead th.orden-desc::after { content: " ↓"; color: var(--accent); }

/* ===================== TROFEOS ===================== */
.trofeo-noacum {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.trofeo-noacum input { transform: translateY(1px); }
.trofeo-noacum .hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================== TOAST OK ===================== */
.toast-ok {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #16a34a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 999;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===================== PIE DE TABLA PARTICIPANTES ===================== */
/* [eliminado] */
  font-size: 13px;
  color: var(--text-primary);
}

.pie-paginacion button:disabled { opacity: 0.35; cursor: default; }
.pie-paginacion button:not(:disabled):hover { background: #fff7ed; }

.pie-filas {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pie-filas select {
  font-size: 12px;
  padding: 2px 6px;
}

/* ===================== PANEL PERSONALIZAR TABLA ===================== */
.btn-personalizar-tabla {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}
.btn-personalizar-tabla:hover { border-color: var(--accent); color: var(--accent); }
.btn-personalizar-tabla.activo { border-color: var(--accent); background: #fff7ed; color: var(--accent); }

.panel-columnas {
  position: fixed;
  top: 0;
  right: 0;
  width: 300px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  background: #f8f9fc;
  flex-shrink: 0;
}

.panel-col-header button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  border-radius: 4px;
}
.panel-col-header button:hover { background: var(--bg); }

.panel-col-body {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.panel-col-seccion {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-col-seccion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.panel-col-seccion-btns {
  display: flex;
  gap: 4px;
}

.panel-col-seccion-btns button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 4px;
  color: var(--text-muted);
  border-radius: 3px;
}
.panel-col-seccion-btns button:hover { color: var(--accent); background: #fff7ed; }

.panel-col-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.col-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  user-select: none;
  transition: all 0.15s;
}

.col-chip.activo {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.col-chip:hover:not(.activo) { border-color: var(--accent); color: var(--accent); }

/* ===================== SCROLL HORIZONTAL TABLA ===================== */
.tabla-scroll-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.tabla-scroll-wrapper::-webkit-scrollbar { height: 6px; }
.tabla-scroll-wrapper::-webkit-scrollbar-track { background: var(--bg); }
.tabla-scroll-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.tabla-scroll-wrapper::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Ritmo en tabla */
.ritmo-cell {
  font-family: var(--mono);
  font-size: 10px;
  color: #7c3aed;
  white-space: nowrap;
}

/* ===================== SUB-COLUMNAS DE TRAMO EN PANEL ===================== */
.tramo-col-grupo {
  width: 100%;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.tramo-col-titulo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: #f8f9fc;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.tramo-col-acciones {
  display: flex;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}

.tramo-col-acciones span:hover { color: var(--accent); }

.tramo-col-subcols {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
}

.subcol-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  user-select: none;
  transition: all 0.12s;
}

.subcol-chip.activo {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.subcol-chip:hover:not(.activo) {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===================== DRAG & DROP DE COLUMNAS ===================== */
#tabla-participantes th[draggable="true"] {
  cursor: grab;
  user-select: none;
}

#tabla-participantes th[draggable="true"]:active {
  cursor: grabbing;
}

.col-th-dragging {
  opacity: 0.4;
  background: #fff7ed !important;
}

.col-th-over-left {
  box-shadow: -3px 0 0 0 var(--accent);
}

.col-th-over-right {
  box-shadow: 3px 0 0 0 var(--accent);
}

/* ===================== PANEL RESULTADOS PARTICIPANTE ===================== */
.panel-resultados {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px rgba(0,0,0,0.12);
  z-index: 200;
  flex-direction: column;
  overflow: hidden;
}

.pr-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fc;
  flex-shrink: 0;
}

.pr-header-info { flex: 1; min-width: 0; }

.pr-nombre {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.2;
}

.pr-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.pr-dorsal {
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  flex-shrink: 0;
  font-family: var(--mono);
}

.pr-header-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 8px;
}

.pr-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}

.pr-seccion {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
}

.pr-seccion:last-child { border-bottom: none; }

.pr-seccion-titulo {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 20px 6px;
  background: #f8f9fc;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.pr-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pr-tabla th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}

.pr-tabla td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f1f4;
  vertical-align: middle;
}

.pr-tabla tbody tr:hover { background: #f0f6ff; }

.pr-tabla .mono { font-family: var(--mono); font-size: 12px; }

.pr-pos {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
}

.pr-pos-cat { color: #0891b2; }

/* Fila de la tabla seleccionada cuando el panel está abierto */
#tabla-participantes tbody tr.fila-panel-activo {
  background: #fff7ed !important;
  border-left: 3px solid var(--accent);
}

/* ===================== HISTORIAL DE CARRERAS ===================== */
.hist-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
}

.hist-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(37,99,235,0.1);
  transform: translateY(-1px);
}

.hist-card-left { flex: 1; min-width: 0; }

.hist-fecha {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hist-nombre {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.hist-eventos {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hist-ev-badge {
  display: inline-block;
  font-size: 11px;
  background: #f0f6ff;
  color: var(--accent);
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 2px 8px;
  font-weight: 500;
}

.hist-card-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  margin-left: 20px;
}

.hist-stat-grupo { text-align: center; }
.hist-stat-num { font-size: 18px; font-weight: 700; line-height: 1; }
.hist-stat-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }

.hist-card-arrow {
  font-size: 20px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* Detalle de carrera */
.hist-evento-bloque {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface);
}

.hist-evento-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.hist-evento-nombre {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.hist-evento-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
  margin-top: 4px;
}

.hist-top-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}

.hist-top-tabla th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fc;
  text-align: left;
}

.hist-top-tabla td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f1f4;
}

.hist-top-tabla tbody tr:first-child td { background: #fefce8; }
.hist-top-tabla tbody tr:hover { background: #f0f6ff; }

/* ===================== AVISOS DE TIEMPO MÍNIMO ===================== */
.pr-fila-sin-tiempo > td:first-child {
  color: var(--text-muted);
}

.pr-aviso {
  font-size: 10px;
  font-weight: 400;
  color: #f97316;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ===================== FIX 3: TABLA PARTICIPANTES ANCHO COMPLETO ===================== */
.part-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;  /* necesario en cadena flex para no desbordar */
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.part-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.part-wrapper .filtros {
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.part-wrapper .tabla-scroll-wrapper {
  flex: 1;
  overflow: auto;
  min-height: 0;
  /* Garantía extra: el contenido no llega hasta el borde inferior */
  box-sizing: border-box;
}

/* [eliminado] */

.part-wrapper #tabla-participantes {
  margin-top: 0;
  border-radius: 0;
  border: none;
  width: 100%;
}

/* ===================== FIX 5: PANEL COLUMNAS — CHIPS INDIVIDUALES ===================== */
.panel-col-grupo-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 2px 6px;
  margin-top: 4px;
}

/* [eliminado] */
  cursor: pointer;
  color: var(--text-primary);
}

.pie-paginacion button:disabled { opacity: 0.35; cursor: default; }

.pie-agrupar, .pie-filas {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===================== FILAS DE GRUPO ===================== */
.fila-grupo td {
  background: var(--bg);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 12px;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
}

/* ===================== PIE DE TABLA — FIJO EN LA PARTE INFERIOR ===================== */
/* Se muestra solo cuando la pestaña participantes está activa */
#pie-tabla-participantes {
  position: fixed;
  bottom: 0;
  left: 64px;   /* ancho de la iconbar-vertical */
  right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  background: var(--surface);
  border-top: 2px solid var(--border);
  font-size: 12px;
  z-index: 100;
  flex-wrap: nowrap;
  overflow: hidden;
}

.pie-info { flex: 1; min-width: 120px; white-space: nowrap; }
.pie-info strong { color: var(--text-primary); }

.pie-paginacion {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pie-paginacion button {
  padding: 2px 10px;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-primary);
  line-height: 1;
}

.pie-paginacion button:disabled { opacity: 0.35; cursor: default; }
.pie-paginacion button:not(:disabled):hover { background: var(--bg); }

.pie-agrupar, .pie-filas {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pie-agrupar select, .pie-filas input {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-primary);
}

.pie-filas input { width: 56px; text-align: center; }

/* Garantía: nada dentro de participantes-screen desborda verticalmente */
.participantes-screen,
.part-wrapper,
.part-wrapper .tabla-scroll-wrapper {
  max-height: 100%;
}

/* ===================== EDITOR DE TIEMPO MANUAL (panel resultados) ===================== */
.editor-tiempo-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-tiempo-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  width: 360px;
  max-width: 95vw;
  overflow: hidden;
}

.editor-tiempo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.editor-tiempo-body { padding: 16px; }

.editor-modo-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--bg);
  border-radius: 6px;
  padding: 3px;
}

.editor-modo-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

.editor-modo-btn.activo {
  background: var(--surface);
  color: var(--accent-dark);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.editor-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.editor-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text-primary);
  box-sizing: border-box;
}

.editor-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249,115,22,0.15);
}

.editor-ayuda {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.editor-acciones {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}
