:root {
  --bg: #f6f7f5; --surface: #fff; --text: #1c2321; --muted: #5d6b67; --border: #dde3e0;
  --accent: #0f766e; --accent-ink: #fff; --accent-soft: #e0f2ef; --warn: #b45309; --warn-soft: #fef3c7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111615; --surface: #1a2120; --text: #e7ecea; --muted: #9aa8a4; --border: #2c3634;
    --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #123430; --warn: #fbbf24; --warn-soft: #3a2d0f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
header { padding: calc(16px + env(safe-area-inset-top)) 16px 8px; max-width: 720px; margin: auto; }
h1 { margin: 0; font-size: 1.4rem; }
h3 { margin: 0 0 8px; font-size: 1.05rem; }
.muted { color: var(--muted); }
#status { margin: 4px 0 0; font-size: .9rem; }

nav { display: flex; gap: 4px; max-width: 720px; margin: 8px auto 0; padding: 0 16px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
nav button { flex: 1; border: 0; background: none; color: var(--muted); padding: 10px 4px; font: inherit; font-weight: 600; border-bottom: 3px solid transparent; cursor: pointer; }
nav button[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }

main { max-width: 720px; margin: auto; padding: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row input { flex: 1; min-width: 0; }
input, textarea, button, .file {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
textarea { width: 100%; resize: vertical; }
button, .file { cursor: pointer; font-weight: 600; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .6; cursor: progress; }
input[type=range] { width: 100%; padding: 0; accent-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 16px 0; }
.card p { margin: 4px 0 8px; }

#items { list-style: none; padding: 0; margin: 8px 0; }
#items li { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px 12px; margin-bottom: 6px; }
#items li input { flex: 1; border: 0; padding: 6px 0; background: none; }
#items li button { border: 0; background: none; color: var(--muted); padding: 6px; font-size: 1.1rem; }

.group h2 { font-size: 1rem; margin: 20px 0 8px; }
.deal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.deal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.price { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.price s { font-size: .85rem; color: var(--muted); font-weight: 400; margin-inline-start: 6px; }
.chain { font-weight: 600; }
.product { margin-top: 2px; }
.desc { font-size: .9rem; }
.meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: .9rem; }
.until { background: var(--accent-soft); border-radius: 6px; padding: 1px 8px; }
.until.soon { background: var(--warn-soft); color: var(--warn); }
.badge { white-space: nowrap; display: inline-block; font-size: .75rem; border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; margin-inline-start: 6px; color: var(--muted); }
.empty { text-align: center; padding: 32px 8px; }
#chains label { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
details { margin-top: 16px; font-size: .9rem; color: var(--muted); }

.small { font-size: .85rem; margin: 2px 0 0; }
.toggle { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.toggle input { margin-top: 5px; accent-color: var(--accent); }
.desc a { color: var(--accent); }
#toast {
  position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: 520px; margin: auto;
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 5; box-shadow: 0 4px 16px rgb(0 0 0 / .2);
}

body.logged-out header, body.logged-out nav, body.logged-out main { display: none; }
body:not(.logged-out) #login { display: none; }
#login { max-width: 420px; margin: 0 auto; padding: calc(32px + env(safe-area-inset-top)) 16px; }
#login h1 { margin-bottom: 4px; }
label { display: block; margin: 8px 0; }
[hidden] { display: none !important; }
label > input:not([type=checkbox]):not([type=range]):not([type=file]) { display: block; width: 100%; margin-top: 4px; }
form > button { margin-top: 8px; }
.error { color: #b91c1c; }
@media (prefers-color-scheme: dark) { .error { color: #fca5a5; } }
#family { list-style: none; padding: 0; margin: 8px 0; }
#family li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
#family li .who { flex: 1; min-width: 0; }
#family li .acts { display: flex; gap: 6px; }
#family li button { padding: 6px 10px; font-size: .9rem; }

.food { font-size: 1.5rem; line-height: 1; width: 2rem; text-align: center; flex: none; }
.hero { text-align: center; margin: 0 0 8px; }
.hero svg { width: 100%; max-width: 260px; height: auto; display: block; margin: 0 auto; }
.hero p { margin: 0; font-weight: 600; color: var(--muted); }
.h-shadow { fill: var(--border); }
.h-bag { fill: var(--accent); }
.h-handle { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; }
.h-milk { fill: #e8f1fb; stroke: #7aa7d6; stroke-width: 2; }
.h-milk-top { fill: #7aa7d6; }
.h-apple { fill: #e5484d; }
.h-stem { fill: none; stroke: #2f855a; stroke-width: 3; stroke-linecap: round; }
.h-baguette { fill: #d9a35b; }
.h-tag { fill: #fbbf24; }
.h-hole { fill: var(--bg); }
.h-pct { font: 700 22px system-ui, sans-serif; fill: #7c2d12; }
.h-spark { fill: #fbbf24; }

#report { margin-top: 16px; }
#report summary { font-weight: 600; cursor: pointer; color: var(--text); }
#report h4 { margin: 12px 0 4px; font-size: .95rem; }
#report p { margin: 6px 0; }
.report-list { margin: 0; padding-inline-start: 18px; }
.report-list li { margin: 4px 0; }
.warn { color: var(--warn); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#gear {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 8px 12px; border-radius: 999px; font-size: .95rem; color: var(--muted);
}
#gear svg { width: 20px; height: 20px; fill: currentColor; transition: transform .3s; }
#gear:hover svg { transform: rotate(45deg); }
#gear[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (max-width: 360px) { #gear span { display: none; } }

.count { display: inline-block; min-width: 1.4em; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; line-height: 1.4em; }
#homeList { list-style: none; padding: 0; margin: 8px 0; }
.homeitem { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; }
.homeitem .check { flex: none; width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--accent); background: none; color: var(--accent-ink); font-size: 1rem; }
.homeitem.done .check { background: var(--accent); }
.hbody { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.htext { display: flex; flex-direction: column; min-width: 0; font-size: 1.05rem; }
.htext small { font-size: .8rem; }
.homeitem.done .htext > span:first-child { text-decoration: line-through; color: var(--muted); }
.homeitem.done .food { opacity: .5; }
.onsale { color: var(--warn); font-weight: 600; }
.mini { flex: none; border: 0; background: none; padding: 6px; font-size: 1rem; color: var(--muted); }
nav button { font-size: .95rem; line-height: 1.25; }
#family li .acts { flex-wrap: wrap; }

.voice-row { margin-top: 0; }
.voice-row button { padding: 8px 12px; }
button.live { background: #dc2626; border-color: #dc2626; color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.mini.play { font-size: 1.1rem; color: var(--accent); }

.linkbox { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.linkbox code { flex: 1; min-width: 0; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .9rem; text-align: left; }
.linkbox button { padding: 8px 12px; }
.dup { margin: 0 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: .9rem; }
.homeitem.flash { animation: flash 1s ease-in-out 2; }
@keyframes flash { 50% { background: var(--warn-soft); border-color: var(--warn); } }

.source { margin-top: 6px; }
.source a { color: var(--accent); font-weight: 600; text-decoration: none; }
.source a:hover { text-decoration: underline; }
button.onsale { display: block; text-align: start; border: 0; background: none; padding: 2px 0; font: inherit; font-size: .8rem; color: var(--warn); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
#dealSheet { width: min(560px, calc(100vw - 24px)); max-height: 85vh; border: 1px solid var(--border); border-radius: 16px; padding: 16px; background: var(--bg); color: var(--text); }
#dealSheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head h3 { margin: 0; }
#sheetClose { border: 0; background: none; font-size: 1.2rem; padding: 4px 8px; color: var(--muted); }

.statusrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.statusrow #status { margin: 0; flex: 1; min-width: 180px; }
#locBtn { padding: 6px 12px; border-radius: 999px; font-size: .85rem; flex: none; }

.mic { flex: none; width: 44px; padding: 10px 0; font-size: 1.15rem; line-height: 1; }
.mic.live { width: auto; padding: 10px 12px; }
#voiceHint:empty { display: none; }

#toast { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#toast[hidden] { display: none; }
.toast-action { flex: none; border: 0; background: none; color: var(--accent); font-weight: 700; padding: 4px 8px; }
@media (prefers-color-scheme: light) { .toast-action { color: #5eead4; } }

#limitsBox { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }
#limitsBox h4 { margin: 8px 0 0; font-size: .95rem; }
#maxUsers { max-width: 120px; }

/* הלשונית הפעילה: רקע מלא בצבע הראשי */
nav { gap: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
nav button { border-radius: 12px; border-bottom: 0; padding: 10px 6px; transition: background .15s, color .15s; }
nav button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px rgb(0 0 0 / .15); }
nav button[aria-selected="true"] .count { background: var(--accent-ink); color: var(--accent); }

/* לשוניות לא פעילות: מסגרת ורקע, כדי שיהיה ברור שאפשר ללחוץ עליהן */
nav button { border: 1.5px solid var(--border); background: var(--surface); color: var(--text); }
nav button[aria-selected="true"] { border-color: var(--accent); }
nav button:not([aria-selected="true"]) { border-color: #a9bdb7; box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
@media (prefers-color-scheme: dark) { nav button:not([aria-selected="true"]) { border-color: #4b5f5a; } }
/* ריחוף רק במכשירים עם עכבר (בטלפון „ריחוף” נשאר דבוק אחרי לחיצה), ולעולם לא על הלשונית הפעילה */
@media (hover: hover) {
  nav button:not([aria-selected="true"]):hover { border-color: var(--accent); background: var(--accent-soft); }
}
/* הלשונית הפעילה תמיד בצבע הראשי של האפליקציה */
nav button[aria-selected="true"], nav button[aria-selected="true"]:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

#maxUsersForm label { margin-bottom: 0; }
#maxUsersForm .row { margin-top: 4px; flex-wrap: nowrap; }
#maxUsersForm input { max-width: 110px; flex: none; }
#maxUsersForm button:disabled { opacity: .45; cursor: default; }
.saved { color: var(--accent); font-weight: 700; }

.share { display: inline-flex; align-items: center; gap: 6px; }
.share svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share svg.android circle { fill: currentColor; stroke: none; }
.share.is-ios svg.android, .share.is-other svg.ios { display: none; }
.linkbox code { flex: 1 1 100%; }

#addUser h4 { margin: 16px 0 0; font-size: .95rem; border-top: 1px solid var(--border); padding-top: 12px; }
/* כפתור עדכון המיקום בולט בכתום */
#locBtn { background: #ea580c; border-color: #ea580c; color: #fff; font-weight: 700; box-shadow: 0 2px 6px rgb(234 88 12 / .35); }
#locBtn:hover { background: #c2410c; border-color: #c2410c; }
#locBtn:disabled { opacity: .7; }

/* תנאי שימוש */
.legal-links { text-align: center; margin: 12px 0 0; }
.legal-links a { color: var(--accent); }
#termsDlg { width: min(480px, calc(100vw - 24px)); border: 1px solid var(--border); border-radius: 16px; padding: 20px; background: var(--surface); color: var(--text); }
#termsDlg::backdrop { background: rgb(0 0 0 / .55); }
#termsDlg a { color: var(--accent); font-weight: 600; }
#termsDlg button { width: 100%; margin-top: 12px; }
button.danger { background: #b91c1c; color: #fff; border-color: #b91c1c; margin-top: 8px; }

/* נתוני שימוש */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.kpi { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .8rem; }
.chart { position: relative; direction: ltr; margin: 4px 0 16px; padding-top: 18px; }
.chart .ymax { position: absolute; top: 0; left: 0; }
.chart .plot { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--border); }
.chart .col { flex: 1; max-width: 24px; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline: none; }
.chart .col i { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; }
.chart .col.on i, .chart .col:focus-visible i { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.chart .axis { display: flex; justify-content: space-between; margin-top: 4px; }
.chart .tip { position: absolute; top: -8px; transform: translateX(-50%); background: var(--text); color: var(--bg); font-size: .8rem; padding: 3px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; direction: rtl; }
.tablewrap { overflow-x: auto; }
table.stats { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.stats th, table.stats td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: start; }
table.stats td:not(:first-child), table.stats th:not(:first-child) { text-align: end; font-variant-numeric: tabular-nums; }

/* שפה */
select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 180px; }
body.not-il .il-only { display: none; }

/* הוספה מצילום */
label.photo { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
#loginForm .login-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
#loginForm .lang-mini { min-width: 0; padding: 6px 10px; font-size: .9rem; }

/* שפה בראש המסך */
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .lang-mini { min-width: 0; padding: 6px 8px; font-size: .85rem; max-width: 130px; }

/* תפריט 📷: צילום עכשיו / מהגלריה */
.photo-wrap { position: relative; display: inline-flex; }
.photo-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; z-index: 5; display: flex; flex-direction: column; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / .15); overflow: hidden; }
.photo-menu[hidden] { display: none; }
.photo-menu label { padding: 12px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.photo-menu label + label { border-top: 1px solid var(--border); }
.photo-menu label:hover { background: var(--accent-soft); }
