:root {
  --gutter-x: 15px;
  --gutter-y: 0;
  --primary-color: #f50666;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --dark-color: #343a40;
  --gray-color: #6c757d;
  --light-bg: #f5f5f5;
  --white-bg: #ffffff;
  --blue-color: #0984e3;
  --yellow-color: #d6b706;
  --pink-color: #f7089c;
  --purple-color: #9b59b6;
}

* {
  box-sizing: border-box;
}

body {
  padding: 10px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--light-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  -webkit-text-size-adjust: 100%;
}

.container {
  width: 100%;
  max-width: 1400px;
  padding-right: calc(var(--gutter-x) * .5);
  padding-left: calc(var(--gutter-x) * .5);
  margin-right: auto;
  margin-left: auto;
  flex: 1;
}

/* Заголовок и селектор категорий */
.category-select-container {
  margin: 0 0 20px 0;
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.category-select-container h3 {
  margin-bottom: 15px;
  color: #333;
  font-weight: 600;
  font-size: 1.5rem;
}

.category-select-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.category-select {
  width: 100%;
  max-width: 250px;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background-color: white;
  font-size: 14px;
}

.buttons-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

/* Статус трансляции */
.broadcast-status {
  margin-bottom: 15px;
}

.broadcast-status .badge {
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
}

.bg-secondary {
  background-color: var(--gray-color) !important;
}

.bg-success {
  background-color: var(--success-color) !important;
}

.bg-danger {
  background-color: var(--danger-color) !important;
}

.blinking-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: white;
  border-radius: 50%;
  margin-right: 6px;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Кнопки */
.map-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0 20px;
  border-radius: 4px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  height: 38px;
  line-height: 38px;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

.donate-btn {
  background-color: #a0a0a0 !important;
}

.donate-btn:hover {
  background-color: #8a8a8a !important;
  color: white !important;
  text-decoration: none !important;
}

.map-btn:hover {
  background-color: #d40558;
  color: white;
  text-decoration: none;
}

/* Таблица */
.table-responsive {
  width: 100%;
  margin-bottom: 20px;
  background-color: var(--white-bg);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: auto;
  
}

.results-table th {
  background-color: #f8f9fa;
  position: sticky;
  top: 0;
  padding: 12px 8px;
  font-weight: 600;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  white-space: nowrap;
  z-index: 10;
}

.results-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #e9ecef;
  vertical-align: middle;
  white-space: nowrap;
}

.results-table tbody tr:hover td {
  background-color: #f8f9fa;
}

.results-table tr:nth-child(even) td {
  background-color: #fcfcfc;
}

/* Ширины колонок - фиксированные слева, Splits резиновый с выравниванием влево */
.results-table th:nth-child(1),
.results-table td:nth-child(1) { width: 50px; text-align: center; } /* Rank */

.results-table th:nth-child(2),
.results-table td:nth-child(2) { width: 60px; text-align: center; } /* Bib */

.results-table th:nth-child(3),
.results-table td:nth-child(3) { width: 220px; } /* Team */

.results-table th:nth-child(4),
.results-table td:nth-child(4) { width: 70px; text-align: center; } /* Category */

.results-table th:nth-child(5),
.results-table td:nth-child(5) { width: 80px; text-align: center; } /* Rank Abs. */

.results-table th:nth-child(6),
.results-table td:nth-child(6) { width: 70px; text-align: center; } /* Start */

.results-table th:nth-child(7),
.results-table td:nth-child(7) { width: 70px; text-align: center; } /* Finish */

.results-table th:nth-child(8),
.results-table td:nth-child(8) { width: 40px; text-align: center; } /* CP */

.results-table th:nth-child(9),
.results-table td:nth-child(9) { width: 70px; text-align: center; } /* Points */

.results-table th:nth-child(10),
.results-table td:nth-child(10) { width: 80px; text-align: center; } /* Time */

