/* Charte officielle Exercices Excel (exercicesexcel.com)
   Vert Excel #217346 | Vert sombre #12261a | Vert clair #9be3b2
   Rouge erreur #b3261e sur #fdecea | Encre #111827 | Gris #f3f4f6 */

:root {
  --excel-green: #217346;
  --excel-green-hover: #1a5c38;
  --excel-dark: #12261a;
  --excel-light: #9be3b2;
  --excel-soft: #eef7f1;
  --error-fg: #b3261e;
  --error-bg: #fdecea;
  --error-border: #f5c6c2;
  --ink: #111827;
  --ink-muted: #4b5563;
  --ink-subtle: #6b7280;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --border: #e5e7eb;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-narrow {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header unifié */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--excel-dark);
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: block;
}

.brand-accent {
  color: var(--excel-green);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-muted);
  transition: color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--excel-green);
}

.nav-link.active {
  font-weight: 600;
}

/* Main */
main {
  flex: 1;
}

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.98rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--excel-green);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(33, 115, 70, 0.22);
}

.btn-primary:hover {
  background: var(--excel-green-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--excel-dark);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--excel-green);
  color: var(--excel-green);
}

/* Hero accueil */
.hero {
  padding: 4.5rem 0 3.5rem;
  text-align: center;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--excel-green);
  background: var(--excel-soft);
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.hero h1 {
  margin: 0 auto 1.1rem;
  max-width: 780px;
  font-size: clamp(2.1rem, 4.5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--excel-dark);
}

.hero-lead {
  margin: 0 auto 2rem;
  max-width: 640px;
  font-size: 1.15rem;
  color: var(--ink-muted);
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

/* Aperçu visuel de la promesse produit */
.demo-card {
  margin: 3rem auto 0;
  max-width: 740px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 45px rgba(18, 38, 26, 0.08);
  overflow: hidden;
}

.demo-fx-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.demo-cell-ref {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  font-weight: 700;
  color: var(--excel-dark);
}

.demo-fx-label {
  color: var(--ink-subtle);
  font-style: italic;
  font-weight: 700;
}

.demo-formula {
  color: var(--ink);
  font-weight: 600;
}

.demo-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.demo-grid th {
  background: #e2efda;
  color: #2c4a1d;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  border: 1px solid #d4d4d4;
  text-align: center;
}

.demo-grid td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e7eb;
}

.demo-grid .row-num {
  width: 40px;
  text-align: center;
  background: #e2efda;
  color: #2c4a1d;
  font-weight: 600;
}

.demo-grid .target-cell {
  background: #eef7f1;
  border: 2px solid var(--excel-green);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--excel-green);
}

.demo-feedback {
  padding: 1rem 1.25rem;
  background: var(--error-bg);
  border-top: 1px solid var(--error-border);
  color: var(--error-fg);
  font-size: 0.94rem;
}

.demo-feedback strong {
  display: block;
  margin-bottom: 0.25rem;
}

/* Sections & cartes */
.section {
  padding: 3rem 0 4rem;
}

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-header h1,
.section-header h2 {
  margin: 0 0 0.7rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--excel-dark);
}

.section-header h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.75rem);
}

.section-header p {
  margin: 0 auto;
  max-width: 660px;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.pillar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.pillar-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--excel-dark);
}

.pillar-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.94rem;
}

/* Catalogue */
.category-group {
  margin-bottom: 2.75rem;
}

.category-title {
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-count {
  color: #9ca3af;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: var(--excel-green);
  box-shadow: 0 10px 24px rgba(18, 38, 26, 0.07);
  transform: translateY(-2px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.card h2,
.card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--excel-dark);
}

.card:hover h2,
.card:hover h3 {
  color: var(--excel-green);
}

.card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.badge {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-muted);
}

.badge-beginner {
  background: var(--excel-soft);
  color: var(--excel-green);
}

.badge-intermediate {
  background: #fef3c7;
  color: #92400e;
}

.badge-advanced {
  background: var(--error-bg);
  color: var(--error-fg);
}

/* Articles SEO */
.breadcrumb {
  font-size: 0.86rem;
  color: var(--ink-subtle);
  margin: 0 0 1rem;
}

.breadcrumb a:hover {
  color: var(--excel-green);
}

.article-title {
  margin: 0 0 1.25rem;
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--excel-dark);
}

.article-chapo {
  background: var(--excel-soft);
  border-left: 4px solid var(--excel-green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  margin: 0 0 2rem;
  font-size: 1.06rem;
  color: var(--excel-dark);
}

.article-body {
  color: #374151;
  font-size: 1.03rem;
  line-height: 1.75;
}

.article-body h2 {
  margin: 2.2rem 0 0.75rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--excel-dark);
  letter-spacing: -0.015em;
}

.article-body h3 {
  margin: 1.6rem 0 0.55rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--excel-dark);
}

