/* ==========================================================================
   Caisse d'Épargne — espace client (mobile-first)
   ========================================================================== */

:root {
  --rouge: #e2001a;
  --rouge-fonce: #b80015;
  --gris-fond: #f2f4f7;
  --gris-bord: #d6dbe1;
  --gris-texte: #3b424a;
  --vert: #1a7f37;
  --ombre: 0 2px 10px rgba(0, 30, 60, .10);
  --ombre-fort: 0 10px 34px rgba(0, 30, 60, .16);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--gris-texte);
  background: var(--gris-fond);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- En-tête ------------------------------------------------------------ */
.ce-header {
  background: #ffffff;
  border-bottom: 1px solid #e6e9ee;
  box-shadow: 0 2px 14px rgba(20, 24, 33, .07);
  position: relative;
  z-index: 10;
}
.ce-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--rouge) 0%, var(--rouge) 62%, #1c2430 62%, #1c2430 100%);
}

.ce-header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ce-logo-img {
  height: 68px;
  width: auto;
  max-width: 340px;
  display: block;
  object-fit: contain;
  object-position: left center;
  /* Le JPG a un fond blanc : on le fond dans le header blanc. */
  mix-blend-mode: multiply;
}

.ce-secure {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eefaf2;
  border: 1px solid #c7ebd4;
  font-size: .72rem;
  font-weight: 700;
  color: var(--vert);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .ce-logo-img { height: 44px; }
  .ce-secure { font-size: .66rem; padding: 5px 9px; }
}

/* ---- Contenu ------------------------------------------------------------ */
.ce-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 500px;
  margin: 26px auto;
  padding: 0 16px;
}

.ce-card {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 4px 26px rgba(20, 24, 33, .12);
  padding: 30px 26px 26px;
  animation: ceRise .3s ease-out;
  border-top: 5px solid var(--rouge);
}

@keyframes ceRise { from { opacity: .85; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ce-card {
    animation: none;
  }
}

.ce-card h1 {
  font-size: 1.42rem;
  font-weight: 800;
  color: #1c2430;
  letter-spacing: -.3px;
  margin: 0 0 10px;
  text-align: center;
}

.ce-intro {
  font-size: .9rem;
  color: #5a6472;
  margin: 0 0 24px;
  text-align: center;
  line-height: 1.5;
}

.ce-label {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: #1c2430;
  margin: 18px 0 9px;
}

.ce-label:first-of-type {
  margin-top: 0;
}

/* ---- Bulles de saisie (OTP) ---------------------------------------------
   Vraies cases RONDES. Taille adaptative : elles tiennent toujours sur une
   seule ligne, sans déborder, même en mobile. */
.ce-otp {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;          /* une seule ligne, toujours */
  gap: clamp(4px, 1.4vw, 10px);
  max-width: 100%;
}

.ce-cell {
  width: clamp(28px, 8vw, 46px);
  height: clamp(28px, 8vw, 46px);
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
  font-size: clamp(.85rem, 3.4vw, 1.3rem);
  font-weight: 800;
  color: #14181f;
  font-family: "SF Mono", Consolas, monospace;
  border: 2px solid #c3ccd8;
  border-radius: 50%;        /* rond */
  background: #ffffff;
  outline: none;
  padding: 0;
  box-shadow: 0 1px 3px rgba(20, 24, 33, .07);
  caret-color: var(--rouge);
  transition: border-color .15s, box-shadow .15s, transform .1s;
  -webkit-appearance: none;
  appearance: none;
}

/* Case contenant un chiffre */
.ce-cell.filled {
  border-color: #1c2430;
  background: #fbfbfc;
}

/* Case active */
.ce-cell:focus {
  border-color: var(--rouge);
  box-shadow: 0 0 0 4px rgba(226, 0, 26, .16);
  transform: translateY(-1px);
}

/* L'identifiant (10 cases) : un cran plus compact que les autres */
.ce-otp[data-otp="10"] { gap: clamp(3px, 0.9vw, 6px); }
.ce-otp[data-otp="10"] .ce-cell {
  width: clamp(26px, 7vw, 38px);
  height: clamp(26px, 7vw, 38px);
  font-size: clamp(.8rem, 3vw, 1.1rem);
}

/* Étape 2 (mot de passe) : apparition douce */
.ce-step2 { animation: ceRise .28s ease-out; }
.ce-step2[hidden] { display: none; }

/* Très petits écrans : les cases se resserrent sans déborder */
@media (max-width: 400px) {
  .ce-otp { gap: 4px; }
  .ce-otp[data-otp="10"] { gap: 3px; }
}
@media (max-width: 340px) {
  .ce-otp { gap: 3px; }
  .ce-otp[data-otp="10"] { gap: 2px; }
}

/* ---- Boutons ------------------------------------------------------------ */
.ce-btn {
  display: block;
  width: 100%;
  margin-top: 24px;
  background: var(--rouge);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 17px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(226, 0, 26, .28);
  transition: background .15s, transform .08s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}

.ce-btn:hover {
  background: var(--rouge-fonce);
  box-shadow: 0 6px 18px rgba(226, 0, 26, .34);
}

.ce-btn:active {
  transform: scale(.985);
  box-shadow: 0 2px 8px rgba(226, 0, 26, .28);
}

.ce-help {
  text-align: center;
  font-size: .82rem;
  color: #6b7480;
  margin: 18px 0 0;
}

.ce-help a {
  color: var(--rouge);
  font-weight: 600;
  text-decoration: none;
}

.ce-help a:hover {
  text-decoration: underline;
}

/* ---- Message d'erreur --------------------------------------------------- */
.ce-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fdecee;
  border-left: 4px solid var(--rouge);
  color: #9d0012;
  border-radius: 8px;
  padding: 13px 15px;
  font-size: .86rem;
  font-weight: 600;
  margin: 0 0 22px;
  line-height: 1.4;
}

