:root {
  color-scheme: light;
  --bg: #eef2f8;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --success: #059669;
  --warning: #d97706;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.1; }
.topbar-title strong { font-size: 14px; }
.topbar-title small { color: var(--muted); font-size: 11px; }

.hamburger {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  box-shadow: var(--shadow);
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 180ms, opacity 180ms;
}
body.sidebar-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
body.sidebar-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  padding: 24px 18px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  transform: translateX(-100%);
  transition: transform 220ms ease;
  z-index: 80;
  box-shadow: var(--shadow);
}
body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.sidebar-close:hover { background: var(--danger-soft); color: var(--danger); }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms;
}
body.sidebar-open .backdrop { opacity: 1; pointer-events: auto; }

.content {
  padding: 24px clamp(16px, 3vw, 40px) 48px;
  margin-left: 0;
  transition: margin-left 220ms ease, padding 220ms ease;
}

@media (min-width: 961px) {
  .topbar { position: fixed; width: auto; right: auto; left: 0; padding: 12px 16px; background: transparent; border: 0; backdrop-filter: none; }
  .topbar-title { display: none; }
  body.sidebar-open .topbar { left: 280px; }
  body.sidebar-open .backdrop { opacity: 0; pointer-events: none; }
  body.sidebar-open .sidebar-close { display: none; }
  .content { padding-left: 80px; }
  body.sidebar-open .content {
    margin-left: 280px;
    padding-left: clamp(20px, 2.5vw, 40px);
  }
}

@media (max-width: 960px) {
  .content { padding-top: 72px; }
}

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

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 120ms, color 120ms;
}
.nav-link:hover { background: var(--accent-soft); color: var(--accent); }
.nav-link.active { background: var(--accent); color: white; }

