/* Réinitialisation + base */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #f4f6f8;
  color: #1f2937;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { margin: 0 0 8px; font-size: 24px; }
h2 { margin: 32px 0 12px; font-size: 18px; color: #111827; border-bottom: 1px solid #e5e7eb; padding-bottom: 6px; }
h3 { margin: 20px 0 8px; font-size: 15px; color: #374151; }

.muted { color: #6b7280; font-size: 13px; }
.lead { font-size: 15px; color: #1f2937; }

/* Topbar */
.topbar {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.topbar .logo {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  letter-spacing: 0.2px;
}
.topbar .logo-sep { color: #64748b; margin: 0 4px; font-weight: 400; }
.topbar .logo-sub { color: #cbd5e1; font-weight: 500; font-size: 14px; }
.topbar .breadcrumb {
  font-size: 13px;
  color: #cbd5e1;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.topbar .breadcrumb a { color: #93c5fd; text-decoration: none; }
.topbar .breadcrumb a:hover { color: #fff; }
.topbar .breadcrumb .sep { color: #64748b; }

/* Footer */
.footer {
  padding: 16px 24px;
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  border-top: 1px solid #e5e7eb;
  margin-top: 60px;
}

/* Content */
.content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

/* Page header avec actions */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* Boutons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #1f2937;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}
.btn:hover { background: #e5e7eb; text-decoration: none; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { background: transparent; }
.btn.mini { padding: 4px 8px; font-size: 12px; }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  color: #1f2937;
  text-decoration: none;
  transition: all 0.15s;
}
.card:hover {
  text-decoration: none;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37,99,235,0.15);
  transform: translateY(-1px);
}
.card-title { font-weight: 600; font-size: 16px; color: #111827; margin-bottom: 4px; text-transform: capitalize; }
.card-sub { color: #6b7280; font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }

/* Badges / tags */
.badge {
  display: inline-block;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}
.badge.accent { background: #d1fae5; color: #065f46; }
.badge.gray { background: #f3f4f6; color: #6b7280; }
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  margin: 2px;
}
.tag.var { background: #fef3c7; color: #92400e; }
.tag.fn { background: #dbeafe; color: #1e40af; }
.tags { line-height: 2; margin-top: 6px; }

/* Tableaux */
table.data {
  width: 100%;
  background: #fff;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-top: 12px;
}
table.data th {
  background: #1e293b;
  color: #f8fafc;
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
table.data td {
  padding: 10px 12px;
  border-top: 1px solid #f3f4f6;
  vertical-align: top;
  font-size: 13px;
}
table.data tr:hover { background: #fafbfc; }
table.data td.num { color: #9ca3af; font-family: 'Consolas', monospace; }

table.kv {
  background: #fff;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 12px;
  width: 100%;
}
table.kv th {
  text-align: left;
  padding: 8px 12px;
  background: #f9fafb;
  color: #374151;
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid #f3f4f6;
  width: 30%;
  vertical-align: top;
}
table.kv td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  vertical-align: top;
  word-break: break-word;
}

/* Booléens */
.bool.yes { color: #059669; font-weight: 700; }
.bool.no { color: #9ca3af; }

/* Recherche */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.search-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}
.search-bar input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.search-bar select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}
.search-bar .checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 24px;
}
.pagination a {
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #2563eb;
  text-decoration: none;
}
.pagination a:hover { background: #f3f4f6; }
.pagination .current {
  padding: 6px 12px;
  color: #6b7280;
  font-size: 13px;
}

/* Alertes */
.alert {
  background: #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 12px 16px;
  border-radius: 4px;
  color: #78350f;
  margin: 16px 0;
}

/* Formule CEGI */
pre.formule {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 600px;
  overflow-y: auto;
}
.formule-meta { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

pre.json-snippet {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  color: #374151;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

/* Section */
section {
  background: #fff;
  padding: 20px 24px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin: 16px 0;
}

/* Meta block (collapsible) */
details.meta-block {
  background: #fff;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  margin: 12px 0;
}
details.meta-block summary { cursor: pointer; font-weight: 500; color: #374151; }

.back { margin-top: 24px; }

code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  color: #dc2626;
}

/* ============== Page règle : nouveau design ============== */

/* En-tête de règle */
.regle-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  padding: 24px 28px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.regle-hero-main { flex: 1; min-width: 0; }
.regle-eyebrow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.regle-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}
.regle-validite {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 13px;
}
.regle-validite strong { color: #374151; font-family: 'Consolas', monospace; font-weight: 500; }
.regle-hero-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Blocs secondaires (cross-refs, variantes, source) */
.block {
  background: #fff;
  padding: 20px 28px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin: 16px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.block-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  border-bottom: none;
  padding-bottom: 0;
}
.block-title .count, .count {
  color: #94a3b8;
  font-weight: 400;
  font-size: 13px;
}
.block-sub {
  margin: 16px 0 8px;
  font-size: 13px;
  color: #475569;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.block-sub:first-of-type { margin-top: 0; }

tr.current-row { background: #f0f7ff; }
tr.current-row:hover { background: #e0eeff; }

/* =============================================================
   PAGE DÉTAIL RÈGLE — vues Métier / Technique
   ============================================================= */

/* Tabs Métier / Technique */
.view-tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 6px;
  margin: 0 0 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.view-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 12px 18px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #6b7280;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}
.view-tab:hover {
  background: #f8fafc;
  color: #1f2937;
}
.view-tab.is-active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.view-tab-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}
.view-tab-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.view-tab-sub {
  font-size: 11px;
  opacity: 0.75;
  font-weight: 400;
}
.view-tab.is-active .view-tab-sub { opacity: 0.85; }

/* Vue métier : 2 colonnes contenu + sidebar */
.metier-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}
.metier-main { min-width: 0; }
.metier-aside { display: flex; flex-direction: column; gap: 14px; }

/* Bloc prose mis en avant */
.prose-block { padding: 28px 32px; }
.prose-large {
  font-size: 15px;
  line-height: 1.8;
  color: #1f2937;
  max-width: 72ch;
}
.prose-large strong { color: #0f172a; font-weight: 600; }
.empty-msg {
  padding: 24px;
  background: #f8fafc;
  border-radius: 8px;
  text-align: center;
  margin: 0;
}

/* Sidebar info cards */
.info-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.info-title {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: none;
  padding: 0;
}
.info-list {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.info-list dt {
  color: #6b7280;
  font-weight: 500;
}
.info-list dd {
  margin: 0;
  color: #1f2937;
  font-weight: 500;
}
.info-list dd code {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: #1f2937;
}
.info-section { margin-top: 14px; }
.info-section + .info-section { padding-top: 14px; border-top: 1px solid #f1f5f9; }
.info-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.tags-soft .tag {
  font-size: 11px;
  padding: 2px 7px;
}

.status-on { color: #047857; font-weight: 600; }
.status-off { color: #6b7280; font-weight: 500; }

.pill-archived { background: #f1f5f9; color: #64748b; }
.small { font-size: 12px; }

@media (max-width: 1000px) {
  .metier-layout { grid-template-columns: 1fr; }
  .view-tab-sub { display: none; }
  .view-tab { flex-direction: row; align-items: center; gap: 8px; padding: 10px 14px; }
}

/* =============================================================
   PAGE LISTE DES RÈGLES (etablissement principal) — design pro
   ============================================================= */

/* Hero établissement */
.etb-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 28px 32px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #f1f5f9;
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}
.etb-hero-main { flex: 1; min-width: 0; }
.etb-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 4px;
}
.etb-title {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.5px;
}
.etb-subtitle {
  margin: 0;
  font-size: 14px;
  color: #cbd5e1;
}
.etb-hero-actions .btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #f1f5f9;
}
.etb-hero-actions .btn:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: #fff;
  padding: 18px 22px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  position: relative;
}
.kpi-accent {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #eff6ff 0%, #fff 60%);
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.kpi-accent .kpi-value { color: #1d4ed8; }
.kpi-label {
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kpi-bar {
  margin-top: 10px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.kpi-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  transition: width 0.3s;
}

/* Toolbar */
.toolbar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.toolbar-search {
  position: relative;
  margin-bottom: 14px;
}
.toolbar-search input[type="text"] {
  width: 100%;
  padding: 12px 40px 12px 40px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: #f9fafb;
  transition: all 0.15s;
}
.toolbar-search input[type="text"]:focus {
  outline: none;
  background: #fff;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #94a3b8;
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 11px;
  text-decoration: none;
}
.search-clear:hover { background: #d1d5db; text-decoration: none; }

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toolbar-actions {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.toolbar select {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.toolbar select:focus { outline: none; border-color: #2563eb; }

/* Chip toggles (vs old .checkbox label) */
.chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
  color: #374151;
  user-select: none;
  transition: all 0.12s;
  margin-right: 4px;
}
.chip-toggle:hover { border-color: #94a3b8; }
.chip-toggle input[type="checkbox"] { accent-color: #2563eb; }
.chip-toggle input[type="checkbox"]:checked + span { color: #1d4ed8; font-weight: 500; }
.chip-toggle:has(input:checked) {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* Barre de résultats */
.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 4px;
  font-size: 13px;
  color: #475569;
  flex-wrap: wrap;
  gap: 8px;
}
.result-count strong { color: #0f172a; font-size: 15px; }
.result-count .muted { font-weight: 400; }

/* Table pro */
.table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
table.data-pro {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  box-shadow: none;
  border-radius: 0;
}
table.data-pro th {
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  white-space: nowrap;
}
table.data-pro td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
  color: #1f2937;
  vertical-align: middle;
}
table.data-pro tbody tr:last-child td { border-bottom: none; }
table.data-pro tr.row-link { cursor: pointer; transition: background 0.1s; }
table.data-pro tr.row-link:hover { background: #f8fafc; }
table.data-pro tr.row-link:hover .cell-title-main a { color: #1d4ed8; }

.cell-title-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin-bottom: 4px;
}
.cell-title-main a { color: #0f172a; text-decoration: none; }
.cell-title-main a:hover { color: #2563eb; text-decoration: underline; }
.cell-title-meta {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  color: #94a3b8;
  font-family: 'Consolas', monospace;
}
.cell-code { color: #6b7280; }
.cell-variant { color: #6b7280; }
.cell-size { color: #94a3b8; }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-active { background: #10b981; box-shadow: 0 0 0 2px #d1fae5; }
.dot-inactive { background: #cbd5e1; }

.col-period { white-space: nowrap; font-family: 'Consolas', monospace; font-size: 12px; color: #64748b; }
.col-stats { text-align: right; width: 90px; font-variant-numeric: tabular-nums; color: #475569; }
.col-content { white-space: nowrap; width: 220px; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
  white-space: nowrap;
}
.pill-prose { background: #dcfce7; color: #166534; }
.pill-struct { background: #e0e7ff; color: #3730a3; }

/* Pagination pro */
.pagination-pro {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 24px 0 12px;
  font-size: 13px;
}
.pagination-pro a, .pagination-pro span {
  padding: 7px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  color: #2563eb;
  text-decoration: none;
  transition: all 0.1s;
}
.pagination-pro a:hover { background: #eff6ff; border-color: #93c5fd; }
.pagination-pro .current { background: #f8fafc; color: #475569; cursor: default; }
.pagination-pro .current strong { color: #0f172a; }
.pagination-pro .disabled { color: #cbd5e1; cursor: not-allowed; background: #fafbfc; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: 10px;
}
.empty-icon {
  font-size: 48px;
  color: #cbd5e1;
  margin-bottom: 16px;
  line-height: 1;
}
.empty-state h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  border: none;
  padding: 0;
}
.empty-state p { margin: 0 0 20px; }

/* Mobile responsive */
@media (max-width: 800px) {
  .etb-hero { padding: 20px 22px; }
  .etb-title { font-size: 24px; }
  .toolbar-actions { margin-left: 0; }
  table.data-pro th, table.data-pro td { padding: 10px 12px; }
  .col-period { display: none; }
  .col-stats { display: none; }
}

/* ============================================================
   VUE DOCUMENT — accueil avec cartes type couverture + lecteur
   ============================================================ */

/* Page d'accueil — cartes */
.docs-hero {
  text-align: center;
  padding: 40px 24px 32px;
}
.docs-title {
  font-size: 32px;
  margin: 0 0 12px;
  color: #0f172a;
  letter-spacing: -0.5px;
  font-weight: 700;
}
.docs-sub {
  font-size: 15px;
  color: #64748b;
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
  margin-top: 24px;
  padding: 0 8px;
}

.cover-card {
  display: block;
  background: transparent;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s;
}
.cover-card:hover { transform: translateY(-4px); text-decoration: none; }

.cover-card-book {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(15,23,42,0.12), 0 2px 6px rgba(15,23,42,0.08);
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 40%, #1d4ed8 100%);
  display: flex;
  margin-bottom: 14px;
}
.cover-card:hover .cover-card-book {
  box-shadow: 0 12px 32px rgba(15,23,42,0.2), 0 4px 12px rgba(15,23,42,0.1);
}
.cover-card-spine {
  width: 16px;
  background: linear-gradient(90deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.15) 40%, rgba(0,0,0,0) 100%);
  flex-shrink: 0;
}
.cover-card-face {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 24px 22px;
  color: #f1f5f9;
  position: relative;
}
.cover-card-band {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 10px;
  border-top: 1px solid rgba(255,255,255,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding: 6px 0;
  text-align: center;
}
.cover-card-code {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  color: #fff;
  margin: 16px 0 8px;
}
.cover-card-libelle {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.4;
  flex: 1;
  word-break: break-word;
}
.cover-card-bottom {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.15);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.cover-card-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}
.cover-card-stat strong {
  display: block;
  font-size: 18px;
  color: #fff;
  font-weight: 700;
}
.cover-card-stat span {
  font-size: 10px;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.cover-card-info {
  padding: 0 4px;
}
.cover-card-info-title {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  line-height: 1.4;
  margin-bottom: 4px;
}
.cover-card-info-meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 8px;
}
.cover-card-info-cta {
  font-size: 13px;
  color: #2563eb;
  font-weight: 500;
}

/* ===== Layout du document (lecteur avec TOC) ===== */

.doc-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px;
  align-items: flex-start;
}

.doc-main {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 48px 56px 36px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  min-width: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1f2937;
}
.doc-main h1, .doc-main h2, .doc-main h3 {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: #0f172a;
}
.doc-main h1 {
  font-size: 30px;
  letter-spacing: -0.5px;
  font-weight: 700;
  margin: 0 0 8px;
  border: none;
  padding: 0;
}
.doc-main h2 {
  font-size: 19px;
  margin-top: 32px;
  padding-bottom: 6px;
  border-bottom: 2px solid #f1f5f9;
}
.doc-main h3 {
  font-size: 15px;
  margin-top: 20px;
}
.doc-main p, .doc-main li { line-height: 1.75; }
.doc-main .lead { font-size: 17px; color: #475569; margin: 4px 0 24px; }
.doc-main .muted { font-family: -apple-system, sans-serif; }

.doc-page-head {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f1f5f9;
}
.doc-page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* TOC sidebar */
.doc-toc {
  position: sticky;
  top: 12px;
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.doc-toc-head {
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
}
.doc-toc-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: none;
  padding: 0;
}
.doc-toc-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  font-size: 12.5px;
  background: #f8fafc;
}
.doc-toc-search input:focus { outline: none; background: #fff; border-color: #2563eb; }

.doc-toc-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px 0 14px;
  font-size: 13px;
}
.toc-part {
  padding: 0;
}
.toc-part-link, .toc-leaf {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 18px;
  color: #1f2937;
  text-decoration: none;
  font-weight: 500;
}
.toc-part-link:hover, .toc-leaf:hover { background: #f8fafc; text-decoration: none; }
.toc-caret {
  font-size: 10px;
  color: #94a3b8;
  display: inline-block;
  transition: transform 0.15s;
  width: 12px;
  flex-shrink: 0;
}
.toc-open > .toc-part-link .toc-caret { transform: rotate(90deg); color: #2563eb; }
.toc-children {
  list-style: none;
  margin: 0;
  padding: 0 0 4px 18px;
  display: none;
}
.toc-open .toc-children { display: block; }
.toc-children li { margin: 0; }
.toc-children a {
  display: block;
  padding: 5px 18px 5px 12px;
  color: #475569;
  text-decoration: none;
  font-size: 12.5px;
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc-children a:hover { background: #f8fafc; color: #1d4ed8; text-decoration: none; }
.toc-current {
  color: #1d4ed8 !important;
  background: #eff6ff !important;
  border-left-color: #2563eb !important;
  font-weight: 600;
}

/* Pagination prev / next dans le document */
.doc-paginav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #f1f5f9;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.paginav-prev, .paginav-next {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #fafbfc;
  transition: all 0.12s;
}
.paginav-prev:hover, .paginav-next:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  text-decoration: none;
}
.paginav-next { text-align: right; }
.paginav-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.paginav-title { font-weight: 500; color: #1d4ed8; font-size: 14px; }

/* === Page Cover === */
.page-cover {
  text-align: center;
  padding: 40px 24px;
}
.page-cover-band {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #2563eb;
  border-top: 2px solid #2563eb;
  border-bottom: 2px solid #2563eb;
  padding: 8px 22px;
  margin-bottom: 40px;
}
.page-cover-title {
  font-size: 48px !important;
  font-weight: 800 !important;
  margin: 12px 0 8px !important;
  letter-spacing: -1.5px !important;
  border: none !important;
  padding: 0 !important;
}
.page-cover-sub {
  color: #475569;
  font-size: 16px;
  margin: 0 0 50px;
  font-style: italic;
}
.page-cover-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 600px;
  margin: 0 auto 50px;
}
.cover-stat {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 22px 16px;
}
.cover-stat-value {
  font-size: 30px;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1;
  margin-bottom: 6px;
  font-family: -apple-system, sans-serif;
}
.cover-stat-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.page-cover-meta {
  max-width: 460px;
  margin: 0 auto 36px;
  text-align: left;
  background: #fff;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  padding: 18px 24px;
}
.page-cover-meta dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
  font-family: -apple-system, sans-serif;
  font-size: 13px;
}
.page-cover-meta dt {
  color: #6b7280;
  font-weight: 500;
}
.page-cover-meta dd {
  margin: 0;
  color: #1f2937;
  font-weight: 500;
}
.page-cover-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  font-family: -apple-system, sans-serif;
}

/* === Sommaire détaillé === */
.big-toc {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: part-counter;
  font-family: -apple-system, sans-serif;
}
.big-toc-part {
  margin: 24px 0;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}
.big-toc-part:first-child { border-top: none; padding-top: 0; }
.big-toc-part-link {
  display: block;
  font-weight: 700;
  font-size: 17px;
  color: #0f172a;
  text-decoration: none;
  margin-bottom: 6px;
}
.big-toc-part-link:hover { color: #1d4ed8; }
.big-toc-intro {
  font-style: italic;
  color: #6b7280;
  font-size: 13px;
  margin: 0 0 10px;
}
.big-toc-chapters {
  list-style: none;
  padding: 0;
  margin: 0;
}
.big-toc-chapters li {
  display: flex;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dotted #e5e7eb;
  gap: 12px;
}
.big-toc-chapters a {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
}
.big-toc-chapters a:hover { text-decoration: underline; }
.big-toc-desc {
  color: #6b7280;
  font-size: 12.5px;
  flex: 1;
}

/* === Page avant-propos === */
.preface-section { margin-bottom: 28px; }
.preface-section h2 { margin-top: 0 !important; }

/* === Page « Comment se calcule la paie » === */
.page-how-payroll .doc-page-head {
  padding-bottom: 28px;
}
.page-how-payroll .lead {
  font-size: 17px;
  line-height: 1.7;
  color: #475569;
}

.payroll-steps {
  list-style: none;
  padding: 0;
  margin: 32px 0;
  counter-reset: step;
}
.step-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 24px;
  padding: 28px 32px 28px 24px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  font-family: -apple-system, sans-serif;
  position: relative;
}
.step-card::before {
  content: '';
  position: absolute;
  left: 56px;
  top: 100%;
  width: 2px;
  height: 18px;
  background: linear-gradient(180deg, #cbd5e1 0%, transparent 100%);
}
.step-card:last-child::before { display: none; }
.step-num {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
  flex-shrink: 0;
}
.step-body { min-width: 0; }
.step-title {
  margin: 0 0 12px !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  color: #0f172a !important;
  border: none !important;
  padding: 0 !important;
  font-family: -apple-system, sans-serif !important;
}
.step-body p {
  margin: 0 0 12px;
  font-size: 14.5px;
  line-height: 1.7;
  color: #1f2937;
}
.step-list {
  margin: 8px 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.75;
  color: #374151;
}
.step-list li { margin-bottom: 6px; }
.step-list a {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dotted #93c5fd;
}
.step-list a:hover { color: #1e40af; border-bottom-style: solid; }

.step-substeps {
  list-style: decimal;
  padding-left: 22px;
  margin: 10px 0 14px;
  counter-reset: substep;
}
.step-substeps li {
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.substep-title {
  display: block;
  font-weight: 600;
  color: #1f2937;
}
.substep-desc {
  display: block;
  color: #475569;
  margin-top: 2px;
  font-size: 13.5px;
}

.step-note {
  margin: 12px 0 0;
  padding: 12px 16px;
  background: #fef9c3;
  border-left: 3px solid #fbbf24;
  border-radius: 0 6px 6px 0;
  font-size: 13.5px;
  color: #713f12;
}

.step-formula {
  margin: 12px 0;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-family: 'Consolas', monospace;
  font-size: 13.5px;
  color: #1f2937;
  line-height: 1.8;
}

.step-extra {
  font-size: 13px !important;
  color: #6b7280 !important;
  font-style: italic;
  margin-top: 10px !important;
}

.step-callout {
  margin-top: 14px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.callout-link {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
}
.callout-link:hover { color: #1e3a8a; text-decoration: underline; }
.callout-sub {
  font-size: 12px;
  color: #475569;
}

.step-outputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.output-card {
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.output-title {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 4px;
}
.output-desc {
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}
.output-desc a { color: #2563eb; text-decoration: none; }
.output-desc a:hover { text-decoration: underline; }

/* Synthèse en une phrase */
.payroll-synthesis {
  margin: 40px 0 24px;
  padding: 28px 32px;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: #f1f5f9;
  border-radius: 12px;
  font-family: -apple-system, sans-serif;
}
.synthesis-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #93c5fd;
  margin-bottom: 12px;
}
.synthesis-text {
  font-size: 16px !important;
  line-height: 1.75;
  margin: 0 0 16px !important;
  color: #f1f5f9 !important;
}
.synthesis-text strong { color: #fff; font-weight: 700; }
.synthesis-text code {
  background: rgba(255,255,255,0.15);
  color: #fff;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 13px;
}
.synthesis-note {
  margin: 0 !important;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 13.5px !important;
  color: #cbd5e1 !important;
  font-style: italic;
}
.synthesis-note strong { color: #fff; font-style: normal; }

@media (max-width: 700px) {
  .step-card { grid-template-columns: 1fr; padding: 20px; }
  .step-card::before { display: none; }
  .step-num { margin: 0 auto; }
}

/* === Bloc Source technique (style « pipeline de données ») === */
.source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.source-header .block-title { margin: 0 !important; }
.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(220,38,38,0.25);
}

.source-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f8fafc 0%, #fafbfc 100%);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-family: -apple-system, sans-serif;
}
.source-cell {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  padding: 4px 10px;
}
.source-arrow {
  display: flex;
  align-items: center;
  color: #cbd5e1;
  font-size: 18px;
  font-weight: 300;
  padding: 0 4px;
  user-select: none;
}
.source-label {
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 4px;
}
.source-value {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-all;
}
.source-extra {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}
.source-extra code {
  background: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid #e5e7eb;
  font-size: 11px;
  color: #475569;
}

/* Bloc identifiants en bas */
.source-ids {
  margin-top: 14px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.source-ids .source-label { margin-bottom: 8px; }
.source-ids-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.source-id-chip {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  font-family: 'Consolas', monospace;
  font-size: 12px;
}
.source-id-key {
  padding: 3px 8px;
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
}
.source-id-eq {
  padding: 3px 6px;
  color: #94a3b8;
}
.source-id-val {
  padding: 3px 10px 3px 0;
  color: #0f172a;
  font-weight: 600;
}

.source-footer {
  margin-top: 10px;
  text-align: right;
  font-family: -apple-system, sans-serif;
}
.source-footer code {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

@media (max-width: 700px) {
  .source-grid { flex-direction: column; }
  .source-arrow { transform: rotate(90deg); align-self: center; padding: 4px 0; }
}

/* === Chapitre Référentiel des règles (dans le book) === */
.regles-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
  font-family: -apple-system, sans-serif;
}
.rkpi {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}
.rkpi.rkpi-accent {
  background: linear-gradient(180deg, #eff6ff 0%, #fff 70%);
  border-color: #93c5fd;
}
.rkpi strong {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rkpi.rkpi-accent strong { color: #1d4ed8; }
.rkpi span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Toolbar de filtres dans le book */
.book-toolbar {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 16px 0;
  font-family: -apple-system, sans-serif;
}
.book-toolbar-search { position: relative; margin-bottom: 10px; }
.book-toolbar-search input {
  width: 100%;
  padding: 10px 36px 10px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}
.book-toolbar-search input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.search-clear-link {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  text-decoration: none;
  font-size: 11px;
}
.book-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.book-toolbar-filters select {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}
.book-toolbar-filters .btn { margin-left: auto; }

/* Table des règles dans le book */
.book-regle-table tr.row-link { cursor: pointer; }
.book-regle-table tr.row-link:hover { background: #f8fafc; }
.book-regle-table .col-period {
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #64748b;
  white-space: nowrap;
}

/* Page détail règle dans le book : tabs adaptés */
.regle-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 6px;
}
.regle-validite {
  font-family: -apple-system, sans-serif;
  color: #6b7280;
  font-size: 13px;
  margin: 4px 0 0;
}
.regle-validite strong { color: #374151; font-family: 'Consolas', monospace; }
.view-tabs-book {
  margin: 24px 0 20px;
}

/* === Page partie : blocs chapitre inline === */
.part-chapter-block {
  margin: 32px 0 0;
  padding-top: 32px;
  border-top: 1px solid #f1f5f9;
}
.part-chapter-block:first-of-type {
  border-top: none;
  padding-top: 16px;
}
.part-chapter-head {
  margin-bottom: 16px;
}
.part-chapter-title {
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 22px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
  margin: 0 0 6px !important;
  padding: 0 !important;
  border: none !important;
}
.part-chapter-desc {
  margin: 4px 0 0;
  color: #475569;
  font-size: 14px;
  font-style: italic;
  font-family: Georgia, serif;
}
.part-chapter-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 6px;
  margin: 14px 0;
  font-family: -apple-system, sans-serif;
}
.part-chapter-meta strong { color: #1d4ed8; font-size: 15px; }
.part-chapter-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}
.part-chapter-link:hover { text-decoration: underline; }
.part-chapter-footer {
  margin-top: 18px;
  text-align: center;
}

/* Cartes compactes (aperçu) */
.rule-cards-compact { gap: 14px; }
.rule-card-compact { padding: 16px 20px; }
.rule-card-compact .rule-card-title { font-size: 15px !important; }
.rule-card-compact .rule-card-prose {
  margin-top: 8px;
  padding: 10px 14px;
}
.rule-card-compact .rule-card-prose .prose {
  font-size: 13.5px;
  line-height: 1.65;
}

/* === Ancienne page partie (chap-list) === */
.chap-list { list-style: none; padding: 0; margin: 0; counter-reset: chap; }
.chap-list li {
  counter-increment: chap;
  margin-bottom: 12px;
}
.chap-list-link {
  display: block;
  padding: 16px 20px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: all 0.12s;
}
.chap-list-link:hover {
  border-color: #93c5fd;
  background: #f8fafc;
  text-decoration: none;
}
.chap-list-title {
  display: block;
  font-weight: 600;
  color: #0f172a;
  font-size: 15px;
}
.chap-list-desc {
  display: block;
  color: #6b7280;
  font-size: 13px;
  margin-top: 4px;
}

/* === Page chapitre (liste de règles) === */
.chap-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 20px 0 28px;
  font-family: -apple-system, sans-serif;
}
.chap-search {
  display: flex;
  gap: 6px;
  flex: 1;
}
.chap-search input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}
.chap-count { font-size: 13px; }

.rule-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 24px 0;
}
.rule-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 22px 26px;
  transition: border-color 0.12s;
  font-family: -apple-system, sans-serif;
}
.rule-card:hover { border-color: #cbd5e1; }
.rule-card-head { margin-bottom: 14px; }
.rule-card-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.rule-num {
  font-family: 'Consolas', monospace;
  font-size: 12px;
  color: #6b7280;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 4px;
}
.rule-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.rule-status-on { background: #d1fae5; color: #047857; }
.rule-status-off { background: #f1f5f9; color: #64748b; }
.rule-card-title {
  margin: 0;
  font-size: 17px !important;
  color: #0f172a;
  font-weight: 600 !important;
  border: none !important;
  padding: 0 !important;
}
.rule-card-desc {
  color: #6b7280;
  font-size: 13px;
  margin: 6px 0 0;
}
.rule-card-prose {
  margin: 12px 0 0;
  padding: 14px 18px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #2563eb;
}
.rule-card-prose .prose {
  font-family: Georgia, serif;
  font-size: 14.5px;
  line-height: 1.75;
  color: #1f2937;
  white-space: pre-wrap;
}
.rule-card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
.rule-link {
  font-size: 13px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.rule-link:hover { text-decoration: underline; }

/* Block detail dans une carte (rubriques d'un profil, etc.) */
.card-detail-block {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.card-detail-block summary {
  cursor: pointer;
  font-weight: 500;
  color: #475569;
  font-size: 13px;
}
.card-detail-block summary:hover { color: #1d4ed8; }
.card-inner-table {
  margin-top: 10px !important;
  font-size: 12.5px;
  background: #fff;
}
.card-inner-table th, .card-inner-table td {
  padding: 6px 10px !important;
}

/* === Références dans les cartes de règle === */
.rule-card-refs {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e5e7eb;
}
.ref-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.ref-row:last-child { margin-bottom: 0; }
.ref-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  min-width: 130px;
  padding-top: 2px;
}
.ref-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}
.ref-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: 'Consolas', monospace;
  font-size: 11.5px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.1s;
}
.ref-tag:hover { text-decoration: none; transform: translateY(-1px); }
.ref-tag-var { background: #fef3c7; color: #92400e; }
.ref-tag-var:hover { background: #fde68a; border-color: #fbbf24; }
.ref-tag-fn { background: #dbeafe; color: #1e40af; }
.ref-tag-fn:hover { background: #bfdbfe; border-color: #60a5fa; }
.ref-more {
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  padding: 2px 4px;
}

/* === Status info pour constantes / attributs === */
.rule-status-info {
  background: #ede9fe;
  color: #5b21b6;
}

/* === Listing détaillé des entrées d'annexe (vars / fns) === */
.annex-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
  font-family: -apple-system, sans-serif;
}
.annex-entry {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 18px;
  scroll-margin-top: 20px;
  transition: all 0.18s;
}
.annex-entry-highlight {
  border-color: #fbbf24;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(251,191,36,0.18);
}
.annex-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.annex-entry-name {
  margin: 0 !important;
  font-family: 'Consolas', monospace !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #1f2937 !important;
  border: none !important;
  padding: 0 !important;
}
.annex-entry-count {
  font-size: 11px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.annex-entry-refs {
  font-size: 12.5px;
}
.annex-entry-refs-label {
  display: block;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.annex-entry-refs-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.annex-entry-refs-list li {
  padding: 3px 0;
}
.annex-entry-refs-list a {
  color: #2563eb;
  text-decoration: none;
}
.annex-entry-refs-list a:hover { text-decoration: underline; }

/* Anchors sur cartes (pour permettre #cst-XXX) */
.rule-card { scroll-margin-top: 20px; }

/* === Index (annexes) === */
.alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 14px 0 28px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 8px;
  font-family: -apple-system, sans-serif;
}
.alpha-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #475569;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.alpha-letter:hover { border-color: #93c5fd; color: #1d4ed8; text-decoration: none; }
.alpha-letter.is-current {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  font-family: -apple-system, sans-serif;
}
.index-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  transition: all 0.1s;
}
.index-item:hover { border-color: #93c5fd; background: #f8fafc; text-decoration: none; }
.index-item-name {
  font-family: 'Consolas', monospace;
  color: #1f2937;
  font-weight: 500;
}
.index-item-count {
  font-size: 11px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 1px 8px;
  border-radius: 10px;
}

/* Responsive */
@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: 1fr; }
  .doc-toc { position: static; max-height: none; }
  .doc-main { padding: 32px 32px 28px; }
}
@media (max-width: 700px) {
  .doc-main { padding: 24px 20px 24px; font-size: 15px; }
  .doc-main h1 { font-size: 24px; }
  .page-cover-title { font-size: 32px !important; }
  .page-cover-stats { grid-template-columns: 1fr; }
}

/* Narration structurée — arbre */
.narration-tree {
  font-size: 13px;
}
.narr-resume {
  background: #f9fafb;
  border-left: 3px solid #2563eb;
  padding: 8px 12px;
  margin: 8px 0 16px;
  border-radius: 0 4px 4px 0;
  color: #1f2937;
}
.narr-list {
  list-style: none;
  padding-left: 16px;
  margin: 4px 0;
  border-left: 1px dashed #d1d5db;
}
.narr-list li {
  margin: 6px 0;
  padding-left: 8px;
}
.narr-intitule {
  color: #1f2937;
}
li.narr-condition > .narr-intitule {
  color: #1e40af;
  font-weight: 500;
}
li.narr-affectation > .narr-intitule {
  color: #065f46;
}
li.narr-fonction > .narr-intitule {
  color: #92400e;
}
li.narr-controle > .narr-intitule {
  color: #b91c1c;
  font-weight: 500;
}
.narr-branche {
  margin: 4px 0;
}
.narr-branche em {
  color: #6b7280;
  font-style: normal;
  font-weight: 600;
  font-size: 12px;
}

/* Boutons d'actions de navigation */
.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Prose */
.prose {
  font-size: 14px;
  line-height: 1.75;
  color: #1f2937;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.prose strong { color: #111827; }