.article-body p {
  margin: 0 0 1rem;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1rem 1.35rem;
  padding: 0;
}

.article-body li {
  margin: 0.35rem 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-muted);
  color: var(--excel-dark);
  padding: 0.12em 0.4em;
  border-radius: 5px;
}

.article-body pre {
  margin: 0 0 1.25rem;
  padding: 0.95rem 1.15rem;
  background: var(--excel-soft);
  border: 1px solid var(--excel-light);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.article-body pre code {
  background: none;
  padding: 0;
  color: var(--excel-dark);
}

.article-cta {
  margin-top: 2.75rem;
  border: 2px solid var(--excel-green);
  background: var(--excel-soft);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  text-align: center;
}

.article-cta-eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--excel-green);
  margin: 0 0 0.45rem;
}

.article-cta p {
  margin: 0 0 1.25rem;
  color: var(--excel-dark);
  font-size: 1.04rem;
}

/* Footer unifié */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.25rem 0;
  margin-top: 2rem;
  color: var(--ink-subtle);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a:hover {
  color: var(--excel-green);
}

.empty-state {
  text-align: center;
  color: var(--ink-subtle);
  padding: 2.5rem 1rem;
}

@media (max-width: 640px) {
  .header-inner {
    height: auto;
    padding: 0.75rem 0;
    flex-direction: column;
    align-items: flex-start;
  }
  .site-nav {
    gap: 1rem;
  }
  .hero {
    padding: 3rem 0 2.5rem;
  }
}

/* =========================================================
   Interface exercice interactif (/lesson/:slug)
   ========================================================= */

.app-body {
  background: #ffffff;
}

.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--excel-dark);
  color: #ffffff;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  z-index: 60;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-light {
  color: #ffffff;
}

.mobile-menu-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 45;
}

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

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--excel-dark);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 50;
}

.sidebar-brand {
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.sidebar-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 0 0.65rem 0.65rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.52rem 0.7rem;
  border-radius: 8px;
  font-size: 0.87rem;
  color: #cbd5e1;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-link.active {
  background: var(--excel-green);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.sidebar-link.active .sidebar-dot {
  background: var(--excel-light);
}

.sidebar-link-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer-link {
  font-size: 0.85rem;
  color: #9be3b2;
  font-weight: 600;
}

.sidebar-footer-link:hover {
  text-decoration: underline;
}

.lesson-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

.lesson-header-text {
  min-width: 0;
}

.lesson-header h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--excel-dark);
}

.lesson-header p {
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
  color: var(--ink-subtle);
}

.btn-tool {
  background: var(--surface-muted);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-tool:hover {
  border-color: var(--excel-green);
  color: var(--excel-green);
  background: var(--excel-soft);
}

.lesson-columns {
  flex: 1;
  display: flex;
  min-height: 0;
}

.lesson-sidepane {
  width: 380px;
  flex-shrink: 0;
  background: #f9fafb;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.pane-block {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.pane-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-subtle);
  cursor: default;
}

.mobile-only {
  display: none;
}

.instructions-body {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.theory-box {
  background: var(--excel-soft);
  border: 1px solid var(--excel-light);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.theory-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--excel-green);
  margin-bottom: 0.35rem;
}

.instructions-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  font-size: 0.92rem;
}

.rich-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
}

.rich-text code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.instructions-hint {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-subtle);
}

.mono-ref {
  font-family: var(--font-mono);
  color: var(--excel-green);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface-muted);
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.related-guide-link {
  display: block;
  font-size: 0.84rem;
  color: var(--excel-green);
  background: #ffffff;
  border: 1px dashed var(--excel-light);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
}

.related-guide-link:hover {
  background: var(--excel-soft);
}

/* Panneau d'erreur (rouge doux officiel) & réussite (vert Excel) */
.feedback-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 12px;
  padding: 1rem;
  color: var(--error-fg);
}

.feedback-error-msg {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
}

.feedback-sub {
  margin: 0.45rem 0 0;
  font-size: 0.86rem;
}

.feedback-code {
  font-family: var(--font-mono);
  background: rgba(179, 38, 30, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.feedback-points {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--error-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.feedback-ai {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--error-border);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.5;
}

.feedback-success {
  background: var(--excel-soft);
  border: 1px solid var(--excel-light);
  border-radius: 12px;
  padding: 1.25rem;
}

.feedback-success h3 {
  margin: 0.3rem 0 1rem;
  text-align: center;
  color: var(--excel-dark);
  font-size: 1.15rem;
}

.recap-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.recap-stat {
  background: #ffffff;
  border: 1px solid var(--excel-light);
  border-radius: 8px;
  padding: 0.65rem;
  text-align: center;
}

.recap-stat-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--excel-dark);
}

.recap-stat-lbl {
  font-size: 0.74rem;
  color: var(--ink-subtle);
}

