* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

.filters {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    overflow-x: hidden;
}
.filters::-webkit-scrollbar {
    width: 8px;
}
.filters::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}
.filters::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}
.filters::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}


.filters h2 {
    margin-bottom: 1.5rem;
    color: #667eea;
    font-size: 1.3rem;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-secondary {
    width: 100%;
    padding: 0.7rem;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.results {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #f0f0f0;
}

.results-header h2 {
    color: #333;
    font-size: 1.5rem;
}

#race-count {
    color: #667eea;
    font-size: 0.9em;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-controls label {
    font-size: 0.9rem;
    color: #666;
}

.sort-controls select {
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.9rem;
}

.races-list {
    display: grid;
    gap: 1rem;
}

.race-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.race-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.race-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.race-card-title-section {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    flex: 1;
}

.race-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.race-name-link {
    color: #667eea;
    text-decoration: none;
    transition: color 0.3s;
}

.race-name-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.race-name-text {
    color: #333;
}

.race-date {
    font-size: 0.95rem;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

.race-details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.race-detail {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: #666;
}

.race-detail-icon {
    font-size: 1.1rem;
}

.race-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-road {
    background: #3498db;
    color: white;
}

.badge-trail {
    background: #27ae60;
    color: white;
}

.badge-mixed {
    background: #f39c12;
    color: white;
}

.race-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.btn-register {
    padding: 0.6rem 1.2rem;
    background: #2ecc71;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.3s;
    display: inline-block;
}

.btn-register:hover {
    background: #27ae60;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
}

footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #666;
    font-size: 0.9rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Navigation */
.view-navigation {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.view-btn {
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s;
    position: relative;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.view-btn.active {
    background: white;
    color: #667eea;
}

.badge-count {
    background: #ff4757;
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 0.3rem;
    font-weight: bold;
}

/* Quick Filters */
.quick-filters {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-quick {
    padding: 0.6rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-quick:hover {
    background: #5568d3;
}

/* Checkbox Labels - FIXED */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label > span:first-of-type {
    flex: 1;
}

/* Favorite Button - MOVED TO LEFT */
.favorite-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #ccc;
    transition: all 0.3s;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

.favorite-btn.is-favorite {
    color: #ffd700;
}

/* Compare Checkbox - MOVED TO BOTTOM RIGHT */
.compare-container {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #666;
    cursor: pointer;
    z-index: 10;
}

.compare-container:hover {
    color: #667eea;
}

.compare-checkbox {
    cursor: pointer;
}

.difficulty-rating {
    font-size: 0.85rem;
    margin-top: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.difficulty-stars {
    color: #ff6b6b;
    letter-spacing: 2px;
}

.difficulty-label {
    color: #999;
    font-size: 0.75rem;
}

/* Gradient Metric */
.gradient-metric {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
}

.gradient-value {
    color: #ff6b6b;
}

/* Dashboard */
.dashboard {
    padding: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-value {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.next-race-highlight {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.next-race-highlight h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.next-race-name {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.next-race-details {
    font-size: 1.1rem;
    opacity: 0.95;
}

.dashboard-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-card h3 {
    margin-bottom: 1rem;
    color: #667eea;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.bar-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    gap: 0.8rem;
}

.bar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
}

.bar-container {
    position: relative;
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
}

.bar-value {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    font-weight: bold;
    color: #333;
}

/* Comparison Table */
.comparison-table-container {
    overflow-x: auto;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.comparison-table th,
.comparison-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.comparison-table th {
    background: #f8f8f8;
    font-weight: 600;
    position: relative;
}

.comparison-table tbody tr:hover {
    background: #fafafa;
}

.remove-comparison {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.remove-comparison:hover {
    background: #e84040;
}

.comparison-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
    font-size: 1.1rem;
}

.btn-small {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
    margin-right: 0.3rem;
    transition: background 0.3s;
}

.btn-small:hover {
    background: #5568d3;
}

.btn-register-small {
    background: #2ecc71;
}

.btn-register-small:hover {
    background: #27ae60;
}

/* Favorites */
.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
}

.favorites-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-primary {
    padding: 0.6rem 1.2rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

.favorites-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.favorites-empty h2 {
    margin-bottom: 1rem;
    color: #666;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
}

/* Training Timeline */
.training-timeline {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.timeline-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #555;
}

.status-icon {
    font-size: 1.2rem;
}

.timeline-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
}

.timeline-start,
.timeline-end {
    text-align: center;
}

.timeline-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.timeline-date {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.timeline-progress {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border-radius: 20px;
    text-align: center;
}

.timeline-weeks {
    font-size: 0.85rem;
    font-weight: 600;
}

.status-training {
    border-left-color: #2ecc71;
}

.status-training .timeline-progress {
    background: #2ecc71;
}

.status-past {
    opacity: 0.6;
    border-left-color: #95a5a6;
}

.status-past .timeline-progress {
    background: #95a5a6;
}

/* Expanded Race Card */
.race-card.expanded {
    background: #f8f9fa;
    cursor: pointer;
}

.race-expanded {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #e0e0e0;
}

.expanded-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.expand-indicator {
    font-size: 0.75rem;
    color: #999;
    margin-left: 0.5rem;
}

/* Content Sections */
.content-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Info and Help Elements */
.info-banner {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-banner strong {
    color: #1976d2;
}

.help-text {
    color: #666;
    font-style: italic;
}

.help-icon {
    display: inline-block;
    background: #2196f3;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    text-align: center;
    font-size: 0.7rem;
    line-height: 16px;
    margin-left: 0.3rem;
    cursor: help;
    font-style: normal;
}

/* Header Updates */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.btn-help {
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-help:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 2rem;
    line-height: 1.8;
}

.modal-body h3 {
    color: #667eea;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
    font-size: 1.2rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.modal-body .example {
    background: #f8f9fa;
    padding: 0.8rem;
    border-radius: 4px;
    margin: 0.8rem 0;
    font-size: 0.9rem;
    border-left: 3px solid #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .filters {
        position: static;
    }
    
    .view-navigation {
        font-size: 0.85rem;
    }
    
    .view-btn {
        padding: 0.5rem 0.8rem;
    }
    
    .comparison-table {
        font-size: 0.85rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .timeline-bar {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .timeline-start,
    .timeline-end {
        text-align: left;
    }
    
    .favorites-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .favorites-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .btn-help {
        width: 100%;
    }
    
    .modal-content {
        max-width: 95%;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
}

/* Improved Info Banner */
.info-banner {
    position: relative;
}

.banner-content {
    flex: 1;
}

.banner-toggle {
    color: #1976d2;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.banner-toggle:hover {
    text-decoration: underline;
}

.banner-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    color: #666;
    font-size: 1.2rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1;
    padding: 0;
}

.banner-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    cursor: pointer;
}

/* Dropdown with checkboxes */
.dropdown-container {
    position: relative;
}

.dropdown-toggle {
    width: 100%;
    padding: 0.5rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    font-size: 0.9rem;
}

.dropdown-toggle:hover {
    border-color: #007bff;
}

.dropdown-arrow {
    transition: transform 0.2s;
}

.dropdown-toggle.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu label {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    cursor: pointer;
    gap: 0.5rem;
    font-weight: normal;
}

.dropdown-menu label:hover {
    background: #f5f5f5;
}

.dropdown-menu input[type="checkbox"] {
    cursor: pointer;
}
