/* ============================================================
   EkaPay — app des entités. Feuille de style unique.
   Identité : bleu nuit, orange, vert, bleu canard.
   ============================================================ */

:root {
  --navy: #151c2b;          /* identité : fond des écrans de marque, carte principale */
  --navy-2: #222b3d;
  --brand-orange: #f39c1f;  /* boutons principaux */
  --teal: #1a9fbf;          /* liens, focus, onglet actif */
  --bg: #f2f4f7;            /* fond général */
  --card: #ffffff;          /* cartes */
  --ink: #151c2b;           /* texte principal */
  --muted: #667085;         /* texte secondaire */
  --green: #1a8f5c;         /* « à jour », barres de progression */
  --green-dark: #151c2b;    /* grande carte du tableau de bord */
  --green-pale: #e3f5ec;    /* badge « À jour » */
  --orange: #b5560f;        /* arriérés, alertes (texte lisible sur fond clair) */
  --orange-bg: #fdeed8;     /* fond alerte / badge arriéré */
  --line: #e4e7ec;          /* séparateurs */
  --radius: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }

/* ---------- Écran ---------- */
.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 22px 16px 110px;
}

.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.screen-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.link-logout {
  border: 0;
  background: none;
  color: var(--green);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 0;
}
.link-logout:hover { text-decoration: underline; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 22px 0 10px;
}

