/* ============================================================
   MONARCH — Enseignement par itinérance
   Design tokens + composants (gestion de classes CP1/CP2)
   ============================================================ */

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --text-base: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --text-xl: clamp(1.375rem, 1.2rem + 0.8vw, 1.875rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Couleurs — identité MONARCH (bleu profond + bleu royal + or + blanc) */
  --bg: #EEF3FC;
  --surface: #ffffff;
  --surface-2: #E7EFFB;
  --surface-3: #D9E6F8;
  --border: #DCE6F5;
  --border-strong: #B9CFEF;

  --ink: #0B1E45;
  --ink-2: #43567E;
  --ink-3: #6E80A3;

  --accent: #257ABD;
  --accent-strong: #123168;
  --accent-soft: #E4EDFC;

  --gold: #C9A46B;
  --gold-strong: #9C7742;
  --gold-soft: #F7EDD3;

  --warn: #B4842A;
  --warn-soft: #FBF0D9;
  --danger: #C43D3D;
  --danger-soft: #FBEAEA;
  --ok: #1E8A5F;
  --ok-soft: #E3F4EC;
  --info: #257ABD;
  --info-soft: #E4EDFC;

  /* Sidebar : bleu profond en dégradé, propre à l'identité MONARCH */
  --sidebar-from: #071340;
  --sidebar-to: #123168;
  --sidebar-ink: #EAF1FF;
  --sidebar-ink-soft: #AEC3EE;
  --sidebar-hover: rgba(255,255,255,0.10);
  --sidebar-active-bg: #ffffff;
  --sidebar-active-ink: #123168;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(10,24,64,0.06), 0 2px 8px rgba(10,24,64,0.05);
  --shadow-2: 0 8px 28px rgba(10,24,64,0.14);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --sidebar-w: 244px;
  --font: 'Satoshi', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', 'Roboto Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent-strong); }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.app { display: none; }
.app.is-active { display: block; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  border-right: 1px solid var(--sidebar-from);
  padding: var(--space-5) var(--space-4);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-4);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand svg { flex: 0 0 auto; color: var(--gold-strong); }
.brand-name { font-weight: 700; font-size: var(--text-sm); letter-spacing: -0.01em; color: var(--ink); }
.brand-sub { font-size: var(--text-xs); color: var(--ink-3); }
.sidebar .brand svg, .drawer .brand svg { color: var(--gold); }
.sidebar .brand-name, .drawer .brand-name { color: var(--sidebar-ink); }
.sidebar .brand-sub, .drawer .brand-sub { color: var(--sidebar-ink-soft); }
.user-chip .brand-sub, .user-chip strong { color: var(--sidebar-ink); }
.sidebar .btn-ghost, .drawer .btn-ghost { color: var(--sidebar-ink); }
.sidebar .btn-ghost:hover, .drawer .btn-ghost:hover { background: var(--sidebar-hover); color: #fff; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.nav-label {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--sidebar-ink-soft); font-weight: 600; margin: var(--space-3) 0 var(--space-1) var(--space-2);
}
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  color: var(--sidebar-ink); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  min-height: 40px; transition: background 160ms var(--ease), color 160ms var(--ease);
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-ink); font-weight: 600; border-left-color: var(--gold); }
.nav a .ico { width: 18px; height: 18px; flex: 0 0 18px; }
.nav a .pill { margin-left: auto; }

.sidebar-foot { margin-top: auto; flex: 0 0 auto; display: flex; flex-direction: column; gap: var(--space-3); }
.user-chip {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-sm); background: var(--sidebar-hover);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: grid; place-items: center; background: var(--gold); color: var(--accent-strong);
  font-size: var(--text-xs); font-weight: 700; border: 1.5px solid rgba(255,255,255,0.6);
}

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) clamp(var(--space-4), 3vw, var(--space-8));
  background: rgba(238,243,252,0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--text-lg); }
.btn { white-space: nowrap; }
.topbar .spacer { flex: 1 1 auto; }
.crumb { font-size: var(--text-xs); color: var(--ink-3); }

.page { padding: clamp(var(--space-4), 3vw, var(--space-8)); }
.page-head { margin-bottom: var(--space-6); }
.page-head h2 { font-size: var(--text-xl); }
.page-head .lede { color: var(--ink-2); font-size: var(--text-sm); max-width: 68ch; margin-top: var(--space-2); }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-end { margin-left: auto; }
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

