/* ==========================================================================
   Charte « premium » (passe design du 2026-09-30, demande d'Ams)
   Chargée après styles.css : elle redéfinit les jetons (couleurs, police, rayons,
   ombres) et l'habillage des composants communs. Pour revenir à l'ancien habillage,
   il suffit de retirer la ligne theme.css de index.html.

   - Police : Inter (hébergée dans /assets/fonts, 62 Ko, licence OFL).
   - Couleur d'accent : violet du logo de l'école. Les couleurs de notes restent
     orange < 50 %, gris < 70 %, bleu au-delà (maquette validée le 2026-09-26).
   - Menu clair, icônes au trait, surfaces blanches à filet fin, ombres très légères.
   - Transitions courtes (150–280 ms), coupées si le système demande moins d'animations.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-var.woff2?v=3.19") format("woff2"),
       url("/assets/fonts/inter-latin-var.woff?v=3.19") format("woff");
}

/* Tout l'habillage est réservé à l'écran : bulletins, reçus et certificats imprimés
   gardent exactement leur police, leurs couleurs et leurs marges d'origine. */
@media screen {
  :root {
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Neutres */
    --ink: #141824;
    --ink-2: #2f3645;
    --muted: #667085;
    --subtle: #98a2b3;
    --line: #e7e9ee;
    --line-strong: #d4d8e0;
    --paper: #ffffff;
    --surface: #f6f7f9;
    --surface-soft: #f9fafb;
    --hover: #f4f5f8;

    /* Accent : violet de l'école */
    --primary: #6941c6;
    --primary-hover: #5a35b0;
    --primary-press: #4c2c96;
    --primary-soft: #f4f0fd;
    --primary-softer: #faf8ff;
    --primary-line: #ddd1f8;
    --primary-ink: #5b36b3;
    --ring: rgba(105, 65, 198, 0.2);
    --surface-blue: var(--primary-softer);
    --blue: #2457d6;
    --secondary: #667085;
    --gray: #667085;

    /* États */
    --green: #067647;
    --green-bg: #ecfdf3;
    --green-line: #abefc6;
    --amber: #b54708;
    --amber-bg: #fffaeb;
    --amber-line: #fedf89;
    --red: #c4320a;
    --red-strong: #b42318;
    --red-bg: #fef3f2;
    --red-line: #fecdca;
    --teal: #667085;

    /* Formes */
    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
    --shadow-soft: var(--shadow-xs);
    --shadow: 0 24px 48px -12px rgba(16, 24, 40, 0.18), 0 4px 12px -4px rgba(16, 24, 40, 0.06);
    --shadow-pop: 0 12px 24px -8px rgba(16, 24, 40, 0.14), 0 2px 6px -2px rgba(16, 24, 40, 0.05);

    /* Mouvement */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --t-fast: 140ms;
    --t-med: 220ms;

    --sidebar-w: 256px;
  }

  /* ---------- Base ---------- */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    color: var(--ink-2);
    background: var(--surface);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "cv05" 1, "cv08" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  body::before {
    display: none;
  }

  h1, h2, h3, h4 {
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.012em;
  }

  strong, b {
    font-weight: 600;
  }

  a {
    color: var(--primary-ink);
    text-underline-offset: 3px;
  }

  ::selection {
    background: #e4dafb;
  }

  :focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  .muted {
    color: var(--muted);
  }

  table,
  .dash-num,
  .gchip,
  .metric strong,
  input[type="number"] {
    font-variant-numeric: tabular-nums;
  }

  button,
  a,
  input,
  select,
  textarea {
    transition: color var(--t-fast) ease, background-color var(--t-fast) ease, border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-fast) ease, opacity var(--t-fast) ease;
  }

  button:active,
  .guide-link:active {
    transform: translateY(0.5px) scale(0.985);
  }

  svg.ico {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
  }

  /* ---------- Connexion ---------- */
  .login-shell {
    background:
      radial-gradient(60rem 30rem at 50% -10%, rgba(105, 65, 198, 0.07), transparent 70%),
      var(--surface);
  }

  .login-panel {
    width: min(400px, 100%);
    gap: 18px;
    padding: 36px 32px 32px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    animation: rise-in 420ms var(--ease-out) both;
  }

  .login-brand {
    justify-items: center;
    gap: 6px;
    margin-bottom: 6px;
    text-align: center;
  }

  .login-logo {
    width: 188px;
    max-height: 140px;
    margin-bottom: 10px;
  }

  .login-panel .eyebrow {
    color: var(--muted);
  }

  .login-panel h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
  }

  .login-panel .primary-button {
    min-height: 44px;
    margin-top: 4px;
    font-size: 15px;
  }

  .login-panel input {
    min-height: 44px;
  }

  .login-error {
    color: var(--red-strong);
    background: var(--red-bg);
    border-color: var(--red-line);
    font-weight: 500;
  }

  /* ---------- Coquille : menu latéral clair ---------- */
  .app-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .sidebar {
    gap: 20px;
    height: 100dvh;
    padding: 20px 14px 16px;
    color: var(--ink-2);
    background: var(--paper);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .brand-block {
    gap: 12px;
    padding: 4px 8px 0;
    margin: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }

  .sidebar-logo {
    width: 118px;
    max-height: 88px;
  }

  .brand-block .eyebrow,
  .sidebar .eyebrow {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
  }

  .brand-block h1 {
    margin: 2px 0 0;
    color: var(--ink);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  .nav-list {
    gap: 2px;
  }

  .nav-button {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 38px;
    padding: 0 10px;
    color: var(--ink-2);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.005em;
  }

  .nav-button .ico {
    color: var(--subtle);
    transition: color var(--t-fast) ease;
  }

  .nav-button:hover {
    color: var(--ink);
    background: var(--hover);
    border-color: transparent;
    box-shadow: none;
  }

  .nav-button:hover .ico {
    color: var(--muted);
  }

  .nav-button.active {
    color: var(--primary-ink);
    background: var(--primary-soft);
    border-color: transparent;
    box-shadow: none;
    font-weight: 600;
  }

  .nav-button.active .ico {
    color: var(--primary);
  }

  .nav-group-title {
    margin: 16px 0 4px;
    padding: 0 10px;
    color: var(--subtle);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
  }

  .guide-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 38px;
    margin-top: 14px;
    padding: 0 10px;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
  }

  .guide-link::before {
    content: none;
  }

  .guide-link .ico {
    color: var(--subtle);
  }

  .guide-link .ico:last-child {
    width: 14px;
    height: 14px;
    margin-left: auto;
    opacity: 0.8;
  }

  .guide-link:hover {
    color: var(--ink);
    background: var(--hover);
    border-style: none;
  }

  .session-box {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 14px 10px 0;
    border-top: 1px solid var(--line);
  }

  .session-box strong {
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
  }

  .session-box span {
    color: var(--muted);
    font-size: 12.5px;
  }

  .sidebar .secondary-button,
  .session-box .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: fit-content;
    min-height: 32px;
    margin: 8px -10px 0;
    padding: 0 10px;
    color: var(--muted);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 13.5px;
    font-weight: 500;
  }

  .sidebar .secondary-button:hover {
    color: var(--red-strong);
    background: var(--red-bg);
  }

  .sidebar .secondary-button .ico {
    width: 16px;
    height: 16px;
  }

  /* ---------- Espace de travail et en-tête d'écran ---------- */
  .workspace {
    padding: 28px 40px 56px;
  }

  .workspace-header {
    align-items: flex-end;
    margin-bottom: 24px;
    padding: 4px 0 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .workspace-header .eyebrow {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
  }

  .workspace-header h2 {
    margin: 2px 0 0;
    color: var(--ink);
    font-size: 28px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.024em;
  }

  .header-right {
    gap: 10px;
  }

  .school-year-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    padding: 0 12px;
    color: var(--ink-2);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-xs);
    font-size: 13px;
    font-weight: 500;
  }

  .school-year-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #12b76a;
    box-shadow: 0 0 0 3px #d1fadf;
  }

  .school-year-badge.is-archived {
    color: var(--muted);
    background: var(--surface-soft);
  }

  .school-year-badge.is-archived::before {
    background: var(--subtle);
    box-shadow: 0 0 0 3px #eaecf0;
  }

  /* Aide : « ? » et interrupteur, discrets */
  .help-control {
    gap: 8px;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .help-button {
    width: 32px;
    height: 32px;
    min-height: 32px;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
    box-shadow: var(--shadow-xs);
    font-weight: 600;
  }

  .help-button:hover {
    color: var(--primary-ink);
    background: var(--primary-softer);
    border-color: var(--primary-line);
  }

  .help-switch {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
  }

  .help-switch-track {
    background: #e4e7ec;
    box-shadow: none;
  }

  .help-switch input:checked + .help-switch-track {
    background: var(--primary);
  }

  .help-switch input:focus-visible + .help-switch-track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* Message de confirmation : pastille flottante en bas de l'écran */
  .toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 80;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 0;
    max-width: min(520px, calc(100vw - 32px));
    padding: 11px 16px 11px 14px;
    color: var(--ink) !important;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-pop);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transform: translate(-50%, 0);
    opacity: 1;
    transition: opacity var(--t-med) ease, transform var(--t-med) var(--ease-out);
    pointer-events: none;
  }

  .toast::before {
    content: "";
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #12b76a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 12px no-repeat;
  }

  .toast[data-tone="error"]::before {
    background: #f04438 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17h.01'/%3E%3C/svg%3E") center / 12px no-repeat;
  }

  .toast:empty {
    opacity: 0;
    transform: translate(-50%, 12px);
  }

  /* ---------- Surfaces ---------- */
  .panel,
  .metric,
  .table-wrap,
  .management-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }

  .panel {
    padding: 20px 22px;
  }

  .metric {
    background: var(--paper);
  }

  .metric::before {
    content: none;
  }

  .metric strong {
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .grid {
    gap: 16px;
  }

  .view-panel {
    gap: 16px;
  }

  /* Surtitres dans les blocs : petites capitales grises, espacées */
  .eyebrow,
  .card-kicker {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
  }

  /* ---------- Champs ---------- */
  label {
    gap: 6px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    padding: 8px 12px;
    color: var(--ink);
    background-color: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    font-size: 14.5px;
  }

  input::placeholder,
  textarea::placeholder {
    color: var(--subtle);
  }

  input:hover,
  select:hover,
  textarea:hover {
    border-color: #c1c7d2;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--ring);
    outline: none;
  }

  select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    text-overflow: ellipsis;
  }

  select[multiple] {
    padding-right: 12px;
    background-image: none;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 16px;
    min-height: 16px;
    height: 16px;
    padding: 0;
    box-shadow: none;
    accent-color: var(--primary);
  }

  input[type="file"] {
    box-shadow: none;
  }

  input:disabled,
  select:disabled,
  textarea:disabled {
    color: var(--muted);
    background-color: var(--surface-soft);
    box-shadow: none;
  }

  /* ---------- Boutons ---------- */
  .primary-button,
  .secondary-button,
  .danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.005em;
  }

  .primary-button {
    color: #fff;
    background: var(--primary);
    border: 1px solid var(--primary);
    box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }

  .primary-button:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
  }

  .primary-button:active {
    background: var(--primary-press);
  }

  .secondary-button {
    color: var(--ink-2);
    background: var(--paper);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-xs);
  }

  .secondary-button:hover {
    color: var(--ink);
    background: var(--surface-soft);
    border-color: #c1c7d2;
  }

  .danger-button {
    color: #fff;
    background: #d92d20;
    border: 1px solid #d92d20;
    box-shadow: var(--shadow-xs);
  }

  .danger-button:hover {
    background: var(--red-strong);
    border-color: var(--red-strong);
  }

  .primary-button:disabled,
  .secondary-button:disabled,
  .danger-button:disabled,
  button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
  }

  .link-button {
    color: var(--primary-ink);
    font-weight: 500;
  }

  /* Bouton « Bulletin » : plus d'orange, accent de l'école */
  .report-button {
    color: #fff !important;
    background: var(--primary) !important;
    border-color: var(--primary) !important;
  }

  .report-button:hover {
    background: var(--primary-hover) !important;
  }

  .button-row {
    gap: 8px;
  }

  /* ---------- Tableaux ---------- */
  .table-wrap {
    overflow: auto;
  }

  th,
  td {
    padding: 12px 14px;
    border-bottom: 1px solid #eef0f3;
  }

  th {
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  tbody tr {
    transition: background-color var(--t-fast) ease;
  }

  tbody tr:hover {
    background: #fafbfc;
  }

  tbody tr:last-child td {
    border-bottom: 0;
  }

  tbody .student-row.selected {
    background: var(--primary-softer);
    box-shadow: inset 3px 0 0 var(--primary);
  }

  tbody .student-row.selected .secondary-button {
    color: var(--primary-ink);
    border-color: var(--primary-line);
  }

  /* ---------- Pastilles ---------- */
  .badge {
    min-height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
  }

  .badge.green {
    color: var(--green);
    background: var(--green-bg);
    box-shadow: inset 0 0 0 1px var(--green-line);
  }

  .badge.amber {
    color: var(--amber);
    background: var(--amber-bg);
    box-shadow: inset 0 0 0 1px var(--amber-line);
  }

  .badge.red {
    color: var(--red-strong);
    background: var(--red-bg);
    box-shadow: inset 0 0 0 1px var(--red-line);
  }

  .badge.gray {
    color: #344054;
    background: #f2f4f7;
    box-shadow: inset 0 0 0 1px #e4e7ec;
  }

  .badge.blue {
    color: #175cd3;
    background: #eff8ff;
    box-shadow: inset 0 0 0 1px #b2ddff;
  }

  .count-pill {
    color: var(--ink-2);
    background: var(--surface-soft);
    border-color: var(--line);
    font-weight: 500;
  }

  /* ---------- Onglets ---------- */
  .notes-tabs {
    gap: 20px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }

  .notes-tabs::-webkit-scrollbar {
    display: none;
  }

  .notes-tab {
    position: relative;
    min-height: 42px;
    padding: 0 2px;
    color: var(--muted);
    border-bottom: 0;
    font-size: 14px;
    font-weight: 500;
  }

  .notes-tab::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform var(--t-med) var(--ease-out);
  }

  .notes-tab:hover {
    color: var(--ink);
    background: none;
  }

  .notes-tab.active {
    color: var(--ink);
    font-weight: 600;
    border-bottom: 0;
  }

  .notes-tab.active::after {
    transform: scaleX(1);
  }

  .attendance-subtabs .tab-button.active {
    color: var(--primary-ink);
    font-weight: 600;
  }

  /* ---------- Fenêtres (aide, période, paiements…) ---------- */
  dialog {
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
  }

  dialog[open] {
    animation: dialog-in var(--t-med) var(--ease-out);
  }

  dialog::backdrop {
    background: rgba(16, 24, 40, 0.42);
    backdrop-filter: blur(3px);
    animation: fade-in var(--t-med) ease;
  }

  .empty-state {
    justify-items: center;
    padding: 36px 24px;
    color: var(--muted);
    text-align: center;
  }

  /* ---------- Transitions entre écrans et contenus ---------- */
  /* L'ancienne animation rejouait à chaque rafraîchissement du contenu : retirée */
  .view-panel > .panel,
  .view-panel > .grid,
  .view-panel > .management-layout {
    animation: none;
  }

  /* Changement d'écran : le panneau apparaît en fondu en remontant légèrement */
  .view-panel:not(.hidden) {
    animation: view-in 280ms var(--ease-out) both;
  }

  /* Contenu remplacé dans un même écran (fiche ouverte, onglet changé) */
  .is-entering {
    animation: content-in 240ms var(--ease-out) both;
  }






  /* ---------- Téléphone et tablette ---------- */
  @media (max-width: 980px) {
    .app-shell {
      grid-template-columns: minmax(0, 1fr);
    }

    body {
      background: var(--surface);
    }

    .sidebar {
      height: auto;
      padding: 8px 12px 8px 16px;
      padding-top: max(8px, env(safe-area-inset-top));
      color: var(--ink);
      background: transparent;
      border-right: 0;
      border-bottom: 1px solid var(--line);
      box-shadow: none;
      overflow: visible;
    }

    /* Verre dépoli posé sur un pseudo-élément : un filtre sur la barre elle-même
       enfermerait le menu (position fixe) dans la hauteur de la barre */
    .sidebar::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: rgba(255, 255, 255, 0.88);
      backdrop-filter: saturate(1.6) blur(14px);
      -webkit-backdrop-filter: saturate(1.6) blur(14px);
    }

    .brand-block {
      padding: 0;
    }

    .sidebar-logo {
      width: 46px;
      max-height: 36px;
    }

    .brand-block .eyebrow {
      font-size: 10px;
    }

    .brand-block h1 {
      font-size: 16px;
    }

    .nav-toggle {
      min-height: 40px;
      padding: 0 12px;
      color: var(--ink-2);
      background: var(--paper);
      border: 1px solid var(--line);
      border-radius: 999px;
      box-shadow: var(--shadow-xs);
      font-size: 14px;
      font-weight: 500;
    }

    /* Menu complet : panneau qui glisse sous la barre, liste d'une colonne */
    .nav-drawer {
      display: flex;
      inset: calc(56px + env(safe-area-inset-top)) 0 0 0;
      padding: 12px 16px calc(96px + env(safe-area-inset-bottom));
      background: var(--paper);
      opacity: 0;
      visibility: hidden;
      transform: translateY(-10px);
      transition: opacity var(--t-med) ease, transform var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
    }

    .nav-open .nav-drawer {
      display: flex;
      opacity: 1;
      visibility: visible;
      transform: none;
      transition: opacity var(--t-med) ease, transform var(--t-med) var(--ease-out), visibility 0s;
    }

    .nav-list {
      grid-template-columns: minmax(0, 1fr);
      gap: 2px;
    }

    .nav-list .nav-button {
      min-height: 48px;
      padding: 0 12px;
      font-size: 15.5px;
    }

    .nav-list .nav-button .ico {
      width: 20px;
      height: 20px;
    }

    .nav-group-title {
      margin-top: 14px;
    }

    .guide-link {
      min-height: 48px;
      padding: 0 12px;
      font-size: 15px;
    }

    .session-box {
      margin-top: 12px;
      padding: 16px 12px 0;
    }

    /* Barre du bas : verre dépoli, icônes au trait, onglet actif en pastille */
    .bottom-nav {
      padding: 6px 8px max(8px, env(safe-area-inset-bottom));
      background: rgba(255, 255, 255, 0.86);
      border-top: 1px solid var(--line);
      box-shadow: none;
      backdrop-filter: saturate(1.6) blur(16px);
      -webkit-backdrop-filter: saturate(1.6) blur(16px);
    }

    .bottom-nav .bottom-nav-button {
      display: grid;
      justify-items: center;
      align-content: center;
      gap: 3px;
      min-height: 52px;
      padding: 4px 2px 2px;
      color: var(--muted);
      border-radius: 12px;
      font-size: 11px;
      font-weight: 500;
      letter-spacing: 0;
    }

    .bottom-nav-button .bn-icon {
      width: 40px;
      height: 28px;
      padding: 4px 10px;
      border-radius: 999px;
      stroke-width: 1.8;
      transition: background-color var(--t-med) var(--ease-out), color var(--t-fast) ease;
    }

    .bottom-nav-button.active,
    .nav-open .bottom-nav-more,
    .bottom-nav-button:hover {
      color: var(--primary-ink);
      background: none;
      box-shadow: none;
    }

    .bottom-nav-button.active .bn-icon,
    .nav-open .bottom-nav-more .bn-icon {
      color: var(--primary);
      background: var(--primary-soft);
    }

    .bottom-nav-button.active span {
      font-weight: 600;
    }

    .workspace {
      padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
    }

    .workspace-header {
      align-items: center;
      gap: 8px 10px;
      margin-bottom: 16px;
      padding: 6px 0 0;
      background: none;
      border: 0;
      box-shadow: none;
    }

    .workspace-header h2 {
      font-size: 24px;
    }

    .toast {
      bottom: calc(84px + env(safe-area-inset-bottom));
    }

    .panel {
      padding: 16px;
    }
  }

  @media (max-width: 760px) {
    .workspace-header .eyebrow {
      font-size: 12px;
    }

    .school-year-badge {
      min-height: 28px;
      padding: 0 10px;
      font-size: 12px;
    }

    .help-button {
      width: 30px;
      height: 30px;
      min-height: 30px;
    }
  }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes content-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Moins d'animations si le système le demande ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Impression : documents inchangés (police et couleurs d'origine) ---------- */
