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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #4f5bd5 0%, #962fbf 100%);
    height: 100vh;
    padding: 10px;
    touch-action: manipulation;
    font-size: 16px;
    margin: 0;
    overflow: hidden;
}

.container {
    max-width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.8);
}

header h1 {
    background: linear-gradient(135deg, #4f5bd5 0%, #962fbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.6em;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 20px;
    align-items: center;
}


.main-layout {
    display: grid;
    grid-template-columns: 35% 65%;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.left-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-column {
    overflow: hidden;
    display: flex;
}

.config-section {
    background: linear-gradient(135deg, #ffffff 0%, #fefeff 100%);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}


.config-section.scrollable-section {
    flex: 1;
    overflow-y: auto;
}

.subsection {
    margin-bottom: 12px;
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection h2 {
    margin-bottom: 8px;
    font-size: 1.1em;
}

.subsection .items-list {
    overflow-y: visible;
    max-height: none;
}

.running-section {
    background: linear-gradient(135deg, #ffffff 0%, #fefeff 100%);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.config-section h2, .running-section h2 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -0.3px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.count {
    background: linear-gradient(135deg, #4f5bd5 0%, #962fbf 100%);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1em;
    box-shadow: 0 2px 8px rgba(79, 91, 213, 0.3);
}

.add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.add-form input {
    flex: 1;
    padding: 10px;
    font-size: 0.95em;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.3s;
}

.add-form input:focus {
    border-color: #667eea;
}

.btn-primary, .btn-danger, .btn-success, .btn-warning, .btn-secondary, .btn-export, .btn-import, .btn-add, .btn-suivi {
    padding: 10px 16px;
    font-size: 0.95em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    touch-action: manipulation;
}

.btn-large {
    padding: 10px 16px;
    font-size: 1em;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #4f5bd5 0%, #5b6dd6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 91, 213, 0.3);
}

.btn-primary:active {
    background: linear-gradient(135deg, #3f4bc0 0%, #4b5dc6 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(79, 91, 213, 0.3);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
    font-weight: 700;
}

.btn-warning:active {
    background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.btn-export {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 6px 12px;
    font-size: 0.85em;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-export:active {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-import {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 6px 12px;
    font-size: 0.85em;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-import:active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.btn-add {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
    padding: 6px 14px;
    font-size: 0.9em;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.btn-add:active {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.btn-suivi {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 6px 14px;
    font-size: 0.9em;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.btn-suivi:active {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    padding: 10px 16px;
}

.btn-secondary:active {
    background: #cbd5e0;
    transform: translateY(1px);
}

.btn-danger {
    background: #f56565;
    color: white;
    padding: 6px 10px;
    font-size: 0.85em;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-delete {
    background: transparent;
    border: none;
    color: #cbd5e0;
    font-size: 1.3em;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.3s;
}

.btn-delete:hover {
    color: #f56565;
}

.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-item, .parcours-item {
    background: linear-gradient(135deg, #fafbff 0%, #ffffff 100%);
    border: 2px solid #e8ecf5;
    border-radius: 10px;
    padding: 10px;
    transition: all 0.3s;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.group-item:active {
    transform: scale(0.98);
}

.group-item.selected {
    border: 3px solid #4f5bd5;
    background: linear-gradient(135deg, #eef1ff 0%, #ffffff 100%);
    box-shadow: 0 6px 20px rgba(79, 91, 213, 0.25);
    transform: scale(1.02);
}

.parcours-item {
    cursor: pointer;
    border-style: solid;
    border-width: 3px;
    border-color: #10b981;
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.parcours-item:active {
    transform: scale(0.98);
}

.parcours-item.disabled {
    border-color: #d1d5db;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-name {
    font-size: 1.1em;
    font-weight: 700;
    color: #2d3748;
}

.group-stats {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stats-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stat-badge {
    background: linear-gradient(135deg, #4f5bd5 0%, #5b6dd6 100%);
    color: white;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(79, 91, 213, 0.2);
}

.stat-empty {
    color: #a0aec0;
    font-size: 0.85em;
    font-style: italic;
}

.parcours-history {
    color: #065f46;
    font-size: 0.85em;
    padding: 6px 8px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-radius: 6px;
    border-left: 3px solid #10b981;
    font-weight: 500;
}

.balises-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.balises-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.balises-input {
    width: 56px;
    padding: 4px 6px;
    font-size: 1em;
    font-weight: 700;
    text-align: center;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    color: #2d3748;
}

.balises-input:focus {
    border-color: #4f5bd5;
    box-shadow: 0 0 0 3px rgba(79, 91, 213, 0.1);
}

.balises-denom {
    font-size: 0.9em;
    font-weight: 600;
    color: #6b7280;
}

.course-comment {
    width: 100%;
    height: 52px;
    resize: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.85em;
    font-family: inherit;
    color: #4a5568;
    background: rgba(255, 255, 255, 0.7);
    transition: border-color 0.2s;
}

.course-comment:focus {
    outline: none;
    border-color: #f59e0b;
    background: white;
}

.history-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.history-parcours-name {
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-balises-input {
    width: 44px;
    padding: 2px 4px;
    font-size: 0.82em;
    font-weight: 700;
    text-align: center;
    border: 1px dashed #a7f3d0;
    border-radius: 4px;
    color: #065f46;
    background: transparent;
    outline: none;
    flex-shrink: 0;
}

.history-balises-input:focus {
    border-color: #10b981;
    background: white;
}

.history-balises-denom {
    font-size: 0.8em;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
    margin-right: 2px;
}

.history-comment-input {
    flex: 1;
    min-width: 0;
    border: 1px dashed #a7f3d0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.82em;
    font-family: inherit;
    color: #4a5568;
    background: transparent;
    outline: none;
}

.history-comment-input:focus {
    border-color: #10b981;
    background: white;
}

.parcours-info {
    margin-top: 4px;
    font-size: 0.82em;
    color: #065f46;
    font-weight: 600;
}

.parcours-item.disabled .parcours-info {
    color: #9ca3af;
}

.parcours-hint {
    margin-top: 6px;
    text-align: center;
    color: #059669;
    font-size: 0.85em;
    font-weight: 700;
}

.parcours-item.disabled .parcours-hint {
    color: #a0aec0;
    font-style: italic;
    font-weight: 400;
}

.running-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    align-content: start;
}

.running-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 100%);
    border: 2px solid #10b981;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.running-card.overtime {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 3px solid #ef4444;
    animation: pulse-warning 1.5s ease-in-out infinite;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

@keyframes pulse-warning {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 101, 101, 0.7);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(245, 101, 101, 0);
    }
}

.running-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.running-group {
    font-size: 1.1em;
    font-weight: 700;
    color: #2d3748;
    line-height: 1.2;
}

.running-parcours {
    display: inline-block;
    background: linear-gradient(135deg, #4f5bd5 0%, #5b6dd6 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 700;
    align-self: flex-start;
    box-shadow: 0 2px 6px rgba(79, 91, 213, 0.3);
}

.running-timer {
    font-size: 2em;
    font-weight: 700;
    color: #10b981;
    font-family: 'Courier New', monospace;
    text-align: center;
    padding: 5px 0;
    text-shadow: 0 2px 4px rgba(16, 185, 129, 0.1);
}

.running-card.overtime .running-timer {
    color: #ef4444;
    text-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

.warning-icon {
    font-size: 1.2em;
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.overtime-message {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9em;
    font-weight: 700;
    animation: blink 1s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.empty-state {
    text-align: center;
    color: #a0aec0;
    font-size: 0.95em;
    padding: 20px;
    grid-column: 1 / -1;
}

.empty-state small {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
}

/* ===== SUIVI ===== */

.modal-suivi {
    max-width: 95vw;
    width: 95vw;
    max-height: 90vh;
}

.suivi-content {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    max-height: calc(90vh - 40px);
}

.suivi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.suivi-header h2 {
    font-size: 1.4em;
    font-weight: 800;
    background: linear-gradient(135deg, #4f5bd5 0%, #962fbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.suivi-header-actions {
    display: flex;
    gap: 8px;
}

.suivi-table-container {
    flex: 1;
    overflow-y: auto;
}

.suivi-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.suivi-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.suivi-table th {
    background: linear-gradient(135deg, #4f5bd5 0%, #5b6dd6 100%);
    color: white;
    padding: 10px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: 0.3px;
}

.suivi-table th:first-child {
    border-radius: 8px 0 0 8px;
}

.suivi-table th:last-child {
    border-radius: 0 8px 8px 0;
}

.suivi-table tbody tr {
    border-bottom: 1px solid #e8ecf5;
    transition: background 0.15s;
}

.suivi-table tbody tr:hover {
    background: #f5f7ff;
}

.suivi-table td {
    padding: 10px 14px;
    color: #2d3748;
}

.suivi-name {
    font-weight: 700;
    font-size: 1em;
}

.suivi-center {
    text-align: center;
    font-weight: 600;
}

.suivi-pct {
    font-weight: 800;
    font-size: 1.05em;
}

.pct-good {
    color: #059669;
}

.pct-medium {
    color: #d97706;
}

.pct-bad {
    color: #dc2626;
}

.suivi-en-temps {
    color: #059669;
    font-weight: 700;
}

.suivi-hors-temps {
    color: #dc2626;
    font-weight: 700;
}

/* ===== SUIVI ONGLETS ===== */

.suivi-tabs {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    border-bottom: 2px solid #e8ecf5;
    padding-bottom: 0;
}

.suivi-tab {
    padding: 8px 18px;
    font-size: 0.9em;
    font-weight: 600;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    background: #f1f3f9;
    color: #4a5568;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
    border: 2px solid transparent;
    border-bottom: none;
}

.suivi-tab.active {
    background: white;
    color: #4f5bd5;
    border-color: #e8ecf5;
    border-bottom-color: white;
    font-weight: 700;
}

/* ===== MODAL ÉLÈVES ===== */

.modal-eleves-content {
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.eleves-format-hint {
    font-size: 0.85em;
    color: #6b7280;
    margin: 0;
}

.eleves-format-hint code {
    background: #f1f3f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #4f5bd5;
}

.modal-actions-top {
    justify-content: flex-start;
}

.eleves-list {
    overflow-y: auto;
    flex: 1;
    max-height: 50vh;
}

.eleves-classe-group {
    margin-bottom: 12px;
}

.eleves-classe-header {
    font-size: 0.85em;
    font-weight: 700;
    color: #4f5bd5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 0;
    border-bottom: 1px solid #e8ecf5;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.eleves-classe-count {
    font-weight: 400;
    color: #9ca3af;
    text-transform: none;
    letter-spacing: 0;
}

.eleve-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 4px;
    font-size: 0.9em;
    border-radius: 4px;
    transition: background 0.15s;
}

.eleve-item:hover {
    background: #f5f7ff;
}

/* ===== CHECKLIST ÉLÈVES (modal groupe) ===== */

.eleves-checklist-label {
    font-size: 0.9em;
    font-weight: 600;
    color: #4a5568;
    display: block;
    margin-bottom: 6px;
}

.eleves-checklist {
    max-height: 200px;
    overflow-y: auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    background: #fafbff;
}

.checklist-classe {
    margin-bottom: 8px;
}

.checklist-classe:last-child {
    margin-bottom: 0;
}

.checklist-classe-header {
    font-size: 0.78em;
    font-weight: 700;
    color: #4f5bd5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #e8ecf5;
}

.checklist-eleve {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.15s;
}

.checklist-eleve:hover {
    background: #eef1ff;
}

.checklist-eleve input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4f5bd5;
    flex-shrink: 0;
}

/* ===== MODALS ===== */

dialog {
    border: none;
    border-radius: 16px;
    padding: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90vw;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-content h2 {
    font-size: 1.3em;
    font-weight: 800;
    background: linear-gradient(135deg, #4f5bd5 0%, #962fbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-form label {
    font-size: 0.9em;
    font-weight: 600;
    color: #4a5568;
}

.modal-form input {
    padding: 10px 12px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.modal-form input:focus {
    border-color: #4f5bd5;
    box-shadow: 0 0 0 3px rgba(79, 91, 213, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .left-column {
        order: 2;
    }

    .right-column {
        order: 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .running-container {
        grid-template-columns: 1fr;
    }

    .main-layout {
        gap: 15px;
    }
}
