/* ============================================================
   רחליס — עיצוב משותף
   נבנה מהנייד כלפי מעלה. כל יעד מגע ≥44px.
   כל צבע טקסט נבדק ל-WCAG AA (4.5:1) מול הרקע שלו.
   ============================================================ */

:root {
  --primary:    #1e293b;
  --accent:     #2563eb;   /* 4.6:1 על לבן */
  --accent-ink: #1d4ed8;
  --success:    #047857;   /* 5.5:1 — הוכהה מ-#10b981 שהיה 2.5:1 */
  --warn:       #b45309;   /* 4.9:1 — הוכהה מ-#f59e0b שהיה 2.1:1 */
  --danger:     #dc2626;
  --violet:     #7c3aed;

  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --surface-3:  #eef2f7;
  --border:     #dde5ee;
  --border-2:   #b6c2d2;   /* הוכהה כדי שגבולות שדות ייראו */

  --text:       #0f172a;   /* 16.7:1 */
  --muted:      #52627a;   /* 6.4:1 — הוכהה מ-#64748b */
  --faint:      #5d6b7f;   /* 5.4:1 — הטקסט המשני הכי בהיר שעדיין עובר AA */

  --shadow:     0 1px 3px rgb(15 23 42 / .08), 0 1px 2px rgb(15 23 42 / .04);
  --shadow-lg:  0 10px 25px -5px rgb(15 23 42 / .15), 0 8px 10px -6px rgb(15 23 42 / .08);

  --r:      12px;
  --r-lg:   16px;
  --tap:    44px;           /* יעד מגע מינימלי */
  --header-h: 58px;
  --nav-h:  62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Assistant', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  font-size: 16px;              /* מונע זום אוטומטי ב-iOS */
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

input, button, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-ink); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── כותרת ────────────────────────────────────────────── */
.header {
  background: var(--primary);
  color: #fff;
  min-height: var(--header-h);
  padding: .5rem .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
  padding-top: max(.5rem, env(safe-area-inset-top));
}
.head-txt { min-width: 0; }
.header h1 {
  font-size: 1rem; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header .sub { font-size: .74rem; color: #cbd5e1; font-weight: 500; }
.header .sub:empty { display: none; }
.grow { flex: 1; }

.icon-btn {
  position: relative;
  background: rgb(255 255 255 / .14);
  border: 1px solid rgb(255 255 255 / .22);
  border-radius: 10px;
  width: var(--tap); height: var(--tap);
  min-width: var(--tap);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: #fff;
  transition: background .15s;
}
.icon-btn:hover { background: rgb(255 255 255 / .26); }
.icon-btn.plain {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}

.badge {
  position: absolute; top: -5px; inset-inline-end: -5px;
  background: var(--danger); color: #fff;
  border-radius: 999px; min-width: 21px; height: 21px; padding: 0 5px;
  font-size: .72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--primary);
}
.badge.hidden, .bn-badge.hidden { display: none; }

.admin-banner {
  background: #fef3c7; color: #78350f;
  border-bottom: 1px solid #fcd34d;
  padding: .55rem .9rem; font-size: .85rem; font-weight: 700;
  text-align: center;
}
.admin-banner a { color: #78350f; font-weight: 800; }

/* ── פריסה ────────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem .75rem calc(var(--nav-h) + var(--safe-b) + 1rem);
}
.container.wide { max-width: 1500px; }

.screen, .view { display: none; }
.screen.active, .view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card > h2 {
  font-size: 1rem; font-weight: 800;
  margin-bottom: .9rem; padding-bottom: .7rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.card > h2.plain, h2.plain { border: none; padding: 0; justify-content: center; }

/* ── כרטיס מתקפל ───────────────────────────────────────── */
.card.fold { padding: 0; overflow: hidden; }
.card.fold > summary {
  list-style: none;
  cursor: pointer;
  padding: .85rem 1rem;
  min-height: var(--tap);
  display: flex; align-items: center; gap: .5rem;
  font-weight: 800; font-size: 1rem;
  user-select: none;
}
.card.fold > summary::-webkit-details-marker { display: none; }
.card.fold > summary::after {
  content: '⌄';
  margin-inline-start: auto;
  font-size: 1.3rem; line-height: 1;
  color: var(--muted);
  transition: transform .2s;
  transform: translateY(-3px);
}
.card.fold[open] > summary::after { transform: rotate(180deg) translateY(-1px); }
.card.fold > summary:hover { background: var(--surface-2); }
.card.fold > summary .ttl { flex-shrink: 0; }
.card.fold .fold-hint {
  font-size: .78rem; font-weight: 700; color: var(--muted);
  background: var(--surface-3); border-radius: 999px; padding: .1rem .5rem;
}
.card.fold[open] > summary { border-bottom: 1px solid var(--border); }
.fold-body { padding: 1rem; }

/* ── כרטיס "דורש טיפול" ────────────────────────────────── */
.card.urgent { border-inline-start: 4px solid var(--warn); }
.act-group { margin-bottom: 1rem; }
.act-group:last-child { margin-bottom: 0; }
.act-title {
  font-weight: 800; font-size: .88rem;
  display: flex; align-items: center; gap: .4rem;
  margin-bottom: .45rem;
}
.act-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: .4rem;
  background: var(--surface-2);
  cursor: pointer;
}
.act-row:hover { background: #eff6ff; border-color: #bfdbfe; }
.act-customer-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .5rem;
  margin-bottom: .55rem;
  background: var(--surface);
}
.act-customer-title {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .1rem .2rem .45rem;
  font-weight: 800;
}

.act-customer-tools { align-items: center; gap: .4rem; }
.act-customer-tools .btn { padding: .3rem .55rem; font-size: .78rem; }
.ready-qty-edit-btn { padding: .28rem .5rem; font-size: .78rem; }
.import-error-summary { margin-bottom: .7rem; }
.import-error-list { margin: 0; padding: 0 1.4rem 0 0; max-height: 55vh; overflow: auto; }
.import-error-list li { padding: .55rem .2rem; border-bottom: 1px solid var(--border); }
.import-error-list li:last-child { border-bottom: 0; }
.import-error-list li div { margin-top: .2rem; color: var(--danger); }
.act-customer-card .act-row { margin-bottom: .35rem; }
.act-customer-card .act-row:last-child { margin-bottom: 0; }
.order-customer-groups { display: grid; gap: .65rem; }
.order-customer-card { margin-bottom: 0; }
.order-customer-groups-sortable > .order-customer-card {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.order-customer-groups-sortable.longpress-sort-active,
.order-customer-groups-sortable.longpress-sort-active > .order-customer-card { cursor: grabbing; }
.order-customer-groups-sortable > .order-customer-card.dragging { opacity: .24; }
.order-customer-groups-sortable > .order-customer-card.sort-drop-before,
.order-customer-groups-sortable > .order-customer-card.sort-drop-after { position: relative; }
.order-customer-groups-sortable > .order-customer-card.sort-drop-before::before,
.order-customer-groups-sortable > .order-customer-card.sort-drop-after::after {
  content: '';
  position: absolute;
  z-index: 5;
  left: .35rem;
  right: .35rem;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.order-customer-groups-sortable > .order-customer-card.sort-drop-before::before { top: -.48rem; }
.order-customer-groups-sortable > .order-customer-card.sort-drop-after::after { bottom: -.48rem; }
.invoice-upload-compact { width: 40px; min-width: 40px; padding-inline: 0; }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .84rem; }
.bold  { font-weight: 700; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.req { color: var(--danger); }

/* ── טפסים ────────────────────────────────────────────── */
.field { margin-bottom: .9rem; }
.field label {
  display: block; font-size: .85rem; font-weight: 700;
  color: var(--text); margin-bottom: .35rem;
}
.hint { font-size: .78rem; color: var(--faint); margin-top: .3rem; line-height: 1.4; }

.customer-combobox { position: relative; }
.customer-options {
  display: none;
  position: absolute; z-index: 20;
  inset-inline: 0; top: calc(100% - 1.25rem);
  max-height: 260px; overflow-y: auto;
  padding: .3rem;
  border: 1.5px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.customer-options.open { display: block; }
.customer-option {
  width: 100%; min-height: 48px;
  padding: .55rem .65rem;
  border: 0; border-radius: 8px;
  background: transparent;
  text-align: start;
  display: flex; flex-direction: column; justify-content: center; gap: .1rem;
}
.customer-option:hover, .customer-option.highlighted { background: var(--surface-2); }
.customer-option.selected { background: #eff6ff; color: var(--accent-ink); }
.customer-option-title { font-weight: 750; }
.customer-option-details { font-size: .78rem; color: var(--muted); }
.customer-option-empty { padding: .85rem; text-align: center; color: var(--muted); }

.input, input[type=text], input[type=tel], input[type=email], input[type=search],
input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .6rem .8rem;
  border: 1.5px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(37 99 235 / .15);
}
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(0% + 14px) 50%, calc(0% + 19px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-inline-start: 2rem; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: .6rem; }

/* ── כפתורים ──────────────────────────────────────────── */
.btn {
  min-height: var(--tap);
  padding: .55rem 1rem;
  border: 1.5px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  transition: filter .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 1.05rem; }
.btn.sm { min-height: 40px; padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }
/* במסך מגע גם הכפתורים הקטנים מקבלים יעד מלא */
@media (pointer: coarse) {
  .btn.sm, .tab, select, input { min-height: var(--tap); }
}
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.btn.dark    { background: var(--primary); }
.btn.success { background: var(--success); }
.btn.warn    { background: var(--warn); }
.btn.danger  { background: var(--danger); }
.btn.violet  { background: var(--violet); }
.btn.google  { background: #fff; color: #1f2937; border-color: var(--border-2); }
.btn.google:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.btn.sm.future-order-btn {
  min-height: 34px;
  padding: .22rem .48rem;
  font-size: .76rem;
}
.btn.sm.split-order-btn {
  min-height: 30px;
  padding: .15rem .4rem;
  font-size: .72rem;
  border-radius: 7px;
  gap: .2rem;
}
.order-customer-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .22rem;
}
.btn.sm.merge-order-customer-btn {
  min-height: 24px;
  padding: .08rem .3rem;
  font-size: .66rem;
  border-radius: 6px;
  font-weight: 650;
}

/* ── לשוניות ──────────────────────────────────────────── */
.tabs {
  display: flex; gap: .3rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: .9rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  min-height: var(--tap);
  padding: .5rem .8rem;
  background: none; border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 700; font-size: .9rem; color: var(--muted);
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: .35rem;
}
.tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--surface-3); color: var(--muted);
  border-radius: 999px; padding: .05rem .4rem;
  font-size: .72rem; font-weight: 800;
}
.tab.active .tab-count { background: var(--accent); color: #fff; }

/* ── תגיות סטטוס ──────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .76rem; font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip.gray   { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.chip.amber  { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.chip.blue   { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.chip.violet { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.chip.green  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.chip.red    { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ── מדדים ────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-bottom: 1rem;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .75rem .85rem;
  box-shadow: var(--shadow);
  border-inline-start: 4px solid var(--border-2);
}
.kpi .label { font-size: .76rem; color: var(--muted); font-weight: 700; margin-bottom: .2rem; }
.kpi .value { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.kpi .value.sm { font-size: 1.05rem; }
.kpi .foot { font-size: .72rem; color: var(--faint); margin-top: .15rem; }
.kpi.accent { border-inline-start-color: var(--accent); }
.kpi.warn   { border-inline-start-color: var(--warn); }
.kpi.green  { border-inline-start-color: var(--success); }
.kpi.red    { border-inline-start-color: var(--danger); }
.kpi.violet { border-inline-start-color: var(--violet); }

.profit-exclusion-summary {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.profit-exclusion-summary > .row { align-items: center; }
.profit-exclusion-chips {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: .55rem;
}
.profit-exclusion-chips:empty { display: none; }
.profit-customer-picker {
  display: grid; gap: .4rem;
  max-height: min(55vh, 520px); overflow: auto;
  padding: .15rem;
}
.profit-customer-option {
  display: flex; align-items: center; gap: .65rem;
  min-height: 48px; padding: .55rem .65rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); cursor: pointer;
}
.profit-customer-option:hover { border-color: var(--accent); }
.profit-customer-option input { flex: 0 0 auto; }
.profit-customer-option .customer-copy { min-width: 0; }
.profit-customer-option .customer-copy > * {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── טבלאות: הופכות לכרטיסים בנייד ───────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  background: var(--surface-3);
  padding: .6rem .7rem;
  text-align: start;
  font-weight: 800;
  color: var(--text);
  font-size: .78rem;
  border-bottom: 1.5px solid var(--border-2);
  white-space: nowrap;
}
tbody td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
tfoot td { padding: .6rem .7rem; background: var(--surface-3); font-weight: 800; }

@media (max-width: 780px) {
  #adminTabs {
    position: sticky;
    top: var(--header-h);
    z-index: 75;
    margin-inline: -.5rem;
    padding-inline: .5rem;
    background: var(--bg);
    scroll-snap-type: x proximity;
  }
  #adminTabs .tab { scroll-snap-align: center; }
  .responsive thead { display: none; }
  .responsive, .responsive tbody, .responsive tr, .responsive td { display: block; width: 100%; }
  .responsive tr {
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: .6rem;
    padding: .3rem .1rem;
    background: var(--surface);
  }
  .responsive tr:hover { background: var(--surface); }
  .responsive td {
    display: flex; align-items: center; gap: .6rem;
    padding: .4rem .75rem;
    border: none;
    text-align: start !important;
    min-height: 34px;
  }
  .responsive td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    font-size: .78rem; font-weight: 700; color: var(--muted);
  }
  .responsive td:empty { display: none; }
  .responsive td[data-label=""]::before { display: none; }
  .responsive td[data-label=""] { flex-wrap: wrap; }
  .responsive td > * { min-width: 0; }
  .responsive tfoot td { display: flex; }
  .table-wrap { border: none; background: none; overflow: visible; }
  .modal { padding: .4rem; }
  .modal-box { max-height: 96vh; max-height: 96dvh; }
  .modal-x { width: var(--tap); height: var(--tap); }
}

/* ── תמונות ───────────────────────────────────────────── */
.img-ph {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--border-2);
  font-size: 1.4rem; width: 100%; height: 100%;
}
.thumb {
  width: 46px; height: 46px; border-radius: 8px;
  object-fit: cover; background: var(--surface-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── כרטיס דגם ────────────────────────────────────────── */
.product {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: .75rem;
  box-shadow: var(--shadow);
}
.product-img {
  width: 104px; min-width: 104px;
  aspect-ratio: 3 / 4;
  background: var(--surface-3);
  cursor: zoom-in; position: relative; overflow: hidden;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-img .zoom {
  position: absolute; top: 5px; inset-inline-end: 5px;
  background: rgb(0 0 0 / .6); color: #fff;
  border-radius: 6px; padding: 1px 5px; font-size: .7rem;
}
.product-body { padding: .7rem .8rem; flex: 1; min-width: 0; }
.product-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: .5rem; margin-bottom: .4rem;
}
.product-title { font-weight: 800; font-size: 1rem; }
.product-desc {
  font-size: .82rem; color: var(--muted);
  margin-bottom: .6rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-clamp: 2; overflow: hidden;
}

.sizes { display: flex; flex-wrap: wrap; gap: .4rem; }
.size { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.size .lbl { font-size: .7rem; font-weight: 800; color: var(--muted); }
.size input {
  width: 50px; height: var(--tap); min-height: var(--tap);
  text-align: center;
  border: 1.5px solid var(--border-2); border-radius: 9px;
  font-weight: 800; padding: 0;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.size input::-webkit-outer-spin-button,
.size input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.size input.on {
  border-color: var(--success); background: #ecfdf5; color: #065f46;
  border-width: 2px;
}

.search-row { margin-bottom: .9rem; }

/* ── כרטיס הזמנה (לקוח) ───────────────────────────────── */
.order-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: .85rem;
  margin-bottom: .8rem;
  box-shadow: var(--shadow);
}
.order-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.order-no { font-weight: 800; font-size: 1.02rem; }
.order-meta { font-size: .87rem; color: var(--muted); margin-bottom: .5rem; }
.ship-note {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  border-radius: 9px; padding: .45rem .65rem;
  font-size: .82rem; font-weight: 600; margin-bottom: .55rem;
}
.order-lines summary {
  cursor: pointer; font-weight: 700; font-size: .88rem;
  padding: .5rem 0; color: var(--accent-ink);
  min-height: var(--tap); display: flex; align-items: center;
}
.lines-wrap { display: flex; flex-wrap: wrap; gap: .25rem; padding-bottom: .4rem; }

/* ── פריטי הזמנה בפאנל המנהל: תמונה, דגם ומידות באותה שורה ── */
.admin-order-models {
  display: flex; flex-direction: column; gap: .55rem;
  margin-bottom: 1rem;
}
.admin-order-model {
  position: relative;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  align-items: center; gap: .45rem .7rem;
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: background .15s ease, border-color .15s ease;
}
.admin-order-models.longpress-sort-active .admin-order-model { cursor: grabbing; }
.admin-order-models .admin-order-model { cursor: grab; user-select: none; -webkit-user-select: none; }
.admin-order-models .admin-order-model img { -webkit-user-drag: none; }
.admin-order-models .admin-order-model.dragging {
  opacity: .24;
  border-style: dashed;
  border-color: var(--accent);
  box-shadow: none;
}
.admin-order-model.model-checked { background: #ecfdf5; border-color: #86efac; }
.model-check {
  position: absolute; top: .55rem; left: .55rem; z-index: 2;
  width: 32px; height: 32px; min-height: 32px; padding: 0;
  border: 2px solid var(--border-2); border-radius: 7px;
  background: var(--surface); color: white; font-size: 1.05rem; font-weight: 900;
}
.model-check.checked { background: var(--success); border-color: var(--success); }
.admin-order-model-image {
  grid-row: 1 / 3;
  width: 104px; height: 100%; min-height: 118px;
  border-radius: 9px; overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.admin-order-model-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-order-model-name { min-width: 0; overflow-wrap: anywhere; align-self: end; }
.admin-order-sizes { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-width: 0; }
.admin-order-size {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  position: relative; min-height: 0; padding: .85rem 0 0;
  border: 0; background: transparent;
}
.admin-order-size.short { background: transparent; }
.admin-order-size-label {
  display: block; min-width: 0; height: auto; padding: 0;
  background: transparent; color: var(--muted);
  font-size: .7rem; font-weight: 800;
}
.admin-order-size-qty { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.order-stock-out {
  color: var(--danger); font-size: .64rem; font-weight: 800;
  line-height: 1.1; white-space: nowrap;
}
.order-stock-out[hidden] { display: none; }
.admin-order-size-qty input {
  width: 50px; min-height: var(--tap); height: var(--tap);
  padding: 0; text-align: center; font-weight: 800;
  border: 1.5px solid var(--border-2); border-radius: 9px;
  font-variant-numeric: tabular-nums;
}

.add-order-model-btn { margin: 1rem 0; }
.add-order-product { margin-bottom: .75rem; }
.order-invoices-top {
  padding-bottom: .85rem;
  margin-bottom: .85rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 520px) {
  .admin-order-model {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: .45rem; padding: .45rem;
  }
  .admin-order-model-image { width: 78px; min-height: 104px; }
  .admin-order-model-name { font-size: .86rem; }
  .admin-order-size { gap: .15rem; }
}

/* ── מלאי בכרטיסים זהים לקטלוג הלקוח ───────────────────── */
.stock-collection-tabs { margin-bottom: .8rem; padding-bottom: .35rem; }
.stock-product .product-img { cursor: zoom-in; }
.stock-product-top { align-items: flex-start; }
.stock-product-actions { justify-content: flex-end; }
.stock-pick, .stock-active {
  min-height: 38px; padding: .25rem .45rem;
  border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface-2);
  font-weight: 700; white-space: nowrap;
}
.stock-sizes { margin: .65rem 0; }
.stock-sizes .size input { background: var(--surface); }
.stock-sizes .size input.on { background: #ecfdf5; }
.stock-product-meta {
  display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap;
  padding-top: .55rem; margin-top: .25rem;
  border-top: 1px solid var(--border);
  font-size: .78rem; font-weight: 700;
}
.stock-product-meta .stock-active { margin-inline-start: auto; }

@media (max-width: 520px) {
  .stock-product-top { align-items: center; }
  .stock-product-actions { width: 100%; justify-content: flex-start; }
  .stock-product-meta .stock-active { margin-inline-start: 0; }
}

.order-invoices { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .6rem; }
.oi-title { font-weight: 800; font-size: .87rem; margin-bottom: .4rem; }
.inv-row {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  min-height: var(--tap);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .5rem .7rem; margin-bottom: .35rem;
  text-align: start; font-size: .87rem;
}
.inv-row:hover { background: #eff6ff; border-color: #bfdbfe; }
.inv-row .dl { color: var(--accent-ink); font-weight: 700; white-space: nowrap; }

.tag {
  display: inline-block;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .18rem .5rem; border-radius: 7px;
  font-size: .8rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── פריט בסל ─────────────────────────────────────────── */
.cart-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: .55rem;
  background: var(--surface-2);
}
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .title { font-weight: 800; font-size: .92rem; margin-bottom: .22rem; }
.cart-sizes { justify-content: flex-start; margin: .35rem 0; }
.cart-sizes .size input { width: 52px; }

/* ── פאנל צדדי ────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgb(15 23 42 / .6);
  backdrop-filter: blur(3px);
  z-index: 200;
}
.overlay.active { display: block; }

.panel {
  position: absolute; inset-block: 0; inset-inline-start: 0;
  width: min(440px, 100vw);
  background: var(--surface);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide .2s ease-out;
}
.panel.wide { width: min(820px, 100vw); }
@keyframes slide { from { transform: translateX(-100%); } to { transform: none; } }

.panel-head {
  padding: .75rem .9rem;
  padding-top: max(.75rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
  flex-shrink: 0; background: var(--surface);
}
.panel-head h3 { font-size: 1rem; font-weight: 800; }
.panel-body {
  flex: 1; overflow-y: auto; padding: .9rem;
  -webkit-overflow-scrolling: touch;
}
.panel-foot {
  padding: .9rem;
  padding-bottom: max(.9rem, var(--safe-b));
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
#cartOverlay.guest-checkout .panel { overflow-y: auto; }
#cartOverlay.guest-checkout .panel-head {
  position: sticky; top: 0; z-index: 2;
}
#cartOverlay.guest-checkout .panel-body {
  flex: none; overflow: visible;
}
#cartOverlay.guest-checkout .panel-foot { flex: none; }

/* ── מודאל ────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgb(15 23 42 / .8);
  z-index: 300;
  align-items: center; justify-content: center;
  padding: .75rem;
}
.modal.active { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 1rem;
  width: 100%; max-width: 500px;
  max-height: 90vh; max-height: 90dvh; overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-box.lg { max-width: 860px; }
.modal-box img { width: 100%; border-radius: var(--r); max-height: 68vh; object-fit: contain; }
.modal-x {
  position: absolute; top: .6rem; inset-inline-start: .6rem;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; z-index: 2;
}

/* ── ניווט תחתון ──────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  inset-inline: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 95;
  box-shadow: 0 -2px 10px rgb(15 23 42 / .06);
}
.bn-item {
  flex: 1;
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .1rem;
  color: var(--muted); font-weight: 700;
  position: relative;
}
.bn-item .ico { font-size: 1.3rem; line-height: 1; position: relative; }
.bn-item .lbl { font-size: .72rem; }
.bn-item.active { color: var(--accent-ink); }
.bn-item.active::before {
  content: ''; position: absolute; top: 0;
  inset-inline: 22%; height: 3px;
  background: var(--accent); border-radius: 0 0 3px 3px;
}
.bn-badge {
  position: absolute; top: -5px; inset-inline-end: -9px;
  background: var(--danger); color: #fff;
  border-radius: 999px; min-width: 18px; height: 18px; padding: 0 4px;
  font-size: .66rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

/* ── מצבים ────────────────────────────────────────────── */
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto .7rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

.loading, .empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty .ico { font-size: 2.2rem; margin-bottom: .5rem; opacity: .6; }

.err-msg {
  display: none;
  color: #991b1b; background: #fef2f2;
  border: 1px solid #fca5a5; border-radius: 10px;
  padding: .55rem .75rem; font-size: .87rem; margin-bottom: .8rem;
  font-weight: 600;
}
.err-msg.show { display: block; }

.note {
  background: #eff6ff; border: 1px solid #bfdbfe;
  color: #1e40af; border-radius: 10px;
  padding: .6rem .8rem; font-size: .85rem; margin-bottom: .9rem;
  line-height: 1.45;
}
.note.warn { background: #fffbeb; border-color: #fcd34d; color: #78350f; }
.note.danger { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }

/* ── טוסט ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 1rem);
  left: 50%;
  transform: translate(-50%, 200%);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background: var(--primary); color: #fff;
  padding: .7rem 1.2rem; border-radius: 999px;
  font-weight: 700; font-size: .9rem;
  box-shadow: var(--shadow-lg);
  z-index: 500; transition: transform .25s ease, opacity .2s ease;
  max-width: calc(100vw - 2rem); text-align: center;
}
.toast:empty { display: none; }
.toast.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; }
.toast.err { background: var(--danger); }

/* ── תפריט חשבון ──────────────────────────────────────── */
.menu-wrap { position: relative; }
.menu {
  display: none;
  position: absolute; top: calc(100% + .45rem); inset-inline-end: 0;
  background: var(--surface);
  /* חובה: התפריט יושב בתוך .header שצבעו #fff, והטקסט היה יורש לבן-על-לבן */
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  min-width: 245px; padding: .35rem; z-index: 120;
}
.menu.open { display: block; }
.menu .who { padding: .55rem .65rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.menu .who .name { font-weight: 800; font-size: .92rem; color: var(--text); }
.menu .who .mail { font-size: .76rem; color: var(--muted); word-break: break-all; }
.menu button {
  display: flex; align-items: center; width: 100%; text-align: start;
  min-height: var(--tap);
  padding: .5rem .65rem; border: none; background: none;
  border-radius: 8px; font-weight: 600; font-size: .9rem;
  color: var(--text);
}
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }

/* ── מד אופקי ─────────────────────────────────────────── */
.bar-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.bar-row .nm { width: 72px; font-size: .8rem; font-weight: 700; flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #60a5fa); border-radius: 6px; }
.bar-fill.green { background: linear-gradient(90deg, var(--success), #34d399); }
.bar-row .vl { width: 52px; text-align: end; font-size: .8rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ── גרירה ────────────────────────────────────────────── */
.sortable [draggable=true] { cursor: grab; }
.sortable .dragging { opacity: .45; cursor: grabbing; }
.drag-handle {
  color: var(--border-2); font-size: 1.3rem;
  cursor: grab; user-select: none; touch-action: none;
  padding: 0 .35rem; flex-shrink: 0;
  min-width: 32px; text-align: center;
}
.sort-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: .45rem;
  min-height: 60px;
}
.sort-row.dragging { border-color: var(--accent); box-shadow: var(--shadow-lg); }

.demand-customer-table tbody tr { cursor: grab; user-select: none; -webkit-user-select: none; }
.order-sort-table tbody tr { cursor: grab; user-select: none; -webkit-user-select: none; }
.demand-customer-table tbody.longpress-sort-active,
.demand-customer-table tbody.longpress-sort-active tr,
.order-sort-table tbody.longpress-sort-active,
.order-sort-table tbody.longpress-sort-active tr { cursor: grabbing; }
.demand-customer-table tbody tr.dragging,
.order-sort-table tbody tr.dragging { opacity: .24; }
.demand-customer-table tbody tr.models-checked { background: #ecfdf5; }
.demand-customer-table tbody tr.models-partial { background: #fffbeb; }
.demand-customer-main { display: inline-flex; align-items: center; gap: .45rem; }
.longpress-drag-ghost {
  position: fixed !important;
  z-index: 10020 !important;
  pointer-events: none !important;
  margin: 0 !important;
  opacity: .96;
  transform: rotate(-.25deg);
  transform-origin: center;
  border-color: var(--accent) !important;
  outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 2px;
  box-shadow: 0 20px 42px rgba(15, 23, 42, .24), 0 6px 16px rgba(37, 99, 235, .16) !important;
  transition: box-shadow .12s ease, transform .12s ease;
}
.longpress-drag-ghost-table {
  display: table !important;
  width: 100%;
  height: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}
.longpress-drag-ghost-row {
  overflow: hidden;
  border-radius: 10px;
  background: var(--surface);
}
.longpress-drag-ghost-table tbody { display: table-row-group; }
.longpress-drag-ghost-table tr { display: table-row; background: var(--surface); }
.sort-drop-before { position: relative; }
.admin-order-model.sort-drop-before::before,
.admin-order-model.sort-drop-after::after {
  content: '';
  position: absolute;
  z-index: 5;
  left: .35rem; right: .35rem;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.admin-order-model.sort-drop-before::before { top: -.42rem; }
.admin-order-model.sort-drop-after::after { bottom: -.42rem; }
.demand-customer-table tr.sort-drop-before td { border-top: 3px solid var(--accent); }
.demand-customer-table tr.sort-drop-after td { border-bottom: 3px solid var(--accent); }
.order-sort-table tr.sort-drop-before td { border-top: 3px solid var(--accent); }
.order-sort-table tr.sort-drop-after td { border-bottom: 3px solid var(--accent); }
.demand-model-check {
  width: 28px; height: 28px; min-height: 28px; flex: 0 0 28px; padding: 0;
  border: 2px solid var(--border-2); border-radius: 7px;
  background: var(--surface); color: white; font-size: 1rem; font-weight: 900;
  line-height: 1;
}
.demand-model-check.checked { background: var(--success); border-color: var(--success); }
.demand-model-check.partial { background: var(--warn); border-color: var(--warn); color: #78350f; }
.demand-model-check:disabled { opacity: .6; cursor: wait; }
.demand-mobile-summary { display: none; }
.dm-open-label { display: none; }
.demand-detail-sizes-cell { display: none; }
.demand-detail-sizes { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .45rem; }
.demand-detail-size {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
}
.demand-detail-size-qty {
  display: flex; align-items: center; justify-content: center;
  width: 46px; min-height: 40px; padding: 0 .25rem;
  border: 1.5px solid var(--border-2); border-radius: 9px;
  background: var(--surface); font-variant-numeric: tabular-nums;
}

@media (max-width: 780px) {
  .demand-sort-hint { max-width: 52%; text-align: end; }
  .responsive td.demand-detail-size-column { display: none; }
  .responsive td.demand-detail-sizes-cell {
    display: block; width: 100%; padding: .45rem .75rem;
  }
  .responsive td.demand-detail-sizes-cell::before { display: none; }
  .demand-detail-sizes { justify-content: flex-start; direction: rtl; }

  #tab-demand, #tab-demand .card, #demandTable { width: 100%; max-width: 100%; min-width: 0; }
  #tab-demand .card { overflow: hidden; }
  .demand-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .55rem;
  }
  .demand-filters > * { min-width: 0; max-width: none !important; width: 100%; }
  .demand-filters #dmModel { grid-column: 1 / -1; grid-row: 1; }
  .demand-filters label { grid-column: 1 / -1; min-height: 36px !important; }

  .demand-mobile-summary {
    display: flex; align-items: center; justify-content: space-between; gap: .45rem;
    margin: .7rem 0 .55rem; padding: .55rem .65rem;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-3); font-size: .78rem; color: var(--muted);
  }
  .demand-mobile-summary span { min-width: 0; text-align: center; }
  .demand-mobile-summary b { display: block; color: var(--text); font-size: .9rem; }
  #demandTable .demand-matrix-wrap { overflow: visible; border: 0; background: none; max-width: 100%; }
  #demandTable .demand-matrix,
  #demandTable .demand-matrix tbody { display: block; width: 100%; max-width: 100%; }
  #demandTable .demand-matrix thead,
  #demandTable .demand-matrix tfoot { display: none; }
  #demandTable .demand-matrix tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: .38rem;
    width: 100%; max-width: 100%; margin-bottom: .6rem; padding: .6rem;
    border: 1px solid var(--border); border-radius: var(--r);
    background: var(--surface); box-shadow: var(--shadow);
  }
  #demandTable .demand-matrix td {
    display: flex; align-items: center; min-width: 0;
    padding: .25rem .35rem; border: 0; text-align: start;
  }
  #demandTable .demand-matrix .dm-image { display: none; }
  #demandTable .demand-matrix .dm-model {
    order: 1; flex: 1 1 30%; padding-inline-start: 0;
    font-size: 1.05rem; overflow-wrap: anywhere;
  }
  #demandTable .demand-matrix .dm-collection {
    order: 1; flex: 1 1 34%; overflow-wrap: anywhere;
  }
  #demandTable .demand-matrix .dm-total {
    order: 1; flex: 0 0 auto; gap: .25rem;
    border-radius: 999px; background: #dbeafe; color: #1e3a8a;
  }
  #demandTable .demand-matrix .dm-total::before { content: 'סה״כ'; font-size: .72rem; }
  #demandTable .demand-matrix .dm-size {
    order: 2; flex: 1 0 52px; max-width: 76px;
    flex-direction: column; justify-content: center;
    min-height: 46px; padding: .25rem;
    border-radius: 8px; background: var(--surface-3);
    text-align: center;
  }
  #demandTable .demand-matrix .dm-size::before {
    content: attr(data-size); color: var(--muted); font-size: .7rem; font-weight: 800;
  }
  #demandTable .demand-matrix .dm-customers,
  #demandTable .demand-matrix .dm-value,
  #demandTable .demand-matrix .dm-open { order: 3; margin-top: .1rem; }
  #demandTable .demand-matrix .dm-customers::before,
  #demandTable .demand-matrix .dm-value::before {
    content: attr(data-label) ':'; margin-inline-end: .25rem;
    color: var(--muted); font-size: .72rem; font-weight: 700;
  }
  #demandTable .demand-matrix .dm-value { flex: 1 1 auto; }
  #demandTable .demand-matrix .dm-open { margin-inline-start: auto; }
  #demandTable .demand-matrix .dm-open .faint { color: var(--accent-ink); }
  #demandTable .demand-matrix .dm-open-label { display: inline; font-weight: 700; }
}

/* ── מסך התחברות ──────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  background: linear-gradient(160deg, #1e293b 0%, #334155 100%);
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.6rem 1.3rem;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  max-height: 96dvh; overflow-y: auto;
}
.auth-card .logo { text-align: center; margin-bottom: 1.3rem; }
.auth-card .logo .mark { font-size: 2.3rem; }
.auth-card .logo h1 { font-size: 1.35rem; font-weight: 800; margin-top: .25rem; }
.auth-card .logo p { font-size: .87rem; color: var(--muted); }
.divider {
  display: flex; align-items: center; gap: .7rem;
  margin: 1rem 0; color: var(--faint); font-size: .8rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.guest-order-fields { margin-bottom: 1rem; padding: .9rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.guest-exit-btn { white-space: nowrap; }

@media (max-width: 480px) {
  .guest-exit-btn { min-height: 38px; padding-inline: .55rem; }
  .guest-order-fields { padding: .75rem; }
}

/* ── מתג תצוגה: רשימה / רשת ───────────────────────────── */
.view-toggle {
  display: inline-flex; gap: 2px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 10px; padding: 2px;
  flex-shrink: 0;
}
.view-toggle button {
  min-height: 38px; padding: .3rem .6rem;
  border: none; background: none; border-radius: 8px;
  font-size: .82rem; font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; gap: .3rem;
}
.view-toggle button.on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }

/* ── קטלוג בתצוגת רשת ─────────────────────────────────── */
#productList.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}
#productList.grid .product { flex-direction: column; margin-bottom: 0; }
#productList.grid .product-img {
  width: 100%; min-width: 0;
  aspect-ratio: 1 / 1.25;
}
#productList.grid .product-body { padding: .55rem .6rem .65rem; width: 100%; }
#productList.grid .product-title { font-size: .92rem; }
#productList.grid .product-top { flex-wrap: wrap; gap: .35rem; }
#productList.grid .product-desc { -webkit-line-clamp: 1; line-clamp: 1; margin-bottom: .45rem; }
#productList.grid .sizes { gap: .3rem; }
#productList.grid .size input { width: 42px; }

/* ── כרטיס הזמנה של הלקוח ─────────────────────────────── */
.order-card.clickable { cursor: pointer; }
.order-card.clickable:hover { border-color: #bfdbfe; background: #fbfdff; }
.order-head .inv-icon {
  min-width: 38px; height: 38px; padding: 0 .5rem;
  border-radius: 9px; font-size: 1.05rem;
  background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46;
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  font-weight: 800;
}
.order-head .inv-icon:hover { background: #d1fae5; }
.order-head .inv-icon .n { font-size: .74rem; }

.sub-tabs { display: flex; gap: .4rem; margin-bottom: .9rem; }
.sub-tabs button {
  flex: 1; min-height: var(--tap);
  border: 1.5px solid var(--border-2); background: var(--surface);
  border-radius: 10px; font-weight: 700; font-size: .88rem; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.sub-tabs button.on {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.sub-tabs .n {
  background: rgb(0 0 0 / .12); border-radius: 999px;
  padding: .02rem .38rem; font-size: .74rem;
}
.sub-tabs button.on .n { background: rgb(255 255 255 / .28); }

/* שורה שסופקה בכמות שונה ממה שהוזמן — הלקוח צריך לראות את זה מיד */
tr.short td, tr.short { background: #fffbeb; }
.qty-diff { color: var(--warn); font-weight: 800; }
.admin-order-size .qty-diff {
  position: absolute; inset-block-start: 0; left: 50%;
  transform: translateX(-50%); color: var(--warn); font-size: .62rem;
  line-height: 1; font-weight: 800; white-space: nowrap;
}
.admin-order-size .qty-diff[hidden] { display: none; }

/* ── בקרת הנחה ────────────────────────────────────────── */
.disc-row { display: flex; gap: .4rem; align-items: center; flex-wrap: nowrap; }
.disc-row input[type=number] { width: 100px; min-width: 80px; text-align: center; font-weight: 800; }
.seg {
  display: inline-flex; gap: 2px;
  background: var(--surface-3); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 2px; flex-shrink: 0;
}
.seg button {
  min-width: 42px; min-height: 38px;
  border: none; background: none; border-radius: 8px;
  font-weight: 800; font-size: .9rem; color: var(--muted);
}
.seg button.on { background: var(--accent); color: #fff; }

.order-payment-summary { display: grid; gap: .35rem; }
.inline-payable { display: inline-flex; align-items: center; gap: .35rem; margin-inline-start: .35rem; }
.inline-payable input { width: 120px; min-height: 38px; padding: .35rem .55rem; font-weight: 800; }
.order-invoice-actions { margin: -.1rem 0 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }

.archive-tools { display:flex; gap:.55rem; margin-bottom:.8rem; align-items:center; }
.archive-tools > input[type="search"] { flex:1; min-width:0; }
.archive-filter-menu { position:relative; flex:none; }
.archive-filter-menu > summary { list-style:none; width:48px; min-width:48px; padding:.55rem; position:relative; cursor:pointer; }
.archive-filter-menu > summary::-webkit-details-marker { display:none; }
.archive-filter-menu[open] > summary { border-color:var(--primary); color:var(--primary); background:#eff6ff; }
.filter-icon { width:20px; height:20px; display:block; fill:currentColor; }
.filter-count { position:absolute; top:-7px; left:-7px; min-width:20px; height:20px; padding:0 5px; border-radius:999px; background:var(--primary); color:#fff; display:grid; place-items:center; font-size:.7rem; font-weight:800; }
.archive-filter-popover { position:absolute; z-index:30; top:calc(100% + .45rem); left:0; width:min(420px, calc(100vw - 40px)); padding:1rem; border:1px solid var(--border); border-radius:14px; background:var(--surface); box-shadow:0 14px 36px rgba(15,23,42,.18); display:grid; gap:.75rem; }
.archive-filter-popover label { display:grid; gap:.25rem; color:var(--muted); font-size:.78rem; font-weight:700; }
.archive-filter-dates { display:grid; grid-template-columns:1fr 1fr; gap:.6rem; }
.local-review-banner {
  position: sticky; top: .4rem; z-index: 20;
  margin-bottom: .7rem; padding: .65rem .8rem;
  border: 1px solid #f59e0b; border-radius: var(--r);
  background: #fffbeb; color: #92400e; font-size: .86rem; font-weight: 800;
  box-shadow: var(--shadow);
}

.invoice-file-link {
  border: 0; background: none; padding: .15rem 0;
  color: var(--accent-ink); font: inherit; font-weight: 800;
  text-decoration: underline; cursor: pointer; text-align: start;
}
.table-link {
  border: 0; background: none; padding: .1rem 0;
  color: var(--accent-ink); font: inherit; font-weight: 800;
  text-decoration: underline; cursor: pointer;
}
.customer-settings-summary {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  margin-top: .75rem; padding-top: .65rem; border-top: 1px solid var(--border);
}
.setting-check {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .7rem; margin-bottom: .75rem;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); cursor: pointer;
}
.setting-check input { margin-top: .15rem; flex: 0 0 auto; }
.setting-check span { display: flex; flex-direction: column; gap: .15rem; }
.setting-check small { color: var(--muted); line-height: 1.45; }

.modal-box.wide-modal { max-width: 820px; }
.invoice-preview { display: flex; flex-direction: column; gap: .8rem; }
.invoice-document-options {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem;
  padding: .75rem; border: 1px solid #bfdbfe; border-radius: var(--r); background: #eff6ff;
}
.invoice-document-options .field { margin: 0; }
.icount-cheques {
  display: flex; flex-direction: column; gap: .55rem;
}
.icount-cheque-row {
  display: grid; grid-template-columns: auto repeat(6, minmax(74px, 1fr)) auto;
  align-items: end; gap: .45rem; padding: .65rem;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
}
.icount-cheque-row label { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.icount-cheque-row label > span { font-size: .74rem; color: var(--muted); font-weight: 700; }
.icount-cheque-row input { width: 100%; min-width: 0; }
.custom-price-list { display: flex; flex-direction: column; gap: .5rem; }
.custom-price-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(130px, .45fr);
  gap: .7rem; align-items: center; padding: .7rem;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
}
.custom-price-row > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.custom-price-row small { color: var(--muted); }
.custom-price-input { display: flex; flex-direction: row-reverse; align-items: center; gap: .35rem; }
.custom-price-input input { width: 100%; min-width: 0; }
.invoice-preview-head {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem;
  padding: .75rem; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
}
.invoice-preview-head > div { display: flex; flex-direction: column; gap: .15rem; }
.invoice-totals {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem 1.2rem;
  align-self: flex-end; width: min(100%, 360px); padding: .7rem;
  background: var(--surface-2); border-radius: var(--r);
}
.invoice-totals b { text-align: left; font-variant-numeric: tabular-nums; }
.invoice-totals .invoice-grand { border-top: 1px solid var(--border-2); padding-top: .45rem; font-size: 1rem; }
.danger-note { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.invoice-confirm { margin: 0; }
.flex-invoice-line {
  display: grid;
  grid-template-columns: minmax(115px, .8fr) minmax(180px, 1.5fr) 90px 150px auto;
  gap: .55rem;
  align-items: end;
  padding: .65rem;
  margin-top: .55rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
}
.flex-invoice-line .field { margin: 0; }
.flex-line-remove { margin-bottom: 0; }

/* ── חזרות ────────────────────────────────────────────── */
.ret-line {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .6rem;
  margin-bottom: .55rem;
  background: var(--surface-2);
}
.ret-line.defective { background: #fffbeb; border-color: #fcd34d; }
.ret-line .ret-top { display: flex; gap: .45rem; align-items: flex-start; }
.ret-line .ret-top .grow { min-width: 0; }
.ret-line .field { margin-bottom: .5rem; }
.ret-line .field:last-child { margin-bottom: 0; }
/* בנייד שדה הדגם מקבל שורה משלו — שלוש עמודות היו משאירות לו 66px,
   צר מדי להקלדת מספר דגם ולרשימת ההשלמה שנפתחת מתחתיו. */
.ret-grid { display: grid; grid-template-columns: 1fr 78px; gap: .45rem; }
.ret-grid > .field:first-child { grid-column: 1 / -1; }
.ret-flags { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-top: .5rem; }
.ret-flags label { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 700; min-height: 38px; }

.photo-slot { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.photo-slot img {
  width: 56px; height: 56px; border-radius: 9px; object-fit: cover;
  border: 1px solid var(--border);
}
.cam-btn {
  min-height: 40px; padding: .35rem .7rem;
  border: 1.5px dashed var(--border-2); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: .85rem;
  display: inline-flex; align-items: center; gap: .35rem;
}
.cam-btn:hover { background: var(--surface-2); border-color: var(--accent); }
.cam-btn input[type=file] { display: none; }

.ret-preview {
  width: 44px; height: 44px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-3);
}

.return-model-picker { display: flex; gap: .5rem; margin: .7rem 0 1rem; }
.return-model-picker input { flex: 1; min-width: 0; }
.return-entry-card { padding: .75rem; }
.return-entry-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .7rem; }
.return-entry-image {
  width: 66px; height: 82px; flex: 0 0 66px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3);
}
.return-entry-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.return-entry-image .img-ph { height: 100%; display: grid; place-items: center; }
.return-entry-sizes { padding: .65rem 0; border-top: 1px solid var(--border); }
.return-empty { margin-bottom: 1rem; }
.return-detail-tabs { margin: .8rem 0; }
.return-model-list { display: grid; gap: .6rem; }
.return-model-card { margin-bottom: 0; }
.return-model-card.defective { background: #fffbeb; border-color: #fcd34d; }
.return-model-notes, .return-photo-strip { grid-column: 2 / -1; }
.return-photo-strip { display: flex; gap: .4rem; flex-wrap: wrap; }
.return-discount-status { min-width: 92px; }
.return-discount-status.danger-text { color: var(--danger); font-weight: 700; }

@media (max-width: 520px) {
  .return-model-picker { align-items: stretch; }
  .return-model-picker .btn { padding-inline: .65rem; }
  .return-entry-sizes .size { flex: 1 0 42px; }
  .return-model-notes, .return-photo-strip { grid-column: 1 / -1; }
}

/* ── בחירה מרובה במלאי ────────────────────────────────── */
.bulk-bar {
  display: none;
  position: sticky; top: 0; z-index: 5;
  align-items: center; gap: .6rem; flex-wrap: wrap;
  background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: var(--r); padding: .55rem .7rem; margin-bottom: .7rem;
  font-size: .88rem; font-weight: 700; color: #1e40af;
}
.bulk-bar.on { display: flex; }
td.pick, th.pick { width: 38px; text-align: center; }
@media (max-width: 780px) {
  .responsive td.pick { justify-content: flex-start; }
  .archive-tools { grid-template-columns: 1fr; }
  .invoice-document-options { grid-template-columns: 1fr; }
  .icount-cheque-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .icount-cheque-row > .chip { justify-self: start; }
  .custom-price-row { grid-template-columns: minmax(0, 1fr) auto; }
  .custom-price-input { grid-column: 1 / -1; }
  .invoice-preview-head { grid-template-columns: 1fr; }
  .flex-invoice-line { grid-template-columns: 1fr 1fr; }
  .flex-description-field { grid-column: 1 / -1; }
  .flex-line-remove { grid-column: 1 / -1; width: 100%; }
  .inline-payable { display: flex; margin: .35rem 0 0; }
  .inline-payable input { flex: 1; width: auto; }
}

@media (max-width: 520px) {
  .container { padding-inline: .5rem; padding-top: .65rem; }
  .card { padding: .75rem; margin-bottom: .75rem; }
  .panel-body, .panel-foot { padding: .65rem; }

  .act-row { align-items: stretch; flex-direction: column; }
  .act-row > .row { width: 100%; flex-wrap: nowrap; }
  .act-row > .row .btn {
    flex: 1;
    min-width: 0;
    padding-inline: .4rem;
  }
  .act-row > .row .btn.invoice-upload-compact { flex: 0 0 40px; }

  .profit-exclusion-summary > .row { align-items: stretch; flex-direction: column; }
  .profit-exclusion-summary .btn { width: 100%; }

  #tab-orders .card > h2 .grow,
  #tab-demand .card > h2 .grow,
  #tab-stock .card > h2 .grow,
  #tab-customers .card > h2 .grow,
  #tab-invoices .card > h2 .grow {
    flex-basis: 100%;
    height: 0;
  }
  #tab-orders .card > h2 .btn,
  #tab-demand .card > h2 .btn,
  #tab-stock .card > h2 .btn,
  #tab-customers .card > h2 .btn,
  #tab-invoices .card > h2 .btn {
    flex: 1;
    min-width: 0;
    padding-inline: .4rem;
  }
}

/* ── דסקטופ ───────────────────────────────────────────── */
@media (min-width: 781px) {
  #productList.grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
  #productList.grid .size input { width: 46px; }
  .ret-grid { grid-template-columns: 1fr 120px 100px; }
  .ret-grid > .field:first-child { grid-column: auto; }
  body { font-size: 15px; }
  .container { padding: 1.5rem 1rem 2rem; }
  .card { padding: 1.25rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: .75rem; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: .8rem; }
  .kpi { padding: .95rem 1.05rem; }
  .kpi .value { font-size: 1.55rem; }
  .product-img { width: 124px; min-width: 124px; }
  .bottom-nav { display: none; }
  .toast { bottom: 1.2rem; }
  thead th { position: sticky; top: 0; z-index: 2; }
  .bar-row .nm { width: 105px; }
}

@media print {
  .header, .tabs, .btn, .icon-btn, .overlay, .toast, .bottom-nav, .admin-banner { display: none !important; }
  .card, .order-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  body { background: #fff; }
}
.product-image-source{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.55rem;align-items:center}
.product-image-pick{white-space:nowrap;min-height:44px}
.product-image-hint{margin-top:.4rem;line-height:1.45}
@media(max-width:560px){
  .product-image-source{grid-template-columns:1fr}
  .product-image-pick{width:100%}
}