@media print {
  body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  }

  /* Graisses d'origine des règles communes écran/impression (fiche imprimée) */
  .eyebrow {
    font-weight: 800;
  }

  .student-avatar {
    font-weight: 900;
  }

  .toast {
    display: none !important;
  }
}

/* ==========================================================================
   Écrans : retouches ciblées
   ========================================================================== */
@media screen {
  /* Plus de barres de couleur épaisses sur le bord gauche des blocs */
  .management-layout > .panel,
  .notes-periods-bar,
  #notes-panel > .panel.stack:last-child,
  #attendance-panel .panel.stack,
  #timetable-panel .panel.stack,
  .payments-block,
  .financial-situation,
  #import-panel .grid.two > .panel:first-child,
  #import-panel .grid.two > .panel:last-child,
  #backup-panel .panel {
    border-left: 1px solid var(--line);
  }

  .student-detail {
    border-left: 0;
  }

  /* Encadré « rien à signaler » : neutre et discret */
  .dash-empty {
    padding: 14px 16px;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    font-weight: 500;
  }

  /* Avatars : initiales sur fond violet très clair */
  .student-avatar {
    color: var(--primary-ink);
    background: var(--primary-soft);
    border: 0;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .student-avatar.small {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }

  /* ---- Élèves : barre d'outils d'une ligne ---- */
  .list-toolbar {
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }

  .list-toolbar .filters {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .list-toolbar .filters > select {
    flex: 1 0 172px;
    width: auto;
    min-width: 0;
  }

  .search-field {
    position: relative;
    flex: 1.4 1 220px;
    min-width: 0;
  }

  .search-field .ico {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--subtle);
    transform: translateY(-50%);
  }

  .search-field input {
    padding-left: 36px;
  }

  .list-toolbar > .primary-button {
    flex: none;
    min-height: 40px;
  }

  .primary-button .ico,
  .secondary-button .ico {
    width: 16px;
    height: 16px;
  }

  .list-count {
    margin: -4px 0 -6px 2px;
    color: var(--muted);
    font-size: 13px;
  }

  .students-list-view {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }

  .students-list-view td {
    vertical-align: middle;
  }

  .students-list-view tr.student-row {
    cursor: pointer;
  }

  .student-list-cell {
    gap: 12px;
  }

  .student-list-cell strong {
    color: var(--ink);
    font-weight: 600;
  }

  .student-list-cell .muted {
    font-size: 13px;
  }

  .row-open-cell {
    width: 52px;
    text-align: right;
  }

  .row-open {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    color: var(--subtle);
    background: none;
    border: 0;
    border-radius: 8px;
  }

  tr.student-row:hover .row-open,
  .row-open:focus-visible {
    color: var(--primary);
    background: var(--primary-soft);
  }

  /* ---- Fiche élève ---- */
  .student-detail-view {
    max-width: 1040px;
  }

  .detail-header {
    margin-bottom: 10px;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    margin-left: -8px;
    padding: 0 10px 0 8px;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
  }

  .back-link:hover {
    color: var(--ink);
    background: var(--hover);
  }

  .back-link .ico {
    width: 16px;
    height: 16px;
  }

  .student-header {
    gap: 14px 20px;
    padding: 22px 24px;
  }

  .student-header .student-avatar.large {
    width: 68px;
    height: 68px;
    font-size: 22px;
  }

  .student-header-id h3 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }

  .student-header-actions {
    padding-top: 16px;
    border-top-color: #eef0f3;
  }

  .student-header-contact {
    font-size: 14px;
  }

  .id-phone {
    color: var(--primary-ink);
    font-weight: 500;
  }

  .student-tabs {
    margin-top: 6px;
  }

  .id-grid {
    gap: 16px;
  }

  .id-card {
    gap: 8px;
    padding: 20px 22px;
  }

  .id-card h4,
  .id-card legend {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
  }

  .id-field {
    padding: 10px 0;
    border-top-color: #f0f2f5;
  }

  .id-field dt {
    font-size: 13.5px;
  }

  .id-field dd {
    color: var(--ink);
    font-size: 14.5px;
    font-weight: 500;
  }

  .id-empty {
    color: var(--subtle);
    font-weight: 400;
  }

  .id-alert {
    color: var(--amber);
    background: var(--amber-bg);
    border-color: var(--amber-line);
    border-radius: 12px;
  }

  /* Formulaire : le titre du bloc passe dans le bloc (plus sur la bordure) */
  .student-edit fieldset.id-card {
    display: block;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
  }

  .student-edit legend {
    float: left;
    width: 100%;
    margin: 0 0 16px;
    padding: 0;
  }

  .student-edit legend + * {
    clear: both;
  }

  .student-edit fieldset.id-card > * + * {
    margin-top: 12px;
  }

  .student-edit fieldset.id-card > legend + * {
    margin-top: 0;
  }
}

