/* ============================================================
   fideli.css — Design system FIDELI v2.0
   Mobile-first · Syne + DM Sans · Blanc/Bleu épuré
   Inclure dans toutes les pages :
   <link rel="stylesheet" href="fideli.css">
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500&display=swap');

/* ── Variables ──────────────────────────────────────────── */
:root {
  --blue:       #2563EB;
  --blue-lt:    #EFF6FF;
  --blue-md:    #DBEAFE;
  --ink:        #0F172A;
  --ink2:       #334155;
  --muted:      #64748B;
  --border:     #E2E8F0;
  --surf:       #F8FAFC;
  --white:      #FFFFFF;
  --green:      #16A34A;
  --green-lt:   #DCFCE7;
  --red:        #DC2626;
  --red-lt:     #FEF2F2;
  --amber:      #D97706;
  --amber-lt:   #FEF3C7;
  --r-sm:       10px;
  --r-md:       16px;
  --r-lg:       20px;
  --r-xl:       28px;
  --nav-h:      calc(64px + env(safe-area-inset-bottom));
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--surf);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: var(--nav-h);
  -webkit-font-smoothing: antialiased;
}

/* ── Typographie ────────────────────────────────────────── */
.font-syne { font-family: 'Syne', sans-serif; }
h1, h2, h3 { font-family: 'Syne', sans-serif; font-weight: 800; letter-spacing: -.5px; }

/* ── TOP BAR ────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 57px;
}
.logo {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 22px; color: var(--ink); letter-spacing: -1px;
  text-decoration: none;
}
.logo em { color: var(--blue); font-style: normal; }
.topbar-back {
  display: flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  background: none; border: none; cursor: pointer;
  text-decoration: none; font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.topbar-back svg { width: 18px; height: 18px; }
.topbar-action {
  font-size: 13px; font-weight: 500; color: var(--blue);
  background: none; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

/* ── BOTTOM NAV ─────────────────────────────────────────── */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.ni {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); text-decoration: none;
  background: none; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent; min-width: 52px;
  transition: color .15s;
}
.ni svg { width: 22px; height: 22px; }
.ni span { font-size: 10px; font-weight: 500; }
.ni.active { color: var(--blue); }

/* ── TABS ───────────────────────────────────────────────── */
.tabs-wrap {
  position: sticky; top: 57px; z-index: 30;
  background: var(--white); border-bottom: 1px solid var(--border);
}
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; padding: 13px 18px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  border: none; background: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; position: relative;
  -webkit-tap-highlight-color: transparent; transition: color .15s;
}
.tab-btn.active { color: var(--blue); }
.tab-btn.active::after {
  content: ''; position: absolute; bottom: 0;
  left: 18px; right: 18px; height: 2px;
  background: var(--blue); border-radius: 2px 2px 0 0;
}
.tab-pane { display: none; padding: 20px; }
.tab-pane.active { display: block; }

/* ── BOUTONS ────────────────────────────────────────────── */
.btn-p {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff;
  font-size: 15px; font-weight: 500; padding: 14px 20px;
  border-radius: var(--r-md); border: none; cursor: pointer;
  width: 100%; text-decoration: none; font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .1s;
}
.btn-p:active { transform: scale(.98); background: #1d4ed8; }
.btn-p:disabled { background: var(--muted); cursor: not-allowed; transform: none; }
.btn-p svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-s {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--white); color: var(--ink);
  font-size: 15px; font-weight: 500; padding: 13px 20px;
  border-radius: var(--r-md); border: 1.5px solid var(--border);
  cursor: pointer; width: 100%; text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s, transform .1s;
}
.btn-s:active { transform: scale(.98); border-color: var(--blue); }
.btn-s svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-danger {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--red-lt); color: var(--red);
  font-size: 14px; font-weight: 500; padding: 12px 20px;
  border-radius: var(--r-md); border: 1.5px solid #fecaca;
  cursor: pointer; width: 100%; font-family: 'DM Sans', sans-serif;
}

