:root {
  --fond: #f4f5f7; --carte: #fff; --texte: #16191d; --discret: #5b6470; --trait: #dfe3e8;
  --accent: #b4560f; --accent-clair: #fbeee2; --sur-accent: #fff;
  --alerte: #b42318; --alerte-fond: #fdf1ef; --ok: #14532d; --attente: #92400e; --attente-fond: #fef3c7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #111418; --carte: #1b2026; --texte: #eceff3; --discret: #9aa4b1; --trait: #2f3640;
    --accent: #f0883e; --accent-clair: #2e2218; --sur-accent: #1a1206;
    --alerte: #f97066; --alerte-fond: #2b1715; --ok: #4ade80; --attente: #fcd34d; --attente-fond: #33290f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
h1, h2 { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.entete { position: sticky; top: 0; z-index: 5; background: var(--carte); border-bottom: 1px solid var(--trait); padding-top: env(safe-area-inset-top); }
.titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 6px; }
.titre h1 { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.pastille { flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--accent-clair); color: var(--accent); }
.pastille.hors { background: var(--attente-fond); color: var(--attente); }
.onglets { display: flex; padding: 0 8px; }
.onglets button { flex: 1; background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 8px; font-weight: 600; color: var(--discret); cursor: pointer; }
.onglets button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.compteur { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--attente-fond); color: var(--attente); font-size: 12px; }

main { max-width: 720px; margin: 0 auto; padding: 12px 12px 0; }
.section, .bloc { background: var(--carte); border: 1px solid var(--trait); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.bloc { padding: 14px 16px; }
.bloc h2 { font-size: 16px; margin-bottom: 8px; }
.section > h2 { font-size: 16px; }
.section > h2 button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: var(--accent-clair);
  border: 0; font-weight: 700; text-align: left; cursor: pointer; }
.section > h2 .etat { font-size: 12px; font-weight: 600; color: var(--discret); white-space: nowrap; }
.section > h2 .etat.manque { color: var(--alerte); }
.section > h2 button::after { content: "−"; font-size: 20px; line-height: 1; color: var(--discret); }
.section.repliee > h2 button::after { content: "+"; }
.section.repliee .corps { display: none; }
.corps { padding: 4px 16px 12px; }

.champ { display: block; padding: 12px 0; border-bottom: 1px solid var(--trait); }
.champ:last-child { border-bottom: 0; }
.libelle { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.requis .libelle::after { content: " *"; color: var(--alerte); }
.champ.manque { background: var(--alerte-fond); margin: 0 -16px; padding-left: 16px; padding-right: 16px; box-shadow: inset 3px 0 0 var(--alerte); }
input[type="text"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="password"], textarea, select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--fond); }
textarea { min-height: 110px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info { color: var(--discret); font-size: 14px; white-space: pre-line; margin: 0; }
.aide { color: var(--discret); font-size: 14px; margin: 0 0 10px; }

.interrupteur { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.interrupteur .libelle { margin: 0; }
.interrupteur input { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 30px; border-radius: 99px; background: var(--trait); position: relative; cursor: pointer; transition: background .15s; }
.interrupteur input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.interrupteur input:checked { background: var(--accent); }
.interrupteur input:checked::after { transform: translateX(22px); }

.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.options label { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--fond); cursor: pointer; }
.options input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.options label:has(input:checked) { border-color: var(--accent); background: var(--accent-clair); font-weight: 600; }

.medias { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.vignette { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--trait); background: var(--fond); }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.retirer { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.document { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--fond); margin-bottom: 8px; }
.document span { overflow-wrap: anywhere; font-size: 14px; }
.document .retirer { position: static; flex: none; }
.boutons { display: flex; gap: 8px; }
.boutons button, .secondaire, .principal { min-height: 46px; padding: 10px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.boutons button, .secondaire { flex: 1; background: var(--carte); border: 1px solid var(--trait); color: var(--accent); }
.principal { flex: 2; background: var(--accent); border: 1px solid var(--accent); color: var(--sur-accent); }
button:disabled { opacity: .5; cursor: default; }

.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--carte); border-top: 1px solid var(--trait); }
.actions > * { max-width: 360px; }
.actions { justify-content: center; }

