:root {
  --noir: #121212;
  --carte: #1e1e1e;
  --carte2: #262626;
  --ligne: #333;
  --texte: #f2f2f2;
  --doux: #a8a8a8;
  --rouge: #d7282f;
  --rouge-fonce: #a91d23;
  --vert: #2fa866;
  --jaune: #e9b500;
  --rayon: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--noir); color: var(--texte); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- haut */
.haut {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--noir); border-bottom: 3px solid var(--rouge);
}
.haut h1 { font-size: 19px; margin: 0; flex: 1; font-style: italic; font-weight: 900; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.retour { background: none; border: 0; font-size: 34px; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }
.hors-ligne { font-size: 12px; background: var(--carte2); color: var(--doux); padding: 3px 8px; border-radius: 99px; }

main { padding: 14px 16px 24px; max-width: 640px; margin: 0 auto; }

/* ---------- onglets du bas */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0b0b0b; border-top: 1px solid var(--ligne);
  padding-bottom: env(safe-area-inset-bottom);
}
.onglets button {
  background: none; border: 0; padding: 8px 2px 10px; font-size: 11.5px; color: var(--doux);
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; min-height: 62px;
}
.onglets .ic { font-size: 21px; line-height: 1.2; }
.onglets button.actif { color: #fff; }
.onglets button.actif .ic { color: var(--rouge); }

/* ---------- blocs */
.bloc { background: var(--carte); border-radius: var(--rayon); padding: 14px; margin-bottom: 14px; }
.bloc > h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--doux); margin: 0 0 10px; font-weight: 700; }
.bloc.rouge { background: var(--rouge); }
.intro { color: var(--doux); margin: 0 0 14px; }
.petit { font-size: 13px; color: var(--doux); }
.vide { text-align: center; color: var(--doux); padding: 28px 10px; }

label.champ { display: block; margin-bottom: 10px; }
label.champ > span { display: block; font-size: 13px; color: var(--doux); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; background: var(--carte2); border: 1px solid var(--ligne); border-radius: 10px;
  padding: 12px; min-height: 48px; font-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rouge); outline-offset: 0; border-color: transparent; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.deux > label.champ { margin-bottom: 10px; }

.case { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.case input { width: 24px; height: 24px; accent-color: var(--rouge); flex: none; }
.case b { font-weight: 600; }

/* ---------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--rouge); color: #fff; border: 0; border-radius: 12px;
  padding: 12px 18px; min-height: 50px; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
}
.btn:active { background: var(--rouge-fonce); }
.btn.gris { background: var(--carte2); border: 1px solid var(--ligne); }
.btn.contour { background: none; border: 2px solid var(--rouge); }
.btn.lien { background: none; color: var(--doux); text-decoration: underline; font-weight: 400; }
.btn.plein { width: 100%; }
.btn.danger { background: none; border: 1px solid #5a2326; color: #ff8a8f; }
.btn[disabled] { opacity: .5; }
.rangee { display: flex; gap: 10px; flex-wrap: wrap; }
.rangee > .btn { flex: 1 1 0; min-width: 0; }

.puces { display: flex; gap: 8px; flex-wrap: wrap; }
.puce {
  background: var(--carte2); border: 1px solid var(--ligne); border-radius: 99px;
  padding: 9px 15px; min-height: 42px; cursor: pointer; font-weight: 600;
}
.puce.actif { background: var(--rouge); border-color: var(--rouge); }

/* ---------- lignes de travaux */
.travail { border-top: 1px solid var(--ligne); padding: 12px 0; }
.travail:first-of-type { border-top: 0; padding-top: 0; }
.travail .nom { font-weight: 700; display: flex; gap: 8px; align-items: flex-start; }
.travail .nom span { flex: 1; }
.travail .x { background: none; border: 0; color: var(--doux); font-size: 22px; line-height: 1; padding: 0 2px 0 8px; cursor: pointer; }
.travail .champs { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px; margin-top: 8px; align-items: end; }
.travail .champs label > span { display: block; font-size: 12px; color: var(--doux); margin-bottom: 3px; }
.travail .champs input { min-height: 44px; padding: 9px; }
.qte { display: flex; align-items: center; background: var(--carte2); border: 1px solid var(--ligne); border-radius: 10px; height: 44px; }
.qte button { background: none; border: 0; width: 36px; height: 100%; font-size: 20px; cursor: pointer; }
.qte b { flex: 1; text-align: center; }
.depl-ligne { color: var(--doux); font-size: 14px; }

/* ---------- totaux */
.totaux { width: 100%; border-collapse: collapse; }
.totaux td { padding: 5px 0; }
.totaux td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totaux tr.total td { font-size: 22px; font-weight: 800; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.35); }
.totaux tr.moins td { color: #ffd2d4; }
.bloc.rouge .totaux td { color: #fff; }

.moi { border: 1px dashed #555; background: transparent; }
.jauge { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: 10px; font-weight: 700; }
.jauge.ok { background: rgba(47,168,102,.15); color: #6fe0a2; }
.jauge.moyen { background: rgba(233,181,0,.15); color: #ffd54a; }
.jauge.bas { background: rgba(215,40,47,.18); color: #ff8a8f; }

/* ---------- listes */
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--carte); border: 0; border-radius: 12px; padding: 13px 14px; margin-bottom: 8px; cursor: pointer;
}
.item .gauche { flex: 1; min-width: 0; }
.item .gauche b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .gauche small { color: var(--doux); }
.item .droite { text-align: right; font-weight: 700; white-space: nowrap; }
.etiq { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--carte2); color: var(--doux); margin-top: 3px; }
.etiq.vert { background: rgba(47,168,102,.18); color: #6fe0a2; }
.etiq.jaune { background: rgba(233,181,0,.18); color: #ffd54a; }
.etiq.rouge { background: rgba(215,40,47,.2); color: #ff8a8f; }

.prix-ligne { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--ligne); }
.prix-ligne:first-of-type { border-top: 0; }
.prix-ligne .gauche { flex: 1; }
.prix-ligne .gauche small { color: var(--doux); }
.prix-ligne .montant { font-weight: 800; font-size: 17px; white-space: nowrap; }
.ajout { background: var(--rouge); color: #fff; border: 0; border-radius: 10px; width: 44px; height: 44px; font-size: 24px; cursor: pointer; flex: none; }

.villes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.villes span { background: var(--carte2); border-radius: 99px; padding: 4px 10px; font-size: 13.5px; }

.onglets-doc { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--carte); padding: 5px; border-radius: 12px; margin-bottom: 14px; }
.onglets-doc button { background: none; border: 0; border-radius: 9px; padding: 11px; font-weight: 700; color: var(--doux); cursor: pointer; }
.onglets-doc button.actif { background: var(--rouge); color: #fff; }

.resultat { font-size: 15px; }
.resultat .gros { font-size: 30px; font-weight: 800; }
.avis { background: rgba(233,181,0,.12); border-left: 4px solid var(--jaune); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14.5px; }
.avis.rouge { background: rgba(215,40,47,.14); border-color: var(--rouge); }

/* ---------- tiroir (liste des services) */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; }
.tiroir {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 86vh; overflow: auto;
  background: var(--noir); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; border-top: 3px solid var(--rouge);
}
.tiroir h2 { margin: 0 0 12px; font-size: 18px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30;
  background: #fff; color: #111; padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

.apercu img { width: 100%; border-radius: 10px; display: block; }

#impression { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  body > *:not(#impression) { display: none !important; }
  #impression { display: block !important; }
  #impression img { width: 100%; }
}
