:root{
  /* BASE */
  --bg:#f4f8ff;                 /* fond blanc bleuté */
  --card:#ffffff;               /* cartes blanches */
  --text:#0f172a;               /* bleu nuit */
  --muted:#475569;              /* gris bleuté */
  --line:rgba(15,23,42,.12);

  /* BLEUS */
  --primary:#2563eb;            /* bleu principal */
  --primaryLight:#60a5fa;       /* bleu clair */
  --primarySoft:rgba(37,99,235,.08);

  /* STATUS */
  --good:#16a34a;
  --danger:#dc2626;

  --shadow:0 12px 30px rgba(2,6,23,.08);
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,"Helvetica Neue",Arial;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(96,165,250,.25), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(37,99,235,.18), transparent 55%),
    var(--bg);
  color:var(--text);
  padding:22px;
}

a{color:inherit;text-decoration:none}
.wrap{max-width:1100px;margin:0 auto}

/* ================= NAV ================= */
.nav{
  display:flex;
  align-items:center;
  gap:16px;
  padding:14px 18px;
  background:#ffffff;
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
  margin-bottom:16px;
}



/* ====== BRAND (navbar) ====== */
.brand-link{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  color:inherit;
  flex-shrink:0;
}

.brand-link h1{
  margin:0;
  font-size:19px;      /* ✅ taille "normale" */
  font-weight:800;
  line-height:1.1;
}

.brand-link span{
  display:block;
  margin-top:2px;
  font-size:15px;
  color:var(--muted);
  line-height:1.1;
}

