/* Interventions BLUEROCK : mobile d'abord, lisible en plein soleil, clair et sombre. */
:root {
  --fond: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --texte: #14201f;
  --texte-2: #4a5654;
  --trait: #dcd8cf;
  --marque: #0f3d3e;
  --marque-2: #17595a;
  --accent: #e8a33d;
  --sur-marque: #ffffff;
  --urgent: #c62828;
  --urgent-fond: #fde8e6;
  --haute: #d4600f;
  --haute-fond: #fdeedd;
  --normale: #1d6fb8;
  --normale-fond: #e4f0fb;
  --basse: #5f6b69;
  --basse-fond: #eceeed;
  --ok: #2e7d32;
  --ok-fond: #e5f3e6;
  --retard: #b00020;
  --ombre: 0 1px 2px rgba(20, 32, 31, .06), 0 4px 14px rgba(20, 32, 31, .07);
  --rayon: 16px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0b1416; --surface: #142124; --surface-2: #1a2a2e; --texte: #eef3f2; --texte-2: #a9b8b6;
    --trait: #2a3c40; --marque: #6fc2bf; --marque-2: #8fd6d2; --sur-marque: #08201f; --accent: #f2b85c;
    --urgent: #ff6b63; --urgent-fond: #3a1614; --haute: #ff9d52; --haute-fond: #3a2412;
    --normale: #6fb2f0; --normale-fond: #12283c; --basse: #a3afad; --basse-fond: #222f31;
    --ok: #74c97a; --ok-fond: #15301a; --retard: #ff7b84;
    --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0b1416; --surface: #142124; --surface-2: #1a2a2e; --texte: #eef3f2; --texte-2: #a9b8b6;
  --trait: #2a3c40; --marque: #6fc2bf; --marque-2: #8fd6d2; --sur-marque: #08201f; --accent: #f2b85c;
  --urgent: #ff6b63; --urgent-fond: #3a1614; --haute: #ff9d52; --haute-fond: #3a2412;
  --normale: #6fb2f0; --normale-fond: #12283c; --basse: #a3afad; --basse-fond: #222f31;
  --ok: #74c97a; --ok-fond: #15301a; --retard: #ff7b84;
  --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte); font: 17px/1.45 var(--police);
  min-height: 100dvh; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--marque-2); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.noscript { padding: 24px; }

/* ---------- barre du haut */
.barre {
  position: sticky; top: 0; z-index: 5; background: var(--marque); color: var(--sur-marque);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 14px;
  display: flex; align-items: center; gap: 12px;
}
:root[data-theme="dark"] .barre { background: #0f2224; color: var(--texte); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .barre { background: #0f2224; color: var(--texte); } }
.barre h1 { font-size: 20px; margin: 0; line-height: 1.2; font-weight: 750; letter-spacing: -.01em; }
.barre .sous { font-size: 14px; opacity: .85; }
.barre .titre { flex: 1; min-width: 0; }
.barre .titre h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icone-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .14);
  color: inherit; display: grid; place-items: center; cursor: pointer; flex: none;
}
.icone-btn svg { width: 22px; height: 22px; }

/* ---------- bandeau mode essai */
.essai {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; background: var(--haute-fond);
  color: var(--texte); border: 1px solid var(--haute); font-size: 15px;
}
.essai b { color: var(--haute); }

