/* Même allure que Studio Créateur : fond sombre, cartes, émojis, barre en bas sur téléphone, colonne à gauche sur ordinateur.
   Règle de Franck : un seul geste par écran, tout ce qui se touche fait au moins 44 px. */
:root {
  --bg: #0f1115; --card: #181b22; --card2: #1f232c; --line: #2a2f3a; --text: #eef0f5; --muted: #9aa1b1; --faint: #6b7280;
  --primary: #eef0f5; --on-primary: #0f1115; --accent: #ff4d4d; --online: #3ecf8e; --warn: #ffb020; --bleu: #5aa9ff;
  --radius: 14px; --tabbar: 58px; --rail: 76px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { overflow-x: clip; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
button:focus-visible, label:focus-within, a:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }
h1 { font-size: 24px; margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; font-weight: 700; }
h3 { font-size: 18px; margin: 0; line-height: 1.25; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .faint { color: var(--faint); }
main {
  max-width: 760px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 32px;
}
.entete { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.entete h1 { flex: 1; }
.marque { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.retour { min-width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 22px; }
.retour:hover { background: var(--card); color: var(--text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; }
.status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); margin: 14px 0; font-size: 15px; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--online); flex: none; box-shadow: 0 0 0 4px rgba(62,207,142,.15); }
.status.alert .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(255,176,32,.15); }
.tresor { font-size: 38px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 2px 0 4px; }
.courbe { width: 100%; height: 74px; display: block; margin-top: 8px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 700; text-align: center; }
.btn.soft { background: var(--card2); color: var(--text); font-weight: 600; }
.btn.ok { background: var(--online); color: #0f1115; }
.btn.block { width: 100%; }
.link { color: var(--muted); text-decoration: underline; padding: 6px 0; min-height: 44px; }
.photo {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; overflow: hidden;
  min-height: 132px; border-radius: 18px; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 21px; margin: 4px 0 6px; cursor: pointer;
}
.photo .e { font-size: 40px; line-height: 1; }
.photo small { font-weight: 500; font-size: 14px; color: #3b4150; }
.photo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.action { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; width: 100%; text-align: left; }
.action .ico { font-size: 26px; width: 36px; text-align: center; flex: none; }
.action .grow, .item .grow { flex: 1; min-width: 0; }
.action .t, .item .t { font-weight: 600; line-height: 1.3; }
.action .d, .item .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.fleche { color: var(--faint); font-size: 22px; flex: none; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.item:first-child { border-top: 0; }
.item .ico { font-size: 22px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--card2); border-radius: 12px; flex: none; }
.item .m { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: var(--card2); font-size: 12px; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { color: #0f1115; background: var(--online); border-color: var(--online); }
.chip.warn { color: #0f1115; background: var(--warn); border-color: var(--warn); }
.chip.rouge { color: #fff; background: var(--accent); border-color: var(--accent); }
.wins { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.wins li { display: flex; gap: 10px; font-size: 15px; }
.wins li::before { content: "✓"; color: var(--online); font-weight: 800; }
.bar { height: 8px; background: var(--card2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--online); border-radius: 99px; }

/* À valider */
.decision .type { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.decision .montant { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.decision .par { font-size: 13px; color: var(--faint); margin-top: 10px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.deux .btn { min-height: 58px; font-size: 19px; }
.fini { text-align: center; padding: 30px 12px; }
.fini .big { font-size: 46px; }

/* Lecture d'une facture */
.etape { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; opacity: .3; transition: opacity .3s; }
.etape.fait { opacity: 1; }
.etape .pt { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.etape.fait .pt { background: var(--online); border-color: var(--online); color: #0f1115; }
.facture { border: 1px dashed var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.facture b { color: var(--text); }
.facture img { border-radius: 8px; max-height: 220px; object-fit: contain; }

/* Questions */
.conv { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bulle { padding: 11px 15px; border-radius: 18px; max-width: 88%; }
.bulle.moi { background: #2b3a55; align-self: flex-end; border-bottom-right-radius: 6px; }
.bulle.lui { background: var(--card); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bulle .qui { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chips button { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-size: 14px; min-height: 44px; text-align: left; }
.saisie { display: flex; gap: 8px; }
.saisie input, textarea { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
textarea { width: 100%; resize: vertical; }
.micro { width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; font-size: 22px; }

/* Équipe */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.agent { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.agent:hover { border-color: #3a4150; }
.agent.travaille { border-color: rgba(62,207,142,.5); }
.agent .tete { display: flex; align-items: center; gap: 10px; }
.agent .ico { font-size: 24px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--card2); border-radius: 12px; flex: none; }
.agent .nom { font-weight: 700; flex: 1; line-height: 1.2; min-width: 0; }
.pastille { font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; background: var(--card2); color: var(--muted); }
.pastille.travaille { background: rgba(62,207,142,.15); color: var(--online); }
.pastille.travaille::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--online); margin-right: 6px; animation: pulse 1.4s infinite; }
.pastille.attente { background: rgba(255,176,32,.14); color: var(--warn); }
@keyframes pulse { 50% { opacity: .3; } }
.agent .ligne { font-size: 13.5px; }
.agent .rdv { font-size: 12.5px; color: var(--faint); }
.regle { border-left: 3px solid var(--online); padding: 10px 14px; background: var(--card); border-radius: 0 12px 12px 0; font-size: 15px; margin: 12px 0 4px; }

.onglets { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin: 12px 0; }
.onglets button { flex: 1; min-height: 42px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.onglets button[aria-pressed="true"] { background: var(--card2); color: var(--text); }

/* Fiche qui monte du bas */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 40; }
.fiche { background: var(--card); border: 1px solid var(--line); border-radius: 18px 18px 0 0; width: min(640px, 100%); max-height: 88dvh; overflow: auto;
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }
.fiche h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.bloc { background: var(--card2); border-radius: 12px; padding: 10px 12px; margin: 6px 0; font-size: 14px; }
@media (min-width: 760px) { .voile { align-items: center; } .fiche { border-radius: 18px; } }

/* Barre de navigation */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: #12151b; border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
#tabbar button { flex: 1; min-width: 0; min-height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: #9aa1b1; position: relative; white-space: nowrap; }
#tabbar button span { font-size: 21px; line-height: 1; }
#tabbar button[aria-current] { color: var(--text); font-weight: 600; }
#tabbar b { position: absolute; top: 5px; left: calc(50% + 6px); background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; text-align: center; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom, 0px));
  width: min(440px, calc(100% - 32px)); background: #2b3a55; color: var(--text); border-radius: 14px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; z-index: 50; font-size: 15px; }
.toast button { font-weight: 700; text-decoration: underline; min-height: 44px; flex: none; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: var(--rail); }
  #tabbar { top: 0; right: auto; width: var(--rail); flex-direction: column; justify-content: flex-start; gap: 4px; border-top: 0; border-right: 1px solid var(--line); padding: 14px 0; }
  #tabbar button { flex: none; min-height: 64px; margin: 0 8px; border-radius: 12px; }
  #tabbar button:hover, #tabbar button[aria-current] { background: #181b22; }
  .toast { bottom: 24px; left: calc(50% + var(--rail) / 2); }
}
@media (prefers-reduced-motion: reduce) { .etape { transition: none; } .pastille.travaille::before { animation: none; } }

/* Ajouts de l'app réelle */
.vide { text-align: center; padding: 26px 12px; color: var(--muted); }
.vide .big { font-size: 40px; }
.champ { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; color: var(--muted); }
.champ input, .champ select, .champ textarea { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); color: var(--text); width: 100%; min-height: 48px; }
.erreur { color: #ff8080; font-size: 14px; min-height: 20px; }
.apercu { width: 100%; max-height: 360px; object-fit: contain; border-radius: 10px; background: var(--card2); }
.chargement { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--online); border-radius: 50%; animation: tourne .8s linear infinite; vertical-align: middle; }
@keyframes tourne { to { transform: rotate(360deg); } }
.installer { border-color: rgba(90,169,255,.5); }
