/* ==========================================================================
   School Hub — feuille unique.
   Direction : panneau d'administration éditorial. Papier chaud (bone) / encre
   profonde. Un seul accent, bleu encre désaturé. Filets d'un pixel, angles
   doux (4–6 px) sans cartes flottantes, hiérarchie typographique nette,
   données en tableaux à chiffres tabulaires. Aucun dégradé décoratif.
   ========================================================================== */

/* ---------- Jetons ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg:            #FAFAF8;   /* papier */
  --bg-sunk:       #F3F2EE;   /* zone en creux */
  --surface:       #FFFFFF;
  --surface-2:     #F7F6F3;
  --line:          #E3E1DB;
  --line-strong:   #CFCCC3;
  --fg:            #17181A;   /* encre */
  --fg-2:          #4A4D53;   /* secondaire — contraste >= 4.5:1 sur --bg */
  --fg-3:          #6B6E75;   /* tertiaire */
  --fg-inv:        #FAFAF8;
  --accent:        #2C4A6E;   /* bleu encre */
  --accent-hover:  #1F3A59;
  --accent-soft:   #ECF0F6;
  --accent-line:   #C7D3E3;
  --ok:            #1F6B45;
  --ok-soft:       #E8F2EC;
  --warn:          #8A5A00;
  --warn-soft:     #FBF2DF;
  --danger:        #9A2B2B;
  --danger-soft:   #FBECEC;

  --r:      5px;
  --r-lg:   8px;
  --r-sm:   3px;

  --shadow: 0 1px 2px rgba(20, 20, 25, .05);

  --gap:    24px;
  --pad:    24px;
  --maxw:   1120px;

  --ease: cubic-bezier(.2, .7, .3, 1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg:            #0C0C0D;
  --bg-sunk:       #141416;
  --surface:       #131315;
  --surface-2:     #1A1A1C;
  --line:          #26262A;
  --line-strong:   #35353A;
  --fg:            #ECEBE7;
  --fg-2:          #A7A7AC;   /* >= 4.5:1 sur #0C0C0D */
  --fg-3:          #85858B;
  --fg-inv:        #0C0C0D;
  --accent:        #8FB2DC;
  --accent-hover:  #A9C4E6;
  --accent-soft:   #16202E;
  --accent-line:   #2B3C54;
  --ok:            #6FC79A;
  --ok-soft:       #12231A;
  --warn:          #D9AE5E;
  --warn-soft:     #221C0F;
  --danger:        #E08C8C;
  --danger-soft:   #241414;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* ---------- Réinitialisation ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}
::selection { background: var(--accent-soft); color: var(--fg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- Coquille ---------- */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
  padding: 0 max(clamp(16px, 4vw, 40px), calc((100vw - var(--maxw)) / 2 + 40px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  font-weight: 620;
  font-size: 14px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.wordmark-mark {
  width: 15px; height: 15px;
  border-radius: 3px;
  background: var(--fg);
  position: relative;
}
.wordmark-mark::after {
  content: "";
  position: absolute;
  inset: 4px 4px auto 4px;
  height: 2px;
  background: var(--bg);
  box-shadow: 0 3.5px 0 var(--bg);
  border-radius: 1px;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 12px;
  font-size: 13.5px;
  color: var(--fg-2);
  transition: color .15s var(--ease);
}
.nav-link:hover { color: var(--fg); }
.nav-link[aria-current="page"] { color: var(--fg); font-weight: 540; }
.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  background: var(--fg);
  border-radius: 2px 2px 0 0;
}

.masthead-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Sélecteur de thème : interrupteur à bascule, discret */
.theme-toggle {
  border: 0;
  background: none;
  padding: 8px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r);
}
.tg-track {
  display: block;
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: var(--bg-sunk);
  border: 1px solid var(--line-strong);
  transition: background .2s var(--ease), border-color .2s var(--ease);
}
.tg-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--fg-2);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
html[data-theme="light"] .tg-knob { transform: translateX(16px); background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
html[data-theme="light"] .tg-track { background: var(--accent); border-color: var(--accent); }
html[data-theme="dark"] .tg-track { background: var(--bg-sunk); border-color: var(--line-strong); }
html[data-theme="dark"] .tg-knob { background: var(--fg-3); }

/* Interrupteur d'activation (MCP) : état actif = piste pleine, pastille blanche */
.switch[aria-checked="true"] .tg-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .tg-knob { transform: translateX(16px); background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.35); }

.icon-link {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r);
  color: var(--fg-2);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-link:hover { background: var(--bg-sunk); color: var(--fg); }
.icon-link[aria-current="page"] { color: var(--fg); background: var(--bg-sunk); }

/* ---------- Vue principale ---------- */
.view {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 40px) 72px;
}
.view:focus { outline: none; }

.view-enter { animation: viewIn .22s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- En-tête de page ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.page-head-main { min-width: 0; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 8px;
}
.page-title {
  font-size: clamp(22px, 3.2vw, 29px);
  font-weight: 640;
  letter-spacing: -.022em;
  line-height: 1.15;
}
.page-lede {
  margin-top: 8px;
  max-width: 60ch;
  color: var(--fg-2);
  font-size: 14px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border-radius: var(--r);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .05s var(--ease);
}
.btn:hover { border-color: var(--fg-3); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--fg-inv);
  font-weight: 540;
}
.btn-primary:hover { background: var(--fg); border-color: var(--fg); filter: brightness(1.06); }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); filter: none; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--bg-sunk); color: var(--fg); border-color: transparent; }

