:root {
  --bg: #f6f4ee;
  --card: #ffffff;
  --ink: #1d2b22;
  --muted: #6b7568;
  --line: #e6e2d8;
  --green: #1f6b3a;
  --green-soft: #e4efe6;
  --danger: #b42318;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 14px) 20px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.top-title { font-size: 28px; font-weight: 800; letter-spacing: -0.3px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--green); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }

.banner { margin: 0 16px 8px; padding: 10px 14px; border-radius: 12px; background: #fff4e5; color: #8a4b00; font-size: 15px; }

.main { padding: 4px 16px calc(var(--safe-b) + 110px); }
.card { background: var(--card); border-radius: var(--radius); padding: 6px 16px 16px; box-shadow: 0 1px 3px rgb(0 0 0 / 0.06); }
.label { display: block; margin: 14px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

.picker {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px; border-radius: 12px; background: var(--bg); font-size: 18px; font-weight: 600; text-align: right;
}
.placeholder { color: var(--muted); font-weight: 500; }
.chev { color: var(--muted); font-size: 24px; line-height: 1; }

.row { display: flex; gap: 10px; align-items: stretch; }
.stepper { display: flex; align-items: center; background: var(--bg); border-radius: 12px; overflow: hidden; }
.stepper button { width: 46px; height: 46px; font-size: 22px; color: var(--green); font-weight: 700; }
.stepper button:active { background: var(--green-soft); }
.stepper span { min-width: 30px; text-align: center; font-size: 19px; font-weight: 700; }
.segmented { flex: 1; display: flex; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg { flex: 1; border-radius: 9px; font-size: 16px; color: var(--muted); font-weight: 600; transition: background .18s, color .18s; }
.seg.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.1); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 10px 16px; border-radius: 999px; background: var(--bg); font-size: 16px; font-weight: 600; transition: background .18s, color .18s; }
.chip.on { background: var(--green); color: #fff; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 10px; font-weight: 700; font-size: 18px; }
.muted { color: var(--muted); font-weight: 500; font-size: 15px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgb(0 0 0 / 0.06); }
.list:empty { display: none; }
.cust { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); transition: opacity .2s; }
.cust:last-child { border-bottom: 0; }
.cust.off { opacity: 0.4; }
.cust.off .cust-name { text-decoration: line-through; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 700; flex: none; }
.cust-main { flex: 1; min-width: 0; }
.cust-name { font-weight: 600; }
.cust-sub { color: var(--muted); font-size: 14px; direction: ltr; text-align: right; }
.toggle { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 20px; }
.skeleton { height: 64px; background: linear-gradient(90deg, #f1efe8 25%, #faf9f5 50%, #f1efe8 75%); background-size: 200% 100%; animation: shimmer 1.1s infinite; border-bottom: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

.bottom {
  position: fixed; inset: auto 0 0 0; z-index: 6;
  padding: 12px 16px calc(var(--safe-b) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.primary { width: 100%; padding: 17px; border-radius: 16px; background: var(--green); color: #fff; font-size: 19px; font-weight: 700; transition: transform .1s, opacity .2s; }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: 0.35; }
.secondary { width: 100%; padding: 15px; margin-top: 8px; border-radius: 16px; font-size: 17px; color: var(--muted); font-weight: 600; }
.link-btn { margin-top: 18px; color: var(--muted); text-decoration: underline; font-size: 15px; }

.backdrop { position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / 0.35); animation: fade .2s; }
.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 11; max-height: 94vh; display: flex; touch-action: pan-y; flex-direction: column;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(var(--safe-b) + 18px);
  animation: up .26s cubic-bezier(.2,.8,.2,1);
}
.sheet h2 { margin: 10px 0 6px; font-size: 22px; }
.grip { position: relative; height: 30px; margin: -8px -18px 2px; cursor: grab; touch-action: none; }
.grip::before { content: ""; position: absolute; top: 12px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: #cfc9bb; }
.sheet.dragging { transition: none !important; animation: none; }
.sheet.dragging .grip { cursor: grabbing; }
.sheet.snap { transition: transform .22s cubic-bezier(.2,.8,.2,1), height .22s cubic-bezier(.2,.8,.2,1); }
#product-sheet, #history-sheet { height: 64vh; max-height: 94vh; }
.search { width: 100%; padding: 13px 14px; border-radius: 12px; border: 0; background: var(--bg); font: inherit; font-size: 17px; outline: none; -webkit-user-select: text; user-select: text; }
.sheet-list { flex: 1; min-height: 0; list-style: none; margin: 10px 0 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-list.grabbing { cursor: grabbing; }
.sheet-list li { padding: 15px 4px; border-bottom: 1px solid var(--line); font-size: 17px; }
.sheet-list li.pick:active { background: var(--green-soft); }
.hist-sub { display: block; color: var(--muted); font-size: 14px; margin-top: 3px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast { pointer-events: none; max-width: 448px; margin-inline: auto; position: fixed; z-index: 20; inset: auto 16px calc(var(--safe-b) + 96px) 16px; padding: 14px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 600; text-align: center; animation: up .25s; }
.toast.err { background: var(--danger); }

.install { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; padding: 24px; }
.install-card { max-width: 360px; text-align: center; }
.install-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); }
.install h1 { font-size: 24px; margin: 18px 0 6px; }
.install ol { text-align: right; line-height: 1.9; padding-right: 22px; }

/* במסך רחב: עמודה צרה באמצע, כמו טלפון */
@media (min-width: 560px) {
  .top, .main, .banner { max-width: 480px; margin-inline: auto; }
  .banner { margin-bottom: 8px; }
  .bottom { max-width: 480px; margin-inline: auto; }
  .sheet { max-width: 480px; margin-inline: auto; }
}

/* מסך כניסה */
.gate { position: fixed; inset: 0; z-index: 60; background: var(--bg, #f6f7f5); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 360px; text-align: center; }
.gate-card h1 { margin: 12px 0 6px; font-size: 22px; }
.gate-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.code-input { font: inherit; font-size: 24px; letter-spacing: 8px; text-align: center; padding: 14px; border: 1px solid #ccd3cc; border-radius: 12px; background: #fff; color: inherit; direction: ltr; }
.code-input:focus { outline: 2px solid #1f6b3a; outline-offset: 1px; }
.gate-error { color: #b3261e; margin: 0; font-size: 15px; }
[hidden] { display: none !important; }
