/* Suivi des prestations — langage de la signalétique d'aérogare :
   fond béton clair lisible au soleil, texte ardoise, la ligne en cours
   en jaune balisage. Une seule police, conçue pour la lisibilité. */

:root {
  --beton: #E8EBED;      /* fond */
  --surface: #F8F9FA;    /* cartes */
  --ardoise: #22272B;    /* texte, boutons principaux */
  --gris: #4F575E;       /* texte secondaire (contraste 6,0 sur le béton) */
  --ligne: #C3C9CE;      /* bordures */
  --balisage: #FFC400;   /* ligne en cours, prise en charge */
  --vert: #1B6E3F;       /* fait */
  --rouge: #B3261E;      /* non fait, alerte */
  --bleu: #0B57A4;       /* information, envoi */

  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 6px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--beton);
  color: var(--ardoise);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, p, ol, dl, dd, blockquote { margin: 0; }
a { color: var(--bleu); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--bleu); outline-offset: 2px; }
[hidden] { display: none !important; }  /* l'attribut hidden l'emporte sur les display des classes */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ardoise); color: #fff; padding: var(--s2) var(--s3); z-index: 10; }
.skip:focus { left: var(--s2); }

/* --- En-tête -------------------------------------------------------------- */
.top-bar {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--ardoise); color: #fff;
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3);
}
.brand { font-weight: 700; margin-right: auto; }
.who { font-size: 15px; opacity: .85; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { color: #fff; border-color: rgba(255,255,255,.4); }
.net { padding: var(--s2) var(--s4); font-size: 15px; font-weight: 700; }
.net-off { background: #3A4046; color: #fff; }
.net-sync { background: var(--bleu); color: #fff; }

/* --- Mise en page ------------------------------------------------------------ */
.view { max-width: 640px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s6); display: grid; gap: var(--s4); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.page-title { font-size: 28px; line-height: 1.15; }
.group { display: grid; gap: var(--s3); }
.group-title { font-size: 17px; color: var(--gris); }
.loading, .empty { color: var(--gris); padding: var(--s5) 0; }
.empty-calm { padding: var(--s3) 0; }
.note { font-size: 15px; padding: var(--s2) var(--s3); border-radius: var(--radius); }
.note-offline { background: #DCE6F1; color: #0A3D73; }
.note-warn { background: #FBE3E1; color: #7A1A14; }
.back { font-weight: 700; text-decoration: none; justify-self: start; padding: var(--s2) 0; }
.back::before { content: '‹ '; }

/* --- Boutons ------------------------------------------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 60px; width: 100%; padding: var(--s3) var(--s4);
  border: 3px solid transparent; border-radius: var(--radius);
  font-size: 20px; font-weight: 700; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy='true'] { opacity: .7; }
.btn-go { background: var(--ardoise); color: #fff; }
.btn-done { background: var(--vert); color: #fff; }
.btn-notdone { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn-notdone-solid { background: var(--rouge); color: #fff; }
.btn-quiet { background: transparent; color: var(--ardoise); border-color: var(--ardoise); }
.btn-icon { background: transparent; border: 2px solid var(--ligne); border-radius: var(--radius); min-height: 40px; padding: 0 var(--s3); cursor: pointer; }
.btn-small {
  min-height: 44px; padding: 0 var(--s4); border-radius: var(--radius);
  background: var(--ardoise); color: #fff; border: 2px solid var(--ardoise); font-weight: 700; cursor: pointer;
}
.btn-small-quiet { background: transparent; color: var(--ardoise); }

/* --- Cartes de prestation -------------------------------------------------------- */
.card {
  display: grid; gap: var(--s1);
  background: var(--surface); color: var(--ardoise); text-decoration: none;
  border: 2px solid var(--ligne); border-left-width: 8px; border-radius: var(--radius);
  padding: var(--s3) var(--s4);
}
.card-in_progress { border-left-color: var(--balisage); }
.card-planned { border-left-color: var(--ardoise); }
.card-closed { border-left-color: var(--vert); }
.card-site { font-size: 20px; font-weight: 700; }
.card-slot { color: var(--gris); }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: 15px; }
.bar { display: block; height: 6px; background: var(--ligne); border-radius: 3px; overflow: hidden; margin-top: var(--s2); }
.bar-fill { display: block; height: 100%; background: var(--ardoise); }

.chip { display: inline-block; padding: 2px var(--s2); border-radius: 4px; font-size: 14px; font-weight: 700; background: var(--ligne); }
.chip-in_progress { background: var(--balisage); }
.chip-planned { background: var(--ardoise); color: #fff; }
.chip-closed { background: var(--vert); color: #fff; }
.chip-alert-open { background: var(--rouge); color: #fff; }
.chip-alert-acknowledged { background: var(--balisage); }
.chip-alert-resolved { background: var(--vert); color: #fff; }
.chip-escalated { background: #fff; color: var(--rouge); border: 2px solid var(--rouge); }

/* --- Tournée ---------------------------------------------------------------------- */
.mission { display: grid; gap: var(--s2); }
.mission-site { font-size: 28px; line-height: 1.15; }
.mission-slot { color: var(--gris); }
.mission-access summary { cursor: pointer; font-weight: 700; color: var(--bleu); min-height: 44px; display: flex; align-items: center; }
.mission-access p { background: var(--surface); padding: var(--s3); border-radius: var(--radius); }
.progress { height: 14px; background: var(--surface); border: 2px solid var(--ardoise); border-radius: 7px; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--ardoise); }
.progress-text { font-weight: 700; }
.start { display: grid; gap: var(--s3); }

.zone { display: grid; gap: var(--s2); }
.zone-title { font-size: 15px; color: var(--gris); border-top: 2px solid var(--ligne); padding-top: var(--s3); }
.lines { list-style: none; padding: 0; display: grid; gap: var(--s2); }

.line { display: grid; grid-template-columns: 40px 1fr auto; align-items: start; gap: var(--s3); padding: var(--s2) 0; }
.num {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: var(--ardoise); color: #fff; font-weight: 700; border-radius: 3px;
}
.line-label { font-weight: 700; }
.line-locked { color: var(--gris); }
.line-locked .num { background: var(--ligne); color: var(--ardoise); }
.line-locked .line-label { font-weight: 400; }

/* La ligne en cours : un panneau de balisage */
.line-current { display: grid; grid-template-columns: 1fr; gap: var(--s3); padding: 0; }
.sign {
  display: grid; grid-template-columns: 56px 1fr; gap: var(--s4); align-items: start;
  background: var(--balisage); color: var(--ardoise);
  padding: var(--s4); border-radius: var(--radius);
}
.sign .num { width: 56px; height: 56px; font-size: 28px; background: var(--ardoise); color: var(--balisage); }
.sign-text { display: grid; gap: var(--s2); }
.sign-label { font-size: 24px; font-weight: 700; line-height: 1.2; }
.sign-instr { font-size: 17px; }
.badge { justify-self: start; font-size: 14px; font-weight: 700; padding: 2px var(--s2); border-radius: 4px; }
.badge-photo { background: var(--ardoise); color: #fff; }
.line-locked .badge-photo { background: transparent; color: var(--gris); border: 1px solid var(--gris); }
.actions { display: grid; gap: var(--s3); }
.actions-row { grid-template-columns: 1fr; }

.mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 700; font-size: 20px; color: #fff; }
.line-done .mark, .line-done_late .mark { background: var(--vert); }
.line-not_done .mark { background: var(--rouge); }
.line-body { display: grid; gap: 2px; grid-column: 2 / 4; }
.line-status { font-size: 15px; color: var(--gris); }
.line-not_done .line-status { color: var(--rouge); font-weight: 700; }
.line-photos { font-size: 14px; color: var(--gris); }
.line-pending { font-size: 14px; color: var(--bleu); font-weight: 700; }
.line-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.line-actions:empty { display: none; }

.close { display: grid; gap: var(--s3); border-top: 2px solid var(--ardoise); padding-top: var(--s4); }
.report { display: grid; gap: var(--s2); background: var(--surface); border: 2px solid var(--vert); border-radius: var(--radius); padding: var(--s4); }
.report-rate { font-size: 56px; font-weight: 700; line-height: 1; color: var(--vert); margin-top: var(--s2); }
.report-list { padding-left: 0; list-style: none; display: grid; gap: var(--s1); margin: var(--s2) 0; color: var(--gris); }

/* --- Feuille modale ------------------------------------------------------------------ */
.backdrop { position: fixed; inset: 0; background: rgba(34, 39, 43, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 12px 12px 0 0;
  padding: var(--s4) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
}
.sheet-head { display: flex; align-items: start; gap: var(--s3); margin-bottom: var(--s3); }
.sheet-title { font-size: 20px; line-height: 1.25; margin-right: auto; }
.sheet-body { display: grid; gap: var(--s3); }
.field-label { font-weight: 700; }
.field {
  width: 100%; font: inherit; font-size: 18px; padding: var(--s3);
  border: 2px solid var(--ardoise); border-radius: var(--radius); background: #fff; color: var(--ardoise);
}
textarea.field { resize: vertical; }
.reasons { display: grid; gap: var(--s2); }
.reason {
  min-height: 52px; text-align: left; padding: var(--s2) var(--s4);
  background: #fff; border: 2px solid var(--ligne); border-radius: var(--radius); font-weight: 700; cursor: pointer;
}
.reason[aria-checked='true'] { background: var(--ardoise); color: #fff; border-color: var(--ardoise); }
.photo-row { display: flex; align-items: center; gap: var(--s3); }
.photo-state { color: var(--vert); font-weight: 700; }

/* --- Encadrement ------------------------------------------------------------------------ */
.tabs { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--ardoise); border-radius: var(--radius); overflow: hidden; }
.tab { min-height: 48px; background: var(--surface); border: 0; font-weight: 700; cursor: pointer; }
.tab[aria-pressed='true'] { background: var(--ardoise); color: #fff; }
.tab-content { display: grid; gap: var(--s4); }
.live { font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.live::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--gris); }
.live-live::before { background: var(--vert); }
.live-down { color: var(--rouge); }
.live-down::before { background: var(--rouge); }
.setup { display: grid; gap: var(--s3); background: var(--surface); border: 2px dashed var(--ardoise); border-radius: var(--radius); padding: var(--s4); }

.alert {
  display: grid; gap: var(--s2);
  background: var(--surface); border: 2px solid var(--ligne); border-left-width: 8px; border-radius: var(--radius);
  padding: var(--s4);
}
.alert-open { border-left-color: var(--rouge); }
.alert-acknowledged { border-left-color: var(--balisage); }
.alert-resolved { border-left-color: var(--vert); }
.alert-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.alert-when { margin-left: auto; font-size: 15px; color: var(--gris); }
.alert-line { font-size: 21px; line-height: 1.25; }
.alert-where { color: var(--gris); }
.alert-reason { font-weight: 700; color: var(--rouge); }
.alert-comment { border-left: 3px solid var(--ligne); padding-left: var(--s3); font-style: italic; }
.alert-who, .alert-ack { font-size: 15px; color: var(--gris); }
.alert-caught { font-size: 15px; color: var(--vert); font-weight: 700; }
.thumbs { display: flex; flex-wrap: wrap; gap: var(--s2); }
.thumbs:empty { display: none; }
.thumbs img { width: 96px; height: 96px; object-fit: cover; border-radius: 4px; border: 2px solid var(--ligne); display: block; }
.alert-resolution { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s3); font-size: 15px; }
.alert-resolution dt { font-weight: 700; }

/* --- Connexion -------------------------------------------------------------------------- */
.login { display: grid; gap: var(--s3); padding-top: var(--s5); }
.login-title { font-size: 30px; line-height: 1.15; }
.login-lead { color: var(--gris); margin-bottom: var(--s3); }

/* --- Message bref --------------------------------------------------------------------------- */
.toast {
  position: fixed; left: var(--s4); right: var(--s4); bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  max-width: 608px; margin: 0 auto; z-index: 30;
  background: var(--ardoise); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--radius);
  font-weight: 700; opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.toast.is-visible { opacity: 1; transform: none; }
.toast-error { background: var(--rouge); }
.toast-ok { background: var(--vert); }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; transform: none; }
}
@media (min-width: 560px) {
  .actions { grid-template-columns: 1fr 1fr; }
}

/* --- Navigation direction / responsables ------------------------------------------------ */
.nav { display: flex; gap: var(--s1); background: var(--ardoise); padding: 0 var(--s4) var(--s2); overflow-x: auto; }
.nav-link {
  flex: 0 0 auto; min-height: 40px; display: flex; align-items: center; padding: 0 var(--s3);
  color: #fff; text-decoration: none; font-weight: 700; border-radius: var(--radius); opacity: .8;
}
.nav-link[aria-current='page'] { background: var(--balisage); color: var(--ardoise); opacity: 1; }

/* --- Paramétrage ------------------------------------------------------------------------------ */
.lead { color: var(--gris); }
.setup-section {
  display: grid; gap: var(--s3); background: var(--surface);
  border: 2px solid var(--ligne); border-radius: var(--radius); padding: var(--s4);
}
.setup-section.draft { border-color: var(--balisage); border-width: 3px; }
.setup-title { font-size: 20px; line-height: 1.2; }
.setup-form { display: grid; gap: var(--s4); }
.form-field { display: grid; gap: var(--s1); }
.field-hint { font-size: 15px; color: var(--gris); }
.subform { display: grid; gap: var(--s3); padding-left: var(--s3); border-left: 4px solid var(--balisage); }
select.field { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2322272B' stroke-width='2.5'/%3E%3C/svg%3E") no-repeat right var(--s3) center; padding-right: var(--s6); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s3); }
.facts dt { color: var(--gris); }
.facts dd { white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 420px) { .facts { grid-template-columns: 1fr; } .facts dd { margin-bottom: var(--s2); } }

.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }
.plain-list { list-style: none; padding: 0; display: grid; gap: var(--s2); }
.plain-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  padding: var(--s2) 0; border-bottom: 1px solid var(--ligne);
}
.plain-row:last-child { border-bottom: 0; }
.plain-label { flex: 1 1 12em; font-weight: 700; overflow-wrap: anywhere; }
.plain-row.is-off .plain-label { color: var(--gris); font-weight: 400; text-decoration: line-through; }

.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip-item {
  display: inline-flex; align-items: center; gap: var(--s2);
  background: var(--ardoise); color: #fff; font-weight: 700; border-radius: var(--radius); padding: 0 0 0 var(--s3);
}
.chip-remove { background: transparent; color: #fff; border: 0; min-width: 44px; min-height: 40px; cursor: pointer; }
.inline-form { display: flex; gap: var(--s2); align-items: stretch; }
.inline-form .field { flex: 1; min-width: 0; }

.daypicker { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s1); }
.day {
  min-height: 48px; border: 2px solid var(--ardoise); border-radius: var(--radius);
  background: #fff; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.day[aria-pressed='true'] { background: var(--ardoise); color: #fff; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); align-items: start; }
.proto-line .line-actions { margin-top: var(--s2); }