/* ---------- Composants ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow-1);
}
.card-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h3 { font-size: var(--text-base); }
.card-head .row-end { margin-left: auto; }
/* Sur petit écran, le titre garde sa ligne et l'action passe dessous. */
@media (max-width: 560px) {
  .card-head { flex-wrap: wrap; }
  .card-head h3 { flex: 1 1 100%; }
  .card-head .row-end { margin-left: 0; }
}
.card-title-sub { font-size: var(--text-xs); color: var(--ink-3); }

.tile {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-4); text-align: left; cursor: pointer; box-shadow: var(--shadow-1);
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), border-color 180ms var(--ease);
  min-height: 96px;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.tile:active { transform: translateY(0); }
.tile .ico { color: var(--accent-strong); width: 22px; height: 22px; }
.tile-title { font-weight: 600; font-size: var(--text-sm); }
.tile-sub { font-size: var(--text-xs); color: var(--ink-3); }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); }
.kpi-label { font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi-value { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; margin-top: var(--space-1); }
.kpi-note { font-size: var(--text-xs); color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: var(--text-sm); font-weight: 600; cursor: pointer;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); white-space: normal; text-align: center; }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px var(--space-2);
  border-radius: 999px; font-size: var(--text-xs); font-weight: 600; line-height: 1.6;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: oklch(0.42 0.1 150); }
.pill-warn { background: var(--warn-soft); color: oklch(0.48 0.12 60); }
.pill-danger { background: var(--danger-soft); color: oklch(0.45 0.15 25); }
.pill-info { background: var(--info-soft); color: oklch(0.44 0.1 255); }
.pill-accent { background: var(--accent-soft); color: var(--accent-strong); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font-family: inherit; font-size: var(--text-sm); color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--space-3); min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { font-size: var(--text-xs); color: var(--ink-3); font-weight: 500; }
.req { color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-strong); width: 18px; height: 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
th, td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); background: var(--surface-2); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t-name { font-weight: 600; }

.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 999px; gap: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600;
  padding: var(--space-2) var(--space-4); border-radius: 999px; cursor: pointer; min-height: 38px;
}
.seg button.is-active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-1); }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: var(--space-3) var(--space-4); cursor: pointer;
  font-size: var(--text-sm); font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button.is-active { color: var(--accent-strong); border-bottom-color: var(--accent-strong); }

.banner {
  display: flex; gap: var(--space-3); align-items: flex-start;
  border-radius: var(--radius); padding: var(--space-4); border: 1px solid var(--border);
  background: var(--surface-2); font-size: var(--text-sm);
}
.banner .ico { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px; }
.banner-warn { background: var(--warn-soft); border-color: oklch(0.86 0.08 70); color: oklch(0.4 0.1 60); }
.banner-info { background: var(--info-soft); border-color: oklch(0.88 0.05 250); color: oklch(0.4 0.09 255); }
.banner-ok { background: var(--ok-soft); border-color: oklch(0.86 0.08 150); color: oklch(0.38 0.1 150); }

.empty { text-align: center; padding: var(--space-10) var(--space-4); color: var(--ink-3); }
.empty h3 { color: var(--ink-2); font-size: var(--text-base); margin-bottom: var(--space-2); }

.list { display: flex; flex-direction: column; gap: var(--space-2); }
.list-item {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; text-align: left; width: 100%; transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.list-item:hover { border-color: var(--accent); background: var(--surface-2); }
.list-item .meta { font-size: var(--text-xs); color: var(--ink-3); }
.list-item .row-end { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 500ms var(--ease); }

/* Appel — marquage des absences */
.att-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); }
.att-row:last-child { border-bottom: 0; }
.att-name { flex: 1 1 auto; font-size: var(--text-sm); font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.att-code { font-family: var(--mono); font-size: var(--text-base); font-weight: 700; color: var(--danger); width: 1.2em; }
.mark-group { display: flex; gap: var(--space-1); }
.mark {
  width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); font-family: var(--mono); font-size: 1rem; font-weight: 700; color: var(--ink-2); cursor: pointer;
}
.mark:hover { background: var(--surface-2); }
.mark.is-on { background: var(--danger); border-color: var(--danger); color: #fff; }
.mark.is-on-ok { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Grille de notes */
.grade-input { min-height: 38px; padding: var(--space-2); text-align: right; font-variant-numeric: tabular-nums; }
td .grade-input { width: 52px; }
.err-input { border-color: var(--danger) !important; background: var(--danger-soft); }

/* Modale */
.modal-back {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,24,64,0.45);
  display: grid; place-items: end center; padding: 0;
  animation: fade 180ms var(--ease);
}
@media (min-width: 700px) { .modal-back { place-items: center; padding: var(--space-6); } }
.modal {
  background: var(--surface); border-radius: 20px 20px 0 0; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-2); animation: rise 240ms var(--ease);
}
@media (min-width: 700px) { .modal { border-radius: var(--radius); } }
.modal-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-5); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: var(--text-base); }
.modal-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.modal-foot { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border); display: flex; gap: var(--space-3); justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }

/* Toast */
.toasts { position: fixed; z-index: 80; bottom: var(--space-4); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--space-2); width: min(420px, calc(100vw - 2rem)); }
@media (min-width: 900px) { .toasts { bottom: var(--space-6); left: auto; right: var(--space-6); transform: none; } }
.toast {
  background: var(--ink); color: #fff; border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); box-shadow: var(--shadow-2); animation: rise 220ms var(--ease);
  display: flex; gap: var(--space-3); align-items: center;
}
.toast.ok { background: oklch(0.42 0.1 155); }
.toast.warn { background: oklch(0.45 0.13 55); }
.toast.info { background: oklch(0.42 0.11 250); }
.toast.danger { background: oklch(0.45 0.16 25); }

/* Document imprimable */
.doc-preview { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-6); font-size: 13px; color: #111; box-shadow: var(--shadow-1); }
.doc-preview h4 { text-align: center; font-size: 15px; margin-bottom: var(--space-1); text-transform: uppercase; }
.doc-preview .doc-sub { text-align: center; font-size: 12px; color: #444; margin-bottom: var(--space-4); }
.doc-preview table { font-size: 12px; }
.doc-preview th, .doc-preview td { border: 1px solid #cfd8d6; padding: 5px 7px; white-space: normal; }
.doc-preview th { background: #eef3f2; color: #222; }
.doc-foot { display: flex; justify-content: space-between; margin-top: var(--space-5); font-size: 11px; color: #444; }

/* Adaptation mobile — navigation par le bouton latéral uniquement */
@media (max-width: 899px) {
  .sidebar { display: none; }
  .page { padding-bottom: var(--space-8); }
  .drawer-btn { display: inline-flex; }
  .no-mobile { display: none; }
  .topbar h1 { font-size: var(--text-base); }
}
@media (min-width: 900px) { .drawer-btn { display: none; } }

/* Tiroir mobile (menu complet) */
.drawer-back { position: fixed; inset: 0; z-index: 70; background: rgba(10,24,64,0.5); }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(300px, 84vw);
  background: linear-gradient(180deg, var(--sidebar-from), var(--sidebar-to));
  padding: var(--space-5) var(--space-4); overflow-y: auto; animation: slide 220ms var(--ease);
  display: flex; flex-direction: column; gap: var(--space-4);
}
@keyframes slide { from { transform: translateX(-100%); } }

/* Écran de connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5); background:
  radial-gradient(1100px 600px at 12% -10%, var(--accent-soft), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, oklch(0.95 0.04 90), transparent 60%), var(--bg); }
.login-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: var(--space-8) var(--space-6); box-shadow: var(--shadow-2); }
.login-card .brand { justify-content: center; margin-bottom: var(--space-5); }
.code-display {
  display: flex; gap: 8px; justify-content: center; margin: var(--space-4) 0 var(--space-2);
}
.code-cell {
  width: 40px; height: 52px; border-radius: var(--radius-sm); border: 1.5px dashed var(--border-strong);
  background: var(--surface-2); display: grid; place-items: center;
  font-size: var(--text-lg); font-weight: 700; color: var(--ink); text-transform: uppercase;
}
.code-cell.is-filled { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.code-cell.is-err { border-color: var(--danger); background: var(--danger-soft); }
.code-input {
  text-align: center; letter-spacing: 0.35em; text-transform: uppercase;
  font-size: var(--text-lg); font-weight: 700; min-height: 54px;
}
.nom-eleve { font-weight: 600; }
.nom-eleve.is-fille { color: #c2185b; }
.nom-eleve.is-garcon { color: var(--ink); }
.photo-eleve { border-radius: 6px; border: 1px solid var(--border); object-fit: cover; background: var(--surface-2); }
.photo-vide {
  border-radius: 6px; border: 1.5px dashed var(--border-strong); background: var(--surface-2);
  display: grid; place-items: center; font-size: 10px; color: var(--ink-3); font-weight: 600; text-align: center;
}
.login-err { color: var(--danger); font-size: var(--text-sm); font-weight: 600; text-align: center; min-height: 22px; }
.demo-codes { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--ink-3); text-align: center; }
.demo-codes b { color: var(--ink-2); font-family: var(--mono); }

/* Bandeau statut réseau */
.net-strip { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); font-weight: 600; padding: 2px var(--space-2); border-radius: 999px; }
.net-on { background: var(--ok-soft); color: oklch(0.4 0.1 150); }
.net-off { background: var(--warn-soft); color: oklch(0.45 0.12 60); }

.spec-note {
  font-size: var(--text-xs); color: var(--ink-3); border-left: 2px solid var(--border-strong);
  padding-left: var(--space-3); margin-top: var(--space-4);
}

@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .page { padding: 0; }
  .doc-preview { border: 0; box-shadow: none; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Documents : identité, badges, légende ---------- */
.doc-identite { display: flex; gap: 12px; align-items: flex-start; margin-top: 10px; }
.doc-identite table { flex: 1; }
.doc-badge {
  margin-top: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--warn); background: var(--warn-soft);
  font-size: var(--text-sm); font-weight: 600; color: var(--ink);
}
.doc-legende { margin-top: 8px; font-size: var(--text-xs); color: var(--ink-3); }
tr.is-absent td { background: var(--danger-soft); }
td.is-zero { color: var(--danger); font-weight: 700; }
@media print {
  .nom-eleve.is-fille { color: #c2185b !important; }
  .photo-eleve, .nom-eleve { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.grade-input:disabled { background: var(--surface-2); border-style: dashed; color: var(--ink-3); cursor: not-allowed; }

/* ---------- Compte rendu de composition ---------- */
.report-block { margin-bottom: var(--space-6); }
.report-block:last-of-type { margin-bottom: var(--space-4); }
.report-title {
  font-size: var(--text-sm); font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--space-3);
}
.table-report tbody tr.is-total td { background: var(--accent-soft); font-weight: 600; }
.table-report td .meta { font-size: var(--text-xs); color: var(--ink-3); white-space: normal; }

/* Extrait de code inline (noms de fichiers techniques) */
code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.05em 0.35em; white-space: nowrap;
}

/* Ligne clé / valeur repliable sur mobile (bloc « Base de données partagée ») */
.kv-row { flex-wrap: wrap; gap: var(--space-2); }
.pill-wrap { font-family: var(--mono); font-size: var(--text-xs); white-space: normal; text-align: left; max-width: 100%; }

/* Aperçu de document A4 : défilement horizontal contenu sur petit écran,
   afin que la page elle-même ne déborde jamais. */
@media (max-width: 700px) {
  .doc-preview { overflow-x: auto; }
  .doc-preview table { min-width: 440px; }
}

/* ---------- Accès : pavé numérique, code personnel, code d'activation ---------- */
.qui {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.qui .avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: var(--text-sm);
}
.qui-nom { font-weight: 700; }
.qui-role { font-size: var(--text-xs); color: var(--ink-3); }
.pave {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  max-width: 280px; margin: var(--space-4) auto var(--space-2);
}
.touche {
  min-height: 56px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-size: var(--text-lg); font-weight: 700;
  cursor: pointer; transition: background 0.12s ease, transform 0.08s ease;
  display: grid; place-items: center;
}
.touche:hover:not(:disabled) { background: var(--surface-2); }
.touche:active:not(:disabled) { transform: scale(0.96); }
.touche:disabled { opacity: 0.4; cursor: not-allowed; }
.touche-sec { background: var(--surface-2); color: var(--ink-2); }
.touche-ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.touche-ok:hover:not(:disabled) { background: var(--accent-strong); }
.code-input-long { letter-spacing: 0.12em; font-size: var(--text-base); }
.code-affiche {
  margin: var(--space-4) 0 var(--space-2); padding: var(--space-4);
  border: 1.5px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft);
  font-family: var(--mono); font-size: var(--text-lg); font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent-strong); text-align: center; word-break: break-all;
}
.btn-danger-ghost { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.pill-muted { background: var(--surface-3, var(--surface-2)); color: var(--ink-3); }
@media (max-width: 420px) {
  .pave { max-width: 100%; }
  .code-cell { width: 34px; height: 46px; }
  .code-affiche { font-size: var(--text-base); letter-spacing: 0.04em; }
}