.btn-danger { color: var(--danger); border-color: var(--line-strong); background: var(--surface); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Champs ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--fg-2);
  margin-bottom: 6px;
}
.field-hint { font-size: 12px; color: var(--fg-3); margin-top: 6px; }
.input {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--fg-3); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input:disabled { background: var(--bg-sunk); color: var(--fg-3); }
textarea.input { min-height: 84px; resize: vertical; line-height: 1.5; }

/* ---------- Panneaux / sections ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.panel + .panel { margin-top: 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.panel-desc { font-size: 12.5px; color: var(--fg-3); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-body--flush { padding: 0; }

/* ---------- Statut / pastilles sobres ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }
.dot--idle { background: var(--fg-3); }
.status--ok { color: var(--ok); }
.status--warn { color: var(--warn); }
.status--danger { color: var(--danger); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: .01em;
  background: var(--bg-sunk);
  color: var(--fg-2);
  border: 1px solid var(--line);
}
.tag--accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tag--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* ---------- Bandeau d'alerte (non insistante) ---------- */
.notice {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--warn);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--fg-2);
  font-size: 13px;
  line-height: 1.5;
}
.notice--danger { border-left-color: var(--danger); }
.notice svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--warn); }
.notice--danger svg { color: var(--danger); }
.notice b { color: var(--fg); font-weight: 600; }

/* ---------- Métadonnées en définitions ---------- */
.dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.dl-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.dl-row:last-child { border-bottom: 0; }
.dl-key { font-size: 12.5px; color: var(--fg-3); flex: none; }
.dl-val { font-size: 13.5px; color: var(--fg); text-align: right; font-weight: 500; word-break: break-word; }
.dl-val--mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Tableaux de données ---------- */
.table-wrap { width: 100%; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
table.data td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data th.cell-num { text-align: right; }
.cell-subject { font-weight: 540; color: var(--fg); }
.cell-muted { color: var(--fg-3); font-size: 12.5px; }
.cell-num { text-align: right; white-space: nowrap; }
.grade-val { font-weight: 600; }
.grade-val small { font-weight: 400; color: var(--fg-3); font-size: 12px; }
.grade-ok { color: var(--ok); }
.grade-low { color: var(--danger); }
.coef-inline {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-3);
}

/* ---------- Conteneur de données (onglets + tableaux) ---------- */
.data-body { padding: 16px 20px 0; }
.data-rule { height: 1px; background: var(--line); margin: 14px -20px 0; }
.data-body > div:last-child { padding: 0; }
.data-body .table-scroll { margin: 0 -20px -1px; }
.data-body .empty { margin: 0 -20px -1px; }
@media (max-width: 720px) {
  .data-body { padding: 12px 16px 0; }
  .data-rule { margin-left: -16px; margin-right: -16px; }
  .data-body .table-scroll, .data-body .empty { margin-left: -16px; margin-right: -16px; }
}

