:root{
  --principal: #A5AD85;
  --principal-2: #8F9770;
  --black: #111111;
  --text: #1b1b1b;
  --muted: #6b7280;
  --bg: #E6E9DA;
  --card: #ffffff;
  --border: rgba(17,17,17,0.10);
  --shadow: 0 12px 30px rgba(0,0,0,0.12);
  --radius: 18px;
  --radius2: 14px;
  --focus: 0 0 0 3px rgb(from var(--principal) r g b / 0.25);
  --color-filter-chip-active-bg: #7e8663;
}

*{ box-sizing: border-box; }
html{ font-size: 16px; }
html, body{ min-height: 100%; }
body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

dialog {
  border: 0;
  background: none;
}

.d-none {
  display: none !important;
}

/* Topbar */
.topbar{
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand{
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brandLogo{
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--principal);
  font-size: 1.75rem;
}
    .brandLogo img{
        max-height: 50px;
    }
.brandSub{
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  display: none;
}

.topbarRight{
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
/* .dot{
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--principal);
  box-shadow: 0 0 0 3px rgb(from var(--principal) r g b / 0.18);
} */
.dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--principal);
  flex-shrink: 0;
}

/* Halo / polsació */
.dot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgb(from var(--principal) r g b / 0.35);;
  animation: gpsPulse 1.6s ease-out infinite;
}

/* Animació */
@keyframes gpsPulse {
  0% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

.cartBtn{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--black);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}
.cartBtn svg{
  width: 24px;
  fill: #fff;
}
.cartCount{
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--principal);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.75rem;
}

/* Icon btn */
.iconBtn{
  background: transparent;
  border: 1px solid transparent;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.125rem;
}
.iconBtn:hover{ background: rgba(17,17,17,0.05); }
.iconBtn:focus{ outline: none; box-shadow: var(--focus); }
.iconBtn.iconBtnCancel{ box-shadow: none !important; }

.burger{
  width: 20px; height: 2px;
  background: var(--black);
  display: inline-block;
  position: relative;
}
.burger::before, .burger::after{
  content: "";
  position: absolute;
  left: 0;
  width: 20px; height: 2px;
  background: var(--black);
}
.burger::before{ top: -6px; }
.burger::after{ top: 6px; }

/* Link banner */
.linkBanner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgb(from var(--principal) r g b / 0.12), rgb(from var(--principal) r g b / 0.04));
  border-bottom: 1px solid rgb(from var(--principal) r g b / 0.18);
  display: none;
}
.linkTitle{
  font-weight: 800;
  letter-spacing: .2px;
}
.linkMeta{
  color: var(--muted);
  font-size: 0.8125rem;
}
.linkMeta code{
  background: rgba(17,17,17,0.05);
  padding: 2px 6px;
  border-radius: 8px;
}

/* Layout */
.layout{
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 120px);
  align-items: start;
  align-content: start;
}

