/* Thème : gris-bleu « atelier propre », une couleur d'accent au choix, et la photo de chaque modèle. */
:root {
  --bg: #edf1f4; --card: #ffffff; --field: #f3f6f8; --text: #15232d; --muted: #5d6f7c; --line: #dde4e9;
  --brand: #0e7dba; --brand-text: #ffffff; --tint: #e2f0f8; --head: #0b6fa8; --head-text: #ffffff;
  --danger: #c62f3d; --warn: #f2b84b; --shadow: 0 1px 2px rgba(21, 35, 45, .06), 0 4px 14px rgba(21, 35, 45, .05);
}
[data-accent=vert] { --brand: #17805c; --tint: #e0f2eb; --head: #17755a; }
[data-accent=orange] { --brand: #bf560c; --tint: #fbebdd; --head: #b8520b; }
[data-accent=violet] { --brand: #5b46b8; --tint: #ece8fa; --head: #5441ad; }
[data-mode=dark] {
  --bg: #0f181f; --card: #18242d; --field: #101a21; --text: #e6edf2; --muted: #93a4b0; --line: #283741;
  --brand: #56b6ea; --brand-text: #08202e; --tint: #17384a; --head: #14212b; --head-text: #ffffff;
  --danger: #ff7b85; --shadow: none;
}
[data-mode=dark][data-accent=vert] { --brand: #4fc99c; --brand-text: #06231a; --tint: #173a2f; }
[data-mode=dark][data-accent=orange] { --brand: #f29a4a; --brand-text: #2b1403; --tint: #40291a; }
[data-mode=dark][data-accent=violet] { --brand: #a898fa; --brand-text: #150f36; --tint: #2a2550; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#app { min-height: 100%; display: flex; flex-direction: column; }
.boot { margin: auto; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ico { width: 22px; height: 22px; flex: none; }

/* En-tête */
header.top { background: var(--head); color: var(--head-text); padding: calc(env(safe-area-inset-top) + 8px) 8px 10px 16px;
  display: flex; align-items: center; gap: 2px; position: sticky; top: 0; z-index: 5; min-height: 60px; }
header.top .tt { flex: 1; min-width: 0; padding-right: 6px; }
header.top h1 { font-size: 20px; line-height: 1.2; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
header.top small { display: block; font-size: 13px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbtn { background: none; border: 0; color: var(--head-text); width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.hbtn:active { background: rgba(255, 255, 255, .16); }
header.top .hbtn:first-child { margin-left: -12px; }
.banner { background: var(--warn); color: #2a1c00; padding: 8px 14px; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.banner .ico { width: 18px; height: 18px; }

/* Contenu */
main { flex: 1; padding: 14px 14px calc(160px + env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
.list, .card, .hero { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
[data-mode=dark] .list, [data-mode=dark] .card, [data-mode=dark] .hero { border: 1px solid var(--line); }
.list { overflow: hidden; }
.row { background: none; border: 0; border-top: 1px solid var(--line); padding: 10px 12px 10px 14px; display: flex; align-items: center; gap: 12px;
  text-align: left; width: 100%; min-height: 60px; }
.row:first-child { border-top: 0; }
button.row:active, .row .plain:active { background: var(--field); }
.grow { flex: 1; min-width: 0; }
.row b, .hero b { display: block; overflow-wrap: anywhere; font-weight: 600; }
.row small, .hero small, .muted { color: var(--muted); font-size: 13.5px; display: block; }
.row small.note { color: var(--text); opacity: .85; margin-top: 2px; }
.row small b, .hero small b { display: inline; color: var(--text); font-size: inherit; }
.row.red, .row.red .ico { color: var(--danger); }
.chev { color: var(--muted); opacity: .7; width: 18px; height: 18px; }
.card { padding: 14px; }
.hero { display: flex; align-items: center; gap: 14px; padding: 14px; margin-bottom: 12px; }
.hero b { font-size: 18px; }
h2.sec { font-size: 14px; font-weight: 600; color: var(--muted); margin: 20px 6px 8px; }
main > h2.sec:first-child, #listzone > h2.sec:first-child { margin-top: 4px; }
.loading { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty .ico { width: 44px; height: 44px; stroke-width: 1.4; opacity: .55; margin-bottom: 6px; }
.empty b { color: var(--text); font-size: 17px; }
.empty span { max-width: 30ch; }

/* Pastilles et photos des modèles */
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--tint); color: var(--brand); display: grid; place-items: center; flex: none; }
.avatar.pdf { background: #fde8e6; color: #c0392b; }
[data-mode=dark] .avatar.pdf { background: #432220; color: #ff9c92; }
.avatar.me { width: 52px; height: 52px; border-radius: 50%; background: var(--brand); color: var(--brand-text); font-weight: 700; font-size: 19px; }
.mimg { width: 34px; height: 34px; border-radius: 9px; background: #fff; border: 1px solid var(--line); overflow: hidden; flex: none; display: inline-block; }
.mimg.big { width: 56px; height: 56px; border-radius: 14px; }
.hero .mimg.big { width: 68px; height: 68px; }
.mimg img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Historique */
.day { width: 44px; flex: none; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.15; }
.day b { font-size: 20px; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.qty { color: var(--brand); font-weight: 700; white-space: nowrap; }
.mlink { display: inline-flex; align-items: center; gap: 2px; border: 0; background: var(--tint); color: var(--brand); border-radius: 7px; padding: 3px 4px 3px 8px; margin: 3px 0 1px; font: inherit; font-size: 13.5px; font-weight: 700; min-height: 30px; }
.mlink .ico { width: 16px; height: 16px; }
.iconbtn { background: none; border: 0; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); flex: none; margin-right: -6px; }
.iconbtn:active { background: var(--field); }
.iconbtn .ico { width: 20px; height: 20px; }

/* Références */
.plain { background: none; border: 0; padding: 4px 0; text-align: left; flex: 1; min-width: 0; color: inherit; text-decoration: none; border-radius: 8px; }
.plain.line { display: flex; align-items: center; gap: 12px; }
.ref { display: inline-block; margin: 3px 0 1px; background: var(--tint); color: var(--brand); border-radius: 7px; padding: 2px 8px; font-size: 14px; font-weight: 700;
  letter-spacing: .02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
[data-mode=dark] .ref { color: var(--text); }

/* Onglets internes */
.seg { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin: 0 0 12px; }
.seg.in { margin: 0; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; min-height: 40px; color: var(--muted); font-weight: 600; font-size: 15px; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(21, 35, 45, .16); }
.seg i { font-style: normal; font-size: 12px; font-weight: 700; background: var(--tint); color: var(--brand); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
[data-mode=dark] .seg i { color: var(--text); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.swatches button { border: 2px solid transparent; background: var(--field); border-radius: 12px; padding: 10px 2px 8px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.swatches button.on { border-color: var(--brand); font-weight: 700; }
.swatches span { width: 26px; height: 26px; border-radius: 50%; }
.sw-bleu span { background: #0e7dba; } .sw-vert span { background: #17805c; } .sw-orange span { background: #d9690f; } .sw-violet span { background: #5b46b8; }

/* Recherche */
.searchbox { position: relative; margin-bottom: 12px; }
.searchbox .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.searchbox input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px 11px 40px; -webkit-appearance: none; appearance: none; }
.searchbox input:focus { border-color: var(--brand); outline: 0; }

/* Boutons */
button.primary { background: var(--brand); color: var(--brand-text); border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; min-height: 46px; }
button.danger { background: var(--danger); color: #fff; border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; min-height: 46px; }
[data-mode=dark] button.danger { color: #2b0509; }
button.ghost { background: none; border: 0; padding: 12px 16px; color: var(--muted); font-weight: 600; min-height: 46px; border-radius: 12px; }
button:disabled { opacity: .5; }
.fab { position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 6; background: var(--brand); color: var(--brand-text);
  border: 0; border-radius: 18px; padding: 15px 20px; font-weight: 700; font-size: 16px; box-shadow: 0 6px 18px rgba(11, 60, 90, .32); }
.fab:active { transform: scale(.97); }
.chip { background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; white-space: nowrap; font-size: 14px; }
.linkdanger { background: none; border: 0; color: var(--danger); padding: 12px 0 0; margin-top: 8px; display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; }
.linkdanger .ico { width: 19px; height: 19px; }

/* Barre du bas */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding: 4px 0 env(safe-area-inset-bottom); z-index: 7; }
nav.tabs button { flex: 1; background: none; border: 0; padding: 4px 4px 6px; color: var(--muted); font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav.tabs button span { width: 60px; height: 30px; border-radius: 999px; display: grid; place-items: center; }
nav.tabs button.on { color: var(--text); }
nav.tabs button.on span { background: var(--tint); color: var(--brand); }

/* Fenêtres */
.overlay { position: fixed; inset: 0; background: rgba(8, 16, 22, .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; animation: rise .2s ease-out; }
.grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 6px; font-size: 19px; overflow-wrap: anywhere; }
.sheet label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.sheet input[type=text], .sheet input[type=number], .sheet input[type=date], .sheet input[type=file], .sheet select, .sheet textarea, .login input {
  width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 12px; padding: 12px; min-height: 46px; }
.sheet input:focus, .sheet select:focus, .sheet textarea:focus, .login input:focus { border-color: var(--brand); outline: 0; }
.sheet textarea { min-height: 70px; resize: vertical; }
.stepper { display: flex; gap: 8px; align-items: stretch; }
.stepper button { width: 54px; flex: none; border: 1px solid var(--line); background: var(--field); border-radius: 12px; font-size: 24px; line-height: 1; color: var(--brand); font-weight: 600; }
.stepper input[type=number] { text-align: center; font-weight: 700; font-size: 18px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.daterow { display: flex; gap: 8px; align-items: center; }
.daterow input { flex: 1; min-width: 0; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet label.pick { margin: 0; position: relative; color: var(--text); }
.pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; }
.pick > span { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.pick input:checked + span { border-color: var(--brand); background: var(--tint); }
.pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.sheet .btns { display: flex; gap: 8px; margin-top: 20px; }
.sheet .btns .primary, .sheet .btns .danger { flex: 1; }
.menu { display: flex; flex-direction: column; margin: 6px -6px 0; }
.menu button { display: flex; align-items: center; gap: 14px; background: none; border: 0; padding: 14px 8px; min-height: 52px; text-align: left; font-weight: 600; border-radius: 12px; }
.menu button:active { background: var(--field); }
.menu button.red { color: var(--danger); }
.err { color: var(--danger); font-size: 14px; margin-top: 12px; font-weight: 600; }

/* Connexion */
.login { margin: auto; width: 100%; max-width: 380px; padding: 24px 22px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto; box-shadow: var(--shadow); background: #fff; }
.login h1 { margin: 8px 0 0; letter-spacing: -.01em; }
.login p { margin: 0 0 6px; }
.login input { text-align: left; background: var(--card); }
.login button.primary { width: 100%; }
.pwbox { position: relative; }
.pwbox input { width: 100%; padding-right: 46px; }
.pwtoggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted, #667); display: flex; align-items: center; justify-content: center; border-radius: 10px; cursor: pointer; }
.pwtoggle .ico { width: 22px; height: 22px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + env(safe-area-inset-bottom)); background: #15232d; color: #fff;
  padding: 11px 16px; border-radius: 14px; z-index: 30; width: max-content; max-width: 88%; font-size: 14.5px; text-align: center; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
[data-mode=dark] #toast { background: #e6edf2; color: #15232d; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .overlay, .sheet { animation: none; } .fab:active { transform: none; } }

/* ── 2.4 : photos, filtres de l'historique, guides gardés, file d'attente */
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumb { width: 58px; height: 58px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--field); flex: none; object-fit: cover; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.plate { width: 64px; height: 64px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; }
.chips .chip { color: var(--text); min-height: 36px; }
.chip.on { background: var(--tint); border-color: var(--brand); color: var(--brand); font-weight: 600; }
[data-mode=dark] .chip.on { color: var(--text); }
.count { color: var(--muted); font-size: 13.5px; margin: 0 4px 6px; }
.hint { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; margin: 0 4px 10px; }
.hint .ico { width: 18px; height: 18px; flex: none; }
.row small.pend, .hero small.pend { display: flex; align-items: center; gap: 5px; color: var(--brand); margin-top: 3px; }
.pend .ico { width: 15px; height: 15px; }
.row small.keptnote { color: var(--brand); }
.iconbtn.kept, .iconbtn.kept .ico { color: var(--brand); }
.plain.off { opacity: .55; }
.banner.soft { background: var(--tint); color: var(--text); }
.overlay.viewer { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; background: rgba(0, 0, 0, .9); }
.overlay.viewer img { max-width: 100%; max-height: calc(100% - 70px); border-radius: 8px; object-fit: contain; }
.overlay.viewer button { color: #fff; border-color: rgba(255, 255, 255, .5); background: none; }

/* Réparations en attente : pastille du nombre sur l'onglet, bouton « Fait » */
nav.tabs button span { position: relative; }
nav.tabs button span i { position: absolute; top: -2px; right: 8px; font-style: normal; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--brand); color: #fff; display: grid; place-items: center; line-height: 1; }
.iconbtn.ok { width: 34px; height: 34px; margin-right: 0; border-radius: 10px; color: #fff; background: linear-gradient(#4fa616, #3d850d); box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.iconbtn.ok:active { background: #33720a; }
.sheet .btns .sqbtn { flex: none; width: 36px; height: 36px; border: 0; border-radius: 7px; color: #fff; display: grid; place-items: center; padding: 0; box-shadow: 0 2px 5px rgba(0,0,0,.3); }
.sheet .btns .sqbtn.yes { background: linear-gradient(#4fa616, #3d850d); margin-left: auto; }
.sheet .btns .sqbtn.no { background: linear-gradient(#e53935, #b71c1c); }
.sheet .btns .sqbtn .ico { width: 20px; height: 20px; stroke-width: 3; pointer-events: none; }
.overlay.center { align-items: center; padding: 20px; }
.sheet.alert { border-radius: 18px; max-width: 360px; padding: 18px; }
.sheet.alert p { margin: 6px 0 0; }
.iconbtn.ok .ico { width: 20px; height: 20px; stroke-width: 2.6; }

/* QR code de dépannage : aperçu dans la fiche, impression de l'étiquette seule */
.qrlabel svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.qrbtns { display: flex; gap: 10px; flex-wrap: wrap; }
.qrbtns button { flex: 1 1 140px; }
#printzone { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body > * { display: none !important; }
  body > #printzone { display: block !important; }
  #printzone svg { width: 95mm; height: 66mm; }
}
