/* Inter */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url('fonts/playfair-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 700 800;
  font-display: swap;
  src: url('fonts/playfair-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/playfair-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/playfair-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --ink: #1a1525;
  --muted: #6b6280;
  --line: #ddd8ea;
  --soft: #f6f4fb;
  --panel: #ffffff;
  --accent: #7c3aed;
  --accent-strong: #5b21b6;
  --accent-glow: rgba(124, 58, 237, 0.12);
  --nav-active-bar: #a78bfa;
  --status-acquired: #16a34a;
  --status-acquired-bg: #dcfce7;
  --status-in-progress: #d97706;
  --status-in-progress-bg: #fef3c7;
  --status-not-acquired: #dc2626;
  --status-not-acquired-bg: #fee2e2;
}

/* ── Mode sombre ─────────────────────────────────────────────────────────────── */

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e2d9f3;
  --muted: #8b7da8;
  --line: #2d2540;
  --soft: #1a1528;
  --panel: #221b33;
  --accent: #9b6dff;
  --accent-strong: #c4b5fd;
  --accent-glow: rgba(155, 109, 255, 0.2);
  --nav-active-bar: #c4b5fd;
  --status-acquired: #34d399;
  --status-acquired-bg: rgba(52,211,153,0.15);
  --status-in-progress: #fbbf24;
  --status-in-progress-bg: rgba(251,191,36,0.12);
  --status-not-acquired: #f87171;
  --status-not-acquired-bg: rgba(248,113,113,0.12);
}

[data-theme="dark"] body {
  background: linear-gradient(135deg,rgba(88,28,220,.12),transparent 34%),
              linear-gradient(315deg,rgba(109,40,217,.08),transparent 40%), #100d1a;
}

[data-theme="dark"] .login-overlay { background: #100d1a; }

[data-theme="dark"] .sidebar {
  background: #0d0a18;
  border-right-color: rgba(255,255,255,0.04);
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--soft);
  color: var(--ink);
  border-color: var(--line);
}

[data-theme="dark"] .eval-grid th,
[data-theme="dark"] .bilan-table th { background: var(--soft); }

[data-theme="dark"] .domain-row td,
[data-theme="dark"] .hm-domain-row td { background: rgba(155,109,255,0.12); color: var(--accent-strong); }

[data-theme="dark"] .eval-cell:hover { background: rgba(155,109,255,0.1); }

[data-theme="dark"] .badge-acquis     { background: var(--status-acquired-bg);    color: var(--status-acquired); }
[data-theme="dark"] .badge-en-cours   { background: var(--status-in-progress-bg); color: var(--status-in-progress); }
[data-theme="dark"] .badge-non-acquis { background: var(--status-not-acquired-bg);color: var(--status-not-acquired); }

[data-theme="dark"] .primary-button { box-shadow: 0 1px 4px rgba(155,109,255,0.3); }

