/* Stock Lodimar — feuille de style
   Palette : béton (fond), papier, encre, ruban adhésif jaune (N° colis), marqueur bleu (liens), rouge contrôle */
:root {
  --beton: #E3E6E4;
  --papier: #FFFFFF;
  --encre: #1D2428;
  --gris: #5B666C;
  --trait: #CBD1CE;
  --ruban: #F3C318;
  --ruban-fonce: #C99E00;
  --marqueur: #1E4F8F;
  --alerte: #B3372B;
  --vert: #2F7A4D;
  --etroit: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --texte: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 4px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--beton); color: var(--encre); font: 400 1rem/1.5 var(--texte); }
a { color: var(--marqueur); text-underline-offset: 2px; }
a:hover { color: var(--encre); }
:focus-visible { outline: 3px solid var(--marqueur); outline-offset: 2px; }
h1, h2 { font-family: var(--etroit); font-weight: 700; line-height: 1.1; margin: 0 0 .6rem; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.discret { color: var(--gris); }
.inline { display: inline; margin: 0; }
[hidden] { display: none !important; }

/* ---------- En-tête ---------- */
.barre { background: var(--encre); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .7rem clamp(1rem, 3vw, 2rem); }
.marque { font: 700 1.6rem/1 var(--etroit); color: #fff; text-decoration: none; padding: .15rem .6rem; border: 2px solid var(--ruban); }
.nav, .nav-admin { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; }
.nav-admin { margin-left: auto; }
.barre a:not(.btn), .barre .lien { color: #D5DBD8; text-decoration: none; font-weight: 500; }
.barre a:not(.btn):hover, .barre .lien:hover { color: #fff; }
.barre a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--ruban); padding-bottom: 2px; }
.lien { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: .45rem 1rem; border-radius: var(--r); border: 2px solid transparent; font: 600 .95rem/1 var(--texte); text-decoration: none; cursor: pointer; }
.btn-encre { background: var(--encre); color: #fff; }
.btn-encre:hover { background: #33404A; color: #fff; }
.btn-ruban { background: var(--ruban); color: var(--encre); }
.btn-ruban:hover { background: #FFD43D; color: var(--encre); }
.btn-contour { background: transparent; border-color: currentColor; color: inherit; }
.barre .btn-contour { color: #fff; }
.btn-danger { background: var(--alerte); color: #fff; }
.btn-petit { min-height: 32px; padding: .25rem .7rem; border-radius: var(--r); border: 1px solid var(--encre); background: var(--papier); color: var(--encre); font: 600 .85rem/1 var(--texte); cursor: pointer; }
.btn-petit:hover { background: var(--encre); color: #fff; }
.btn-danger-texte { border-color: var(--alerte); color: var(--alerte); }

/* ---------- Page ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 1.25rem clamp(.75rem, 3vw, 2rem) 4rem; }
.msg { padding: .7rem 1rem; border-radius: var(--r); margin: 0 0 1rem; border-left: 5px solid var(--vert); background: var(--papier); }
.msg p { margin: .2rem 0; }
.msg-alerte { border-left-color: var(--alerte); }
.fil { margin: 0 0 .75rem; color: var(--gris); }
.intro { max-width: 70ch; }
.aide { font-size: .88rem; color: var(--gris); margin: .3rem 0 0; }

/* ---------- Ruban (N° colis) : l'élément signature ---------- */
.ruban {
  display: inline-block; background: var(--ruban); color: var(--encre);
  font: 600 1rem/1 var(--etroit); letter-spacing: .03em; padding: .28rem .6rem .24rem; margin: 0 .25rem .3rem 0;
  clip-path: polygon(3px 0, calc(100% - 3px) 0, 100% 22%, calc(100% - 2px) 50%, 100% 78%, calc(100% - 3px) 100%, 3px 100%, 0 78%, 2px 50%, 0 22%);
}
.ruban-trouve { background: var(--encre); color: var(--ruban); }
.rubans { display: flex; flex-wrap: wrap; }

/* ---------- Recherche ---------- */
.recherche { display: grid; grid-template-columns: minmax(220px, 2.2fr) minmax(120px, .8fr) minmax(160px, 1.2fr) auto; gap: .75rem; align-items: end; background: var(--papier); padding: 1rem; border-radius: var(--r); border: 1px solid var(--trait); }
.champ label, .champ legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--papier); border: 1px solid #9AA4A0; border-radius: var(--r); padding: .5rem .65rem; min-height: 42px;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--marqueur); outline: 2px solid color-mix(in srgb, var(--marqueur) 30%, transparent); }
.champ-q input { font-size: 1.05rem; }
.champ-actions { display: flex; gap: .5rem; }

.resume { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem 1.5rem; margin: 1.1rem 0 .6rem; }
.resume p { margin: 0; }
.resume-chiffres { font-size: 1.05rem; }
.resume-chiffres strong { font: 700 1.5rem/1 var(--etroit); }
.resume-tri { font-size: .9rem; color: var(--gris); display: flex; flex-wrap: wrap; gap: .2rem .8rem; align-items: baseline; }
.resume-tri a[aria-current] { color: var(--encre); font-weight: 600; text-decoration: none; box-shadow: inset 0 -2px 0 var(--ruban); }
.resume-tri .export { margin-left: .6rem; }
.pastille { display: inline-flex; gap: .4rem; align-items: center; background: var(--encre); color: #fff; border-radius: 99px; padding: .1rem .7rem; font-size: .85rem; margin-left: .5rem; }
.pastille a { color: var(--ruban); text-decoration: none; font-weight: 700; }
.vide { background: var(--papier); padding: 2rem; border-radius: var(--r); border: 1px dashed #9AA4A0; }

/* ---------- Liste ---------- */
.liste { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r); }
.ligne { display: grid; grid-template-columns: 76px minmax(170px, 1.35fr) 52px minmax(120px, .9fr) minmax(120px, .9fr) minmax(200px, 1.5fr) 72px; gap: .9rem; padding: .7rem 1rem; border-top: 1px solid var(--trait); align-items: start; }
.ligne:first-child { border-top: 0; }
.ligne:target { background: #FFF8DC; }
.ligne-titre { font-size: .82rem; font-weight: 600; color: var(--gris); padding-top: .55rem; padding-bottom: .55rem; background: #F4F6F5; }
.c-qte { font: 700 1.5rem/1 var(--etroit); text-align: center; padding-top: .2rem; }
.ligne-titre .c-qte { font: inherit; }
.c-type a { color: var(--encre); text-decoration: none; border-bottom: 1px dotted var(--gris); }
.c-article a { font-weight: 600; }
.c-actions { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
.lib-mobile { display: none; }
.vignette { position: relative; display: block; width: 72px; height: 72px; padding: 0; border: 0; border-radius: var(--r); overflow: hidden; background: var(--beton); cursor: zoom-in; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette .nb { position: absolute; right: 3px; bottom: 3px; background: var(--encre); color: #fff; font: 600 .75rem/1 var(--texte); padding: 2px 5px; border-radius: 3px; }
.sans-photo { display: grid; place-items: center; width: 72px; height: 72px; border: 1px dashed #A9B2AE; border-radius: var(--r); font-size: .72rem; color: var(--gris); text-align: center; line-height: 1.15; }

/* Remarques */
.remarque textarea { min-height: 42px; font-size: .92rem; }
.remarque-pied { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-height: 1.4rem; margin-top: .2rem; }
.etat { font-size: .78rem; color: var(--gris); }
.etat.ok { color: var(--vert); }
.etat.erreur { color: var(--alerte); }
.remarque.modifiee textarea { border-color: var(--ruban-fonce); background: #FFFCEF; }
.remarque-texte { margin: 0; font-size: .92rem; }

/* ---------- Fiche ---------- */
.fiche { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r); padding: clamp(1rem, 3vw, 2rem); }
.fiche-tete { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--trait); }
.fiche-tete > div { flex: 1 1 260px; }
.fiche-tete h1 { font-size: 2.4rem; margin: 0; }
.fiche-type { margin: .2rem 0 0; }
.fiche-qte { margin: 0; font-family: var(--etroit); font-size: 1.2rem; }
.fiche-qte strong { font-size: 2.6rem; }
.fiche-bloc { padding: 1.2rem 0 .4rem; border-bottom: 1px solid var(--trait); }
.fiche-bloc:last-child { border-bottom: 0; }
.fiche-ref { font-size: .9rem; color: var(--gris); margin: 0 0 .5rem; }
.galerie { display: flex; flex-wrap: wrap; gap: .75rem; }
.vignette.grande { width: 220px; height: 220px; }
.historique { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.historique li { padding: .4rem 0; border-top: 1px solid #E4E8E6; }
.historique li:first-child { border-top: 0; }
.historique time { display: inline-block; min-width: 9.5rem; color: var(--gris); font-size: .85rem; }

/* ---------- Formulaires ---------- */
.formulaire { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r); padding: clamp(1rem, 3vw, 1.75rem); max-width: 760px; }
.formulaire .champ { margin-bottom: 1.2rem; }
.formulaire fieldset { border: 0; padding: 0; margin: 0 0 1.2rem; }
#nouveau_type { margin-top: .5rem; }
.apercu-qte { display: inline-block; margin-left: .4rem; font-weight: 600; color: var(--encre); }
.apercu-qte.erreur { color: var(--alerte); }
.photos-edit, .apercu-photos { display: flex; flex-wrap: wrap; gap: .75rem; margin: .4rem 0 .8rem; }
.photo-edit { width: 132px; font-size: .85rem; }
.photo-edit img, .apercu-photos img { width: 132px; height: 132px; object-fit: cover; border-radius: var(--r); display: block; margin-bottom: .3rem; border: 1px solid var(--trait); }
.champ .photo-edit label, .champ label.aide { font-weight: 400; }
.photo-edit label { display: flex; gap: .35rem; align-items: center; cursor: pointer; }
.photo-edit .retirer { color: var(--alerte); }
.photo-edit:has(.retirer input:checked) img { opacity: .3; }
.actions-form { display: flex; gap: .6rem; flex-wrap: wrap; }
.zone-suppression { max-width: 760px; margin-top: 2rem; padding: 1rem 1.25rem; border: 1px solid #E2B6B0; border-radius: var(--r); background: #FBF1EF; }
.zone-suppression p { margin: 0 0 .7rem; }
.connexion { max-width: 460px; margin: 2rem auto; }
.connexion .formulaire { max-width: none; }

/* ---------- Types ---------- */
.ajout-type { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; background: var(--papier); padding: 1rem; border: 1px solid var(--trait); border-radius: var(--r); margin: 1rem 0; max-width: 760px; }
.ajout-type label { font-weight: 600; }
.ajout-type input { flex: 1 1 220px; width: auto; }
.types { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r); }
.type-ligne { display: grid; grid-template-columns: minmax(280px, 1.6fr) 150px minmax(220px, 1fr); gap: .75rem; align-items: center; padding: .65rem 1rem; border-top: 1px solid var(--trait); }
.type-ligne:first-child { border-top: 0; }
.type-renommer, .type-fusion { display: flex; gap: .5rem; align-items: center; }
.type-renommer input[type=text] { flex: 1; }
.coche { display: flex; gap: .3rem; align-items: center; font-size: .82rem; color: var(--gris); white-space: nowrap; }
.type-compte { font-size: .9rem; }

/* ---------- Tableau de bord ---------- */
.tb-tete { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; margin: .5rem 0 1.5rem; }
.tb-phrase { font-size: clamp(1.6rem, 3.5vw, 2.6rem); font-weight: 600; max-width: 32ch; margin: 0; }
.tb-phrase .gros { display: inline-block; font-size: 1.9em; font-weight: 700; background: var(--ruban); padding: 0 .2em; margin-right: .1em;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 20%, calc(100% - 3px) 50%, 100% 80%, calc(100% - 4px) 100%, 4px 100%, 0 80%, 3px 50%, 0 20%); }
.tb-chiffres { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0; }
.tb-chiffres dt { font-size: .85rem; color: var(--gris); }
.tb-chiffres dd { margin: 0; font: 700 1.5rem/1.2 var(--etroit); }
.tb-chiffres dd a { font: 500 .9rem var(--texte); margin-left: .4rem; }
.alerte { color: var(--alerte); }
.ok { color: var(--vert); }
.tb-grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.tb-bloc { background: var(--papier); border: 1px solid var(--trait); border-radius: var(--r); padding: 1.1rem 1.25rem; }
.tb-types, .tb-plan { grid-row: span 2; }
.barres { list-style: none; margin: 0; padding: 0; }
.barres a { display: grid; grid-template-columns: minmax(110px, 11rem) 1fr 2.5rem; gap: .6rem; align-items: center; padding: .28rem 0; text-decoration: none; color: var(--encre); }
.barres a:hover .barre-nom { color: var(--marqueur); text-decoration: underline; }
.barre-nom { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-piste { height: 14px; background: #EEF1EF; }
.barre-plein { display: block; height: 100%; background: var(--ruban); border-right: 2px solid var(--ruban-fonce); }
.barre-val { font: 700 1.1rem/1 var(--etroit); text-align: right; }
.plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 3px; margin-top: .6rem; }
.case { display: grid; place-items: center; aspect-ratio: 1; font: 600 .72rem/1 var(--etroit); background: var(--ruban); color: var(--encre); text-decoration: none; }
a.case:hover, a.case:focus-visible { background: var(--encre); color: var(--ruban); }
.case-manque { background: transparent; color: var(--alerte); outline: 1px dashed var(--alerte); outline-offset: -1px; }
.plan-info { min-height: 1.5rem; margin: .5rem 0 0; font-weight: 600; }
.liste-simple { list-style: none; margin: 0; padding: 0; }
.liste-simple li { padding: .5rem 0; border-top: 1px solid #E4E8E6; }
.liste-simple li:first-child { border-top: 0; }
.liste-simple p { margin: .2rem 0; font-size: .92rem; }
.liste-simple time { font-size: .8rem; color: var(--gris); }
.tb-histo { grid-column: 1 / -1; }

/* ---------- Visionneuse ---------- */
.visionneuse { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1100px); max-height: 96vh; }
.visionneuse::backdrop { background: rgba(20, 26, 29, .88); }
.visionneuse figure { margin: 0; text-align: center; }
.visionneuse img { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; border-radius: var(--r); }
.visionneuse figcaption { color: #fff; margin-top: .6rem; }
.visionneuse .fermer { position: fixed; top: 12px; right: 16px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--papier); font-size: 1.6rem; cursor: pointer; }
.vis-nav { display: flex; justify-content: center; align-items: center; gap: 1rem; color: #fff; margin-top: .5rem; }
.vis-nav button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ruban); font-size: 1.6rem; line-height: 1; cursor: pointer; }

/* ---------- Petits écrans ---------- */
@media (max-width: 1000px) {
  .recherche { grid-template-columns: 1fr 1fr; }
  .champ-q, .champ-actions { grid-column: 1 / -1; }
  .tb-grille { grid-template-columns: 1fr; }
  .tb-types, .tb-plan { grid-row: auto; }
  .type-ligne { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .nav-admin { margin-left: 0; width: 100%; }
  .ligne-titre { display: none; }
  .ligne { grid-template-columns: 76px 1fr auto; grid-template-areas: "photo colis qte" "photo type type" "photo article article" "rem rem rem" "act act act"; gap: .35rem .8rem; }
  .c-photo { grid-area: photo; } .c-colis { grid-area: colis; } .c-qte { grid-area: qte; }
  .c-type { grid-area: type; } .c-article { grid-area: article; } .c-remarque { grid-area: rem; margin-top: .3rem; }
  .c-actions { grid-area: act; flex-direction: row; gap: 1.2rem; }
  .lib-mobile { display: block; font: 500 .7rem var(--texte); color: var(--gris); }
  .vignette.grande { width: calc(50% - .4rem); height: auto; aspect-ratio: 1; }
}
@media (max-width: 480px) {
  .historique time { display: block; }
  .barres a { grid-template-columns: 7.5rem 1fr 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Impression ---------- */
@media print {
  .barre, .recherche, .resume-tri, .c-actions, .remarque-pied, .zone-suppression { display: none !important; }
  body { background: #fff; }
  .liste, .fiche { border: 0; }
  .remarque textarea { border: 0; resize: none; padding: 0; }
  .ligne { break-inside: avoid; }
}
