/* סל זול — עיצוב לאפליקציה: רקע נייר חם, כרטיסים לבנים, עוגן נייבי למעלה.
   כלל ברזל: אפס אנימציות, אפס גרדיאנטים, אפס צללים. RTL, Heebo.
   הניווט הוא סרגל תחתון (כמו אפליקציה). */

:root {
  /* הרקע הוא *נייר* ולא לבן: הכרטיסים הלבנים עולים ממנו בזכות הפרש הגוון
     בלבד — בלי צל ובלי גרדיאנט. זה מה שנותן עומק בעיצוב מודפס. */
  --bg: #F4F1EA;
  --card: #FFFFFF;
  --ink: #14181D;
  --navy: #16233A;
  --muted: #7A828C;
  --line: #E4E0D6;
  --line-soft: #EFECE4;
  --gold: #8A6420;
  --gold-soft: #F3EBD8;
  --green: #0E7040;
  --green-soft: #EDF5F0;
  --red: #A83A2C;
  --red-soft: #FBF1EF;
  --radius: 10px;
  --shadow: none;
  --tabbar-h: 60px;
  /* אריג עדין מאוד (SVG חוזר, סטטי) — טקסטורה של נייר, לא אפקט:
     אין אנימציה, אין גרדיאנט, ולא זז כלום. נותן חיים לרקע השטוח. */
  --paper: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14'><g fill='none' stroke='%23000' stroke-opacity='.028' stroke-width='1'><path d='M0 .5h14M0 7.5h14'/><path d='M.5 0v14M7.5 0v14'/></g></svg>");
  --icon-search: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Heebo', -apple-system, Segoe UI, Arial, sans-serif;
  background: var(--paper) repeat, var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.wrap { width: min(760px, 100% - 26px); margin-inline: auto; }
/* מרווח תחתון = גובה סרגל הניווט + בטיחות מסך (iPhone) */
main.wrap { flex: 1; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 20px); }
.hidden { display: none !important; }

/* ---------- כותרת עליונה: לוגו על רקע הנייבי שלו ----------
   הלוגו יושב בתוך שדה כהה משלו — זה נותן לאפליקציה עוגן ברור למעלה
   ומונע את התחושה ה"שטוחה" של לבן על לבן. צבע אחד, בלי גרדיאנט. */