/* ---- Élèves sur téléphone ---- */
@media screen and (max-width: 760px) {
  .list-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-field {
    flex-basis: 100%;
  }

  .list-toolbar .filters > select {
    flex-basis: calc(50% - 4px);
  }

  .students-list-view {
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .students-list-view tr.student-row {
    padding: 14px;
    border-radius: 14px;
    box-shadow: var(--shadow-card);
  }

  .student-header {
    padding: 16px;
  }

  .id-card {
    padding: 16px;
  }
}

@media screen and (max-width: 980px) {
  .toast:empty {
    display: inline-flex;
  }

  .list-toolbar .filters,
  .list-toolbar .filters.filters {
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }
}

/* ---- Bloc utilisateur du menu : initiales, nom, rôle, déconnexion ---- */
@media screen {
  .session-box {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 14px 6px 0;
  }

  .session-box .session-avatar {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: #fff;
    background: linear-gradient(135deg, #7f56d9, #5a35b0);
    border-radius: 50%;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .session-id {
    display: grid;
    min-width: 0;
    line-height: 1.3;
  }

  .session-id strong,
  .session-id span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar .session-box #logout-button {
    width: 34px;
    min-height: 34px;
    margin: 0;
    padding: 0;
    justify-content: center;
    border-radius: 8px;
  }

  .sidebar .session-box #logout-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media screen and (max-width: 980px) {
  .sidebar .session-box #logout-button {
    width: auto;
    padding: 0 12px;
    gap: 8px;
  }

  .sidebar .session-box #logout-button span {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
  }
}