.liste { list-style: none; margin: 0 0 12px; padding: 0; }
.liste li { padding: 10px 0; border-bottom: 1px solid var(--trait); font-size: 14px; }
.liste li:last-child { border-bottom: 0; }
.liste strong { display: block; font-size: 15px; overflow-wrap: anywhere; }
.liste .vide { color: var(--discret); }
.liste .erreur { color: var(--alerte); }
.liste a { color: var(--accent); font-weight: 600; }

.message { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 10; max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 10px;
  background: var(--texte); color: var(--fond); font-weight: 600; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.message.erreur { background: var(--alerte); color: #fff; }

.localiser { width: 100%; margin-top: 8px; }
.document small { display: block; color: var(--discret); margin-top: 2px; }
.controle-image { display: block; width: 100%; max-height: 420px; object-fit: contain; border: 1px solid var(--trait); border-radius: 8px; background: var(--fond); }
.controle-ref { margin: 10px 0; font-size: 17px; }
.controle-ref strong { font-size: 20px; letter-spacing: .02em; }
.controle-coche { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--fond); cursor: pointer; font-weight: 600; }
.controle-coche input { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.alerte { color: var(--alerte); font-weight: 600; margin: 8px 0 0; }
.bandeau { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 12px; border-radius: 12px; background: var(--attente-fond); color: var(--attente); font-weight: 600; }
.bandeau span { flex: 1 1 200px; overflow-wrap: anywhere; }
.bandeau button { flex: 0 0 auto; min-height: 40px; }
#recherche { margin-bottom: 4px; }
.liste .ligne-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.liste .ligne-actions > * { flex: 0 0 auto; min-height: 40px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--trait); background: var(--carte); color: var(--accent); font-weight: 600; text-decoration: none; cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; }
.ajout { display: flex; gap: 8px; }
.ajout input { flex: 1; }
.ajout button { flex: 0 0 auto; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; letter-spacing: .08em; user-select: all; }
.titre h1 { display: flex; flex-direction: column; }
.appli { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .04em; text-transform: uppercase; }
/* Page de connexion : photo de l'armoire en haut, carte blanche par-dessus, fond bleu nuit en bas */
.connexion { display: none; min-height: 100dvh; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(20,27,43,0) 0, rgba(20,27,43,0) 28vh, #1b2336 46vh, #0d1a33 100%), url(images/fond-connexion.jpg) 32% top / auto 50vh no-repeat, #0d1a33; }
@media (min-aspect-ratio: 1/1) { .connexion { background: linear-gradient(to bottom, rgba(20,27,43,.15), #0d1a33 92%), url(images/fond-connexion.jpg) center / cover no-repeat, #0d1a33; } }
.carte-connexion { width: 100%; max-width: 420px; margin-top: 16vh; display: flex; flex-direction: column; align-items: center; padding: 40px 28px 28px; text-align: center;
  background: #fff; color: #0f1b33; border-radius: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.carte-connexion h1 { font-size: clamp(28px, 8vw, 36px); font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.carte-connexion .accroche { margin: 8px 0 28px; font-size: 18px; color: #0f1b33; }
.bouton-connexion { width: 100%; min-height: 56px; border: 0; border-radius: 99px; background: linear-gradient(180deg, #cc6a1f, #b9570f); color: #fff; font-size: 19px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px; }
.bouton-connexion span { font-size: 22px; line-height: 1; }
.bouton-connexion:focus-visible { outline: 3px solid #0f1b33; outline-offset: 3px; }
.carte-connexion form { width: 100%; text-align: left; }
.carte-connexion form .champ { border: 0; padding-top: 0; }
.carte-connexion form .libelle { color: #0f1b33; }
.carte-connexion form input { background: #f4f5f7; color: #0f1b33; border-color: #cfd5de; }
.carte-connexion form .alerte { color: #b42318; margin: 0 0 12px; }
.carte-connexion .logo { margin-top: 32px; height: auto; max-width: 200px; }
.carte-connexion .version { margin: 6px 0 0; color: #5b6470; font-size: 15px; }
.signature { margin: 0; color: #fff; font-size: 13px; letter-spacing: .32em; text-transform: uppercase; }
body.non-connecte { padding-bottom: 0; }
body.non-connecte .connexion { display: flex; }
body.non-connecte .entete, body.non-connecte main, body.non-connecte .actions { display: none !important; }
