/* Design « iPhone » : fond groupé, cartes blanches, verre dépoli, barre d'onglets flottante.
   L'ancienne feuille à la charte Pure Drive est gardée dans design-archive/. */
:root {
  --bg: #F2F2F7;            /* fond groupé iOS */
  --card: #ffffff;
  --ink: #1c1c1e;
  --ink-2: #48484a;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, .14);
  --fill: rgba(118, 118, 128, .12);
  --accent: #007AFF;
  --accent-soft: rgba(0, 122, 255, .12);
  --green: #34C759;  --green-text: #1f8a3b;  --green-soft: rgba(52, 199, 89, .16);
  --orange: #FF9500; --orange-text: #b36200; --orange-soft: rgba(255, 149, 0, .16);
  --red: #FF3B30;    --red-text: #c4221a;    --red-soft: rgba(255, 59, 48, .13);
  --indigo: #5856D6; --indigo-text: #4543b8; --indigo-soft: rgba(88, 86, 214, .13);
  --gray: #8e8e93;   --gray-text: #636366;   --gray-soft: rgba(142, 142, 147, .16);
  --glass: rgba(255, 255, 255, .72);
  --blur: saturate(180%) blur(22px);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
  font-size: 17px; line-height: 1.3; letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; letter-spacing: inherit; }
a { color: inherit; }

/* Couleur de statut : une seule définition, reprise par l'avatar, la pastille, les choix et l'agenda */
.s-prospect { --c: var(--indigo); --ct: var(--indigo-text); --cs: var(--indigo-soft); }
.s-devis    { --c: var(--orange); --ct: var(--orange-text); --cs: var(--orange-soft); }
.s-ok       { --c: var(--green);  --ct: var(--green-text);  --cs: var(--green-soft); }
.s-done     { --c: var(--gray);   --ct: var(--gray-text);   --cs: var(--gray-soft); }
.s-lost     { --c: var(--red);    --ct: var(--red-text);    --cs: var(--red-soft); }