/* ====== MENU À DROITE ====== */
.navlinks{
  margin-left:auto;
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

/* ================= NAV — MOBILE ================= */
@media (max-width: 620px){

  .nav{
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  /* Brand en haut */
  .brand-link{
    width: 100%;
  }

  /* Menu en bas, 1 seule ligne, scroll horizontal */
  .navlinks{
    width: 100%;
    margin-left: 0;                 /* annule le push desktop */
    flex-wrap: nowrap;              /* pas de retour à la ligne */
    overflow-x: auto;               /* scroll */
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 2px;
  }

  /* Cache la barre de scroll (optionnel) */
  .navlinks::-webkit-scrollbar{
    height: 0;
  }

  /* Pills plus compactes */
  .pill{
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;            /* texte sur 1 ligne */
    flex: 0 0 auto;                 /* évite l’écrasement */
  }

  /* Optionnel: logo + titre un peu plus petit */
  .logo{
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

  .brand h1{
    font-size: 14px;
    line-height: 1.1;
  }

  .brand span{
    font-size: 12px;
  }
}


.logo{
  width:50px;
  height:50px;
  border-radius:12px;
  background:linear-gradient(135deg, var(--primary), var(--primaryLight));
  display:grid;
  place-items:center;
  font-weight:900;
  color:#fff;
}




.pill{
  padding:10px 14px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#fff;
  font-size:13px;
  font-weight:600;
}
.pill:hover{
  background:var(--primarySoft);
  border-color:rgba(37,99,235,.35);
}

/* ================= HERO ================= */
.hero{
  padding:26px;
  border-radius:20px;
  background:
    linear-gradient(180deg, rgba(37,99,235,.12), rgba(255,255,255,1));
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  margin-bottom:18px;
}

.hero h2{
  margin:0 0 10px;
  font-size:32px;
  color:#0b1f44;
}
.hero p{
  margin:0;
  color:var(--muted);
  line-height:1.6;
}

/* ================= BUTTONS ================= */
.cta{
  margin-top:18px;
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.btn{
  padding:13px 18px;
  border-radius:14px;
  border:1px solid rgba(37,99,235,.25);
  background:linear-gradient(135deg, var(--primary), var(--primaryLight));
  color:#fff;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 10px 24px rgba(37,99,235,.35);
}
.btn:hover{filter:brightness(1.04)}

.btn.secondary{
  background:#fff;
  color:var(--primary);
  border:1px solid rgba(37,99,235,.35);
  box-shadow:none;
}
.btn.secondary:hover{
  background:var(--primarySoft);
}

/* ================= GRID ================= */
.grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:16px;
  margin-bottom:18px;
}
@media(max-width:900px){
  .grid{grid-template-columns:1fr}
  .hero h2{font-size:24px}
}

/* ================= CARD ================= */
.card{
  padding:22px;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}

.card h3{
  margin:0 0 6px;
  font-size:18px;
  color:#0b1f44;
}
.card p{
  margin:0 0 14px;
  color:var(--muted);
  line-height:1.5;
}

/* ================= TOOL ================= */
.tool{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:12px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
  margin-bottom:10px;
}
.tool:hover{
  border-color:rgba(37,99,235,.35);
  background:var(--primarySoft);
}

/* ================= TAG ================= */
.tag{
  font-size:12px;
  color:var(--muted);
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#fff;
}
.tag.good{
  background:rgba(22,163,74,.12);
  border-color:rgba(22,163,74,.35);
  color:#14532d;
}

/* ================= FORMS ================= */
label{font-size:12px;color:var(--muted);display:block;margin:12px 0 6px}
input, select, textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
}
textarea{min-height:120px}
input::placeholder{color:#94a3b8}

input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--primary);
  box-shadow:0 0 0 4px rgba(37,99,235,.15);
}

/* ================= TABLE ================= */
table{width:100%;border-collapse:separate;border-spacing:0}
th, td{
  padding:10px 8px;
  border-bottom:1px solid var(--line);
}
th{
  font-size:12px;
  color:var(--muted);
  font-weight:700;
}
td:last-child, th:last-child{text-align:right}

/* ================= KPI ================= */
.summary{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin-top:16px;
}
.kpi{
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
  background:
    linear-gradient(180deg, rgba(37,99,235,.06), #fff);
}
.kpi .t{font-size:12px;color:var(--muted)}
.kpi .v{font-size:22px;font-weight:900}
.kpi .s{font-size:12px;color:var(--muted)}

@media(max-width:860px){
  .summary{grid-template-columns:1fr}
  th:nth-child(3), td:nth-child(3){display:none}
}

@media print{
  /* ✅ Dans la fiche print, on force la colonne 3 visible */
  .print-table th:nth-child(3),
  .print-table td:nth-child(3){
    display:table-cell !important;
  }
}


/* ================= FOOTER ================= */
footer{
  margin-top:20px;
  font-size:12px;
  color:var(--muted);
  display:flex;
  justify-content:space-between;
  flex-wrap:wrap;
}

/* ================= TOP BAR CALCUL (2 LIGNES) ================= */
.topbar{
  display:flex;              /* ✅ plus de 2 colonnes */
  flex-direction:column;     /* ✅ boutons en bas */
  gap:14px;
  margin-bottom:20px;
}

/* Champs */
.topbar .controls:first-child{
  display:grid;
  grid-template-columns: 2fr 1fr 0.8fr;
  gap:16px;
}

/* Boutons (en bas) */
.topbar .controls:last-child{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:wrap;
  white-space:normal;        /* ✅ évite que ça force sur une ligne */
}

/* Hauteur uniforme */
.topbar .btn{
  height:44px;
  padding:0 16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* Responsive */
@media (max-width: 900px){
  .topbar .controls:first-child{
    grid-template-columns: 1fr;
  }
}


/* ================= TABLE SANS SCROLL ================= */
.table-wrap{
  border-radius:14px;
  border:1px solid var(--line);
  overflow:hidden;      /* supprime la barre horizontale */
}

/* le tableau doit rentrer dans le conteneur */
#ingredientsTable{
  width:100%;
  table-layout:fixed;   /* clé anti-débordement */
}

/* autorise les inputs/select à se réduire */
#ingredientsTable input,
#ingredientsTable select{
  width:100%;
  min-width:0;          /* TRÈS important */
}

/* évite que les titres poussent trop large */
#ingredientsTable th{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* on limite la largeur du bouton supprimer */
#ingredientsTable td:last-child{
  width:110px;
}

/* ================= BUDGET — TABLE -> CARTES (MOBILE) ================= */
@media (max-width: 620px){

  /* On retire l'effet "table fixe" sur mobile */
  .table-wrap table{
    table-layout: auto;
  }

  /* Cache l'entête */
  .table-wrap thead{
    display:none;
  }

  /* Chaque ligne devient une carte */
  .table-wrap tbody tr{
    display:block;
    border:1px solid var(--line);
    border-radius:16px;
    padding:12px;
    margin:10px;
    background:#fff;
    box-shadow:var(--shadow);
  }

  /* Les cellules deviennent des blocs empilés */
  .table-wrap tbody td{
    display:block;
    width:100%;
    border-bottom:none;
    padding:8px 0;
    text-align:left;
  }

  /* Le bouton poubelle en bas à droite */
  .table-wrap tbody td:last-child{
    padding-top:10px;
    display:flex;
    justify-content:flex-end;
  }

  /* Inputs/select en full width */
  .table-wrap input,
  .table-wrap select{
    width:100%;
  }

  /* Respire un peu */
  .card{
    padding:16px;
  }
}