/* ---------- Cartes ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16, 40, 30, 0.05);
}
.card.clickable { cursor: pointer; transition: transform 0.06s ease; }
.card.clickable:active { transform: scale(0.995); }

.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 20px; font-weight: 800; margin-top: 4px; }
.value.orange { color: var(--orange); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 26px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand-orange);
  color: var(--navy);
}
.btn:hover { background: #e08b10; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.outline {
  background: transparent;
  color: var(--navy);
  border: 1.6px solid var(--navy);
}
.btn.outline:hover { background: #e9edf3; }
.btn.small { padding: 8px 16px; font-size: 13.5px; border-radius: 20px; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn.danger { color: #b3391b; border-color: #b3391b; background: transparent; }
.btn.danger:hover { background: #fbe9da; }

/* ---------- Page d'ouverture / connexion ---------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.splash-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(16, 40, 30, 0.08);
}
.splash-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 26px 0 8px;
}
.splash-subtitle {
  color: var(--green);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  margin-bottom: 34px;
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(16, 40, 30, 0.08);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  text-align: left;
}
.auth-title { font-weight: 800; font-size: 17px; margin: 0 0 14px; }
.auth-logo { width: 88px; height: 88px; object-fit: contain; margin-bottom: 14px; background:#fff; border-radius:8px; padding:6px; }
.auth-name { font-size: 22px; font-weight: 800; margin: 4px 0 18px; }

/* ---------- Champs de formulaire ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.field-error { color: #b3391b; font-size: 13px; margin-top: 6px; }

/* ---------- Tableau de bord ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.kpi {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(16, 40, 30, 0.05);
}
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 21px; font-weight: 800; margin-top: 5px; }
.kpi .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.hero-card {
  background: var(--green-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin-bottom: 14px;
}
.hero-card .label { color: #c8d0de; font-size: 13.5px; }
.hero-card .value { font-size: 38px; font-weight: 800; margin: 6px 0 14px; }
.hero-card .value.small { font-size: 28px; }
.hero-sub { color: #c8d0de; font-size: 12.5px; margin-top: 4px; }

.bar-track {
  height: 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}
.bar-track.dark-track { background: #e4e7e5; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--brand-orange); }
.bar-fill.green { background: var(--green); }

.alert-card {
  background: var(--orange-bg);
  color: var(--orange);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 12px;
}
.alert-card.ok { background: var(--green-pale); color: var(--green); }

.cat-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.cat-row .name { font-size: 15px; }
.cat-row .amount { font-weight: 800; font-size: 15px; }

/* ---------- Listes (membres, comptes, relances) ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(16, 40, 30, 0.05);
}
.list-item.clickable { cursor: pointer; }
.list-item .avatar { flex-shrink: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name {
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.list-item .name:not(.uppercase) { text-transform: none; letter-spacing: 0; }
.list-item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--green-pale);
}
.avatar.initial {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-weight: 800;
  font-size: 17px;
}

.badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.green { background: var(--green-pale); color: var(--green); }
.badge.strong-orange { background: var(--orange); color: #fff; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Barre de navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  z-index: 40;
}
.bottom-nav .inner {
  max-width: 660px;
  margin: 0 auto;
  display: flex;
}
.nav-item {
  flex: 1;
  border: 0;
  background: none;
  padding: 14px 4px 16px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  position: relative;
}
.nav-item.active { color: var(--teal); font-weight: 800; }
.nav-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  background: #c96a2b;
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 28, 43, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.15s ease;
}
.modal {
  background: #fff;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 30px rgba(21, 28, 43, 0.25);
  animation: sheet-in 0.2s ease;
}
.modal.wide { max-width: 680px; }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.25; }
.modal-subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-close {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: var(--bg); color: var(--ink); font-size: 15px; cursor: pointer;
}
.modal-close:hover { background: #e4e7ec; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-body > div > p:first-child { margin-top: 0; }
.modal .modal-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fafbfc;
  border-radius: 0 0 22px 22px;
}
.modal .modal-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; max-height: 86vh; box-shadow: 0 20px 50px rgba(21, 28, 43, 0.3); }
}
body.modal-open { overflow: hidden; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* Sections dans une fenêtre (console) */
.m-section { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.m-section-title { font-size: 12px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.m-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.m-fact { background: var(--bg); border-radius: 12px; padding: 10px; }
.m-fact .label { color: var(--muted); font-size: 11.5px; }
.m-fact .value { font-weight: 800; font-size: 15px; margin-top: 2px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 84px; left: 0; right: 0; display: flex; justify-content: center; z-index: 200; pointer-events: none; }
.toast {
  background: #14261d;
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Divers ---------- */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--muted); }
.center-muted { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14.5px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.detail-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.detail-table .num { text-align: right; font-weight: 700; white-space: nowrap; }
.detail-table td.num { font-weight: 700; }
.detail-table td.num.orange { color: var(--orange); }
.photo-picker { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.photo-picker img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--green-pale); }
.photo-picker .btn { padding: 8px 14px; font-size: 13px; }
.link-remove { background: none; border: 0; color: #b3391b; font-size: 13px; cursor: pointer; padding: 8px; }
.note-variables { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.template-card textarea { width: 100%; min-height: 110px; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px; resize: vertical; }
.demo-note { background: #eef3f0; border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px; color: var(--muted); margin-top: 18px; }

/* ---------- Mode de stockage (badge) ---------- */
.mode-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: #eef3f0;
  color: var(--muted);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.mode-badge.server { background: var(--green-pale); color: var(--green); border-color: transparent; }
.screen-head .mode-badge { margin-bottom: 0; }

/* ---------- Connexion : onglets des deux voies ---------- */
.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.auth-tab.active { background: var(--green); color: #fff; }

/* ---------- Chargement ---------- */
.loading-text { color: var(--muted); font-size: 15px; font-weight: 600; }

/* ---------- EkaPay : écrans de marque et barre d'application ---------- */
.brand-screen { background: var(--navy); color: #fff; }
.brand-screen .muted { color: var(--muted); }
.brand-screen .auth-card { color: var(--ink); }
.brand-screen .loading-text { color: #c8d0de; }
.brand-screen .link-logout { color: var(--teal); }
.brand-logo { width: 260px; max-width: 80vw; height: auto; margin-bottom: 26px; }
.small-note { font-size: 12.5px; margin: 14px 0 0; }

.app-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 14px 8px 8px;
  margin-bottom: 18px;
}
.app-bar-logo { height: 40px; width: auto; border-radius: 10px; }
.app-bar-entity { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar .link-logout { color: #fff; opacity: 0.85; font-size: 13.5px; }
.link-logout { color: var(--teal); }

/* Dépôts déclarés à valider */
.pending-item { align-items: center; }
.pending-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pending-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Lien à partager */
.link-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  word-break: break-all;
  user-select: all;
}

/* Case de certification (dépôt déclaré) */
.attest { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 600; margin: 4px 0 8px; cursor: pointer; }
.attest input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--brand-orange); }

/* Console super-admin */
.seg { display: flex; gap: 6px; background: #e4e7ec; border-radius: 22px; padding: 4px; margin-bottom: 16px; }
.seg-btn { flex: 1; border: 0; background: none; border-radius: 18px; padding: 9px 6px; font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg-btn.active { background: var(--navy); color: #fff; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.inline-form > input, .inline-form > .field { flex: 1; margin-bottom: 0; }
.inline-form > input { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.module-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding: 8px 0; }
.module-row .attest { margin: 0; flex: 1; min-width: 180px; }
.module-until { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.module-until input { border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.field textarea { resize: vertical; }

/* Console : administrateurs et graphique */
.admin-row { border-bottom: 1px solid var(--line); padding: 8px 0; }
.admin-row:last-of-type { border-bottom: 0; }
.admin-main { display: flex; gap: 10px; align-items: center; }
.admin-main .name { font-weight: 700; word-break: break-all; }
.admin-main .sub { color: var(--muted); font-size: 12.5px; }
.admin-row select { margin-top: 8px; width: 100%; border: 1.5px dashed var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; font-size: 13.5px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 14px 12px 10px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.bar-v { width: 100%; max-width: 26px; background: var(--teal); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: 10px; color: var(--muted); margin-bottom: 3px; white-space: nowrap; }
.bar-lab { font-size: 10px; color: var(--muted); margin-top: 5px; white-space: nowrap; }
@media (max-width: 420px) { .m-facts { grid-template-columns: 1fr 1fr; } }

/* Mot de passe temporaire affiché une fois */
.temp-password {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px; font-weight: 800; letter-spacing: 1px; text-align: center;
  background: var(--bg); border: 1px dashed var(--orange, #f39c1f); border-radius: 12px;
  padding: 14px; margin-top: 10px; user-select: all;
}
.modal .modal-actions .btn { min-width: 120px; }

/* Page d'ouverture de l'entité */
.opening-screen { background: #fff; color: var(--navy, #151c2b); cursor: pointer; text-align: center; padding: 24px; }
.opening-logo { width: 132px; height: 132px; object-fit: contain; border-radius: 24px; background: #fff;
  box-shadow: 0 10px 30px rgba(21, 28, 43, 0.12); padding: 10px; animation: opening-in .6s ease both; }
.opening-name { font-weight: 800; font-size: 22px; margin-top: 18px; text-transform: uppercase; animation: opening-in .6s .1s ease both; }
.opening-sub { color: var(--green, #1fa86b); font-weight: 700; font-size: 12px; letter-spacing: 2.5px; text-transform: uppercase; margin-top: 6px; animation: opening-in .6s .2s ease both; }
.opening-powered { margin-top: 18px; font-size: 12px; color: var(--muted); }
@keyframes opening-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Paiement mobile */
.op-grid { display: grid; gap: 10px; }
.op-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; color: inherit; }
.op-btn:hover { border-color: var(--op); }
.op-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--op); flex: none; display: inline-block; margin-right: 10px; }
.op-btn .op-dot { margin-right: 0; }
.qr-img { width: 100%; max-width: 260px; aspect-ratio: 1; object-fit: contain; border-radius: 14px; background: #fff;
  border: 1px solid var(--line); padding: 8px; margin: 4px auto 10px; display: block; }
.qr-number { font-size: 22px; font-weight: 800; letter-spacing: 1px; margin: 6px 0 10px; user-select: all; }
.qr-preview { text-align: center; }
.logo-picker img { border-radius: 14px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