[data-theme="dark"] .topbar { background: #160f26; border-bottom-color: var(--line); }

/* Éléments avec anciens backgrounds blancs codés en dur */
[data-theme="dark"] .student-name,
[data-theme="dark"] .comp-item-name,
[data-theme="dark"] .student-item,
[data-theme="dark"] .comp-item,
[data-theme="dark"] .panel,
[data-theme="dark"] .bilan-table td,
[data-theme="dark"] .bilan-table th,
[data-theme="dark"] .eval-grid td,
[data-theme="dark"] .eval-grid th { color: var(--ink); }

[data-theme="dark"] .login-panel,
[data-theme="dark"] .modal-panel  { background: var(--panel); border-color: var(--line); }

[data-theme="dark"] .google-signin-button { background: #2a1f44; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .google-signin-button:hover { background: #362854; }

[data-theme="dark"] select option { background: var(--soft); color: var(--ink); }

[data-theme="dark"] .topbar { color: var(--ink); }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] strong, [data-theme="dark"] label { color: var(--ink); }

[data-theme="dark"] .comp-domain-header { background: rgba(155,109,255,0.15); color: var(--accent-strong); }

[data-theme="dark"] .bilan-toggle button { background: var(--soft); color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .bilan-toggle button.active { background: var(--accent); color: white; }

[data-theme="dark"] .rgpd-banner { background: rgba(155,109,255,0.1); color: var(--muted); border-color: rgba(155,109,255,0.2); }
[data-theme="dark"] .import-banner { background: var(--soft); border-color: var(--line); color: var(--ink); }

[data-theme="dark"] .empty-state,
[data-theme="dark"] .eyebrow { color: var(--muted); }

[data-theme="dark"] .nav-button { color: #b8a8d8; }
[data-theme="dark"] .nav-button:hover { color: #e2d9f3; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  background:
    linear-gradient(135deg, rgba(167, 139, 250, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(196, 181, 253, 0.22), transparent 40%),
    #f0eef8;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

/* ── Login page (login.html) ───────────────────────────────────────────────── */

body.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 18px 60px rgba(26, 15, 46, 0.12), 0 2px 8px rgba(124, 58, 237, 0.08);
  display: grid;
  gap: 16px;
}

.login-panel h1, .login-panel p { margin-bottom: 0; }

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.login-brand img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.login-brand strong { display: block; font-size: 1.1rem; }
.login-brand small { display: block; color: var(--muted); font-size: 0.78rem; }

.google-signin-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 20px;
  border: 1px solid #dadce0;
  border-radius: 8px;
  background: var(--panel);
  color: #3c4043;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.google-signin-button:hover { background: #f8f9fa; box-shadow: 0 2px 6px rgba(0,0,0,0.14); }

.login-toggle {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  justify-self: center;
}
.login-toggle:hover { color: var(--ink); }

.password-login-form { display: grid; gap: 12px; }
.password-login-form.hidden { display: none; }

/* ── Login overlay (in-app) ────────────────────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f0eef8;
}

.login-overlay.hidden { display: none; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.nav-button, .secondary-button, .primary-button, .ghost-button, .icon-button {
  min-height: 40px;
  border-radius: 8px;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 0 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 3px rgba(124,58,237,0.3), 0 4px 12px rgba(124,58,237,0.15);
}
.primary-button:hover {
  background: var(--accent-strong);
  box-shadow: 0 2px 6px rgba(124,58,237,0.35), 0 6px 18px rgba(124,58,237,0.2);
}

.secondary-button {
  background: #ede9f8;
  color: var(--accent-strong);
  padding: 0 14px;
  font-weight: 600;
}
.secondary-button:hover { background: #ddd6f3; }

.ghost-button {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  padding: 0 14px;
  font-weight: 600;
}
.ghost-button:hover { background: var(--accent-glow); border-color: var(--accent); }

.danger-button {
  background: #7f1d1d;
  color: white;
  padding: 0 14px;
  font-weight: 700;
}
.danger-button:hover { background: #6b1a1a; }

.icon-button {
  width: 36px;
  height: 36px;
  background: #f3e8ff;
  color: var(--accent-strong);
  font-size: 1.1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.icon-button:hover { background: #ede9f8; }

.icon-button.danger { background: #fee2e2; color: #dc2626; }
.icon-button.danger:hover { background: #fecaca; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
  background: #1a0f2e;
  color: #ede9f8;
  min-height: 100vh;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255,255,255,0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

.brand strong, .brand small { display: block; }
.brand small { color: #9d8ec7; margin-top: 2px; font-size: 0.75rem; letter-spacing: 0.02em; }

.nav { display: grid; gap: 4px; }

.nav-button {
  text-align: left;
  padding: 0 12px 0 14px;
  background: transparent;
  color: #c4b5fd;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-left: 3px solid transparent;
}

.nav-button svg { flex-shrink: 0; opacity: 0.7; transition: opacity 160ms ease; }

.nav-button:hover {
  background: rgba(167, 139, 250, 0.1);
  color: #ede9f8;
  border-left-color: rgba(167, 139, 250, 0.35);
}
.nav-button:hover svg { opacity: 1; }

.nav-button.active {
  background: rgba(167, 139, 250, 0.15);
  color: #ffffff;
  font-weight: 600;
  border-left-color: var(--nav-active-bar);
}
.nav-button.active svg { opacity: 1; }

.nav-separator {
  height: 1px;
  background: rgba(255,255,255,0.07);
  margin: 4px 0;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.side-actions button {
  text-align: center;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */

.app-shell {
  min-width: 0;
  padding: 28px;
  position: relative;
  z-index: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.05em;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; }
h3 { font-size: 0.9375rem; font-weight: 600; margin-bottom: 8px; }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input, select, textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  min-width: 0;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 80px; }

.view { display: none; }
.view.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 18px rgba(26,15,46,0.06), 0 1px 4px rgba(124,58,237,0.04);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.empty-state {
  padding: 32px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfaff;
  text-align: center;
}
.empty-state p { margin: 6px 0 0; color: var(--muted); }

/* ── RGPD banner ───────────────────────────────────────────────────────────── */

.rgpd-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3e8ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--accent-strong);
  margin-bottom: 18px;
}
.rgpd-banner svg { flex-shrink: 0; }

/* ── Eval grid ─────────────────────────────────────────────────────────────── */

.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.week-nav button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #ede9f8;
  color: var(--accent-strong);
  border: 0;
  font-size: 1rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 160ms;
}
.week-nav button:hover { background: #ddd6f3; }
.week-nav strong { font-size: 0.9rem; min-width: 100px; text-align: center; }

.grid-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 12px rgba(26,15,46,0.06);
}