/* ---- Pastilles de sélection (classes, matières) et semaines ---- */
@media screen {
  .subject-chip {
    min-height: 36px;
    color: var(--ink-2);
    border-color: var(--line-strong);
    font-weight: 500;
  }

  .subject-chip:hover {
    color: var(--ink);
    background: var(--hover);
  }

  .subject-chip.active {
    color: var(--primary-ink);
    background: var(--primary-soft);
    border-color: var(--primary-line);
    font-weight: 600;
  }

  .res-count {
    color: var(--muted);
    background: #f2f4f7;
    font-weight: 600;
  }

  .subject-chip.active .res-count {
    color: var(--primary-ink);
    background: var(--paper);
  }

  .subject-chip.is-todo:not(.active) {
    border-color: var(--amber-line);
    background: var(--amber-bg);
  }

  .res-week {
    border-radius: 10px;
  }

  .res-week.is-now {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
  }

  .res-week.is-now small {
    color: #e9e1fc;
  }

  .res-week.is-selected:not(.is-now) {
    box-shadow: 0 0 0 2px var(--primary);
  }
}

/* ---- Tableau de bord sur téléphone : chiffres à la bonne taille ---- */
@media screen and (max-width: 760px) {
  .dash-kpi {
    padding: 14px 16px;
  }

  .dash-kpi-label {
    font-size: 10.5px;
    letter-spacing: 0.045em;
  }

  .dash-kpi b {
    font-size: 21px;
    letter-spacing: -0.02em;
  }

  .dash-kpi b small {
    font-size: 12px;
  }

  .dash-kpi-sub {
    font-size: 13px;
  }
}