/* ================= MOBILE – HEURES TRAVAILLÉES ================= */
/* Labels uniquement utiles en mobile (Début/Fin/Pause) */
.m-label{
  display:none;
  font-size:12px;
  color:var(--muted);
  font-weight:600;
  margin:0 0 6px;
}

/* Desktop : cellule heures nettes + bouton alignés proprement */
.net-cell{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.net-row{
  display:flex;
  align-items:baseline;
  gap:10px;
}
.net-label{
  display:none; /* caché en desktop */
  color:var(--muted);
  font-weight:600;
  font-size:13px;
}
.net-cell .d-net{
  font-weight:900;
  font-size:16px;
}

/* ================= MOBILE – HEURES TRAVAILLÉES ================= */
@media (max-width: 640px){

  .hours-table thead{ display:none; }

  /* Chaque ligne devient une carte en grid */
  .hours-table tbody tr{
    display:grid !important;
    grid-template-columns:1fr 1fr;
    gap:12px;
    padding:14px;
    margin:12px;
    border:1px solid var(--line);
    border-radius:16px;
    background:#fff;
    box-shadow:var(--shadow);
  }

  /* Jour plein */
  .hours-table tbody td:nth-child(1){
    grid-column:1 / -1;
  }

  /* Début / Fin */
  .hours-table tbody td:nth-child(2),
  .hours-table tbody td:nth-child(3){
    display:flex;
    flex-direction:column;
    gap:6px;
  }

  /* Pause plein */
  .hours-table tbody td:nth-child(4){
    grid-column:1 / -1;
    display:flex;
    flex-direction:column;
    gap:6px;
  }

  /* ✅ Heures nettes (plein) + bouton sur la même ligne */
  .hours-table tbody td:nth-child(5){
    grid-column:1 / -1;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding-top:6px;
  }

  /* Afficher les petits labels */
  .m-label{ display:block; }

  /* Label "Heures nettes" visible en mobile */
  .net-label{
    display:inline;
  }

  /* Valeur 7h00 bien visible */
  .hours-table .d-net{
    font-size:20px;
    font-weight:900;
    color:var(--text);
  }

  /* Bouton delete à droite */
  .hours-table .del-btn{
    flex:0 0 auto;
  }

  /* Inputs full width */
  .hours-table input{
    width:100%;
  }
}

/* ================= MOBILE — COÛT RECETTE (table -> cartes + libellés) ================= */
@media (max-width: 620px){

  /* Cible uniquement la page recette (wrapper ajouté) */
  .recipe-table thead{
    display:none;
  }

  /* Chaque ligne devient une carte */
  .recipe-table tbody tr{
    display:block;
    border:1px solid var(--line);
    border-radius:16px;
    padding:12px;
    margin:10px;
    background:#fff;
    box-shadow:var(--shadow);
  }

  /* Chaque cellule devient un bloc empilé */
  .recipe-table tbody td{
    display:block;
    width:100%;
    border-bottom:none;
    padding:10px 0;
    text-align:left;
  }

  /* Inputs / select full largeur */
  .recipe-table input,
  .recipe-table select{
    width:100%;
  }

  /* ===== Libellés par colonne (ordre exact de TON tableau) =====
     1 Ingrédient
     2 Quantité
     3 Unité quantité
     4 Prix d’achat
     5 Unité prix
     6 Coût
     7 Supprimer
  */

  .recipe-table tbody td:nth-child(1)::before{
    content:"Ingrédient";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  .recipe-table tbody td:nth-child(2)::before{
    content:"Quantité utilisée";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  .recipe-table tbody td:nth-child(3)::before{
    content:"Unité quantité";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  .recipe-table tbody td:nth-child(4)::before{
    content:"Prix d’achat";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  .recipe-table tbody td:nth-child(5)::before{
    content:"Unité prix";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  /* Coût mis en avant */
  .recipe-table tbody td:nth-child(6){
    padding-top:14px;
    font-weight:900;
    font-size:18px;
  }
  .recipe-table tbody td:nth-child(6)::before{
    content:"Coût";
    display:block;
    font-size:12px;
    color:var(--muted);
    font-weight:700;
    margin-bottom:6px;
  }

  /* Poubelle en bas à droite */
  .recipe-table tbody td:nth-child(7){
    padding-top:10px;
  }
  .recipe-table tbody td:nth-child(7) .row-actions{
    display:flex !important;
    justify-content:flex-end !important;
  }

  /* Un peu plus compact sur mobile */
  .card{ padding:16px; }
}


/* =========================
   PRINT / PDF (A4)
========================= */
.print-area{
  position:absolute;
  left:-99999px;
  top:0;
  width:0;
  height:0;
  overflow:hidden;
}

/* La fiche (écran) */
.print-sheet{
  width:210mm;
  min-height:297mm;
  padding:14mm;
  background:#fff;
  color:#0f172a;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,"Helvetica Neue",Arial;
}

.print-head{
  display:flex;
  flex-direction:column;
  gap:10px;
  border-bottom:1px solid rgba(15,23,42,.15);
  padding-bottom:10px;
  margin-bottom:12px;
}

.print-brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.print-logo{
  width:36px;
  height:36px;
  border-radius:10px;
  display:grid;
  place-items:center;
  font-weight:900;
  color:#fff;
  background:linear-gradient(135deg, #2563eb, #60a5fa);
}

.print-title{
  font-weight:900;
  font-size:16px;
}
.print-sub{
  font-size:12px;
  color:#475569;
  margin-top:2px;
}

.print-row{
  display:flex;
  gap:10px;
}

.print-box{
  border:1px solid rgba(15,23,42,.12);
  border-radius:10px;
  padding:8px 10px;
  background:#fff;
  flex:1;
}

.print-k{
  font-size:11px;
  color:#475569;
  font-weight:700;
}
.print-v{
  font-size:13px;
  font-weight:800;
  margin-top:4px;
}
.print-v.big{
  font-size:16px;
}

.print-h2{
  font-size:14px;
  margin:10px 0 8px;
}

.print-table{
  width:100%;
  border-collapse:collapse;
  font-size:12px;
}

.print-table th{
  text-align:left;
  padding:8px 6px;
  border-bottom:1px solid rgba(15,23,42,.18);
  color:#475569;
  font-weight:800;
}

.print-table td{
  padding:8px 6px;
  border-bottom:1px solid rgba(15,23,42,.10);
  vertical-align:top;
}

.print-totals{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:10px;
  margin-top:12px;
}

.print-total{
  border:1px solid rgba(15,23,42,.12);
  border-radius:12px;
  padding:10px;
}

.print-notes{
  margin-top:12px;
  border:1px solid rgba(15,23,42,.12);
  border-radius:12px;
  padding:10px;
}

.print-notes-box{
  min-height:28mm;
  margin-top:6px;
  font-size:12px;
  color:#0f172a;
  white-space:pre-wrap;
}

.print-foot{
  margin-top:12px;
  display:flex;
  justify-content:space-between;
  font-size:11px;
  color:#475569;
  border-top:1px solid rgba(15,23,42,.12);
  padding-top:8px;
}

#recipeNotes{
  min-height: 140px;
  resize: vertical;
}


/* =========================
   PRINT / PDF (A4) — CLEAN
   (Compatible page print + popup)
========================= */

/* caché à l’écran */
#printArea{
  display:none;
}

/* PRINT : on affiche uniquement la fiche */
@media print{
  /* on masque le site */
  body > *{
    display:none !important;
  }

  /* on affiche la zone print */
  #printArea{
    display:block !important;
  }

  /* on remet la fiche en layout normal */
  #printArea .print-area{
    position:static !important;
    width:auto !important;
    height:auto !important;
    left:auto !important;
    overflow:visible !important;
  }

  @page{
    size:A4;
    margin:0;
  }

  body{
    margin:0 !important;
    background:#fff !important;
    padding:0 !important;
  }
}

/* ✅ Mode "sans prix" */
/* ✅ Mode "sans prix" : on masque prix + coût + totaux € */
#printSheet.no-price .col-price,
#printSheet.no-price .col-cost,
#printSheet.no-price .money-totals{
  display:none !important;
}

/* Quand on cache 2 blocs, on laisse la masse seule en pleine largeur */
#printSheet.no-price .print-totals{
  grid-template-columns: 1fr !important;
}



/* 🔧 Alignement fin des boutons */
.actions-stack{
  display:grid;
  grid-template-rows:auto auto;
  row-gap:10px;
}

/* Chaque ligne de boutons */
.actions-row{
  display:flex;
  align-items:center;
  gap:12px;
}

/* Même largeur visuelle pour les boutons */
.actions-row .btn{
  height:44px;
  padding:0 18px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

/* Les exports commencent exactement sous le 1er bouton */
.exports-row{
  margin-left:0;               /* reset */
}

/* Alignement précis sous le bouton "Ajouter" */
@media (min-width: 900px){
  .exports-row{
    padding-left:0;            /* bien calé à gauche */
  }
}

/* Mobile : full width, aligné */
@media (max-width: 760px){
  .actions-row{
    flex-wrap:wrap;
  }

  .exports-row .btn{
    flex:1 1 calc(50% - 6px);
  }
}

