/* =========================================================
   CCMB  — maquette front (thème clair, palette fixe)
   ========================================================= */

:root {
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --surface-2:      #f3f2ee;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  /* Couleurs de marque CCMB, extraites de images/Signature_CCMB.jpg (logo "CCMB FINANCEMENT") */
  --brand:        #5f280a; /* marron du wordmark "CCMB" */
  --brand-accent: #e89000; /* orange du mot "FINANCEMENT" et du filet sous le logo */

  --series-1: #2a78d6; /* blue   */
  --series-2: #1baf7a; /* aqua   */
  --series-3: #eda100; /* yellow */
  --series-4: #008300; /* green  */
  --series-5: #4a3aa7; /* violet */
  --series-6: #e34948; /* red    */
  --series-7: #e87ba4; /* magenta*/
  --series-8: #eb6834; /* orange */

  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;

  /* ordinal ramp (pipeline de statuts), light mode : pas plus clair que step 250.
     Dérivée de --brand (même teinte ~22°, luminosité dégressive) pour rester cohérente
     avec l'identité CCMB au lieu d'un bleu générique. */
  --ord-1: #f0ac84;
  --ord-2: #ed9b6b;
  --ord-3: #ea8a52;
  --ord-4: #e67839;
  --ord-5: #e3671f;
  --ord-6: #cd5b19;
  --ord-7: #b45016;
  --ord-8: #9a4513;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(11,11,11,0.06), 0 1px 8px rgba(11,11,11,0.04);
}

* { box-sizing: border-box; }
/* L'attribut hidden doit rester prioritaire même sur les éléments avec display défini
   explicitement en classe (ex. .btn { display: inline-flex }), sinon "hidden" est ignoré. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  accent-color: var(--brand); /* checkboxes / radios / <progress> aux couleurs CCMB plutôt qu'au bleu par défaut du navigateur */
}

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 240px;
  flex: none;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 14px; border-bottom: 3px solid var(--brand-accent);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 13px; }
.brand-text span { font-size: 11px; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary); font-size: 13.5px; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item svg { flex: none; }

.nav-section { display: flex; flex-direction: column; gap: 3px; }
.nav-section-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 0 10px; margin-bottom: 3px;
}
.nav-filter {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: 8px; border: none; background: none; cursor: pointer;
  color: var(--text-secondary); font-size: 13px; text-align: left; font-family: inherit;
}
.nav-filter:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-filter.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }
.nav-filter-count {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  background: var(--surface-2); border-radius: 100px; padding: 1px 7px; min-width: 20px; text-align: center;
}
.nav-filter.active .nav-filter-count { background: var(--surface-1); }
.nav-filter-alert.has-alerts .nav-filter-label,
.nav-filter-alert.has-alerts .nav-filter-count { color: var(--critical); }
.nav-filter-alert.has-alerts .nav-filter-count { background: rgba(208,59,59,0.12); }

.sidebar-foot {
  margin-top: auto; display: flex; flex-direction: column; gap: 8px;
  font-size: 11px; color: var(--text-muted);
}
.sidebar-logout-btn {
  align-self: flex-start;
  background: none; border: none; padding: 0; margin: 0;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
}
.sidebar-logout-btn:hover { color: var(--critical); }

/* ---------- Buttons / inputs ---------- */
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--surface-2); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--gridline); }
.btn-ghost { background: none; color: var(--text-secondary); padding: 4px 0; font-weight: 500; }
.btn-ghost:hover { color: var(--text-primary); }
.btn-danger-ghost { background: none; border: none; color: var(--critical); cursor: pointer; font-size: 13px; }
.btn-danger { background: none; color: var(--critical); border-color: var(--critical); }
.btn-danger:hover { background: rgba(208,59,59,0.08); }
.btn-block { width: 100%; justify-content: center; }
.btn-back { margin-bottom: 6px; }

.link-btn {
  background: none; border: none; padding: 0; margin: 0;
  font-family: inherit; font-size: inherit; color: var(--brand);
  text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--text-primary); }