.recap-history {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recap-item {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
}

.recap-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.recap-actions .btn {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
}

/* Tableur Excel */
.lesson-gridpane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  user-select: none;
}

.fx-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.fx-ref {
  width: 58px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  color: var(--excel-dark);
}

.fx-symbol {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  color: var(--ink-subtle);
  padding: 0 0.25rem;
}

.fx-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.fx-input:focus {
  border-color: var(--excel-green);
  box-shadow: 0 0 0 2px rgba(33, 115, 70, 0.15);
}

.mouse-warning {
  padding: 0.55rem 1rem;
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  font-size: 0.85rem;
}

.sheet-scroll {
  flex: 1;
  overflow: auto;
}

.excel-table {
  border-collapse: collapse;
  table-layout: fixed;
}

.excel-table th,
.excel-table td {
  border: 1px solid #d4d4d4;
}

.col-corner,
.row-header {
  width: 44px;
  background: #e2efda;
  color: #2c4a1d;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.col-header {
  width: 112px;
  height: 28px;
  background: #e2efda;
  color: #2c4a1d;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 5;
}

.subheader-cell {
  height: 32px;
  padding: 0 0.5rem;
  background: #d6e4cc;
  color: #2c4a1d;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.sheet-cell {
  width: 112px;
  height: 34px;
  padding: 0 0.45rem;
  background: #ffffff;
  position: relative;
  cursor: default;
}

.sheet-cell.is-target {
  background: var(--excel-soft);
  border-color: var(--excel-light);
  cursor: cell;
}

.sheet-cell.is-target .cell-display {
  color: var(--excel-green);
  font-weight: 700;
}

.sheet-cell.is-selected {
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
  z-index: 4;
}

.sheet-cell.is-drag {
  background: #dbeafe;
  outline: 1px solid #3b82f6;
  outline-offset: -1px;
}

.sheet-cell.is-pointed {
  background: var(--excel-soft);
  outline: 2px dashed var(--excel-green);
  outline-offset: -2px;
  z-index: 4;
}

.sheet-cell.is-success {
  background: #dcfce7;
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
}

.cell-display {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.cell-editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
  padding: 0 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--excel-green);
  background: #ffffff;
  z-index: 6;
}

@media (max-width: 1024px) {
  .mobile-topbar {
    display: flex;
  }
  .app-shell {
    padding-top: 56px;
  }
  .app-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .lesson-workspace {
    height: auto;
    min-height: calc(100vh - 56px);
  }
  .lesson-columns {
    flex-direction: column;
  }
  .lesson-sidepane {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .pane-toggle {
    cursor: pointer;
  }
  .mobile-only {
    display: inline;
  }
  .lesson-gridpane {
    min-height: 420px;
  }
}

/* =========================================================
   Auth, formulaires, coches sidebar et Administration
   ========================================================= */

.sidebar-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
}

.sidebar-link.is-completed .sidebar-dot {
  background: var(--excel-light);
  color: var(--excel-dark);
}

.sidebar-pro {
  font-size: 0.65rem;
  font-weight: 800;
  background: rgba(250, 204, 21, 0.2);
  color: #fde047;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

.sidebar-points {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--excel-light);
  margin-bottom: 0.55rem;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #d1d5db;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.sidebar-logout-btn:hover {
  color: #ffffff;
  border-color: #ffffff;
}

.auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(18, 38, 26, 0.07);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--excel-dark);
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.94rem;
  color: var(--ink);
  background: #ffffff;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--excel-green);
  box-shadow: 0 0 0 3px rgba(33, 115, 70, 0.14);
}

.alert-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-fg);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: var(--excel-soft);
  border: 1px solid var(--excel-light);
  color: var(--excel-dark);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  background: var(--surface-muted);
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-subtle);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.btn-danger {
  color: var(--error-fg);
  border-color: var(--error-border);
  background: var(--error-bg);
}

.btn-danger:hover {
  background: #fbd5d2;
  color: var(--error-fg);
  border-color: var(--error-fg);
}

.nav-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--excel-soft);
  border: 1px solid var(--excel-light);
  color: var(--excel-dark);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.84rem;
}

.nav-user-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--excel-green);
}

.nav-user-pts {
  color: var(--excel-green);
  font-weight: 700;
}

.nav-logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-logout-btn:hover {
  border-color: var(--error-fg);
  color: var(--error-fg);
}