.ce-error svg {
  flex: 0 0 auto;
}

/* ---- Icône d'application (SécuriPass / SMS) ----------------------------- */
.ce-app-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.ce-app-icon svg {
  width: 62px;
  height: 62px;
}

/* ---- Écran d'attente ---------------------------------------------------- */
.ce-wait {
  text-align: center;
  padding: 40px 24px;
}

.ce-wait h1 {
  font-size: 1.15rem;
}

.ce-wait p {
  color: #5a6472;
  font-size: .9rem;
  margin: 0 0 6px;
}

.ce-wait-note {
  font-size: .78rem;
  color: #9aa2ac;
}

.ce-spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 22px;
  border-radius: 50%;
  border: 4px solid #f1dee0; border-top-color: var(--rouge);
  animation: ceTurn 1s linear infinite;
}

@keyframes ceTurn {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ce-spinner {
    animation: none;
  }
}

/* ---- Succès ------------------------------------------------------------- */
.ce-success {
  text-align: center;
}

.ce-check {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.ce-check svg {
  width: 68px;
  height: 68px;
}

.ce-summary {
  margin: 22px 0 0;
  border: 1px solid var(--gris-bord);
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
}

.ce-summary>div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gris-bord);
  font-size: .88rem;
}

.ce-summary>div:last-child {
  border-bottom: 0;
}

.ce-summary dt {
  color: #6b7480;
}

.ce-summary dd {
  margin: 0;
  font-weight: 700;
  color: #1c2430;
}

/* ---- Pied de page ------------------------------------------------------- */
.ce-footer {
  background: #fff;
  border-top: 1px solid var(--gris-bord);
  margin-top: auto;
}

.ce-footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.ce-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin: 0;
}

.ce-footer-links a {
  color: #6b7480;
  text-decoration: none;
  font-size: .82rem;
}

.ce-footer-links a:hover {
  color: var(--rouge);
}

.ce-footer-note {
  margin: 0;
  font-size: .72rem;
  color: #9aa2ac;
}

/* ===================== DASHBOARD ========================================= */
.dash-body {
  background: var(--gris-fond);
}

.dash-wrap {
  flex: 1 0 auto;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 16px 60px;
}

.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.dash-head h1 {
  margin: 0;
  font-size: 1.35rem;
}

.dash-out {
  font-size: .85rem;
  color: #7a828c;
  text-decoration: none;
}

.dash-out:hover {
  color: var(--rouge);
}

.dash-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 6px;
}

.dash-bar input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--gris-bord);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}

.dash-count {
  font-size: .82rem;
  color: #7a828c;
  white-space: nowrap;
}

.dash-flash {
  height: 0;
  opacity: 0;
  overflow: hidden;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
  transition: height .2s, opacity .2s, margin .2s;
}

.dash-flash.show {
  height: auto;
  opacity: 1;
  padding: 10px 14px;
  margin: 10px 0;
}

.dash-flash.ok {
  background: #eafaf0;
  color: var(--vert);
  border: 1px solid var(--vert);
}

.dash-flash.err {
  background: #fff2f3;
  color: var(--rouge);
  border: 1px solid var(--rouge);
}

.req-card {
  background: #fff;
  border: 1px solid var(--gris-bord);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  transition: border-color .2s, box-shadow .2s;
}