.sidebar-filter {
  margin-top: auto;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-filter strong { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sidebar-filter label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.sidebar-filter input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: white;
  font: inherit;
}
.sidebar-filter button {
  border: 0;
  background: var(--accent);
  color: white;
  padding: 10px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-filter .reset {
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.sidebar-filter small { color: var(--muted); font-size: 11px; }


.export-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}
.export-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 160ms, border-color 160ms, color 160ms;
}
.export-btn::before {
  content: "\2193";
  font-weight: 900;
  color: var(--accent);
}
.export-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.export-btn:active { transform: translateY(1px); }


.page-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 2px 0 6px;
  font-size: clamp(24px, 4vw, 36px);
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.hero-card {
  min-width: 200px;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-weight: 700;
}
.hero-card span {
  display: block;
  color: var(--accent);
  font-size: 44px;
  line-height: 1;
}
.hero-card small { display: block; margin-top: 6px; color: var(--muted); font-weight: 500; }

.pill-link {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}

.panel {
  margin: 18px 0;
  padding: 22px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 8px; font-size: 20px; }
.panel.info { background: #f8fafc; border-color: #e2e8f0; }
.panel.info ul { margin: 0; }

.rules { padding-left: 20px; color: var(--muted); line-height: 1.6; font-size: 14px; }
.rules strong { color: var(--text); }

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.muted { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0; }

.grid { display: grid; gap: 16px; margin: 14px 0; }
.cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.outcomes { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--line);
}
.card .label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.card strong { display: block; margin: 8px 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.card small { display: block; color: var(--muted); font-weight: 500; }
.card.alert { background: var(--danger-soft); border-color: #fecdd3; }
.card.alert strong { color: var(--danger); }

.chart-wrap { position: relative; height: 260px; margin-bottom: 18px; }
.chart-wrap.tall { height: 360px; }
.chart-wrap canvas { max-height: 100%; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
}

table { width: 100%; border-collapse: collapse; min-width: 860px; }

th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 1;
}

tbody tr:hover { background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; margin-top: 2px; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.metric-empty {
  background: repeating-linear-gradient(135deg, #f8fafc 0 6px, #eef2f8 6px 12px);
  color: #94a3b8;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.metric-empty::after {
  content: "";
  font-weight: 500;
  color: #cbd5e1;
  font-size: 11px;
}

.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; }

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-negligeable { background: #f1f5f9; color: #94a3b8; }
.badge-faible { background: #e0f2fe; color: #0369a1; }
.badge-modere { background: #fef3c7; color: #92400e; }
.badge-fort { background: var(--danger-soft); color: var(--danger); }
.badge-insuffisant { background: #f1f5f9; color: #94a3b8; }
.badge-p-significant { background: #dcfce7; color: #166534; }
.badge-p-tendance { background: #fef3c7; color: #92400e; }
.badge-p-ns { background: #f1f5f9; color: #94a3b8; }
.badge-p-na { background: #f1f5f9; color: #cbd5e1; }

.factor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.factor-card {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  transition: transform 120ms, border-color 120ms;
}
.factor-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.matrix td, .matrix th { text-align: center; }
.matrix td:first-child { text-align: left; }
.matrix td small { color: inherit; opacity: 0.6; font-weight: 500; }

.cell { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; }
.cell-negligeable { background: #f8fafc; color: #94a3b8; }
.cell-faible { background: #e0f2fe; color: #0369a1; }
.cell-modere { background: #fef3c7; color: #92400e; }
.cell-fort { background: var(--danger-soft); color: var(--danger); }
.cell-insuffisant { background: #f8fafc; color: #cbd5e1; }
.cell-p-significant { background: #dcfce7; color: #166534; }
.cell-p-tendance { background: #fef9c3; color: #854d0e; }
.cell-p-ns { background: #f8fafc; color: #94a3b8; }
.cell-p-na { background: #f8fafc; color: #cbd5e1; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 120ms, color 120ms;
}
.tab:hover { color: var(--accent); border-color: var(--accent); }
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.outcome-card { display: flex; flex-direction: column; gap: 4px; }
.outcome-card .card-title { font-weight: 900; font-size: 14px; }
.outcome-card .card-sub { color: var(--muted); font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.outcome-card strong { display: block; margin-top: 6px; font-size: 22px; color: var(--accent); letter-spacing: -0.02em; }
.outcome-card small { color: var(--muted); font-size: 12px; font-weight: 500; }

details.factor {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-top: 10px;
  overflow: hidden;
  background: white;
}
details.factor > summary {
  padding: 14px 16px;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
details.factor > summary strong { font-size: 14px; }

.markdown {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.markdown h1 {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 28px;
  letter-spacing: -0.02em;
}
.markdown h2 {
  margin: 32px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
  color: var(--accent);
}
.markdown h3 {
  margin: 22px 0 6px;
  font-size: 17px;
}
.markdown p { margin: 8px 0 14px; color: var(--text); }
.markdown ul, .markdown ol { margin: 6px 0 14px; padding-left: 22px; }
.markdown li { margin: 4px 0; }
.markdown li strong { color: var(--text); }
.markdown hr { margin: 32px 0; border: 0; border-top: 1px solid var(--line); }
.markdown code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.93em;
  color: #0f172a;
}
.markdown pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  overflow: auto;
  font-size: 13px;
}
.markdown pre code { background: transparent; padding: 0; color: inherit; }
.markdown blockquote {
  margin: 12px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
}
.markdown table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  margin: 14px 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.markdown th, .markdown td {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
  white-space: normal;
  font-size: 14px;
}
.markdown th {
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.markdown tr:last-child td { border-bottom: 0; }
.markdown strong { color: var(--text); font-weight: 800; }
.markdown a { color: var(--accent); }

.logout-link {
  display: block;
  margin-top: 8px;
  padding: 8px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.logout-link:hover { color: var(--danger); border-color: #fecdd3; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #e0e7ff, #eef2f8);
  grid-template-columns: 1fr;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 8px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.login-card p { color: var(--muted); margin: 0; line-height: 1.6; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-card input[type="password"] {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #f8fafc;
  font: inherit;
  font-size: 16px;
}
.login-card input[type="password"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: white;
}
.login-card button {
  border: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.login-card button:hover { background: #1d4ed8; }
.login-card .error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
  font-size: 13px;
}

@media (max-width: 960px) {
  .content { padding: 72px 16px 40px; }
  .page-header { flex-direction: column; gap: 14px; }
  .page-header h1 { font-size: 26px; }
  .hero-card { min-width: 0; width: 100%; }
  .cards, .outcomes { grid-template-columns: 1fr; }
  .section-title { flex-direction: column; align-items: stretch; }
  table { min-width: 640px; }
  .chart-wrap { height: 220px; }
  .chart-wrap.tall { height: 320px; }
  .matrix th, .matrix td { font-size: 12px; padding: 8px 6px; }
  .markdown h1 { font-size: 22px; }
  .markdown h2 { font-size: 18px; }
  .markdown table { min-width: 520px; }
  .pill-link { align-self: flex-start; }
  .factor-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .tabs .tab { flex: 0 0 auto; }
}

button.pill-link {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
button.pill-link:hover {
  filter: brightness(0.97);
}

.raw-panel { padding: 0; background: transparent; border: 0; box-shadow: none; }
.raw-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
.raw-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 13px;
}
.raw-table thead { position: sticky; top: 0; z-index: 5; }
.raw-table tr.raw-groups th {
  position: sticky;
  top: 0;
  padding: 10px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid white;
  color: white;
  text-align: center;
  white-space: nowrap;
}
.raw-group-id { background: #0f172a; }
.raw-group-demo { background: #2563eb; }
.raw-group-avant { background: #0ea5e9; }
.raw-group-reprise { background: #f59e0b; }
.raw-group-clinic { background: #10b981; }
.raw-group-tdm { background: #7c3aed; }

.raw-table tr.raw-columns th {
  position: sticky;
  top: 40px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}
.raw-col-id { border-top: 3px solid #0f172a; }
.raw-col-demo { border-top: 3px solid #2563eb; }
.raw-col-avant { border-top: 3px solid #0ea5e9; }
.raw-col-reprise { border-top: 3px solid #f59e0b; }
.raw-col-clinic { border-top: 3px solid #10b981; }
.raw-col-tdm { border-top: 3px solid #7c3aed; }

.raw-table td.raw-cell {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
.raw-table tbody tr:hover td { background: #f1f5f9; }
.raw-table td.raw-empty { color: #cbd5e1; text-align: center; }
.raw-table tbody td:first-child { font-weight: 800; color: var(--text); background: #f8fafc; position: sticky; left: 0; z-index: 2; }

/* Panneaux repliables */
.collapsible[data-collapsed="1"] { display: none; }
.collapsible { margin-top: 16px; }

/* Badges des types de colonne dans la table de statistiques */
.badge-empty {
  background: #f1f5f9; color: #64748b;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.stat-row td { vertical-align: top; }
.stat-row small { color: var(--muted); font-size: 11px; line-height: 1.5; display: block; }
.stat-row code {
  background: #f1f5f9; padding: 1px 6px; border-radius: 6px;
  font-size: 11px; color: var(--text);
}

/* Pastilles de couleur de section */
.group-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.group-id { background: #0f172a; }
.group-demo { background: #2563eb; }
.group-avant { background: #0ea5e9; }
.group-reprise { background: #f59e0b; }
.group-clinic { background: #10b981; }
.group-tdm { background: #7c3aed; }

/* Vue personnalise : slecteur de colonnes */
.custom-controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.custom-controls .muted { margin-left: auto; font-size: 12px; }

.custom-columns-picker {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.custom-group {
  border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 10px 12px 12px; margin: 0; background: var(--panel);
}
.custom-group legend {
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: white;
}
.custom-group-id legend { background: #0f172a; }
.custom-group-demo legend { background: #2563eb; }
.custom-group-avant legend { background: #0ea5e9; }
.custom-group-reprise legend { background: #f59e0b; }
.custom-group-clinic legend { background: #10b981; }
.custom-group-tdm legend { background: #7c3aed; }

.custom-check {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 13px; cursor: pointer; user-select: none;
}
.custom-check input { accent-color: var(--accent); margin: 0; }
.custom-check:hover span { color: var(--accent); }

.custom-hint { text-align: center; padding: 20px; font-style: italic; }

/* Page facteur : grille des 4 graphiques empiles Oui/Non/NR */
.breakdown-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.chart-card {
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.chart-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
}
.chart-card .chart-wrap.tall { height: 280px; }

/* Tableau decomposition : en-tetes groupes coloriees */
.grouped-th {
  text-align: center;
  border-bottom: 2px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-recidive { background: #fef2f4; color: #be123c; }
.badge-luxation { background: #fef3c7; color: #b45309; }
.badge-subluxation { background: #dbeafe; color: #1d4ed8; }
.badge-apprehension { background: #d1fae5; color: #047857; }

td.bd { font-size: 12px; padding: 8px 10px; }
td.bd small { display: block; color: var(--muted); font-size: 10px; }
td.bd-yes { background: #fef2f4; color: #be123c; }
td.bd-no { background: #f0fdf4; color: #047857; }
td.bd-missing { background: #f8fafc; color: #64748b; }
