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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

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

section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

h2 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 1.5em;
    font-weight: 600;
}

/* Import Section */
.import-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.import-area:hover {
    border-color: var(--primary-color);
    background-color: #f1f5f9;
}

#fileInput {
    display: none;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.file-label:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.9em;
    margin-bottom: 10px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.status-badge.definitive {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
}

.help-panel {
    margin-top: 15px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    color: #0f172a;
}

.help-panel ol {
    padding-left: 16px;
    margin: 8px 0 0 0;
}

.help-panel li {
    margin-bottom: 6px;
    line-height: 1.4;
}

.file-list {
    margin-top: 20px;
    text-align: left;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background-color: #f1f5f9;
    border-radius: 6px;
    margin-bottom: 8px;
}

.file-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-item-remove:hover {
    background-color: #fee2e2;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

/* Filters */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.filter-group select,
.filter-group input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.discipline-group {
    margin-bottom: 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.discipline-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 15px 20px;
    font-size: 1.2em;
    font-weight: 600;
}

.discipline-table {
    width: 100%;
    border-collapse: collapse;
}

.discipline-table thead {
    background-color: #f8fafc;
}

.discipline-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.discipline-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.discipline-table tbody tr:hover {
    background-color: #f8fafc;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9em;
}

.rank-1 {
    background-color: #ffd700;
    color: #854d0e;
}

.rank-2 {
    background-color: #c0c0c0;
    color: #3f3f46;
}

.rank-3 {
    background-color: #cd7f32;
    color: white;
}

.rank-other {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.rank-nc {
    background-color: #f1f5f9;
    color: #64748b;
    border: 2px dashed #cbd5e1;
    font-style: italic;
}

.performance {
    font-weight: 600;
    color: var(--primary-color);
}

.total-points {
    font-weight: 700;
    font-size: 1.1em;
    color: var(--success-color);
}

/* Stats */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Print Styles */
@media print {
    body {
        background-color: white;
    }

    .import-section,
    .filter-section,
    .btn,
    footer {
        display: none !important;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    section {
        box-shadow: none;
        page-break-inside: avoid;
    }

    .discipline-group {
        page-break-inside: avoid;
        margin-bottom: 30px;
    }

    header {
        background: none;
        color: var(--text-primary);
        box-shadow: none;
        border-bottom: 3px solid var(--primary-color);
    }
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
    }

    .discipline-table {
        font-size: 0.9em;
    }

    .discipline-table th,
    .discipline-table td {
        padding: 8px;
    }
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 1.1em;
}
