:root {
  --bg: #f4f6f3; --card: #ffffff; --text: #17201b; --muted: #66706a; --line: #e2e7e3;
  --brand: #138a4f; --brand-2: #0e6b3d; --brand-soft: #e3f4ea; --warn: #b46a00; --warn-soft: #fff3df;
  --bad: #c0392b; --gold: #f2b705; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 18px rgba(16,40,28,.07);
  --r: 16px;
}
:root[data-theme="dark"] {
  --bg: #0f1512; --card: #18211c; --text: #e8efe9; --muted: #98a59d; --line: #2a362f;
  --brand: #2fbf77; --brand-2: #4fd38f; --brand-soft: #173326; --warn: #f0a640; --warn-soft: #33270f;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Heebo, system-ui, sans-serif;
  font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.grow { flex: 1; }

.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 8px; align-items: center; font-size: 18px; }
.logo { font-size: 22px; }
.place-chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px;
  font-size: 14px; max-width: 58vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.place-chip::before { content: "📍 "; }

main { padding: 14px 16px 90px; max-width: 640px; margin: 0 auto; }
.hero h1 { font-size: 22px; line-height: 1.25; margin: 6px 0 4px; font-weight: 800; }
.hero p { margin: 0 0 14px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg);
  resize: vertical; line-height: 1.6; min-height: 140px; }
textarea:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.hint { font-size: 13px; margin: 10px 2px 0; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; min-height: 46px; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-2); }
.btn.ghost { background: var(--brand-soft); color: var(--brand-2); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; cursor: pointer; padding: 4px; }

h2.sec { font-size: 16px; margin: 18px 2px 8px; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items .name { flex: 1; min-width: 0; }
.items .name small { display: block; color: var(--muted); font-size: 12.5px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 32px; height: 32px; border: 0; background: var(--bg); cursor: pointer; font-size: 18px; }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-size: 14px; }
.x { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 6px; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg); }

.winner { background: linear-gradient(160deg, var(--brand), var(--brand-2)); color: #fff; border-radius: 20px;
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.winner .lbl { opacity: .85; font-size: 14px; }
.winner .store { font-size: 20px; font-weight: 800; margin: 2px 0; }
.winner .addr { opacity: .9; font-size: 14px; }
.winner .total { font-size: 34px; font-weight: 800; margin: 10px 0 0; letter-spacing: -.5px; }
.save { display: inline-block; background: rgba(255,255,255,.18); padding: 6px 10px; border-radius: 10px;
  font-weight: 700; margin-top: 10px; font-size: 15px; }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }

/* isolation: השכבות של Leaflet (z-index 400+) נשארות בתוך המפה — לא מעל הכותרת והגיליון */
#map { height: 220px; border-radius: var(--r); overflow: hidden; margin-bottom: 14px; box-shadow: var(--shadow);
  isolation: isolate; position: relative; z-index: 0; }
.rank { list-style: none; padding: 0; margin: 0; }
.rank li { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--card); border-radius: 14px;
  margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.rank .pos { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.rank li:first-child .pos { background: var(--gold); color: #3a2a00; }
.rank .info { flex: 1; min-width: 0; }
.rank .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank .info small { color: var(--muted); font-size: 13px; }
.rank .price { font-weight: 800; font-size: 17px; text-align: left; white-space: nowrap; }
.rank .price small { display: block; font-weight: 500; font-size: 12px; color: var(--warn); }
.diff { color: var(--muted); font-size: 12px; font-weight: 500; display: block; }

.lines { list-style: none; padding: 0; margin: 0; }
.lines li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines .what { flex: 1; min-width: 0; }
.lines .what small { display: block; color: var(--muted); font-size: 12.5px; }
.lines .cost { font-weight: 700; white-space: nowrap; }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand-2); border-radius: 6px;
  font-size: 11.5px; padding: 1px 6px; margin-top: 3px; }
.tag.miss { background: var(--warn-soft); color: var(--warn); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 40; }
.sheet { position: fixed; inset: auto 0 0 0; z-index: 41; background: var(--card); border-radius: 20px 20px 0 0;
  max-height: 86vh; overflow: auto; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 6px; font-size: 18px; }
.sheet input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); }
.seg { display: flex; gap: 6px; margin: 10px 0; }
.seg button { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 0; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.opt { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: right; border: 0;
  border-bottom: 1px solid var(--line); background: none; padding: 12px 2px; cursor: pointer; }
.opt.on { color: var(--brand); font-weight: 700; }

.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline: 16px; z-index: 60;
  background: #1d2a23; color: #fff; padding: 12px 14px; border-radius: 12px; text-align: center; }
.loading { text-align: center; padding: 50px 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 4px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hist li { cursor: pointer; }
.foot { text-align: center; font-size: 12.5px; margin-top: 24px; line-height: 1.6; }
.bottom-bar { position: fixed; bottom: calc(58px + env(safe-area-inset-bottom)); inset-inline: 0; padding: 10px 16px;
  background: var(--bg); border-top: 1px solid var(--line); z-index: 15; }
.bottom-bar .btn { max-width: 608px; margin: 0 auto; display: flex; }
.empty { text-align: center; padding: 30px 10px; }
main { padding-bottom: 150px; }

/* tabs */
.tabs { position: fixed; bottom: 0; inset-inline: 0; z-index: 30; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 6px 0 8px; font-size: 12px; color: var(--muted); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tabs a span { font-size: 20px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--brand); font-weight: 700; }
.tabs a.on span { filter: none; opacity: 1; }

/* cards */
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card .sub { font-size: 13px; color: var(--muted); margin: -4px 0 10px; }
.split { border: 2px dashed var(--brand); background: var(--brand-soft); }
.split .two { display: flex; gap: 8px; margin: 8px 0; }
.split .two > div { flex: 1; background: var(--card); border-radius: 12px; padding: 10px; font-size: 14px; }
.split .two b { display: block; }
.subs li { align-items: center; }
.saved-badge { display: flex; align-items: center; gap: 10px; background: var(--brand-soft); color: var(--brand-2);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.saved-badge .grow { flex: 1; }
.sponsor { font-size: 13px; text-align: center; margin: 14px 0; color: var(--muted); }
.sponsor a { color: var(--brand); }

/* checklist */
.chk li { cursor: pointer; user-select: none; }
.chk .box { width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 7px; flex: none; display: grid;
  place-items: center; font-weight: 800; color: #fff; }
.chk li.done .box { background: var(--brand); border-color: var(--brand); }
.chk li.done .what { text-decoration: line-through; opacity: .5; }
.dept { font-size: 13px; font-weight: 700; color: var(--brand-2); margin: 14px 2px 4px; }
.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 6px 0 12px; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* price search */
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--card); }
.results li { cursor: pointer; }
#scanVideo { width: 100%; border-radius: 14px; background: #000; max-height: 260px; object-fit: cover; }
.chart { width: 100%; height: 180px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 4px; vertical-align: middle; }

/* settings */
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.switch { width: 46px; height: 28px; border-radius: 28px; background: var(--line); position: relative; border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: right .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch.on { background: var(--brand); }
.switch.on::after { right: 21px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chips button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chips.neg button.on { background: var(--bad); border-color: var(--bad); }
select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); }