.results-table th:nth-child(11),
.results-table td:nth-child(11) { width: 70px; text-align: center; } /* Result */

.results-table th:nth-child(12),
.results-table td:nth-child(12) { width: 90px; } /* Status */

/* Splits - выравнивание влево */
.results-table th:nth-child(13),
.results-table td:nth-child(13) { 
  width: auto; 
  min-width: 60px; 
  text-align: left;
  padding-left: 15px;
  white-space: nowrap;
}

/* Специальные колонки */
.time-column,
.result-column {
  color: var(--primary-color);
  font-weight: 700;
}

/* Статусы команд */
.status-inactive,
.status-dns,
.status-dnf,
.status-dsq {
  color: var(--gray-color);
  font-style: italic;
}

.status-running {
  color: var(--info-color);
  font-weight: 500;
}

.status-finished {
  color: var(--success-color);
  font-weight: 500;
}

.status-registered {
  color: var(--success-color);
  font-weight: 500;
}

.status-ready {
  color: var(--blue-color);
  font-weight: 700;
}

.status-trained {
  color: var(--yellow-color);
  font-weight: 700;
}

.status-at_start {
  color: var(--pink-color);
  font-weight: 700;
}

/* GPX индикатор */
.gpx-indicator {
  display: inline-block;
  margin-left: 5px;
}

.gpx-indicator i {
  color: var(--purple-color);
  font-size: 14px;
}

/* PDF иконка */
.pdf-icon {
  color: var(--primary-color);
  font-size: 1.2rem;
  transition: transform 0.2s;
}

.pdf-icon:hover {
  transform: scale(1.1);
}

/* Подсветка изменений */
.highlighted-row td {
  animation: fadeOutHighlight 5s ease-out forwards !important;
}

@keyframes fadeOutHighlight {
  0% {
    background-color: #FFEB3B !important;
    box-shadow: inset 0 0 0 2px rgba(255, 193, 7, 0.5);
  }
  70% {
    background-color: #FFEB3B !important;
  }
  100% {
    background-color: inherit !important;
    box-shadow: none;
  }
}

/* Информация об обновлении */
.update-info {
  font-size: 13px;
  color: var(--gray-color);
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin-top: 20px;
  border: 1px solid #e9ecef;
}

.update-info .fw-bold {
  color: #495057;
}

/* Попап с составом команды */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.team-popup {
  background: white;
  border-radius: 15px;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.popup-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 20px;
  border-radius: 15px 15px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
}

.popup-header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.popup-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: transform 0.2s;
}

.popup-close:hover {
  transform: scale(1.2);
}

.popup-content {
  padding: 20px;
}

.team-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.team-info p {
  margin: 5px 0;
  font-size: 1rem;
}

.team-info strong {
  color: #495057;
  min-width: 80px;
  display: inline-block;
}

.team-members h4 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.1rem;
  border-bottom: 2px solid #667eea;
  padding-bottom: 5px;
  display: inline-block;
}