.eval-grid {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.82rem;
}

.eval-grid th, .eval-grid td {
  border: 1px solid var(--line);
  padding: 0;
}

.eval-grid thead th {
  background: #1a0f2e;
  color: #ede9f8;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 10px 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 3;
}

.eval-grid thead th.col-comp {
  background: #2d1b52;
  text-align: left;
  min-width: 220px;
  max-width: 280px;
  position: sticky;
  left: 0;
  z-index: 4;
}

.eval-grid thead th.col-student {
  min-width: 80px;
  text-align: center;
}

.eval-grid .domain-row td {
  background: #f3eeff;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-strong);
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  left: 0;
}

.eval-grid .comp-row td.col-comp {
  background: var(--panel);
  padding: 8px 12px;
  line-height: 1.35;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 2px solid var(--line);
}

.eval-grid .comp-row td.eval-cell {
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  transition: background 120ms;
  position: relative;
  min-width: 80px;
  height: 48px;
}

.eval-cell:hover { background: #f9f7ff; }

.eval-cell .status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 1rem;
  transition: transform 120ms;
}

.eval-cell:hover .status-badge { transform: scale(1.1); }

.status-acquis .status-badge { background: var(--status-acquired-bg); color: var(--status-acquired); }
.status-en-cours .status-badge { background: var(--status-in-progress-bg); color: var(--status-in-progress); }
.status-non-acquis .status-badge { background: var(--status-not-acquired-bg); color: var(--status-not-acquired); }
.status-empty .status-badge { background: #f3f4f6; color: #9ca3af; }

.obs-dot {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Students view ─────────────────────────────────────────────────────────── */

.student-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.student-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}

.student-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.student-name { flex: 1; font-weight: 600; }

/* ── Competencies view ─────────────────────────────────────────────────────── */

.comp-domain-group { margin-bottom: 20px; }

.comp-domain-header {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-strong);
  padding: 6px 12px;
  background: #f3eeff;
  border-radius: 6px;
  margin-bottom: 6px;
}

.comp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 4px;
}

.comp-item-name { flex: 1; font-size: 0.875rem; line-height: 1.4; }

/* ── Bilan view ─────────────────────────────────────────────────────────────── */

.bilan-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
  margin-bottom: 18px;
}

.bilan-toggle button {
  padding: 8px 18px;
  background: var(--panel);
  color: var(--muted);
  border: 0;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms, color 160ms;
}

.bilan-toggle button.active {
  background: var(--accent);
  color: white;
}