.categories{
  position: sticky;
  top: 70px;
  align-self: start;
  height: calc(100vh - 70px);
  padding: 16px;
  border-right: 1px solid var(--border);
  background: #fff;

  overflow: auto;
}
.sectionTitle{
  font-weight: 800;
  font-family: Montserrat, Inter, sans-serif;
  letter-spacing: .4px;
}
.catList{
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;

  padding-bottom: 12px;

  flex: 1 1 auto;   /* clau: ocupa l'espai restant */
  min-height: 0;    /* clau: permet que l'overflow funcioni en flex */
}
.catBtn{
  text-align: left;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  
}
.catBtn small{ color: var(--muted); font-weight: 600; margin-left: 5px; }
.catBtn.active{
    background: linear-gradient(135deg, var(--principal), color-mix(in srgb, var(--principal) 70%, #ffffff 30%));
    box-shadow: 1px 2px 6px rgba(0, 0, 0, 0.15);
    color: #fff;
}
.catBtn.active small{ color: #fff; }
.asideFooter{
  margin-top: auto;   /* clau */
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.hint{
  font-size: 0.78125rem;
  color: var(--muted);
  line-height: 1.35;
}

.content{
  padding: 16px;
}
.contentHeader{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-direction: column;
}
h1{
  margin: 0;
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 800;
  letter-spacing: .2px;
}
  #screenTitle {
    text-align: center;
  }
.searchWrap{
  width: min(420px, 100%);
}
input[type="search"]{
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  outline: none;
  background: #fff;
}
input[type="search"]:focus{ box-shadow: var(--focus); border-color: rgb(from var(--principal) r g b / 0.35); }

.grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card{
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible; /* antes hidden */
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.02);
    display: grid;
    grid-template-rows: 180px 1fr;
    cursor: pointer;
    grid-template-columns: 150px 1fr;
    transition: opacity .2s ease, transform .2s ease;
    position: relative;
    z-index: 1;
}
.card:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card.hidden {
  opacity: 0;
  transform: translateY(6px) scale(.98);
  pointer-events: none;
  display: none;
}
.card.is-hidden,
.card.is-hidden-by-filter,
.card.is-hidden-by-order {
    display: none !important;
}
.cardImg{
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(17,17,17,0.05);
}
.cardBody{
  padding: 12px;
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 2;
}
.cardTitle{
  font-weight: 700;
  font-family: Montserrat, Inter, sans-serif;
  margin: 0;
  position: relative;
  padding-right: 15px;
}
.cardTitle::after {
    content: "›";
    font-size: 2.2rem;
    color: #000;
    position: absolute;
    top: 0;
    right: 0;
    font-weight: 100;
    line-height: 1rem;
}
.cardDesc{
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.25;
  min-height: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cardActions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.productMedia{
  overflow: hidden;
  border-top-left-radius: var(--radius);
  border-bottom-left-radius: var(--radius);
  position: relative;
}
.addCartForm {
    margin: 0;
}
.addToCartPrimary {
    border: 0;
    cursor: pointer;
    background: #aeb28d;
    color: #fff;
}
.cardRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.price{
  font-weight: 900;
}
.addToCart{
    border: none;
    background: var(--principal);
    color: #fff;
    font-weight: 900;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
}
.addToCart:hover{ background: var(--principal-2); }

/* Buttons */
.primaryBtn{
  border: none;
  background: var(--principal);
  color: #fff;
  font-weight: 900;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
}
.primaryBtn:hover{ background: var(--principal-2); }
.primaryBtn:focus{ outline: none; box-shadow: var(--focus); }
.ghostBtn{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--black);
  font-weight: 800;
  padding: 12px 14px;
  border-radius: 14px;
  cursor: pointer;
}
.ghostBtn:focus{ outline: none; box-shadow: var(--focus); }
.wide{ width: 100%; }

/* Modal */
.modal::backdrop{
  background: rgba(0,0,0,0.55);
}
.modalCard{
  width: min(860px, calc(100vw - 24px));
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  padding: 0;
  background: #fff;
  box-shadow: var(--shadow);
  max-width: 100%;
}
.modalHeader{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--border);
}
.modalTitle{
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 900;
  font-size: 1.125rem;
}
.modalDesc{
  color: var(--muted);
  font-size: 0.8125rem;
}
  .modalDesc > p{
    margin-top: 12px;
    margin-bottom: 0;
  }
.modalBody{
  padding: 14px;
  display: grid;
  gap: 14px;
}
.modalFooter{
  padding: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.pmHero{
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: stretch;
}
.pmHero img{
  width: 100%;
  max-height: 50vh;
  object-fit: cover;
  border-radius: 18px;
  background: rgba(17,17,17,0.05);
}
.pmPrice{
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
  background: linear-gradient(180deg, rgb(from var(--principal) r g b / 0.06), transparent);
}
.pmPrice span{ color: var(--muted); font-weight: 700; }
.pmPrice strong{ font-size: 1.375rem; }

.pmSection{
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  background: #fff;
}
.pmSectionTitle{
  font-weight: 900;
  font-family: Montserrat, Inter, sans-serif;
}
.pmHint{
  margin-top: 6px;
  font-size: 0.78125rem;
  color: var(--muted);
  line-height: 1.35;
}
.pmCols{
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pmSubTitle{
  font-weight: 900;
  margin-bottom: 8px;
}
.chipList{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip{
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.8125rem;
  user-select: none;
}
.chip.active{
  border-color: rgb(from var(--principal) r g b / 0.45);
  background: rgb(from var(--principal) r g b / 0.10);
}
.textareaLabel{
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-weight: 800;
  color: var(--black);
}
textarea{
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 10px;
  font: inherit;
  outline: none;
}
textarea:focus{ box-shadow: var(--focus); border-color: rgb(from var(--principal) r g b / 0.35); }

.qtyRow{
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.qtyBtn{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  font-weight: 900;
}
.qtyValue{
  min-width: 44px;
  text-align: center;
  font-weight: 900;
  font-size: 1.125rem;
}

/* Drawer cart */
.drawer{
  position: fixed;
  right: 0;
  top: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .18s ease;
  z-index: 40;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.drawer.open{ transform: translateX(0); }
.drawerHeader{
  padding: 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.drawerTitle{
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 900;
  font-size: 1.125rem;
}
.drawerSub{
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8125rem;
}
.drawerBody{
  padding: 14px;
  overflow: auto;
}
.drawerFooter{
  padding: 14px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}
.totalRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 1rem;
}
.cartList{
  display: grid;
  gap: 10px;
}
.cartItem{
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.cartTop{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.cartName{
  font-weight: 900;
  font-family: Montserrat, Inter, sans-serif;
}
.cartMeta{
  color: var(--muted);
  font-size: 0.78125rem;
  line-height: 1.3;
  margin-top: 4px;
}
.cartBottom{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cartQty{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.smallBtn{
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
}
.smallBtn.danger{
  border-color: rgba(165, 173, 133, 0.35);
}
.cartPrice{
  font-weight: 900;
}
.emptyState{
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.legal{
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

/* Checkout fields */
.checkoutCard{ width: min(640px, calc(100vw - 24px)); }
.fieldGrid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.fieldFull{ grid-column: 1 / -1; }
.field{
  display: grid;
  gap: 6px;
  font-weight: 800;
}
.field input{
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  outline: none;
  font: inherit;
}
.field input:focus{ box-shadow: var(--focus); border-color: rgb(from var(--principal) r g b / 0.35); }

.paySummary{
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, rgb(from var(--principal) r g b / 0.06), transparent);
}
.sumRow{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  font-weight: 900;
}
.sumRow.muted{
  font-weight: 700;
  color: var(--muted);
  font-size: 0.8125rem;
}
.sumRow[hidden]{
  display: none;
}

/* Toast */
.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  z-index: 60;
  background: #111;
  color: #fff;
  padding: 12px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 800;
  white-space: nowrap;
}

/* Expired overlay */
.expiredOverlay{
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0,0,0,0.62);
  display: grid;
  place-items: center;
  padding: 16px;
  display: none;
}
#expiredOverlay[hidden='hidden'] {
  display: none;
}
.expiredCard{
  width: min(520px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.expiredCard h2{
  margin: 0 0 8px;
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 900;
}
.expiredCard p{ margin: 0 0 12px; color: var(--muted); }

/* ******************************************************** */


/* =========================
   Location picker (FINAL)
   HTML esperat:
   <dialog id="locationModal" class="modal">
     <form class="modalCard">
       <div class="modalHeader">...</div>
       <div class="modalBody">
         <div class="searchWrap">...</div>
         <div id="locationList" class="locationList">
           <div class="restGroup">
             <div class="restCity">Barcelona</div>
             <div class="restGrid">
               <button class="restRow">...</button>
             </div>
           </div>
         </div>
       </div>
       <div class="modalFooter">...</div>
     </form>
   </dialog>
   ========================= */

#locationModal .modalCard{
  width: min(920px, calc(100vw - 24px));
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
}

/* Body en columna i amb scroll intern correcte */
#locationModal .modalBody{
  flex: 1;
  min-height: 0;              /* CLAAU per a scroll en flex */
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Search sticky dins del body (opcional però agradable) */
#locationModal .searchWrap{
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  padding-bottom: 12px;
}

/* Contenidor llista: ocupa tot l'espai restant i fa scroll */
#locationModal .locationList{
  flex: 1;
  min-height: 0;              /* CLAAU */
  overflow: auto;
  display: grid;
  gap: 14px;
  padding-right: 6px;
}

/* Grup per ciutat */
#locationModal .restGroup{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
}

/* Capçalera ciutat */
#locationModal .restCity{
  padding: 10px 14px;
  font-family: Montserrat, Inter, sans-serif;
  font-weight: 900;
  letter-spacing: .2px;
  background: rgba(17,17,17,0.03);
  border-bottom: 1px solid var(--border);
}

/* Grid de locals */
#locationModal .restGrid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  align-content: start;
}

@media (min-width: 900px){
  #locationModal .restGrid{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Targeta del local */
#locationModal .restRow{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  cursor: pointer;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  text-align: left;

  transition: transform .06s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

#locationModal .restRow:hover{
  background: rgb(from var(--principal) r g b / 0.06);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
}

#locationModal .restRow:active{
  transform: scale(.995);
}

#locationModal .restRow:focus{
  outline: none;
  box-shadow: var(--focus);
  border-color: rgb(from var(--principal) r g b / 0.35);
}

#locationModal .restMain{ min-width: 0; }

#locationModal .restName{
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 4px;
}

#locationModal .restHours{
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.25;
}