.topbar { background: var(--navy); position: sticky; top: 0; z-index: 40; }
.topbar-in { display: flex; align-items: center; gap: 10px; padding: 8px 0 9px; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo-mark { height: 34px; width: auto; display: block; }
.logo-word { height: 18px; width: auto; display: block; }
.topbar-city { margin-inline-start: auto; font-size: 12.5px; color: #9AA8BE; }

/* ---------- סרגל ניווט תחתון ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar .tab {
  flex: 1; font: inherit; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; color: var(--muted); font-size: 11px; font-weight: 500;
}
.tabbar .tab svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.tabbar .tab.active { color: var(--ink); font-weight: 700; }

/* ---------- כלליים ---------- */
.screen { display: none; padding-top: 14px; }
.screen.active { display: block; }

/* .card הוא מעטפת-פריסה בלבד (חיפוש, כותרת מסך). הרקע הלבן שמור
   לכרטיסים האמיתיים — מוצר, סניף, מדף — שעולים מהנייר. */
.card { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.pad { padding: 0; }
.sec-title { font-size: 19px; font-weight: 800; margin: 20px 0 3px; }
.sec-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; max-width: 640px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- קלטים, כפתורים ----------
   אייקון הזכוכית מצויר ב-CSS (mask) ולא כתמונה, כדי שיישאר חד בכל מסך
   ויקבל את צבע הטקסט. הוא דקורטיבי בלבד — לכן לא בתוך ה-DOM. */
.search-line { position: relative; }
.search-line::before {
  content: ''; position: absolute; inset-inline-start: 13px; top: 50%;
  transform: translateY(-50%); width: 17px; height: 17px; background: #9AA0A8;
  pointer-events: none;
  -webkit-mask: var(--icon-search) center/contain no-repeat;
  mask: var(--icon-search) center/contain no-repeat;
}
/* padding לוגי ולא צדדי: ב-RTL הטקסט מתחיל מימין, ושם יושב האייקון */
/* על רקע הנייר, שדה החיפוש לבן — בולט במקום להיבלע */
.input {
  width: 100%; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; padding-inline-start: 38px;
  background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--navy); outline-offset: -2px; }
.input::placeholder { color: #9AA0A8; }
.btn-primary {
  font: inherit; font-weight: 700; font-size: 16px; color: #fff;
  background: var(--navy); border: 0; border-radius: var(--radius);
  padding: 13px 24px; cursor: pointer; margin-top: 12px; width: 100%;
}
/* כפתור כבוי = מסגרת ריקה, לא גוש אפור כבד על הנייר. */
.btn-primary:disabled {
  background: #fff; color: var(--muted);
  border: 1px solid var(--line); cursor: default;
}
.btn-ghost {
  font: inherit; font-weight: 600; font-size: 15px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 24px; cursor: pointer;
}
.load-more-wrap { text-align: center; margin-top: 18px; }

.suggest {
  position: absolute; z-index: 30; margin-top: 5px;
  inset-inline: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.sug-row { display: flex; align-items: center; gap: 10px; padding: 10px 13px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.sug-row:last-child { border-bottom: 0; }
.sug-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
.sug-meta { font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips:empty { margin: 0; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; color: #5C6470; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.chip.filter { background: #fff; color: #5C6470; }
.chip.filter.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- מוצרים: כרטיס נפרד לכל שורה (קל ללחוץ בלי לטעות) ---------- */
.prod-row {
  display: grid; grid-template-columns: 48px 1fr auto 28px; gap: 10px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 7px; cursor: pointer;
}
.prod-img, .pimg {
  width: 48px; height: 48px; border-radius: 6px; object-fit: contain; background: #fff;
}
.img-ph {
  width: 48px; height: 48px; border-radius: 6px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: #A9AFB6;
}
.fam-img.img-ph { width: 44px; height: 44px; }
.prod-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.prod-meta { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.prod-side { text-align: left; white-space: nowrap; }
.prod-price { font-weight: 800; font-size: 17px; }
.prod-store { font-size: 11.5px; color: var(--green); font-weight: 700; }
.prod-range { font-size: 11px; color: var(--muted); }

/* ---------- סניפים ---------- */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 7px; }
.store-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.store-chain { font-weight: 800; font-size: 15.5px; }
.store-name { color: var(--muted); font-size: 12.5px; margin: 1px 0 7px; }
.store-stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.store-stats b { color: var(--ink); }
.note { margin-top: 14px; font-size: 13px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 13px; }
.note strong { color: var(--ink); }

/* ---------- חלון מוצר: גיליון שנפתח מלמטה (כמו אפליקציה) ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-back { position: absolute; inset: 0; background: rgba(20,24,29,.45); }
.modal-card {
  position: relative; background: #fff; border-radius: 14px 14px 0 0; width: min(560px, 100%);
  max-height: 88vh; overflow: auto; padding: 20px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
.modal-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.modal-head .pimg { width: 64px; height: 64px; }
.modal-title { font-size: 16.5px; font-weight: 800; line-height: 1.3; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.mrow { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.mrow:last-child { border-bottom: 0; }
.mrow.cheapest { background: var(--green-soft); border-radius: 7px; padding-inline: 9px; border-bottom: 0; }
.mrow-store { font-size: 14px; font-weight: 600; }
.mrow-substore { font-size: 11.5px; color: var(--muted); }
.mrow-price { font-weight: 800; font-size: 15.5px; }
.mrow.cheapest .mrow-price { color: var(--green); }
.mrow-diff { font-size: 11px; color: var(--muted); }
.modal-close {
  position: absolute; top: 12px; inset-inline-start: 12px;
  border: 0; background: var(--bg); color: var(--muted); width: 30px; height: 30px;
  border-radius: 50%; font-size: 16px; cursor: pointer; font-family: inherit;
}

/* ---------- טעינה ---------- */
.loader { position: fixed; bottom: calc(var(--tabbar-h) + 12px); inset-inline: 0; margin-inline: auto; width: min(320px, 90%); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 15px; z-index: 60; font-size: 13px; color: var(--muted); text-align: center; }
.loader-bar { height: 4px; background: var(--line-soft); border-radius: 3px; overflow: hidden; margin-bottom: 7px; }
#loaderFill { height: 100%; width: 15%; border-radius: 3px; background: var(--navy); }
.skeleton { background: var(--line-soft); border-radius: var(--radius); }

/* ---------- פוטר ---------- */
.footer { border-top: 1px solid var(--line); padding: 14px 0 18px; color: var(--muted); font-size: 12px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.footer .by-nx { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; margin-inline-start: auto; }
.footer .by-nx b { font-weight: 600; color: var(--ink, inherit); }
.footer .by-nx svg { flex: none; border-radius: 4px; }

/* ---------- מובייל ---------- */
@media (max-width: 640px) {
  .logo-mark { height: 30px; }
  .logo-word { height: 16px; }
  .store-grid { grid-template-columns: 1fr; }
}

/* ---------- מבצעים ---------- */
.sale-tag {
  display: inline-block; background: var(--green); color: #fff;
  font-size: 10.5px; font-weight: 800; border-radius: 6px;
  padding: 1px 7px; margin-inline-start: 6px; vertical-align: 2px;
}
.mrow-promo { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.mrow-promo.applied { color: var(--green); font-weight: 600; }

/* ---------- משפחות מוצרים ---------- */
.group-row { border-inline-start: 1px solid var(--line); }
.fam-badge {
  display: inline-block; background: var(--gold-soft); color: var(--gold);
  font-size: 10.5px; font-weight: 700; border-radius: 4px;
  padding: 1px 6px; margin-inline-start: 5px; vertical-align: 2px;
}
.fam-chips { margin: 4px 0; }
/* שורת סינון בתוך המדף: "הכשר" / "חברה" עם הכפתורים לצידה */
.fam-filter-row { display: flex; align-items: center; gap: 9px; margin: 9px 0; }
.fam-filter-label {
  flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--muted);
  padding-top: 2px;
}
.fam-filter-row .chips { flex: 1 1 auto; overflow-x: auto; }
/* טבלת "המחיר בכל חנות" בתוך חלון המשפחה */
.fam-stores-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 9px;
  font-weight: 700; font-size: 14px; color: var(--ink);
  margin: 15px 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.fam-stores-count { font-weight: 500; font-size: 11.5px; color: var(--muted); }
.fam-stores { max-height: 46vh; overflow-y: auto; }
.fam-stores .mrow { cursor: pointer; }
.fam-variant {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fam-list { max-height: 60vh; overflow-y: auto; }
.fam-item {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; border-radius: 7px;
}
.fam-item.cheapest { background: var(--green-soft); }
.fam-img { width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: #fff; }
.fam-name { font-size: 14px; font-weight: 600; }
.fam-meta { font-size: 11.5px; color: var(--muted); }
.fam-price { font-size: 16px; font-weight: 800; }
/* המחיר לק"ג — ההשוואה האמיתית בין אריזה של 400 גרם לאריזה של 1 ק"ג */
.fam-unit { font-size: 11px; font-weight: 700; color: var(--green); text-align: left; }
.fam-store { font-size: 11.5px; color: var(--muted); text-align: left; }
.modal-back-btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  background: transparent; border: 0; cursor: pointer; padding: 0 0 8px;
}

/* ---------- טריות הנתונים ---------- */
.fresh-banner {
  margin-bottom: 10px; font-size: 13px; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 13px;
}
.fresh-banner b { color: var(--ink); }
.store-fresh {
  margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--line-soft);
  font-size: 12px; font-weight: 600;
}
.store-fresh.ok { color: var(--green); }
.store-fresh.warn { color: var(--gold); }
.store-fresh.bad { color: var(--red); }

/* ---------- תיקון גלישה במובייל ----------
   בפריסות grid/flex ברירת המחדל היא min-width:auto, ולכן תוכן רחב
   (שורת הקטגוריות, שם מוצר ארוך) הרחיב את כל העמוד וגרם לו לגלוש הצידה:
   הלוגו נחתך ותמונות המוצרים נדחפו מחוץ למסך. */
html, body { max-width: 100%; }
.chips-scroll { max-width: 100%; min-width: 0; }
.prod-row > *, .fam-item > *, .mrow > * { min-width: 0; }
.prod-name, .prod-meta, .fam-name, .fam-meta,
.mrow-store, .mrow-substore { overflow-wrap: anywhere; }
.topbar-in, .store-card { min-width: 0; }

@media (max-width: 640px) {
  .wrap { width: calc(100% - 20px); }
  /* עמודת הלב לוקחת רוחב משם המוצר — לכן במסך צר התמונה והמרווחים
     מתכווצים מעט, כדי שהשמות ימשיכו להיכנס בשורה אחת. */
  .prod-side { min-width: 66px; }
  .prod-row { gap: 7px; grid-template-columns: 44px 1fr auto 24px; }
  .prod-row .prod-img, .prod-row .img-ph { width: 44px; height: 44px; }
  .fav-btn { width: 24px; height: 24px; }
  .fav-btn svg { width: 20px; height: 20px; }
}

/* ---------- המוצרים שאני אוהב ----------
   לב אחד ליד כל מוצר. סימון = המוצר עולה לראש מסך המוצרים, ובמסך
   המבצעים נכתב עליו מיד אם הוא במבצע או לא. נשמר בדפדפן של המשתמש. */
.fav-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  color: #C6CBD1; font-family: inherit;
}
.fav-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.fav-btn.on { color: var(--red); }
.fav-btn.on svg { fill: currentColor; }
.fav-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 9px;
  font-weight: 800; font-size: 14.5px; margin: 2px 2px 8px;
}
.fav-head small { font-weight: 500; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.fav-empty {
  font-size: 12.5px; color: var(--muted); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
}
.fav-empty b { color: var(--red); }
.fav-status { font-size: 11.5px; margin-top: 2px; }
.fav-status.on { color: var(--green); font-weight: 700; }
.fav-status.off { color: var(--muted); }
/* טקסט המבצע של הרשת ארוך ולא אחיד — חותכים אחרי שתי שורות */
.fav-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#favProducts:not(:empty) {
  display: block; margin-bottom: 15px; padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
/* בתוך חלון המוצר הכפתור מקבל מילים, כדי שיהיה ברור מה הוא עושה */
.fav-line {
  display: inline-flex; align-items: center; gap: 7px; font: inherit;
  font-size: 13.5px; font-weight: 700; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; margin-bottom: 12px;
}
.fav-line svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.fav-line.on { color: var(--red); border-color: #E6CEC9; }
.fav-line.on svg { fill: currentColor; }

/* ---------- קבוצות מקופלות בתוך מחלקה ---------- */
.grp {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 7px; overflow: hidden;
}
.grp-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 13px; cursor: pointer; user-select: none;
}
.grp-name { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.grp-name small { color: var(--muted); font-weight: 400; font-size: 12px; margin-inline-start: 7px; }
.grp-arrow { color: var(--muted); font-size: 12px; }
.grp.open .grp-arrow { transform: rotate(180deg); }
.grp-body { display: none; border-top: 1px solid var(--line); padding: 6px 8px; }
.grp.open .grp-body { display: block; }
.grp-body .prod-row { border: none; border-bottom: 1px solid var(--line-soft); border-radius: 0; margin-bottom: 0; padding: 9px 5px; }
.grp-body .prod-row:last-child { border-bottom: none; }

/* ---------- מסך מבצעים ---------- */
.deal-head {
  font-weight: 800; font-size: 14px; color: var(--ink);
  margin: 14px 2px 7px;
}
.deal-head:first-child { margin-top: 4px; }
.deal-row .prod-name { line-height: 1.3; }
.deal-row .prod-meta { color: var(--muted); }
.deal-branch .grp-head, .deal-cat .grp-head { cursor: pointer; }
.deal-back {
  display: inline-block; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13.5px; font-weight: 600; font-family: inherit;
  padding: 5px 2px 9px;
}
