/* Notation des rendus — encre marine, stylo rouge du correcteur. */
:root {
  --bg: #e9edf2;
  --card: #ffffff;
  --ink: #14213d;
  --ink2: #3d4a63;
  --muted: #6c7689;
  --line: #d6dde6;
  --line2: #eaeef3;
  --red: #e63946;
  --red-dark: #c1272d;
  --blue: #2757a3;
  --green: #1f7a4a;
  --h0: #fbdcdc; --h1: #fdebd2; --h2: #e3f0dc; --h3: #cfe9da;
  --font: -apple-system, BlinkMacSystemFont, "Avenir Next", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-lg: 14px; --r-sm: 8px;
  --top-h: 58px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font); font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 1.65rem; line-height: 1.2; }
h2 { font-size: 1.12rem; margin: 30px 0 10px; }
h3 { font-size: 1rem; }
button, .btn, .box, .icon { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(39, 87, 163, .35); outline-offset: 2px; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Barre supérieure ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--ink); color: #fff;
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 9px; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--red); font-size: 16px; font-weight: 800; }
nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav a { color: #b9c3d6; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 600; }
nav a:hover { color: #fff; text-decoration: none; }
nav a.on { color: #fff; box-shadow: inset 0 -3px 0 var(--red); border-radius: 0; }
.sync { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .8rem; cursor: pointer; white-space: nowrap; background: rgba(255,255,255,.1); color: #fff; }
.sync::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: #7dd3a0; vertical-align: 1px; }
.sync.off::before { background: #9aa4b5; }
.sync.warn::before { background: #f4b740; }
.sync.busy::before { background: #7fb2ff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .sync.busy::before { animation: none; } }
.top .icon { color: #fff; font-size: 1.25rem; }
.top .icon:hover { background: rgba(255,255,255,.1); }

main { max-width: 1440px; margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-left)) 70px; }

/* ---------- Éléments génériques ---------- */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.back { display: inline-block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; }
.card + .card { margin-top: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.stack { display: grid; gap: 8px; }
.muted { color: var(--muted); }
small { font-size: .8em; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 30px 16px !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.btn:hover { border-color: #b9c4d2; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #1f3159; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger { color: var(--red-dark); border-color: #f2c4c7; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.icon { border: 0; background: none; cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: 8px; color: var(--ink2); min-width: 36px; min-height: 36px; }
.icon:hover { background: var(--line2); }
.icon.danger { color: var(--red-dark); }
.icon:disabled { opacity: .25; cursor: default; background: none; }

input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 10px; min-height: 40px; width: 100%;
}
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--ink); }
textarea { resize: vertical; min-height: 60px; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(39,87,163,.15); }
label { display: block; }

/* ---------- Tableaux ---------- */
.tablewrap { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl th, .tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: middle; }
.tbl thead th { font-size: .8rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl tr.filters th { padding: 4px 6px 10px; }
.tbl tr.filters input, .tbl tr.filters select { min-height: 34px; padding: 4px 8px; font-size: .85rem; font-weight: 400; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.rows-link tbody tr[data-act] { cursor: pointer; }
.rows-link tbody tr[data-act]:hover td { background: #f5f8fb; }
.tbl td.actions-cell { text-align: right; white-space: nowrap; }
.tbl tfoot td, .tbl tfoot th { border-top: 2px solid var(--ink); font-weight: 700; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.st-futur { background: #e6ebf2; color: #4a5670; }
.st-acorriger { background: #fde8c8; color: #8a560b; }
.st-encours { background: #dde8fa; color: #1f4b95; }
.st-termine { background: #d8efe1; color: #1c6440; }

.prog { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: .85rem; }
.prog i { display: block; width: 70px; height: 6px; border-radius: 3px; background: var(--line2); overflow: hidden; }
.prog i b { display: block; height: 100%; background: var(--ink); }

.h0 { background: var(--h0); } .h1 { background: var(--h1); } .h2 { background: var(--h2); } .h3 { background: var(--h3); }

/* ---------- En-têtes de fiche ---------- */
.head-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field.wide { grid-column: span 2; }
@media (max-width: 560px) { .field.wide { grid-column: auto; } }
.big { font-size: 1.35rem; font-weight: 700; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin: 14px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; }
.kpi span { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-size: 1.45rem; }
.kpi small { color: var(--ink2); }
.kpi.res { border-top: 4px solid var(--red); }

.notice { background: #fff4dc; border: 1px solid #f1d9a0; color: #6b4a0d; padding: 10px 14px; border-radius: 10px; margin: 12px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink2); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 18px 0 10px; }
.toolbar input { max-width: 280px; }
.toolbar select { max-width: 220px; }

.kpi.bareme { grid-column: span 2; border-top: 4px solid var(--ink); }
@media (max-width: 560px) { .kpi.bareme { grid-column: auto; } }
.harmo { display: flex; gap: 10px; margin: 8px 0 4px; }
.harmo label { font-size: .78rem; color: var(--muted); font-weight: 600; flex: 1; }
.harmo input { margin-top: 2px; min-height: 36px; padding: 4px 8px; font-weight: 700; }
.dates { margin: 4px 0 0; font-size: .85rem; }

/* ---------- Tableau des résultats d'examen ---------- */
.results { font-size: .85rem; }
.results th, .results td { padding: 6px 8px; text-align: center; white-space: nowrap; border-right: 1px solid var(--line2); }
.results .sticky { position: sticky; left: 0; z-index: 2; background: var(--card); text-align: left; min-width: 190px; box-shadow: 1px 0 0 var(--line); }
.results thead th { color: var(--ink); }
.results thead th.grp { background: var(--ink); color: #fff; font-weight: 700; border-right: 1px solid #2c3b5c; }
.results thead th.q { min-width: 54px; }
.results thead th.q.clk { cursor: help; }
.results .agg { background-color: #f4f6f9; font-weight: 700; }
.results .agg.harm { box-shadow: inset 3px 0 0 var(--red); }
.results th.harm { color: var(--red-dark); }
.results th.wrap { white-space: normal; min-width: 92px; max-width: 110px; line-height: 1.2; }
.results td small { display: block; font-weight: 400; color: var(--ink2); font-size: .74rem; }
.results tbody.synth th { font-weight: 600; color: var(--ink2); }
.results tbody.synth tr:last-child > * { border-bottom: 2px solid var(--ink); }
.results tbody.synth td { color: var(--ink2); }
.results td.nr { color: var(--red-dark); font-style: italic; }
.results td.todo { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line2) 5px 6px); }
.results th.name { font-weight: 600; }
.results td.grpname { color: var(--ink2); }
.results .sortable { cursor: pointer; text-decoration: underline dotted; }

/* ---------- Notation ---------- */
.tabs { display: flex; gap: 6px; margin: 16px 0; }
.tab { flex: 1; max-width: 260px; min-height: 44px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-weight: 700; color: var(--ink2); cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.opts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.switch { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem; }
.entnav { display: flex; align-items: center; gap: 12px; position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 10; margin-bottom: 16px; box-shadow: 0 6px 16px rgba(20,33,61,.07); }
.navbtn { width: 54px; height: 54px; font-size: 1.2rem; flex: none; }
.entmid { flex: 1; min-width: 0; text-align: center; }
.entsel { border: 0; background: transparent; font-size: 1.3rem; font-weight: 800; text-align: center; text-align-last: center; padding: 2px; min-height: 0; color: var(--ink); cursor: pointer; }
.entsel:focus { box-shadow: none; }
.entinfo { font-size: .82rem; color: var(--muted); display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.okchip { color: var(--green); font-weight: 700; }
.members-inline { font-size: .88rem; color: var(--ink2); margin-top: 4px; }
.gpart > h3 { margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; }
.gpart > h3 small { color: var(--muted); font-weight: 600; }
.qrow { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 10px; }
.qrow.pending { border-left-color: var(--red); }
.qrow.mixed { border-left-color: #f4b740; }
.qhead { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.qnum { font-weight: 800; color: var(--red); min-width: 30px; }
.qtitle { font-weight: 700; flex: 1; }
.qpts { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.warn { color: #8a560b; font-size: .82rem; font-weight: 600; }
.answer { white-space: pre-wrap; font-size: .9rem; color: var(--ink2); background: #f5f7fa; border-left: 3px solid #c3ccd8; padding: 6px 10px; margin: 8px 0 2px; border-radius: 0 8px 8px 0; }
.boxes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.box {
  min-width: 56px; height: 54px; padding: 0 10px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.box small { font-weight: 500; color: var(--muted); font-size: .7rem; }
.box:hover:not(:disabled) { border-color: var(--ink2); }
.box.b-nr { color: var(--muted); border-style: dashed; }
.box.b-zero { color: var(--red-dark); }
.box.sel { background: var(--ink); border-color: var(--ink); color: #fff; }
.box.sel small { color: #c5cee0; }
.box.b-nr.sel { background: #5b6477; border-color: #5b6477; border-style: solid; }
.box.b-zero.sel { background: var(--red); border-color: var(--red); color: #fff; }
.box:disabled { cursor: default; opacity: .75; }
.bottomnav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

.groups-layout { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 14px; align-items: start; }
@media (max-width: 800px) { .groups-layout { grid-template-columns: 1fr; } }
.checklist { display: grid; gap: 2px; max-height: 420px; overflow: auto; margin: 10px 0 14px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.check:hover { background: var(--line2); }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.groups .card { margin: 0; }
.gname { font-weight: 800; font-size: 1.05rem; flex: 1; min-width: 0; }
.members { list-style: none; margin: 10px 0; padding: 0; }
.members li { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--line2); }

/* ---------- Éditeur de sujet ---------- */
.part { margin-top: 16px; }
.parthead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.pname { font-size: 1.08rem; font-weight: 800; border-color: transparent; background: transparent; }
.pname:hover { border-color: var(--line); }
.ptotal { white-space: nowrap; font-weight: 700; background: var(--ink); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: .85rem; }
.tools { display: flex; align-items: center; gap: 2px; }
.tools select { width: auto; max-width: 170px; min-height: 36px; font-size: .85rem; }
.qedit { border-top: 1px dashed var(--line); padding: 12px 0; }
.qline { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.qtline { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.qlabel { flex: none; min-width: 48px; text-align: center; font-weight: 800; color: var(--red); background: #fdecee; border-radius: 8px; padding: 9px 8px; }
.qt { flex: 1; font-size: 1.02rem; font-weight: 600; }
.pnum { flex: none; display: inline-grid; place-items: center; min-width: 34px; height: 34px; border-radius: 8px; background: var(--red); color: #fff; font-weight: 800; }
.mini { font-size: .75rem; color: var(--muted); font-weight: 600; }
.mini input, .mini select { display: block; margin-top: 3px; }
.mini input { width: 86px; }
.mini select { width: 158px; }
.qedit textarea { margin-top: 8px; font-size: .92rem; }

/* ---------- Fenêtres, notifications, connexion ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,33,61,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(860px, 100%); }
.modal h3 { padding: 18px 20px 0; font-size: 1.15rem; }
.modal-body { padding: 14px 20px; overflow: auto; display: grid; gap: 12px; }
.modal-body label { font-size: .88rem; font-weight: 600; color: var(--ink2); }
.modal-body label input, .modal-body label select, .modal-body label textarea { margin-top: 4px; font-weight: 400; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line2); }
.preview { font-size: .85rem; }
.preview .tbl th, .preview .tbl td { padding: 5px 8px; }
#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.err { background: var(--red-dark); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: min(380px, 100%); display: grid; gap: 12px; padding: 28px; }
.login .logo { width: 48px; height: 48px; font-size: 26px; border-radius: 12px; color: #fff; }
.login h1 { margin-top: 4px; }
.login label { font-weight: 600; font-size: .9rem; }
.login label input { margin-top: 4px; }
.err { color: var(--red-dark); min-height: 1.2em; margin: 0; }

@media (max-width: 700px) {
  h1 { font-size: 1.35rem; }
  .top { flex-wrap: wrap; }
  nav { order: 3; flex-basis: 100%; }
  :root { --top-h: 100px; }
}
@media print {
  .top, .actions, .toolbar, .bottomnav, .opts { display: none !important; }
  body { background: #fff; }
}