/* ---------- filtres */
.filtres { display: flex; gap: 8px; padding: 14px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.puce-filtre {
  flex: none; min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--trait);
  background: var(--surface); color: var(--texte); font-weight: 600; font-size: 15px; cursor: pointer;
}
.puce-filtre[aria-pressed="true"] { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.puce-filtre .n { opacity: .7; margin-left: 4px; font-weight: 500; }

/* ---------- liste */
main { padding: 0 16px calc(env(safe-area-inset-bottom) + 120px); max-width: 760px; margin: 0 auto; }
.groupe { margin: 18px 4px 8px; font-size: 13px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--texte-2); }
.groupe.retard { color: var(--retard); }
.carte {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--trait);
  border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px 16px 14px 20px; margin: 0 0 10px;
  position: relative; cursor: pointer; color: inherit; text-decoration: none; overflow: hidden;
}
.carte::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--normale); }
.carte.p4::before, .carte.p3::before { background: var(--urgent); }
.carte.p1::before, .carte.p0::before { background: var(--basse); }
.carte:active { transform: scale(.995); }
.carte h2 { font-size: 18px; margin: 6px 0 4px; line-height: 1.3; font-weight: 700; }
.carte .lieu { color: var(--texte-2); font-size: 15px; display: flex; gap: 6px; align-items: flex-start; }
.carte .lieu svg { width: 16px; height: 16px; flex: none; margin-top: 3px; }
.carte .bas { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 14px; color: var(--texte-2); }
.carte .bas b { color: var(--texte); font-weight: 650; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; line-height: 1.5; background: var(--basse-fond); color: var(--basse);
}
.puce.p4, .puce.p3 { background: var(--urgent-fond); color: var(--urgent); }
.puce.p2 { background: var(--normale-fond); color: var(--normale); }
.puce.retard { background: var(--retard); color: #fff; }
.puce.encours { background: var(--ok-fond); color: var(--ok); }
.puce .point { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.vide { text-align: center; padding: 48px 16px; color: var(--texte-2); }
.vide svg { width: 56px; height: 56px; opacity: .5; }
.maj { text-align: center; font-size: 13px; color: var(--texte-2); margin: 16px 0; }

/* ---------- fiche */
.bloc { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 16px; margin: 12px 0; box-shadow: var(--ombre); }
.bloc h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--texte-2); font-weight: 750; }
.fiche-titre { font-size: 23px; line-height: 1.25; margin: 16px 0 8px; font-weight: 750; letter-spacing: -.01em; }
.lots .lot { font-weight: 750; font-size: 18px; }
.lots .adresse { color: var(--texte-2); }
.lots .lot-item + .lot-item { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--trait); }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.date-case { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.date-case .l { font-size: 13px; color: var(--texte-2); }
.date-case .v { font-size: 18px; font-weight: 750; }
.date-case.retard .v { color: var(--retard); }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.fil .msg { padding: 10px 0; border-top: 1px solid var(--trait); }
.fil .msg:first-of-type { border-top: 0; padding-top: 0; }
.fil .qui { font-weight: 700; font-size: 15px; }
.fil .quand { color: var(--texte-2); font-size: 13px; margin-left: 6px; font-weight: 500; }
.fil .txt { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.creneaux { display: flex; flex-wrap: wrap; gap: 8px; }
.creneau { background: var(--ok-fond); color: var(--ok); border-radius: 10px; padding: 6px 10px; font-weight: 650; font-size: 15px; }
.avert { background: var(--haute-fond); border: 1px solid var(--haute); border-radius: 12px; padding: 12px; font-size: 15px; }
.lien-ext { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-weight: 650; text-decoration: none; }
.lien-ext svg { width: 18px; height: 18px; }

/* ---------- actions */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--trait);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 760px; margin: 0 auto;
}
.btn {
  min-height: 54px; border-radius: 14px; border: 0; padding: 10px 14px; font-weight: 750; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  background: var(--surface-2); color: var(--texte); border: 1.5px solid var(--trait);
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.principal { background: var(--marque); color: var(--sur-marque); border-color: var(--marque); }
.btn.fin { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.large { grid-column: 1 / -1; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ---------- feuille (dialogue) */
dialog.feuille {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; border-radius: 22px 22px 0 0;
  background: var(--surface); color: var(--texte); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
dialog.feuille::backdrop { background: rgba(8, 18, 18, .5); }
@media (min-width: 700px) { dialog.feuille { margin: auto; border-radius: 22px; } }
.feuille form { padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); }
.feuille h2 { margin: 0 0 4px; font-size: 21px; }
.feuille .aide { color: var(--texte-2); font-size: 15px; margin: 0 0 14px; }
.champ { display: block; margin: 0 0 14px; }
.champ span { display: block; font-weight: 650; font-size: 15px; margin-bottom: 6px; }
.champ input, .champ textarea {
  width: 100%; min-height: 52px; border-radius: 12px; border: 1.5px solid var(--trait); background: var(--surface-2);
  padding: 12px 14px; font-size: 17px;
}
.champ textarea { min-height: 120px; resize: vertical; }
.ligne2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feuille .boutons { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }

/* ---------- connexion */
.connexion { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--marque) 35%, transparent), transparent), var(--fond); }
.connexion .boite { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; padding: 28px 22px; box-shadow: var(--ombre); border: 1px solid var(--trait); }
.connexion .logo { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 14px; }
.connexion h1 { text-align: center; font-size: 24px; margin: 0; }
.connexion p.sous { text-align: center; color: var(--texte-2); margin: 4px 0 22px; }
.connexion .btn { width: 100%; margin-top: 4px; }
.erreur { color: var(--urgent); font-weight: 650; margin: 0 0 12px; min-height: 1.4em; }

