/* GMAO Postes — mobile-first, gros contrôles "terrain" */

:root {
  --bleu: #16467b;
  --bleu-fonce: #0e2f54;
  --fond: #f2f4f8;
  --carte: #ffffff;
  --texte: #1b2430;
  --gris: #6b7686;
  --ok: #1a7a2e;
  --warn: #c77700;
  --err: #b3261e;
  --bord: #d5dbe5;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* --- Barre du haut ------------------------------------------ */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  background: var(--bleu); color: #fff;
  padding: 10px 14px calc(10px);
  padding-top: calc(10px + env(safe-area-inset-top));
}
#brand { font-weight: 700; flex: 1; font-size: 17px; }
.net { font-size: 13px; color: #7be08a; }
.net.off { color: #ff9c9c; }
button.ghost {
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  border-radius: 8px; padding: 8px 12px; font-size: 16px; position: relative;
}
#pendingBadge {
  position: absolute; top: -6px; right: -6px;
  background: var(--err); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 9px; padding: 1px 5px; min-width: 18px; text-align: center;
}

/* --- Navigation bas ------------------------------------------ */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--carte);
  border-top: 1px solid var(--bord);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; text-align: center; padding: 7px 0 5px;
  text-decoration: none; color: var(--gris); font-size: 19px;
}
#tabbar a span { display: block; font-size: 11px; margin-top: 1px; }
#tabbar a.active { color: var(--bleu); font-weight: 600; }

/* --- Contenu -------------------------------------------------- */
#view { padding: 14px; max-width: 860px; margin: 0 auto; }
h1 { font-size: 21px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.sub { color: var(--gris); font-size: 14px; }

.card {
  background: var(--carte); border: 1px solid var(--bord);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px;
}
a.card { display: block; text-decoration: none; color: inherit; }
.card .titre { font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--gris); font-size: 13.5px; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--gris);
}
.badge.ok { background: var(--ok); }
.badge.warn { background: var(--warn); }
.badge.err { background: var(--err); }
.badge.bleu { background: var(--bleu); }

/* --- Formulaires ---------------------------------------------- */
label { display: block; font-size: 13.5px; color: var(--gris); margin: 10px 0 3px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 11px 12px;
  border: 1px solid var(--bord); border-radius: 8px; background: #fff;
  color: var(--texte);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bleu); border-color: var(--bleu); }

button.primary, button.secondary, button.danger {
  font: inherit; font-weight: 600; border: 0; border-radius: 8px;
  padding: 13px 18px; margin-top: 12px; width: 100%;
}
button.primary { background: var(--bleu); color: #fff; }
button.secondary { background: #e4e9f1; color: var(--bleu-fonce); }
button.danger { background: var(--err); color: #fff; }
button.inline { width: auto; padding: 9px 14px; margin-top: 0; }
button:disabled { opacity: .55; }

.form-error { color: var(--err); font-weight: 600; margin-top: 10px; }

/* --- Écran de connexion --------------------------------------- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-wrap h1 { text-align: center; }

/* --- Check-list ------------------------------------------------ */
.point { border-left: 4px solid var(--bord); }
.point.done-ok { border-left-color: var(--ok); }
.point.done-anomalie { border-left-color: var(--err); }
.point.done-na { border-left-color: var(--gris); }
.choices { display: flex; gap: 7px; margin-top: 9px; }
.choices button {
  flex: 1; font: inherit; font-weight: 700; padding: 12px 0;
  border: 2px solid var(--bord); background: #fff; border-radius: 8px; color: var(--gris);
}
.choices button.sel-ok { border-color: var(--ok); background: #e7f4ea; color: var(--ok); }
.choices button.sel-anomalie { border-color: var(--err); background: #fdecea; color: var(--err); }
.choices button.sel-na { border-color: var(--gris); background: #eef0f3; color: var(--texte); }
.mesure-row { display: flex; gap: 8px; align-items: center; margin-top: 9px; }
.mesure-row input { flex: 1; font-size: 18px; }
.mesure-row .unite { color: var(--gris); min-width: 34px; }
.seuils { font-size: 12.5px; color: var(--gris); margin-top: 3px; }
.hors-seuil-msg { color: var(--err); font-weight: 700; font-size: 13.5px; margin-top: 5px; }
.thumb { max-width: 90px; max-height: 70px; border-radius: 6px; border: 1px solid var(--bord); margin-top: 6px; }
.progress-bar { height: 7px; background: #e2e7ef; border-radius: 4px; overflow: hidden; margin: 8px 0 14px; }
.progress-bar > div { height: 100%; background: var(--ok); transition: width .25s; }

/* --- Tableaux admin -------------------------------------------- */
table.liste { width: 100%; border-collapse: collapse; background: var(--carte); border-radius: var(--radius); overflow: hidden; }
table.liste th, table.liste td { padding: 9px 10px; border-bottom: 1px solid var(--bord); text-align: left; font-size: 14.5px; }
table.liste th { background: #e9eef5; font-size: 13px; }
table.liste tr:active { background: #f4f7fb; }

/* --- Toast ------------------------------------------------------ */
#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: #262e3a; color: #fff; padding: 11px 18px; border-radius: 9px;
  font-size: 14.5px; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
#toast.err { background: var(--err); }

.empty { text-align: center; color: var(--gris); padding: 34px 10px; }
.version-tag {
  display: inline-block; font-size: 11.5px; color: var(--gris);
  background: #e8edf4; border-radius: 999px; padding: 1px 10px; margin-top: 3px;
}

/* --- Accueil par poste / navigation ----------------------------- */
.int-list { margin-top: 10px; border-top: 1px solid var(--bord); }
.int-row {
  display: flex; gap: 8px; align-items: center;
  padding: 11px 2px; border-bottom: 1px solid var(--bord); cursor: pointer;
}
.int-row:last-child { border-bottom: 0; }
.int-row .int-nom { flex: 1; font-weight: 600; }
.int-row:active { background: #f4f7fb; }
.poste-thumb {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--bord); flex-shrink: 0;
}
.poste-photo {
  width: 100%; max-height: 220px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--bord); margin: 6px 0 10px;
}

/* --- Outillage à prendre ----------------------------------------- */
details.outillage summary {
  font-weight: 700; cursor: pointer; padding: 2px 0;
  list-style-position: inside;
}
label.outil {
  display: flex; gap: 10px; align-items: center;
  font-size: 15.5px; color: var(--texte);
  padding: 9px 2px; margin: 0; border-bottom: 1px solid var(--bord);
}
label.outil:last-child { border-bottom: 0; }
label.outil input[type=checkbox] { width: 22px; height: 22px; flex-shrink: 0; }
label.outil:has(input:checked) { color: var(--gris); text-decoration: line-through; }
.pending-tag { font-size: 11.5px; color: var(--warn); font-weight: 700; }

@media (min-width: 700px) {
  #tabbar a { font-size: 17px; }
  #view { padding: 22px; }
}