/* Chevron opcional */
#locationModal .restChevron{
  color: var(--muted);
  opacity: .8;
  font-size: 1.25rem;
  line-height: 1;
}

/* Seleccionat */
#locationModal .restRow.isSelected{
  border-color: var(--principal);
  box-shadow: 0 0 0 3px rgb(from var(--principal) r g b / 0.15);
  background: var(--principal) !important;
  color: #fff !important;
}
#locationModal .restRow.isSelected .restHours,
#locationModal .restRow.isSelected .restChevron {
  color: #fff !important;
}

/* FIX: evitar que els botons col·lapsin (es veien com ratlles) */
#locationModal .restRow{
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;

  padding: 12px !important;
  min-height: 70px !important;      /* clau */
  height: auto !important;

  font-size: 0.875rem !important;   /* clau si hi ha font-size:0 heretat */
  line-height: 1.2 !important;      /* clau si hi ha line-height:0 heretat */
  color: var(--text) !important;

  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  background: #fff !important;
}

/* Assegura que el contingut no col·lapsa */
#locationModal .restMain,
#locationModal .restName,
#locationModal .restHours{
  display: block !important;
}

#locationModal .restName{
  font-weight: 900 !important;
  margin: 0 0 4px 0 !important;
}

#locationModal .restHours{
  color: var(--muted) !important;
  font-size: 0.8125rem !important;
}