.input {
  font-family: inherit; font-size: 13.5px;
  padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); width: 100%;
}
.input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.input:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
textarea.input { resize: vertical; font-family: inherit; }
#search-clients { max-width: 240px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-secondary); }
label input, label select, label textarea { color: var(--text-primary); }

.check-toggle {
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--text-primary); cursor: pointer;
  margin: 4px 0 14px;
}
.check-toggle input { width: auto; }

/* ---------- Layout helpers ---------- */
.content { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.view-header h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--text-muted); margin: 0; font-size: 13px; }
.view-actions { display: flex; gap: 10px; }

/* Fiche : les actions du dossier peuvent passer à la ligne, alignées à droite. Le séparateur
   force « Lettre de relance » sur sa propre ligne, juste sous « Supprimer le dossier ». */
#view-fiche .view-actions { flex-wrap: wrap; justify-content: flex-end; }
.view-actions-break { flex-basis: 100%; height: 0; }

/* Titre du tableau de bord quand un filtre de catégorie est actif : pastille de la couleur de
   la catégorie devant le nom, pour bien montrer "où on est" (voir renderDashboardHeading). */
.dashboard-title-filtered { display: inline-flex; align-items: center; gap: 10px; }
.dashboard-title-filtered::before {
  content: ""; width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: var(--cat-color, var(--brand));
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card > legend, fieldset.card > legend {
  font-weight: 700; font-size: 13.5px; padding: 0 4px 10px 0; color: var(--text-primary);
}
fieldset.card { border: 1px solid var(--border); }
.section-title { margin: 0 0 14px; font-size: 14px; }

.grid { display: grid; gap: 14px 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .span-2, .span-3 { grid-column: span 2; }
  .field-hint { grid-column: 1 / -1; }
}

.form-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }
.form-actions .btn:only-child { margin-left: auto; }

/* ---------- Table (dashboard) ---------- */
.table-wrap { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--gridline);
}
.table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.table th.sortable:hover { color: var(--text); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--gridline); font-size: 13.5px; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
.client-row { cursor: pointer; }
.client-name { font-weight: 600; }
.client-sub { color: var(--text-muted); font-size: 12px; }

.status-group-header td {
  padding: 0; border-bottom: none; background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--group-color, var(--brand)); /* liseré de couleur de la catégorie */
}
.status-group-header:hover td { background: var(--surface-2); }
.status-group-toggle {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 19px; border: none; background: none; cursor: pointer;
  font-family: inherit; text-align: left;
}
.status-group-chevron {
  display: inline-block; font-size: 10px; color: var(--text-muted);
  transition: transform 0.15s ease;
}
.status-group-chevron.expanded { transform: rotate(90deg); }
.status-group-count { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 100px; font-size: 14px; font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.relance-tag-wrap { display: inline-flex; align-items: center; gap: 6px; }
.relance-tag { font-size: 12px; }
.relance-late { color: var(--critical); font-weight: 700; }
.relance-ok { color: var(--text-secondary); }
.relance-na { color: var(--baseline); }
.relance-commercial { color: var(--series-5); }
.relance-commercial.relance-late { color: var(--critical); }

.relance-dismiss {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%;
  background: none; color: var(--text-muted); font-size: 12px; line-height: 1; cursor: pointer;
}
.relance-dismiss:hover { color: var(--critical); background: color-mix(in srgb, var(--critical) 14%, white); }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-actions .btn { padding: 6px 12px; font-size: 12.5px; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-state p { margin-bottom: 14px; }

/* ---------- Stepper (onglets du dossier : premier contact / documents / finalisation) ---------- */
.stepper { list-style: none; display: flex; gap: 4px; padding: 0; margin: 0 0 24px; }
.step {
  display: flex; align-items: center; gap: 10px; flex: 1;
  position: relative; padding: 9px 12px 14px; cursor: pointer;
  border-bottom: 3px solid var(--gridline); color: var(--text-muted);
  border-radius: 8px 8px 0 0;
  transition: background 0.12s ease, color 0.12s ease;
}
.step:hover { background: var(--surface-2); }

/* Étapes déjà parcourues : repère orange (progression), cliquables pour y revenir. */
.step.done { color: var(--text-secondary); border-bottom-color: var(--brand-accent); }
.step.done .step-num { background: var(--brand-accent); color: #fff; }

/* Étape courante : nettement mise en avant — fond teinté, libellé marqué, pastille cerclée,
   filet marron plus soutenu, pour qu'on repère d'un coup d'œil sur quel onglet on est. */
.step.active {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, white);
  border-bottom-color: var(--brand);
}
.step.active .step-label { font-weight: 800; }
.step.active .step-num {
  background: var(--brand); color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, white);
}

.step-num {
  width: 23px; height: 23px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--text-muted);
}
.step-label { font-size: 13px; font-weight: 600; }