.bilan-toggle button:hover:not(.active) { background: #f3eeff; color: var(--accent); }

.bilan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.bilan-table th, .bilan-table td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
}

.bilan-table th {
  background: #f3eeff;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bilan-table td:first-child { font-weight: 600; max-width: 240px; }

.badge-acquis { background: var(--status-acquired-bg); color: var(--status-acquired); padding: 2px 8px; border-radius: 20px; font-weight: 700; font-size: 0.75rem; white-space: nowrap; }
.badge-en-cours { background: var(--status-in-progress-bg); color: var(--status-in-progress); padding: 2px 8px; border-radius: 20px; font-weight: 700; font-size: 0.75rem; white-space: nowrap; }
.badge-non-acquis { background: var(--status-not-acquired-bg); color: var(--status-not-acquired); padding: 2px 8px; border-radius: 20px; font-weight: 700; font-size: 0.75rem; white-space: nowrap; }
.badge-empty { background: #f3f4f6; color: #9ca3af; padding: 2px 8px; border-radius: 20px; font-size: 0.75rem; white-space: nowrap; }

/* ── Observation modal ─────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,15,46,0.55);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal-panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 24px;
  width: min(480px, 100%);
  box-shadow: 0 24px 80px rgba(26,15,46,0.2);
  display: grid;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-header small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.mic-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent-strong);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms, border-color 160ms;
}
.mic-button:hover { background: #f3eeff; border-color: var(--accent); }
.mic-button.recording { background: #fee2e2; border-color: #dc2626; color: #dc2626; animation: pulse-mic 1s infinite; }
@keyframes pulse-mic { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── CGU overlay ───────────────────────────────────────────────────────────── */

.cgu-panel {
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cgu-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
  font-size: 0.875rem;
  line-height: 1.6;
}
.cgu-body h3 { margin-top: 16px; font-size: 0.9rem; }
.cgu-body h3:first-child { margin-top: 0; }
.cgu-body ul { padding-left: 18px; margin: 0 0 8px; }
.cgu-body p { margin: 0 0 8px; }

.consent-checkbox-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.875rem;
  cursor: pointer;
}
.consent-checkbox-label input { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

/* ── Settings view ─────────────────────────────────────────────────────────── */

.settings-section { margin-bottom: 24px; }
.settings-section h3 { border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* ── Help view ─────────────────────────────────────────────────────────────── */

.help-body { max-width: 640px; }
.help-body h3 { color: var(--accent); margin-top: 20px; }
.help-body p, .help-body li { line-height: 1.65; margin-bottom: 8px; }

/* ── Import banner ─────────────────────────────────────────────────────────── */

.import-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ede9f8;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.import-banner button { flex-shrink: 0; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */

.danger-text { color: #dc2626; font-size: 0.85rem; }
.success-text { color: var(--status-acquired); font-size: 0.85rem; }
.hidden { display: none !important; }

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.form-row label { flex: 1; }

select option { padding: 4px; }

.mobile-login-button { display: none; }

/* ── Print ─────────────────────────────────────────────────────────────────── */

@media print {
  body { display: block; background: var(--panel); }
  .sidebar, .topbar, .toolbar, .side-actions, .modal-overlay,
  .bilan-toggle, .rgpd-banner, .import-banner { display: none !important; }
  .app-shell { padding: 0; }
  .view { display: block !important; }
  .view:not(.print-active) { display: none !important; }
  .bilan-table { font-size: 10pt; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
  @page { size: A4 landscape; margin: 1.2cm; }
}

/* ── Progression temporelle ─────────────────────────────────────────────────── */

.progression-table .col-week { min-width: 44px; text-align: center; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.prog-chip { display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 0.68rem; font-weight: 700; padding: 2px 5px; min-width: 24px; }
.prog-acquis     { background: #d1fae5; color: #065f46; }
.prog-en-cours   { background: #fef3c7; color: #92400e; }
.prog-non-acquis { background: #fee2e2; color: #991b1b; }
.prog-empty      { background: var(--soft); color: var(--muted); }
td.prog-up   { background: rgba(16,185,129,0.08); }
td.prog-down { background: rgba(239,68,68,0.07); }
.prog-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; font-size: 0.78rem; color: var(--muted); align-items: center; }
.prog-up-ex   { color: #059669; font-weight: 700; font-size: 1rem; }
.prog-down-ex { color: #dc2626; font-weight: 700; font-size: 1rem; }

/* ── Objectifs de période ────────────────────────────────────────────────────── */

.period-badge { display: inline-block; border-radius: 4px; font-size: 0.72rem; font-weight: 700; padding: 2px 7px; white-space: nowrap; }
.period-ahead  { background: #d1fae5; color: #065f46; }
.period-ontime { background: #e0f2fe; color: #0369a1; }
.period-warn   { background: #fef3c7; color: #92400e; }
.period-late   { background: #fee2e2; color: #991b1b; }
.period-select { font-size: 0.75rem; padding: 2px 4px; border-radius: 4px; border: 1px solid var(--line); background: var(--soft); color: var(--muted); min-width: 72px; }
.period-select:focus { outline: 1px solid var(--accent); color: var(--ink); }

/* ── Alertes élèves ──────────────────────────────────────────────────────────── */

.alert-badge { font-size: 0.85rem; line-height: 1; cursor: help; flex-shrink: 0; }

/* ── Heatmap ─────────────────────────────────────────────────────────────────── */

.heatmap-table { border-collapse: separate; border-spacing: 2px; }
.heatmap-table th { font-size: 0.7rem; font-weight: 600; }
.hm-comp-col  { min-width: 180px; max-width: 240px; text-align: left; }
.hm-student-col { width: 36px; text-align: center; font-size: 0.68rem; color: var(--muted); padding: 2px; overflow: hidden; }
.hm-comp-name { max-width: 240px; font-size: 0.78rem; padding: 2px 8px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-cell { width: 32px; height: 26px; border-radius: 3px; cursor: default; transition: transform 0.1s; }
.hm-cell:hover { transform: scale(1.3); z-index: 2; position: relative; }
.hm-domain-row td { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-strong); background: #f3eeff; padding: 5px 6px; border-radius: 3px; }
.hm-legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-size: 0.78rem; color: var(--muted); }
.hm-dot { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: middle; }

/* ── Sub-toggle (Tableau / Heatmap) ─────────────────────────────────────────── */

.bilan-sub-toggle { display: inline-flex; gap: 4px; margin: 12px 0 10px; }
.bilan-sub-toggle button { font-size: 0.78rem; font-weight: 600; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); color: var(--muted); cursor: pointer; transition: background 120ms, color 120ms; }
.bilan-sub-toggle button.active { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Badge niveau élève ─────────────────────────────────────────────────────── */

.level-badge { font-size: 0.68rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--accent-glow); color: var(--accent-strong); flex-shrink: 0; }

/* ── Modal partage ───────────────────────────────────────────────────────────── */

.share-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.5); }
.share-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(480px,100%); display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.share-url-row { display: flex; gap: 8px; align-items: center; }
.share-url { flex:1; font-size:.82rem; padding:8px 10px; border:1px solid var(--line); border-radius:6px; background:var(--soft); color:var(--ink); font-family:monospace; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ── Mobile — 980px (tablette + téléphone) ────────────────────────────────── */

@media (max-width: 980px) {

  /* Layout : sidebar en haut, contenu en dessous */
  body {
    display: block;
    overflow-x: hidden;
  }

  /* Sidebar → barre de navigation horizontale collante */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: auto;
    padding: 10px 14px 8px;
    gap: 8px;
    background-image: none;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  /* Logo + titre compact */
  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }

  .brand strong { font-size: 0.88rem; }
  .brand small   { display: none; }

  /* Nav → pills scrollables horizontalement */
  .nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav::-webkit-scrollbar { display: none; }

  .nav-separator { display: none; }

  .nav-button {
    flex: 0 0 auto;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 2px solid transparent;
    border-radius: 999px;
    padding: 0 12px;
    min-height: 34px;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.06);
  }

  .nav-button svg { display: none; }

  .nav-button.active {
    background: rgba(167,139,250,0.18);
    border-bottom-color: var(--nav-active-bar);
  }

  /* Actions latérales → ligne horizontale compacte */
  .side-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 0;
    border-top: none;
    margin-top: 0;
  }

  .side-actions button {
    width: auto;
    font-size: 0.75rem;
    min-height: 28px;
    padding: 0 10px;
    text-overflow: clip;
  }

  /* Contenu principal */
  .app-shell {
    padding: 14px 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar h1 { font-size: 1.4rem; }
  .eyebrow   { font-size: 0.72rem; margin-bottom: 2px; }

  /* Toolbars */
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar label { min-width: 0; flex: 1 1 120px; }

  /* Grilles → scroll horizontal */
  .grid-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
  }

  .eval-grid .col-comp {
    min-width: 130px;
    max-width: 160px;
    font-size: 0.78rem;
  }

  .eval-grid th.col-student {
    min-width: 60px;
    font-size: 0.75rem;
  }

  /* Formulaires */
  .form-row {
    flex-direction: column;
    gap: 8px;
  }

  .form-row label { min-width: 0; width: 100%; }
  .form-row button { width: 100%; }

  /* Panneaux */
  .panel {
    padding: 16px;
  }

  /* Bilan toggle */
  .bilan-toggle {
    flex-wrap: wrap;
    gap: 6px;
  }

  .bilan-filter-label {
    flex: 1 1 100%;
    margin-left: 0 !important;
    margin-top: 4px;
  }

  /* Import banner */
  .import-banner {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Modal */
  .modal-panel {
    padding: 20px;
  }

  /* Bilan tableau */
  .bilan-table { font-size: 0.8rem; }

  /* Heatmap */
  .hm-comp-name { max-width: 130px; font-size: 0.72rem; }
  .hm-cell      { width: 26px; height: 22px; }

  /* Share panel */
  .share-panel { padding: 20px; }
  .share-url-row { flex-direction: column; }
  .share-url { white-space: normal; }
}

/* ── Mobile — 640px (petits téléphones) ──────────────────────────────────── */

@media (max-width: 640px) {

  .sidebar {
    padding: 8px 12px 6px;
    gap: 6px;
  }

  .brand { display: none; }  /* plus de place pour la nav sur petit écran */

  .nav-button {
    font-size: 0.78rem;
    min-height: 30px;
    padding: 0 10px;
  }

  /* Cacher certains boutons secondaires pour gagner de la place */
  #exportCsvButton,
  #adminButton { display: none; }

  .side-actions {
    gap: 4px;
  }

  .side-actions button {
    font-size: 0.72rem;
    min-height: 26px;
    padding: 0 8px;
  }

  .app-shell {
    padding: 10px 12px;
  }

  .topbar h1 { font-size: 1.15rem; }

  .week-nav button {
    min-width: 32px;
    min-height: 32px;
    font-size: 1rem;
  }

  .panel {
    padding: 12px;
  }

  /* Login */
  .login-overlay { padding: 12px; }
  .login-panel   { padding: 20px; }

  /* Grille éval : compétence plus courte */
  .eval-grid .col-comp {
    min-width: 100px;
    max-width: 130px;
    font-size: 0.72rem;
  }

  .status-badge { font-size: 0.8rem; }

  /* Textes généraux */
  h1 { font-size: 1.1rem !important; }
  h3 { font-size: 0.95rem; }

  /* Bilan */
  .bilan-table { font-size: 0.72rem; }
  .bilan-table th, .bilan-table td { padding: 6px 8px; }

  /* Progression */
  .progression-table .col-week { min-width: 34px; }
  .prog-chip { font-size: 0.6rem; padding: 1px 3px; min-width: 20px; }

  /* Appréciations */
  #appreciationContent .panel { padding: 10px; }
}
