/* Style sobre : gros boutons, champs larges, contrastes nets. */

:root {
  --fond: #f6f4ef;
  --carte: #ffffff;
  --texte: #222;
  --discret: #6b6b6b;
  --bordure: #d6d2c8;
  --accent: #2f6b3a;       /* vert « cuisine » */
  --accent-clair: #e5f0e6;
  --danger: #b3261e;
  --alerte-fond: #fdecea;
  --survol: #f0ede4;
  --rayon: 8px;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  font-family: "Ubuntu", "Segoe UI", system-ui, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.4;
}

main { max-width: 1400px; margin: 0 auto; padding: 1rem 1.25rem 4rem; }

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }

a { color: var(--accent); }

/* ---------- Onglets ---------- */
header { background: var(--accent); position: sticky; top: 0; z-index: 10; }
.onglets { display: flex; flex-wrap: wrap; max-width: 1400px; margin: 0 auto; padding: 0 1rem; }
.onglets a {
  color: #fff; text-decoration: none; padding: .9rem 1.3rem; font-size: 1.1rem; font-weight: 500;
  border-bottom: 4px solid transparent;
}
.onglets a:hover { background: rgba(255, 255, 255, .12); }
.onglets a.actif { border-bottom-color: #fff; background: rgba(255, 255, 255, .18); }

/* ---------- Champs et boutons ---------- */
input, select, textarea, button, .bouton {
  font: inherit; font-size: 1rem;
  border: 1px solid var(--bordure); border-radius: 6px;
  padding: .5rem .65rem; background: #fff; color: var(--texte);
}
input[type="text"], input[type="search"], input[type="number"], input[type="date"], select { min-height: 2.6rem; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-clair); border-color: var(--accent); }
input:disabled, select:disabled { background: #f3f3f3; color: #aaa; }
input[type="checkbox"] { width: 1.3rem; height: 1.3rem; vertical-align: middle; accent-color: var(--accent); }

button, .bouton {
  cursor: pointer; display: inline-block; text-decoration: none; background: #fff;
  min-height: 2.6rem; white-space: nowrap;
}
button:hover:not(:disabled), .bouton:hover { background: var(--survol); }
button:disabled { opacity: .45; cursor: default; }
button.principal, .bouton.principal { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.principal:hover:not(:disabled), .bouton.principal:hover { background: #255530; }
button.grand { font-size: 1.15rem; padding: .7rem 1.3rem; }
button.danger { color: var(--danger); border-color: #e2b4b0; }
button.danger:hover { background: var(--alerte-fond); }
.bouton-icone { border: none; background: none; padding: .3rem .5rem; min-height: 0; font-size: 1.1rem; color: var(--discret); }
.bouton-icone:hover:not(:disabled) { color: var(--danger); background: var(--alerte-fond); }
.bouton-icone.petit { font-size: .8rem; padding: .15rem .35rem; }

label { display: inline-flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--discret); }
label > input, label > select, label > textarea { color: var(--texte); }
label.case { flex-direction: row; align-items: center; gap: .45rem; color: var(--texte); font-size: 1rem; cursor: pointer; }
.court { width: 7rem; }
.tres-court { width: 4.5rem; }
.large { flex: 1; min-width: 14rem; }

/* ---------- Mise en page ---------- */
.barre-outils { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; margin-bottom: 1rem; }
.champ-recherche-liste { min-width: 18rem; flex: 1; max-width: 30rem; }
.carte { background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.ligne-champs { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.actions { display: flex; gap: .7rem; margin-top: 1rem; flex-wrap: wrap; }
.droite { text-align: right; }
.centre { text-align: center; }
.discret { color: var(--discret); font-size: .92rem; }
.vide { color: var(--discret); font-style: italic; padding: 1rem 0; }
.fort { font-weight: 700; }
.grand { font-size: 1.15rem; }

.alerte { background: var(--alerte-fond); color: var(--danger); border-radius: 6px; padding: .6rem .8rem; }
.avertissement { color: var(--danger); font-weight: 500; }
a.avertissement { text-decoration: underline; cursor: pointer; }
.inconnu { color: var(--danger); font-weight: 700; }
.pastille, .badge-incomplet {
  display: inline-block; margin-left: .4rem; padding: .05rem .45rem; border-radius: 99px;
  background: var(--alerte-fond); color: var(--danger); font-size: .8rem; font-weight: 600; white-space: nowrap;
}

/* ---------- Tableaux ---------- */
.tableau { width: 100%; border-collapse: collapse; background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon); }
.tableau th, .tableau td { padding: .45rem .6rem; border-bottom: 1px solid #ebe8e0; text-align: left; vertical-align: middle; }
.tableau th { background: #faf9f5; font-size: .88rem; color: var(--discret); font-weight: 600; }
.tableau .nombre, .nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tableau.cliquable tbody tr { cursor: pointer; }
.tableau.cliquable tbody tr:hover, .catalogue tbody tr:hover { background: var(--survol); }
.tableau.compact td, .tableau.compact th { padding: .3rem .5rem; }
.tableau tfoot td { border-bottom: none; padding-top: .7rem; }
.actions-ligne { white-space: nowrap; text-align: right; }
.actions-ligne button { min-height: 2.1rem; padding: .25rem .6rem; font-size: .9rem; margin-left: .2rem; }

/* Fiche recette */
.entete-recette .nom-recette { display: flex; margin-bottom: .8rem; }
.entete-recette .nom-recette input { font-size: 1.4rem; font-weight: 600; }
.lignes-recette td > input[type="text"], .lignes-recette td > select, .lignes-recette td > .recherche input { width: 100%; }
.lignes-recette .col-ordre { width: 2.2rem; white-space: nowrap; padding: 0; text-align: center; }
.lignes-recette .col-qte { width: 7rem; }
.lignes-recette .col-unite { width: 9rem; }
.lignes-recette .col-cout { width: 7rem; }
.lignes-recette .col-prix { width: 15rem; }
.prix-achat { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.texte-achat { white-space: nowrap; }
.petit-bouton { min-height: 0; padding: .2rem .55rem; font-size: .85rem; color: var(--accent); }
.petit-bouton.manquant { color: var(--danger); border-color: #e2b4b0; font-weight: 600; }
.catalogue td.col-achat { min-width: 13rem; }
.lignes-recette .col-suppr { width: 2.5rem; }
.lignes-recette td:nth-child(2) { min-width: 18rem; }
.lignes-recette tr.ligne-vide td { background: #fcfcfa; }
.lignes-recette tr.ligne-avertissement td { border-top: none; padding-top: 0; }
.lignes-recette tr:has(+ .ligne-avertissement) td { border-bottom: none; }
.etat-enregistrement { margin-left: auto; color: var(--discret); font-size: .95rem; min-width: 12rem; text-align: right; }
.etat-enregistrement.ok { color: var(--accent); }
.etat-enregistrement.erreur { color: var(--danger); font-weight: 600; }

/* Catalogue */
.catalogue td.editable { cursor: text; }
.catalogue td.editable:hover { outline: 1px dashed var(--bordure); }
.catalogue td input, .catalogue td select { width: 100%; min-width: 5rem; }
.catalogue td.remarque { max-width: 22rem; font-size: .9rem; }
.catalogue tr.archive td { color: #999; }

/* ---------- Autocomplétion ---------- */
.recherche { position: relative; width: 100%; }
.recherche input { width: 100%; }
.suggestions {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none;
  background: #fff; border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
  max-height: 22rem; overflow-y: auto; min-width: 22rem;
}
.suggestions li { padding: .45rem .7rem; cursor: pointer; display: flex; gap: .6rem; align-items: baseline; }
.suggestions li.actif { background: var(--accent-clair); }
.suggestions li.creer { color: var(--accent); font-weight: 600; border-top: 1px solid var(--bordure); }
.suggestions.vide { padding: .5rem .7rem; color: var(--discret); font-style: italic; }
.sugg-nom { flex: 1; }
.sugg-prix { color: var(--discret); font-size: .88rem; white-space: nowrap; }
.sugg-cat { color: #999; font-size: .8rem; white-space: nowrap; }

/* ---------- Fenêtres ---------- */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 1rem; overflow-y: auto; }
.fenetre { background: #fff; border-radius: 10px; width: 100%; max-width: 36rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.fenetre.large { max-width: 60rem; }
.fenetre-titre { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.2rem; border-bottom: 1px solid var(--bordure); }
.fenetre-titre h2 { margin: 0; }
.fenetre-corps { padding: 1rem 1.2rem 1.2rem; }
.formulaire { display: flex; flex-direction: column; gap: .8rem; }
.formulaire label { display: flex; }
.saisie-prix { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.details { border: 1px solid var(--bordure); border-radius: 6px; display: flex; flex-direction: column; gap: .6rem; }

/* ---------- Menu ---------- */
.entete-periode { display: flex; flex-wrap: wrap; gap: .8rem; }
.service-haut, .service-bas { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.service-haut .bouton-icone { margin-left: auto; }
.date-lisible { font-weight: 700; font-size: 1.1rem; padding-bottom: .55rem; min-width: 9rem; }
.service-cases { display: grid; grid-template-columns: repeat(5, minmax(10rem, 1fr)); gap: .7rem; margin: .8rem 0; }
.service-cases label { display: flex; }
.service.sans-recette { background: #fbfaf6; }
.cout-service { margin-left: auto; padding-bottom: .5rem; }
.totaux { margin-top: 1rem; font-size: 1.05rem; }
.semaine { margin-bottom: 1.4rem; }
.titre-semaine { display: flex; align-items: center; gap: 1rem; margin: .4rem 0 .6rem; }
.titre-semaine h2 { margin: 0; }
.ajout-jour { color: var(--accent); font-weight: 600; }
.jours-service { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin: .5rem 0; }
.choix-periode { display: inline-flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }

/* ---------- Liste de courses ---------- */
.resume-courses { display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; }
.liste-services { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.colonnes-courses { columns: 2 34rem; column-gap: 1.5rem; }
.rayon { break-inside: avoid-column; margin-bottom: 1rem; }
.rayon h2 { border-bottom: 2px solid var(--accent); padding-bottom: .2rem; }

/* ---------- Réglages / import ---------- */
.reglages { max-width: 50rem; }
.liste-simple { list-style: none; padding: 0; }
.liste-simple li { display: flex; align-items: center; gap: .5rem; }
.resume-import { line-height: 1.8; }
.apercu-import details { margin: .6rem 0; }
.apercu-import summary { cursor: pointer; font-weight: 600; }
.changement { display: inline-block; margin-right: 1rem; }

/* ---------- Message en bas d'écran ---------- */
.message {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #2b2b2b; color: #fff; padding: .8rem 1.3rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  max-width: 90vw; cursor: pointer;
}
.message.erreur { background: var(--danger); }

/* ---------- Connexion ---------- */
.page-connexion { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.connexion { display: flex; flex-direction: column; gap: 1rem; width: 24rem; max-width: 92vw; }
.connexion h1 { font-size: 1.4rem; margin: 0 0 .4rem; color: var(--accent); }
.connexion label { display: flex; }

/* Éléments réservés à l'impression */
.zone-impression, .seulement-impression { display: none; }

/* Écran moyen (portable) : le tableau de la recette se resserre au lieu de déborder */
@media (max-width: 1250px) {
  .lignes-recette td:nth-child(2) { min-width: 11rem; }
  .lignes-recette .col-qte { width: 5rem; }
  .lignes-recette .col-unite { width: 7.5rem; }
  .lignes-recette .col-prix { width: 9rem; }
  .lignes-recette .col-cout { width: 5.5rem; }
  .lignes-recette .prix-achat { flex-direction: column; align-items: flex-start; gap: .2rem; }
  .lignes-recette .texte-achat { white-space: normal; }
  .lignes-recette th, .lignes-recette td { padding-left: .3rem; padding-right: .3rem; }
  .lignes-recette td > select { min-width: 4.8rem; padding-left: .35rem; padding-right: .1rem; }
  .lignes-recette td > input[type="text"] { padding-left: .4rem; padding-right: .4rem; min-width: 3.5rem; }
}

@media (max-width: 900px) {
  .service-cases { grid-template-columns: repeat(2, 1fr); }
  html { font-size: 16px; }
}