.step-panel { display: none; }
.step-panel.active { display: block; }

/* ---------- Sous-onglets (ex. vue Commercial : mail groupé / courrier) ---------- */
.subtabs { display: flex; gap: 2px; margin: 0 0 20px; border-bottom: 1px solid var(--border); }
.subtab {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subtab:hover { color: var(--text-primary); }
.subtab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Statut du dossier ---------- */
.status-card { margin-bottom: 20px; }
.status-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.status-card-current { display: flex; align-items: center; gap: 10px; }
.status-card-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.status-change-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gridline); }
.status-history-toggle { display: inline-flex; align-items: center; gap: 5px; margin-top: 14px; font-size: 12.5px; }
.status-history-toggle #status-history-arrow { display: inline-block; transition: transform .15s ease; font-size: 10px; }
.status-history-toggle.open #status-history-arrow { transform: rotate(90deg); }
.status-history { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.status-history-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; flex-wrap: wrap; }
.status-history-date { color: var(--text-muted); min-width: 90px; font-variant-numeric: tabular-nums; }
.status-history-comment { color: var(--text-secondary); }

/* ---------- Fiche de renseignement (généré) ---------- */
.ccmb-dossier-card { background: var(--surface-2); }
.ccmb-dossier-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ccmb-dossier-actions { display: flex; gap: 8px; flex-wrap: wrap; }

dialog.ccmb-dialog {
  border: none; border-radius: var(--radius); padding: 0;
  max-width: 720px; width: 92vw; max-height: 88vh;
  box-shadow: 0 8px 40px rgba(11,11,11,0.25);
  background: var(--surface-1); color: var(--text-primary);
}
dialog.ccmb-dialog::backdrop { background: rgba(11,11,11,0.45); }
dialog.ccmb-dialog form { padding: 26px 28px; overflow-y: auto; max-height: 88vh; }
dialog.ccmb-dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog.ccmb-dialog fieldset { border: none; padding: 0; margin: 0 0 22px; }
dialog.ccmb-dialog legend { font-weight: 700; font-size: 13.5px; padding: 0 0 10px; color: var(--text-primary); }

.ccmb-piece-category { margin-bottom: 18px; }
.ccmb-piece-category:last-child { margin-bottom: 0; }
.ccmb-piece-category h4 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-secondary); margin: 0 0 8px;
}
.ccmb-piece-category .check-options { gap: 6px; }
.ccmb-piece-category .check-option { font-size: 13px; align-items: flex-start; }
.ccmb-piece-category .check-option input { margin-top: 3px; }

/* ---------- Groupes de cases à cocher / radios ---------- */
.check-options { display: flex; flex-direction: column; gap: 10px; }
.check-option { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-primary); cursor: pointer; }
.check-option input { width: auto; }
.civilite-row { flex-direction: row; gap: 20px; margin-bottom: 12px; }
.radio-group { display: flex; gap: 20px; margin-bottom: 14px; }
.radio-option { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-primary); cursor: pointer; }
.radio-option input { width: auto; }

/* ---------- Crédits dynamiques ---------- */
.credits-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.credit-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr auto auto; gap: 10px; align-items: end;
  padding: 10px; background: var(--surface-2); border-radius: 8px;
}
@media (max-width: 1100px) { .credit-row { grid-template-columns: repeat(2, 1fr); } }
.credit-row.sim-credit-row { grid-template-columns: 1fr 1fr 1fr 1fr auto auto; }
@media (max-width: 1100px) { .credit-row.sim-credit-row { grid-template-columns: repeat(2, 1fr); } }
.credit-racheter-option { padding-bottom: 10px; white-space: nowrap; }
.demande-total { margin: 14px 0 0; font-size: 14px; }
.demande-total strong { font-size: 15px; }