.members-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.member-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: #f8f9fa;
  margin-bottom: 8px;
  border-radius: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.member-item:hover {
  transform: translateX(5px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.member-number {
  background: #667eea;
  color: white;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-right: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.member-name {
  font-size: 1rem;
  color: #333;
}

/* Тулы для состава команды */
.has-team-info {
  cursor: help;
  position: relative;
  border-bottom: 1px dashed #999;
}

.team-tooltip {
  position: absolute;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  padding: 12px 16px;
  z-index: 10000;
  max-width: 280px;
  min-width: 220px;
  font-size: 14px;
  animation: fadeIn 0.2s ease-out;
  pointer-events: auto;
}

.tooltip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
}

.tooltip-bib {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 11px;
  color: #666;
}

.tooltip-members {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tooltip-member {
  display: flex;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px dashed #f5f5f5;
}

.tooltip-member:last-child {
  border-bottom: none;
}

.tooltip-member .member-number {
  width: 22px;
  height: 22px;
  margin-right: 10px;
  font-size: 11px;
}

.tooltip-member .member-name {
  font-size: 13px;
}

.tooltip-loading {
  color: #666;
  font-style: italic;
  padding: 8px;
  text-align: center;
}

.tooltip-error {
  color: var(--danger-color);
  padding: 8px;
  text-align: center;
}

/* Анимации */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Планшеты и небольшие десктопы */
@media (max-width: 992px) {
  .container {
    max-width: 100%;
    padding: 0 10px;
  }
  
  .category-select-container h3 {
    font-size: 1.3rem;
  }
}

/* Мобильные устройства */
@media (max-width: 768px) {
  body {
    padding: 5px;
  }
  
  .container {
    padding: 0 5px;
    max-width: 100%;
  }
  
  .category-select-container {
    padding: 15px;
    margin-bottom: 15px;
  }
  
  .category-select-container h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
  }
  
  /* Обновленная структура кнопок */
  .category-select-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  
  .category-select {
    width: 100%;
    max-width: 100%;
    margin-bottom: 5px;
    flex: 0 0 100%;
  }
  
  .buttons-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    width: 100%;
  }
  
  .buttons-row .map-btn {
    flex: 1;
    min-width: 0;
    width: auto;
  }
  
  .map-btn.donate-btn {
    width: 100%;
    flex: 0 0 100%;
    margin-top: 0;
  }
  
  /* Таблица с горизонтальным скроллом */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -5px 15px -5px;
    width: calc(100% + 10px);
  }
  
  .results-table {
    min-width: auto;
    width: auto;
    font-size: 12px;
    
  }
  
  /* Мобильные ширины колонок */
  .results-table th:nth-child(1),
  .results-table td:nth-child(1) { width: 40px; }
  
  .results-table th:nth-child(2),
  .results-table td:nth-child(2) { width: 45px; }
  
  .results-table th:nth-child(3),
  .results-table td:nth-child(3) { width: 150px; }
  
  .results-table th:nth-child(4),
  .results-table td:nth-child(4) { width: 60px; }
  
  .results-table th:nth-child(5),
  .results-table td:nth-child(5) { width: 60px; }
  
  .results-table th:nth-child(6),
  .results-table td:nth-child(6) { width: 55px; }
  
  .results-table th:nth-child(7),
  .results-table td:nth-child(7) { width: 55px; }
  
  .results-table th:nth-child(8),
  .results-table td:nth-child(8) { width: 35px; }
  
  .results-table th:nth-child(9),
  .results-table td:nth-child(9) { width: 50px; }
  
  .results-table th:nth-child(10),
  .results-table td:nth-child(10) { width: 60px; }
  
  .results-table th:nth-child(11),
  .results-table td:nth-child(11) { width: 55px; }
  
  .results-table th:nth-child(12),
  .results-table td:nth-child(12) { width: 80px; }
  
  /* Splits на мобильных - выравнивание влево */
  .results-table th:nth-child(13),
  .results-table td:nth-child(13) { 
    width: auto; 
    min-width: 45px;
    text-align: left;
    padding-left: 10px;
  }
  
  .update-info {
    padding: 12px;
    font-size: 12px;
  }
  /*
  .update-info .d-flex {
    flex-direction: column;
  }
  
  .update-info .me-3 {
    margin-right: 0 !important;
    margin-bottom: 8px;
  }
  */
  .gpx-indicator i {
    font-size: 12px;
  }
  
  .pdf-icon {
    font-size: 1rem;
  }
}

/* Очень маленькие экраны */


@media (max-width: 480px) {
  .category-select-container h3 {
    font-size: 1.1rem;
  }
  
  .buttons-row {
    gap: 5px;
  }
  
  .buttons-row .map-btn {
    font-size: 13px;
    padding: 0 10px;
  }
  
  .results-table {
    font-size: 11px;
    
    
  }
  
  .results-table th,
  .results-table td {
    padding: 6px 3px;
  }
}