:root {
  --navy: #22405E;
  --navy-2: #1A3249;
  --ink: #1E2A33;
  --green: #2D7A3A;
  --green-2: #3A833D;
  --green-soft: #E5F1E6;
  --brown: #4E3830;
  --sand: #F6F3EE;
  --line: #E3DED6;
  --muted: #6B7480;
  --white: #fff;
  --orange: #C26A12;
  --orange-soft: #FDF0DF;
  --red: #A3352B;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 42, 51, .06), 0 4px 14px rgba(30, 42, 51, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --head: 'Archivo', system-ui, -apple-system, sans-serif;
  --body: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--sand); color: var(--ink); }
body {
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--head); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- en-tête */
.head { position: sticky; top: 0; z-index: 20; }
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: calc(var(--safe-top) + 10px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar .brand img { width: 34px; height: 34px; border-radius: 9px; background: #fff; padding: 3px; }
.topbar .brand b { font-family: var(--head); font-size: 19px; display: block; }
.topbar .brand small { opacity: .75; font-size: 14px; display: block; }
.topbar .title { flex: 1; font-family: var(--head); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; color: inherit;
}
.icon-btn:active { background: rgba(255,255,255,.12); }
.icon-btn svg { width: 24px; height: 24px; }
.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ onglets */
.tabs {
  background: var(--navy);
  padding: 0 12px 12px;
  display: flex; gap: 6px;
}
.tab {
  flex: 1; padding: 9px 6px; border-radius: 10px;
  color: rgba(255,255,255,.78); font-weight: 600; font-size: 15px;
  background: rgba(255,255,255,.07);
}
.tab.on { background: var(--white); color: var(--navy); }
.tab .n { display: inline-block; min-width: 22px; padding: 0 6px; margin-left: 4px; border-radius: 99px; font-size: 13px; background: rgba(255,255,255,.18); }
.tab.on .n { background: var(--green); color: #fff; }

.wrap { padding: 14px 14px calc(110px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 12px; margin-bottom: 12px;
}
.search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.search input { border: 0; outline: 0; background: none; padding: 12px 0; width: 100%; font-size: 16px; }

/* ------------------------------------------------------------------ cartes */
.card {
  display: block; width: 100%; text-align: left;
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 14px 18px; margin-bottom: 10px;
  position: relative; overflow: hidden;
}
.card:active { transform: scale(.99); }
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--navy)); }
.card .row1 { display: flex; align-items: baseline; gap: 8px; }
.card .who { font-family: var(--head); font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .when { color: var(--muted); font-size: 14px; flex: none; }
.card .what { color: var(--muted); font-size: 15px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: #EEF1F4; color: var(--navy); line-height: 1.35; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.orange { background: var(--orange-soft); color: var(--orange); }
.chip.red { background: #F7E3E1; color: var(--red); }
.chip.grey { background: #EEEDEA; color: #615C56; }

.st-Lead { --c: var(--navy); }
.st-Lead-qualifie { --c: var(--green-2); }
.st-RDV { --c: #D99A1E; }
.st-Achat { --c: var(--green); }
.st-Non-qualifie { --c: #B9B3AA; }
.st-Perdu { --c: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty svg { width: 56px; height: 56px; color: var(--green-2); margin-bottom: 8px; }
.empty b { display: block; color: var(--ink); font-family: var(--head); font-size: 18px; margin-bottom: 4px; }

.banner {
  background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--green);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
  display: flex; gap: 12px; align-items: center;
}
.banner p { margin: 0; flex: 1; font-size: 15px; }
.banner p b { display: block; font-size: 16px; }

.fab {
  position: fixed; right: 18px; bottom: calc(22px + var(--safe-bottom)); z-index: 30;
  width: 60px; height: 60px; border-radius: 20px;
  background: var(--green); color: #fff; box-shadow: 0 6px 18px rgba(45,122,58,.4);
  display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; }

/* ------------------------------------------------------------------- fiche */
.hero { background: var(--navy); color: #fff; padding: 4px 18px 22px; }
.hero h1 { font-size: 26px; }
.hero .meta { opacity: .8; margin-top: 4px; font-size: 15px; }
.hero .chips .chip { background: rgba(255,255,255,.14); color: #fff; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: -14px 14px 0; position: relative; }
.act {
  background: var(--white); border-radius: 14px; box-shadow: var(--shadow);
  padding: 12px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; color: var(--navy); text-decoration: none;
}
.act svg { width: 24px; height: 24px; }
.act.call { background: var(--green); color: #fff; }
.act.off { pointer-events: none; color: #B5BCC4; }
.act.call.off { background: #A7C9AD; color: #fff; }

.section { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.section h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 12px; font-weight: 700; }
.msg { white-space: pre-wrap; font-size: 16px; margin: 0; }

.statuts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stbtn {
  padding: 13px 10px; border-radius: 12px; border: 2px solid var(--line);
  font-weight: 700; font-size: 16px; background: var(--white); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.stbtn.on { border-color: var(--c); background: var(--c); color: #fff; }
.stbtn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.stbtn.on .dot { background: #fff; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px 13px; font-size: 16px; outline: 0; line-height: 1.4;
}
.field input:focus, .field textarea:focus { border-color: var(--green-2); }
.field textarea { min-height: 96px; resize: vertical; }
.money { position: relative; }
.money span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }

.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { padding: 9px 13px; border-radius: 99px; border: 1.5px solid var(--line); font-weight: 600; font-size: 15px; background: #fff; }
.pick button.on { background: var(--navy); border-color: var(--navy); color: #fff; }

.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.steps li:last-child { border-bottom: 0; }
.steps li span:last-child { color: var(--muted); }
.steps li.done span:first-child { font-weight: 700; color: var(--green); }

details.more summary { list-style: none; font-weight: 700; color: var(--navy); display: flex; justify-content: space-between; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: '+'; font-size: 22px; line-height: 1; }
details.more[open] summary::after { content: '−'; }
details.more[open] summary { margin-bottom: 12px; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 14px calc(12px + var(--safe-bottom));
  background: rgba(246,243,238,.94); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  transform: translateY(110%); visibility: hidden; transition: transform .2s ease, visibility .2s;
}
.savebar.show { transform: none; visibility: visible; }
.btn {
  display: block; width: 100%; padding: 15px; border-radius: 14px;
  background: var(--green); color: #fff; font-weight: 700; font-size: 17px; text-align: center;
}
.btn:disabled { opacity: .5; }
.btn.ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn.navy { background: var(--navy); }
.btn + .btn { margin-top: 10px; }
.link { color: var(--navy); font-weight: 600; text-decoration: underline; padding: 10px; }

/* --------------------------------------------------------- connexion / PIN */
.screen { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 34px) 22px calc(var(--safe-bottom) + 24px); max-width: 480px; margin: 0 auto; }
.screen .logo { width: 190px; margin: 0 auto 26px; display: block; }
.screen h1 { font-size: 24px; text-align: center; color: var(--navy); }
.screen .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.who-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 12px;
  font-family: var(--head); font-size: 20px; font-weight: 700; color: var(--navy);
}
.who-btn .av { width: 48px; height: 48px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 20px; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0 26px; }
.dots i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--navy); }
.dots i.on { background: var(--navy); }
.dots.err { animation: shake .35s; }
.dots.err i { border-color: var(--red); }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; width: 100%; }
.pad button { height: 64px; border-radius: 18px; background: #fff; box-shadow: var(--shadow); font-size: 26px; font-weight: 600; font-family: var(--head); color: var(--navy); }
.pad button:active { background: var(--green-soft); }
.pad .ghost { background: none; box-shadow: none; font-size: 16px; }
.err-msg { text-align: center; color: var(--red); min-height: 22px; font-weight: 600; margin-top: -14px; margin-bottom: 8px; }

.install-steps { list-style: none; padding: 0; margin: 0 0 24px; counter-reset: s; }
.install-steps li { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 14px 14px 14px 56px; margin-bottom: 10px; position: relative; counter-increment: s; }
.install-steps li::before { content: counter(s); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-family: var(--head); }
.install-steps svg { width: 20px; height: 20px; vertical-align: -4px; color: #0A84FF; }

/* -------------------------------------------------------------- feuille */
.sheet-bg { position: fixed; inset: 0; background: rgba(20,30,40,.45); z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  background: var(--sand); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + var(--safe-bottom)); max-width: 640px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { font-size: 19px; margin-bottom: 12px; color: var(--navy); }
.sheet .line { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.sheet .line small { display: block; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 60; white-space: nowrap; max-width: 92vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

.loader { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.offline { background: #FFF6E5; color: #7A4B00; text-align: center; font-size: 14px; padding: 6px; }