/* En-tête en verre */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(242, 242, 247, .78);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: .5px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.logo { height: 34px; width: 34px; flex: none; border-radius: 10px; background: #fff; padding: 3px; box-shadow: var(--shadow); }
.wordmark { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.who { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--accent); background: var(--card); box-shadow: var(--shadow); }
.icon-btn:active { opacity: .6; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 12px 16px calc(40px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
body.has-tabs main { padding-bottom: calc(120px + var(--safe-b)); }

/* Barre d'onglets flottante en verre */
.tabbar {
  position: fixed; z-index: 20; left: 12px; right: 12px; bottom: calc(10px + var(--safe-b));
  max-width: 460px; margin: 0 auto; padding: 6px;
  display: flex; gap: 2px;
  border-radius: 30px; border: .5px solid rgba(255, 255, 255, .7);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .16), 0 1px 0 rgba(255, 255, 255, .6) inset;
}
.view {
  position: relative; flex: 1; min-width: 0; min-height: 54px; padding: 6px 0 5px; border-radius: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-2); font-size: 11px; font-weight: 600;
}
.view .tab-lbl { white-space: nowrap; }
.view.on { color: var(--accent); background: rgba(0, 122, 255, .13); }
.view .n {
  position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* Recherche */
.input {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 17px;
  border: 0; border-radius: 14px; background: var(--card); color: var(--ink);
  -webkit-appearance: none; appearance: none; box-shadow: var(--shadow);
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.search { margin-bottom: 12px; padding: 10px 14px; background: var(--fill); box-shadow: none; border-radius: 12px; }

/* Sources : capsules défilantes */
.sources {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px;
  scrollbar-width: none;
}
.sources::-webkit-scrollbar { display: none; }
.src {
  flex: none; min-height: 34px; padding: 0 14px; border-radius: 17px;
  background: var(--card); font-size: 15px; font-weight: 500; white-space: nowrap; box-shadow: var(--shadow);
}
.src .n { margin-left: 6px; color: var(--muted); font-size: 13px; }
.src.on { background: var(--ink); color: #fff; font-weight: 600; }
.src.on .n { color: rgba(255, 255, 255, .65); }

/* Contrôle segmenté iOS */
.seg { display: flex; padding: 2px; gap: 2px; background: var(--fill); border-radius: 11px; }
.seg button { flex: 1; min-height: 40px; border-radius: 9px; font-weight: 500; font-size: 14px; color: var(--ink); line-height: 1.15; }
.seg button.on { background: #fff; font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.seg button small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }

.count { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .02em; margin: 18px 4px 8px; }

/* Légende de l'agenda */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 4px 0; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }

/* Liste */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; margin-bottom: 10px;
  border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); cursor: pointer;
}
.item:active { background: #f7f7fa; }
.item.due { box-shadow: 0 0 0 2px var(--orange), var(--shadow); }
.item.col { flex-direction: column; align-items: stretch; }
.item .row { display: flex; align-items: center; gap: 12px; }
.body { flex: 1; min-width: 0; }
.avatar {
  flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; letter-spacing: 0;
  background: var(--cs); color: var(--ct);
}
.nom { font-weight: 600; font-size: 17px; }
.sub { color: var(--muted); font-size: 15px; margin-top: 1px; }
.next { font-size: 14px; margin-top: 5px; font-weight: 600; color: var(--ink-2); }
.next::before { content: '→ '; color: var(--accent); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); align-items: center; }
.tag { padding: 3px 9px; border-radius: 8px; background: var(--fill); color: var(--ink-2); }

/* Statut : pastille teintée */
.st { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 8px; font-weight: 600; background: var(--cs); color: var(--ct); }
.st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
/* Dernière étape de suivi */
.stp { padding: 3px 9px; border-radius: 8px; background: var(--fill); color: var(--ink); font-weight: 600; }
.stp.none { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); font-weight: 500; }
.stp.ok { background: var(--green-soft); color: var(--green-text); }
.rel { padding: 3px 9px; border-radius: 8px; background: var(--orange); color: #fff; font-weight: 600; }

/* Appel direct */
.call {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: var(--green); color: #fff;
  box-shadow: 0 4px 12px rgba(52, 199, 89, .35);
}
.call:active { transform: scale(.94); }

/* Actions rapides (avis) */
.quick { display: flex; gap: 8px; margin-top: 12px; }
.qa { flex: 1; min-height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 15px; }
.qa.strong { background: var(--accent); color: #fff; }
.qa:active { opacity: .7; }
.avis-meta { margin-top: 0; }
.qa[disabled] { opacity: .35; }
.qa.wa { background: #25D366; }
.send { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }

/* À encaisser */
.total { list-style: none; padding: 18px 16px; margin-bottom: 14px; border-radius: 22px; color: #fff;
  background: linear-gradient(135deg, #1c1c1e, #3a3a3c); box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.total small { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; }
.total b { display: block; font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.total span { font-size: 14px; opacity: .85; }
.total em { font-style: normal; color: #FF9F97; font-weight: 600; }
.money { flex: none; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.item.late { box-shadow: 0 0 0 2px var(--red), var(--shadow); }
.rel.late { background: var(--red); }

/* Alerte de conflit de voiture */
.alert { margin-top: 8px; padding: 9px 12px; border-radius: 12px; font-size: 14px; background: var(--orange-soft); color: var(--orange-text); }
.alert.hard { background: var(--red-soft); color: var(--red-text); }
.alert b { display: block; font-weight: 700; }
.alert span { display: block; }
.sheet .alert { margin: 0 0 12px; padding: 12px 14px; font-size: 15px; border-radius: var(--radius); }

/* Agenda des prochains départs */
.section-title { list-style: none; font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 22px 4px 10px; }
.ag-date {
  flex: none; width: 54px; align-self: stretch; min-height: 62px; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  border-radius: 13px; background: var(--bg);
}
.ag-date span { width: 100%; padding: 3px 0; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #fff; background: var(--c, var(--gray)); }
.ag-date b { margin: auto; font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.car { display: inline-block; margin-top: 4px; padding: 3px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; }
.car.todo { background: none; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--muted); font-weight: 500; }
.car.mini { margin: 0; padding: 1px 7px; font-size: 12px; }

.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* Panneaux plein écran */
.sheet {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: up .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes up { from { transform: translateY(28px); opacity: 0; } }
.sheet-body { max-width: 640px; margin: 0 auto; padding: calc(8px + var(--safe-t)) 16px calc(36px + var(--safe-b)); }
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 48px; margin-bottom: 6px;
}
.sheet-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.sheet-head > :first-child { justify-self: start; }
.text-btn { min-height: 44px; padding: 0 4px; color: var(--accent); font-weight: 500; font-size: 17px; }
.text-btn.center { display: block; margin: 10px auto 0; }

.lbl { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 20px 4px 8px; }
.muted { color: var(--muted); text-transform: none; }
.date-row { display: flex; gap: 10px; align-items: center; }
.date-row .input { flex: 1; min-height: 50px; }
.hint { color: var(--muted); font-size: 14px; text-align: center; margin: 8px 4px 0; }
.hint.left { text-align: left; }
.hint.warn { color: var(--red-text); font-weight: 600; font-size: 15px; }

.btn-primary {
  display: block; width: 100%; min-height: 52px; margin-top: 24px;
  border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px;
}
.btn-primary:active { opacity: .75; }
.btn-primary[disabled] { opacity: .5; }
.btn-primary.gold { margin-top: 14px; }   /* bouton principal dans une carte */
.btn-secondary {
  display: block; width: 100%; min-height: 50px; margin-top: 12px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.btn-secondary:active { opacity: .7; }

/* Choix rapides : capsules */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qc {
  min-height: 38px; padding: 0 14px; border-radius: 19px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 500; font-size: 15px;
}
.d-sec .qc { background: var(--fill); box-shadow: none; }
.qc.on { background: var(--c, var(--accent)); color: #fff; font-weight: 600; }
.grp { display: block; color: var(--muted); font-size: 13px; margin: 12px 4px 6px; }
.grp:first-child { margin-top: 0; }

/* Détail : sections en cartes */
.d-cat { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 4px; }
.d-title { font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; margin: 4px 4px 4px; overflow-wrap: anywhere; }
.d-sub { color: var(--muted); margin: 0 4px 16px; font-size: 15px; }
.d-sec { margin: 0 0 12px; padding: 14px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.d-sec > small { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .02em; }
.d-next { font-weight: 600; }
.d-next small { display: block; font-weight: 400; color: var(--orange-text); margin-top: 3px; font-size: 15px; }
.d-notes { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.d-cell { background: var(--card); border-radius: 14px; padding: 10px 12px; min-width: 0; box-shadow: var(--shadow); }
.d-cell.wide { grid-column: 1 / -1; }
.d-cell small { display: block; color: var(--muted); font-size: 12px; }
.d-cell b { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; white-space: pre-wrap; }
.d-cell a { color: var(--accent); text-decoration: none; }
.acts { display: flex; gap: 10px; margin: 0 0 12px; }
.act {
  flex: 1; min-height: 48px; display: grid; place-items: center; border-radius: 14px;
  background: var(--card); color: var(--accent); font-weight: 600; text-decoration: none; box-shadow: var(--shadow);
}
.act { font-size: 17px; }
.act.call-act { background: var(--green); color: #fff; }
.act:active { opacity: .7; }

/* Journal de suivi */
.tl { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.tl:last-of-type { padding-bottom: 2px; }
.tl::before {
  content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--card);
}
.tl.g-reglement::before { background: var(--green); }
.tl.g-avis::before { background: var(--orange); }
.tl-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tl-h b { font-size: 16px; font-weight: 600; }
.tl-h .tag { font-size: 13px; }
.tl-d { color: var(--muted); font-size: 13px; margin-left: auto; }
.tl p { margin: 4px 0 0; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.tl-empty { color: var(--muted); margin: 0; }
.split-parent { font-weight: 700; font-size: 22px; letter-spacing: -.02em; margin: 0 4px; }

/* Bouton de dictée */
.mic {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; margin-bottom: 8px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.mic.rec { background: var(--red); color: #fff; }
.mic.rec svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.mic + .hint { margin: 0 0 8px; }
.mic + .hint:empty { display: none; }

/* Message bref, en verre sombre */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + var(--safe-b)); z-index: 50;
  margin: 0 auto; max-width: 400px;
  padding: 13px 16px; border-radius: 22px;
  background: rgba(28, 28, 30, .86); color: #fff; text-align: center; font-size: 15px; font-weight: 500;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.toast.err { background: rgba(196, 34, 26, .92); }
