/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0f1a;
  --bg2:      #131629;
  --bg3:      #1a1f38;
  --bg4:      #222745;
  --border:   #2a3155;
  --accent:   #4f73ff;
  --accent2:  #7c3aed;
  --success:  #22c55e;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --radius:   10px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
  --font:     'Inter', system-ui, sans-serif;
  --mono:     'JetBrains Mono', monospace;
}

body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: .75rem 1rem; flex-wrap: wrap;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem; box-shadow: var(--shadow);
}

.header-logo {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.1rem; color: var(--accent);
  white-space: nowrap;
}
.header-logo svg { width: 22px; height: 22px; }

.tabs {
  display: flex; gap: .25rem; flex: 0 0 100%; order: 3;
  overflow-x: auto; padding-top: .15rem;
}
.tab {
  padding: .5rem 1.1rem; border: none; background: transparent;
  color: var(--text2); cursor: pointer; border-radius: 7px;
  font-size: .875rem; font-family: var(--font); font-weight: 500;
  transition: all .2s; white-space: nowrap;
}
.tab:hover { background: var(--bg3); color: var(--text); }
.tab.active { background: var(--accent); color: #fff; }

.badge-stat { font-size: .8rem; color: var(--text3); font-family: var(--mono); }

/* ===== MAIN ===== */
.main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.section-header h2 { font-size: 1.4rem; font-weight: 700; }
.subtitle { color: var(--text2); font-size: .875rem; margin-top: .2rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border: none; border-radius: 7px;
  font-family: var(--font); font-size: .875rem; font-weight: 600;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(.95); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg4); color: var(--text); border: 1px solid var(--border); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-large    { padding: .7rem 1.6rem; font-size: 1rem; }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-group { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ===== INPUTS ===== */
.input-search, input[type="text"], input[type="date"], input[type="number"],
select, textarea {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: .45rem .75rem;
  font-family: var(--font); font-size: .875rem; outline: none;
  transition: border-color .2s;
}
.input-search, input[type="text"], input[type="date"], input[type="number"] {
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.select-sm { width: auto; }
option { background: var(--bg2); }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  background: var(--bg3); color: var(--text2); font-weight: 600;
  padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }


/* Tableau Élèves : garder la ligne des libellés visible pendant le défilement */
#tab-eleves .sticky-table-wrapper {
  max-height: calc(100vh - 245px);
  min-height: 320px;
  overflow: auto;
  position: relative;
}

#eleves-table {
  border-collapse: separate;
  border-spacing: 0;
}

#eleves-table thead th {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg3);
  box-shadow: 0 1px 0 var(--border), 0 4px 10px rgba(0,0,0,.25);
}

@media (max-height: 720px) {
  #tab-eleves .sticky-table-wrapper {
    max-height: calc(100vh - 210px);
  }
}

/* Niveau badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: .8rem; font-weight: 700; font-family: var(--mono);
}
.badge-A { background: #166534; color: #86efac; }
.badge-B { background: #1e3a5f; color: #7dd3fc; }
.badge-C { background: #3b2a00; color: #fcd34d; }
.badge-D { background: #431407; color: #fdba74; }
.badge-E { background: #3b0a0a; color: #fca5a5; }
.badge-none { background: var(--bg4); color: var(--text3); }

.badge-sexe-M { background: #1e3a5f; color: #7dd3fc; padding: 2px 8px; border-radius: 4px; font-size: .8rem; }
.badge-sexe-F { background: #3b1a5e; color: #d8b4fe; padding: 2px 8px; border-radius: 4px; font-size: .8rem; }

.icon-lock { font-size: 1rem; cursor: pointer; transition: opacity .2s; }
.icon-lock:hover { opacity: .7; }

.chip-class {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: .8rem; background: var(--accent); color: #fff; font-family: var(--mono);
}

/* ===== CLASSES GRID ===== */
.classes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1rem; }