.child-row {
  display: grid; grid-template-columns: 1fr 120px 140px auto; gap: 10px; align-items: end;
  padding: 10px; background: var(--surface-2); border-radius: 8px;
}
@media (max-width: 700px) { .child-row { grid-template-columns: repeat(2, 1fr); } }
.child-age { font-size: 12.5px; color: var(--text-secondary); align-self: center; }
.child-age-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* Libellé calculé (« depuis X ans ») : soit dans sa propre cellule de grille à côté d'un champ
   date, soit en sous-ligne à l'intérieur du <label> du champ (situation pro). */
.field-hint { font-size: 12.5px; color: var(--text-secondary); align-self: end; padding-bottom: 8px; }
.field-hint strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
label > .field-hint { align-self: flex-start; padding-bottom: 0; margin-top: 3px; }

/* ---------- Documents ---------- */
.doc-category { margin-bottom: 20px; }
.doc-category:last-child { margin-bottom: 0; }
.doc-category-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.doc-category-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.doc-category-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); }
.doc-category-count { font-size: 11.5px; color: var(--text-muted); margin-left: auto; font-weight: 600; }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.doc-card {
  border: 1px dashed var(--baseline); border-radius: 9px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--surface-2);
}
.doc-card.has-file { border-style: solid; border-color: var(--good); }
.doc-title { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.doc-preview {
  height: 90px; border-radius: 6px; background: var(--surface-1); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-muted); font-size: 11px;
}
.doc-preview img { width: 100%; height: 100%; object-fit: cover; }
.doc-file-input { font-size: 11.5px; }
.doc-card-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.doc-view-link { font-size: 12px; }
.doc-card-actions .btn-danger-ghost { font-size: 12px; padding: 0; }
.doc-status { font-size: 11px; font-weight: 700; }
.doc-status.received { color: var(--good); }
.doc-status.missing { color: var(--text-muted); }
.simulation-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Commercial (mail groupé) ---------- */
#commercial-filter-statuses.check-options { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; }
.commercial-recipients-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 16px 0 10px;
}
#commercial-recipients-tbody td.commercial-no-email { color: var(--text-muted); font-style: italic; }
.commercial-signature {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2);
}
.commercial-signature-img { max-width: 260px; height: auto; border-radius: 4px; }

/* ---------- Stats: KPI + charts ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 4px; }
.kpi-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted);
  font-size: 10px; font-weight: 700; cursor: help; vertical-align: middle;
}
.kpi-value-input {
  font-family: inherit; font-size: 22px; font-weight: 700;
  border: 1px dashed var(--border); border-radius: 6px; background: var(--surface-2);
  padding: 3px 6px; width: 100%; color: inherit;
}
.kpi-value-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 950px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { display: flex; flex-direction: column; }
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-bar { rx: 4; }
.chart-axis-label { fill: var(--text-muted); font-size: 10.5px; font-family: system-ui, sans-serif; }
.chart-value-label { fill: var(--text-primary); font-size: 11px; font-weight: 600; font-family: system-ui, sans-serif; }
.chart-gridline { stroke: var(--gridline); stroke-width: 1; }
.hoverable { cursor: pointer; }

.chart-tooltip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--text-primary); color: var(--page);
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  transform: translate(-50%, -110%); white-space: pre-line;
  max-width: 240px; box-shadow: var(--shadow);
}
.chart-tooltip.tooltip-right { transform: translate(14px, -50%); }

/* ---------- Déconnexion de secours (écrans sans sidebar visible) ---------- */
/* Le bouton normal vit en bas de la barre de nav (.sidebar-logout-btn) ; celui-ci ne sert que
   là où la sidebar n'existe pas : changement de mot de passe obligatoire (.app entière masquée)
   et rôle client (sidebar masquée par les règles .mode-client ci-dessous). Affiché/masqué par
   js/auth.js selon l'écran (voir showChangePasswordView / applyRoleUI). */
