/* מערך הלוגיסטיקה: עיצוב משותף. טלפון קודם (400px), כפתורים גדולים לכפפות, ניגודיות גבוהה, מצב כהה. */
:root {
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-2: #ebe9e3;
  --fg: #1b2230;
  --muted: #5f6775;
  --line: #d6d3ca;
  --ink: #1b2a41;
  --ink-fg: #f6f4ee;
  --accent: #f2b705;
  --accent-fg: #1b1a12;
  --ok: #2a7f4f;
  --ok-bg: #dff3e6;
  --warn: #c0392b;
  --warn-bg: #fbe3e0;
  --mid: #b86e00;
  --mid-bg: #fff0cc;
  --info: #1f5fa8;
  --info-bg: #dfeaf8;
  --gray: #6b7280;
  --gray-bg: #e5e7eb;
  --purple: #6b3fa0;
  --purple-bg: #ece3f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.06);
  --font: 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --tap: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d; --surface: #1c222b; --surface-2: #262d38; --fg: #ecebe6; --muted: #a0a8b3; --line: #343c48;
    --ink: #0d1726; --ink-fg: #f6f4ee; --accent: #f5c33b; --accent-fg: #1b1a12;
    --ok: #4fc47f; --ok-bg: #173a27; --warn: #ff6b5c; --warn-bg: #4a1d18; --mid: #f0b24a; --mid-bg: #45320d;
    --info: #6ea8ff; --info-bg: #15304f; --gray: #9aa3ad; --gray-bg: #2c333d; --purple: #b89ae6; --purple-bg: #2f2144;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d; --surface: #1c222b; --surface-2: #262d38; --fg: #ecebe6; --muted: #a0a8b3; --line: #343c48;
  --ink: #0d1726; --ink-fg: #f6f4ee; --accent: #f5c33b; --accent-fg: #1b1a12;
  --ok: #4fc47f; --ok-bg: #173a27; --warn: #ff6b5c; --warn-bg: #4a1d18; --mid: #f0b24a; --mid-bg: #45320d;
  --info: #6ea8ff; --info-bg: #15304f; --gray: #9aa3ad; --gray-bg: #2c333d; --purple: #b89ae6; --purple-bg: #2f2144;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 17px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: var(--info); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- כותרת עליונה ---- */
.bar { position: sticky; top: 0; z-index: 20; background: var(--ink); color: var(--ink-fg); padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; display: flex; align-items: center; gap: 10px; }
.bar .brand { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.bar .brand-name { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .brand-sub { font-size: 0.8rem; opacity: 0.8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .tools { display: flex; gap: 6px; }
.btn-ghost { background: transparent; color: var(--ink-fg); border: 1px solid rgba(255,255,255,0.4); border-radius: 8px; padding: 8px 12px; min-height: 44px; font-size: 0.95rem; }
.btn-ghost:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible, .cube:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sample-bar { background: var(--accent); color: var(--accent-fg); font-weight: 700; text-align: center; padding: 6px 12px; font-size: 0.95rem; position: sticky; top: 0; z-index: 21; }
.sample-bar small { font-weight: 400; display: block; font-size: 0.8rem; opacity: 0.85; }

/* ---- פריסה ---- */
.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 14px 16px 90px; display: flex; flex-direction: column; gap: 14px; }
.wrap.wide { max-width: 1400px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.25rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.en { direction: ltr; text-align: left; unicode-bidi: isolate; font-size: 0.9rem; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---- כפתורים ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 18px; border-radius: var(--radius); border: 2px solid transparent; background: var(--ink); color: var(--ink-fg); font-weight: 700; font-size: 1.05rem; text-decoration: none; user-select: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.accent { background: var(--accent); color: var(--accent-fg); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.info { background: var(--info); color: #fff; }
.btn.outline { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.outline.ok { color: var(--ok); border-color: var(--ok); }
.btn.outline.warn { color: var(--warn); border-color: var(--warn); }
.btn.outline.info { color: var(--info); border-color: var(--info); }
.btn.block { width: 100%; }
.btn.huge { min-height: 72px; font-size: 1.3rem; }
.btn.sm { min-height: 44px; padding: 6px 12px; font-size: 0.95rem; border-radius: 10px; }
.btn.icon { padding: 10px; min-width: var(--tap); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ---- צ'יפים לסינון ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { border: 2px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 8px 16px; min-height: 44px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); }
.chip .count { background: rgba(127,127,127,0.25); border-radius: 999px; padding: 0 8px; font-size: 0.85rem; }

/* ---- שדות ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 700; font-size: 0.95rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg); font-size: 1.05rem;
}
textarea { min-height: 96px; resize: vertical; }
select { appearance: auto; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 600; }
.check input { width: 26px; height: 26px; accent-color: var(--ink); }

/* ---- כרטיסים וקוביות ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2 { font-size: 1.15rem; }
.group-title { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 800; margin-top: 6px; }
.group-title .count { background: var(--surface-2); border-radius: 999px; padding: 2px 12px; font-size: 0.95rem; }
.cubes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.cube { background: var(--surface); border: 1px solid var(--line); border-inline-start: 8px solid var(--c, var(--gray)); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; text-align: start; cursor: pointer; width: 100%; color: inherit; position: relative; }
.cube:hover { border-color: var(--c, var(--gray)); }
.cube .l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.cube .ord { font-weight: 800; font-variant-numeric: tabular-nums; }
.cube .cust { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cube .l2 { font-size: 0.95rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cube .l3 { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.cube .when { font-size: 0.85rem; color: var(--muted); }
.cube.c-new { --c: var(--gray); }
.cube.c-at_pickers { --c: var(--mid); }
.cube.c-picked { --c: var(--ok); }
.cube.c-assigned, .cube.c-loaded { --c: var(--info); }
.cube.c-departed, .cube.c-delivered { --c: var(--purple); }
.cube.c-waiting_purchase { --c: var(--warn); }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; background: var(--gray-bg); color: var(--gray); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.mid { background: var(--mid-bg); color: var(--mid); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: var(--info-bg); color: var(--info); }
.tag.purple { background: var(--purple-bg); color: var(--purple); }
.tag.ink { background: var(--ink); color: var(--ink-fg); }
.tag.accent { background: var(--accent); color: var(--accent-fg); }

/* ---- שורות הזמנה ---- */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; box-shadow: var(--shadow); position: relative; }
.line.picked { background: var(--ok-bg); border-color: var(--ok); }
.line.new-line { border: 3px solid var(--warn); background: var(--warn-bg); }
.line .new-bar { grid-column: 1 / -1; background: var(--warn); color: #fff; font-weight: 800; text-align: center; padding: 6px; border-radius: 8px; letter-spacing: 0.02em; }
.line .desc { font-weight: 700; font-size: 1.1rem; }
.line .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); margin-top: 4px; }
.line .qty { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.line .actions .btn { flex: 1; }
.line .note-text { grid-column: 1 / -1; background: var(--surface-2); border-radius: 8px; padding: 6px 10px; font-size: 0.95rem; }
.line .loc { font-weight: 700; color: var(--fg); }

/* ---- לוח ימים × משאיות ---- */
.board-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.board { border-collapse: separate; border-spacing: 4px; min-width: 760px; width: 100%; }
.board th { background: var(--surface-2); padding: 8px; font-size: 0.95rem; border-radius: 8px; white-space: nowrap; }
.board th.day { text-align: start; min-width: 110px; }
.board td { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; vertical-align: top; padding: 6px; min-width: 130px; }
.board td.today { box-shadow: inset 0 0 0 2px var(--accent); }
.board .slot { display: block; width: 100%; text-align: start; border: 0; border-inline-start: 5px solid var(--c, var(--gray)); background: var(--surface-2); border-radius: 6px; padding: 5px 8px; margin-bottom: 4px; font-size: 0.9rem; line-height: 1.3; color: inherit; }
.board .slot .ord { font-weight: 800; font-size: 0.85rem; }
.board .slot .cust { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.board .slot.c-new { --c: var(--gray); } .board .slot.c-at_pickers { --c: var(--mid); } .board .slot.c-picked { --c: var(--ok); }
.board .slot.c-assigned, .board .slot.c-loaded { --c: var(--info); } .board .slot.c-departed, .board .slot.c-delivered { --c: var(--purple); } .board .slot.c-waiting_purchase { --c: var(--warn); }
.board .empty { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 6px; }

/* ---- חלון קופץ ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { background: var(--bg); color: var(--fg); width: 100%; max-width: 640px; max-height: 94vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; box-shadow: 0 -4px 30px rgba(0,0,0,0.3); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); border-radius: 18px 18px 0 0; }
.modal-head h2 { flex: 1; font-size: 1.15rem; }
.modal-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }
@media (min-width: 700px) { .modal-back { align-items: center; padding: 20px; } .modal { border-radius: 18px; max-height: 90vh; } .modal-head { border-radius: 18px 18px 0 0; } }

/* ---- toast ---- */
.toasts { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--ink-fg); padding: 12px 18px; border-radius: 12px; font-weight: 700; box-shadow: var(--shadow); max-width: 600px; width: 100%; text-align: center; animation: toast-in 0.2s ease-out; }
.toast.ok { background: var(--ok); color: #fff; } .toast.warn { background: var(--warn); color: #fff; } .toast.accent { background: var(--accent); color: var(--accent-fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- מסך הכניסה ---- */
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.user-btn { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 10px; min-height: 72px; font-weight: 700; font-size: 1.1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: inherit; }
.user-btn small { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 10px 0; }
.pin-dots span { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--ink); display: block; }
.pin-dots span.on { background: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; width: 100%; }
.pin-key { min-height: 72px; font-size: 1.8rem; font-weight: 700; border-radius: var(--radius); border: 2px solid var(--line); background: var(--surface); color: inherit; }
.pin-key.alt { font-size: 1.05rem; background: var(--surface-2); }

/* ---- ספירה לאחור ---- */
.countdown { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border-radius: var(--radius); background: var(--info-bg); color: var(--info); font-weight: 800; }
.countdown .num { font-size: 2.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown.soon { background: var(--mid-bg); color: var(--mid); }
.countdown.late { background: var(--warn-bg); color: var(--warn); }
.countdown.done { background: var(--ok-bg); color: var(--ok); }

/* ---- נהג ---- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 0.9rem; }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd a { font-size: 1.15rem; }
.counter { display: inline-flex; align-items: center; gap: 6px; }
.counter .btn { min-width: 52px; }
.counter .val { font-size: 1.3rem; font-weight: 800; min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.loading { text-align: center; color: var(--muted); padding: 20px; }
.sticky-foot { position: fixed; bottom: 0; inset-inline: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 15; }
.sticky-foot .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.sticky-foot .btn { flex: 1; }
.events { font-size: 0.9rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn { position: relative; }
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.sig-preview { background: #fff; border: 1px solid var(--line); border-radius: 8px; max-width: 100%; height: 120px; object-fit: contain; }
