/* ============================================================
   AgriCalcul — Thème app « Terroir moderne »
   Appliqué à toute l'application (hors landing) :
   - fond crème des écrans
   - barre de navigation ancrée façon maquette
   N'altère pas la structure/logique des écrans.
   ============================================================ */

/* --- Fond crème (écrans de l'app, pas la landing) --- */
body:not(.landing-page) {
  background: #f4f1ea !important;
}
body:not(.landing-page) #app-wrapper,
body:not(.landing-page) #app-main {
  background: #f4f1ea;
}
/* Conteneur racine de chaque écran (enfant direct de #app-main) → crème */
body:not(.landing-page) #app-main > div {
  background: #f4f1ea !important;
}

/* --- Barre de navigation ancrée (style maquette) --- */
#bottom-nav.terroir-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
  margin: 0;
  background: #ffffff;
  border: none;
  border-top: 1px solid #e7e3da;
  border-radius: 0;
  box-shadow: 0 -4px 24px -10px rgba(20, 36, 27, .16);
  backdrop-filter: none;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 9px 6px calc(11px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.terroir-nav .nav-item {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.terroir-nav .nav-pill {
  width: 42px;
  height: 28px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease;
}
.terroir-nav .nav-item i {
  width: 20px;
  height: 20px;
  color: #b9c2b3;
  stroke-width: 1.9;
  transition: color .2s ease, stroke-width .2s ease;
}
.terroir-nav .nav-item.active .nav-pill {
  background: #eef3e4;
}
.terroir-nav .nav-item.active i {
  color: #517f26;
  stroke-width: 2.2;
}
/* Variante mode support / super-admin (accent rouge) */
.terroir-nav.admin {
  background: #fff;
}
.terroir-nav.admin .nav-item.active .nav-pill {
  background: #fbe9e4;
}
.terroir-nav.admin .nav-item.active i {
  color: #b94530;
}
.terroir-nav .nav-exit i {
  color: #d2553f;
}

/* ============================================================
   SIDEBAR DESKTOP / TABLETTE (≥ 1024px)
   ============================================================ */
.app-sidebar {
  display: none;
}
.app-sidebar.hidden,
#bottom-nav.hidden {
  display: none !important;
}

@media (min-width: 1024px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    z-index: 45;
    background: #ffffff;
    border-right: 1px solid #e7e3da;
    padding: 22px 16px;
  }
  /* Sur grand écran : barre du bas masquée, contenu décalé pour la sidebar */
  #bottom-nav.terroir-nav {
    display: none !important;
  }
  body.has-sidebar #app-main {
    margin-left: 260px;
    width: calc(100% - 260px);
  }
  body.has-sidebar:not(.landing-page) #app-main > div {
    max-width: 1340px;
    margin-left: auto;
    margin-right: auto;
  }
}

.sb-top {
  min-height: 0;
}
.sb-logo {
  height: 46px;
  width: auto;
  display: block;
  margin: 2px 6px 22px;
}
.sb-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9aa595;
  padding: 0 10px;
  margin-bottom: 8px;
}
.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #3f4d44;
  text-align: left;
  width: 100%;
  transition: background .15s, border-color .15s;
}
.sidebar-item:hover {
  background: #faf8f3;
}
.sidebar-item .si-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7c8a80;
  flex: none;
  transition: background .15s, color .15s;
}
.sidebar-item .si-icon i {
  width: 19px;
  height: 19px;
}
.sidebar-item.active {
  background: #ffffff;
  border-color: #cfe0b3;
  box-shadow: 0 6px 16px -10px rgba(20, 36, 27, .22);
  color: #14241b;
  font-weight: 700;
}
.sidebar-item.active .si-icon {
  background: #eef3e4;
  color: #517f26;
}
.app-sidebar.admin .sidebar-item.active {
  border-color: #f2dcc0;
}
.app-sidebar.admin .sidebar-item.active .si-icon {
  background: #fbe9e4;
  color: #b94530;
}
.sb-profile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid #e7e3da;
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: background .15s, box-shadow .15s;
}
.sb-profile:hover {
  background: #faf8f3;
  box-shadow: 0 6px 16px -10px rgba(20, 36, 27, .18);
}
.sb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, #6ba23a, #477021);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.sb-avatar i {
  width: 20px;
  height: 20px;
  color: #fff;
}
.sb-profile-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.sb-profile-txt strong {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 13.5px;
  color: #14241b;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-profile-txt span {
  font-size: 11.5px;
  color: #9aa595;
}