/* Sélecteur de langue déroulant (0 JS, 7 langues) */
.lang-dropdown {
  position: relative;
  display: inline-block;
}
.lang-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-alt, #f1f5f2);
  border: 1px solid var(--border, #dce5df);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink, #1f2937);
  cursor: pointer;
  user-select: none;
}
.lang-trigger::-webkit-details-marker {
  display: none;
}
.lang-trigger:hover {
  border-color: var(--excel-green);
  color: var(--excel-green);
}
.lang-caret {
  font-size: 0.7rem;
  opacity: 0.75;
}
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 215px;
  padding: 0.35rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border, #dce5df);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 80;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--ink, #1f2937);
  text-decoration: none;
  font-size: 0.84rem;
}
.lang-option:hover {
  background: var(--surface-alt, #f1f5f2);
  color: var(--excel-green);
}
.lang-option.active {
  background: rgba(29, 111, 66, 0.12);
  color: var(--excel-green);
  font-weight: 700;
}
.lang-option-code {
  min-width: 46px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0.8;
}
.lang-dropdown-dark .lang-trigger {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}
.lang-dropdown-dark .lang-trigger:hover {
  border-color: var(--excel-light, #9be3b2);
  color: var(--excel-light, #9be3b2);
}
.lang-dropdown-dark .lang-menu {
  left: 0;
  right: auto;
}


/* =========================================================================
 * Simulateur de Tableau Croisé Dynamique (TCD / PivotTable)
 * ========================================================================= */
.pivot-validate-btn {
  padding: 0.48rem 1.05rem;
  font-size: 0.88rem;
}
.pivot-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.15rem;
  padding: 1.15rem 1.35rem 2rem;
  align-items: start;
}
.pivot-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.pivot-card {
  background: #ffffff;
  border: 1px solid var(--border, #dce5df);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.pivot-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.94rem;
  color: var(--excel-dark);
}
.pivot-filter-bar {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--excel-green);
}
.pivot-table-scroll {
  overflow-x: auto;
}
.pivot-placeholder {
  padding: 2rem 1rem;
  text-align: center;
  border: 2px dashed var(--border, #dce5df);
  border-radius: 10px;
  color: var(--ink-muted, #4b5563);
  font-size: 0.9rem;
  background: var(--surface-alt, #f8faf9);
}
.pivot-result-table,
.pivot-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.pivot-result-table th,
.pivot-result-table td,
.pivot-data-table th,
.pivot-data-table td {
  padding: 0.48rem 0.68rem;
  border: 1px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}
.pivot-result-table th {
  background: #edf7f1;
  color: var(--excel-dark);
  font-weight: 700;
}
.pivot-data-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}
.pivot-result-table .num,
.pivot-data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pivot-result-table .row-lbl {
  font-weight: 600;
  color: #1e293b;
}
.pivot-result-table .total-col {
  background: #f6fbf8;
  font-weight: 700;
}
.pivot-result-table .grand-total-row td {
  background: #e6f4ec;
  font-weight: 800;
  color: var(--excel-dark);
  border-top: 2px solid var(--excel-green);
}
.pivot-source-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  color: var(--excel-dark);
}
.pivot-source-summary::-webkit-details-marker {
  display: none;
}
.pivot-source-count {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* Panneau droit style Excel */
.pivot-panel {
  background: #ffffff;
  border: 1px solid var(--border, #dce5df);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 1rem;
}
.pivot-panel-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--excel-dark);
  margin-bottom: 0.25rem;
}
.pivot-panel-hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.4;
}
.pivot-field-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border, #dce5df);
}
.pivot-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.6rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
}
.pivot-field-chip:hover {
  border-color: var(--excel-green);
  background: #edf7f1;
}
.pivot-field-chip.is-used {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--excel-dark);
}
.pivot-field-chip.is-selected {
  border-color: var(--excel-green);
  background: var(--excel-green);
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(29, 111, 66, 0.22);
}
.pivot-field-chip.is-selected .pivot-field-type {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
.pivot-field-type {
  font-size: 0.66rem;
  font-weight: 800;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.pivot-zones-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.pivot-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.5rem;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.15s, background-color 0.15s;
}
.pivot-zone.is-dragover,
.pivot-zone.is-pickable:hover {
  border-color: var(--excel-green);
  background: #edf7f1;
}
.pivot-zone.is-pickable {
  border-style: solid;
  border-color: #86efac;
  cursor: pointer;
}
.pivot-zone-head {
  font-size: 0.75rem;
  font-weight: 800;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pivot-zone-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.pivot-zone-empty {
  font-size: 0.74rem;
  color: #94a3b8;
  font-style: italic;
}
.pivot-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.28rem 0.48rem;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid #b7dec5;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--excel-dark);
}
.pivot-pill-rich {
  flex-wrap: wrap;
}
.pivot-pill-select {
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0.12rem 0.28rem;
  background: #f8fafc;
  color: var(--excel-green);
  max-width: 100%;
}
.pivot-pill-remove {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.15rem;
}
.pivot-pill-remove:hover {
  color: #dc2626;
}
@media (max-width: 980px) {
  .pivot-layout {
    grid-template-columns: 1fr;
    padding: 0.85rem;
  }
  .pivot-panel {
    position: static;
  }
}