.logout-btn-floating {
  position: fixed; top: 14px; right: 18px; z-index: 100;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); cursor: pointer;
  box-shadow: var(--shadow);
}
.logout-btn-floating:hover { background: var(--surface-2); }

/* ---------- Mode pro / client (maquette) ---------- */
.client-mode-banner {
  background: rgba(95,40,10,0.10); color: var(--brand);
  border: 1px solid rgba(95,40,10,0.25); border-radius: var(--radius);
  padding: 10px 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 16px;
}

/* Barre de navigation du rôle client (voir renderClientNav dans js/documents.js) : collée en
   haut de page, liens vers les catégories de documents + déconnexion. */
.client-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 16px; padding: 10px 12px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.client-nav[hidden] { display: none; }
.client-nav-links { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.client-nav-link {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 100px; border: 1px solid var(--border);
  background: none; color: var(--text-secondary); cursor: pointer;
}
.client-nav-link:hover { background: var(--surface-2); color: var(--text-primary); }
.client-nav-count { color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.client-nav-logout { flex: none; }
/* Les cibles des liens ne doivent pas passer sous la barre collée en haut. */
body.mode-client #card-ccmb-retour,
body.mode-client .doc-category { scroll-margin-top: 90px; }

body.mode-client .sidebar,
body.mode-client .btn-back,
body.mode-client .stepper,
body.mode-client #panel-2 .form-actions,
body.mode-client #btn-new-dossier-same-client,
body.mode-client #btn-print-recap,
body.mode-client #fiche-siblings,
body.mode-client .status-card,
body.mode-client .ccmb-dossier-card,
body.mode-client .simulation-card,
body.mode-client #btn-lettre-relance {
  display: none;
}

.simple-table { width: 100%; border-collapse: collapse; }
.simple-table td, .simple-table th { padding: 8px 4px; font-size: 13px; border-bottom: 1px solid var(--gridline); }
.simple-table th { color: var(--text-muted); font-weight: 600; text-align: left; font-size: 11.5px; text-transform: uppercase; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { color: var(--text-primary); }
.bank-bar-track { background: var(--gridline); border-radius: 4px; height: 8px; width: 100%; overflow: hidden; }
.bank-bar-fill { background: var(--brand); height: 100%; border-radius: 4px; }

.agence-row { cursor: pointer; }
.agence-row:hover td, .agence-row.expanded td { background: var(--gridline); }
.agence-detail-row td { padding: 0; }
.agence-detail-list { list-style: none; margin: 0; padding: 8px 4px 8px 24px; display: flex; flex-direction: column; gap: 4px; max-width: 320px; }
.agence-detail-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--text-muted); }
.agence-detail-list li span:first-child { color: var(--text-primary); }

/* ---------- Authentification & niveaux d'accès ---------- */
/* [hidden] et .app{display:flex} ont la même spécificité CSS : sans cette règle, un <div hidden
   class="app"> resterait affiché en flex (le hidden natif serait écrasé par la cascade). */
.app[hidden] { display: none; }

.view-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--page); padding: 20px;
}
.view-login[hidden] { display: none; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 26px;
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.login-logo-link { display: block; width: fit-content; margin: 0 auto 4px; border-radius: 6px; }
.login-logo { display: block; width: 140px; height: auto; }
.login-card h1 { font-size: 18px; margin: 0; }
.login-card label { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); display: flex; flex-direction: column; gap: 4px; }
.login-error { color: var(--critical); font-size: 12.5px; font-weight: 600; margin: 0; }

/* Éléments réservés au principal (onglet Utilisateurs, et toute l'étape 3 « Finalisation » :
   pastille du stepper, panneau, boutons qui y mènent, frais de mandat, récapitulatif de relance)
   : masqués pour tout autre rôle. Rappel : la vraie barrière est côté serveur (voir
   server/lib/redact.js et requireRole sur les routes), ceci n'est qu'une commodité d'UI. */
body[data-role="collaborateur"] .principal-only,
body[data-role="client"] .principal-only {
  display: none !important;
}
