:root {
  --bg: #EEF3F0;
  --surface: #FFFFFF;
  --soft: #E3ECE8;
  --ink: #12211D;
  --muted: #5B6B65;
  --line: #CFDBD5;
  --brand: #1D5A48;
  --brand-press: #164737;
  --wait: #C98A12;
  --wa: #25D366;
  --wa-ink: #06381C;
  --no: #B3432F;
  --focus: 0 0 0 3px rgba(29, 90, 72, .28);
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Sora', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  width: 100%;
  max-width: 400px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

/* ---------- Logo : il porte l'état de la demande ---------- */
.mark {
  position: relative;
  width: 150px;
  height: 150px;
  flex: none;
  padding: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 22px 44px -24px rgba(29, 90, 72, .55);
  cursor: pointer;
  transition: width .45s cubic-bezier(.2, .8, .2, 1), height .45s cubic-bezier(.2, .8, .2, 1), transform .15s;
}
.mark:active { transform: scale(.97); }
.mark:focus-visible { outline: none; box-shadow: var(--focus), 0 22px 44px -24px rgba(29, 90, 72, .55); }
.mark img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: contain; }

.mark-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  opacity: 0;
  pointer-events: none;
}
.mark-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  border: 3px solid var(--bg);
}

[data-state="intro"] .mark-ring { animation: pulse 2.4s ease-out infinite; }
[data-state="form"] .mark,
[data-state="loading"] .mark { width: 104px; height: 104px; }
[data-state="form"] .mark { cursor: default; }

[data-state="pending"] .mark-ring,
[data-state="loading"] .mark-ring {
  border: 0;
  opacity: 1;
  background: conic-gradient(var(--wait) 0 22%, transparent 22% 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  animation: spin 1.8s linear infinite;
}
[data-state="loading"] .mark-ring { background: conic-gradient(var(--line) 0 22%, transparent 22% 100%); }
[data-state="pending"] .mark-badge { display: flex; background: var(--wait); }

[data-state="approved"] .mark-ring { opacity: 1; border: 4px solid var(--wa); animation: settle .6s cubic-bezier(.2, .8, .2, 1); }
[data-state="approved"] .mark-badge { display: flex; background: var(--wa); color: var(--wa-ink); }
[data-state="approved"] .mark,
[data-state="pending"] .mark,
[data-state="rejected"] .mark { cursor: default; }

[data-state="rejected"] .mark-ring { opacity: 1; border: 3px solid var(--no); }
[data-state="rejected"] .mark-badge { display: flex; background: var(--no); }

@keyframes pulse {
  0% { transform: scale(.94); opacity: .55; }
  100% { transform: scale(1.22); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes settle {
  0% { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Panneau ---------- */
.panel { width: 100%; text-align: center; }
.panel h1 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
}
.panel p { margin: 0 auto 14px; max-width: 34ch; color: var(--muted); }
.panel p strong { color: var(--ink); font-weight: 600; white-space: nowrap; }
.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  font-size: .88rem;
  background: var(--soft);
  border-radius: 12px;
  padding: 12px 14px;
  max-width: 34ch;
}
.note i { margin-top: 4px; color: var(--brand); }

.form { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
.phone-field {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.phone-field:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.phone-field.has-error { border-color: var(--no); }
.cc-btn {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 14px;
  border: 0;
  border-right: 1.5px solid var(--line);
  background: var(--soft);
  font-weight: 600;
  cursor: pointer;
}
.cc-btn:focus-visible { outline: none; background: #D6E3DD; }
.cc-btn i { font-size: .7rem; color: var(--muted); }
.iso {
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--brand);
  color: #fff;
  letter-spacing: .04em;
}
.phone-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  padding: 16px 14px;
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.phone-field input::placeholder { color: #9AABA4; }
.field-error { min-height: 1.2em; margin: 0 !important; font-size: .85rem; color: var(--no) !important; text-align: left; }

.btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--brand-press); }
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-wa { background: var(--wa); color: var(--wa-ink); font-size: 1.05rem; padding: 18px 20px; }
.btn-wa:hover { background: #1FBE5B; }
.btn-wa i { font-size: 1.35rem; }
.btn-ghost { background: transparent; color: var(--brand); margin-top: 6px; }
.btn-ghost:hover { background: var(--soft); }
.actions { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Bottom sheet pays ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 33, 29, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 105%);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  z-index: 21;
}
.sheet-open .sheet-backdrop { opacity: 1; pointer-events: auto; }
.sheet-open .sheet { transform: translate(-50%, 0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 10px; }
.sheet-title { margin: 0; padding: 4px 20px 12px; font-size: 1.05rem; font-weight: 600; }
.sheet-list { overflow-y: auto; padding: 0 8px; }
.sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.sheet-item:hover, .sheet-item:focus-visible { background: var(--soft); outline: none; }
.sheet-item .name { flex: 1; }
.sheet-item .dial { color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-item .fa-check { color: var(--brand); }
.sheet-item[aria-selected="true"] { font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: .92rem;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
