:root {
  --bg: #F5F3EE;
  --fg: #161612;
  --card: #FFFFFF;
  --primary: #E0531A;
  --primary-fg: #FFFFFF;
  --muted: #ECE9E1;
  --muted-fg: #6A675E;
  --border: #E3DED3;
  --danger: #C62828;
  --plate: #FFD400;
  --dark: #14150F;
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font-h: "Heebo", system-ui, sans-serif;
  --font-b: "Assistant", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-b); font-size: 16px; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 14px calc(96px + var(--safe-b)); }
body.no-tabs #app { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- ניווט תחתון ---------- */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + var(--safe-b)); background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
body.no-tabs .tabbar { display: none; }
.tabbar a {
  flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 14px; color: var(--muted-fg); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar a.active { color: var(--primary); background: #FCEDE6; }
.tabbar svg { width: 22px; height: 22px; }

/* ---------- בסיס ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stack > * + * { margin-top: 12px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .16em; color: var(--primary); }
h1, h2, h3 { font-family: var(--font-h); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 900; line-height: 1.1; }
h2 { font-size: 16px; font-weight: 800; }
.muted { color: var(--muted-fg); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted-fg); margin-bottom: 8px; }
.label svg { width: 15px; height: 15px; }

.hero { padding: 20px 18px; }
.hero p { margin: 8px 0 0; font-size: 15px; line-height: 1.5; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--font-h); font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted-fg); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--card);
  font-weight: 600; font-size: 15px; color: var(--fg); transition: all .12s;
}
.chip.active { background: var(--fg); border-color: var(--fg); color: #fff; }
.chip:active { transform: scale(.97); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; padding: 12px 18px;
  border-radius: 18px; background: var(--primary); color: var(--primary-fg); font-family: var(--font-h); font-size: 17px; font-weight: 800;
  transition: filter .12s, transform .08s;
}
.btn:active:not(:disabled) { transform: scale(.985); filter: brightness(.95); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.secondary { background: var(--muted); color: var(--fg); }
.btn.ghost { background: transparent; border: 1.5px solid var(--border); color: var(--fg); min-height: 48px; font-size: 15px; }
.btn.small { min-height: 42px; font-size: 14px; border-radius: 14px; width: auto; padding: 8px 14px; }
.btn.danger { background: #FDECEC; color: var(--danger); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 999px; color: var(--muted-fg); }
.iconbtn:active { background: var(--muted); }

.sticky-cta { position: sticky; bottom: calc(84px + var(--safe-b)); z-index: 5; padding-top: 8px; }

.input {
  width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--card);
  font-size: 16px; outline: none;
}
.input:focus { border-color: var(--primary); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted-fg) 50%), linear-gradient(135deg, var(--muted-fg) 50%, transparent 50%); background-position: 18px 50%, 13px 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-left: 30px; }

.empty { border: 1.5px dashed var(--border); border-radius: 14px; padding: 14px; font-size: 14px; color: var(--muted-fg); }
.empty a { color: var(--primary); font-weight: 700; }

/* ---------- לוחית ---------- */
.plate-tag {
  display: inline-block; direction: ltr; border: 2px solid rgba(0,0,0,.85); background: var(--plate); color: #000;
  border-radius: 7px; padding: 1px 8px; font-family: var(--font-h); font-weight: 900; font-size: 15px; letter-spacing: .06em; white-space: nowrap;
}
.chassis-tag { display: inline-block; direction: ltr; background: var(--muted); border-radius: 7px; padding: 2px 8px; font-weight: 700; font-size: 13px; }
.plate-input-wrap { border: 2.5px solid rgba(0,0,0,.85); background: var(--plate); border-radius: 16px; padding: 4px; }
.plate-input {
  width: 100%; border: 0; background: transparent; text-align: center; direction: ltr; outline: none; color: #000;
  font-family: var(--font-h); font-weight: 900; font-size: 32px; letter-spacing: .14em; padding: 6px 0;
}
.plate-input::placeholder { color: rgba(0,0,0,.2); }

/* ---------- סריקה ---------- */
.scanbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.scanbar .who { flex: 1; min-width: 0; }
.scanbar .who b { display: block; font-family: var(--font-h); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { background: var(--fg); color: #fff; border-radius: 14px; padding: 6px 12px; text-align: center; }
.counter b { display: block; font-family: var(--font-h); font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.counter span { font-size: 10px; opacity: .75; }

.viewport {
  position: relative; aspect-ratio: 4 / 3; border-radius: 22px; overflow: hidden; background: var(--dark); color: #fff;
}
.viewport video, .viewport img.shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.frame div { width: 78%; height: 34%; border: 2.5px dashed rgba(255,255,255,.8); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.shutter {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: 72px; height: 72px; border-radius: 999px;
  border: 5px solid #fff; background: rgba(255,255,255,.28); box-shadow: 0 4px 18px rgba(0,0,0,.35);
}
.shutter:active { transform: translateX(-50%) scale(.92); }
.vp-btn { position: absolute; top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 600; backdrop-filter: blur(6px); }
.vp-btn.right { right: 10px; } .vp-btn.left { left: 10px; }
.vp-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; text-align: center; }
.vp-center .ic { width: 56px; height: 56px; border-radius: 18px; background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; }
.vp-center .ic svg { width: 26px; height: 26px; }
.vp-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.vp-actions .btn { width: auto; min-height: 46px; font-size: 15px; padding: 8px 16px; border-radius: 14px; }
.vp-actions .btn.outline { background: transparent; border: 1.5px solid rgba(255,255,255,.35); color: #fff; }
.overlay { position: absolute; inset: 0; background: rgba(0,0,0,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-weight: 600; }
.spin { width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 999px; animation: spin .8s linear infinite; }
.spin.dark { border-color: rgba(0,0,0,.15); border-top-color: currentColor; width: 20px; height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

.note { margin-top: 10px; font-size: 14px; color: #9A5B00; }
.warn { margin-top: 10px; border: 1px solid #F3C97A; background: #FFF6E5; color: #6E4A00; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.types .chip { padding: 8px 6px; font-size: 15px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- ניהול ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--muted); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { min-height: 42px; border-radius: 11px; font-weight: 700; color: var(--muted-fg); }
.seg button.active { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .full { grid-column: 1 / -1; }
.rec { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.rec:first-child { border-top: 0; }
.rec .meta { font-size: 13px; color: var(--muted-fg); margin-top: 4px; line-height: 1.45; }
.editor-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.editor-item .input { min-height: 44px; }
.editor-item.inactive .input { color: var(--muted-fg); text-decoration: line-through; }
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; background: #CFCAC0; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 999px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: #2E7D32; }
.switch.on::after { transform: translateX(-18px); }


.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); z-index: 50;
  background: var(--fg); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
body.no-tabs .toast { bottom: calc(24px + var(--safe-b)); }
