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

:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --sidebar-bg: #1e1b4b;
    --sidebar-width: 250px;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f3f4f6;
    --white: #ffffff;
    --border: #e5e7eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--white);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    padding: 1.5rem 0;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-header span {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
}

.sidebar-nav a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page {
    padding: 2rem;
}

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

.card {
    background: var(--white);
    border-radius: 0.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-link:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

.card h3 {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: var(--sidebar-bg);
}

.card-sub {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.dashboard-section {
    margin-top: 2rem;
}

.dashboard-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.empty-state {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
}

.empty-state a {
    color: var(--primary);
}

.login-container {
    display: flex;
    justify-content: center;
    padding-top: 4rem;
}

.login-form {
    background: var(--white);
    padding: 2rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
}

.login-form h2 {
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.error-page {
    text-align: center;
    padding-top: 4rem;
}

.error-page h2 {
    font-size: 4rem;
    color: var(--text-light);
}

.error-page p {
    margin: 1rem 0 2rem;
    color: var(--text-light);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.alert ul {
    margin: 0;
    padding-left: 1.25rem;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Module header */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-form input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    min-width: 300px;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Table */
.table-container {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

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

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.875rem;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f9fafb;
}

.text-center {
    text-align: center;
}

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

.inline-form {
    display: inline;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #ecfdf5;
    color: #065f46;
}

.badge-danger {
    background: #fef2f2;
    color: #991b1b;
}

/* Buttons */
.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: #dc2626;
    color: var(--white);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Forms */
.module-form {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 700px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    max-height: 300px;
    overflow-y: auto;
}

.checkbox-card {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.checkbox-card:hover {
    border-color: #a78bfa;
    background: #faf5ff;
}

.checkbox-card:has(input:checked) {
    border-color: #7c3aed;
    background: #f5f3ff;
}

.checkbox-card input[type="checkbox"] {
    width: auto;
    margin-top: 3px;
    flex-shrink: 0;
}

.checkbox-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.8125rem;
    line-height: 1.3;
}

.checkbox-card-content strong {
    font-size: 0.875rem;
    color: #1f2937;
}

.checkbox-card-content small {
    color: #6b7280;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Select & Textarea */
.select-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: var(--white);
    color: var(--text);
}

.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-form .select-input {
    width: auto;
    min-width: 160px;
}

.textarea-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: vertical;
}

.textarea-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-sm {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.8125rem;
}

.input-sm:focus {
    outline: none;
    border-color: var(--primary);
}

.input-sm:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

/* Badge filière */
.badge-filiere {
    background: #eef2ff;
    color: #3730a3;
}

.badge-type {
    background: #fef3c7;
    color: #92400e;
}

.badge-warning {
    background: #fffbeb;
    color: #b45309;
}

/* Text link */
.text-link {
    color: var(--primary);
    font-size: 0.75rem;
    text-decoration: none;
}

.text-link:hover {
    text-decoration: underline;
}

/* Form hint */
.form-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.375rem;
}

.form-hint a {
    color: var(--primary);
}

/* Row selected */
.row-selected td {
    background: #f0fdf4;
}

/* Text muted */
.text-muted {
    color: var(--text-light);
    font-size: 0.875rem;
}

/* Filière + Seuil rows */
.filiere-seuil-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.filiere-seuil-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-light, #f9fafb);
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.seuil-input-wrap {
    flex-shrink: 0;
    width: 110px;
}
.seuil-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    background: #fff;
    transition: opacity 0.15s;
}
.seuil-input:disabled {
    opacity: 0.35;
    background: #f3f4f6;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 0.375rem;
    margin-top: 1.5rem;
    justify-content: center;
}
