/* Feuille de style écrite à la main — pas de Tailwind, pas d'étape de build.
   Aucun style en ligne dans les gabarits : la CSP (style-src 'self') l'interdit. */

:root {
  --fond: #faf7f2;
  --surface: #ffffff;
  --texte: #2b2a27;
  --texte-doux: #6b6860;
  --bordure: #e3ddd2;
  --accent: #4f6f52;
  --accent-fonce: #3b553e;
  --accent-clair: #e8efe6;
  --danger: #a63d2f;
  --danger-clair: #fbeae7;
  --alerte: #8a6d1d;
  --alerte-clair: #fbf3d9;
  --rayon: 10px;
  --ombre: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-fonce); }
a:hover { text-decoration: none; }
h1 { font-size: 1.7rem; margin: 0 0 1rem; line-height: 1.2; }
h2 { font-size: 1.25rem; margin: 1.75rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* --- Structure --- */
.entete { background: var(--surface); border-bottom: 1px solid var(--bordure); }
.entete__contenu, .page {
  max-width: 1080px; margin: 0 auto; padding: 0 1rem;
}
.entete__contenu { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; min-height: 60px; }
.marque { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--accent-fonce); }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--texte); }
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-clair); color: var(--accent-fonce); }
.nav--fin { flex: 0 1 auto; align-items: center; }
.page { padding-top: 1.5rem; padding-bottom: 4rem; }
.etroit { max-width: 460px; margin: 2rem auto; }
.fil { color: var(--texte-doux); font-size: .9rem; margin-bottom: .5rem; }
.titre-ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.titre-ligne h1, .titre-ligne h2 { margin: 0; }
.doux { color: var(--texte-doux); }
.petit { font-size: .875rem; }
.droite { text-align: right; }
.pile > * + * { margin-top: 1rem; }
.ligne { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pousse { margin-left: auto; }

/* --- Cartes et grilles --- */
.carte {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); padding: 1.1rem 1.25rem; box-shadow: var(--ombre);
}
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grille--large { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.tuile { display: flex; flex-direction: column; gap: .5rem; }
.tuile h3 { margin: 0; }
.tuile h3 a { text-decoration: none; }
.tuile__photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--accent-clair); }
.tuile__pied { margin-top: auto; padding-top: .5rem; }
.photo-fiche { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--rayon); }
.chiffre { font-size: 2rem; font-weight: 700; line-height: 1; }