/* Grid: que no “s’estiri” raro i col·lapsi fills */
#locationModal .restGrid{
  align-content: start !important;
  align-items: start !important;
}

/* --- FIX: estable amb llista completa i filtrada --- */

/* No sticky: és el que trenca els càlculs quan hi ha molts grups */
#locationModal .searchWrap{
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  background: transparent !important;
  padding-bottom: 0 !important;
}

/* modalBody en grid: search a dalt, llista ocupa la resta */
#locationModal .modalBody{
  display: grid !important;
  grid-template-rows: auto 1fr !important;
  min-height: 0 !important;
}

/* La llista és L'ÚNIC scroll */
#locationModal .locationList{
  overflow: auto !important;
  min-height: 0 !important;
}

/* Quan la cerca és buida: assegura que els cards no col·lapsen */
#locationModal.search-empty .restRow{
  min-height: 70px;
  font-size: 0.875rem;
  line-height: 1.2;
}

#locationModal.search-empty .restName{ line-height: 1.15; }
#locationModal.search-empty .restHours{ line-height: 1.2; }

#pmRemoveList .chip.active {
  color: #721c24;
  background-color: #f8d7da;
  border-color: #f5c6cb;
}

#pmExtraList .chip.active {
  color: #155724;
  background-color: #d4edda;
  border-color: #c3e6cb;
}

select{
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  outline: none;
  background: #fff;
  font: inherit;
}
select:focus{ box-shadow: var(--focus); border-color: rgb(from var(--principal) r g b / 0.35); }

.modeGrid{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 860px){
  .modeGrid{ grid-template-columns: 1fr; }
}

#coModeGrid {
  grid-template-columns: 1fr;
}

.modeCard{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px 1fr 22px;
  gap: 12px;
  align-items: center;
  transition: box-shadow .12s ease, transform .06s ease, border-color .12s ease, background .12s ease;
  user-select: none;
}

.modeCard input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.modeIcon{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(165, 173, 133, 0.08);
  color: var(--principal);
  font-size: 1.125rem;
}

.modeTitle{
  font-weight: 900;
  line-height: 1.1;
}
.modeSub{
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 3px;
}

.modeCheck{
  opacity: 0;
  color: var(--principal);
  font-size: 1rem;
  justify-self: end;
}

.modeCard:hover{
  background: rgb(from var(--principal) r g b / 0.04);
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}

.modeCard:active{
  transform: scale(.995);
}

.modeCard:has(input:checked){
  border-color: rgb(from var(--principal) r g b / 0.45);
  box-shadow: 0 0 0 3px rgb(from var(--principal) r g b / 0.15);
  background: rgb(from var(--principal) r g b / 0.06);
}

.modeCard:has(input:checked) .modeCheck{
  opacity: 1;
}

.modeCard.active {
  background: var(--bg);
}
  .modeCard.active .modeIcon {
    background: var(--principal-2);
    color: #fff;
  }

.whenGrid{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 860px){
  .whenGrid{ grid-template-columns: 1fr; }
}

.whenCard{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px 1fr 22px;
  gap: 12px;
  align-items: center;
  transition: box-shadow .12s ease, transform .06s ease, border-color .12s ease, background .12s ease;
  user-select: none;
}

.whenCard input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.whenIcon{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(165, 173, 133, 0.08);
  color: var(--principal);
  font-size: 1.125rem;
}

.whenTitle{ font-weight: 900; line-height: 1.1; }
.whenSub{ color: var(--muted); font-size: 0.8125rem; margin-top: 3px; }

.whenCheck{
  opacity: 0;
  color: var(--principal);
  font-size: 1rem;
  justify-self: end;
}

.whenCard:hover{
  background: rgb(from var(--principal) r g b / 0.04);
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}
.whenCard:active{ transform: scale(.995); }

.whenCard:has(input:checked){
  border-color: rgb(from var(--principal) r g b / 0.45);
  box-shadow: 0 0 0 3px rgb(from var(--principal) r g b / 0.15);
  background: rgb(from var(--principal) r g b / 0.06);
}
.whenCard:has(input:checked) .whenCheck{ opacity: 1; }

/* si encara no tens estil per select */
select{
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 12px 12px;
  outline: none;
  background: #fff;
  font: inherit;
}
select:focus{ box-shadow: var(--focus); border-color: rgb(from var(--principal) r g b / 0.35); }

.processingOverlay{
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: grid;
  place-items: center;
  z-index: 10;
}
#processingOverlay[hidden]{
  display: none !important;
}

.processingCard{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 900;
}

.processingCard i{
  color: var(--principal);
  font-size: 1.375rem;
}

.processingText{
  font-size: 0.9375rem;
}

#btnLocation {
    display: inline-flex !important;
}


/* POPUP LOCAL OR ONLINE */

.orderTypeCard {
  max-width: 100%;
  padding-bottom: 10px;
}

.orderTypeGrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.orderTypeBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #eef1e6;
}

.orderTypeBarText {
    font-size: 14px;
}

.orderTypeBar button {
    border: 0;
    background: #aeb58d;
    color: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
}

.deliveryBadge {
    display: none; /* inline-flex; */
    align-items: center;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef1e6;
    color: #6f7656;
    font-size: 12px;
    font-weight: 700;
}

.card-hidden-by-order {
    display: none !important;
}

/* CHANGE VISIBILITY */

.confirmBox {
  background: #f7f7f2;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.confirmLabel {
  font-weight: 700;
  margin-bottom: 10px;
}

.confirmList {
  margin: 0;
  padding-left: 18px;
}

.confirmList li + li {
  margin-top: 6px;
}

.modalFooter {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px 20px;
}

.secondaryBtn,
.primaryBtn {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

.secondaryBtn {
  background: #ecece6;
}

.primaryBtn {
  background: #a5ad85;
  color: #fff;
}

.primaryBtn.danger {
  background: #111;
  color: #fff;
}

.shippingAddressRow {
  margin-top: 12px;
}

.shippingAddressCard {
  background: #f7f7f2;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.shippingAddressHeader {
  margin-bottom: 6px;
}

.shippingAddressLabel {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 15px;
  margin-top: 30px;
}

.shippingAddressText {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
}

.shippingFields > * {
  margin-bottom: 12px;
}

/* TOAST */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;

  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 9999;

  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* visible */
#toast:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* animació suau d'entrada */
#toast[hidden] {
  transform: translateX(-50%) translateY(10px);
}

/* MENU */

.menuOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.38);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  z-index: 90;
}

.menuOverlay.active {
  opacity: 1;
  visibility: visible;
}

.sideMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: calc(100vw - 32px);
  height: 100vh;
  background: #fff;
  transform: translateX(-100%);
  transition: transform .28s ease;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
}

.sideMenu.expanded {
  width: 100vw;
  max-width: 100vw;
}
  .sideMenu.expanded .menuPage {
    padding: 20px;
  }

.sideMenu.active {
  transform: translateX(0);
}

.menuHeader {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #ececec;
}

.menuHeader strong {
  text-align: center;
}

.menuBody {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.menuView {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  background: #fff;
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}

.menuView.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.menuContent,
.menuPage {
  padding: 12px;
}
.menuContent img,
.menuPage img {
  width: 100%;
  margin: 0 auto;
  display: block;
}

.menuItem {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.menuItem:hover {
  background: #f5f5f5;
}

.menuDivider {
  height: 1px;
  background: #ededed;
  margin: 10px 0;
}

.menuTitleSmall {
  font-size: 12px;
  font-weight: 700;
  opacity: .55;
  padding: 10px 12px 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.is-hidden {
  visibility: hidden;
}

body.menu-open {
  overflow: hidden;
}

.menuPage h3 {
  margin: 0 0 12px;
}

.menuPage p,
.menuPage li {
  line-height: 1.45;
}

.contactTitle {
  margin: 0 0 16px;
  font-size: 18px;
}

.contactCard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contactItem {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 14px;
  background: #f7f7f7;
  text-decoration: none;
  color: inherit;
  transition: 0.2s;
}

.contactItem:hover {
  background: #ecefdf; /* tono oliva suave */
}
  .contactItem a {
    padding: 0;
  }

.icon {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}

.label {
  font-size: 12px;
  opacity: 0.6;
}

.value {
  font-size: 14px;
  font-weight: 500;
}

.contactIntro {
  margin-bottom: 14px;
  line-height: 1.4;
  opacity: 0.85;
}

.contactItem {
  background: #f4f4f4;
}

.contactItem:hover {
  background: #e9eddc; /* tono oliva */
}

.contactItem.whatsapp {
  background: #e6f7ed;
}

#infoModal .modalTitle i {
  color: var(--principal);
  margin-right: 8px;
}

#infoModalBody {
  white-space: normal;
  line-height: 1.5;
}

#infoModalBody ul {
  margin: 0;
  padding-left: 18px;
}

#infoModalBody li + li {
  margin-top: 6px;
}

.minSaleBadge {
  position: relative;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;

  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid transparent;

  font-size: 12px;
  font-weight: 700;
  line-height: 1;

  cursor: help;
  transition: transform .15s ease, box-shadow .15s ease;
  pointer-events: auto;
}

.minSaleBadge:hover,
.minSaleBadge:focus {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.10);
  outline: none;
}

.minSaleBadge i {
  font-size: 12px;
}

.minSaleBadge span {
  white-space: nowrap;
}

.minSaleBadgeInfo {
  opacity: .7;
}

/* Paleta por grupo */
.minSaleBadge--1 {
  background: #eef7ea;
  border-color: #d5e7c8;
  color: #5f7d49;
}

.minSaleBadge--2 {
  background: #eef4fb;
  border-color: #d2e0f3;
  color: #4e6f98;
}

.minSaleBadge--3 {
  background: #fbf3e8;
  border-color: #eed7b3;
  color: #9a6d2f;
}

.minSaleBadge--4 {
  background: #f7edf7;
  border-color: #e2cde3;
  color: #7f5b88;
}

.minSaleBadge--5 {
  background: #edf8f5;
  border-color: #cce7dc;
  color: #4f7d6d;
}

.minSaleBadge--6 {
  background: #fbeff0;
  border-color: #efcfd4;
  color: #9a5d67;
}

/* Tooltip custom */
.minSaleBadge[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 50;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(6px);

  min-width: 220px;
  max-width: 280px;
  width: max-content;

  padding: 10px 12px;
  border-radius: 12px;

  background: rgba(17, 17, 17, 0.96);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
  text-align: left;

  box-shadow: 0 10px 24px rgba(0,0,0,0.18);

  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: opacity .18s ease, transform .18s ease;
}

.minSaleBadge[data-tooltip]::before {
  content: "";
  position: absolute;
  z-index: 50;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);

  border-width: 6px;
  border-style: solid;
  border-color: rgba(17, 17, 17, 0.96) transparent transparent transparent;

  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.minSaleBadge[data-tooltip]:hover::after,
.minSaleBadge[data-tooltip]:hover::before,
.minSaleBadge[data-tooltip]:focus::after,
.minSaleBadge[data-tooltip]:focus::before {
  opacity: 1;
}

.minSaleBadge[data-tooltip]:hover::after,
.minSaleBadge[data-tooltip]:focus::after {
  transform: translateX(-50%) translateY(0);
} 

.menuGroup {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.menuTitleSmall {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #8a8a8a;
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.menuItem {
    display: flex;
    align-items: center;
    padding: 10px 0;
    text-decoration: none;
    color: #222;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
}

.menuItem.is-active {
    font-weight: 700;
}

.languageList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.languageItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: #1f1f1f;
    background: transparent;
    transition: background .2s ease, color .2s ease;
}

.languageItem:hover {
    background: rgba(0, 0, 0, 0.05);
}

.languageItem.is-active {
    background: #f1f3e8;
    font-weight: 700;
    color: #111;
}

.languageName {
    display: block;
    line-height: 1.2;
}

.languageCheck {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: #8b9167;
    color: #fff;
    font-size: 11px;
    flex-shrink: 0;
}

.menuDivider {
    margin: 18px 0;
}

.menuTitleSmall {
    display: block;
    margin: 0 0 10px 0;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #b0b0b0;
}

/*

STRIPE

*/

#payment-message {
  display: none; /* amagat per defecte */
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
}

/* estat error */
#payment-message.error {
  display: block;
  background-color: #fdecea;
  color: #c0392b;
  border: 1px solid #e74c3c;
}

/* estat èxit */
#payment-message.success {
  display: block;
  background-color: #eafaf1;
  color: #1e8449;
  border: 1px solid #2ecc71;
}


/* ******************************************************** */

/* --- MOBILE: assegura que el selector de local (#btnLocation) es vegi --- */
@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: 50px 1fr 188px;
    grid-template-areas:
      "menu brand cart"
      "rest rest rest";
    row-gap: 10px;
    align-items: center;
  }

  #btnMenu { grid-area: menu; }
  .brand   { grid-area: brand; justify-self: center; }
  .topbarRight { grid-area: cart; justify-self: end; display: flex; gap: 10px; }

  /* el botó de location passa a una segona fila i ocupa tot l'ample */
  #btnLocation {
    grid-area: rest;
    display: inline-flex !important;
    width: 100%;
    justify-content: center;
    white-space: nowrap;
  }

  /* evita que es talli el text intern */
  #locationName {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}


/* Responsive */
@media (min-width: 1300px){
  #productGrid.grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1500px){
  #productGrid.grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1020px){
  .grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px){
  .layout{ grid-template-columns: 1fr; }
  .categories{
    position: relative;
    top: 0;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .catList{
    flex-direction: row;
    overflow: auto;
    padding-bottom: 6px;
  }
  .catBtn{ white-space: nowrap; }
  .pmHero{ grid-template-columns: 1fr; }
  .pmCols{ grid-template-columns: 1fr; }
  .asideFooter{
    display: none;
  }
}
@media (max-width: 520px){
  .brandLogo{ font-size: 1.375rem; }
  .grid{ grid-template-columns: 1fr; }
  .topbarRight #btnLocation{ display: none; }
  .fieldGrid{ grid-template-columns: 1fr; }
}