/* ============================================================
   RÉCOLTES — layout desktop (liste à gauche / récap à droite)
   ============================================================ */
@media (min-width: 1024px) {
  .ag-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas: "nav rev" "list note";
    grid-template-rows: auto 1fr;
    column-gap: 20px;
    row-gap: 16px;
    align-items: start;
  }
  .ag-area-nav { grid-area: nav; margin-bottom: 0 !important; }
  .ag-area-rev { grid-area: rev; margin-bottom: 0 !important; }
  .ag-area-list { grid-area: list; }
  .ag-area-note { grid-area: note; margin-top: 0 !important; }

  /* Carte recette estimée en grand (dégradé vert façon maquette) */
  #daily-revenue-card.ag-area-rev {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    background: linear-gradient(145deg, #6ba23a, #477021) !important;
    border-color: transparent !important;
    padding: 18px 20px;
    box-shadow: 0 16px 32px -18px rgba(20, 36, 27, .5);
  }
  #daily-revenue-card.ag-area-rev .text-brand-green,
  #daily-revenue-card.ag-area-rev .text-gray-400,
  #daily-revenue-card.ag-area-rev .text-gray-500 {
    color: rgba(255, 255, 255, .85) !important;
  }
  #daily-revenue-card.ag-area-rev #daily-total-amount {
    color: #fff !important;
    font-size: 34px;
    line-height: 1;
  }
  #daily-revenue-card.ag-area-rev .bg-brand-green {
    background: rgba(255, 255, 255, .18) !important;
  }
}

/* ============================================================
   COMPOSANTS DESIGN SYSTEM « Terroir moderne » (propres, sans Tailwind)
   Réécrits depuis la maquette desktop/mobile. Aucune valeur inline.
   ============================================================ */