/* ---- Finitions : fenêtres, fichiers, barres, défilement ---- */
@media screen {
  .dialog-overlay {
    background: rgba(16, 24, 40, 0.42);
    backdrop-filter: blur(3px);
    animation: fade-in var(--t-med) ease;
  }

  .dialog-box {
    display: grid;
    gap: 12px;
    min-width: min(380px, calc(100vw - 32px));
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    animation: dialog-in var(--t-med) var(--ease-out);
  }

  .dialog-box h3 {
    margin: 0;
    font-size: 17px;
  }

  .help-dialog {
    border-radius: 18px;
  }

  input[type="file"] {
    padding: 6px;
    color: var(--muted);
    font-size: 14px;
  }

  input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 6px 12px;
    color: var(--ink-2);
    background: var(--surface-soft);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--t-fast) ease;
  }

  input[type="file"]::file-selector-button:hover {
    background: var(--hover);
  }

  #backup-panel .primary-button {
    justify-self: start;
    width: auto;
  }

  /* Barres de progression : fines et calmes */
  .dash-bar {
    height: 4px;
    background: #eceef2;
  }

  .dash-kpi-bar {
    height: 6px;
    background: #eceef2;
  }

  [data-scroll-table] {
    width: 34px;
    min-height: 34px;
    padding: 0;
  }

  [data-scroll-table] .ico {
    width: 18px;
    height: 18px;
  }

  .session-id span {
    white-space: normal;
  }
}

@media screen and (max-width: 760px) {
  .id-toolbar > button {
    flex: none;
    width: auto;
  }
}

/* ---- Barres des moyennes (Notes, fiche) : plus fines, repère de classe plus léger ---- */
@media screen {
  .avg-bar {
    height: 6px;
    background: #eceef2;
  }

  .avg-bar-fill {
    height: 6px;
  }

  .class-mark {
    top: -4px;
    width: 2px;
    height: 14px;
    background: var(--ink-2);
  }

  .class-mark-legend {
    width: 2px;
    height: 12px;
    background: var(--ink-2);
  }
}

/* Élèves, écrans moyens : recherche sur sa ligne, filtres en colonnes égales (jamais tronqués) */
@media screen and (max-width: 1360px) {
  .list-toolbar .filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  }

  .list-toolbar .search-field {
    grid-column: 1 / -1;
  }
}