/* ── CHAMPS ─────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label {
  font-size: 13px; font-weight: 500; color: var(--ink2);
  display: block; margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%; padding: 14px 16px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: 16px; font-family: 'DM Sans', sans-serif;
  color: var(--ink); background: var(--white);
  outline: none; transition: border-color .15s;
  -webkit-appearance: none; -moz-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--blue); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  background-size: 18px; padding-right: 44px;
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px;
}
.card + .card { margin-top: 12px; }

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
}
.badge-blue   { background: var(--blue-md); color: var(--blue); }
.badge-green  { background: var(--green-lt); color: var(--green); }
.badge-amber  { background: var(--amber-lt); color: var(--amber); }
.badge-gray   { background: var(--surf); color: var(--muted); border: 1px solid var(--border); }
.badge-red    { background: var(--red-lt); color: var(--red); }

/* ── STAT BOX ───────────────────────────────────────────── */
.stat-box {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 12px;
}
.stat-box .sv {
  font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800;
  color: var(--blue); letter-spacing: -.5px;
}
.stat-box .sl { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

/* ── SECTION TITLE ──────────────────────────────────────── */
.sec-title {
  font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 800;
  color: var(--ink); letter-spacing: -.5px; margin-bottom: 14px;
}

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue-lt); display: flex;
  align-items: center; justify-content: center; margin: 0 auto 14px;
}
.empty-icon svg { width: 26px; height: 26px; stroke: var(--blue); }
.empty h3 { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; color: var(--ink); }
.empty p { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.55; max-width: 260px; margin-inline: auto; }

/* ── BOTTOM SHEET (modale) ──────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.sheet {
  background: var(--white);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 12px 20px calc(32px + env(safe-area-inset-bottom));
  width: 100%; max-height: 90dvh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.overlay.open .sheet { transform: translateY(0); }
.handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 2px; margin: 0 auto 20px; flex-shrink: 0;
}
.sheet-title {
  font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800;
  color: var(--ink); margin-bottom: 6px; flex-shrink: 0;
}
.sheet-sub { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; flex-shrink: 0; }
.sheet-body { overflow-y: auto; flex: 1; }

/* ── TOAST ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 20px; right: 20px;
  background: var(--ink); color: #fff;
  padding: 14px 18px; border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  z-index: 200; text-align: center;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── PROGRESS BAR ───────────────────────────────────────── */
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width .3s; }

/* ── SPINNER ────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── STEPPER ─────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; padding: 20px 20px 0; }
.step-item { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.step-item:not(:last-child)::after {
  content: ''; position: absolute;
  top: 14px; left: calc(50% + 14px); right: calc(-50% + 14px);
  height: 2px; background: var(--border); z-index: 0;
}
.step-item.done:not(:last-child)::after { background: var(--blue); }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 12px;
  z-index: 1; position: relative;
  border: 2px solid var(--border); background: var(--white); color: var(--muted);
  transition: all .2s;
}
.step-item.active .step-dot,
.step-item.done   .step-dot { border-color: var(--blue); background: var(--blue); color: #fff; }
.step-lbl { font-size: 10px; color: var(--muted); margin-top: 5px; font-weight: 500; text-align: center; }
.step-item.active .step-lbl { color: var(--blue); }

/* ── SCAN BOX ───────────────────────────────────────────── */
.scan-area {
  margin: 20px; border-radius: var(--r-md); overflow: hidden;
  background: var(--ink); aspect-ratio: 1; position: relative;
}
.scan-frame-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.scan-frame {
  width: 55%; aspect-ratio: 1; border: 2.5px solid var(--blue);
  border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.48);
}

/* ── ITI (intl-tel-input) ───────────────────────────────── */
.iti { width: 100%; }

/* ── UTILITAIRES ────────────────────────────────────────── */
.p-20    { padding: 20px; }
.pt-0    { padding-top: 0; }
.mb-12   { margin-bottom: 12px; }
.mb-16   { margin-bottom: 16px; }
.mb-20   { margin-bottom: 20px; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-muted { font-size: 13px; color: var(--muted); }
.text-small { font-size: 12px; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }