/* ---------- Jetons de thème (clair par défaut, sombre via data-bs-theme) ---------- */
:root {
  --bf-green: #2f5d3a;
  --bf-green-dark: #1f3f27;
  --bf-gold: #c99a3b;
  --bf-bg: #f5f4ef;
  --bf-surface: #ffffff;
  --bf-surface-2: #fafaf7;
  --bf-border: #ecebe5;
  --bf-heading: #1f3f27;
  --bf-link: #2f5d3a;
  --bf-sidebar: #1f3f27;
  --bf-sidebar-active: #2f5d3a;

  /* Graphiques (palette de référence dataviz, validée clair / sombre) */
  --viz-surface: #fcfcfb;
  --viz-ink: #0b0b0b;
  --viz-ink-2: #52514e;
  --viz-muted: #898781;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
}
[data-bs-theme="dark"] {
  --bf-bg: #0f1310;
  --bf-surface: #1a1a19;
  --bf-surface-2: #222220;
  --bf-border: #2c2c2a;
  --bf-heading: #e8efe9;
  --bf-link: #7fc28f;
  --bf-sidebar: #121a14;
  --bf-sidebar-active: #2a4a32;

  --viz-surface: #1a1a19;
  --viz-ink: #ffffff;
  --viz-ink-2: #c3c2b7;
  --viz-muted: #898781;
  --viz-grid: #2c2c2a;
  --viz-axis: #383835;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --bs-body-bg: var(--bf-bg);
  --bs-body-color: #dfe3df;
}

body { background: var(--bf-bg); font-size: .95rem; }
.brand { font-weight: 700; letter-spacing: .18em; }
a { color: var(--bf-link); }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bf-sidebar); color: #fff; padding: .5rem 1rem;
  position: sticky; top: 0; z-index: 1030;
}
.layout { display: flex; min-height: 100vh; }
/* !important : Bootstrap rend le fond des .offcanvas-lg transparent sur grand écran */
.sidebar { background: var(--bf-sidebar) !important; color: #fff; width: 250px; flex-shrink: 0; }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}
.sidebar-inner { display: flex; flex-direction: column; min-height: 100%; padding: 1rem .75rem; }
.brand-block { display: block; color: #fff; text-decoration: none; padding: .5rem .75rem 1.25rem; }
.brand-block .brand { font-size: 1.4rem; display: block; }
.brand-block small { color: var(--bf-gold); font-size: .7rem; letter-spacing: .15em; }
.sidebar .nav-link { color: rgba(255,255,255,.8); border-radius: .5rem; padding: .5rem .75rem; }
.sidebar .nav-link i { width: 1.4rem; display: inline-block; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: var(--bf-sidebar-active); color: #fff; }
.nav-section { color: var(--bf-gold); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; padding: 1rem .75rem .2rem; }
.sidebar .nav-link { padding: .4rem .75rem; }
.sidebar-user { margin-top: auto; padding: 1rem .75rem 0; border-top: 1px solid rgba(255,255,255,.1); font-size: .85rem; }
.theme-toggle { --bs-btn-border-color: rgba(255,255,255,.25); }

.content { flex: 1; min-width: 0; padding: 1.5rem; }
@media (max-width: 576px) { .content { padding: 1rem; } }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; color: var(--bf-heading); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.card { border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); border-radius: .75rem; background: var(--bf-surface); }
[data-bs-theme="dark"] .card { box-shadow: 0 0 0 1px var(--bf-border); }
.card-header { background: var(--bf-surface); font-weight: 600; border-bottom: 1px solid var(--bf-border); }
.list-group-item { background: var(--bf-surface); }
.kpi { padding: 1rem 1.25rem; }
.kpi .label { color: var(--bs-secondary-color); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 1.6rem; font-weight: 700; color: var(--bf-heading); }
.kpi .sub { font-size: .8rem; color: var(--bs-secondary-color); }

.btn-primary { --bs-btn-bg: var(--bf-green); --bs-btn-border-color: var(--bf-green);
  --bs-btn-hover-bg: var(--bf-green-dark); --bs-btn-hover-border-color: var(--bf-green-dark);
  --bs-btn-active-bg: var(--bf-green-dark); --bs-btn-active-border-color: var(--bf-green-dark); }
.btn-outline-primary { --bs-btn-color: var(--bf-link); --bs-btn-border-color: var(--bf-link);
  --bs-btn-hover-bg: var(--bf-green); --bs-btn-hover-border-color: var(--bf-green); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--bf-green); --bs-btn-active-border-color: var(--bf-green); }

.table { --bs-table-bg: var(--bf-surface); margin: 0; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color);
  background: var(--bf-surface-2); white-space: nowrap; }
.table td { vertical-align: middle; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-card { overflow-x: auto; border-radius: .75rem; }

.badge-limitant { background: #fde2e1; color: #a12622; }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .25rem; }
.helptext, .form-text { font-size: .75rem; }
.formset-row td { padding: .35rem; }
.formset-row .form-control, .formset-row .form-select { min-width: 90px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(135deg, var(--bf-green-dark), var(--bf-green)); }
.login-card { width: 100%; max-width: 380px; }

/* ---------- Graphiques ---------- */
.viz { position: relative; color: var(--viz-ink); }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz .grid line { stroke: var(--viz-grid); stroke-width: 1; }
.viz .axis line { stroke: var(--viz-axis); stroke-width: 1; }
.viz text { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz text.lbl { fill: var(--viz-ink-2); font-size: 12px; }
.viz text.val { fill: var(--viz-ink); font-size: 12px; font-weight: 600; }
.viz .bar { transition: opacity .1s; }
.viz .hit { fill: transparent; cursor: default; }
.viz .hit:hover + .bar, .viz .bar.hover { opacity: .8; }
.viz-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--viz-surface); color: var(--viz-ink);
  border: 1px solid var(--bf-border); border-radius: .5rem; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  padding: .4rem .6rem; font-size: .8rem; white-space: nowrap; display: none; }
.viz-tip .t { color: var(--viz-ink-2); font-size: .75rem; }
.viz-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .8rem; color: var(--viz-ink-2); margin-bottom: .5rem; }
.viz-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.viz-empty { color: var(--bs-secondary-color); padding: 2rem 0; text-align: center; }

/* ---------- Registres imprimables (format ONSSA) ---------- */
.registre-head { display: grid; grid-template-columns: 1fr 1.4fr 1fr; border: 1.5px solid #333; margin-bottom: 1rem; text-align: center; color: #222; background: #fff; }
.registre-head > div { padding: .5rem; display: flex; flex-direction: column; justify-content: center; }
.registre-head > div + div { border-left: 1.5px solid #333; }
.registre-head .nom { font-family: Georgia, serif; font-weight: 700; font-size: 1.1rem; }
.registre-head .titre { font-family: Georgia, serif; font-weight: 700; text-transform: uppercase; font-size: .95rem; }
.registre-head .logo { font-weight: 700; letter-spacing: .2em; color: #444; }
.registre-head .logo small { display: block; font-size: .6rem; letter-spacing: .2em; font-weight: 400; }
.registre-table { width: 100%; border-collapse: collapse; background: #fff; color: #222; font-size: .8rem; }
.registre-table th, .registre-table td { border: 1px solid #555; padding: .3rem .4rem; vertical-align: middle; }
.registre-table th { text-transform: uppercase; font-size: .7rem; text-align: center; background: #f4f4f1; }
.registre-foot { margin-top: 1.5rem; text-align: center; font-size: .75rem; font-weight: 700; text-decoration: underline; }
.registre-page { background: #fff; color: #222; padding: 1.5rem; border-radius: .5rem; }

@media print {
  .sidebar, .topbar, .page-head .actions, .no-print, .alert { display: none !important; }
  .content { padding: 0; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none; }
  .registre-page { padding: 0; }
  @page { size: A4 landscape; margin: 12mm; }
}