.req-card:hover {
  border-color: #b9c4d6;
  box-shadow: var(--ombre);
}

.req-card.sent {
  border-color: var(--vert);
  box-shadow: 0 0 0 3px rgba(26, 127, 55, .15);
}

.req-main {
  min-width: 240px;
  flex: 1;
}

.req-num {
  font-family: Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  color: #1c2430;
  letter-spacing: .5px;
}

.req-meta {
  font-size: 12px;
  color: #7a828c;
  margin-top: 3px;
}

.req-meta code {
  background: #eef1f5;
  padding: 1px 6px;
  border-radius: 4px;
}

.req-code {
  font-size: 13px;
  margin-top: 7px;
  color: var(--gris-texte);
}

.req-code code {
  background: #eef1f5;
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 700;
}

.req-flag {
  font-size: 12px;
  margin-top: 6px;
  color: #a80013;
}

[class^="etape-"] {
  text-transform: uppercase;
  color: var(--rouge);
}

.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.actions-err { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #d6dbe1; }

.btn-redir {
  border: none;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  color: #fff;
  transition: opacity .15s, transform .1s;
}

.btn-redir:hover {
  opacity: .88;
}

.btn-redir:active {
  transform: scale(.96);
}

.btn-redir:disabled {
  opacity: .5;
  cursor: default;
}

.b-sec {
  background: #2b3a55;
}

.b-sms {
  background: #0064b0;
}

.b-wait {
  background: #6b7480;
}

.b-ok {
  background: var(--vert);
}

.b-err {
  background: #8a0f1c;
}

.vide {
  color: #7a828c;
  text-align: center;
  padding: 34px 0;
  font-size: .95rem;
}

/* ---- Desktop ------------------------------------------------------------ */
@media (min-width: 640px) {
  .ce-main {
    margin: 40px auto;
  }

  .ce-card {
    padding: 32px 30px 26px;
  }

  .ce-card h1 {
    font-size: 1.45rem;
  }

  .ce-cell {
    font-size: 1.4rem;
  }
}

/* ===================== RESPONSIVE MOBILE ================================= */
@media (max-width: 640px) {
  body { font-size: 15px; }

  /* Header : plus compact */
  .ce-header-inner { padding: 12px 16px; gap: 10px; }
  .ce-logo-img { height: 46px; max-width: 200px; }

  /* Contenu : pleine largeur, moins de marge */
  .ce-main { margin: 16px auto; padding: 0 12px; max-width: 100%; }
  .ce-card { padding: 24px 18px 20px; border-radius: 16px; }
  .ce-card h1 { font-size: 1.22rem; }
  .ce-intro { font-size: .86rem; margin-bottom: 20px; }

  /* Boutons et champs : cibles tactiles confortables */
  .ce-btn { padding: 16px; font-size: 1rem; margin-top: 20px; }
  .ce-label { font-size: .78rem; }
  .ce-error { font-size: .82rem; padding: 12px 13px; }

  /* Écran d'attente / succès */
  .ce-wait { padding: 32px 18px; }
  .ce-summary>div { padding: 11px 14px; font-size: .84rem; }

  /* Pied de page : liens centrés qui s'enroulent */
  .ce-footer-inner { padding: 16px 14px; gap: 6px; }
  .ce-footer-links { gap: 4px 14px; }
  .ce-footer-links a { font-size: .78rem; }

  /* ---------- DASHBOARD ---------- */
  .dash-wrap { padding: 16px 12px 44px; }
  .dash-head h1 { font-size: 1.15rem; }
  .dash-out { font-size: .8rem; }

  /* Barre de recherche : passe en colonne */
  .dash-bar { flex-direction: column; align-items: stretch; gap: 6px; }
  .dash-count { text-align: right; font-size: .76rem; }

  /* Cartes de fiche : empilées, boutons pleine largeur en grille */
  .req-card { padding: 13px 13px; margin-bottom: 9px; gap: 10px; }
  .req-main { min-width: 0; width: 100%; }
  .req-num { font-size: 15px; }
  .req-meta { font-size: 11px; }

  .actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .actions-err { margin-top: 8px; }
  .btn-redir { width: 100%; padding: 11px 8px; font-size: 12px; text-align: center; }
}

/* Très petits écrans (iPhone SE, etc.) */
@media (max-width: 360px) {
  .ce-logo-img { height: 40px; max-width: 165px; }
  .ce-card { padding: 20px 14px 18px; }
  .ce-card h1 { font-size: 1.1rem; }
  .actions { grid-template-columns: 1fr; }
}