* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
    font-size: 2.5rem;
}

.version-badge {
    display: inline-block;
    background: #4CAF50;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    margin-left: 10px;
}

.upload-section {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    margin-bottom: 30px;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-label {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.file-input-label:hover {
    transform: scale(1.05);
}

.simulate-btn {
    padding: 12px 40px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 20px;
    transition: transform 0.3s ease;
}

.simulate-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.simulate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.download-btn {
    padding: 10px 25px;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    margin: 5px;
    transition: transform 0.3s ease;
}

.download-btn:hover {
    transform: scale(1.05);
}

.api-url-input {
    margin-top: 20px;
    padding: 10px;
    width: 100%;
    max-width: 400px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.charts-container {
    display: grid;
    gap: 30px;
    margin-top: 30px;
}

.chart-wrapper {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.chart-title {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 15px;
    font-weight: bold;
}

#mainDiagram,
#speedProfile,
#individualDiagram,
#incidentDiagram,
#incidentSpeedProfile {
    height: 400px !important;
}

.train-selector {
    margin: 20px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.selector-label {
    font-weight: bold;
    color: #666;
    margin-right: 10px;
}

.train-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.train-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.train-btn.active {
    background: #667eea;
    color: white;
}

.statistics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
}

.stat-unit {
    font-size: 0.8rem;
    opacity: 0.8;
}

.loading {
    display: none;
    text-align: center;
    margin: 20px 0;
}

.loading.active {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.info-text {
    background: #e3f2fd;
    color: #1976d2;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
}

#linkViewerSection {
    margin-top: 40px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    display: none;
}

.link-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.link-trains {
    margin-top: 30px;
}

.link-train-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.link-train-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.link-stops-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.link-stop-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    font-size: 12px;
}

.link-stop-item:hover {
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.link-stop-item.has-link {
    background: #e8f5e9;
    border-color: #4caf50;
}

.link-stop-item.no-link {
    opacity: 0.6;
}

.stop-position {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.stop-link-id {
    color: #666;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dwell-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ff9800;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
}

#eventSelectPanel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 320px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.25);
    padding: 20px;
    z-index: 1000;
}

#eventSelectPanel h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.event-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.file-name {
    margin-top: 15px;
    color: #666;
}