/* ---------- Onglets internes (segments sobres) ---------- */
.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--bg-sunk);
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.seg {
  border: 0;
  background: transparent;
  padding: 0 14px;
  min-height: 32px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg:hover { color: var(--fg); }
.seg { justify-content: center; }
.seg-short { display: none; }
.seg-long { display: inline; }
.seg[aria-selected="true"] {
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ---------- États vides ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 52px 24px;
  color: var(--fg-2);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg-3);
  margin-bottom: 4px;
}
.empty-icon svg { width: 20px; height: 20px; }
.empty-title { font-size: 14.5px; font-weight: 600; color: var(--fg); }
.empty-text { font-size: 13px; max-width: 38ch; line-height: 1.55; }

/* ---------- Grille de résumé ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.metric {
  padding: 16px 20px;
  border-right: 1px solid var(--line);
}
.metric:last-child { border-right: 0; }
.metric-label { font-size: 11.5px; color: var(--fg-3); font-weight: 500; letter-spacing: .01em; }
.metric-value { font-size: 22px; font-weight: 620; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-unit { font-size: 13px; color: var(--fg-3); font-weight: 400; }

/* ---------- Code / URL (copiable) ---------- */
.copyline {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--bg-sunk);
  overflow: hidden;
}
.copyline code {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  line-height: 1.5;
  display: flex;
  align-items: center;
}
.copyline .btn { border: 0; border-left: 1px solid var(--line-strong); border-radius: 0; min-height: 100%; background: var(--surface); }

