:root {
  --ink: #17212b;
  --muted: #5d6b79;
  --paper: #f3f5f7;
  --surface: #ffffff;
  --line: #d3dae1;
  --steel: #0b4f7c;
  --steel-dark: #07385a;
  --steel-soft: #e3eef6;
  --danger: #a82a1c;
  --ok: #1d6b3c;
  --warn-bg: #fff4d6;
  --warn-line: #e0b000;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; font-size: 16px; }
a { color: var(--steel); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #f0a000; outline-offset: 2px;
}
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* En-tête */
.site-header { background: var(--steel-dark); color: #fff; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-top: 16px; padding-bottom: 12px; }
.brand { color: #fff; text-decoration: none; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; display: flex; flex-direction: column; line-height: 1.15; }
.brand span { font-size: .8rem; font-weight: 400; opacity: .8; letter-spacing: 0; }
.session { display: flex; align-items: center; gap: 10px; }
.who { opacity: .85; margin-right: 8px; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; background: var(--steel); max-width: none; padding: 0; }
.nav a { color: #fff; text-decoration: none; padding: 10px 16px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a[aria-current="page"] { background: var(--paper); color: var(--steel-dark); }
.nav { padding-left: max(20px, calc((100% - 1180px) / 2 + 20px)); }

/* Mise en page */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; padding-top: 28px; padding-bottom: 40px; }
.narrow { max-width: 380px; margin: 40px auto; }
main > section { margin-top: 28px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 14px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.lead { font-size: 1.1rem; max-width: none; }
p { max-width: none; }
.muted { color: var(--muted); }

/* Menu latéral */
.side { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 16px 18px; align-self: start; }
.side h2 { font-size: .95rem; margin-top: 14px; padding-bottom: 6px; border-bottom: 2px solid var(--steel); }
.side h2:first-child { margin-top: 0; }
.side h2 a { color: var(--ink); text-decoration: none; }
.side ul { list-style: none; margin: 0 0 4px; padding: 0; }
.side li a { display: flex; justify-content: space-between; padding: 4px 6px; text-decoration: none; border-radius: 3px; }
.side li a:hover { background: var(--steel-soft); }
.side li a[aria-current="page"] { background: var(--steel); color: #fff; }
.side small { color: var(--muted); font-variant-numeric: tabular-nums; }
.side li a[aria-current="page"] small { color: #cfe3f1; }

/* Liste de matières */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.chips a { display: flex; flex-direction: column; min-width: 110px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--steel); border-radius: 3px; text-decoration: none; font-weight: 600; }
.chips a:hover { background: var(--steel-soft); }
.chips small { font-weight: 400; color: var(--muted); }

/* Tableau de stock */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.stock { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.stock th, .stock td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stock thead th { background: var(--steel-soft); font-size: .88rem; border-bottom: 2px solid var(--steel); }
.stock tbody tr:nth-child(even) { background: #f8fafb; }
.stock tbody tr:hover { background: var(--steel-soft); }
.stock .num { text-align: right; }
.actions { display: flex; gap: 6px; align-items: center; }

/* Pastilles de couleur (liste blanche, sans style inline) */
.sw { display: inline-block; width: .85em; height: .85em; margin-right: .55em; border-radius: 50%; border: 1px solid rgba(0,0,0,.35); vertical-align: -.05em; background: repeating-linear-gradient(45deg, #fff 0 3px, #ddd 3px 6px); }
.sw-naturel { background: #e8dfc4; } .sw-blanc { background: #fff; } .sw-noir { background: #14181c; }
.sw-bleu { background: #1f5fbf; } .sw-vert { background: #2b8a4b; } .sw-rouge { background: #c62d2d; }
.sw-jaune { background: #f0c20a; } .sw-gris { background: #8a949e; } .sw-orange { background: #ee7d14; }
.sw-marron { background: #6e4a2c; } .sw-beige { background: #d9c7a3; }
.sw-transparent, .sw-incolore { background: linear-gradient(135deg, #fff 45%, #cfe6f5 55%); }

/* Boutons et formulaires */
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 8px 16px; border: 1px solid var(--steel); background: var(--steel); color: #fff; border-radius: 3px; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--steel-dark); }
.btn-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.btn-light:hover { background: rgba(255,255,255,.15); }
main .btn-light { color: var(--steel); border-color: var(--steel); }
main .btn-light:hover { background: var(--steel-soft); }
.btn-small { padding: 3px 10px; font-size: .88rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #7f1d12; }
.inline { display: inline; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=file], select { font: inherit; padding: 8px 10px; border: 1px solid #8997a5; border-radius: 3px; background: #fff; color: var(--ink); width: 100%; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 12px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

/* Zone d'administration */
.admin { border-top: 3px solid var(--warn-line); background: var(--warn-bg); padding: 16px 20px 20px; border-radius: 0 0 4px 4px; }
.admin details { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; margin-top: 12px; }
.admin summary { cursor: pointer; font-weight: 600; }
.danger-zone { border-color: var(--danger) !important; }
code { background: var(--steel-soft); padding: 1px 5px; border-radius: 3px; font-size: .88em; }

/* Messages */
.flash { padding: 10px 14px; border-left: 4px solid; border-radius: 3px; background: #fff; margin: 0 0 10px; }
.flash-ok { border-color: var(--ok); }
.flash-error { border-color: var(--danger); }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; padding: 18px 0 30px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .bar { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }



/* Déstockage & tri */
:root { --signal: #c2410c; --signal-soft: #fff1e8; }
.nav a.nav-destock { font-weight: 700; box-shadow: inset 0 -3px 0 #ffb27a; }
.nav a.nav-destock[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--signal); }
.side-destock { display: flex; justify-content: space-between; padding: 8px 10px; margin-bottom: 4px; background: var(--signal); color: #fff; text-decoration: none; font-weight: 700; border-radius: 3px; }
.side-destock:hover { background: #9a3412; }
.side-destock small { color: #ffe3d2; }
.badge-destock { display: inline-block; padding: 1px 9px; background: var(--signal); color: #fff; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.stock tbody tr.row-destock { background: var(--signal-soft); box-shadow: inset 4px 0 0 var(--signal); }
.stock th.sortable a { color: inherit; text-decoration: none; display: block; }
.stock th.sortable a:hover { text-decoration: underline; }
.stock th[aria-sort] { background: #cfe2f0; }
.callout-destock { margin: 22px 0 0; padding: 12px 16px; background: var(--signal-soft); border-left: 4px solid var(--signal); border-radius: 3px; font-weight: 600; }
.callout-destock a { color: var(--signal); }
.span-all { grid-column: 1 / -1; }

#form-produit { scroll-margin-top: 12px; }

/* Pages illustrées : les fichiers imageN.jpg sont des placeholders à remplacer */
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px 0 28px; }
.photo-grid figure { margin: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.photo-grid img { display: block; width: 100%; aspect-ratio: 8 / 5; object-fit: cover; background: #e3e8ed; }
.photo-grid figcaption { padding: 8px 11px; font-size: .9rem; font-weight: 600; }
.home-atelier, .request-panel { margin-top: 26px; padding: 20px; background: var(--steel-soft); border-left: 4px solid var(--steel); border-radius: 4px; }
.request-panel .muted { margin-bottom: 0; }
.tutorial { max-width: 980px; margin: 30px auto 48px; }
.eyebrow { color: var(--steel); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: .82rem; }
.tutorial-index { display: grid; gap: 7px; padding: 18px 22px; margin: 24px 0 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.tutorial-index a { text-decoration: none; }
.tutorial-index a:hover { text-decoration: underline; }
.tutorial-section { padding: 20px 22px; margin: 18px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; scroll-margin-top: 16px; }
.tutorial-section h2 { color: var(--steel-dark); margin-bottom: 12px; }
.tutorial-section h3 { margin: 18px 0 6px; font-size: 1rem; }
.tutorial-section li { margin: 5px 0; }
.csv-example { overflow-x: auto; padding: 12px; background: #eef2f5; border: 1px solid var(--line); border-radius: 3px; }
.warning-note { padding: 12px 14px; background: var(--warn-bg); border-left: 4px solid var(--warn-line); }
.tutorial-back { margin-top: 26px; }
@media (max-width: 800px) {
  .photo-grid { grid-template-columns: 1fr; }
  .photo-grid img { aspect-ratio: 16 / 9; }
  .tutorial-section { padding: 16px; }
}

/* ===== Responsive mobile ===== */
.side-toggle { display: none; }

@media (max-width: 800px) {
  .wrap { padding: 0 14px; }
  .bar { padding-top: 12px; padding-bottom: 10px; }
  .brand { font-size: 1.3rem; }
  .session { gap: 6px; }
  .who { display: none; }

  /* Navigation : une seule ligne défilante au lieu de 3-4 lignes empilées */
  .nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-left: 0; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; padding: 12px 14px; white-space: nowrap; }

  .layout { gap: 14px; padding-top: 16px; padding-bottom: 28px; }
  h1 { font-size: 1.45rem; }

  /* Menu latéral plaques / barres : replié par défaut (si JS actif), bouton pour l'ouvrir */
  .side-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%;
    font: inherit; font-weight: 600; text-align: left; cursor: pointer;
    padding: 12px 14px; color: var(--steel-dark);
    background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--steel); border-radius: 4px;
  }
  .side-toggle::after { content: "▾"; margin-left: auto; transition: transform .15s; }
  .side-toggle.is-open::after { transform: rotate(180deg); }
  .js .side:not(.open) { display: none; }
  .side { max-height: 70vh; overflow-y: auto; }
  .side li a { padding: 10px 8px; }

  .chips a { min-width: 0; }
  .grid-form { grid-template-columns: 1fr; }

  /* Tableaux de stock : une carte par produit, sans défilement horizontal */
  .table-scroll { overflow: visible; background: none; border: 0; }
  .stock-cards, .stock-cards tbody, .stock-cards tr, .stock-cards td { display: block; }
  .stock-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stock-cards tbody tr, .stock-cards tbody tr:nth-child(even) {
    background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
    margin-bottom: 12px; padding: 4px 0;
  }
  .stock-cards tbody tr.row-destock { background: var(--signal-soft); }
  .stock-cards tbody tr:hover { background: var(--surface); }
  .stock-cards tbody tr.row-destock:hover { background: var(--signal-soft); }
  .stock-cards td, .stock-cards .num {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    text-align: right; white-space: normal; padding: 7px 14px; border-bottom: 1px dashed var(--line);
  }
  .stock-cards td:last-child { border-bottom: 0; }
  .stock-cards td::before { content: attr(data-label); flex: 0 0 auto; font-weight: 600; font-size: .85rem; color: var(--muted); text-align: left; }
  .stock-cards td.actions { flex-wrap: wrap; justify-content: flex-end; }
  .stock-cards td.actions::before { margin-right: auto; }
}