/* ---------- divers */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 20;
  max-width: 560px; margin: 0 auto; background: var(--texte); color: var(--fond); padding: 14px 16px;
  border-radius: 14px; font-weight: 600; box-shadow: var(--ombre);
}
#toast.erreur-toast { background: var(--urgent); color: #fff; }
.chargement { display: grid; place-items: center; min-height: 60vh; }
.rond { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--trait); border-top-color: var(--marque); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rond { animation-duration: 3s; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.outils { display: flex; gap: 8px; }
.haut { margin-top: 14px; }
.gras { font-weight: 650; }

/* ---------- prise de rendez-vous */
.puce.etape { background: var(--surface-2); color: var(--texte); border: 1px solid var(--trait); }
.puce.e-attente_paiement { background: var(--haute-fond); color: var(--haute); border-color: transparent; }
.puce.e-sans_reponse { background: var(--urgent-fond); color: var(--urgent); border-color: transparent; }
.puce.e-choix_recu { background: var(--accent); color: #1a1205; border-color: transparent; }
.puce.e-rdv_fixe, .puce.e-rdv_confirme { background: var(--ok-fond); color: var(--ok); border-color: transparent; }
.etape-bloc { border-left: 6px solid var(--marque-2); }
.etape-bloc.e-attente_paiement { border-left-color: var(--haute); }
.etape-bloc.e-sans_reponse { border-left-color: var(--urgent); }
.etape-bloc.e-choix_recu { border-left-color: var(--accent); }
.etape-bloc.e-rdv_fixe, .etape-bloc.e-rdv_confirme { border-left-color: var(--ok); }
.pas { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 12px; counter-reset: pas; }
.pas li { flex: 1; text-align: center; font-size: 12px; font-weight: 700; color: var(--texte-2); padding-top: 26px; position: relative; counter-increment: pas; }
.pas li::before { content: counter(pas); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--trait); display: grid; place-items: center; font-size: 12px; line-height: 18px; }
.pas li.fait::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.pas li.actif { color: var(--texte); }
.pas li.actif::before { border-color: var(--marque-2); background: var(--marque-2); color: var(--sur-marque); }
.etape-titre { font-size: 19px; font-weight: 750; }
.etape-detail { margin: 4px 0 10px; color: var(--texte-2); }
.paiement { display: flex; gap: 14px; align-items: center; border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.paiement.attente { background: var(--haute-fond); }
.paiement.ok { background: var(--ok-fond); }
.paiement .montant { font-size: 24px; font-weight: 800; white-space: nowrap; }
.liste-creneaux { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.liste-creneaux li { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.liste-creneaux li.choisi { background: var(--accent); color: #1a1205; }
.reponse { margin: 10px 0 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 12px 12px 0; white-space: pre-wrap; }
.reponse .l { font-size: 13px; color: var(--texte-2); font-weight: 650; margin-bottom: 2px; }
.rdv-final { display: flex; gap: 8px; align-items: center; font-weight: 750; font-size: 18px; color: var(--ok); margin-top: 8px; }
.rdv-final svg { width: 22px; height: 22px; }
.explication { margin: 0; font-size: 14px; color: var(--texte-2); text-align: center; }
.grille-jours { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; margin-bottom: 8px; }
.jour { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; }
.jour-nom { font-weight: 700; font-size: 15px; }
.jour-choix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.choix { min-height: 44px; border-radius: 10px; border: 1.5px solid var(--trait); background: var(--surface-2); font-weight: 650; font-size: 14px; cursor: pointer; }
.choix[aria-pressed="true"] { background: var(--marque); color: var(--sur-marque); border-color: var(--marque); }
.compteur { color: var(--texte-2); font-size: 14px; margin: 0 0 10px; }