/* ---------- Connexion (écran autonome) ---------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0);
  background-size: 22px 22px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: 0 12px 40px -20px rgba(0, 0, 0, .35);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-brand .wordmark-mark { width: 18px; height: 18px; background: var(--accent); }
.auth-brand .wordmark-mark::after { background: var(--surface); }
.auth-title { font-size: 19px; font-weight: 640; letter-spacing: -.02em; }
.auth-sub { font-size: 13px; color: var(--fg-2); margin-top: 4px; line-height: 1.5; }
.auth-form { margin-top: 24px; }
.auth-error {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--danger);
  margin: 2px 0 12px;
  line-height: 1.45;
}
.auth-submit { width: 100%; min-height: 42px; }

/* ---------- Séparateur de liste ---------- */
.list { border-top: 1px solid var(--line); }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: 13.5px; font-weight: 540; color: var(--fg); }
.list-item-meta { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* ---------- Navigation mobile (bas) ---------- */
.mobile-nav { display: none; }

/* ---------- Amorçage & toasts ---------- */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 100;
}
.boot-bar {
  width: 22px; height: 22px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  padding: 10px 16px;
  border-radius: var(--r);
  background: var(--fg);
  color: var(--fg-inv);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px -8px rgba(0, 0, 0, .5);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

/* ---------- Utilitaires ---------- */
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--fg-2); }
.dim { color: var(--fg-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Responsive : mobile d'abord impeccable ---------- */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .primary-nav { display: none; }
  .masthead { height: 52px; gap: 12px; padding: 0 14px; }
  .view { padding: 20px 16px calc(84px + env(safe-area-inset-bottom)); }
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding-bottom: 16px;
    margin-bottom: 20px;
  }
  .page-actions { width: 100%; justify-content: flex-start; }
  .page-actions .btn { min-height: 44px; }
  .page-actions .btn-primary, .page-actions .btn-accent { flex: 1; }
  .page-title { font-size: 23px; }
  .dl-row { flex-direction: column; align-items: flex-start; gap: 3px; }
  .dl-val { text-align: left; }
  .panel-head { flex-wrap: wrap; }
  .status { flex-shrink: 0; }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    height: calc(58px + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
  }
  .mn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--fg-3);
    min-height: 44px;
    transition: color .15s var(--ease);
  }
  .mn-item[aria-current="page"] { color: var(--fg); }
  .mn-item[aria-current="page"] svg { stroke: var(--accent); }

  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(2n) { border-right: 1px solid var(--line); }
  .metric:nth-child(n+3) { border-top: 0; }
  .metric:last-child { border-right: 0; }
  .metric { padding: 12px 14px; }
  .metric-label { font-size: 10.5px; }
  .metric-value { font-size: 18px; }

  .segmented { flex-wrap: wrap; }
  .data-body .segmented {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    -webkit-mask-image: none;
    mask-image: none;
    gap: 2px;
    padding: 3px;
  }
  .data-body .seg { justify-content: center; padding: 0 2px; width: 100%; min-width: 0; font-size: 12px; }
  .data-body .seg-long { display: none; }
  .data-body .seg-short { display: inline; }
  .data-body .seg[aria-selected="true"] {
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-line);
  }

  /* Tableaux : défilement horizontal contenu, jamais la page */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  /* Tableaux empilés : chaque ligne devient un bloc lisible, sans scroll horizontal */
  table.data.data--stack { min-width: 0; display: block; }
  table.data.data--stack thead { display: none; }
  table.data.data--stack tbody { display: block; }
  table.data.data--stack tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 2px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }
  table.data.data--stack tr:last-child { border-bottom: 0; }
  table.data.data--stack tbody tr:hover { background: transparent; }
  table.data.data--stack td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }
  /* libellé affiché uniquement quand la cellule n'est pas l'élément principal */
  table.data.data--stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--fg-3);
    margin-bottom: 1px;
  }

  /* Notes : matière en tête, date à gauche / note à droite, appréciation en bas */
  .row-grades { grid-template-columns: 1fr auto; }
  .row-grades .cell-subject { grid-row: 1; grid-column: 1 / -1; font-size: 14px; }
  .row-grades .cell-muted[data-label="Date"] { grid-row: 2; grid-column: 1; color: var(--fg-3); font-size: 12px; }
  .row-grades .cell-muted[data-label="Date"]::before { display: none; }
  .row-grades .cell-note { grid-row: 2; grid-column: 2; text-align: right; }
  .row-grades .cell-note::before { display: none; }
  .row-grades .cell-note-text { grid-row: 3; grid-column: 1 / -1; font-size: 12.5px; margin-top: 6px; }
  .row-grades .cell-note-text::before { display: none; }

  /* Emploi du temps : jour en bandeau pleine largeur */
  .row-day { display: block !important; padding: 8px 16px !important; background: var(--surface-2); }
  .row-day .cell-day {
    font-size: 11px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--fg-3);
  }
  /* Cours : horaire en colonne à gauche, matière + détails empilés à droite */
  .row-lesson { grid-template-columns: 74px 1fr !important; gap: 1px 12px !important; padding-top: 10px !important; padding-bottom: 10px !important; }
  .row-lesson td[data-label]::before { display: none; }
  table.data.data--stack .row-lesson td[data-label]::before,
  table.data.data--stack .row-grades td[data-label]::before { display: none; }
  .row-lesson td[data-label="Horaire"] {
    grid-column: 1; grid-row: 1 / span 2;
    font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--fg-2); font-weight: 500; white-space: nowrap;
  }
  .row-lesson td[data-label="Matière"] { grid-column: 2; grid-row: 1; font-size: 13.5px; }
  .row-lesson td[data-label="Détails"] { grid-column: 2; grid-row: 2; font-size: 12px; color: var(--fg-3); }

  /* Autres listes : horaire/date compact en en-tête de bloc */
  table.data.data--stack tr:not(.row-day):not(.row-grades) {
    grid-template-columns: 1fr;
  }
  table.data.data--stack tr:not(.row-day):not(.row-grades) td.cell-subject { font-size: 14px; margin-bottom: 2px; }
  table.data.data--stack tr:not(.row-day):not(.row-grades) td.cell-num { text-align: left; }
  table.data:not(.data--stack) { min-width: 460px; }
  table.data th, table.data td { padding: 10px 12px; }

  .panel-body { padding: 16px; }
  .panel-head { padding: 14px 16px; }
  .dl-row { padding: 10px 0; }
  .input { min-height: 44px; font-size: 16px; } /* évite le zoom iOS */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 44px; }
  .seg { min-height: 44px; }
  .icon-link, .theme-toggle { width: 44px; height: 44px; }
  .copyline code { font-size: 12px; }
  .copyline .btn { min-height: 44px; }
  .auth-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