.ds-page { padding: 24px 20px 120px; }
.ds-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.ds-h1 { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 28px; letter-spacing: -.02em; color: #14241b; margin: 0; }
.ds-card { background: #fff; border: 1px solid #e7e3da; border-radius: 18px; box-shadow: 0 1px 2px rgba(20,36,27,.04); }
.ds-btn { display: inline-flex; align-items: center; gap: 8px; border: none; cursor: pointer; background: #5f8f2e; color: #fff; font-family: inherit; font-weight: 700; font-size: 14px; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 22px -10px rgba(95,143,46,.6); transition: transform .15s, box-shadow .15s; }
.ds-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -10px rgba(95,143,46,.7); }
.ds-btn i { width: 17px; height: 17px; }
.ds-chip { font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 99px; white-space: nowrap; }
.ds-chip-green { color: #45701f; background: #eef3e4; }
.ds-chip-orange { color: #a8611c; background: #fbeede; }
@media (min-width: 1024px) { .ds-page { padding: 32px; } .ds-h1 { font-size: 32px; } }

/* ---- PROFIL (maquette) ---- */
.pf-grid { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.pf-card { padding: 28px 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pf-avatar-wrap { position: relative; }
.pf-avatar { width: 104px; height: 104px; border-radius: 26px; background: linear-gradient(150deg,#6ba23a,#477021); display: flex; align-items: center; justify-content: center; box-shadow: 0 14px 28px -14px rgba(95,143,46,.6); overflow: hidden; cursor: pointer; }
.pf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pf-avatar > i { width: 54px; height: 54px; color: #fff; }
.pf-avatar-edit { position: absolute; right: -4px; bottom: -4px; width: 34px; height: 34px; border-radius: 99px; background: #5f8f2e; border: 3px solid #fff; display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; }
.pf-avatar-edit i { width: 15px; height: 15px; }
.pf-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 22px; color: #14241b; text-align: center; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 4px 10px; width: 100%; max-width: 260px; }
.pf-name:hover { background: #faf8f3; }
.pf-name:focus { outline: none; border-color: #cfe0b3; background: #fff; box-shadow: 0 0 0 3px rgba(95,143,46,.18); }
.pf-save { font-size: 11px; font-weight: 700; color: #5f8f2e; opacity: 0; transition: opacity .3s; height: 12px; }
.pf-save.on { opacity: 1; }
.pf-chips { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.pf-menu-col { display: flex; flex-direction: column; gap: 16px; }
.pf-menu { overflow: hidden; }
.pf-row { display: flex; align-items: center; gap: 14px; padding: 16px 18px; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid #f1eee7; cursor: pointer; font-family: inherit; transition: background .15s; }
.pf-row:last-child { border-bottom: none; }
.pf-row:hover { background: #faf8f3; }
.pf-row .pf-ic { width: 42px; height: 42px; border-radius: 12px; background: #eef3e4; display: flex; align-items: center; justify-content: center; flex: none; color: #517f26; }
.pf-row .pf-ic i { width: 20px; height: 20px; }
.pf-row .pf-txt { flex: 1; min-width: 0; }
.pf-row .pf-txt b { display: block; font-weight: 600; font-size: 15.5px; color: #14241b; }
.pf-row .pf-txt span { font-size: 13px; color: #9aa595; }
.pf-row .pf-chev { width: 18px; height: 18px; color: #c7cfc6; flex: none; }
.pf-logout { display: inline-flex; align-self: flex-start; align-items: center; gap: 9px; border: 1px solid #f5ddd6; background: #fbe9e4; color: #b94530; font-family: inherit; font-weight: 700; font-size: 15px; padding: 13px 22px; border-radius: 14px; cursor: pointer; }
.pf-logout i { width: 18px; height: 18px; }
@media (min-width: 1024px) {
  .pf-grid { flex-direction: row; align-items: flex-start; gap: 22px; max-width: 920px; }
  .pf-card { width: 300px; flex: none; }
  .pf-menu-col { flex: 1 1 360px; }
}

/* ---- Segmented control (Mois / Semaine) ---- */
.ds-seg { display: inline-flex; background: #fff; border: 1px solid #e7e3da; border-radius: 99px; padding: 4px; }
.ds-seg-btn { border: none; cursor: pointer; font-family: inherit; padding: 8px 16px; border-radius: 99px; font-size: 13px; font-weight: 700; background: transparent; color: #9aa595; }
.ds-seg-btn.on { background: #5f8f2e; color: #fff; }

/* ---- CALENDRIER (maquette) ---- */
.cal-head-actions { display: flex; align-items: center; gap: 10px; }
.cal-info-btn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid #e7e3da; background: #fff; color: #7c8a80; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cal-info-btn i { width: 18px; height: 18px; }
.cal-layout { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.cal-main { padding: 18px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid #e7e3da; background: #faf8f3; color: #5c6b60; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cal-nav-btn i { width: 17px; height: 17px; }
.cal-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 20px; letter-spacing: .02em; color: #14241b; }
.cal-week-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.cal-week-head div { text-align: center; font-size: 11.5px; font-weight: 700; color: #b9c2b3; letter-spacing: .04em; }
.cal-weeks { display: flex; flex-direction: column; gap: 6px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { height: 56px; border-radius: 12px; border: 1px solid #f1eee7; background: #fff; padding: 7px 9px; position: relative; cursor: pointer; transition: background .15s; }
.cal-cell:not(.empty):not(.today):hover { background: #faf8f3; }
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell.today { background: #5f8f2e; border-color: transparent; }
.cal-num { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 600; font-size: 14px; color: #2f3d33; }
.cal-cell.today .cal-num { color: #fff; font-weight: 800; }
.cal-day-rev { position: absolute; left: 9px; bottom: 7px; font-size: 10.5px; font-weight: 700; color: rgba(255,255,255,.9); }
.cal-dots { position: absolute; left: 9px; bottom: 8px; display: flex; gap: 3px; }
.cal-cell.today .cal-dots { display: none; }
.cal-dot { width: 5px; height: 5px; border-radius: 9px; display: inline-block; }
.cal-dot.g { background: #6fa23a; }
.cal-dot.y { background: #e2912f; }
.cal-loading { padding: 44px; display: flex; justify-content: center; }
.cal-spin { width: 28px; height: 28px; color: #5f8f2e; animation: cal-spin 1s linear infinite; }
@keyframes cal-spin { to { transform: rotate(360deg); } }
.cal-side { display: flex; flex-direction: column; gap: 14px; }
.cal-rev-card { border-radius: 18px; padding: 20px 22px; color: #fff; background: linear-gradient(150deg, #6ba23a, #477021); box-shadow: 0 18px 40px -20px rgba(20,36,27,.5); }
.cal-rev-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.82); margin-bottom: 8px; }
.cal-rev-val { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 32px; letter-spacing: -.02em; }
.cal-stat { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.cal-stat-ic { width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: none; }
.cal-stat-ic.green { background: #eef3e4; color: #517f26; }
.cal-stat-ic.orange { background: #fbeede; color: #c2762a; }
.cal-stat-ic i { width: 22px; height: 22px; }
.cal-stat-lbl { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #9aa595; }
.cal-stat-val { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 24px; margin-top: 3px; color: #14241b; }
@media (min-width: 1024px) {
  .cal-layout { flex-direction: row; align-items: flex-start; gap: 22px; }
  .cal-main { flex: 1 1 0; min-width: 0; }
  .cal-side { width: 300px; flex: none; }
  .cal-cell { height: 72px; }
}

/* ---- INVENTAIRE — cartes produit (maquette) ---- */
.inv-card { position: relative; overflow: hidden; background: #fff; border: 1px solid #e7e3da; border-radius: 14px; padding: 15px 16px; cursor: pointer; transition: box-shadow .15s; }
.inv-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--spine, #6fa23a); }
.inv-card:hover { box-shadow: 0 8px 18px -12px rgba(20,36,27,.25); }
.inv-card.sel { border-color: #f4d9d1; background: #fbe9e4; }
.inv-wm { position: absolute; right: -10px; top: -10px; opacity: .07; color: var(--spine, #6fa23a); pointer-events: none; }
.inv-wm i { width: 66px; height: 66px; }
.inv-check { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cdd3cb; background: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.inv-check.on { background: #d2553f; border-color: #d2553f; }
.inv-check i { width: 13px; height: 13px; color: #fff; }
.inv-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 15px; line-height: 1.15; margin-left: 5px; min-height: 38px; color: #14241b; position: relative; z-index: 1; }
.inv-cal { color: #9aa595; font-weight: 700; }
.inv-price { display: inline-flex; align-items: baseline; gap: 3px; margin-left: 5px; margin-top: 8px; background: #eef3e4; padding: 4px 10px; border-radius: 9px; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 17px; color: #45701f; position: relative; z-index: 1; }
.inv-price span { font-size: 11px; color: #9aa595; font-weight: 600; }
.inv-noprice { margin-left: 5px; margin-top: 8px; font-size: 13px; font-style: italic; font-weight: 600; color: #b9c2b3; position: relative; z-index: 1; }
.inv-maj { display: flex; align-items: center; gap: 5px; margin-left: 5px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed #efece4; font-size: 11.5px; color: #9aa595; font-weight: 500; position: relative; z-index: 1; }
.inv-maj i { width: 13px; height: 13px; }

/* ============================================================
   RÉCOLTES — tableau (maquette)
   Mobile : lignes/cartes propres · Desktop : vraies colonnes
   ============================================================ */
.rec-head { display: none; }
.rec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e7e3da;
  border-left: 4px solid var(--spine, #6fa23a);
  border-radius: 14px;
  padding: 12px 14px;
}
.rec-row.is-selected { border-color: #bcd79c; background: #f3f8ec; }
.rec-row.is-editing { border-color: #5f8f2e; box-shadow: 0 0 0 2px rgba(95,143,46,.25); }
.rec-c-check { display: none; }
.rec-row.sel-mode .rec-c-check { display: flex; align-items: center; }
.rec-checkbox {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #cdd3cb; background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.rec-checkbox.on { background: #5f8f2e; border-color: #5f8f2e; }
.rec-checkbox i { width: 13px; height: 13px; color: #fff; }
.rec-c-name { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.rec-dot { display: none; }
.rec-name-txt { display: flex; flex-direction: column; min-width: 0; }
.rec-title {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 14px; color: #14241b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-refus { font-size: 10px; color: #d2553f; background: #fbe9e4; padding: 1px 6px; border-radius: 99px; }
.rec-sub { font-size: 11px; color: #9aa595; }
.rec-c-qty, .rec-c-price { display: none; }
.rec-c-total {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 13px;
  color: #45701f; margin-left: auto; white-space: nowrap;
}
.rec-c-act { display: flex; gap: 6px; flex: none; }
.rec-c-act button {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid #e7e3da; background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: #5c6b60; transition: background .15s;
}
.rec-c-act button i { width: 15px; height: 15px; }
.rec-c-act button:hover { background: #faf8f3; }
.rec-c-act .del-btn { color: #d2553f; background: #fbe9e4; border-color: #f4d9d1; }
.rec-c-act button[disabled] { opacity: .4; pointer-events: none; }

@media (min-width: 1024px) {
  #agenda-list.ag-area-list {
    background: #fff; border: 1px solid #e7e3da; border-radius: 16px; overflow: hidden; padding: 0;
    box-shadow: 0 6px 18px -14px rgba(20,36,27,.18);
  }
  #agenda-list.ag-area-list > * + * { margin-top: 0 !important; }
  .rec-head {
    display: grid; align-items: center;
    grid-template-columns: 44px minmax(0,1fr) 110px 110px 110px 92px;
    padding: 13px 16px; border-bottom: 1px solid #e7e3da;
    font-size: 11px; font-weight: 700; letter-spacing: .05em; color: #9aa595; text-transform: uppercase;
  }
  #agenda-list.rec-nofin .rec-head,
  #agenda-list.rec-nofin .rec-row { grid-template-columns: 44px minmax(0,1fr) 110px 92px; }
  .rec-row {
    display: grid; align-items: center;
    grid-template-columns: 44px minmax(0,1fr) 110px 110px 110px 92px;
    border: none; border-bottom: 1px solid #efece4; border-left: none; border-radius: 0;
    padding: 12px 16px; gap: 0;
  }
  .rec-row:last-child { border-bottom: none; }
  .rec-row.is-selected { background: #f3f8ec; }
  .rec-row.is-editing { box-shadow: inset 3px 0 0 #5f8f2e; }
  .rec-c-check { display: flex !important; align-items: center; }
  .rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
  .rec-sub { display: none; }
  .rec-c-qty { display: block; font-size: 13px; color: #45534a; font-weight: 600; }
  .rec-c-price { display: block; font-size: 13px; color: #2f3d33; font-weight: 700; font-family: 'Bricolage Grotesque', sans-serif; }
  .rec-c-total { display: block; margin-left: 0; font-size: 14px; }
}