.class-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; transition: border-color .2s;
}
.class-card:hover { border-color: var(--accent); }
.class-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.class-card-name { font-size: 1.2rem; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.class-card-badge { font-size: .8rem; color: var(--text2); background: var(--bg3); padding: 2px 8px; border-radius: 4px; }
.class-meta { color: var(--text2); font-size: .85rem; margin-bottom: .75rem; }
.class-meta span { margin-right: .75rem; }
.progress-bar { background: var(--bg4); border-radius: 4px; height: 8px; overflow: hidden; margin: .5rem 0; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .4s; }
.progress-fill.full { background: var(--danger); }
.class-stats { display: flex; gap: 1rem; font-size: .8rem; color: var(--text2); }
.class-card-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.restriction-tag { font-size: .75rem; background: var(--danger); color: #fff; padding: 1px 6px; border-radius: 3px; }

/* ===== GROUPES LIST ===== */
.groupes-list { display: grid; gap: .75rem; }
.groupe-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; display: flex; align-items: center; gap: 1rem;
}
.groupe-type-badge { padding: 4px 12px; border-radius: 5px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.groupe-type-regrouper { background: #14532d; color: #86efac; }
.groupe-type-separer   { background: #450a0a; color: #fca5a5; }
.groupe-name { font-weight: 600; flex: 1; }
.groupe-count { color: var(--text2); font-size: .85rem; }
.groupe-actions { display: flex; gap: .5rem; }

/* ===== RÉPARTITION PANEL ===== */
.repartition-layout { display: grid; grid-template-columns: 1fr 350px; gap: 1.5rem; }
@media (max-width: 900px) { .repartition-layout { grid-template-columns: 1fr; } }

.criteria-panel { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.criteria-panel h3 { margin-bottom: .3rem; }
.criteria-footer { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.hint { font-size: .82rem; color: var(--text2); margin-bottom: 1rem; }

.criterion-item {
  display: flex; align-items: center; gap: 1rem;
  padding: .65rem 0; border-bottom: 1px solid var(--border);
}
.criterion-item:last-child { border-bottom: none; }
.criterion-toggle { flex-shrink: 0; }
.criterion-label { flex: 1; font-size: .9rem; font-weight: 500; }
.criterion-label small { display: block; color: var(--text3); font-size: .78rem; font-weight: 400; }
.criterion-action select { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 5px; padding: 3px 6px; font-size: .8rem; }
.criterion-weight { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.criterion-weight input[type="range"] { width: 80px; accent-color: var(--accent); cursor: pointer; }
.criterion-weight-val { font-family: var(--mono); font-size: .85rem; color: var(--accent); width: 20px; text-align: center; }
.criterion-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .criterion-item { align-items: flex-start; flex-wrap: wrap; }
  .criterion-label { flex-basis: calc(100% - 52px); }
  .criterion-actions { width: 100%; justify-content: flex-start; }
}

/* Toggle switch */
.toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--bg4); border-radius: 20px; transition: .2s; border: 1px solid var(--border); }
.toggle-slider::before { content:''; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: var(--text3); border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ===== INFO CARDS ===== */
.repartition-info { display: flex; flex-direction: column; gap: 1rem; }
.info-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.info-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.info-card h4 { margin-bottom: .5rem; font-size: 1rem; }
.info-card ol, .info-card p { color: var(--text2); font-size: .875rem; }
.info-card ol { padding-left: 1.2rem; }
.info-card li { margin-bottom: .3rem; }

/* ===== RESULTS ===== */
.placeholder { text-align: center; padding: 4rem 1rem; color: var(--text2); font-size: 1rem; }

.results-overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.result-class-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; cursor: grab;
}
.result-class-card.drag-over { border-color: var(--accent); background: var(--bg3); }
.result-class-name { font-size: 1.1rem; font-weight: 700; color: var(--accent); font-family: var(--mono); margin-bottom: .5rem; }
.result-stats-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: .4rem 0; font-size: .82rem; }
.result-stat { background: var(--bg4); padding: 2px 8px; border-radius: 4px; color: var(--text2); }
.result-stat.ok { color: var(--success); }
.result-stat.warn { color: var(--warning); }
.level-bar { display: flex; height: 16px; border-radius: 4px; overflow: hidden; margin: .4rem 0; }
.level-seg { display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: rgba(255,255,255,.8); }
.level-seg.A { background: #166534; } .level-seg.B { background: #1e40af; }
.level-seg.C { background: #92400e; } .level-seg.D { background: #c2410c; } .level-seg.E { background: #991b1b; }
.level-seg.none { background: var(--bg4); color: var(--text3); }

.result-eleve-list { max-height: 250px; overflow-y: auto; margin-top: .5rem; }
.result-eleve-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .5rem; border-radius: 5px; font-size: .83rem;
  cursor: grab; transition: background .15s;
}
.result-eleve-item:hover { background: var(--bg3); }
.result-eleve-item.locked { opacity: .6; cursor: not-allowed; }
.eleve-drag-icon { color: var(--text3); font-size: .8rem; }

.charts-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.chart-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.chart-card h4 { margin-bottom: 1rem; font-size: .95rem; color: var(--text2); }

.errors-panel { background: #2a0a0a; border: 1px solid #7f1d1d; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.errors-panel h4 { color: var(--danger); margin-bottom: .5rem; }
.errors-panel li { font-size: .85rem; color: #fca5a5; }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  animation: fadeIn .15s;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 660px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.15rem; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 1.2rem; cursor: pointer; padding: .25rem .5rem; border-radius: 5px; }
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: .82rem; font-weight: 500; color: var(--text2); }
.checkbox-label { display: flex; align-items: center; gap: .5rem; flex-direction: row; cursor: pointer; color: var(--text); }
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* Chips */
.chips-container { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 32px; padding: .4rem; background: var(--bg3); border-radius: 7px; border: 1px solid var(--border); }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: 3px 8px; background: var(--bg4); border: 1px solid var(--border); border-radius: 5px; font-size: .82rem; }
.chip-remove { cursor: pointer; color: var(--danger); background: none; border: none; padding: 0; line-height: 1; font-size: 1rem; }
.chip-remove:hover { opacity: .7; }

/* ===== ALERTS ===== */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem; }
.alert-warning { background: #2a1a00; border: 1px solid #92400e; color: #fcd34d; }
.alert-success { background: #052e16; border: 1px solid #166534; color: #86efac; }
.alert-info { background: #0f172a; border: 1px solid #334155; color: #cbd5e1; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  padding: .8rem 1.4rem; border-radius: 9px; font-size: .9rem; font-weight: 500;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  box-shadow: var(--shadow); transform: translateY(100px); opacity: 0;
  transition: all .3s; pointer-events: none;
}
.toast.show { transform: none; opacity: 1; }
.toast.success { background: #052e16; border-color: var(--success); color: #86efac; }
.toast.error   { background: #2a0a0a; border-color: var(--danger); color: #fca5a5; }

/* ===== MISC ===== */
.mt-1  { margin-top: 1rem; }
.mt-05 { margin-top: .5rem; }
.text-muted { color: var(--text3); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
}
.loading-big { width: 48px; height: 48px; border-width: 4px; }

/* ===== IMPORT ===== */
.import-layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .import-layout { grid-template-columns: 1fr; } }
.import-panel, .import-help-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem;
}
.import-panel h3, .import-help-card h3 { margin-bottom: 1rem; }
.import-columns { display: flex; flex-wrap: wrap; gap: .4rem; }
.import-example pre {
  margin-top: .5rem; padding: .75rem; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text2); overflow-x: auto; font-family: var(--mono); font-size: .78rem;
}
.import-notes { color: var(--text2); font-size: .85rem; padding-left: 1.2rem; margin-top: .75rem; }
.import-notes li { margin-bottom: .25rem; }
.import-result { margin-top: 1rem; border-radius: 8px; padding: 1rem; font-size: .875rem; }
.import-result.success { background: #052e16; border: 1px solid #166534; color: #bbf7d0; }
.import-result.warning { background: #2a1a00; border: 1px solid #92400e; color: #fde68a; }
.import-result.error { background: #2a0a0a; border: 1px solid #7f1d1d; color: #fecaca; }
.import-result h4 { margin-bottom: .5rem; }
.import-stats { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .75rem; }
.import-stats span { background: rgba(255,255,255,.06); border-radius: 5px; padding: 4px 8px; }
.import-result details { margin-top: .75rem; }
.import-result ul { padding-left: 1.2rem; margin-top: .5rem; }

/* Critères éditables */
.criterion-name-input {
  width: 100%; padding: .35rem .5rem; font-size: .9rem; font-weight: 600;
  background: var(--bg3); border: 1px solid transparent; border-radius: 6px;
}
.criterion-name-input:hover, .criterion-name-input:focus { border-color: var(--border); }
.criterion-label code { color: var(--text3); font-family: var(--mono); }
input[type="file"] {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  border-radius: 7px; padding: .45rem .75rem; font-family: var(--font); font-size: .875rem;
}
input[type="file"]::file-selector-button {
  margin-right: .75rem; border: none; border-radius: 6px; padding: .35rem .7rem;
  background: var(--bg4); color: var(--text); font-family: var(--font); cursor: pointer;
}

.result-adjust-note { margin-bottom: 1rem; }

/* Classe affectée dans la page Élèves */
.select-classe-affectee {
  min-width: 130px;
  max-width: 170px;
}

/* ===== PAGE MEF ===== */
#mef-table code {
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
}
.modal-small { max-width: 520px; }

/* ===== AUTH / UTILISATEURS ===== */
.header-actions { display: flex; align-items: center; gap: .75rem; flex: 1; flex-wrap: wrap; justify-content: flex-end; }
.user-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .6rem; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; font-size: .8rem; color: var(--text);
}
.user-badge small { color: var(--text3); font-size: .72rem; text-transform: uppercase; }

.auth-page {
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background: radial-gradient(circle at top, #1f2a55 0, var(--bg) 42%, #080a12 100%);
}
.auth-shell { width: 100%; max-width: 460px; }
.auth-card {
  background: rgba(19, 22, 41, .95); border: 1px solid var(--border);
  border-radius: 18px; padding: 1.6rem; box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.4rem; }
.auth-logo-icon {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); border-radius: 14px; font-size: 1.4rem;
}
.auth-logo h1 { font-size: 1.35rem; color: var(--text); }
.auth-logo p { color: var(--text2); font-size: .9rem; margin-top: .1rem; }
.auth-form { display: flex; flex-direction: column; gap: .9rem; }
.auth-message { margin-top: 1rem; padding: .75rem 1rem; border-radius: 8px; font-size: .875rem; }
.auth-message.error, .alert-error { background: #2a0a0a; border: 1px solid #7f1d1d; color: #fecaca; }
.auth-help {
  margin-top: 1.2rem; padding: .85rem; border-radius: 10px;
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2); font-size: .85rem; line-height: 1.5;
}
.auth-help code { color: var(--text); font-family: var(--mono); }
.full-width { width: 100%; justify-content: center; }
input[type="email"], input[type="password"], input[type="tel"] {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 7px; padding: .45rem .75rem;
  font-family: var(--font); font-size: .875rem; outline: none;
}
input[type="email"]:focus, input[type="password"]:focus, input[type="tel"]:focus { border-color: var(--accent); }
.role-badge, .badge-mini {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; border: 1px solid var(--border);
}
.role-admin { background: #2d1b69; color: #ddd6fe; border-color: #6d28d9; }
.role-utilisateur { background: #0f172a; color: #cbd5e1; }
.badge-mini { background: var(--bg4); color: var(--text2); margin-left: .35rem; }
.status-ok { color: #86efac; font-weight: 600; }
.status-off { color: #fca5a5; font-weight: 600; }
.hint-inline { color: var(--text3); font-size: .75rem; font-weight: 400; }

/* ===== MAINTENANCE BASE ===== */
.maintenance-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 1rem;
}
.maintenance-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.maintenance-card h3 { margin-bottom: .45rem; }
.maintenance-stats {
  margin-top: .9rem;
  display: grid;
  gap: .45rem;
}
.maintenance-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg3);
}
.maintenance-stat-row span { color: var(--text2); }
.maintenance-stat-row strong { font-family: var(--mono); color: var(--text); }
.danger-zone {
  border-color: rgba(239, 68, 68, .55);
  background: linear-gradient(180deg, rgba(127, 29, 29, .28), var(--bg2));
}
.danger-zone h3 { color: #fecaca; }

.maintenance-delete-options {
  display: grid;
  gap: .55rem;
  margin: 1rem 0;
}
.maintenance-delete-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
  padding: .7rem;
  border: 1px solid rgba(248, 113, 113, .28);
  border-radius: 10px;
  background: rgba(15, 23, 42, .55);
  cursor: pointer;
}
.maintenance-delete-option input { width: 18px; height: 18px; }
.maintenance-delete-option strong { display: block; color: var(--text); }
.maintenance-delete-option small { display: block; margin-top: .15rem; color: var(--text3); line-height: 1.35; }
.maintenance-delete-option em {
  min-width: 2.6rem;
  padding: .2rem .45rem;
  border-radius: 999px;
  text-align: center;
  font-style: normal;
  font-family: var(--mono);
  color: #fecaca;
  background: rgba(127, 29, 29, .55);
}
.maintenance-actions { margin-bottom: .75rem; }
.loading-inline { color: var(--text2); padding: .5rem 0; }

@media (max-width: 900px) {
  .maintenance-grid { grid-template-columns: 1fr; }
}

/* ===== RÉPARTITION PAR NIVEAU ===== */
.level-action-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.level-selector {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 220px;
}
.level-selector label {
  color: var(--text2);
  font-size: .78rem;
  font-weight: 600;
}
.level-selector select {
  width: 100%;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  outline: none;
}
.level-selector select:focus { border-color: var(--accent); }

/* Diagnostic base / répartition */
.maintenance-diagnostic-card {
  grid-column: 1 / -1;
}
.maintenance-diagnostic {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.diagnostic-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: .85rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
}
.diagnostic-summary.success {
  background: rgba(34,197,94,.12);
  color: #bbf7d0;
}
.diagnostic-summary.warning {
  background: rgba(245,158,11,.12);
  color: #fde68a;
}
.diagnostic-table-wrapper {
  max-height: 360px;
  overflow: auto;
}
.diagnostic-table td,
.diagnostic-table th {
  white-space: nowrap;
}
.diagnostic-issue {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: .75rem 1rem;
}
.diagnostic-issue summary {
  cursor: pointer;
  font-weight: 700;
}
.diagnostic-issue ul {
  margin: .75rem 0 0 1.1rem;
  padding: 0;
}
.diagnostic-issue li {
  margin-bottom: .5rem;
}
.diagnostic-issue small {
  display: block;
  color: var(--muted);
  margin-top: .15rem;
}
.badge-danger {
  background: rgba(239,68,68,.18);
  color: #fecaca;
  border-color: rgba(239,68,68,.35);
}

/* Édition directe dans la page Élèves */
.eleve-name-cell { min-width: 190px; }
.eleve-name-inline { display: flex; flex-direction: column; gap: .25rem; }
.inline-eleve-input,
.inline-eleve-select {
  width: 100%;
  min-height: 30px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: .28rem .45rem;
  font-family: var(--font);
  font-size: .8rem;
}
.inline-eleve-input:focus,
.inline-eleve-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79,115,255,.16);
}
.inline-eleve-name { min-width: 82px; }
.inline-eleve-mef { min-width: 145px; max-width: 220px; }
.inline-eleve-level { min-width: 54px; }
.inline-eleve-classe-actuelle { min-width: 82px; font-family: var(--mono); }
.inline-check-cell { text-align: center; }
.inline-eleve-check { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; color: var(--text2); }
.inline-eleve-check input { accent-color: var(--accent); }

.pin-hint { color: var(--text3); font-size: .78rem; margin-top: .25rem; }

.pin-visible {
  display: inline-block;
  padding: 0.18rem 0.45rem;
  border-radius: 0.45rem;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.25);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
}

.role-badge.role-visiteur { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }
.role-badge.role-niveau { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
