/* ===== Thème Richatt (facile à remplacer par la charte officielle) ===== */
:root {
  --brand:        #046BD2;   /* bleu Richatt (charte officielle) */
  --brand-dark:   #045CB4;
  --brand-50:     #EAF3FC;
  --accent:       #046BD2;   /* CTAs en bleu Richatt */
  --accent-dark:  #045CB4;
  --ink:          #1E293B;   /* slate - titres Richatt */
  --muted:        #64748B;
  --line:         #E2E8F0;
  --bg:           #F0F5FA;   /* fond clair Richatt */
  --card:         #FFFFFF;
  --ok:           #1E9E5A;
  --ok-50:        #E7F6EE;
  --warn:         #E08A0D;
  --warn-50:      #FCF2E1;
  --danger:       #D14343;
  --danger-50:    #FBEAEA;
  --info:         #046BD2;
  --info-50:      #EAF3FC;
  --radius:       12px;
  --shadow:       0 1px 2px rgba(30,41,59,.06), 0 6px 24px rgba(30,41,59,.07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Barre de navigation ===== */
.nav {
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.nav-inner {
  max-width: 1040px; margin: 0 auto; padding: 0 20px;
  height: 62px; display: flex; align-items: center; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-weight: 600; font-size: 13px; padding-left: 12px; border-left: 1px solid var(--line); }
.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-links a.active, .nav-links a:hover { color: var(--brand); text-decoration: none; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.nav-user { font-size: 13px; color: var(--muted); }

/* ===== Layout ===== */
.container { max-width: 1040px; margin: 26px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* ===== Boutons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font-weight: 600; font-size: 14px; font-family: inherit; background: #eef1f5; color: var(--ink);
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ===== Cartes organisations (tableau de bord) ===== */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600;
}
.chip.active { background: var(--brand-50); color: var(--brand); border-color: #cfe0f2; }
.chip:hover { text-decoration: none; }

.org-list { display: flex; flex-direction: column; gap: 14px; }
.org-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; display: flex; gap: 16px; align-items: flex-start;
  transition: border-color .15s, transform .05s;
}
.org-card:hover { border-color: #c9d6e4; text-decoration: none; transform: translateY(-1px); }
.org-main { flex: 1; min-width: 0; }
.org-name { font-weight: 700; font-size: 16px; color: var(--ink); margin: 0 0 10px; }
.stat-line { display: flex; align-items: center; gap: 9px; font-size: 14px; color: #37464f; margin: 5px 0; }
.count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.count.gray { background: #c3ccd6; }
.count.red { background: var(--danger); }
.count.blue { background: var(--info); }
.count.green { background: var(--ok); }
.org-arrow { align-self: center; color: var(--muted); font-size: 22px; flex: none; }

/* ===== Badges statut ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.inscription_en_cours { background: #f0f2f5; color: #6b7785; }
.badge.en_attente { background: var(--warn-50); color: var(--warn); }
.badge.en_cours { background: var(--info-50); color: var(--info); }
.badge.complement { background: var(--warn-50); color: var(--warn); }
.badge.valide { background: var(--ok-50); color: var(--ok); }
.badge.rejete { background: var(--danger-50); color: var(--danger); }

/* ===== Panneaux / détail ===== */
.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 15px; margin: 0 0 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.doc-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.doc-row:last-child { border-bottom: 0; }
.doc-type { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .t-date { font-size: 12px; color: var(--muted); }
.timeline .t-note { font-size: 13px; color: #37464f; }

/* ===== Formulaires / wizard ===== */
.steps { display: flex; gap: 6px; margin: 0 auto 26px; max-width: 760px; }
.step { flex: 1; text-align: center; font-size: 12px; color: var(--muted); }
.step .dot { width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid var(--line); color: var(--muted); display: flex; align-items: center; justify-content: center; font-weight: 700; margin: 0 auto 6px; }
.step.active .dot { border-color: var(--brand); color: var(--brand); }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active span, .step.done span { color: var(--ink); font-weight: 600; }

.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; max-width: 760px; margin: 0 auto; }
.form-card h2 { text-align: center; font-size: 22px; margin: 0 0 6px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.form-card .hint { text-align: center; color: var(--muted); font-size: 14px; margin: 0 auto 22px; max-width: 520px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.file-drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.file-drop input { margin-top: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; }
.party-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 10px; align-items: end; }
.wizard-actions { display: flex; justify-content: space-between; margin-top: 24px; }
.review-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px; font-size: 14px; }
.review-box dl { display: grid; grid-template-columns: 200px 1fr; gap: 6px 14px; margin: 0; }
.review-box dt { color: var(--muted); }

/* ===== Login ===== */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #1f7ad6 0, var(--bg) 55%); }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 10px; }
.auth-logo img { height: 38px; width: auto; }
.auth-card h1 { font-size: 20px; text-align: center; margin: 4px 0 2px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.alert { background: var(--danger-50); color: var(--danger); border: 1px solid #f1caca; padding: 10px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .row2, .party-row { grid-template-columns: 1fr; }
  .steps .step span { display: none; }
}

/* ===== Raffinements visuels (v2) ===== */
.btn { transition: transform .06s ease, box-shadow .18s ease, background .18s ease, filter .18s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { box-shadow: 0 2px 8px rgba(4,107,210,.22); }
.btn-primary:hover { box-shadow: 0 5px 16px rgba(4,107,210,.30); }
.btn-accent { box-shadow: 0 2px 8px rgba(4,107,210,.22); }
.btn-accent:hover { box-shadow: 0 5px 16px rgba(4,107,210,.30); }

/* En-tête de panneau avec petit accent */
.panel h2 { display: flex; align-items: center; gap: 9px; }
.panel h2::before { content: ""; width: 4px; height: 15px; border-radius: 3px; background: var(--brand); display: inline-block; }
.pill-count { background: var(--brand-50); color: var(--brand); border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 9px; }

/* Carte organisation : liseré de statut + survol plus doux */
.org-card { position: relative; overflow: hidden; padding-left: 24px; }
.org-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #c3ccd6; }
.org-card.st-valide::before { background: var(--ok); }
.org-card.st-en_attente::before, .org-card.st-complement::before { background: var(--warn); }
.org-card.st-en_cours::before { background: var(--info); }
.org-card.st-rejete::before { background: var(--danger); }
.org-card:hover { box-shadow: 0 8px 24px rgba(30,41,59,.10); border-color: #bcd3ee; }

/* Galerie de pièces jointes */
.empty-sm { color: var(--muted); font-size: 14px; padding: 6px 0; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.doc-tile { margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; transition: box-shadow .15s, border-color .15s; }
.doc-tile:hover { box-shadow: 0 6px 18px rgba(30,41,59,.11); border-color: #cfe0f2; }
.doc-thumb { display: block; height: 118px; background: var(--bg); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.doc-thumb:hover img { transform: scale(1.05); }
.doc-thumb--file { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef4fb, #e1ebf7); }
.doc-ext { font-weight: 800; font-size: 14px; letter-spacing: .06em; color: var(--brand); background: #fff; border: 1px solid #d6e4f4; padding: 8px 12px; border-radius: 8px; box-shadow: 0 1px 3px rgba(4,107,210,.12); }
.doc-tile figcaption { padding: 10px 11px; }
.doc-tile .doc-type { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); font-weight: 700; margin-bottom: 2px; }
.doc-tile .doc-name { display: block; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-actions { display: flex; gap: 7px; align-items: center; margin-top: 7px; font-size: 12px; }
.doc-actions .sep { color: #c3ccd6; }

/* Visionneuse (lightbox) */
.lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: rgba(15,23,42,.82); padding: 32px; }
.lightbox.show { display: flex; }
.lightbox-fig { margin: 0; max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox-fig img { max-width: 92vw; max-height: 82vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #fff; }
.lightbox-fig figcaption { color: #e8eef6; font-size: 13px; }
.lightbox-close { position: absolute; top: 18px; right: 22px; width: 42px; height: 42px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.14); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,.26); }

/* ===== Plateforme : soldes, dépôts, transactions, cotation (v3) ===== */
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions form { margin: 0; }
.link-sm { font-size: 13px; font-weight: 600; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }

/* Badges génériques (statuts transactions / dépôts) */
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.info { background: var(--info-50); color: var(--info); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.muted { background: #eef1f5; color: #6b7785; }

/* Soldes / wallets */
.wallets { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 20px; }
.wallet { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.cur-badge { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; color: #fff; flex: none; }
.cur-XOF { background: linear-gradient(135deg, #16a34a, #0f7a37); }
.cur-EUR { background: linear-gradient(135deg, #2b6cb0, #1e4e8c); }
.cur-USD { background: linear-gradient(135deg, #2f855a, #276749); }
.cur-XAF { background: linear-gradient(135deg, #b45309, #92400e); }
.cur-CNY { background: linear-gradient(135deg, #c53030, #9b2c2c); }
.wallet-label { font-size: 12px; color: var(--muted); }
.wallet-bal { font-size: 22px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.wallet-bal small { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Listes transactions / dépôts */
.tx-list { display: flex; flex-direction: column; }
.tx-row { display: grid; grid-template-columns: 70px 1fr auto auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tx-row:last-child { border-bottom: 0; }
.tx-date { font-size: 12px; color: var(--muted); }
.tx-benef { min-width: 0; display: flex; flex-direction: column; }
.tx-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-ref { font-size: 11px; color: var(--muted); }
.tx-amt { text-align: right; display: flex; flex-direction: column; }
.tx-src { font-weight: 700; color: var(--ink); white-space: nowrap; }
.tx-dst { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Cotation */
.quote .field { margin-bottom: 12px; }
.quote-result { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: var(--muted); }
.quote-result.ok { border-style: solid; border-color: #cfe0f2; color: var(--ink); background: var(--brand-50); }
.quote-result strong { font-size: 17px; color: var(--brand); display: block; }
.quote-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }

@media (max-width: 560px) {
  .tx-row { grid-template-columns: 1fr auto; }
  .tx-date { display: none; }
  .tx-amt { grid-column: 1 / -1; text-align: left; flex-direction: row; gap: 10px; align-items: baseline; }
  .tx-actions { grid-column: 1 / -1; }
}

/* ===== Opérations : statuts, modales, cartes (v4) ===== */
.tx-row--manage { grid-template-columns: 70px 1fr auto auto auto; }
.tx-actions { display: flex; gap: 6px; }
.tx-actions form { margin: 0; }
.tx-act { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); font-family: inherit; transition: border-color .12s, background .12s; }
.tx-act:hover { border-color: #c9d6e4; background: #f7f9fc; }
.tx-act.ok { color: var(--ok); }
.tx-act.danger { color: var(--danger); }

/* Modales (<dialog>) */
.modal { border: none; border-radius: 14px; padding: 0; max-width: 480px; width: 92vw; box-shadow: 0 24px 70px rgba(15,23,42,.32); color: var(--ink); }
.modal::backdrop { background: rgba(15,23,42,.5); }
.modal-card { padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x { border: none; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-x:hover { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Cartes virtuelles */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.card-wrap { display: flex; flex-direction: column; gap: 10px; }
.vcard { aspect-ratio: 1.6 / 1; border-radius: 16px; padding: 20px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 10px 28px rgba(15,23,42,.18); position: relative; overflow: hidden; }
.vcard::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.08); }
.vcard--green { background: linear-gradient(135deg, #1e7a46, #0f4f2c); }
.vcard--orange { background: linear-gradient(135deg, #d98324, #a85d12); }
.vcard--red { background: linear-gradient(135deg, #b23b3b, #7d2222); }
.vcard--blue { background: linear-gradient(135deg, #1f6fb2, #123f6b); }
.vcard.is-frozen { filter: grayscale(.65) brightness(.95); }
.vcard-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.vcard-brand { font-weight: 700; font-size: 15px; }
.vcard-net { font-style: italic; font-weight: 800; letter-spacing: .04em; font-size: 18px; }
.vcard-label { font-size: 13px; opacity: .9; position: relative; z-index: 1; }
.vcard-num { font-size: 19px; letter-spacing: .14em; font-weight: 600; position: relative; z-index: 1; }
.vcard-bottom { display: flex; justify-content: space-between; align-items: center; font-size: 12px; opacity: .92; position: relative; z-index: 1; }
.vcard-state { background: rgba(255,255,255,.18); padding: 2px 9px; border-radius: 999px; font-weight: 700; }
.vcard-actions { display: flex; gap: 8px; }
.vcard-actions form { margin: 0; }

/* ===== Analyse IA (AMI) + taux par société (v5) ===== */
.rate-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.rate-line span { white-space: nowrap; }
.rate-line input { flex: 1; min-width: 0; }

.ami-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.ami-score { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: baseline; justify-content: center; font-size: 21px; font-weight: 800; color: #fff; flex: none; }
.ami-score small { font-size: 11px; font-weight: 600; opacity: .85; }
.ami-favorable { background: linear-gradient(135deg, #1e9e5a, #137a43); }
.ami-vigilance { background: linear-gradient(135deg, #e08a0d, #b46f08); }
.ami-defavorable { background: linear-gradient(135deg, #d14343, #a82f2f); }
.ami-at { font-size: 11px; color: var(--muted); margin-top: 5px; }
.ami-summary { font-size: 13px; color: #37464f; margin: 4px 0 12px; }
.ami-checks { list-style: none; margin: 0; padding: 0; }
.ami-checks li { padding: 8px 0 8px 16px; border-bottom: 1px solid var(--line); position: relative; }
.ami-checks li:last-child { border-bottom: 0; }
.ami-checks li::before { content: ""; position: absolute; left: 0; top: 13px; width: 8px; height: 8px; border-radius: 50%; }
.ami-checks li.ami-ok::before { background: var(--ok); }
.ami-checks li.ami-warn::before { background: var(--warn); }
.ami-checks li.ami-fail::before { background: var(--danger); }
.ami-label { display: block; font-weight: 600; font-size: 13px; color: var(--ink); }
.ami-detail { display: block; font-size: 12px; color: var(--muted); }