/* --- Étiquettes --- */
.etiquette {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem;
  background: var(--accent-clair); color: var(--accent-fonce); border: 1px solid transparent;
  white-space: nowrap;
}
.etiquette--neutre { background: #efece6; color: var(--texte-doux); }
.etiquette--alerte { background: var(--alerte-clair); color: var(--alerte); }
.etiquette--danger { background: var(--danger-clair); color: var(--danger); }
.etiquettes { display: flex; flex-wrap: wrap; gap: .3rem; }

/* --- Boutons --- */
.bouton, button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; line-height: 1.2;
}
.bouton:hover, button:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.bouton--secondaire { background: var(--surface); color: var(--accent-fonce); border-color: var(--bordure); }
.bouton--secondaire:hover { background: var(--accent-clair); border-color: var(--accent); }
.bouton--danger { background: var(--surface); color: var(--danger); border-color: #e2b9b2; }
.bouton--danger:hover { background: var(--danger-clair); border-color: var(--danger); }
.bouton--petit { padding: .3rem .6rem; font-size: .875rem; }
.bouton--lien { background: none; border: none; color: var(--accent-fonce); padding: .4rem .7rem; font-weight: 400; }
.bouton--lien:hover { background: var(--accent-clair); }
button:disabled, .bouton[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid #9bb89e; outline-offset: 2px; }

/* --- Formulaires --- */
form.formulaire > div, .champ { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="url"], input[type="color"], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  padding: .5rem .65rem; border: 1px solid #cfc8ba; border-radius: 8px;
}
input[type="color"] { padding: .15rem; height: 2.4rem; max-width: 5rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); vertical-align: middle; }
.helptext { display: block; color: var(--texte-doux); font-size: .875rem; margin-top: .2rem; }
ul.errorlist { list-style: none; margin: .25rem 0; padding: 0; color: var(--danger); font-size: .9rem; font-weight: 600; }
.case label, form.formulaire > div:has(> input[type="checkbox"]) label { display: inline; font-weight: 400; margin-right: .4rem; }
.en-ligne { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.en-ligne > * { margin: 0; }
.en-ligne .grandit { flex: 1 1 180px; }
.en-ligne input[type="number"] { width: 6.5rem; }
.portions { width: 5rem !important; }
.cases { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
.case-bouton { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: 0; padding: .3rem .65rem; border: 1px solid var(--bordure); border-radius: 999px; background: var(--surface); cursor: pointer; }
.case-bouton:has(input:checked) { background: var(--accent-clair); border-color: var(--accent); }

/* --- Messages --- */
.message { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.message--success { background: var(--accent-clair); border-color: #bfd3bd; color: var(--accent-fonce); }
.message--error, .message--erreur { background: var(--danger-clair); border-color: #e2b9b2; color: var(--danger); font-weight: 600; }
.message--warning, .message--info { background: var(--alerte-clair); border-color: #ead9a0; color: var(--alerte); }
#erreur-globale { position: sticky; top: .5rem; z-index: 10; }
.bandeau { background: var(--accent-clair); border: 1px solid #bfd3bd; border-radius: var(--rayon); padding: .8rem 1rem; margin-bottom: 1.25rem; }

/* --- Tableaux --- */
.tableau-defilant { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-doux); }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }
tr.inactif td { color: var(--texte-doux); }
.vide { padding: 1.5rem; text-align: center; color: var(--texte-doux); background: var(--surface); border: 1px dashed var(--bordure); border-radius: var(--rayon); }

/* --- Onglets --- */
.onglets { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--bordure); margin: 1rem 0 1.25rem; }
.onglets a { padding: .55rem .9rem; text-decoration: none; color: var(--texte-doux); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.onglets a:hover { color: var(--accent-fonce); }
.onglets a[aria-selected="true"] { color: var(--accent-fonce); border-bottom-color: var(--accent); }

/* --- Listes --- */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: .6rem 0; border-bottom: 1px solid var(--bordure); }
.liste > li:last-child { border-bottom: none; }
ol.etapes { padding-left: 1.25rem; }
ol.etapes li { margin-bottom: .5rem; }
dl.fiche { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.fiche dt { color: var(--texte-doux); }
dl.fiche dd { margin: 0; }

/* --- États de chargement HTMX (remplace les styles qu'HTMX injecterait) --- */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.chargement { align-items: center; gap: .4rem; color: var(--texte-doux); font-size: .9rem; }
.chargement::before {
  content: ""; width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid var(--bordure); border-top-color: var(--accent);
  animation: tourne .7s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
.htmx-request.zone-chargee, .htmx-request .zone-chargee { opacity: .5; transition: opacity .15s; }

.pied { color: var(--texte-doux); font-size: .85rem; text-align: center; padding: 1.5rem 1rem; }

/* --- Impression (liste de courses) --- */
@media print {
  .entete, .pied, .onglets, .non-imprime, button, .bouton, #erreur-globale { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .page { max-width: none; padding: 0; }
  .carte { border: none; box-shadow: none; padding: 0; }
  h2 { break-after: avoid; }
  .saut-page { break-before: page; }
  tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* --- Compte administrateur --- */
.marque__role { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--alerte); background: var(--alerte-clair); padding: .1rem .45rem; border-radius: 999px; vertical-align: middle; margin-left: .3rem; }
.nav a[aria-current="page"] { font-weight: 600; }
.raccourcis { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
